Git Product home page Git Product logo

Comments (3)

undera avatar undera commented on July 28, 2024

Hi,
Indeed, in case of Windows you only need to try the bluegiga way. So the error you see is irrelevant on Windows. You need to concentrate on BLED112. I myself don't have Windows nor BLED112, so I can only guess.
First thing to do, is instead of automatic connection, use hub=MoveHub(get_connection_bluegiga()) always, so you won't get irrelevant messages. Then, to get potentially more diagnostics, add import logging; logging.basicConfig(level=logging.DEBUG); before getting MoveHub connection.

Please share the results here.

from pylgbst.

mivola avatar mivola commented on July 28, 2024

Hi Andrey,

I changed the logging and the initialization of the MoveHub as suggested. This changed the error message:

DEBUG:comms-pygatt:Trying to connect client to MoveHub with MAC: None
INFO:pygatt.backends.bgapi.bgapi:Initialized new BGAPI backend
DEBUG:pygatt.backends.bgapi.bgapi:Opening connection to serial port (attempt 1)
INFO:pygatt.backends.bgapi.bgapi:Auto-detecting serial port for BLED112
DEBUG:pygatt.backends.bgapi.util:Found 1 serial USB devices
DEBUG:pygatt.backends.bgapi.util:Checking serial USB device: COM3 - USB Serial Device (COM3)
DEBUG:pygatt.backends.bgapi.util:USB device: USB Serial Device (COM3) VID=0x2458 PID=0x0001 on COM3
INFO:pygatt.backends.bgapi.bgapi:Found BLED112 on serial port COM3
INFO:pygatt.backends.bgapi.bgapi:Resetting and reconnecting to device for a clean environment
DEBUG:pygatt.backends.bgapi.bgapi:Opening connection to serial port (attempt 1)
INFO:pygatt.backends.bgapi.bgapi:Auto-detecting serial port for BLED112
DEBUG:pygatt.backends.bgapi.util:Found 1 serial USB devices
DEBUG:pygatt.backends.bgapi.util:Checking serial USB device: COM3 - USB Serial Device (COM3)
DEBUG:pygatt.backends.bgapi.util:USB device: USB Serial Device (COM3) VID=0x2458 PID=0x0001 on COM3
INFO:pygatt.backends.bgapi.bgapi:Found BLED112 on serial port COM3
DEBUG:pygatt.backends.bgapi.bgapi:Failed to open serial port
Traceback (most recent call last):
  File "C:\Users\mvoigt\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pygatt\backends\bgapi\bgapi.py", line 159, in _open_serial_port
    timeout=0.25)
  File "C:\Users\mvoigt\AppData\Local\Programs\Python\Python37-32\lib\site-packages\serial\serialwin32.py", line 31, in __init__
    super(Serial, self).__init__(*args, **kwargs)
  File "C:\Users\mvoigt\AppData\Local\Programs\Python\Python37-32\lib\site-packages\serial\serialutil.py", line 240, in __init__
    self.open()
  File "C:\Users\mvoigt\AppData\Local\Programs\Python\Python37-32\lib\site-packages\serial\serialwin32.py", line 78, in open
    self._reconfigure_port()
  File "C:\Users\mvoigt\AppData\Local\Programs\Python\Python37-32\lib\site-packages\serial\serialwin32.py", line 222, in _reconfigure_port
    'Original message: {!r}'.format(ctypes.WinError()))
serial.serialutil.SerialException: Cannot configure port, something went wrong. Original message: FileNotFoundError(2, 'The system cannot find the file specified.', None, 2)
Traceback (most recent call last):
  File "C:\Users\mvoigt\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pygatt\backends\bgapi\bgapi.py", line 159, in _open_serial_port
    timeout=0.25)
  File "C:\Users\mvoigt\AppData\Local\Programs\Python\Python37-32\lib\site-packages\serial\serialwin32.py", line 31, in __init__
    super(Serial, self).__init__(*args, **kwargs)
  File "C:\Users\mvoigt\AppData\Local\Programs\Python\Python37-32\lib\site-packages\serial\serialutil.py", line 240, in __init__
    self.open()
  File "C:\Users\mvoigt\AppData\Local\Programs\Python\Python37-32\lib\site-packages\serial\serialwin32.py", line 78, in open
    self._reconfigure_port()
  File "C:\Users\mvoigt\AppData\Local\Programs\Python\Python37-32\lib\site-packages\serial\serialwin32.py", line 222, in _reconfigure_port
    'Original message: {!r}'.format(ctypes.WinError()))
