rossmann-engineering / EasyModbusTCP.PY

Modbus TCP, Modbus UDP and Modbus RTU client library for Python implementations
MIT License
67 stars 33 forks source link

method write_multiple_registers creates invalid modbus query #3

Closed Teubex closed 3 years ago

Teubex commented 5 years ago

As I started working with the easymodbus library for python3 I encountered an error, which occured to me while using the "write_multiple_registers" method.

My master was controlling a slave, which took its instructions from the ascii-values the master submitted into a number of registers, starting from register 0.

As my slave did not seem to respond to my masters commands, I checked the Modbus TCP/IP - message via Wireshark and found that the length of my package was wrong, as you can see in this picture: picture1

To adjust my messages length parameter, I changed a few lines in the methods code: line 741: length = len(values)*2+7 instead of length = 6

line 791: length_lsb = length&0xFF; instead of length_lsb = 0x06;

line 792: length_msb = (length&0xFF00) >> 8 instead of length_msb = 0x00

As you can see in my second picture, it fixed the issue for me. picture2 Nonetheless I would love to see your take on this problem.

Kind regards, Alex

rossmann-engineering commented 3 years ago

Finally fixed