FreeRTOS-Cpp
|
Base class that provides the standard queue interface to FreeRTOS::Queue and FreeRTOS::StaticQueue. More...
#include <FreeRTOS/Queue.hpp>
Public Member Functions | |
QueueBase (const QueueBase &)=delete | |
QueueBase & | operator= (const QueueBase &)=delete |
bool | isValid () const |
Function that checks if the underlying queue handle is not NULL. This should be used to ensure a queue has been created correctly. More... | |
bool | sendToBack (const T &item, const TickType_t ticksToWait=portMAX_DELAY) const |
Function that calls xQueueSendToBack( xQueue, pvItemToQueue, xTicksToWait ) More... | |
bool | sendToBackFromISR (bool &higherPriorityTaskWoken, const T &item) const |
Function that calls xQueueSendToBackFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) More... | |
bool | sendToBackFromISR (const T &item) const |
Function that calls xQueueSendToBackFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) More... | |
bool | sendToFront (const T &item, const TickType_t ticksToWait=portMAX_DELAY) const |
Function that calls xQueueSendToFront( xQueue, pvItemToQueue, xTicksToWait ) More... | |
bool | sendToFrontFromISR (bool &higherPriorityTaskWoken, const T &item) const |
Function that calls xQueueSendToFrontFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) More... | |
bool | sendToFrontFromISR (const T &item) const |
Function that calls xQueueSendToFrontFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) More... | |
std::optional< T > | receive (const TickType_t ticksToWait=portMAX_DELAY) const |
Function that calls BaseType_t xQueueReceive( QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait ) More... | |
std::optional< T > | receiveFromISR (bool &higherPriorityTaskWoken) const |
Function that calls BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue, void *pvBuffer, BaseType_t *pxHigherPriorityTaskWoken ) More... | |
std::optional< T > | receiveFromISR () const |
Function that calls BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue, void *pvBuffer, BaseType_t *pxHigherPriorityTaskWoken ) More... | |
UBaseType_t | messagesWaiting () const |
Function that calls UBaseType_t uxQueueMessagesWaiting( QueueHandle_t xQueue ) More... | |
UBaseType_t | messagesWaitingFromISR () const |
Function that calls UBaseType_t uxQueueMessagesWaitingFromISR( QueueHandle_t xQueue ) More... | |
UBaseType_t | spacesAvailable () const |
Function that calls UBaseType_t uxQueueSpacesAvailable( QueueHandle_t xQueue ) More... | |
void | reset () const |
Function that calls BaseType_t xQueueReset( QueueHandle_t xQueue ) More... | |
void | overwrite (const T &item) const |
Function that calls BaseType_t xQueueOverwrite( QueueHandle_t xQueue, const void * pvItemToQueue ) More... | |
void | overwriteFromISR (bool &higherPriorityTaskWoken, const T &item) const |
Function that calls BaseType_t xQueueOverwriteFromISR( QueueHandle_t xQueue, const void * pvItemToQueue, BaseType_t *pxHigherPriorityTaskWoken ) More... | |
void | overwriteFromISR (const T &item) const |
Function that calls BaseType_t xQueueOverwriteFromISR( QueueHandle_t xQueue, const void * pvItemToQueue, BaseType_t *pxHigherPriorityTaskWoken ) More... | |
std::optional< T > | peek (const TickType_t ticksToWait=portMAX_DELAY) const |
Function that calls BaseType_t xQueuePeek( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait ) More... | |
std::optional< T > | peekFromISR () const |
Function that calls BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void *pvBuffer ) More... | |
void | addToRegistry (const char *name) const |
Function that calls void vQueueAddToRegistry( QueueHandle_t xQueue, char *pcQueueName ) More... | |
void | unregister () const |
Function that calls void vQueueUnregisterQueue( QueueHandle_t xQueue ) More... | |
const char * | getName () const |
Function that calls const char *pcQueueGetName( QueueHandle_t xQueue ) More... | |
bool | isFullFromISR () const |
Function that calls BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) More... | |
bool | isEmptyFromISR () const |
Function that calls BaseType_t xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue ) More... | |
Private Member Functions | |
QueueBase ()=default | |
Construct a new QueueBase object. More... | |
~QueueBase () | |
Destroy the QueueBase object by calling void vQueueDelete( QueueHandle_t xQueue ) More... | |
QueueBase (QueueBase &&) noexcept=default | |
QueueBase & | operator= (QueueBase &&) noexcept=default |
Private Attributes | |
QueueHandle_t | handle = NULL |
Handle used to refer to the queue when using the FreeRTOS interface. | |
Friends | |
template<class > | |
class | Queue |
template<class , UBaseType_t > | |
class | StaticQueue |
Base class that provides the standard queue interface to FreeRTOS::Queue and FreeRTOS::StaticQueue.
T | Type to be stored in the queue. |
|
privatedefault |
Construct a new QueueBase object.
|
inlineprivate |
Destroy the QueueBase object by calling void vQueueDelete( QueueHandle_t xQueue )
Delete a queue - freeing all the memory allocated for storing of items placed on the queue.
|
inline |
Function that calls void vQueueAddToRegistry( QueueHandle_t xQueue, char *pcQueueName )
The registry is provided as a means for kernel aware debuggers to locate queues, semaphores and mutexes. Call addToRegistry() add a queue, semaphore or mutex handle to the registry if you want the handle to be available to a kernel aware debugger. If you are not using a kernel aware debugger then this function can be ignored.
configQUEUE_REGISTRY_SIZE defines the maximum number of handles the registry can hold. configQUEUE_REGISTRY_SIZE must be greater than 0 within FreeRTOSConfig.h for the registry to be available. Its value does not effect the number of queues, semaphores and mutexes that can be created - just the number that the registry can hold.
If addToRegistry() is called more than once for the same queue, the registry will store the name parameter from the most recent call to addToRegistry().
name | The name to be associated with the handle. This is the name that the kernel aware debugger will display. The queue registry only stores a pointer to the string - so the string must be persistent (global or preferably in ROM/Flash), not on the stack. |
|
inline |
Function that calls const char *pcQueueGetName( QueueHandle_t xQueue )
The queue registry is provided as a means for kernel aware debuggers to locate queues, semaphores and mutexes. Call getName() to look up and return the name of a queue in the queue registry from the queue's handle.
|
inline |
Function that calls BaseType_t xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue )
Queries a queue to determine if the queue is empty. This function should only be used in an ISR.
true | if the queue is empty. |
false | if the queue is not empty. |
|
inline |
Function that calls BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue )
Queries a queue to determine if the queue is empty. This function should only be used in an ISR.
|
inline |
Function that checks if the underlying queue handle is not NULL. This should be used to ensure a queue has been created correctly.
true | the handle is not NULL. |
false | the handle is NULL. |
|
inline |
Function that calls UBaseType_t uxQueueMessagesWaiting( QueueHandle_t xQueue )
Return the number of messages stored in a queue.
UBaseType_t | The number of messages available in the queue. |
|
inline |
Function that calls UBaseType_t uxQueueMessagesWaitingFromISR( QueueHandle_t xQueue )
A version of messagesWaiting() that can be called from an ISR. Return the number of messages stored in a queue.
UBaseType_t | The number of messages available in the queue. |
|
inline |
Function that calls BaseType_t xQueueOverwrite( QueueHandle_t xQueue, const void * pvItemToQueue )
Only for use with queues that have a length of one - so the queue is either empty or full.
Post an item on a queue. If the queue is already full then overwrite the value held in the queue. The item is queued by copy, not by reference.
This function must not be called from an interrupt service routine. See overwriteFromISR() for an alternative which may be used in an ISR.
item | A reference to the item that is to be placed on the queue. |
Example Usage
|
inline |
Function that calls BaseType_t xQueueOverwriteFromISR( QueueHandle_t xQueue, const void * pvItemToQueue, BaseType_t *pxHigherPriorityTaskWoken )
A version of overwrite() that can be used in an interrupt service routine (ISR).
Only for use with queues that can hold a single item - so the queue is either empty or full.
Post an item on a queue. If the queue is already full then overwrite the value held in the queue. The item is queued by copy, not by reference.
higherPriorityTaskWoken | A reference that will be set to true if sending to the queue caused a task to unblock, and the unblocked task has a priority higher than the currently running task. |
item | A reference to the item that is to be placed on the queue. |
Example Usage
|
inline |
Function that calls BaseType_t xQueueOverwriteFromISR( QueueHandle_t xQueue, const void * pvItemToQueue, BaseType_t *pxHigherPriorityTaskWoken )
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Function that calls BaseType_t xQueuePeek( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait )
Receive an item from a queue without removing the item from the queue.
Successfully received items remain on the queue so will be returned again by the next call, or a call to receive().
This function must not be used in an interrupt service routine. See peekFromISR() for an alternative that can be called from an interrupt service routine.
ticksToWait | The maximum amount of time the task should block waiting for an item to receive should the queue be empty at the time of the call. Setting ticksToWait to 0 will cause the function to return immediately if the queue is empty. The time is defined in tick periods so the constant portTICK_PERIOD_MS should be used to convert to real time if this is required. |
Example Usage
|
inline |
Function that calls BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void *pvBuffer )
A version of peek() that can be called from an interrupt service routine (ISR).
Receive an item from a queue without removing the item from the queue.
Successfully received items remain on the queue so will be returned again by the next call, or a call to receive().
|
inline |
Function that calls BaseType_t xQueueReceive( QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait )
Receive an item from a queue. This function must not be used in an interrupt service routine. See receiveFromISR() for an alternative that can.
ticksToWait | The maximum amount of time the task should block waiting for an item to receive should the queue be empty at the time of the call. Setting ticksToWait to 0 will cause the function to return immediately if the queue is empty. The time is defined in tick periods so the constant portTICK_PERIOD_MS should be used to convert to real time if this is required. |
Example Usage
|
inline |
Function that calls BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue, void *pvBuffer, BaseType_t *pxHigherPriorityTaskWoken )
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Function that calls BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue, void *pvBuffer, BaseType_t *pxHigherPriorityTaskWoken )
Receive an item from a queue. It is safe to use this function from within an interrupt service routine.
higherPriorityTaskWoken | A reference that will be set to true if sending to the queue caused a task to unblock, and the unblocked task has a priority higher than the currently running task. |
Example Usage
|
inline |
Function that calls BaseType_t xQueueReset( QueueHandle_t xQueue )
Resets a queue to its original empty state.
|
inline |
Function that calls xQueueSendToBack( xQueue, pvItemToQueue, xTicksToWait )
Post an item to the back of a queue. The item is queued by copy, not by reference. This function must not be called from an interrupt service routine. See FreeRTOS::Queue::sendToBackFromISR() for an alternative which may be used in an ISR.
item | A reference to the item that is to be placed on the queue. |
ticksToWait | The maximum amount of time the task should block waiting for space to become available on the queue, should it already be full. The call will return immediately if this is set to 0 and the queue is full. The time is defined in tick periods so the constant portTICK_PERIOD_MS should be used to convert to real time if this is required. |
true | if the item was successfully posted. |
false | otherwise. |
Example Usage
|
inline |
Function that calls xQueueSendToBackFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken )
higherPriorityTaskWoken | A reference that will be set to true if sending to the queue caused a task to unblock, and the unblocked task has a priority higher than the currently running task. |
item | A reference to the item that is to be placed on the queue. |
true | if the item was successfully posted |
false | otherwise. |
Example Usage
|
inline |
Function that calls xQueueSendToBackFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken )
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Function that calls xQueueSendToFront( xQueue, pvItemToQueue, xTicksToWait )
item | A reference to the item that is to be placed on the queue. |
ticksToWait | The maximum amount of time the task should block waiting for space to become available on the queue, should it already be full. The call will return immediately if this is set to 0 and the queue is full. The time is defined in tick periods so the constant portTICK_PERIOD_MS should be used to convert to real time if this is required. |
true | if the item was successfully posted. |
false | otherwise. |
Example Usage
|
inline |
Function that calls xQueueSendToFrontFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken )
higherPriorityTaskWoken | A reference that will be set to true if sending to the queue caused a task to unblock, and the unblocked task has a priority higher than the currently running task. |
item | A reference to the item that is to be placed on the queue. |
true | if the item was successfully posted |
false | otherwise. |
Example Usage
|
inline |
Function that calls xQueueSendToFrontFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken )
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Function that calls UBaseType_t uxQueueSpacesAvailable( QueueHandle_t xQueue )
Return the number of free spaces in a queue.
UBaseType_t | The number of free spaces available in the queue. |
|
inline |
Function that calls void vQueueUnregisterQueue( QueueHandle_t xQueue )
The registry is provided as a means for kernel aware debuggers to locate queues, semaphores and mutexes. Call addToRegistry() add a queue, semaphore or mutex handle to the registry if you want the handle to be available to a kernel aware debugger, and unregister() to remove the queue, semaphore or mutex from the register. If you are not using a kernel aware debugger then this function can be ignored.