getsenic / nuimo-linux-python

Nuimo Python SDK for Linux to connect and communicate with Nuimo controllers made by Senic
https://senic.com
MIT License
52 stars 20 forks source link

TypeError: list indices must be integers, not str #9

Closed naimo84 closed 8 years ago

naimo84 commented 8 years ago

EDIT: it was an error regarding to the iOS simulator. Now I'm using a real nuimo and everything works.

TypeError: list indices must be integers, not str

This occurs in swipe_event and rotation_event.

Traceback (most recent call last):
  File "/home/naimo/nuimo-linux-python/examples/nuimo.py", line 247, in on_notification
    event = self.event_factory(data, uuid)
  File "/home/naimo/nuimo-linux-python/examples/nuimo.py", line 256, in event_factory
    event = item['constructor'](received_data)
  File "/home/naimo/nuimo-linux-python/examples/nuimo.py", line 228, in swipe_event
    event_kind = directions[swipe_direction]

A quick fix for me, as a beginner in python, is to rewrite the nuimo.py code to

directions = [NuimoGestureEvent.SWIPE_LEFT, NuimoGestureEvent.SWIPE_RIGHT,
                      NuimoGestureEvent.SWIPE_UP, NuimoGestureEvent.SWIPE_DOWN]
        swipe_direction = "".join(format(ord(c),"02x") for c in received_data[3])
        event_kind = directions[int(swipe_direction)]        
        event = NuimoGestureEvent(event_kind, swipe_direction)
        return event

Now it works for about 10 seconds and then nothing happens. No event is received, no error occurs. I have to restart the python script and it works again for this timespan. What am I doing wrong?

Tested with python 2.7 and 3.4 on a Raspberry Pi 3 with the built-in Bluetooth adapter, Nuimo iOS Simulator

larsblumberg commented 8 years ago

@naimo84: Thanks for sharing your insights!

larsblumberg commented 7 years ago

Hi @naimo84, please try our all new Nuimo Python SDK. It now uses BlueZ's D-Bus API directly. Please find all information here: https://github.com/getsenic/nuimo-linux-python