iomz / dl-myo

Yet another MyoConnect alternative without dongles
GNU General Public License v3.0
5 stars 1 forks source link

AttributeError: 'NoneType' object has no attribute 'get_characteristic' #22

Closed iomz closed 1 year ago

iomz commented 1 year ago

This sometimes happen during Myo.command()

iomz commented 1 year ago

For example,

  File "/Users/iomz/ghq/github.com/Interactions-HSG/MyoKTROS/src/myoktros/client.py", line 229, in record
    await self.stop()
  File "/Users/iomz/ghq/github.com/iomz/dl-myo/myo/core.py", line 505, in stop
    await self.vibrate(VibrationType.SHORT)
  File "/Users/iomz/ghq/github.com/iomz/dl-myo/myo/core.py", line 544, in vibrate
    await self.m.vibrate(self._client, vibration_type)
  File "/Users/iomz/ghq/github.com/iomz/dl-myo/myo/core.py", line 213, in vibrate
    await self.command(client, Vibrate(vibration_type))
  File "/Users/iomz/ghq/github.com/iomz/dl-myo/myo/core.py", line 146, in command
    await client.write_gatt_char(Handle.COMMAND.value, cmd.data, True)
  File "/Users/iomz/ghq/github.com/Interactions-HSG/MyoKTROS/.venv/lib/python3.10/site-packages/bleak/__init__.py", line 659, in write_gatt_char
    await self._backend.write_gatt_char(char_specifier, data, response)
  File "/Users/iomz/ghq/github.com/Interactions-HSG/MyoKTROS/.venv/lib/python3.10/site-packages/bleak/backends/corebluetooth/client.py", line 325, in write_gatt_char
    characteristic = self.services.get_characteristic(char_specifier)
AttributeError: 'NoneType' object has no attribute 'get_characteristic'
iomz commented 1 year ago

Looks like this happens when self.stop() and to vibrate...

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/iomz/ghq/github.com/Interactions-HSG/MyoKTROS/src/myoktros/__init__.py", line 369, in entrypoint
    asyncio.run(args.command(args))
  File "/Users/iomz/.asdf/installs/python/3.10.11/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/Users/iomz/.asdf/installs/python/3.10.11/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/Users/iomz/ghq/github.com/Interactions-HSG/MyoKTROS/src/myoktros/command.py", line 86, in calibrate
    await cls.record(args)
  File "/Users/iomz/ghq/github.com/Interactions-HSG/MyoKTROS/src/myoktros/command.py", line 103, in record
    await rc.record(args)
  File "/Users/iomz/ghq/github.com/Interactions-HSG/MyoKTROS/src/myoktros/client.py", line 261, in record
    await self.stop()
  File "/Users/iomz/ghq/github.com/iomz/dl-myo/myo/core.py", line 505, in stop
    await self.vibrate(VibrationType.SHORT)
  File "/Users/iomz/ghq/github.com/iomz/dl-myo/myo/core.py", line 545, in vibrate
    await self.m.vibrate(self._client, vibration_type)
  File "/Users/iomz/ghq/github.com/iomz/dl-myo/myo/core.py", line 213, in vibrate
    await self.command(client, Vibrate(vibration_type))
  File "/Users/iomz/ghq/github.com/iomz/dl-myo/myo/core.py", line 146, in command
    await client.write_gatt_char(Handle.COMMAND.value, cmd.data, True)
  File "/Users/iomz/ghq/github.com/Interactions-HSG/MyoKTROS/.venv/lib/python3.10/site-packages/bleak/__init__.py", line 659, in write_gatt_char
    await self._backend.write_gatt_char(char_specifier, data, response)
  File "/Users/iomz/ghq/github.com/Interactions-HSG/MyoKTROS/.venv/lib/python3.10/site-packages/bleak/backends/corebluetooth/client.py", line 325, in write_gatt_char
    characteristic = self.services.get_characteristic(char_specifier)
AttributeError: 'NoneType' object has no attribute 'get_characteristic'
iomz commented 1 year ago

Observed a different case, but still vibrate

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/iomz/ghq/github.com/Interactions-HSG/MyoKTROS/src/myoktros/__init__.py", line 369, in entrypoint
    asyncio.run(args.command(args))
  File "/Users/iomz/.asdf/installs/python/3.10.11/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/Users/iomz/.asdf/installs/python/3.10.11/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/Users/iomz/ghq/github.com/Interactions-HSG/MyoKTROS/src/myoktros/command.py", line 86, in calibrate
    await cls.record(args)
  File "/Users/iomz/ghq/github.com/Interactions-HSG/MyoKTROS/src/myoktros/command.py", line 103, in record
    await rc.record(args)
  File "/Users/iomz/ghq/github.com/Interactions-HSG/MyoKTROS/src/myoktros/client.py", line 248, in record
    await start_countdown(
  File "/Users/iomz/ghq/github.com/Interactions-HSG/MyoKTROS/src/myoktros/client.py", line 358, in start_countdown
    await vibrate(VibrationType.SHORT)
  File "/Users/iomz/ghq/github.com/iomz/dl-myo/myo/core.py", line 548, in vibrate
    await self.m.vibrate(self._client, vibration_type)
  File "/Users/iomz/ghq/github.com/iomz/dl-myo/myo/core.py", line 213, in vibrate
    await self.command(client, Vibrate(vibration_type))
  File "/Users/iomz/ghq/github.com/iomz/dl-myo/myo/core.py", line 146, in command
    await client.write_gatt_char(Handle.COMMAND.value, cmd.data, True)
  File "/Users/iomz/ghq/github.com/Interactions-HSG/MyoKTROS/.venv/lib/python3.10/site-packages/bleak/__init__.py", line 659, in write_gatt_char
    await self._backend.write_gatt_char(char_specifier, data, response)
  File "/Users/iomz/ghq/github.com/Interactions-HSG/MyoKTROS/.venv/lib/python3.10/site-packages/bleak/backends/corebluetooth/client.py", line 325, in write_gatt_char
    characteristic = self.services.get_characteristic(char_specifier)
AttributeError: 'NoneType' object has no attribute 'get_characteristic'