ESPHome
2024.10.2
|
#include <ring_buffer.h>
Public Member Functions | |
~RingBuffer () | |
size_t | read (void *data, size_t len, TickType_t ticks_to_wait=0) |
Reads from the ring buffer, waiting up to a specified number of ticks if necessary. More... | |
size_t | write (void *data, size_t len) |
Writes to the ring buffer, overwriting oldest data if necessary. More... | |
size_t | write_without_replacement (void *data, size_t len, TickType_t ticks_to_wait=0) |
Writes to the ring buffer without overwriting oldest data. More... | |
size_t | available () const |
Returns the number of available bytes in the ring buffer. More... | |
size_t | free () const |
Returns the number of free bytes in the ring buffer. More... | |
BaseType_t | reset () |
Resets the ring buffer, discarding all stored data. More... | |
Static Public Member Functions | |
static std::unique_ptr< RingBuffer > | create (size_t len) |
Protected Attributes | |
StreamBufferHandle_t | handle_ |
StaticStreamBuffer_t | structure_ |
uint8_t * | storage_ |
size_t | size_ {0} |
Definition at line 13 of file ring_buffer.h.
esphome::RingBuffer::~RingBuffer | ( | ) |
Definition at line 14 of file ring_buffer.cpp.
size_t esphome::RingBuffer::available | ( | ) | const |
Returns the number of available bytes in the ring buffer.
This function provides the number of bytes that can be read from the ring buffer without blocking the calling FreeRTOS task.
Definition at line 63 of file ring_buffer.cpp.
|
static |
Definition at line 22 of file ring_buffer.cpp.
size_t esphome::RingBuffer::free | ( | ) | const |
Returns the number of free bytes in the ring buffer.
This function provides the number of bytes that can be written to the ring buffer without overwriting data or blocking the calling FreeRTOS task.
Definition at line 65 of file ring_buffer.cpp.
size_t esphome::RingBuffer::read | ( | void * | data, |
size_t | len, | ||
TickType_t | ticks_to_wait = 0 |
||
) |
Reads from the ring buffer, waiting up to a specified number of ticks if necessary.
Available bytes are read into the provided data pointer. If not enough bytes are available, the function will wait up to ticks_to_wait
FreeRTOS ticks before reading what is available.
data | Pointer to copy read data into |
len | Number of bytes to read |
ticks_to_wait | Maximum number of FreeRTOS ticks to wait (default: 0) |
Definition at line 38 of file ring_buffer.cpp.
BaseType_t esphome::RingBuffer::reset | ( | ) |
Resets the ring buffer, discarding all stored data.
Definition at line 67 of file ring_buffer.cpp.
size_t esphome::RingBuffer::write | ( | void * | data, |
size_t | len | ||
) |
Writes to the ring buffer, overwriting oldest data if necessary.
The provided data is written to the ring buffer. If not enough space is available, the function will overwrite the oldest data in the ring buffer.
data | Pointer to data for writing |
len | Number of bytes to write |
Definition at line 49 of file ring_buffer.cpp.
size_t esphome::RingBuffer::write_without_replacement | ( | void * | data, |
size_t | len, | ||
TickType_t | ticks_to_wait = 0 |
||
) |
Writes to the ring buffer without overwriting oldest data.
The provided data is written to the ring buffer. If not enough space is available, the function will wait up to ticks_to_wait
FreeRTOS ticks before writing as much as possible.
data | Pointer to data for writing |
len | Number of bytes to write |
ticks_to_wait | Maximum number of FreeRTOS ticks to wait (default: 0) |
Definition at line 59 of file ring_buffer.cpp.
|
protected |
Definition at line 85 of file ring_buffer.h.
|
protected |
Definition at line 88 of file ring_buffer.h.
|
protected |
Definition at line 87 of file ring_buffer.h.
|
protected |
Definition at line 86 of file ring_buffer.h.