Supported Function Codes
The gateway supports the following Modbus function codes:
| Code | Name | Description |
|---|---|---|
| 0x01 | Read Coils | Read coil status (status registers) |
| 0x05 | Write Single Coil | Write a single coil (command registers) |
Exception Codes
The gateway returns the following Modbus exception codes when an error occurs:
| Code | Name | Description |
|---|---|---|
| 0x01 | Illegal Function | Function code not supported |
| 0x02 | Illegal Data Address | Coil address out of range |
| 0x03 | Illegal Data Value | Invalid value (neither 0xFF00 nor 0x0000) |
MBAP Header
All Modbus TCP communication uses the standard MBAP (Modbus Application Protocol) header:
| Byte | Field | Value |
|---|---|---|
| 0–1 | Transaction ID | Set by client (echoed in response) |
| 2–3 | Protocol ID | 0x0000 (Modbus) |
| 4–5 | Length | Number of following bytes |
| 6 | Unit ID | 0x01 |
| 7 | Function Code | 0x01, 0x05 |
| 8+ | Data | Function-specific payload |