xQueueReceive return value

rrrum wrote on Saturday, June 27, 2015:

After queue is created and then used to receive with Maximum delay parameter as in example bellow:

xStatus = xQueueReceive( xReceiveTestprocess, &evt, portMAX_DELAY);

if(xStatus == pdPASS ){


I would like to optimize code. Should return value always be tested for pdPASS before processing received data as shown in some examples? I mean xQueueReceive can ever return errQUEUE_EMPTY if maximum delay is specified?
What do you recommend?

rtel wrote on Saturday, June 27, 2015:

If you block indefinitely using portMAX_DELAY then you don’t need to check the return value because, as you say, it will only return if data was received.

Although lots of examples use infinite block times for simplicity, it is not recommended to use infinite delays in real code is they offer no neat method of recovering from errors (for example if something had happened that meant data was never posted to your queue the task would carry on blocking indefinitely so you would need another task to check for the error condition).

Note portMAX_DELAY is only an infinite block time if configINCLUDE_vTaskSuspend is set to 1.