Control NeoMatrix with BlinkStickPro and Python

Hi,
I’m trying to get started with my BlinkStickPro and a NeoMatrix using Python 2.79 on Windows 8.1 x64 and Blinkstick Python API 1.1.6, but I’m getting errors like

Exception: 'HidDevice' object has no attribute 'ctrl_transfer'

If I want to set the mode on the BlinkStickPro using

bstick = blinkstick.find_first()
bstick.set_mode(2)

Then I receive the following error:

f:\Documents\blinkstick-python-master>c:\Python27\python.exe circlethrough.py
Traceback (most recent call last):
  File "circlethrough.py", line 33, in <module>
    bstick.set_mode(2)
  File "f:\Documents\blinkstick-python-master\blinkstick\blinkstick.py", line 49
3, in set_mode
    self.device.ctrl_transfer(0x20, 0x9, 0x0004, 0, control_string)
AttributeError: 'HidDevice' object has no attribute 'ctrl_transfer'

The Info Example (Information about Blinkstick) prints out the following:

f:\Documents\blinkstick-python-master>c:\Python27\python.exe blinksticktest.py
Found device:
    Manufacturer:  Agile Innovative Ltd
    Description:   BlinkStick
    Serial:        BS001730-2.2
    Current Color: #000000
    Info Block 1:
    Info Block 2:

Even get_mode() breaks with an error:

f:\Documents\blinkstick-python-master>c:\Python27\python.exe circlethrough.py
Traceback (most recent call last):
  File "circlethrough.py", line 33, in <module>
    print str(bstick.get_mode())
  File "f:\Documents\blinkstick-python-master\blinkstick\blinkstick.py", line 51
1, in get_mode
    device_bytes = self.device.ctrl_transfer(0x80 | 0x20, 0x1, 0x0004, 0, 2)
AttributeError: 'HidDevice' object has no attribute 'ctrl_transfer'

What could be the problem?

Hi Sören,

Thanks for the details. I’m looking into this now. Can you please paste the contents of the following command:

pip.exe list

Hi,
pip list brings the following output:

f:\Documents\blinkstick-python-master>pip list
blinkstick (1.1.6)
pip (1.5.6)
pywinusb (0.3.3)
setuptools (7.0)

Thanks for the quick answer

This should be fixed now. I can see based on your folder paths that you are using a downloaded version of BlinkStick Python package. Please download the updated source code and run your scripts.

https://github.com/arvydas/blinkstick-python/archive/master.zip

Would be grateful if you could let me know whether this solves the issue. I’ll release an updated pip package later today.

Thank you so much, this has resolved the problem.
I’m just not sure why

bstick.set_mode(2)
print "Mode: " + bstick.get_mode()

prints “Mode: -1”
But anyway, now my BlinkStickPro + NeoMatrix works as it should.

ciao, Sören

Thanks for letting me know that it has solved your issue.

The other issue happens because you need to wait about 50ms after you set the mode. BlinkStick is busy with performing the mode change so it can’t respond to any requests. BTW, mode is stored in EEPROM so you don’t have to set it again if you already set it once. If you just run this line of code without setting the mode before that, it should return the correct mode:

print "Mode: " + bstick.get_mode()