Module hdlc

Module hdlc 

Source
Expand description

HDLC-Lite framing for asynchronous serial links (UART, USB-CDC).

Same discipline as Spinel’s HDLC-Lite: frames are delimited by 0x7E flag bytes, control bytes inside a frame are escaped with 0x7D (XOR 0x20), and each frame carries a trailing 16-bit FCS (CRC-16/X-25 per RFC 1662), least-significant byte first.

Structs§

Decoder
Streaming decoder with an internal reassembly buffer of N bytes.

Enums§

DecodeError
EncodeError

Constants§

ESCAPE
Escape byte; the following byte is XORed with ESCAPE_XOR.
ESCAPE_XOR
XOR applied to escaped bytes.
FLAG
Frame delimiter.

Functions§

crc16
RFC 1662 FCS-16 (CRC-16/X-25) over data.
encode_frame
Encode one frame, including both delimiting flags, into out.
max_encoded_len
Worst-case encoded size for a payload of payload_len bytes.