arvydas / blinkstick-python

BlinkStick Python interface to control devices connected to the computer
Other
136 stars 53 forks source link

Blinkstick Flex on Windows crashes on get_led_count() #46

Open dramamine opened 7 years ago

dramamine commented 7 years ago

This function is working for me on OSX but not on Windows. count = stick.get_led_count() File "C:\Python27\lib\site-packages\blinkstick\blinkstick.py", line 539, in get_led_count device_bytes = self._usb_ctrl_transfer(0x80 | 0x20, 0x1, 0x81, 0, 2) File "C:\Python27\lib\site-packages\blinkstick\blinkstick.py", line 235, in _usb_ctrl_transfer return self.reports[wValue - 1].get() IndexError: list index out of range

Was debugging a bit, and in this case wValue is 129. I tried hacking at the code but to me it looks like self.reports only has 4 entries, so wValue is way out there. Happy to help debug a bit if you're missing the hardware. As a hacky fix I just changed get_led_count to "return 32" but that's not something I should share with anyone! Basically all the other stuff I'm trying to do with the SDK works fine.

p0ke234 commented 7 years ago

Try to change line 539 like this: device_bytes = self._usb_ctrl_transfer(0x80 | 0x20, 0x1, 0xA, 0, 2)

dramamine commented 7 years ago

Yep, that did the trick! What's happening there?

dj-lucas commented 7 years ago

This wont work for me on Windows10 am i doing something wrong? File "C:/Blinkstick-stuff/blinkpulse-visualizer-master-3616d2d2eadc92607fc0fd2077aa8c2aa6389392/blinkpulse.py", line 41, in count = stick.get_led_count() File "C:\Users\DJ-Lucas\AppData\Local\Programs\Python\Python36-32\lib\site-packages\blinkstick\blinkstick.py", line 513, in get_led_count device_bytes = self._usb_ctrl_transfer(0x80 | 0x20, 0x1, 0x81, 0, 2) File "C:\Users\DJ-Lucas\AppData\Local\Programs\Python\Python36-32\lib\site-packages\blinkstick\blinkstick.py", line 235, in _usb_ctrl_transfer return self.reports[wValue - 1].get() IndexError: list index out of range

p0ke234 commented 7 years ago

As you can see in your error message you did not change the regarding line in your blinkstick.py. The line number means to me that you´ve changed something more in your blinkstick.py as the line must be somewhere at 538/539.

dj-lucas commented 7 years ago

i have reloaded the original blinkstick.py. and im getting this now: Traceback (most recent call last): File "C:/Blinkstick-stuff/blinkpulse-visualizer-master-3616d2d2eadc92607fc0fd2077aa8c2aa6389392/blinkpulse.py", line 41, in count = stick.get_led_count() File "C:\Users\DJ-Lucas\AppData\Local\Programs\Python\Python36-32\lib\site-packages\blinkstick\blinkstick.py", line 538, in get_led_count device_bytes = self._usb_ctrl_transfer(0x80 | 0x20, 0x1, 0x81, 0, 2) File "C:\Users\DJ-Lucas\AppData\Local\Programs\Python\Python36-32\lib\site-packages\blinkstick\blinkstick.py", line 235, in _usb_ctrl_transfer return self.reports[wValue - 1].get() IndexError: list index out of range

p0ke234 commented 7 years ago

Hey Lucas, still no change at the regarding line. As stated in the workaround above: Try to change line 538 in blinkstick.py like this: device_bytes = self._usb_ctrl_transfer(0x80 | 0x20, 0x1, 0xA, 0, 2)

dj-lucas commented 7 years ago

I have tried that but it didn't work for me. I have given up on trying to use the "get_led_count()" function because everything else is working fine so far.

mitom commented 6 years ago

Hey, I can fix that the change you suggested is working, could this please be released in the package?