use lager::LagerBox;let lager = LagerBox::from_env()?;let mut uart = lager.uart("uart1")?;
uart() is the only handle constructor that returns a Result. Every other net
handle is inert until you call a method. uart() connects the session and starts
streaming immediately, so it can fail right here.
Accumulate until needle appears.Returns: everything up to and including the needle; the remainder stays
buffered. An empty needle returns immediately; a miss is Error::Timeout.
The most recent session status notification, updated during reads. While a USB serial
adapter re-enumerates — because a hub port was cycled, or the DUT was reflashed — this
reads "reconnecting" and then "reconnected". Checking it distinguishes “the DUT is
quiet” from “the adapter went away”.
use std::time::Duration;dbg.flash_bin("target/app.bin", 0x0)?; // the adapter may re-enumerate// The session reconnects on its own; watch the status while it does.let banner = uart.wait_for(b"ready", Duration::from_secs(30))?;println!("status during reflash: {:?}", uart.last_status());assert!(String::from_utf8_lossy(&banner).contains("ready"));
The box owns the port exclusively, and only one session per net or device is
allowed. A second opener gets Error::Stream saying the port is already in use.
That includes a session your own previous test leaked — call stop().
The connect confirmation timeout is 15 seconds; failing it is Error::Timeout.
Bytes are raw. There is no line discipline, no echo handling and no encoding
conversion; wait_for works on bytes.
Sessions carry the gateway bearer token on the Socket.IO handshake, so a gated box
needs no extra setup.
On FTDI multi-channel parts, UART works on all four channels, unlike the MPSSE
protocols (debug, spi, i2c) which are limited to channels A and B. On a single-channel
FT232H, claiming UART makes the MPSSE roles unavailable and vice versa.