1

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?

Disminder
  • 51
  • 5

1 Answers1

1

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 a a 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.

Community
  • 1
  • 1
Nelson
  • 91
  • 1
  • 1
  • 5
  • Thanks, I'll try pyModSlave. It would be really strange, if it will work. I'll comment later about it. About sniffers - on sniffer connected between USBtoRS485 and ICPCON tGW-715 - I'll see both request and response (99,9% sure about that, checked this in a "field"). – Disminder Mar 10 '17 at 22:29
  • I assume a hardware sniffer, with LEDs showing requests and responses. A software sniffer will show packets and even timing, so you can check if you have problems with timing on Modbus RTU – Nelson Mar 10 '17 at 22:42
  • Another thing, what Modbus master are you using on Windows PC? If you use qModMaster, you may see if it is receiving malformed responses. Does your master show you raw messages/packets? – Nelson Mar 10 '17 at 23:06
  • [This](http://www.modbustools.com/download.htm) Master and Slave was used on Win PC. This software don't show raw packets, now I see it only on slave. Master shows that device behind gateway (tGW) unable to response. – Disminder Mar 13 '17 at 05:08
  • [QModMaster](https://sourceforge.net/projects/qmodmaster/) shows packets. Win PC (software slave) - USBtoRS485 - ICPCON tGW-715 (TCPtoRTU gateway) - Win PC (software master) still works? If you go to Mac variant, do you at least see something in the slave bus monitor? I guess just using Win as master and Mac as TCP slave work without any issue, right? – Nelson Mar 13 '17 at 18:35
  • Still work with QModMaster. On Mac (RTU) variant I see that tGW response with 0x0B exception, which mean that tGW didn't see slave response. TCP works. Timeouts, port configs (both Mac and tGW) checked - everything correct, at least because I see requests on Mac. – Disminder Mar 14 '17 at 14:34
  • I'm running out of ideas... So the request is being received by pyModSlave and apparently it sends out the reply, but tGW does not receive it. The USBtoRS485 converter between Mac and tGW works in the PC-PC variant. Some wild guesses would be to check driver settings of the converter on the Mac, or buffer problems, but I have no idea on how to do that. Do you have another converter so that you could test QModMaster-----Converter=====Converter---pyModSlave? And I do think you may need to check the option of a VM with Linux on your Windows PC – Nelson Mar 14 '17 at 15:58
  • Don't have another converter. Probably gonna buy one more. Already checked modbus-tk, libmodbus and h5.modbus under Linux VM on Mac (via passing USB to guest system) - same error. Check it under Win host? – Disminder Mar 14 '17 at 18:34
  • Yes, maybe it is some setting in Mac we are not aware of – Nelson Mar 14 '17 at 18:36