Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

Remove specific item from FreeRTOS queue

Posted by exgreyfox on October 19, 2016

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

Posted by rtel on October 19, 2016

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

Posted by exgreyfox on October 20, 2016

Thanks guys.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS