Modbus RTU + Telnet over GPRS + Binary


Thread Starter


I was able to establish a connection between a client (firmware that uses modbus rtu) and Server application, by using atdt<ip address>,<port number>

in the server side I had to run socat to listen to a port number and fork a script to login to the machine using telnet ( telnet -c -l username localhost )

After the Login the server application starts and sends binary commands to the firmware to grab certain modbus address and send them over, well the packets comes wrong and the client doesn't know what to do with it.

If I use Ethernet or Analog modem, everything is fine even with direct telnet connection without forwarding it with socat.

Is there something in the server side or GSM modem to configure or another way to send those packets.

Modbus RTU can be sensitive to timing "gaps" in the message. It could be the GSM modem is breaking the message up into smaller packets and either the client or the server is timing out between each packet.
Hello again,

> Modbus RTU can be sensitive to timing "gaps" in the message. <

From wireshark I see the following message sent from the server side application


01 address

03 function code

1388 start addrss =5000

0020 reg count = 32

c0bc crc code

this looks good per modbus spec

from capture at the client level

01 10 03 13 88 20 c0 bc

the second byte(10) is extra and the byte count(20) should be 0020)

otherwise the address and start address are correct

also the crc is the correct value is the packet was what I expected

to the client it would look like :

01 address

10 function code 16 ----we don't do 16

0313 start addrss =787

8820 reg count = 34848--very large

c0bc crc code ----------which is in error

Any suggestion on how to get the correct bytes.

R Kay

Lynn August Linse

Telnet is designed for 7-bit ASCII.

It doesn't allow raw 8-bit binary data - various bytes (such as 0xFF) will become expanded or consumed. So what you sent is not necessarily what you'll receive.

I'd suggest creating your own script or tool to use a raw socket - don't use telnet.