Modbus RTU Parser
The Modbus RTU Parser plugin parses sent and received Modbus RTU messages. It splits the byte stream into frames, checks each CRC, and shows the slave address, function code, data summary, and raw hexadecimal content for each frame.
It suits debugging a Modbus RTU master or slave. When this software acts as a bus listener, turn on Monitor Mode to watch master and slave traffic together and diagnose bus faults such as response timeouts and CRC errors.
Data Requirements
The plugin parses standard Modbus RTU frames. Each frame contains these fields:
| Field | Length | Description |
|---|---|---|
| Slave address | 1 byte | 1 to 247 are slave addresses. 0 is the broadcast address |
| Function code | 1 byte | See the table below |
| Data | Variable | Depends on the function code |
| CRC16 | 2 bytes | Low byte first. Polynomial 0xA001, initial value 0xFFFF |
Addresses, quantities, and register values are read as big-endian (high byte first).
Supported function codes:
| Function code | Name |
|---|---|
| 0x01 | Read Coils |
| 0x02 | Read Discrete Inputs |
| 0x03 | Read Holding Registers |
| 0x04 | Read Input Registers |
| 0x05 | Write Single Coil |
| 0x06 | Write Single Register |
| 0x0F | Write Multiple Coils |
| 0x10 | Write Multiple Registers |
Exception responses (function code with the high bit set) are also parsed. The plugin recognizes these exception codes: 0x01 Illegal Function, 0x02 Illegal Data Address, 0x03 Illegal Data Value, 0x04 Slave Device Failure, 0x05 Acknowledge (Processing), 0x06 Slave Device Busy, 0x08 Memory Parity Error, 0x0A Gateway Path Unavailable, and 0x0B Gateway Target Device Failed to Respond.
Frames with other function codes: In normal mode, only 4-byte frames (address, function code, and CRC) with a valid CRC are shown as "Unknown function code". Other frames are dropped. In monitor mode, such a 4-byte frame is treated as a request or a response, and a request shows the warning "Unknown or custom function code". Data of other lengths appears as unrecognized data.
Data Source
For the general rules, see Plugins Overview. This plugin receives raw bytes, so the receive display mode (Text or HEX) has no effect on it.
- In normal mode, sent (TX) and received (RX) data each have their own buffer and are split into frames separately.
- The plugin receives data before the frame processing script runs. Frames dropped by the script are still parsed and shown.
- When the Stop Receive button in the device window is on, received data is not sent to this plugin.
- Clearing the device window also clears this plugin's table and statistics.
Text Split (Default)
This plugin does not use text split. It does not parse received text, so it has no text split settings.
Variable Rendering
This plugin does not use variable rendering. It does not read variables, so it has no variable rendering settings.
Channel Settings
This plugin has no Channels button, so it has no channel settings.
Display
In normal mode, the table columns are Time, Direction, Slave, Function, Length, Data Summary, CRC, and Raw Frame. In monitor mode, the Direction column becomes Role, and a Diagnosis column appears.
Table
- Time: The time at which the first byte of the frame's receive batch arrived, in milliseconds.
- Direction: TX is orange and RX is green. In monitor mode, Role shows Master (orange), Slave (green), or Unknown (gray).
- Slave and Function: In monitor mode, data with a CRC error whose role cannot be determined shows "-".
- Length: The number of bytes in the complete frame, including the address and CRC.
- CRC: "OK" in green when the check passes, or "Failed" in red when it fails. Normal mode shows only frames with a valid CRC, so this column always shows OK there.
- Diagnosis (monitor mode only): Lists all diagnostic messages for the frame, separated by semicolons.
- Raw Frame: The complete hexadecimal content, including the address and CRC.
A row with an error has a light red background. A row with only warnings has a light yellow background. Information items do not color the row.
The table keeps up to 5000 rows. When the limit is reached, the oldest rows are removed. When a new frame arrives, the table scrolls to the last row.
Data Summary
The data summary depends on the function code:
- Read requests: The start address and quantity, for example
Start address 0x0010, Quantity 4. - Read Coils and Read Discrete Inputs responses: The bit values, 8 bits per byte, lowest bit first, for example
Bits: [1, 0, 1, 1, 0, 0, 0, 0]. - Read Registers responses: The values in the checked formats. If no format is checked, the data is shown in hexadecimal.
- Write Single Coil: The address and value. A value of 0xFF00 is shown as
ON(0xFF00), a value of 0x0000 asOFF(0x0000), and other values in hexadecimal. - Write Single Register: The address and value, with the value in the checked formats. If no format is checked, it is shown in hexadecimal. U32, S32, and F32 need two registers, so when only these formats are checked, the value shows an empty list such as
U32: []. - Write Multiple Coils and Write Multiple Registers requests: The start address, quantity, and data. Coil data is shown as bits, and register data uses the checked formats. Responses show only the start address and quantity.
- Exception responses: The exception code and its name, for example
Exception code 0x02 (Illegal Data Address). Unknown codes show only the number. - Other: The hexadecimal content of the data area.
- Data that fails the CRC check (monitor mode only):
Unparsed data (N bytes).
The Data Summary checkboxes in the toolbar choose the register formats. Only U16 is checked by default. You can check more than one format. Changing a checkbox rebuilds the whole table.
- U16, S16: Each register is one value, shown as an unsigned or signed integer.
- U32, S32, F32: Each pair of registers forms one value, and the first register holds the high 16 bits. If the register count is odd, the last register is not used. F32 is parsed as an IEEE 754 single-precision float and shown with 6 significant digits.
- BIN: Each register is shown as a 16-bit binary number.
Toolbar
The buttons appear from left to right in the order below. Help is always last.
| Icon | Button | Description |
|---|---|---|
| Monitor Mode | Checkable. When checked, the plugin identifies each frame as a master request or a slave response and diagnoses bus faults. Unchecked means normal mode. Switching clears the parser buffers and request pairing, but displayed frames stay. | |
| Pause | Checkable. While checked, received data is discarded without being parsed or counted in the statistics, and the icon changes to | |
| Clear | Clears the table, statistics, parser buffers, and unfinished request pairing. It does not change the pause state. | |
| Help | Opens this plugin's online help page in your browser. |
Besides the buttons, the toolbar has these controls:
- Data Summary label and six checkboxes, U16, S16, U32, S32, F32, and BIN: Choose the register formats for the data summary. See the data summary under Display.
- Response Timeout spin box (monitor mode only): Ranges from 10 to 10000 ms in steps of 50 ms, and defaults to 500 ms. A new value applies to requests sent after the change. Requests already waiting keep their current timeout.
- Show Issues Only checkbox (monitor mode only): When checked, keeps only frames with a warning or error. Frames with only information items, such as a broadcast write request, are hidden too.
- Statistics label (monitor mode only): Shows the frame, error, and warning totals since the last clear. Removing old rows does not reduce them.
Normal Mode
- Frames are split separately for TX and RX. Only frames with a valid CRC are shown.
- Read requests and responses are told apart by frame length. The plugin does not detect roles or run diagnostics.
Monitor Mode
When this software acts as a bus listener, messages from both the master and the slave arrive as received data. With Monitor Mode checked:
- TX and RX are ignored. All data is processed in one buffer.
- Each frame is identified as a master request or a slave response, and the Direction column becomes the Role column.
- The Diagnosis column lists bus faults. Show Issues Only keeps only the frames with a warning or error.
- Switching monitor mode, or resuming after a pause, clears the parser buffers and request pairing. Displayed frames stay in the table.
Role Detection
In monitor mode, the role of each frame is decided by its function code, its length, and any waiting request:
- Read Registers (0x03, 0x04): A fixed 8-byte frame is a request. Any other length is a response.
- Read Coils and Read Discrete Inputs (0x01, 0x02): An 8-byte frame is usually a request. A response with 3 data bytes is also 8 bytes long. If a request for the same slave and function code is waiting, the frame is a response.
- Write Single (0x05, 0x06): A response echoes the request. When a request with the same function code is waiting, a frame is a response if any of these is true: its data (address and value) matches the request, its slave address and register address both match the request, or its slave address matches and it arrives within 100 ms after the request. Other frames are requests.
- Write Multiple (0x0F, 0x10): An 8-byte frame is a response. A longer frame is a request.
- Exception responses (function code with the high bit set): Always responses.
- Other function codes: A response if the slave address and function code match the waiting request. Otherwise, a request.
Request and Response Pairing
After a master request is sent, the plugin waits for the matching slave response:
- If no response arrives before the Response Timeout (default 500 ms), the request is marked "Slave N no response". This diagnosis is added to the request's row, so no new row appears.
- If the next request is sent before a response arrives, the previous request is also marked as no response.
- If a response has a different slave address or function code from the request, it is marked "Response does not match request", and the request is no longer waited for.
- A response that arrives after its request has timed out is marked "Late response".
- A response with no matching request is marked "Orphan response".
- A broadcast write request (slave address 0) does not wait for a response.
- A response whose slave address matches the waiting request, but that fails the CRC check or is incomplete, is marked as a response error, and the request's timeout is cancelled.
- While paused, timeouts for requests already sent are still checked and counted as errors.
Diagnosis Items
Errors (Light Red Background)
- The frame fails the CRC check, is incomplete, or contains unrecognized data.
- The slave does not respond.
- The response does not match the request.
- A Write Single response does not echo the request, or a Write Multiple response has a different start address or quantity from the request.
- The response byte count does not match the requested quantity, or the byte count field does not match the actual data length.
- The response slave address is 0.
- An exception response uses an undefined exception code.
- The request parameters are invalid. The slave address is greater than 247, a read request uses broadcast address 0, the quantity is out of range, a Write Single Coil value is not 0xFF00 or 0x0000, or a Write Multiple request has a byte count that does not match its quantity. The allowed quantities are 1 to 2000 for Read Coils and Read Discrete Inputs, 1 to 125 for Read Registers, 1 to 1968 for Write Multiple Coils, and 1 to 123 for Write Multiple Registers.
Warnings (Light Yellow Background)
- Late response.
- Orphan response.
- A slave exception response with a defined exception code.
- A request with an unknown or custom function code.
Information (Not Colored)
- A broadcast write request, which the slave does not answer.
Notes
- Normal mode does not detect roles. A Read Coils or Read Discrete Inputs response with 3 data bytes is 8 bytes long, so its data summary may be shown as a read request. Turn on Monitor Mode to tell them apart.
- A frame can be split across several receive batches. After data arrives, the plugin waits 100 ms for more bytes and joins them if they arrive. If no new data arrives within 100 ms, incomplete data is discarded in normal mode, and shown as an error frame in monitor mode.
- Frames from the same receive batch show the same time.
- In monitor mode, after a pause ends, a mode switch, or a clear, requests and responses must be paired again.
- When both text split and variable rendering are off, the plugin splits received text by English commas. This rule does not apply to this plugin, which always parses raw bytes.
