numex::MagicDetector
Finds the magic byte sequence that starts each frame in a serial byte stream.
| Declared in | src/libs/libnumex/numex/MagicDetector.hpp |
| Group | numex |
Detailed description
Give each received byte to detect(). It returns true on the byte that completes the sequence, and then starts again. A wrong byte resets the match, but a byte equal to the first magic byte starts a new match.
The detector copies up to eight magic bytes into itself, in RAM. On an AVR, a pointer to the constant numex::MAGIC would read flash addresses from RAM and get garbage, so the detector must not keep one. NumexSerialLink on the host and fixo::ValueProtocol in the firmware each own one detector.