FreeRTOS-Cpp
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
FreeRTOS::StaticStreamBuffer< N > Class Template Reference

Class that encapsulates the functionality of a FreeRTOS stream buffer. More...

#include <FreeRTOS/StreamBuffer.hpp>

Inheritance diagram for FreeRTOS::StaticStreamBuffer< N >:
Inheritance graph
[legend]
Collaboration diagram for FreeRTOS::StaticStreamBuffer< N >:
Collaboration graph
[legend]

Public Member Functions

 StaticStreamBuffer (const size_t triggerLevel=0)
 Construct a new StaticStreamBuffer object by calling StreamBufferHandle_t xStreamBufferCreateStatic( size_t xBufferSizeBytes, size_t xTriggerLevelBytes, uint8_t *pucStreamBufferStorageArea, StaticStreamBuffer_t *pxStaticStreamBuffer )
 
 StaticStreamBuffer (const StaticStreamBuffer &)=delete
 
StaticStreamBufferoperator= (const StaticStreamBuffer &)=delete
 
 StaticStreamBuffer (StaticStreamBuffer &&) noexcept=default
 
StaticStreamBufferoperator= (StaticStreamBuffer &&) noexcept=default
 
- Public Member Functions inherited from FreeRTOS::StreamBufferBase
 StreamBufferBase (const StreamBufferBase &)=delete
 
StreamBufferBaseoperator= (const StreamBufferBase &)=delete
 
bool isValid () const
 Function that checks if the underlying stream buffer handle is not NULL. This should be used to ensure a stream buffer has been created correctly.
 
size_t send (const void *data, const size_t length, const TickType_t ticksToWait=portMAX_DELAY) const
 Function that calls size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, TickType_t xTicksToWait )
 
size_t sendFromISR (bool &higherPriorityTaskWoken, const void *data, const size_t length) const
 Function that calls size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, BaseType_t *pxHigherPriorityTaskWoken )
 
size_t sendFromISR (const void *data, const size_t length) const
 Function that calls size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, BaseType_t *pxHigherPriorityTaskWoken )
 
size_t receive (void *buffer, const size_t bufferLength, const TickType_t ticksToWait=portMAX_DELAY) const
 Function that calls size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, TickType_t xTicksToWait )
 
size_t receiveFromISR (bool &higherPriorityTaskWoken, void *buffer, const size_t bufferLength) const
 Function that calls size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, BaseType_t *pxHigherPriorityTaskWoken )
 
size_t receiveFromISR (void *buffer, const size_t bufferLength) const
 Function that calls size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, BaseType_t *pxHigherPriorityTaskWoken )
 
size_t bytesAvailable () const
 Function that calls size_t xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer )
 
size_t spacesAvailable () const
 Function that calls size_t xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer )
 
bool setTriggerLevel (const size_t triggerLevel=0) const
 Function that calls BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel )
 
bool reset () const
 Function that calls BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer )
 
bool isEmpty () const
 Function that calls BaseType_t xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer )
 
bool isFull () const
 Function that calls BaseType_t xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer )
 

Private Attributes

StaticStreamBuffer_t staticStreamBuffer
 
uint8_t storage [N]
 

Additional Inherited Members

- Static Public Member Functions inherited from FreeRTOS::StreamBufferBase
static void * operator new (size_t)=delete
 
static void * operator new[] (size_t)=delete
 
static void * operator new (size_t, void *ptr)
 
static void * operator new[] (size_t, void *ptr)
 

Detailed Description

template<size_t N>
class FreeRTOS::StaticStreamBuffer< N >

Class that encapsulates the functionality of a FreeRTOS stream buffer.

If a stream buffer is created using this class then the RAM is provided by the application writer as part of the object instance and allows the RAM to be statically allocated at compile time.

Template Parameters
NThe size, in bytes, of the storage buffer for the stream buffer.

Constructor & Destructor Documentation

◆ StaticStreamBuffer()

template<size_t N>
FreeRTOS::StaticStreamBuffer< N >::StaticStreamBuffer ( const size_t  triggerLevel = 0)
inlineexplicit

Construct a new StaticStreamBuffer object by calling StreamBufferHandle_t xStreamBufferCreateStatic( size_t xBufferSizeBytes, size_t xTriggerLevelBytes, uint8_t *pucStreamBufferStorageArea, StaticStreamBuffer_t *pxStaticStreamBuffer )

StreamBuffer.hpp

See also
https://www.freertos.org/xStreamBufferCreateStatic.html
Parameters
triggerLevelThe number of bytes that must be in the stream buffer before a task that is blocked on the stream buffer to wait for data is moved out of the blocked state. For example, if a task is blocked on a read of an empty stream buffer that has a trigger level of 1 then the task will be unblocked when a single byte is written to the buffer or the task's block time expires. As another example, if a task is blocked on a read of an empty stream buffer that has a trigger level of 10 then the task will not be unblocked until the stream buffer contains at least 10 bytes or the task's block time expires. If a reading task's block time expires before the trigger level is reached then the task will still receive however many bytes are actually available. Setting a trigger level of 0 will result in a trigger level of 1 being used. It is not valid to specify a trigger level that is greater than the buffer size.

Example Usage

#include <FreeRTOS/StreamBuffer.hpp>
#include <FreeRTOS/Task.hpp>
class MyTask : public FreeRTOS::Task {
public:
void taskFunction() final;
};
void MyTask::taskFunction() {
// Variable to hold the stream buffer and it's underlying storage.
// Other code that uses the message buffer can go here.
}
Class that encapsulates the functionality of a FreeRTOS stream buffer.
Definition StreamBuffer.hpp:532
Class that encapsulates the functionality of a FreeRTOS task.
Definition Task.hpp:1427

The documentation for this class was generated from the following file: