virantha / bricknil

Control LEGO Bluetooth Sensors and Motors with Python
https://virantha.github.io/bricknil
Apache License 2.0
142 stars 39 forks source link

Cant connect Lego Move Hub #24

Open SvyatoslavNovikov opened 3 years ago

SvyatoslavNovikov commented 3 years ago

Hi there.

Try connect Lego Move Hub to bricknill using boost_motor_position.py (Windows 10, Python 3.7, Asus BT400 dongle, bleak 0.10.0, bricknil 0.9.3)

When I start programm, i have next stactrace:

bricknil – C__Users_NovikovS_AppData_Local_Program

My Move Hub must connect automatically, or i must connect via windows bluetooth settings, or some other way?

Thanks.

justxi commented 3 years ago

Hi, looking at the release notes of bleak 0.10.0 (https://github.com/hbldh/bleak/releases), there is the information "Removed separate implementation of global discover method". Maybe this is related to your problem? You could try to downgrade your "bleak" version to 0.9.1. I am using bleak 0.6.1 and it works so far. If you will use something newer with success, please let me know.

SvyatoslavNovikov commented 3 years ago

Yes, i downgrade bleak to 0.9.1 version and have new stacktrace:

DEBUG:asyncio:Using selector: SelectSelector
INFO:BLE Event Q.0:using bleak
DEBUG:Vernie.3:Decorating class Robot with ExternalMotor
DEBUG:Vernie.3:Decorating class Robot with LED
INFO:BLE Event Q.0:Starting scan for UART 
INFO:BLE Event Q.0:ble_id **my:hub:mac:here** is not a parseable UUID, so assuming it's a BLE network addresss
INFO:BLE Event Q.0:Looking for specific hub id **my:mac:here**
started thread for curio
inside curio run loop
Awaiting on bleak discover
DEBUG:bleak.backends.dotnet.discovery:Received **not:my:mac:here**: Unknown.
DEBUG:bleak.backends.dotnet.discovery:Received **my:hub:mac:here**: Unknown.
DEBUG:bleak.backends.dotnet.discovery:Received **my:hub:mac:here**: LEGO Move Hub.
DEBUG:bleak.backends.dotnet.discovery:Received **my:hub:mac:here**: Unknown.
DEBUG:bleak.backends.dotnet.discovery:Received **my:hub:mac:here**: LEGO Move Hub.
DEBUG:bleak.backends.dotnet.discovery:Received **not:my:mac:here**: Unknown.
ERROR:curio.kernel:Task Crash: Task(id=7, name='BLEventQ.connect', state='TERMINATED')
Traceback (most recent call last):
  File "C:\Users\NovikovS\AppData\Local\Programs\Python\Python37\lib\site-packages\curio\kernel.py", line 737, in kernel_run
    trap = current.send(current._trap_result)
  File "C:\Users\NovikovS\AppData\Local\Programs\Python\Python37\lib\site-packages\curio\task.py", line 167, in send
    return self._send(value)
  File "C:\Users\NovikovS\AppData\Local\Programs\Python\Python37\lib\site-packages\curio\task.py", line 171, in _task_runner
    return await coro
  File "C:\Users\NovikovS\AppData\Roaming\Python\Python37\site-packages\bricknil\ble_queue.py", line 228, in connect
    await self._ble_connect(hub.uart_uuid, hub.ble_name, hub.manufacturer_id, ble_id)
  File "C:\Users\NovikovS\AppData\Roaming\Python\Python37\site-packages\bricknil\ble_queue.py", line 171, in _ble_connect
    devices = [d for d in devices if str(uart_uuid) in d.uuids]
  File "C:\Users\NovikovS\AppData\Roaming\Python\Python37\site-packages\bricknil\ble_queue.py", line 171, in <listcomp>
    devices = [d for d in devices if str(uart_uuid) in d.uuids]
AttributeError: 'BLEDevice' object has no attribute 'uuids'
INFO:BLE Event Q.0:Terminating and disconnecxting
INFO:root:quitting
Exception in thread Thread-1:
Traceback (most recent call last):
Done Awaiting on bleak discover
quitting
quit
  File "C:\Users\NovikovS\AppData\Local\Programs\Python\Python37\lib\site-packages\curio\kernel.py", line 737, in kernel_run
    trap = current.send(current._trap_result)
  File "C:\Users\NovikovS\AppData\Local\Programs\Python\Python37\lib\site-packages\curio\task.py", line 167, in send
    return self._send(value)
  File "C:\Users\NovikovS\AppData\Local\Programs\Python\Python37\lib\site-packages\curio\task.py", line 171, in _task_runner
    return await coro
  File "C:\Users\NovikovS\AppData\Roaming\Python\Python37\site-packages\bricknil\ble_queue.py", line 228, in connect
    await self._ble_connect(hub.uart_uuid, hub.ble_name, hub.manufacturer_id, ble_id)
  File "C:\Users\NovikovS\AppData\Roaming\Python\Python37\site-packages\bricknil\ble_queue.py", line 171, in _ble_connect
    devices = [d for d in devices if str(uart_uuid) in d.uuids]
  File "C:\Users\NovikovS\AppData\Roaming\Python\Python37\site-packages\bricknil\ble_queue.py", line 171, in <listcomp>
    devices = [d for d in devices if str(uart_uuid) in d.uuids]
AttributeError: 'BLEDevice' object has no attribute 'uuids'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\NovikovS\AppData\Local\Programs\Python\Python37\lib\threading.py", line 926, in _bootstrap_inner
    self.run()
  File "C:\Users\NovikovS\AppData\Local\Programs\Python\Python37\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\NovikovS\AppData\Roaming\Python\Python37\site-packages\bricknil\bricknil.py", line 191, in _curio_event_run
    run(_run_all(ble, system), with_monitor=False)
  File "C:\Users\NovikovS\AppData\Local\Programs\Python\Python37\lib\site-packages\curio\kernel.py", line 823, in run
    return kernel.run(corofunc, *args)
  File "C:\Users\NovikovS\AppData\Local\Programs\Python\Python37\lib\site-packages\curio\kernel.py", line 173, in run
    raise ret_exc
  File "C:\Users\NovikovS\AppData\Local\Programs\Python\Python37\lib\site-packages\curio\kernel.py", line 737, in kernel_run
    trap = current.send(current._trap_result)
  File "C:\Users\NovikovS\AppData\Local\Programs\Python\Python37\lib\site-packages\curio\task.py", line 167, in send
    return self._send(value)
  File "C:\Users\NovikovS\AppData\Local\Programs\Python\Python37\lib\site-packages\curio\task.py", line 171, in _task_runner
    return await coro
  File "C:\Users\NovikovS\AppData\Roaming\Python\Python37\site-packages\bricknil\bricknil.py", line 138, in _run_all
    await task_connect.join()
  File "C:\Users\NovikovS\AppData\Local\Programs\Python\Python37\lib\site-packages\curio\task.py", line 187, in join
    raise TaskError('Task crash') from self.exception
curio.errors.TaskError: Task crash

Process finished with exit code 0

I don't understand, what exactly is going on.

SvyatoslavNovikov commented 3 years ago

Following this issue https://github.com/virantha/bricknil/issues/3 I downgrade python to 3.6.8 and use next envirement: Settings 2021-01-18 22 21 13 but i have same stacktrace.