Writing to function code 0x06(Write Single Register) is failing
Opened this issue · 0 comments
kmadeeha commented
I am trying to set a value of R/W register
modbus -s 2 --verbose 127.0.0.1:9502 H@41167/I=5000
, where 5000 is the value of the register.
With this command I am getting below error, but I am able to read the value of register which is 10000.
File "/opt/homebrew/lib/python3.11/site-packages/modbus_cli/modbus_tcp.py", line 61, in perform_accesses
access.write_registers_receive(self)
File "/opt/homebrew/lib/python3.11/site-packages/modbus_cli/access.py", line 221, in write_registers_receive
modbus.receive(self.request)
File "/opt/homebrew/lib/python3.11/site-packages/modbus_cli/modbus_tcp.py", line 38, in receive
return self.protocol.parse_response_adu(response, request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/umodbus/client/tcp.py", line 235, in parse_response_adu
function = create_function_from_response_pdu(resp_pdu, req_adu)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/umodbus/functions.py", line 132, in create_function_from_response_pdu
function_code = pdu_to_function_code_or_raise_error(resp_pdu)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/umodbus/functions.py", line 118, in pdu_to_function_code_or_raise_error
raise error_code_to_exception_map[error_code]
The device I am trying to connect is connected via Modbus TCP protocol.
According to The register 41167
has
CNT 2 (Number of assigned Modbus registers)
TYPE U32 (A double word (32-bit))
Format FIX2 (Decimal number, commercially rounded, two decimal places.)
I am new to modbus integrations, and couldn't get much help from the readMe or code. Is there something that I am missing?