简体   繁体   中英

Modbus RTU slave RS-485 failed to response

I'm trying to write modbus slave and have one problem: I'm correctly receive requests from master, but when I try to response it's look like something is incorrectly sended to serialport, because when I plug RS485 sniffer - I see both req and res (in HEX).

Hardware: Mac (slave written by me) - USBtoRS485 - ICPCON tGW-715 (TCPtoRTU gateway) - Win PC (software master)

When I'm trying this variant: Win PC (software slave) - USBtoRS485 - ICPCON tGW-715 (TCPtoRTU gateway) - Win PC (software master) everything works.

Libs: libmodbus, h5.modbus (node.js). Doesn't matter - correct request, but no response.

Target PC (for slave) will be on Linux, so Mac is nearly closer than Win.

I'm already have no ideas what to check and how to make it work. What can be wrong?

The Win PC variant is working so, hardware should be fine. Without more details, I would suggests another approach, if your final goal is to use the system in Linux: use aa virtual machine on Windows, with a Linux guest. I work with ICP DAS tech support, and have used VirtualBox with tM-7561 and I-7561 USBtoRS485 converters, with both Linux and Windows hosts.

I have no experience on Mac, but another option would be trying a Modbus Slave not written by you, for example pyModSlave and see if it works correctly on your Mac, it also shows you the packets sent/received.

If pyModSlave works correctly on Mac, maybe try a software serial sniffer with your slave. On Windows I use the one from HHD Software, it has serial, USB and TCP/IP sniffers. On Mac/Linux you should be able to use Wireshark to sniff USB communications, but I haven't done that yet personally.

Instead of the sniffer, maybe you can use a null modem emulator, so that what you send from a (virtual) serial port will be received on another (virtual) serial port on your Mac, so that you can inspect the data sent/received. On Windows I use com0com, for Linux there is tty0tty that I haven't used yet. Not sure what is available on Mac. Or else just use 2 USBtoRS485 with D+ and D- interconnected, on one port your slave, on the other port a master like qModMaster that shows packets.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM