Modbus RTU Client/Master Codec
The client (master) side of Modbus RTU, usually on a serial port with an
RS-485 adapter. It adds the CRC-16 to every request, checks it on responses, matches each response to its request,
labels every field in the message list and decodes registers and coils into values such as
modbus_rtu_1:40001 (see Modbus Helpers for the IDs). Exception
responses are decoded too.
Send requests with the Modbus RTU message inputs or the modbus_rtu_* Lua helpers.
Frames are delimited by bus silence: raise Silent Interval if responses arrive split in two (slow USB
adapters, long cables). The codec works over any byte stream, so a transparent serial-to-Ethernet converter can be
used through a TCP Client connection.


Configuration reference
| Config ID | modbus_rtu_codec |
| Selected by | app_codec = "modbus_rtu_codec" |
| Platforms | Linux, Windows, Android |
| License | Premium |
Binary Modbus RTU protocol with automatic append and validate CRC-16 checksums
Modbus RTU will automatically handle CRC-16 checksum calculation when send message and verification when receive message
| Setting | Key | Type | Default | Notes |
|---|---|---|---|---|
| Silent Interval (ms) | with_receive_timeout | Integer | 20 | Required |
Setting details
Silent Interval (ms)
Minimum silent interval between frames, typically more than 3.5 character times
Example config
Default values as they appear in a saved configuration (for example the JSON block at the end of a cycbox/examples/*.lua file). Settings detected at runtime are omitted.
{
"app": {
"app_codec": "modbus_rtu_codec"
},
"modbus_rtu_codec": {
"with_receive_timeout": 20
}
}