#[repr(u8)]pub enum FunctionCode {
Show 20 variants
Default = 0,
ReadCoils = 1,
ReadDiscreteInputs = 2,
WriteSingleCoil = 5,
WriteMultipleCoils = 15,
ReadHoldingRegisters = 3,
ReadInputRegisters = 4,
WriteSingleRegister = 6,
WriteMultipleRegisters = 16,
MaskWriteRegister = 22,
ReadWriteMultipleRegisters = 23,
ReadFifoQueue = 24,
ReadFileRecord = 20,
WriteFileRecord = 21,
ReadExceptionStatus = 7,
Diagnostics = 8,
GetCommEventCounter = 11,
GetCommEventLog = 12,
ReportServerId = 17,
EncapsulatedInterfaceTransport = 43,
}Expand description
Modbus Public Function Codes.
These are the standardized function codes defined in the Modbus Application Protocol Specification V1.1b3.
See:
- Section 5.1 Public Function Code Definition
- Section 6.x for individual function behaviors
Reference: :contentReference[oaicite:1]{index=1}
Variants§
Default = 0
0x00 — Undefined This value is not defined in the specification and can be used as a placeholder for uninitialized or unknown function codes. It is not a valid function code for actual Modbus transactions.
ReadCoils = 1
0x01 — Read Coils
Reads the ON/OFF status of discrete output coils. Section 6.1
ReadDiscreteInputs = 2
0x02 — Read Discrete Inputs
Reads the ON/OFF status of discrete input contacts. Section 6.2
WriteSingleCoil = 5
0x05 — Write Single Coil
Forces a single coil to ON (0xFF00) or OFF (0x0000). Section 6.5
WriteMultipleCoils = 15
0x0F — Write Multiple Coils
Forces multiple coils to ON/OFF. Section 6.11
ReadHoldingRegisters = 3
0x03 — Read Holding Registers
Reads one or more 16-bit holding registers. Section 6.3
ReadInputRegisters = 4
0x04 — Read Input Registers
Reads one or more 16-bit input registers. Section 6.4
WriteSingleRegister = 6
0x06 — Write Single Register
Writes a single 16-bit holding register. Section 6.6
WriteMultipleRegisters = 16
0x10 — Write Multiple Registers
Writes multiple 16-bit holding registers. Section 6.12
MaskWriteRegister = 22
0x16 — Mask Write Register
Performs a bitwise mask write on a single register. Section 6.16
ReadWriteMultipleRegisters = 23
0x17 — Read/Write Multiple Registers
Reads and writes multiple registers in a single transaction. Section 6.17
ReadFifoQueue = 24
0x18 — Read FIFO Queue
Reads the contents of a FIFO queue. Section 6.18
ReadFileRecord = 20
0x14 — Read File Record
Reads structured file records. Section 6.14
WriteFileRecord = 21
0x15 — Write File Record
Writes structured file records. Section 6.15
ReadExceptionStatus = 7
0x07 — Read Exception Status (Serial Line Only)
Returns 8-bit exception status. Section 6.7
Diagnostics = 8
0x08 — Diagnostics (Serial Line Only)
Provides diagnostic and loopback tests. Requires sub-function codes. Section 6.8
GetCommEventCounter = 11
0x0B — Get Communication Event Counter (Serial Line Only)
Returns communication event counter. Section 6.9
GetCommEventLog = 12
0x0C — Get Communication Event Log (Serial Line Only)
Returns communication event log. Section 6.10
ReportServerId = 17
0x11 — Report Server ID (Serial Line Only)
Returns server identification. Section 6.13
EncapsulatedInterfaceTransport = 43
0x2B — Encapsulated Interface Transport
Used for:
- CANopen General Reference (Sub-function 0x0D)
- Read Device Identification (Sub-function 0x0E)
Section 6.19, 6.20, 6.21
Trait Implementations§
Source§impl Clone for FunctionCode
impl Clone for FunctionCode
Source§fn clone(&self) -> FunctionCode
fn clone(&self) -> FunctionCode
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more