|
pfodParser
5.0.1
The pfodParser library is handles commands sent from the Android pfodApp, pfodApp supports WiFi, BLE, Bluetooth and SMS connections
|
pfodCircularLineBuffer - Line-aware circular buffer for CSV data streaming More...
#include <pfodCircularLineBuffer.h>
Inherits Stream.
Public Member Functions | |
| pfodCircularLineBuffer (size_t bufferSize=4096) | |
| Constructor - Initializes empty circular buffer with specified size. More... | |
| ~pfodCircularLineBuffer () | |
| Destructor - Cleans up buffer memory. More... | |
| size_t | addLine (const char *line) |
| Adds a complete line to the buffer (must include \r terminator). More... | |
| size_t | addLine (const String &line) |
| Adds a complete line to the buffer (must include \r terminator). More... | |
| void | getRange (size_t fromLineCount, BufferRange &range) |
| Gets buffer range starting from specified line number. More... | |
| void | getAllRange (BufferRange &range) |
| Gets buffer range for all available data. More... | |
| void | setReadRange (const BufferRange &range) |
| Sets the current read position to a specific buffer range. More... | |
| void | resetForRead () |
| Resets read position to beginning of all available data. More... | |
| size_t | getStartLineCount () const |
| Gets the current start line number (oldest available line). More... | |
| size_t | getEndLineCount () const |
| Gets the current end line number (newest line + 1). More... | |
| size_t | getLineCount () const |
| Gets total number of lines currently in buffer. More... | |
| size_t | getBufferSize () const |
| Gets the configured buffer size. More... | |
| size_t | getUsedBytes () const |
| Gets number of bytes currently used in buffer. More... | |
| size_t | getAvailableBytes () const |
| Gets number of bytes available in buffer. More... | |
| bool | isEmpty () const |
| Checks if buffer is empty. More... | |
| void | clear () |
| Clears all data from buffer and resets line counts. More... | |
| void | debugBufferRange (Print *outPtr) |
| Prints debug information about buffer state and positions. More... | |
| virtual int | available () override |
| Returns number of bytes available to read from current read range. More... | |
| virtual int | peek () override |
| Reads one byte from current read range without advancing position. More... | |
| virtual int | read () override |
| Reads one byte from current read range and advances position. More... | |
| virtual size_t | write (uint8_t c) override |
| Write single byte to buffer. More... | |
| virtual size_t | write (const uint8_t *buffer, size_t size) override |
| Write buffer. More... | |
pfodCircularLineBuffer - Line-aware circular buffer for CSV data streaming
Maintains complete lines only, automatically adjusting start position when buffer wraps to ensure no partial lines. Tracks line counts for efficient retrieval by line number.
Implements Arduino Stream interface for reading data.
Definition at line 40 of file pfodCircularLineBuffer.h.
| pfodCircularLineBuffer::pfodCircularLineBuffer | ( | size_t | bufferSize = 4096 | ) |
Constructor - Initializes empty circular buffer with specified size.
buffersize must be > line lenght, if buffersize is < line length no data will be available to read
| bufferSize | Size of buffer in bytes (default: 4096) |
| pfodCircularLineBuffer::~pfodCircularLineBuffer | ( | ) |
Destructor - Cleans up buffer memory.
| size_t pfodCircularLineBuffer::addLine | ( | const char * | line | ) |
Adds a complete line to the buffer (must include \r
terminator).
Uses Print interface to write characters. If wrapping occurs and overwrites start position, adjusts start to next complete line.
| line | String containing complete line with \r terminator |
| size_t pfodCircularLineBuffer::addLine | ( | const String & | line | ) |
Adds a complete line to the buffer (must include \r
terminator).
Uses Print interface to write characters. If wrapping occurs and overwrites start position, adjusts start to next complete line.
| line | String containing complete line with \r terminator |
|
overridevirtual |
Returns number of bytes available to read from current read range.
| void pfodCircularLineBuffer::clear | ( | ) |
Clears all data from buffer and resets line counts.
| void pfodCircularLineBuffer::debugBufferRange | ( | Print * | outPtr | ) |
Prints debug information about buffer state and positions.
Outputs buffer range, stream positions, line counts, and usage stats.
| outPtr | Pointer to Print object for output (e.g., &Serial). Returns silently if null. |
| void pfodCircularLineBuffer::getAllRange | ( | BufferRange & | range | ) |
Gets buffer range for all available data.
| range | Output parameter filled with start/end byte positions and line counts |
|
inline |
Gets number of bytes available in buffer.
Definition at line 148 of file pfodCircularLineBuffer.h.
|
inline |
Gets the configured buffer size.
Definition at line 134 of file pfodCircularLineBuffer.h.
|
inline |
Gets the current end line number (newest line + 1).
Definition at line 120 of file pfodCircularLineBuffer.h.
|
inline |
Gets total number of lines currently in buffer.
Definition at line 127 of file pfodCircularLineBuffer.h.
| void pfodCircularLineBuffer::getRange | ( | size_t | fromLineCount, |
| BufferRange & | range | ||
| ) |
Gets buffer range starting from specified line number.
Returns data from that line until end of buffer. If requested line is older than available, returns from earliest line.
| fromLineCount | Line number to start from |
| range | Output parameter filled with start/end byte positions and line counts |
|
inline |
Gets the current start line number (oldest available line).
Definition at line 113 of file pfodCircularLineBuffer.h.
| size_t pfodCircularLineBuffer::getUsedBytes | ( | ) | const |
Gets number of bytes currently used in buffer.
|
inline |
Checks if buffer is empty.
Definition at line 155 of file pfodCircularLineBuffer.h.
|
overridevirtual |
Reads one byte from current read range without advancing position.
|
overridevirtual |
Reads one byte from current read range and advances position.
| void pfodCircularLineBuffer::resetForRead | ( | ) |
Resets read position to beginning of all available data.
Convenience method that calls getAllRange() and setReadRange(). Subsequent Stream read operations will read from start of buffer.
| void pfodCircularLineBuffer::setReadRange | ( | const BufferRange & | range | ) |
Sets the current read position to a specific buffer range.
Subsequent Stream read operations will read from this range.
| range | BufferRange specifying what to read |
|
overridevirtual |
Write buffer.
Calls write(uint8_t) for each byte.
| buffer | Data to write |
| size | Number of bytes |
|
overridevirtual |
Write single byte to buffer.
Used by addLine() via Print interface. Automatically wraps and adjusts start position when \r
detected.
| c | Byte to write |