TinyRobotics
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
BufferRTOS< T, TAllocator > Class Template Reference

Buffer implementation which is using a FreeRTOS StreamBuffer. The default allocator uses psram is available. More...

#include <BufferRTOS.h>

Inheritance diagram for BufferRTOS< T, TAllocator >:
Inheritance graph
[legend]
Collaboration diagram for BufferRTOS< T, TAllocator >:
Collaboration graph
[legend]

Public Member Functions

 BufferRTOS (size_t streamBufferSize, size_t xTriggerLevel=1, TickType_t writeMaxWait=portMAX_DELAY, TickType_t readMaxWait=portMAX_DELAY)
 
bool resize (size_t size)
 Re-Allocats the memory and the queue.
 
void setReadMaxWait (TickType_t ticks)
 
void setWriteMaxWait (TickType_t ticks)
 
void setWriteFromISR (bool active)
 
void setReadFromISR (bool active)
 
bool read (T &result) override
 reads a single value
 
int readArray (T data[], int len)
 reads multiple values
 
int writeArray (const T data[], int len)
 Fills the buffer data.
 
bool peek (T &result) override
 peeks the actual entry from the buffer
 
bool isFull () override
 checks if the buffer is full
 
bool isEmpty ()
 
bool write (T data) override
 write add an entry to the buffer
 
void reset () override
 clears the buffer
 
int available () override
 provides the number of entries that are available to read
 
int availableForWrite () override
 provides the number of entries that are available to write
 
T * address () override
 returns the address of the start of the physical read buffer
 
size_t size ()
 
 operator bool ()
 
void end ()
 
- Public Member Functions inherited from BaseBuffer< T >
 BaseBuffer (BaseBuffer &)=default
 
BaseBufferoperator= (BaseBuffer &)=default
 
virtual bool read (T &result)=0
 reads a single value
 
virtual int readArray (T data[], int len)
 reads multiple values
 
virtual int clearArray (int len)
 Removes the next len entries.
 
virtual int writeArray (const T data[], int len)
 Fills the buffer data.
 
virtual int writeArrayOverwrite (const T data[], int len)
 Fills the buffer data and overwrites the oldest data if the buffer is full.
 
virtual bool peek (T &result)=0
 peeks the actual entry from the buffer
 
virtual bool isFull ()
 checks if the buffer is full
 
bool isEmpty ()
 
virtual bool write (T data)=0
 write add an entry to the buffer
 
virtual void reset ()=0
 clears the buffer
 
void clear ()
 same as reset
 
virtual int available ()=0
 provides the number of entries that are available to read
 
virtual int availableForWrite ()=0
 provides the number of entries that are available to write
 
virtual T * address ()=0
 returns the address of the start of the physical read buffer
 
virtual size_t size ()=0
 
virtual float levelPercent ()
 Returns the level of the buffer in %.
 
virtual bool resize (int bytes)
 Resizes the buffer if supported: returns false if not supported.
 

Protected Member Functions

bool setup ()
 

Protected Attributes

TAllocator allocator
 
StreamBufferHandle_t xStreamBuffer = nullptr
 
StaticStreamBuffer_t static_stream_buffer
 
uint8_t * p_data = nullptr
 
BaseType_t xHigherPriorityTaskWoken = pdFALSE
 
int readWait = portMAX_DELAY
 
int writeWait = portMAX_DELAY
 
bool read_from_isr = false
 
bool write_from_isr = false
 
size_t current_size_bytes = 0
 
size_t trigger_level = 0
 
size_t allocated_size = 0
 

Detailed Description

template<typename T, class TAllocator = AllocatorPSRAM<T>>
class tinyrobotics::BufferRTOS< T, TAllocator >

Buffer implementation which is using a FreeRTOS StreamBuffer. The default allocator uses psram is available.

Author
Phil Schatzmann
Template Parameters
T

Member Function Documentation

◆ address()

T * address ( )
inlineoverridevirtual

returns the address of the start of the physical read buffer

Implements BaseBuffer< T >.

◆ available()

int available ( )
inlineoverridevirtual

provides the number of entries that are available to read

Implements BaseBuffer< T >.

◆ availableForWrite()

int availableForWrite ( )
inlineoverridevirtual

provides the number of entries that are available to write

Implements BaseBuffer< T >.

◆ isFull()

bool isFull ( )
inlineoverridevirtual

checks if the buffer is full

Reimplemented from BaseBuffer< T >.

◆ peek()

bool peek ( T &  result)
inlineoverridevirtual

peeks the actual entry from the buffer

Implements BaseBuffer< T >.

◆ read()

bool read ( T &  result)
inlineoverridevirtual

reads a single value

Implements BaseBuffer< T >.

◆ readArray()

int readArray ( data[],
int  len 
)
inlinevirtual

reads multiple values

Reimplemented from BaseBuffer< T >.

◆ reset()

void reset ( )
inlineoverridevirtual

clears the buffer

Implements BaseBuffer< T >.

◆ setup()

bool setup ( )
inlineprotected

The allocation has been postponed to be done here, so that we can e.g. use psram

◆ size()

size_t size ( )
inlinevirtual

Implements BaseBuffer< T >.

◆ write()

bool write ( data)
inlineoverridevirtual

write add an entry to the buffer

Implements BaseBuffer< T >.

◆ writeArray()

int writeArray ( const T  data[],
int  len 
)
inlinevirtual

Fills the buffer data.

Reimplemented from BaseBuffer< T >.


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