FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [June 2015 Threads] xQueueReceive return valuePosted by rrrum on 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?
Thanks
xQueueReceive return valuePosted by rtel on 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 portMAXDELAY is only an infinite block time if configINCLUDEvTaskSuspend is set to 1.
Regards.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|