serial.serialutil.SerialException: Cannot configure port, something went wrong. Original message: FileNotFoundError(2, 'The system cannot find the file specified.', None, 2)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/git/pylgbst/examples/demo.py", line 194, in <module>
    connection = get_connection_bluegiga()
  File "C:\git\pylgbst\pylgbst\__init__.py", line 12, in get_connection_bluegiga
    return BlueGigaConnection().connect(hub_mac)
  File "C:\git\pylgbst\pylgbst\comms\cpygatt.py", line 27, in connect
    adapter.start()
  File "C:\Users\mvoigt\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pygatt\backends\bgapi\bgapi.py", line 202, in start
    self._open_serial_port()
  File "C:\Users\mvoigt\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pygatt\backends\bgapi\bgapi.py", line 170, in _open_serial_port
    "No BGAPI compatible device detected")
pygatt.exceptions.NotConnectedError: No BGAPI compatible device detected

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/git/pylgbst/examples/demo.py", line 199, in <module>
    connection.disconnect()
NameError: name 'connection' is not defined

Process finished with exit code 1

Then I started debugging with some breakpoints in bgapi.py, serialwin32.py, cpygatt.py etc - and without changing the code or any variables, the connection was working fine afterwards...

pydev debugger: process 10260 is connecting

Connected to pydev debugger (build 183.5912.18)
INFO:pygatt.backends.bgapi.bgapi:Initialized new BGAPI backend
INFO:pygatt.backends.bgapi.bgapi:Auto-detecting serial port for BLED112
INFO:pygatt.backends.bgapi.bgapi:Found BLED112 on serial port COM3
INFO:pygatt.backends.bgapi.bgapi:Resetting and reconnecting to device for a clean environment
INFO:pygatt.backends.bgapi.bgapi:Auto-detecting serial port for BLED112
INFO:pygatt.backends.bgapi.bgapi:Found BLED112 on serial port COM3
INFO:pygatt.backends.bgapi.bgapi:Running receiver
INFO:pygatt.backends.bgapi.bgapi:Disabling advertising
INFO:comms-pygatt:Discovering devices...
INFO:pygatt.backends.bgapi.bgapi:Starting an active scan
INFO:pygatt.backends.bgapi.bgapi:Pausing for 1s to allow scan to complete
INFO:pygatt.backends.bgapi.bgapi:Stopping scan
INFO:pygatt.backends.bgapi.bgapi:Discovered 1 devices: [{'address': '00:16:53:AA:7B:F2', 'name': 'LEGO Move Hub', 'rssi': -55, 'packet_data': {'connectable_advertisement_packet': {'manufacturer_specific_data': bytearray(b'\x97\x03\x00@\x06\xfeA\x00'), 'flags': bytearray(b'\x06'), 'complete_list_128-bit_service_class_uuids': ['0x00:00:16:23:12:12:EF:DE:16:23:78:5F:EA:BC:D1:23']}, 'scan_response_packet': {'slave_connection_interval_range': bytearray(b'\x10\x00 \x00'), 'tx_power_level': bytearray(b'\x00'), 'complete_local_name': 'LEGO Move Hub'}}}]
INFO:root:Found LEGO Move Hub at 00:16:53:AA:7B:F2
INFO:pygatt.backends.bgapi.bgapi:Connecting to device at address 00:16:53:AA:7B:F2 (timeout 5s)
INFO:pygatt.backends.bgapi.bgapi:Connection status: handle=0x0, flags=(242, 123, 170, 83, 22, 0), address=0xb'f27baa531600', connection interval=212.500000ms, timeout=830, latency=22 intervals, bonding=0x0
INFO:pygatt.backends.bgapi.bgapi:Connected to 00:16:53:AA:7B:F2
INFO:pygatt.backends.bgapi.bgapi:Fetching characteristics for connection 0
INFO:pygatt.backends.bgapi.bgapi:Found approved characteristic 00002a05-0000-1000-8000-00805f9b34fb
INFO:pygatt.backends.bgapi.bgapi:Found approved characteristic 00002a00-0000-1000-8000-00805f9b34fb
INFO:pygatt.backends.bgapi.bgapi:Found approved characteristic 00002a01-0000-1000-8000-00805f9b34fb
INFO:pygatt.backends.bgapi.bgapi:Found approved characteristic 00002a04-0000-1000-8000-00805f9b34fb
INFO:pygatt.backends.bgapi.bgapi:Found custom characteristic 00001624-1212-efde-1623-785feabcd123
INFO:pygatt.backends.bgapi.bgapi:Characteristic 0x00002a05-0000-1000-8000-00805f9b34fb is handle 0x3
INFO:pygatt.backends.bgapi.bgapi:Characteristic descriptor 0x00002902-0000-1000-8000-00805f9b34fb is handle 0x4
INFO:pygatt.backends.bgapi.bgapi:Characteristic 0x00002a00-0000-1000-8000-00805f9b34fb is handle 0x7
INFO:pygatt.backends.bgapi.bgapi:Characteristic 0x00002a01-0000-1000-8000-00805f9b34fb is handle 0x9
INFO:pygatt.backends.bgapi.bgapi:Characteristic 0x00002a04-0000-1000-8000-00805f9b34fb is handle 0xb
INFO:pygatt.backends.bgapi.bgapi:Characteristic 0x00001624-1212-efde-1623-785feabcd123 is handle 0xe
INFO:pygatt.backends.bgapi.bgapi:Characteristic descriptor 0x00002902-0000-1000-8000-00805f9b34fb is handle 0xf
INFO:pygatt.device:Subscribed to uuid=00001624-1212-efde-1623-785feabcd123
INFO:pygatt.device:Received notification on handle=0xe, value=0xb'0f0004020125000000001000000010'
INFO:movehub:Attached DISTANCE_COLOR_SENSOR on port D
INFO:pygatt.device:Received notification on handle=0xe, value=0xb'0f0004370127000000001000000010'
INFO:movehub:Attached MOTOR on port A
INFO:pygatt.device:Received notification on handle=0xe, value=0xb'0f0004380127000000001000000010'
INFO:movehub:Attached MOTOR on port B
INFO:pygatt.device:Received notification on handle=0xe, value=0xb'090004390227003738'
INFO:movehub:Attached MOTOR on port AB
INFO:pygatt.device:Received notification on handle=0xe, value=0xb'0f0004320117000000001000000010'
INFO:movehub:Attached LED on port LED
INFO:pygatt.device:Received notification on handle=0xe, value=0xb'0f00043a0128000000001000000002'
INFO:movehub:Attached TILT_SENSOR on port TILT_SENSOR
INFO:pygatt.device:Received notification on handle=0xe, value=0xb'0f00043b0115000200000002000000'
INFO:movehub:Attached AMPERAGE on port AMPERAGE
INFO:pygatt.device:Received notification on handle=0xe, value=0xb'0f00043c0114000200000002000000'
INFO:movehub:Attached VOLTAGE on port VOLTAGE
INFO:pygatt.device:Received notification on handle=0xe, value=0xb'0f0004010126000000001000000010'
INFO:movehub:Attached IMOTOR on port C
INFO:pygatt.device:Received notification on handle=0xe, value=0xb'12000101064c45474f204d6f766520487562'
INFO:pygatt.device:Received notification on handle=0xe, value=0xb'14000108064c45474f2053797374656d20412f53'
INFO:movehub:bytearray(b'LEGO Move Hub') by bytearray(b'LEGO System A/S')
INFO:pygatt.device:Received notification on handle=0xe, value=0xb'0a00473c000000000001'
INFO:pygatt.device:Received notification on handle=0xe, value=0xb'0600453c6d0b'
INFO:pygatt.device:Received notification on handle=0xe, value=0xb'0600453c6c0b'
INFO:pygatt.device:Received notification on handle=0xe, value=0xb'0600453c6c0b'
INFO:pygatt.device:Received notification on handle=0xe, value=0xb'0600453c6c0b'
INFO:pygatt.device:Received notification on handle=0xe, value=0xb'0a00473c000000000000'
INFO:movehub:Voltage: 71%

So I have the feeling this is an issue in the related libraries for the BLE/socket/COM communication...

Regards
Michael

from pylgbst.

mivola avatar mivola commented on July 28, 2024

OK, after some more investigation, this issue is caused by peplin/pygatt#208 and the fix is here: peplin/pygatt#181

from pylgbst.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.