MODBUS/TCP access

J

Thread Starter

John Haggerty

I've been trying to send a command to a MODBUS/TCP device and read the response by reading and writing to a socket with Perl. Using Ethereal to sniff a closed source MODBUS/TCP client, I thought it would be very simple, but I have yet to get a response of any kind. I've opened socket to the device, port 502 tcp, sent it the 12 bytes I saw sent by the closed source client, and... nada in return. Something I'm missing?
 
A

Automation Linse

John, I assume you used Ethereal to sniff your Perl also? We just had 3 Java experts spend 5 days to get a Soloras web server to create the correct 12-bytes of a Modbus/TCP request. First they had problems with Java appending <CR><NL>, then they had problems with Java truncating all bytes to 7-bits only, then they got mucked up in "unicode tables" making them all 16-bit "bytes". The code always worked 100% fine on Windows servers, but not the Sun production server. I think in the end they finally had Sun Java run some Flash applet that created the 12-bytes. gad-zooks, talk about overkill. So "very simple" isn't always simple.

Also make sure your Unit Id (would be 7th byte) matches the expected value. In theory it shouldn't matter, but some slaves demand it be 0 or 1 or some specific value & ignore the request if not correct.

- LynnL, www.digi.com
 
C

Curt Wuollet

If you have the facilities, I would do a small program in C where you have the least amount of code between you and
the network and just send packets until you find out what
works. Then you have a target to aim at with the higher
level stuff. If you have a half dozen variables working at
once, this sort of exercise can drive you mad. When I was
experimenting with this, I had a small program that I
know worked with other things and I could be sure what
was being sent. Sadly, it's not unheard of for people to use a broken implementation because if it's broken the same way on both sides, it works fine for them. I had to
borrow a device that worked with the gizmo and sniff
packets to find that out.

Regards

cww
 
Top