# Loop and pulse usb error

**URL:** <https://forums.blinkstick.com/t/loop-and-pulse-usb-error/1085>\
**Category:** Support\
**Created:** [November 15, 2018, 7:14pm UTC](https://forums.blinkstick.com/t/loop-and-pulse-usb-error/1085 "2018-11-15T19:14:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tull](https://forums.blinkstick.com/letter_avatar_proxy/v4/letter/t/df788c/32.png) [@tull](https://forums.blinkstick.com/u/tull)\
**Post date:** [November 15, 2018, 7:14pm UTC](https://forums.blinkstick.com/t/loop-and-pulse-usb-error/1085/1 "2018-11-15T19:14:22Z")

</div>

Hi there.

I have several apps written using the blinkstick nanos which are working perfectly, lovely and stable. But I’ve hit a couple of problems today and wonder if anyone has the solution.

If I run the code example below I get a seemingly random number of cycles then:  
USBError(\_str\_error[ret], ret, \_libusb\_errno[ret]) usb.code.USBError: [Errno 32] Pipe error

I’ve tried putting in sleeps and moving things around but no joy. I hope someone can find the problem.

Many thanks.

* * *

#!/usr/bin/python

from blinkstick import blinkstick as bstick  
import random as rnd  
import time

def main():  
while True:  
for bl in bstick.find\_all():

```
                    r=rnd.randint(0,255)
                    g=rnd.randint(0,255)
                    b=rnd.randint(0,255)

                    bl.pulse(red=r, green=g, blue=b, duration=500, steps=100)

```

main()

---

<div class="post-metadata">

**Author:** ![arvydas](https://forums.blinkstick.com/user_avatar/forums.blinkstick.com/arvydas/32/242_2.png) [@arvydas](https://forums.blinkstick.com/u/arvydas)\
**Post date:** [November 15, 2018, 7:26pm UTC](https://forums.blinkstick.com/t/loop-and-pulse-usb-error/1085/2 "2018-11-15T19:26:58Z")

</div>

Try decreasing the number of steps to 20.

---

<div class="post-metadata">

**Author:** ![tull](https://forums.blinkstick.com/letter_avatar_proxy/v4/letter/t/df788c/32.png) [@tull](https://forums.blinkstick.com/u/tull)\
**Post date:** [November 16, 2018, 1:00pm UTC](https://forums.blinkstick.com/t/loop-and-pulse-usb-error/1085/3 "2018-11-16T13:00:21Z")

</div>

Same.

I’ve done some more testing with other commands, set\_random\_color, even just blink. Anything in a loop confuses the USB port.

Do you (anyone) have a working python example of this kind I could look at?

Thanks.

---

<div class="post-metadata">

**Author:** ![arvydas](https://forums.blinkstick.com/user_avatar/forums.blinkstick.com/arvydas/32/242_2.png) [@arvydas](https://forums.blinkstick.com/u/arvydas)\
**Post date:** [November 16, 2018, 1:16pm UTC](https://forums.blinkstick.com/t/loop-and-pulse-usb-error/1085/4 "2018-11-16T13:16:07Z")

</div>

You can find code examples in the wiki:

> **[arvydas/blinkstick-python](https://github.com/arvydas/blinkstick-python/wiki)**
>
> BlinkStick Python interface to control devices connected to the computer

---

<div class="post-metadata">

**Author:** ![tull](https://forums.blinkstick.com/letter_avatar_proxy/v4/letter/t/df788c/32.png) [@tull](https://forums.blinkstick.com/u/tull)\
**Post date:** [November 24, 2018, 10:58am UTC](https://forums.blinkstick.com/t/loop-and-pulse-usb-error/1085/5 "2018-11-24T10:58:55Z")

</div>

These extremely basic examples don’t replicate what I’m trying to do at all.
