Closed austinmroczek closed 10 months ago
It does the same on mine but with some buffer error. Any ideas?
Traceback (most recent call last):
File "/home/dev/pysolarmanv5/examples/register_scan.py", line 31, in <module>
main()
File "/home/dev/pysolarmanv5/examples/register_scan.py", line 14, in main
val = modbus.read_input_registers(register_addr=x, quantity=1)[0]
File "/usr/local/lib/python3.9/site-packages/pysolarmanv5/pysolarmanv5.py", line 347, in read_input_registers
modbus_values = self._get_modbus_response(mb_request_frame)
File "/usr/local/lib/python3.9/site-packages/pysolarmanv5/pysolarmanv5.py", line 262, in _get_modbus_response
modbus_values = rtu.parse_response_adu(mb_response_frame, mb_request_frame)
File "/usr/local/lib/python3.9/site-packages/umodbus/client/serial/rtu.py", line 190, in parse_response_adu
function = create_function_from_response_pdu(resp_pdu, req_pdu)
File "/usr/local/lib/python3.9/site-packages/umodbus/functions.py", line 138, in create_function_from_response_pdu
return function.create_from_response_pdu(resp_pdu, req_pdu)
File "/usr/local/lib/python3.9/site-packages/umodbus/functions.py", line 911, in create_from_response_pdu
read_input_registers.data = list(struct.unpack(fmt, resp_pdu[2:]))
struct.error: unpack requires a buffer of 2 bytes
My device uses a similar but different scheme. You could try my code at https://github.com/austinmroczek/modbus_mapper
Per discord discussion, I'm not sure my device is ever going to respond...but register_scan.py does not catch timeout error. So somewhere in the middle of the 10,000 address scan it stopped. Would be nice to catch this and retry, or at least tell user what the last address scanned was.