smeterd icon indicating copy to clipboard operation
smeterd copied to clipboard

serial.setRTS(False) breaks serial read (Should be configurable?)

Open sandnabba opened this issue 2 years ago • 1 comments

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

sandnabba avatar Nov 04 '22 20:11 sandnabba

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

nrocco avatar Nov 04 '22 21:11 nrocco

@sandnabba thanks for making the effort and a Pull Request 👍

nrocco avatar Jan 03 '23 09:01 nrocco

New tag 2.9.2 created.

nrocco avatar Jan 03 '23 09:01 nrocco