Tariq Bellachhab
Tariq Bellachhab

Reputation: 33

How corrupt checksum over TCP/IP

I am connecting my slave via TCP/IP, everything looks fine by using the Wireshark software I can validate that the CRC checksum always valid “good”, but I am wondering how I can corrupt the CRC checksum so I can see like checksum “Invalid”. Any suggestion how can I get this done maybe python code or any other way if possible.

Thank you all Tariq

Upvotes: 1

Views: 578

Answers (2)

Marcos G.
Marcos G.

Reputation: 3506

First off, be aware that Modbus TCP does not include any CRC, the error control is handled via the appropriate layer of the TCP protocol itself. See for instance this post: Can you keep a CRC in a Modbus TCP message?

If you want to play with Modbus RTU CRC errors you can take a look at MinimalModbus (Python) and its unit tests MiniMalModbus Unit Tests

If you prefer something easier you might want to take a look at ModbusPoll, where you can define a slave and simulate CRC errors (only for Modbus RTU, I think). There is a 30 day trial version.

As far as I know what you want to do is not possible out of the box with the other libraries I use: pymodbus and libmodbus but it should not be too difficult to write something similar to the MinimalModbus unit test yourself.

Upvotes: 0

Capibar
Capibar

Reputation: 75

I think you use a library that computes CRC. You can form Modbus packet without it, if you want simulate bad CRC condition

Upvotes: 1

Related Questions