Page 1 of 1

Missing items in queues

Posted: Thu Nov 29, 2018 8:57 am
by NevynSelby
I have some code with multiple tasks and queues and I'm creating some test data and the application is exhibiting some odd behaviour.

Basic principle, the main application posts a series of messages to a queue (UARTTaskQueue). A task, UARTTxTask, waits on the queue and retrieves the messages being posted. It then sends the bytes in the message over the UART.

Should be simple.

The odd behaviour I am seeing is the fact that odd numbered messages go into the queue and the UARTTxTask processes the messages as expected. The even numbered messages appear to go into the queue but they do not get processed, they seem to go into the queue and then disappear.

I have put some debug statements around the post message statement (xQueueSendToBack) and uxQueueMessagesWaiting shows an increase in the number of messages in the queue.

I can get the application to work as expected if I add a vTaskDelay call prior to posting the data.

Has anyone seen this before? Any pointers to what I need to do to get the expected behaviour?

Regards,
Mark

Re: Missing items in queues

Posted: Thu Nov 29, 2018 5:49 pm
by permal
Are you checking the return value of xQueueSendToBack?

It sounds to me that you're posting more messages than fit in the queue, i.e. not reading the queue quickly enough.

Re: Missing items in queues

Posted: Fri Nov 30, 2018 10:55 am
by NevynSelby
I think you are right about the timing issue, I did some optimisation yesterday and it looks to be performing as expected. I'll see how it does under stress testing :)

Thanks for your time,
Mark

Re: Missing items in queues

Posted: Fri Nov 30, 2018 1:35 pm
by permal
Check the return value and you'll know for sure if you're dropping items.