Modbus slave plus vspd easily debug modbus RTU protocol program

Recently, I have to use java to write a program to communicate with hardware, collect power and other related information, the protocol uses modbus RTU, serial communication does not use tcp.

What java serial communication uses is RXTXcomm.jar package and rxtxParallel.dll, rxtxSerial.dll two library files.

After the program is written, because there is no hardware debugging at hand, I can only debug it on my computer. At this time, I use the vspd artifact, which is very cool to use with modbus slave.

1. Download and install the modbus slave, configure the analog data, and use it as the hardware to be collected.

2. Download and install vspd, open the main interface, and click the "Add pair" button behind COM1 and COM2.

3. Connect the virtual COM2 serial port with modbus slave, click "Connection" -> "connect", configure the baud rate and other information, and click OK to connect.

4. Start the program written by yourself, scan the port, connect to the COM1 port, and try to send data, and the data can be received normally.

5. Successfully received the information. In this way, there is no need for hardware or serial port connection, and the acquisition program can be debugged normally.

Supplement: You can see whether vspd successfully opened the serial port in the device manager.

 

 

Note: The register address and data in the modbus slave should simulate the real address and data in the hardware to be collected as much as possible, so as to be the closest to the actual collection environment.

 

Especially those students who do not have hardware debugging at hand and the hardware debugging site does not have a good coding environment, I hope to help you.

 

 

Guess you like

Origin blog.csdn.net/qq_36961530/article/details/107185858