Skip to main content

Module serial

Module serial 

Source
Expand description

Low-level serial I/O traits, device discovery, handshake, frame reader, and writer task.

This module encapsulates all direct interaction with the serial byte stream below the Go-Back-N ResendSP state machines:

  • RX (SerialReader): Rather than spawning a separate reader_task, incoming bytes are parsed by SerialReader, which is borrowed directly by the receiver task (reader.next_frame().await). This allows the caller to recover any unconsumed trailing bytes via SerialReader::take_unconsumed when a session ends or renegotiates.
  • TX (writer_task): Because multiple producers emit frames concurrently (outgoing data/close frames, duplicate handshake replies, and priority cumulative ACKs via AckTracker), outgoing serial writes are handled by a dedicated writer_task that prioritizes ACKs and coalesces 4 KiB frame batches.

Structs§

SerialReader
Buffered UART protocol frame reader wrapping a SerialRead implementation.

Traits§

SerialRead
Asynchronous byte reader abstraction over a target serial device.
SerialWrite
Asynchronous byte writer abstraction over a target serial device.

Functions§

open_serial_device
Discovers a serial device under /dev/class/serial and configures it for 8N1 at baud_rate.
run_target_handshake
Runs the target-side framing protocol handshake over device.
run_target_handshake_with_initial_data
Runs the target-side framing protocol handshake seeded with initial_data.
writer_task
Runs the serial frame writer loop, prioritizing pending ACKs from ack_tracker ahead of coalesced outgoing data frames from data_rx.