xQueueReceive Assert Failed

Lancsrick
Posts: 30
Joined: Mon Apr 10, 2023 5:48 pm

xQueueReceive Assert Failed

Postby Lancsrick » Mon Jul 17, 2023 8:57 am

I'm having an issue with the code below (just extracted the relevant bits). It compiles and flashes fine, but then goes into a boot loop with the error of assert failed: xQueueReceive IDF\components\freertos\queue.c:1382 (( pxQueue )). Any help would be appreciated!

Code: Select all

QueueHandle_t red_line_queue;



void IRAM_ATTR isr_function( void *arg) 
{
   const int64_t time = esp_timer_get_time(); // store the "data" we want to enqueue into a local variable
   BaseType_t shouldYield = pdFALSE; // declare and initialize another local variable for the pxHigherPriorityTaskWoken argument
   
   xQueueSendFromISR(
       red_line_queue,
       &time, // pass a *pointer* to our data (local variable) to the function; the data pointed-to will be *copied* into the queue
       &shouldYield); // pass a *pointer* to the shouldYield local variable (= shouldYield is used as an output parameter)

   // If some task was waiting on our queue and should now be switched to,
   // xQueueSendFromISR will have set our shouldYield variable to pdTRUE       
   if(shouldYield != pdFALSE) {
       // let FreeRTOS know that we want it to switch tasks now
       portYIELD_FROM_ISR();
   }
}



int queue_time_1; //also tried long instead of int



void app_main()
{
 while (1)
    {
        printf("\n");
        if(xQueueReceive(red_line_queue, &(queue_time_1), (TickType_t)0))
        {
        printf("Data received from queue");
        }
        printf(queue_time_1);
        
        
      
    }
}


ESP_Dazz
Posts: 308
Joined: Fri Jun 02, 2017 6:50 am

Re: xQueueReceive Assert Failed

Postby ESP_Dazz » Mon Jul 17, 2023 9:27 am

Where do you call xQueueCreate() to actually create the queue?

Lancsrick
Posts: 30
Joined: Mon Apr 10, 2023 5:48 pm

Re: xQueueReceive Assert Failed

Postby Lancsrick » Mon Jul 17, 2023 9:44 am

Well that might be the root of my problem then.... Surprised it compiled without that! I'll make the amendments later and see if that sorts it. Thanks.

Lancsrick
Posts: 30
Joined: Mon Apr 10, 2023 5:48 pm

Re: xQueueReceive Assert Failed

Postby Lancsrick » Mon Jul 17, 2023 10:17 am

Tried creation through both xQueuehandle and xQueueCreate and not had any change with either approach sadly.

ESP_Dazz
Posts: 308
Joined: Fri Jun 02, 2017 6:50 am

Re: xQueueReceive Assert Failed

Postby ESP_Dazz » Mon Jul 17, 2023 10:35 am

Code: Select all

QueueHandle_t red_line_queue;
This simply declares a Queue handle, and does not create a queue.

Before attempting use "red_line_queue" in any queue function, you need to ensure that the queue is created. You can do this by calling `xQueueCreate()` which creates a queue and returns a handle to the created queue. So somewhere in your startup routine in app_main, add this:

Code: Select all

void app_main()
{
    ...
    red_line_queue = xQueueCreate(...);  // Size of queue items and number of items is set on creation
    ...
}

Lancsrick
Posts: 30
Joined: Mon Apr 10, 2023 5:48 pm

Re: xQueueReceive Assert Failed

Postby Lancsrick » Mon Jul 17, 2023 10:47 am

Thanks, I've now added this to the top of app_main()

Code: Select all

red_line_queue = xQueueCreate (10, sizeof(unsigned int));
and we're onto a new error now! (facepalm).

Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.


Wondering if I need to scrap all my code for this and copy-paste a working example and go from there...

ESP_Dazz
Posts: 308
Joined: Fri Jun 02, 2017 6:50 am

Re: xQueueReceive Assert Failed

Postby ESP_Dazz » Mon Jul 17, 2023 10:57 am

Could you provide the backtrace log?

Lancsrick
Posts: 30
Joined: Mon Apr 10, 2023 5:48 pm

Re: xQueueReceive Assert Failed

Postby Lancsrick » Mon Jul 17, 2023 11:02 am

Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.

Core 0 register dump:
PC : 0x400d9daa PS : 0x00060c30 A0 : 0x800d61b4 A1 : 0x3ffb4700
A2 : 0x00000000 A3 : 0x00000000 A4 : 0x00000000 A5 : 0x00000000
A6 : 0x3ffb4a20 A7 : 0x00000004 A8 : 0x3ffaeb58 A9 : 0x3ffaeb58
A10 : 0x3ffaecec A11 : 0x3ffb4710 A12 : 0x000000ff A13 : 0x0000ff00
A14 : 0x00ff0000 A15 : 0xff000000 SAR : 0x0000001b EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xffffffff


Backtrace: 0x400d9da7:0x3ffb4700 0x400d61b1:0x3ffb4a10 0x400d0c8f:0x3ffb4a60 0x400e52ff:0x3ffb4a80 0x400880bd:0x3ffb4aa0

ESP_Dazz
Posts: 308
Joined: Fri Jun 02, 2017 6:50 am

Re: xQueueReceive Assert Failed

Postby ESP_Dazz » Mon Jul 17, 2023 11:11 am

Could decode the backtrace using "addr2line" to find the function/line numbers in the backtrace (idf.py monitor will automatically decode the backtrace for you).

Lancsrick
Posts: 30
Joined: Mon Apr 10, 2023 5:48 pm

Re: xQueueReceive Assert Failed

Postby Lancsrick » Mon Jul 17, 2023 11:25 am

Will do but it will be later on I'm afraid as I'll have to read up on how to do that!

Thank you for all this help :).

Who is online

Users browsing this forum: No registered users and 138 guests