Remove specific item from FreeRTOS queue

Is there possibly any way that I can use a FreeRTOS queue in which I can load up several items and then cherry pick and remove certain items other than doing a queuePeek which only lets me know what is coming up next in the queue? In other words, if I have 3 items on a queue (0, 1, 2) and I want to delete item in position 1 and then have item 2 become the new item 1, is there an easy way to do this? I’ve looked through the API queue library and have only been able to come up with an algorithm which receives the whole queue on a temporary buffer, deletes an item, then dumps the new contents of the buffer back onto the queue 🙁

Remove specific item from FreeRTOS queue

The API is designed to work as a queue, although there are mechanisms to break the first in first out paradigm in some places (for example, posting urgent data to the front of the queue, or peak data) there is no mechanism that can allow a queue to be used as a generic buffer from which data can be inserted or removed from any position. The actual data in a queue is in a circular buffer, so you could hack your own way of doing this. You would need to see the internal structure of the queue itself, which due to data hiding, would mean you would have to add your code into the queue.c source file. However, consider using other mechanisms too as it doesn’t sound like a queue is actually what you want. You could for example use a linked list. Although not part of the public API and therefore not documented the linked list implementation used internally be FreeRTOS can be used by application code. See list.c and list.h. You could of course always implement your own buffering mechanism.

Remove specific item from FreeRTOS queue

Thanks guys.