Can xQueueReceive Fail When xTicksToWait = portMAX_DELAY?
Let's Imagine I Have This Kind of Event Loop: Mytype_T Object; While(True) { xQueueReceive(QHandle, &Object, portMAX_DELAY); doSomething(object); } the...
Let's imagine I have this kind of event loop :
MyType_t object;
while(true) {
xQueueReceive(QHandle, &object, portMAX_DELAY);
doSomething(object);
}
The documentation () stipulates :
If INCLUDE_vTaskSuspend is set to ‘1’ then specifying the block time as portMAX_DELAY will cause the task to block indefinitely (without a timeout).
To me, this means that it will always wait until it can receive a value, which means it can never fail to receive a value, but I may be wrong.
Is it necessary to check for xQueueReceive failure ? If it is, what are the failure modes ?
1 Answer
Suspending a task allows truly indefinite blocking on a queue. Otherwise it returns with timeout after portMAX_DELAY ticks which is usually very, very long.
If the slightly increased code size setting INCLUDE_vTaskSuspend to 1 doesn’t matter I’d propose to do so.
Although receiving from a queue with indefinite timeout can’t fail it’s good style to check the return code.