pub struct SerialPortHandle { /* private fields */ }Expand description
Open USB serial session: sync I/O plus optional background bulk-IN reader.
Implementations§
Source§impl SerialPortHandle
impl SerialPortHandle
Sourcepub fn write(&mut self, data: &[u8]) -> Result<usize>
pub fn write(&mut self, data: &[u8]) -> Result<usize>
Bulk OUT write. Opens OUT only — IN belongs to the optional Self::start_reader.
Sourcepub fn read(&mut self, buf: &mut [u8]) -> Result<usize>
pub fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Blocking/synchronous bulk IN read through the driver (not the background reader).
Sourcepub fn set_line_config(&mut self, cfg: LineConfig) -> Result<()>
pub fn set_line_config(&mut self, cfg: LineConfig) -> Result<()>
Baud / framing line coding.
pub fn set_flow_control(&mut self, flow: FlowControl) -> Result<()>
pub fn set_dtr(&mut self, value: bool) -> Result<()>
pub fn set_rts(&mut self, value: bool) -> Result<()>
pub fn set_break(&mut self, enabled: bool) -> Result<()>
Sourcepub fn purge(&mut self, kind: PurgeKind) -> Result<()>
pub fn purge(&mut self, kind: PurgeKind) -> Result<()>
Clear RX and/or TX driver buffers (host-side purge).
Sourcepub fn clear(&mut self, kind: PurgeKind) -> Result<()>
pub fn clear(&mut self, kind: PurgeKind) -> Result<()>
Alias for Self::purge (clear input/output buffers).
Sourcepub fn modem_status(&mut self) -> Result<ModemStatus>
pub fn modem_status(&mut self) -> Result<ModemStatus>
Latched modem status lines (CTS/DSR/RI/CD), when the chip reports them.
Sourcepub fn close(&mut self)
pub fn close(&mut self)
Stop the bulk-IN reader, close the driver, then mark closed (idempotent).
Sourcepub fn start_reader(&mut self) -> Result<()>
pub fn start_reader(&mut self) -> Result<()>
Start the background bulk-IN reader (takes ownership of the driver’s IN endpoint).
Call after Self::set_line_config and DTR/RTS on weak OTG / CH340 adapters.
Sourcepub fn try_read(&mut self, buf: &mut [u8]) -> Result<usize>
pub fn try_read(&mut self, buf: &mut [u8]) -> Result<usize>
Non-blocking read from the background reader if running; else Self::read.
Sourcepub fn stop_reader(&mut self)
pub fn stop_reader(&mut self)
Stop and join the background reader without closing the port.
Sourcepub fn transport(&self) -> &SharedTransport
pub fn transport(&self) -> &SharedTransport
Shared transport (for advanced control or re-probe).