eterey/pymodbus3

read_holding_registers returns None

al37919 opened this issue · 6 comments

I show a minimal code example indicating problem and output which I receive using pymodbus-1.2.0 and pymodbus3-1.0.0. to_string() is omitted for clarity. It's just a magic function to convert array of registers to a readable string. The question is why read_holding_registers() returns None when using pymodbus3?
Thanks

#! /usr/bin/env python3

from pymodbus3.client.sync import ModbusSerialClient as ModbusClient

pymc = ModbusClient(method="ascii", port="/dev/ttyUSB2", baudrate=9600, timeout=0.25)
ret = pymc.read_holding_registers(0x130, 13, unit=1)
print(ret)
print(to_string(ret.registers[1:]))

pymodbus-1.2.0 response:

ReadRegisterResponse (13)
Meradat-VIT19IT1

pymodbus3-1.0.0 response:

None
Traceback (most recent call last):
  File "./test_pymodbus3.py", line 33, in <module>
    print(to_string(ret.registers))
AttributeError: 'NoneType' object has no attribute 'registers'

unfortunately, time.sleep(1) between ModbusClient() and read_holding_registers() doesn't help.
The response stays None

I experienced the issue you are describing (serial client returning None when reading registers), when using pymodbus3 installed via pip. When instead running a (newer) version cloned from master, the issue was solved.

I think this was addressed in #5.

I used @perkarlberg way, and succeed!
In pypi.python, pymodbus3 1.0.0 was uploaded on 2014-07-18, and #5 was merged on 04-04, so I think you had install a old version by pip.

Fixed now,