thomasdelaet / python-velbus

A python library to control the Velbus home automation system
MIT License
17 stars 8 forks source link

Exception during scanning #75

Closed deweirdt closed 3 years ago

deweirdt commented 3 years ago

Hi,

Installed a while ago HA with the connection to my Velbus system. Some of the modules where not detected and I had quite some warnings

In order to debug what is going wrong I've forked your source repo and executed the scan.py For this one I'm having an exception after a while (I assume in the callback)

INFO:velbus:Sending message on USB bus: {"name": "ReadDataFromMemoryMessage", "priority": 251, "address": 1, "rtr": false} INFO:root:Exiting ... WARNING:velbus:Stop executed INFO:velbus:Sending message on USB bus: {"name": "ReadDataFromMemoryMessage", "priority": 251, "address": 1, "rtr": false} Exception in thread write_packets_process: Traceback (most recent call last): File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner self.run() File "/usr/lib/python3.7/threading.py", line 865, in run self._target(*self._args, **self._kwargs) File "/home/pi/.local/lib/python3.7/site-packages/velbus/connections/serial.py", line 99, in write_daemon self._reader.write(message.to_binary()) File "/home/pi/.local/lib/python3.7/site-packages/serial/threaded/init.py", line 219, in write return self.serial.write(data) File "/home/pi/.local/lib/python3.7/site-packages/serial/serialposix.py", line 615, in write raise PortNotOpenError() serial.serialutil.PortNotOpenError: Attempting to use a port that is not open

Any known issues? I'll also debug a bit further in order to see what the issue could be

thomasdelaet commented 3 years ago

seems like serial port is used by other process, no?

deweirdt commented 3 years ago

well that was also my assumption but I don't see a program using the port. When running this with HA it's detecting almost all my devices on the Velbus and I can manipulate them through HA

The scan.py is now configured to use /dev/ttyACM2 (HA is not running anymore)

I've changed now the port to: /dev/serial/by-id/usb-Velleman_Projects_VMB1USB_Velbus_USB_interface-if00

ran also the scan.py with sudo but having same problem scan.log

deweirdt commented 3 years ago

Checked also with lsof command and no one is having the port open (until I run the scan)

pi@raspberrypi:~/python-velbus $ date Thu Mar 25 09:58:39 GMT 2021 pi@raspberrypi:~/python-velbus $ sudo lsof /dev/ttyACM2 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME python 23287 root 3u CHR 166,2 0t0 408 /dev/ttyACM2 pi@raspberrypi:~/python-velbus $ sudo lsof /dev/ttyACM2 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME python 23287 root 3u CHR 166,2 0t0 408 /dev/ttyACM2 pi@raspberrypi:~/python-velbus $ sudo lsof /dev/ttyACM2 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME python 23287 root 3u CHR 166,2 0t0 408 /dev/ttyACM2 pi@raspberrypi:~/python-velbus $ sudo lsof /dev/ttyACM2 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME python 23287 root 3u CHR 166,2 0t0 408 /dev/ttyACM2 pi@raspberrypi:~/python-velbus $ date Thu Mar 25 09:59:03 GMT 2021 pi@raspberrypi:~/python-velbus $ sudo lsof /dev/ttyACM2 pi@raspberrypi:~/python-velbus $

thomasdelaet commented 3 years ago

this might be a very weird/stupid thing but have you tried running it on a normal computer (i.e., not raspberry pi). I'm not sure but I recall that I had some issues years ago. I now run my velbus/ha setup on a intel nuc

deweirdt commented 3 years ago

ok, did another test

  1. running on intel linux machine -> No problem, program stops at the 30sec
  2. running again on PI -> Problem is occurring when the timeout expires.

I've increased the timeout (eg 60sec) and got the crash again at 60sec. So I think it's something not gracefully shutting down.

For me this is not an issue anymore (should not stop this in HA)

I'll debug further for the other issues (why the VMBGPOD) are having the issue (and not discovered by HA), if needed I'll create a new issue on this one