Skip to main content

Module serial

Module serial 

Source
Expand description

The C ABI for serial-line packet framing.

These functions wrap [pamoja_serial] for callers that reach the SDK through the flat C boundary. Both framings are here in full: the one-shot encode and decode of a complete frame, and the streaming decoders that reassemble frames from the arbitrary chunks a UART actually delivers.

The Rust decoders take one byte at a time. Crossing the boundary per byte would cost more than the decoding does, so what is exposed here is a chunk-at-a-time feed that runs the same per-byte loop natively and hands back every frame the chunk completed. A chunk that carries a corrupt frame does not fail the call, because the frames around it are still good; the decoder discards the corrupt one and counts it, and the count is readable with the *_discarded calls.

Structs§

PamojaCobsDecoder
An opaque handle to a streaming COBS decoder.
PamojaFrames
An opaque handle to the frames one call to a streaming decoder completed.
PamojaSlipDecoder
An opaque handle to a streaming SLIP decoder.

Constants§

PAMOJA_SERIAL_FRAME_MAX
The largest payload, in bytes, that a streaming decoder will reassemble.

Functions§

pamoja_cobs_decoder_discarded
Returns how many corrupt frames a COBS decoder has discarded.
pamoja_cobs_decoder_feed
Feeds a chunk of the byte stream to a COBS decoder.
pamoja_cobs_decoder_free
Releases a COBS decoder handle.
pamoja_cobs_decoder_new
Creates a streaming COBS decoder.
pamoja_cobs_decoder_reset
Discards any partly assembled frame, returning a COBS decoder to its initial state.
pamoja_frames_count
Returns how many frames a decoder call produced.
pamoja_frames_data
Returns a pointer to one frame’s payload bytes.
pamoja_frames_free
Releases a decoded frame set.
pamoja_frames_len
Returns the length in bytes of one frame’s payload.
pamoja_serial_cobs_decode
Reads the payload back out of a COBS frame.
pamoja_serial_cobs_encode
Frames a payload as a COBS packet, terminated by its zero delimiter.
pamoja_serial_cobs_max_encoded_len
Returns the largest COBS frame a payload of payload_len bytes can produce.
pamoja_serial_slip_decode
Reads the payload back out of a SLIP frame.
pamoja_serial_slip_encode
Frames a payload as a SLIP packet (RFC 1055).
pamoja_serial_slip_max_encoded_len
Returns the largest SLIP frame a payload of payload_len bytes can produce.
pamoja_slip_decoder_discarded
Returns how many corrupt frames a SLIP decoder has discarded.
pamoja_slip_decoder_feed
Feeds a chunk of the byte stream to a SLIP decoder.
pamoja_slip_decoder_free
Releases a SLIP decoder handle.
pamoja_slip_decoder_new
Creates a streaming SLIP decoder.
pamoja_slip_decoder_reset
Discards any partly assembled frame, returning a SLIP decoder to its initial state.