Skip to main content

Module frame

Module frame 

Source
Expand description

Serial API frames.

A data frame is SOF LEN TYPE FUNC PAYLOAD.. CHECKSUM, where LEN counts the bytes after itself (type, function, payload and checksum) and the checksum is 0xFF XOR every byte from LEN to the end of the payload. Single-byte frames acknowledge (ACK), reject (NAK) or signal a collision (CAN).

Structs§

DataFrame
A data frame.
FrameCodec
Streaming codec for Serial API frames.

Enums§

Frame
One unit on the wire.
FrameType
Request (host to controller, or an unsolicited controller frame) or response.

Constants§

ACK
Acknowledge.
CAN
Cancel: the receiver was sending a frame itself.
MAX_PAYLOAD
Longest payload a frame can carry: LEN is one byte and counts type, function and checksum too.
NAK
Negative acknowledge (bad checksum or timeout on the receiver).
SOF
Start of frame.

Functions§

checksum
The Serial API checksum over LEN..=last payload byte.
decode_all
Decodes every complete frame in bytes (for tests and fuzzing).