aequitas / python-rflink

MIT License
30 stars 27 forks source link

ERROR:rflink.protocol:disconnected due to exception #16

Closed olskar closed 5 years ago

olskar commented 5 years ago

I started out with this bug report in hass: https://github.com/home-assistant/home-assistant/issues/23942

I then tried what happened if I run rflink manually and it seems that the messages are kind of cut of?

This is what i get from rflink ERROR:rflink.protocol:disconnected due to exception NoneType: None

and rflink -vv DEBUG:asyncio:Using selector: EpollSelector DEBUG:rflink.protocol:connected ERROR:rflink.protocol:disconnected due to exception NoneType: None

olskar commented 5 years ago

Updating with more information

` ERROR:asyncio:Exception in callback SerialTransport._read_ready() handle: <Handle SerialTransport._read_ready()> Traceback (most recent call last): File "/usr/lib/python3.6/asyncio/events.py", line 145, in _run self._callback(*self._args) File "/home/olskar/.local/lib/python3.6/site-packages/serial_asyncio/init.py", line 106, in _read_ready self._protocol.data_received(data) File "/home/olskar/.local/lib/python3.6/site-packages/rflink/protocol.py", line 51, in data_received data = data.decode() UnicodeDecodeError: 'utf-8' codec can't decode byte 0x86 in position 1: invalid start byte

`

aequitas commented 5 years ago

Sorry for the late reply.

I believe this has to do with the serial buffer already being filled with partial data when python-rflink starts reading it but some data might be cut off causing it to be invalid. To my knowledge this problem also exists on the protocol level and it's solved there by ignoring errors the first time reading. Maybe we could implement this for the lower level as well.

olskar commented 5 years ago

No worries @aequitas !

Do you think this is related to https://github.com/home-assistant/home-assistant/issues/23942 in home assistant?

As I write in that bug, I can "fix" it by running a rflink-python command in the underlying os, then it works fine in home assistant

aequitas commented 5 years ago

Could be, but still would be strange. Let's discus further on the HA issue, I'll close this one if favour of the other one.