|
CodexPadFrameDecoder Arduino Lib 1.0.0
|
robust_frame protocol frame parser (receiver only). More...
#include <robust_frame.h>
Public Types | |
| using | FrameCallback = void (*)(const uint8_t *data, void *user_data) |
| Frame parse callback function type. | |
Public Member Functions | |
| Parser (const size_t max_payload_size, FrameCallback callback, void *user_data) | |
| Constructor. Dynamically allocates the internal buffer based on the maximum payload size. | |
| ~Parser () | |
| Destructor. Frees the internally allocated buffer. | |
| void | Feed (const uint8_t byte) |
| Core state machine for processing a single byte. | |
robust_frame protocol frame parser (receiver only).
Handles frame synchronization, escape reversal, and CRC verification, outputting complete payloads via callback. Does not depend on any specific communication method; only requires feeding bytes one at a time via Feed(). The maximum payload size is specified via the constructor parameter, and the internal buffer is dynamically allocated accordingly.
Definition at line 32 of file robust_frame.h.
| using robust_frame::Parser::FrameCallback = void (*)(const uint8_t *data, void *user_data) |
Frame parse callback function type.
| data | Pointer to the payload data (excluding frame header, footer, and CRC). |
| user_data | User-defined context pointer, passed in via the constructor and returned as-is in the callback. |
Definition at line 46 of file robust_frame.h.
| robust_frame::Parser::Parser | ( | const size_t | max_payload_size, |
| FrameCallback | callback, | ||
| void * | user_data ) |
Constructor. Dynamically allocates the internal buffer based on the maximum payload size.
| [in] | max_payload_size | Maximum payload size in bytes (excluding CRC). The actual allocated buffer size is max_payload_size + 1, where the extra byte is used to store the CRC checksum. |
| [in] | callback | Callback function invoked when a frame is successfully parsed (no callback if nullptr). |
| [in] | user_data | User-defined context pointer passed through to the callback (typically a this pointer). |
Definition at line 23 of file robust_frame.cpp.
| robust_frame::Parser::~Parser | ( | ) |
Destructor. Frees the internally allocated buffer.
Definition at line 27 of file robust_frame.cpp.
| void robust_frame::Parser::Feed | ( | const uint8_t | byte | ) |
Core state machine for processing a single byte.
| [in] | byte | The input byte. |
State transition diagram:
Definition at line 31 of file robust_frame.cpp.