pub struct StdSerialTransport { /* private fields */ }Expand description
A concrete implementation of Transport for Serial communication using serialport crate.
Supports both RTU and ASCII modes.
Implementations§
Source§impl StdSerialTransport
impl StdSerialTransport
Sourcepub fn new(mode: SerialMode) -> Self
pub fn new(mode: SerialMode) -> Self
Creates a new StdSerialTransport instance.
Sourcepub fn available_ports() -> Result<Vec<SerialPortInfo>, Error>
pub fn available_ports() -> Result<Vec<SerialPortInfo>, Error>
Returns a list of available serial ports on the system. This can be useful for allowing a user to select a port.
Trait Implementations§
Source§impl Debug for StdSerialTransport
impl Debug for StdSerialTransport
Source§impl Transport for StdSerialTransport
impl Transport for StdSerialTransport
Source§fn disconnect(&mut self) -> Result<(), Self::Error>
fn disconnect(&mut self) -> Result<(), Self::Error>
Closes the active serial port connection.
If no connection is active, this operation does nothing and returns Ok(()).
Source§fn recv(&mut self) -> Result<Vec<u8, MAX_ADU_FRAME_LEN>, Self::Error>
fn recv(&mut self) -> Result<Vec<u8, MAX_ADU_FRAME_LEN>, Self::Error>
Receives a Modbus Application Data Unit (ADU) from the serial port.
This implementation is non-blocking: it checks the serial port’s input buffer
and reads only the bytes currently available. If no bytes are available,
it returns TransportError::Timeout.
§Returns
Ok(Vec<u8, MAX_ADU_FRAME_LEN>) containing the received ADU, or an error otherwise.
Source§fn is_connected(&self) -> bool
fn is_connected(&self) -> bool
Checks if the transport is currently connected to a remote host.
Source§fn transport_type(&self) -> TransportType
fn transport_type(&self) -> TransportType
Returns the type of transport.
Source§type Error = TransportError
type Error = TransportError
MbusError for upper-layer processing.