Function codes, register and coil validation, exception testing, and endurance runs - what Modbus testing covers and how to automate it.

Modbus testing is the validation of Modbus RTU or Modbus TCP communication between a Modbus master (client) and one or more Modbus slave (server) devices - verifying correct function code handling, register and coil values, exception response behaviour, and communication timing.
Modbus is the most widely deployed industrial protocol in the world - found in PLCs, HMIs, sensors, drives, flow meters, smart meters, and building management systems. It defines a simple request-response model where a master sends requests to addressed slaves: read coils, read discrete inputs, read/write holding registers, read input registers.
Two variants, same test approach: Modbus RTU uses serial RS485/RS232 framing with CRC-16 checksum; Modbus TCP wraps the same PDU in a TCP/IP frame over Ethernet. TestBot's Modbus Server and Client agents support both transports. The same test cases cover both - only the transport configuration changes.
| FC | Name | Data Objects | What It Tests |
|---|---|---|---|
| 01 (0x01) | Read Coils | Output coils (1-bit read/write) | Coil state read, bit-packing, quantity limits |
| 02 (0x02) | Read Discrete Inputs | Input coils (1-bit read-only) | Discrete input state, correct read-only enforcement |
| 03 (0x03) | Read Holding Registers | 16-bit read/write registers | Register values, byte order, quantity limits (max 125 registers) |
| 04 (0x04) | Read Input Registers | 16-bit read-only registers | Input register values, read-only enforcement |
| 05 (0x05) | Write Single Coil | Single output coil | 0xFF00 = ON, 0x0000 = OFF - correct encoding validation |
| 06 (0x06) | Write Single Register | Single holding register | 16-bit value write, immediate readback confirmation |
| 15 (0x0F) | Write Multiple Coils | Multiple output coils | Bulk coil write, byte count validation, partial byte handling |
| 16 (0x10) | Write Multiple Registers | Multiple holding registers | Bulk register write, byte count = 2× register count validation |
| Exception responses | Various FC with error | - | Illegal function (01), illegal data address (02), illegal data value (03), slave device failure (04) |
TestBot's Modbus Server Agent simulates a Modbus slave (PLC or sensor). The Modbus Client Agent sends requests to a real Modbus device. Both use the same RS485 USB Adapter and support RTU and TCP transport.
| Scenario | Agents Used | Validated Outcome |
|---|---|---|
| PLC Register Read Validation | Modbus Client Agent - FC03 read holding registers | All defined registers return values within spec; out-of-range addresses return exception 02 |
| Sensor Coil State Test | Modbus Client Agent - FC01 read coils | All coil states match physical sensor states; bit-packing correct |
| HMI Write and Confirm | Modbus Client Agent - FC16 write + FC03 readback | Written values confirmed by readback within 100ms |
| Slave Simulation for Master Test | Modbus Server Agent (slave simulation) | Master device under test correctly reads and writes all simulated register maps |
| Exception Response Validation | Modbus Client Agent - invalid address + function code | Correct exception codes returned for each error condition |
| Endurance Test (24h) | Modbus Client Agent - continuous FC03 poll | Zero communication errors over 24-hour endurance run; all values within tolerance |

Modbus testing is the validation of Modbus RTU or TCP communication - verifying that a device correctly handles all implemented function codes, returns correct register and coil values, sends correct exception responses for invalid requests, and meets timing requirements. It covers both the Modbus master (client) and slave (server) sides of the communication.
Modbus Server + Client bundle covers both sides. RS485 Adapter for RTU, PC Ethernet for TCP. 14-day free trial.