Incremental parser for USHER's UART framing protocol. More...
#include "usher_protocol.h"
Go to the source code of this file.
Macros | |
| #define | UNINIT 0 |
| #define | GOT_STX 1 |
| #define | GOT_LENGTH 2 |
| #define | GOT_MSGID 3 |
| #define | GOT_PAYLOAD 4 |
| #define | GOT_CRC1 5 |
Functions | |
| void | parse_usher (struct usher_transport *t, uint8_t c) |
| Consume one UART byte and advance a USHER transport parser. The public parameter and lifetime contract is documented in usher_protocol.h. | |
Variables | |
| uint8_t | usher_ck_a |
| uint8_t | usher_ck_b |
| struct usher_transport | usher_protocol |
Detailed Description
Incremental parser for USHER's UART framing protocol.
The UART transport is a byte stream, so this parser keeps state across calls and accepts arbitrarily fragmented frames. It validates both Fletcher-style checksum bytes before publishing a message. On malformed input it discards only the current partial frame and resumes searching for the next start byte; this is deliberately resilient to line noise and lost bytes.
Definition in file usher_protocol.c.
Macro Definition Documentation
◆ GOT_CRC1
| #define GOT_CRC1 5 |
Definition at line 40 of file usher_protocol.c.
◆ GOT_LENGTH
| #define GOT_LENGTH 2 |
Definition at line 37 of file usher_protocol.c.
◆ GOT_MSGID
| #define GOT_MSGID 3 |
Definition at line 38 of file usher_protocol.c.
◆ GOT_PAYLOAD
| #define GOT_PAYLOAD 4 |
Definition at line 39 of file usher_protocol.c.
◆ GOT_STX
| #define GOT_STX 1 |
Definition at line 36 of file usher_protocol.c.
◆ UNINIT
| #define UNINIT 0 |
Parser states; each corresponds to the next byte expected on the wire.
Definition at line 35 of file usher_protocol.c.
Function Documentation
◆ parse_usher()
| void parse_usher | ( | struct usher_transport * | t, |
| uint8_t | c ) |
Consume one UART byte and advance a USHER transport parser. The public parameter and lifetime contract is documented in usher_protocol.h.
Consume one byte from a USHER UART stream.
Checksums cover the length, message ID, and payload bytes. A complete, valid frame sets t->msg_received; the caller must clear that flag after dispatching. Any framing or checksum error increments t->error and resets the state machine, avoiding a poisoned partial frame affecting later traffic.
- Warning
tmust remain valid and unchanged by another thread for the duration of a frame; this parser intentionally contains no synchronization.
Definition at line 54 of file usher_protocol.c.
Variable Documentation
◆ usher_ck_a
| uint8_t usher_ck_a |
Definition at line 31 of file usher_protocol.c.
◆ usher_ck_b
| uint8_t usher_ck_b |
Definition at line 31 of file usher_protocol.c.
◆ usher_protocol
| struct usher_transport usher_protocol |
Definition at line 42 of file usher_protocol.c.