pub enum Function {
ReadCoils,
ReadDiscreteInputs,
ReadHoldingRegisters,
ReadInputRegisters,
WriteSingleCoil,
WriteSingleRegister,
WriteMultipleCoils,
WriteMultipleRegisters,
}Expand description
A Modbus function code, naming the operation a request asks for.
This enum covers the function codes that read and write the four Modbus data tables
(coils, discrete inputs, holding registers, input registers), which is what the great
majority of field devices use. A function code outside this set still travels fine
through Pdu::raw and Adu; this enum is the typed
view of the common ones, not a limit on what the framing carries.
§Examples
use pamoja_modbus::Function;
assert_eq!(Function::ReadHoldingRegisters.code(), 0x03);
assert_eq!(Function::from_code(0x10), Some(Function::WriteMultipleRegisters));
assert_eq!(Function::from_code(0x99), None);Variants§
ReadCoils
Read one or more coils (read/write bits). Function code 0x01.
ReadDiscreteInputs
Read one or more discrete inputs (read-only bits). Function code 0x02.
ReadHoldingRegisters
Read one or more holding registers (read/write 16-bit words). Function code 0x03.
ReadInputRegisters
Read one or more input registers (read-only 16-bit words). Function code 0x04.
WriteSingleCoil
Write a single coil. Function code 0x05.
WriteSingleRegister
Write a single holding register. Function code 0x06.
WriteMultipleCoils
Write a contiguous block of coils. Function code 0x0F.
WriteMultipleRegisters
Write a contiguous block of holding registers. Function code 0x10.