Skip to content

Commit

Permalink
Properly write multiple registers when struct sizes > 2 bytes are used
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinmit committed Jan 12, 2021
1 parent cfbf1d6 commit 91fb431
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion modbus_cli/access.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def write_registers_send(self, modbus):

words.extend([h << 8 | l for h, l in grouper(struct.pack(pack_type, value), 2)])

if len(self.values_to_write) == 1:
if len(words) == 1:
message = modbus.protocol.write_single_register(modbus.slave_id, self.address(), words[0])
else:
message = modbus.protocol.write_multiple_registers(modbus.slave_id, self.address(), words)
Expand Down

0 comments on commit 91fb431

Please sign in to comment.