nrocco / smeterd

Read P1 smart meter packets in Python
MIT License
31 stars 19 forks source link

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

Closed sandnabba closed 1 year ago

sandnabba commented 1 year ago

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

nrocco commented 1 year ago

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 commented 1 year ago

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

nrocco commented 1 year ago

New tag 2.9.2 created.