Four data tables
- Coils: read/write bits, typically output commands.
- Discrete inputs: read-only bits, typically physical input states.
- Input registers: read-only 16-bit measurements.
- Holding registers: read/write 16-bit settings and state.
Translate Modbus register labels into PDU addresses and choose valid read/write functions.
Pick a device table, translate the human label into the address actually carried in the Modbus PDU, and see whether the requested function code is legal for that table. The default example reads two input registers from labels 30002 and 30003.
Read-only 16-bit measurement values.
Human-facing labels are one-based and include the table family.
Modbus request PDUs carry the zero-based address, not the 3x/4x prefix.
FC04 reads input registers only.
Unit 17 reads two input registers beginning at PDU address 1.
The server maps address 1 to label 30002 in the input register table.
The response returns a byte count followed by two big-endian register values.
Read/write output bits. Examples: relays, lamps, motor run commands.
Read-only input bits. Examples: limit switches, door contacts, alarms.
Read-only 16-bit measurements. Examples: temperature, humidity, pressure.
Read/write 16-bit values. Examples: setpoints, modes, configuration.
Read request: function, starting address, and quantity.
Normal response: function, byte count, and register data.
The PDU address 0x0001 selects documentation label 30002. The response contains two 16-bit values: 251 and 536.
When FC01 or FC02 returns multiple bits, the first addressed bit is packed into the least significant bit of the first data byte. Extra bits in the final byte are padding.
Register data is carried as 16-bit quantities in big-endian byte order. Device manuals define scaling, units, and signed versus unsigned interpretation.
A device may implement only a subset of addresses and functions. Valid table family does not guarantee that every address in that range exists.