pub enum BridgeError<SE, TE> {
TcpClosed,
RtuClosed,
TcpIo(TE),
RtuIo(SE),
RtuCrcMismatch,
BufferOverflow,
Timeout,
}Expand description
Hard error returned by Connection::next.
On any BridgeError the caller should exit the connection loop, close the
TCP stream, and call Bridge::accept for the next
client:
loop {
match conn.next().await {
Ok(event) => { /* handle */ }
Err(BridgeError::TcpClosed) => break, // normal disconnect
Err(e) => { defmt::error!("{}", e); break; } // hard error
}
}
conn.into_stream().close();SE is the serial-port error type and TE is the TCP-stream error type.
Both come from the embedded_io_async::ErrorType (or [embedded_io::ErrorType])
implementations of the serial and TCP types passed to
BridgeBuilder.
Variants§
TcpClosed
TCP client closed the connection cleanly (EOF / zero-byte read).
This is the normal exit condition and is not an error in itself. Break the connection loop and accept the next client.
RtuClosed
RTU master closed the serial connection cleanly (EOF / zero-byte read).
Normal exit condition in client mode — equivalent to TcpClosed in bridge mode.
TcpIo(TE)
TCP I/O error from the underlying stream.
RtuIo(SE)
Serial (RTU) I/O error from the underlying serial port.
RtuCrcMismatch
RTU device response failed CRC-16 verification.
This usually indicates a wiring problem, an incorrect baud rate, or electrical noise on the RS-485 bus.
BufferOverflow
A Modbus frame was larger than the internal frame buffer can hold.
The internal buffers support the full Modbus specification maximum (255-byte RTU / 261-byte TCP). This error indicates a malformed or non-Modbus frame.
Timeout
An RTU or TCP I/O operation did not complete within the configured timeout.