Skip to main content

Module session

Module session 

Source
Expand description

Layer 2: sans-I/O session state machine.

Owns the sync counter, the outbound queue, and the inbound ASCII line parser. Callers drive it with feed / poll_outbound / poll_event / tick, plumbing the bytes through any I/O of their choice.

§Lifecycle

  1. Caller writes the ASCII trigger b"M28B1\n" to the device.
  2. Caller calls Session::connect, drains poll_outbound, writes those bytes to the device.
  3. Caller reads bytes from the device and pushes them via Session::feed.
  4. Caller drains Session::poll_event until Event::Synced is observed — the device has acknowledged the SYNC and reported its block size and protocol version.
  5. Caller calls Session::send for each subsequent binary packet, pumping poll_outbound / feed / poll_event as before, calling Session::tick periodically so retransmits fire on timeout.

§Concurrency model

Mirrors the Python reference: only one packet is in flight at a time. Calls to Session::send while a packet is in flight are queued FIFO and dispatched as each ack arrives.

Structs§

Session
Sans-I/O session driver.

Enums§

Event
Things the session emits to the caller as parsed bytes arrive.