arvydas / blinkstick-python

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

ord() expected error #69

Open agogodavid opened 4 years ago

agogodavid commented 4 years ago

Error encountered when trying to control BlinkStrip using Python 3 on Windows.

#Import blinkstick module
from blinkstick import blinkstick

#Find the first BlinkStick
bstick = blinkstick.find_first()

#Set the color red on the 12th LED of R channel
bstick.set_color(channel=0, index=12, name="red")
TypeError                                 Traceback (most recent call last)
<ipython-input-91-73997141703b> in <module>
      6 
      7 #Set the color red on the 12th LED of R channel
----> 8 bstick.set_color(channel=0, index=12, name="red")

E:\Anaconda3\lib\site-packages\blinkstick\blinkstick.py in set_color(self, channel, index, red, green, blue, name, hex)
    339 
    340         if self.error_reporting:
--> 341             self._usb_ctrl_transfer(0x20, 0x9, report_id, 0, control_string)
    342         else:
    343             try:

E:\Anaconda3\lib\site-packages\blinkstick\blinkstick.py in _usb_ctrl_transfer(self, bmRequestType, bRequest, wValue, wIndex, data_or_wLength)
    224         if sys.platform == "win32":
    225             if bmRequestType == 0x20:
--> 226                 data = (c_ubyte * len(data_or_wLength))(*[c_ubyte(ord(c)) for c in data_or_wLength])
    227                 data[0] = wValue
    228                 if not self.device.send_feature_report(data):

E:\Anaconda3\lib\site-packages\blinkstick\blinkstick.py in <listcomp>(.0)
    224         if sys.platform == "win32":
    225             if bmRequestType == 0x20:
--> 226                 data = (c_ubyte * len(data_or_wLength))(*[c_ubyte(ord(c)) for c in data_or_wLength])
    227                 data[0] = wValue
    228                 if not self.device.send_feature_report(data):

TypeError: ord() expected string of length 1, but int found
cwarrencoderedsafety commented 4 years ago

I found that if I removed the ord() portions, following this: https://stackoverflow.com/questions/30076240/ord-expected-string-of-length-1-but-int-found from the blinkstick.py file located under python's site-packages, it works. I am using python 3.8.5

agogodavid commented 4 years ago

This works perfect! Thanks a bunch!!