I encountered a situation in my code where a message was written to a message buffer that was longer than the count specified in the call to xMessageBufferReceive. As documented, this caused the return value to be 0 and the message to be left in the buffer. While I will make changes to my code to prevent the too long message from being written, I was wondering if there is a way to discard a message in the message buffer, short of doing xMessageBufferReset. It seems like this would be useful in some error recovery situations.
I don’t think that should happen in the first place.
Which version of FreeRTOS are you using?
Are you writing to the message buffer from more than one task or from tasks and interrupts?
If 0 was returned, what makes you think the message was left in the buffer.
Which documentation are you referring to?
Re-reading my message, perhaps I wasn’t clear. A long message is written using xMessageBufferSendFromISR. The receiving task is not expecting a message of this length, so the call to xMessageBufferReceive returns 0, and the message is left in the message buffer.
No, messages are sent from a single place in an interrupt routine using xMessageBufferSendFromISR.