Modbus TCP first attempt

05 Dec 2011

I am trying to port the freemodbus TCP source (http://freemodbus.berlios.de/) for mbed (http://mbed.org/users/tmav123/programs/ModbusTCP/m1pxgl).

But I am facing the following problem:

/media/uploads/tmav123/modbus.jpg

1. pc query

2. mbed responces

3. pc acks but with incorrect checksum

/media/uploads/tmav123/ack.jpg

4. mbed is trying several times to tx the responce without success.

Is this a lwip issue?

18 Dec 2011

The missing checksum is likely to be due to IP Checksum offloading by your PC (I'm assuming you are running Wireshark on your pc).

See the Wireshark wiki page about checksum offloading here.

The issue seems to be caused by the mbed not "seeing" the TCP ack from the pc and retransmitting the response, which the pc then acks again.

14 Mar 2012

I rewrote your modbus TCP program with TCPsocket library, and it seems to work somehow.

Import programModbusTCP_Modified

Modified version of ModbusTCP

20 Aug 2013

I am trying to use this library to make slave for master but after 268 comunications loops the mbed is frozen and not possible to continue. If I tested it with PC sw Modbus Poll it works fine and for 40k of readings I have 8 timeout errors. But this sw open MB and than only periodically read registers, but the problem with my hw master interfacing is that it always make comunication as follows.

MODBUS > DEBUG: MBTCP-ACCEPT

MODBUS > Accepted new client 192.168.1.50

MODBUS > DEBUG: MBTCP-RECV

MODBUS > | TID = 7F72 | PID = 0000 | LEN = 0006 | UID = 01|| FUNC = 03 | DATA = 07D00063 |

MODBUS > eMBRegHoldingCB

sent 207 bytes

MODBUS > DEBUG: MBTCP-CLOSE

MODBUS > Closed connection to 192.168.1.50

and if master make 268 loops like this the mbed is frozen, I have implemented WDT with 3sec delay to fully restart mbed, but I would like to know if there is some bug or something to do how can I fix this problem with counting of relations and after 268's closing connection frozing of mbed.

I some body can help me? Thx