tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
stream_buffer Struct Reference

Stream buffers are an RTOS task to RTOS task, and interrupt to task communication primitives. More...

#include <stream_buffer.hpp>

Public Types

using size_type = etl::size_t
 

Public Member Functions

 stream_buffer (size_type size, size_type triggerLevel) noexcept
 Creates a new stream buffer using dynamically allocated memory.
 
 stream_buffer (stream_buffer &&other)=delete
 
 stream_buffer (stream_buffer const &other)=delete
 
 ~stream_buffer () noexcept
 Deletes a stream buffer, then the allocated memory is freed.
 
auto bytes_available () const noexcept -> size_type
 Queries a stream buffer to see how much data it contains, which is equal to the number of bytes that can be read from the stream buffer before the stream buffer would be empty.
 
auto empty () const noexcept -> bool
 Queries a stream buffer to see if it is empty. A stream buffer is empty if it does not contain any data.
 
auto full () const noexcept -> bool
 Queries a stream buffer to see if it is full. A stream buffer is full if it does not have any free space, and therefore cannot accept any more data.
 
auto native_handle () const noexcept -> StreamBufferHandle_t
 Returns the native FreeRTOS handle to the stream_buffer.
 
auto operator= (stream_buffer &&other) -> stream_buffer &=delete
 
auto operator= (stream_buffer const &other) -> stream_buffer &=delete
 
auto read (net::mutable_buffer data, TickType_t ticks) -> size_type
 Receives bytes from a stream buffer.
 
auto read_from_isr (net::mutable_buffer data, BaseType_t *prio) -> size_type
 Receives bytes from a stream buffer.
 
auto reset () noexcept -> void
 Resets a stream buffer to its initial, empty, state. Any data that was in the stream buffer is discarded. A stream buffer can only be reset if there are no tasks blocked waiting to either send to or receive from the stream buffer.
 
auto space_available () const noexcept -> size_type
 Queries a stream buffer to see how much free space it contains, which is equal to the amount of data that can be sent to the stream buffer before it is full.
 
auto trigger_level (size_type triggerLevel) noexcept -> void
 A stream buffer's trigger level is the 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.
 
auto write (net::const_buffer data, TickType_t ticks) -> size_type
 Sends bytes to a stream buffer. The bytes are copied into the stream buffer.
 
auto write_from_isr (net::const_buffer data, BaseType_t *prio) -> size_type
 Interrupt safe version of the API function that sends a stream of bytes to the stream buffer.
 

Detailed Description

Stream buffers are an RTOS task to RTOS task, and interrupt to task communication primitives.

Unlike most other FreeRTOS communications primitives, they are optimised for single reader single writer scenarios, such as passing data from an interrupt service routine to a task, or from one microcontroller core to another on dual core CPUs. Data is passed by copy - the data is copied into the buffer by the sender and out of the buffer by the read.

https://www.freertos.org/RTOS-stream-buffer-API.html https://www.freertos.org/RTOS-stream-message-buffers.html

Member Typedef Documentation

◆ size_type

Constructor & Destructor Documentation

◆ stream_buffer() [1/3]

stream_buffer ( size_type size,
size_type triggerLevel )
inlinenoexcept

Creates a new stream buffer using dynamically allocated memory.

https://www.freertos.org/xStreamBufferCreate.html

◆ ~stream_buffer()

~stream_buffer ( )
inlinenoexcept

Deletes a stream buffer, then the allocated memory is freed.

https://www.freertos.org/vStreamBufferDelete.html

◆ stream_buffer() [2/3]

stream_buffer ( stream_buffer const & other)
delete

◆ stream_buffer() [3/3]

stream_buffer ( stream_buffer && other)
delete

Member Function Documentation

◆ bytes_available()

auto bytes_available ( ) const -> size_type
inlinenodiscardnoexcept

Queries a stream buffer to see how much data it contains, which is equal to the number of bytes that can be read from the stream buffer before the stream buffer would be empty.

https://www.freertos.org/xStreamBufferBytesAvailable.html

◆ empty()

auto empty ( ) const -> bool
inlinenodiscardnoexcept

Queries a stream buffer to see if it is empty. A stream buffer is empty if it does not contain any data.

https://www.freertos.org/xStreamBufferIsEmpty.html

◆ full()

auto full ( ) const -> bool
inlinenodiscardnoexcept

Queries a stream buffer to see if it is full. A stream buffer is full if it does not have any free space, and therefore cannot accept any more data.

https://www.freertos.org/xStreamBufferIsFull.html

◆ native_handle()

auto native_handle ( ) const -> StreamBufferHandle_t
inlinenodiscardnoexcept

Returns the native FreeRTOS handle to the stream_buffer.

◆ operator=() [1/2]

auto operator= ( stream_buffer && other) -> stream_buffer &=delete
delete

◆ operator=() [2/2]

auto operator= ( stream_buffer const & other) -> stream_buffer &=delete
delete

◆ read()

auto read ( net::mutable_buffer data,
TickType_t ticks ) -> size_type
inline

Receives bytes from a stream buffer.

https://www.freertos.org/xStreamBufferReceive.html

◆ read_from_isr()

auto read_from_isr ( net::mutable_buffer data,
BaseType_t * prio ) -> size_type
inline

Receives bytes from a stream buffer.

https://www.freertos.org/xStreamBufferReceiveFromISR.html

◆ reset()

auto reset ( ) -> void
inlinenoexcept

Resets a stream buffer to its initial, empty, state. Any data that was in the stream buffer is discarded. A stream buffer can only be reset if there are no tasks blocked waiting to either send to or receive from the stream buffer.

https://www.freertos.org/xStreamBufferReset.html

◆ space_available()

auto space_available ( ) const -> size_type
inlinenodiscardnoexcept

Queries a stream buffer to see how much free space it contains, which is equal to the amount of data that can be sent to the stream buffer before it is full.

https://www.freertos.org/xStreamBufferSpacesAvailable.html

◆ trigger_level()

auto trigger_level ( size_type triggerLevel) -> void
inlinenoexcept

A stream buffer's trigger level is the 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.

https://www.freertos.org/xStreamBufferSetTriggerLevel.html

◆ write()

auto write ( net::const_buffer data,
TickType_t ticks ) -> size_type
inline

Sends bytes to a stream buffer. The bytes are copied into the stream buffer.

https://www.freertos.org/xStreamBufferSend.html

◆ write_from_isr()

auto write_from_isr ( net::const_buffer data,
BaseType_t * prio ) -> size_type
inline

Interrupt safe version of the API function that sends a stream of bytes to the stream buffer.

https://www.freertos.org/xStreamBufferSendFromISR.html


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