crownstone / crownstone-lib-python-uart

Library to communicate with the Crownstone network via the Crownstone USB dongle
Apache License 2.0
0 stars 4 forks source link

Problem reconnecting to Serial port after connection was lost #4

Closed RicArch97 closed 3 years ago

RicArch97 commented 4 years ago

Crownstone USB dongle unable to connect in Home Assistant instance after the USB has been unplugged, or after Home Assistant has started.

On Raspberry Pi 4 4GB, HassOS 4.13:

After starting Home Assistant without USB: UART lib still connects to a serial port, without the existance of the Crownstone USB, which is unintentional.

2020-10-06 15:28:28 DEBUG (Thread-5) [crownstone_uart.core.uart.UartManager] Initializing... None 230400
2020-10-06 15:28:28 DEBUG (Thread-5) [crownstone_uart.core.uart.UartManager] Setting up connection.../dev/ttyAMA0 230400 True
2020-10-06 15:28:28 DEBUG (Thread-7) [crownstone_uart.core.uart.UartBridge] UartBridge: Initializing serial on port /dev/ttyAMA0 with baudrate 230400
2020-10-06 15:28:28 DEBUG (Thread-7) [crownstone_uart.core.uart.UartBridge] Read starting on serial port./dev/ttyAMA0 True

Plugging the USB in after Home Assistant has started, does nothing.

When plugging the USB in and then starting Home Assistant the USB connects and works fine. However, sometimes the commands take longer than expected to be send to the Crownstone(s).

When trying to disconnect the USB (while HA is running), and then reconnecting it:

2020-10-06 15:20:54 INFO (Thread-8) [crownstone_uart.core.uart.UartBridge] Connection to USB Failed. Retrying...
2020-10-06 15:20:54 DEBUG (Thread-8) [crownstone_uart.core.uart.UartManager] Initializing... None 230400
2020-10-06 15:20:54 DEBUG (Thread-8) [crownstone_uart.core.uart.UartManager] Setting up connection.../dev/ttyUSB0 230400 True
2020-10-06 15:20:54 DEBUG (Thread-10) [crownstone_uart.core.uart.UartBridge] UartBridge: Initializing serial on port /dev/ttyUSB0 with baudrate 230400
2020-10-06 15:20:54 DEBUG (Thread-10) [crownstone_uart.core.uart.UartBridge] Read starting on serial port./dev/ttyUSB0 False

On PC (HA dev version):

The following logs were found after removing the USB and then immediately reconnecting it (without delay):

2020-10-06 15:00:32 INFO (Thread-12) [crownstone_uart.core.uart.UartManager] Connection established to /dev/ttyUSB0
2020-10-06 15:04:43 INFO (Thread-14) [crownstone_uart.core.uart.UartBridge] Connection to USB Failed. Retrying...
2020-10-06 15:04:43 DEBUG (Thread-14) [crownstone_uart.core.uart.UartManager] Initializing... None 230400
2020-10-06 15:04:43 DEBUG (Thread-14) [crownstone_uart.core.uart.UartManager] Setting up connection.../dev/ttyUSB0 230400 True
2020-10-06 15:04:43 DEBUG (Thread-15) [crownstone_uart.core.uart.UartBridge] UartBridge: Initializing serial on port /dev/ttyUSB0 with baudrate 230400
2020-10-06 15:04:43 DEBUG (Thread-15) [crownstone_uart.core.uart.UartBridge] Read starting on serial port./dev/ttyUSB0 False

Reconnection was not possible after that.

RicArch97 commented 3 years ago

This is no longer valid. Closing.