-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
Versions
- Python: 3.12
- OS: macOS 15
- Pymodbus: 3.7.3
- Modbus Hardware (if used):
Description
The type of the Client methods write_register (and write_registers) was changed in client/mixin.py (#2309). Now the value to be sent should be of type bytes instead of int as in the previous releases.
Converting the int value to bytes using value.to_bytes(2, 'big') makes mypy happy, but results in
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pymodbus/client/base.py", line 104, in async_execute
packet = self.ctx.framer.buildPacket(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pymodbus/framer/base.py", line 85, in buildPacket
data = message.function_code.to_bytes(1,'big') + message.encode()
^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pymodbus/pdu/register_write_message.py", line 42, in encode
packet += struct.pack(">H", self.value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
struct.error: required argument is not an integer
Sending the int value as before works, but makes mypy sad.
What to do?
Metadata
Metadata
Assignees
Labels
No labels