smeterd
smeterd copied to clipboard
serial.setRTS(False) breaks serial read (Should be configurable?)
Hello!
I'm trying to use your awesome lib to build a Prometheus exporter. :) However, I've run into some issues.
First is that setRTS(False)
(meter.py:36 ) seems to break the program for me:
emil@fasadmatarskapet:~/smeterd $ python3 -m smeterd read-meter --serial-baudrate 115200 --serial-bytesize 8 --raw
DEBUG:smeterd.meter:Open serial connect to /dev/ttyUSB0 with: baudrate=115200, bytesize=8, parity=E, stopbits=1.0, xonxoff=False, timeout=10
INFO:smeterd.meter:New serial connection opened to /dev/ttyUSB0
INFO:smeterd.meter:Start reading lines
DEBUG:smeterd.meter:>>
DEBUG:smeterd.meter:>>
DEBUG:smeterd.meter:>>
DEBUG:smeterd.meter:>> (10s timeout on each of these lines)
DEBUG:smeterd.meter:>>
DEBUG:smeterd.meter:>>
Commenting this line "solves" this issue for me. I'm not an expert in serial communication, but if this line is required for someone else, I think it should be a configuration option.
Also, the setRTS() parameter seems to have been deprecated: https://pyserial.readthedocs.io/en/latest/pyserial_api.html#serial.Serial.setRTS
Best regards
I will also check this issue.
From what I can see the setRTS function is deprecated but setting RTS is still valid to configure a serial connection with.
Removing this line like breaks other meters.
I will look into making this a cli flag / config option
@sandnabba thanks for making the effort and a Pull Request 👍
New tag 2.9.2
created.