[Errno 32] Pipe error

Hi,

I’ve been trying to write some basic Python code for a Blinkstick Flex and keep getting usb.core.USBError: [Errno 32] Pipe error but only about half the time I run the code. I am aware of the 20ms delay and have my code set currently for 80ms but have tried a number of different values. The Blinkstick Flex is one of three blinkstick products plugged into a Raspberry Pi but it is also the only one that is part of this code.

Here is the code (its written terribly…sorry about that):

from blinkstick import blinkstick
import time
import random

bstick = blinkstick.find_by_serial(“BS018653-3.1”)

#Rainbow
#Red
bstick.set_color(channel=0, index=0, red=255,green=0,blue=0)
time.sleep(.08)
bstick.set_color(channel=0, index=1, red=255,green=0,blue=0)
time.sleep(.08)
#Orange
bstick.set_color(channel=0, index=2, red=255,green=70,blue=0)
time.sleep(.08)
bstick.set_color(channel=0, index=3, red=255,green=70,blue=0)
time.sleep(.08)
#Yellow
bstick.set_color(channel=0, index=4, red=255,green=200,blue=0)
time.sleep(.08)
bstick.set_color(channel=0, index=5, red=255,green=200,blue=0)
time.sleep(.08)
#Green
bstick.set_color(channel=0, index=6, red=0,green=255,blue=0)
time.sleep(.08)
bstick.set_color(channel=0, index=7, red=0,green=255,blue=0)
time.sleep(.08)
#Blue
bstick.set_color(channel=0, index=8, red=0,green=0,blue=255)
time.sleep(.08)
bstick.set_color(channel=0, index=9, red=0,green=0,blue=255)
time.sleep(.08)
#Indigo
bstick.set_color(channel=0, index=10, red=75,green=0,blue=130)
time.sleep(.08)
bstick.set_color(channel=0, index=11, red=75,green=0,blue=130)
time.sleep(.08)
#Violet
bstick.set_color(channel=0, index=12, red=238,green=70,blue=238)
time.sleep(.08)
bstick.set_color(channel=0, index=13, red=238,green=70,blue=238)
time.sleep(.08)

#White
bstick.set_color(channel=0, index=14, red=255,green=255,blue=255)
time.sleep(.08)
bstick.set_color(channel=0, index=15, red=255,green=255,blue=255)
time.sleep(.08)
bstick.set_color(channel=0, index=16, red=255,green=255,blue=255)
time.sleep(.08)
bstick.set_color(channel=0, index=17, red=255,green=255,blue=255)
time.sleep(.08)

bstick.set_color(channel=0, index=18, red=238,green=70,blue=238)
time.sleep(.08)
bstick.set_color(channel=0, index=19, red=238,green=70,blue=238)
time.sleep(.08)
bstick.set_color(channel=0, index=20, red=75,green=0,blue=130)
time.sleep(.08)
bstick.set_color(channel=0, index=21, red=75,green=0,blue=130)
time.sleep(.08)
bstick.set_color(channel=0, index=22, red=0,green=0,blue=255)
time.sleep(.08)
bstick.set_color(channel=0, index=23, red=0,green=0,blue=255)
time.sleep(.08)
bstick.set_color(channel=0, index=24, red=0,green=255,blue=0)
time.sleep(.08)
bstick.set_color(channel=0, index=25, red=0,green=255,blue=0)
time.sleep(.08)
bstick.set_color(channel=0, index=26, red=255,green=200,blue=0)
time.sleep(.08)
bstick.set_color(channel=0, index=27, red=255,green=200,blue=0)
time.sleep(.08)
bstick.set_color(channel=0, index=28, red=255,green=70,blue=0)
time.sleep(.08)
bstick.set_color(channel=0, index=29, red=255,green=70,blue=0)
time.sleep(.08)
bstick.set_color(channel=0, index=30, red=255,green=0,blue=0)
time.sleep(.08)
bstick.set_color(channel=0, index=31, red=255,green=0,blue=0)
time.sleep(.08)

Here is the full error message:

pi@raspberrypi:~/Desktop/Code $ python blink_flex.py
Traceback (most recent call last):
File “blink_flex.py”, line 98, in
bstick.set_color(channel=0, index=28, red=255,green=70,blue=0)
File “/home/pi/.local/lib/python2.7/site-packages/blinkstick/blinkstick.py”, line 341, in set_color
self._usb_ctrl_transfer(0x20, 0x9, report_id, 0, control_string)
File “/home/pi/.local/lib/python2.7/site-packages/blinkstick/blinkstick.py”, line 244, in _usb_ctrl_transfer
return self.device.ctrl_transfer(bmRequestType, bRequest, wValue, wIndex, data_or_wLength)
File “/home/pi/.local/lib/python2.7/site-packages/usb/core.py”, line 711, in ctrl_transfer
self.__get_timeout(timeout)
File “/home/pi/.local/lib/python2.7/site-packages/usb/backend/libusb1.py”, line 836, in ctrl_transfer
timeout))
File “/home/pi/.local/lib/python2.7/site-packages/usb/backend/libusb1.py”, line 571, in _check
raise USBError(_str_error[ret], ret, _libusb_errno[ret])
usb.core.USBError: [Errno 32] Pipe error

Am I trying to do something that is blatantly wrong here? This isn’t the actual program I’m trying to write, just a test to see if I could troubleshoot the Flex. This same error is happening anytime I want to change several of the individual LEDs in a given run of a program.

Thank you!

A more efficient way is to send LED frames. You can use the BlinkStickPro class for this and here is an example:

With LED frames you would be sending all colors ar the same time. You can also do this with basic bstick class and set_led_data function

https://arvydas.github.io/blinkstick-python/blinkstick.blinkstick.BlinkStick-class.html#set_led_data

Please note that set_led_data function accepts an array of bytes in GRB format.

Thank you! Much easier than the way I was trying to do things. :slight_smile: