|
ESPHome 2026.11.0b6
|
Collects fixed length binary frames of N bytes that start with the header bytes HEADER...; the binary twin of LineReader. More...
#include <frame_reader.h>
Public Member Functions | |
| const uint8_t * | feed (uint8_t c) |
| Feed one byte; returns the completed frame, header included, valid until the next call, or nullptr. | |
| size_t | length () const |
| Number of bytes of the partial frame; 0 after a frame is returned and while looking for a header. | |
| void | reset () |
| Forget the partial frame and look for a header from the next byte. | |
| void | resync () |
| For a frame the caller rejected (bad checksum): drop its first byte and realign on a header in the rest. | |
Protected Member Functions | |
| void | replay_ (size_t last) |
Static Protected Member Functions | |
| static constexpr uint8_t | header_byte (size_t i) |
Protected Attributes | |
| uint8_t | buf_ [N] |
| pos_t | pos_ {0} |
Collects fixed length binary frames of N bytes that start with the header bytes HEADER...; the binary twin of LineReader.
Bytes before a header are skipped; checksums are left to the caller.
Definition at line 11 of file frame_reader.h.
|
inline |
Feed one byte; returns the completed frame, header included, valid until the next call, or nullptr.
Definition at line 19 of file frame_reader.h.
|
inlinestaticconstexprprotected |
Definition at line 48 of file frame_reader.h.
|
inline |
Number of bytes of the partial frame; 0 after a frame is returned and while looking for a header.
Definition at line 37 of file frame_reader.h.
|
inlineprotected |
Definition at line 56 of file frame_reader.h.
|
inline |
Forget the partial frame and look for a header from the next byte.
Definition at line 40 of file frame_reader.h.
|
inline |
For a frame the caller rejected (bad checksum): drop its first byte and realign on a header in the rest.
Call only right after feed() returned that frame; use reset() otherwise.
Definition at line 44 of file frame_reader.h.
|
protected |
Definition at line 63 of file frame_reader.h.
|
protected |
Definition at line 64 of file frame_reader.h.