pub enum ModbusError {
Show 18 variants
BroadcastUnit,
ReservedUnit {
unit: u8,
},
EmptyRead,
TooManyRegisters {
count: u16,
max: u16,
},
PastEndOfAddressSpace {
start: u16,
count: u16,
},
TooShort {
expected: usize,
found: usize,
},
ProtocolId {
found: u16,
},
LengthOutOfRange {
declared: u16,
min: u16,
max: u16,
},
LengthMismatch {
declared: u16,
found: u16,
},
TransactionMismatch {
expected: u16,
found: u16,
},
UnitMismatch {
expected: u8,
found: u8,
},
FunctionMismatch {
expected: u8,
found: u8,
},
Exception {
function: u8,
code: ExceptionCode,
},
ByteCountMismatch {
declared: u16,
expected: u16,
},
InconsistentLength {
declared: u16,
byte_count: u8,
},
WordCount {
kind: &'static str,
expected: u16,
found: usize,
},
NonFiniteScale,
ZeroScale,
}Expand description
What a Modbus read refuses, on the way out and on the way back.
Every variant names what was expected beside what was found, because the reader of this error is an operator holding a register map and a device manual, and “length mismatch” alone sends them to a packet capture.
Variants§
BroadcastUnit
Unit id 0 is a broadcast. No device answers a broadcast read.
ReservedUnit
Unit ids 248 to 254 are reserved by the specification.
EmptyRead
A read of zero registers asks a device for nothing.
TooManyRegisters
Function codes 3 and 4 answer at most MAX_REGISTERS words.
Fields
PastEndOfAddressSpace
The last register asked for sits past address 65 535.
TooShort
The byte slice is shorter than a Modbus TCP reply needs.
ProtocolId
The protocol id is not zero, so the frame is not Modbus.
LengthOutOfRange
The length field is outside what a Modbus TCP frame can carry.
Fields
LengthMismatch
The length field does not match the bytes that follow it.
Fields
TransactionMismatch
The reply echoed a different transaction id than this read used.
Fields
UnitMismatch
The reply came from a different unit than this read addressed.
FunctionMismatch
The reply carried a function code this read did not use.
Exception
The device refused the read and named a reason.
Fields
code: ExceptionCodeThe reason the device gave.
ByteCountMismatch
The reply’s byte count is not twice the register count that was asked.
Fields
InconsistentLength
The header length and the PDU byte count do not describe the same body.
Fields
WordCount
A decoder was handed the wrong number of 16-bit words.
Fields
NonFiniteScale
A scale factor must be a finite number.
ZeroScale
A scale of zero would turn every register into nothing.
Trait Implementations§
Source§impl Clone for ModbusError
impl Clone for ModbusError
Source§impl Debug for ModbusError
impl Debug for ModbusError
Source§impl Display for ModbusError
impl Display for ModbusError
impl Eq for ModbusError
Source§impl Error for ModbusError
impl Error for ModbusError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()