ljean / modbus-tk

Create Modbus app easily with Python
Other
557 stars 211 forks source link

RTU Server periodically only interprets the first byte of a request. #171

Open DominiqueMeus opened 1 year ago

DominiqueMeus commented 1 year ago

Hello,

I am running the rtuslave_example.py at 19200 bps to test a modbus master. Everything functions nicely except that periodically the RTU Server/slave interprets the first byte (slave id) as a complete packet and then complains about a CRC error.

I was able to patch this issue for my own testing by adding a time.sleep(0.001) in the _do_run function after the first blocking serial read (line 271) in modbus_rtu.py. However this function should probably be refactored so that it waits for another byte before it starts to parse a response.

I don't have the time to fix this myself but hopefully this can get patched or it will help someone with a similar problem.

Regards, Dominique