I know this seems like a silly question but I just wanted to confirm what xQueueReceive does when it removes an item
the Mastering the FreeRTOS™ Real Time Kernel document says:
The item that is received is removed from the queue.
but it is a bit vague on what that means, particularly when an item is removed does it clear the buffer completely or is the data still there until it overwritten? and if it is, is there any risk of that data being included when the overwriting data is smaller than the buffer?
Any answers appreciated, but if anyone can find documentation that goes into depth on what xQueueReceive does I would be very happy.
The data is removed in the sense that if you ask the queue for an item, the queue knows the item isn’t there any longer. It does not “waste” the time to physically clear the old values.
This means that it might not be suitable if the data really need “cryptoraphic” security, but most applications don’t.
thank you
do you know if it clears the old values when xQueueSend puts data into an item that was removed? or does the Queue remember how much data it put into the item and only retrieve what was put into it?
I’m working with strings of varying lengths, so I just wanted to be sure that I wouldn’t get any old data appended to smaller strings. (It hasn’t happened yet but it would be nice to know what stops that from happening.)
There is simply no way queueing variable sized items into a queue.
It does fixed size memcpy of items in and out. See the prvCopyDataToQueue implementation.
You might want to consider
If you defined the queue for some fixed sized array of char, then it will always copy that big of an array of char into and out of the queue. Since that array includes the NUL terminating character, when it copies out the data, it will copy that NUL so your program won’t “see” the extra data.