Closed kellerza closed 2 years ago
Thanks for reporting the problem.
I just made a quick fix and a released on pypi version 0.1.4
with that fix.
Let me know if it works
Thank you, everything seems ok! 👍
Not sure how you would change the baudrate/other settings with modbus_for_url
, but for now it seems to connect fine on 9600 8N1.
I'm testing your library as an alternative to pymodbus https://github.com/kellerza/sunsynk/issues/18 I like the automatic connect, but getting numpy in the container was not that easy (originally an Alpine build, now Debian)
Would you be open to accept a PR to make numpy optional?
something like
try:
import numpy # noqa
except ImportError:
pass
else:
import async_modbus_use_numpy # noqa
To use a different serial settings:
>>> mb = async_modbus.modbus_for_url("/dev/ttyS0", {"baudrate": 19200, "parity": "E"})
>>> # confirm with:
>>> mb.stream.reader
Serial<id=0x7fae08477e50, open=False>(port='/dev/ttyS0', baudrate=19200, bytesize=8, parity='E', stopbits=1, xonxoff=False, rtscts=False, dsrdtr=False)
Regarding making numpy optional sounds interesting.
I'm happy to accept something that makes numpy not required by default and add an extra in setup something like:
pip install async_modbus[numpy]
Description
Connecting to serial:///dev/ttyUSB0 I get a
AttributeError: 'Serial' object has no attribute 'readexactly'