Modbus Practical Tool Collection: RTU/TCP Parser, Serial Scanner, and Command Line Testing Techniques

freeFree Technical Resource

This content is free to read, suitable for basic learning and search traffic.

Modbus Practical Tool Collection: RTU/TCP Parser, Serial Scanner, and Command Line Testing Techniques

The Swiss Army Knife in Modbus Debugging

In daily life Modbus Equipment debugging in progress, Not every time it needs to be opened Wireshark Capture or write packages Python script. Sometimes you just need to quickly verify a function——Decoding a string of hexadecimal messages, Scan the register range of an unknown device, Or test a read-write request on the command line. This article summarizes modbus.org The recommended lightest ones, The most practical Modbus Small tools.

Modbus RTU/TCP Online message parser

When you receive a string from the serial assistant Modbus Message, Or printed a section during debugging in the code Modbus Binary data, You need to quickly understand what this data means. on-line Modbus The message parser is the fastest solution——No need to install any software, You can use it by opening the browser.

on-line Modbus RTU Parser

Recommended tools: CAS Modbus RTU Parser (Chipkin Automation Systems Provide)

visit: store.chipkin.com/products/tools#modbus-rtu-parser

This is a pure web tool. You just need to paste a string of hexadecimal Modbus RTU Message:

01 03 00 00 00 0A C5 CD

After clicking on 'parse', The tool will automatically display:

  • Slave station address (Slave ID) = 1
  • Function code = 03 (Read Holding Registers)
  • Starting address = 0
  • Request quantity = 10 A register
  • CRC Verification = 0xCDC5 (And verify if it is correct ✓)

on-line Modbus TCP Parser

visit: store.chipkin.com/products/tools#modbus-tcp-parser

And with RTU Similar versions, But it has increased MBAP Analysis of the head: Transaction ID, Protocol ID, Length And Unit ID. Paste as follows: TCP Message is sufficient:

00 01 00 00 00 06 01 03 00 00 00 0A

Analysis results: Affairs ID=1, agreement=Modbus, From the station=1, Function code=03, Starting address=0, quantity Device address space scanning tool=10.

Modbus Download link

CAS Modbus Scanner

When you receive an incomplete register mapping manual: store.chipkin.com/products/tools/cas-modbus-scanner

Equipment time Modbus The most direct method is to 'scan', The most direct method is to 'scan'"——Use Modbus Scanner Traverse the address space of the device, Record which addresses returned valid data.

usage method:

  1. Set connection method (TCP Input IP:Port, RTU Select serial port)
  2. Select the address range to scan (Suggest starting with a small scope 0-100 Probing)
  3. Select the type of data to be scanned: Coil, Discrete input, Maintain registers, Input register
  4. Click Start Scan, Observation results
  5. Record the addresses that return valid data
  6. Combining physical equipment (Change physical quantities, Observe the corresponding register changes) Verify

Scanning skills:

  • First scan and hold the register (4xxxx) , Because the configuration and measurement data of most devices are here
  • If an address returns an exception code 02 (Illegal data address) , Indicates that the address is invalid
  • If returned 0 But there are no abnormalities, Need to determine if the value is true=0 Or is the device not implementing the address (Scanning alone cannot distinguish)
  • Change physical incentives (Like heating up, Rotary encoder) Follow up scan, Observe which address values have changed

Command line protocol testing: modbus-cli skill Except for specialized tools

Many common command-line tools can also be used, Testing Modbus Use:

Testing Netcat Connectivity TCP Use

# Test Modbus TCP Is the device online
nc -zv 192.168.1.100 502

# If output "Connection to 192.168.1.100 502 port [tcp/*] succeeded!" Explanation online

One line command test Python Use

# Install pymodbus after,One line test reads hold register
python3 -c "
from pymodbus.client import ModbusTcpClient
c = ModbusTcpClient('192.168.1.100')
c.connect()
rr = c.read_holding_registers(0, 5, slave=1)
print('Values:', rr.registers if not rr.isError() else rr)
c.close()
"

Analyze binary xxd data Quick reference for protocol functions Modbus During debugging, it is often necessary to check the function code correspondence table

# If you have a paragraph Modbus Binary data file,It can be used. xxd Check
xxd modbus_dump.bin

# or use hexdump Format display
hexdump -C modbus_dump.bin | head -20

Modbus The following is a quick search for commonly used function codes

Function code, name:

Data typeOperationCoilRead
01 (0x01)Read Coilscoil (0xxxx) Read 1-bit
02 (0x02)Read Discrete InputsDiscrete input (1xxxx) Read 1-bit
03 (0x03)Read Holding RegistersMaintain registers (4xxxx) Read 16-bit
04 (0x04)Read Input RegistersInput register (3xxxx) Read 16-bit
05 (0x05)Write Single CoilCoilWrite 1-bit
06 (0x06)Write Single RegisterMaintain registersWrite 16-bit
15 (0x0F)Write Multiple CoilsCoilWrite more 1-bit
16 (0x10)Write Multiple RegistersMaintain registersWrite more 16-bit
23 (0x17)Read/Write Multiple RegistersMaintain registersRead write combination

Modbus Quick search for abnormal codes

Exception codemeaningCommon reasons
01Illegal function codeThe device does not support this function code
02Illegal data addressThe requested address range exceeds the available range of the device
03Illegal data valuesThe value written exceeds the allowed range
04Substation equipment malfunctionInternal device error, Unable to process request
05Confirm (ACK) The request has been accepted but will take a long time to process
06The slave station equipment is busyThe device is busy, Try again later

Summary

Modbus Debugging does not require the use of heavy tools every time. Online parsers are suitable for quickly decoding messages, Scanners are suitable for reverse register mapping of unknown devices, Command line tools are suitable for automated testing. Mastering these 'small tools' can help you Modbus Doubling debugging efficiency——When encountering problems, use the lightest tools to locate them first, Only use when in-depth analysis is needed Wireshark Waiting for heavy tools.

Put this resource to use in a real project?

Go to the Tool Center for message parsing, CRC verification and device debugging, or submit your requirements for selection and integration advice.

Engineer Membership

Turn this article into actionable debugging resources

After activation, you can use advanced message parsing, resource pack downloads, code examples, engineering cases and priority technical support, suitable for real project delivery.

Unlimited Advanced Tools
Resource & Code Packs
Complete Engineering Case Library
Priority Technical Support

Leave a Reply

Your email address will not be published. Required fields are marked *.