pub enum FunctionCode {
ReadCoils,
ReadDiscreteInputs,
ReadHoldingRegisters,
ReadInputRegisters,
WriteSingleCoil,
WriteSingleRegister,
WriteMultipleCoils,
WriteMultipleRegisters,
Other(u8),
}Expand description
Modbus function code extracted from a request frame.
Covers the most common read/write operations. Unknown function codes are
wrapped in Other and forwarded to the RTU device
without modification, so vendor-specific extensions work transparently.
§Examples
if let BridgeEvent::Transaction(t) = event {
match t.function_code {
FunctionCode::ReadHoldingRegisters => { /* … */ }
FunctionCode::WriteMultipleRegisters => { /* … */ }
other => defmt::warn!("unexpected FC: {}", other),
}
}Variants§
ReadCoils
FC 0x01 — reads one or more output coils (digital outputs).
ReadDiscreteInputs
FC 0x02 — reads one or more discrete inputs (digital inputs).
ReadHoldingRegisters
FC 0x03 — reads one or more holding registers (read/write 16-bit words).
ReadInputRegisters
FC 0x04 — reads one or more input registers (read-only 16-bit words).
WriteSingleCoil
FC 0x05 — writes a single output coil.
WriteSingleRegister
FC 0x06 — writes a single holding register.
WriteMultipleCoils
FC 0x0F — writes multiple output coils in a single request.
WriteMultipleRegisters
FC 0x10 — writes multiple holding registers in a single request.
Other(u8)
Any function code not listed above — passed through to the RTU device transparently.
Trait Implementations§
Source§impl Clone for FunctionCode
impl Clone for FunctionCode
Source§fn clone(&self) -> FunctionCode
fn clone(&self) -> FunctionCode
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FunctionCode
impl Debug for FunctionCode
Source§impl Display for FunctionCode
impl Display for FunctionCode
Source§impl From<u8> for FunctionCode
impl From<u8> for FunctionCode
Source§impl PartialEq for FunctionCode
impl PartialEq for FunctionCode
Source§fn eq(&self, other: &FunctionCode) -> bool
fn eq(&self, other: &FunctionCode) -> bool
self and other values to be equal, and is used by ==.