arvydas / blinkstick-node

Node.js library for BlinkStick devices.
MIT License
47 stars 39 forks source link

LIBUSB_TRANSFER_STALL & LIBUSB_TRANSFER_TIMED_OUT #30

Open troywweber7 opened 6 years ago

troywweber7 commented 6 years ago

I believe this error is coming from the usb library used by blinkstick, however, I was wondering if anyone else has run into this issue and has suggestions on how to prevent the error from occurring. I am suspicious that it has to do with sending commands too closely (although I'm properly using the callback on the setColors command). Has anyone experienced this? Is there any other information I can provide to receive help debugging this?

troywweber7 commented 6 years ago

I should note that the blinkstick initially operates perfectly fine for up to 15 minutes or more, but then one of these errors will occur, and from that point forward unless you unplug/re-plug the device and re-instantiate the node.js driver, it will continue to give that error.

troywweber7 commented 6 years ago

Also important to note is that I'm running two blinksticks at once. One will get the LIBUSB_TRANSFER_TIMED_OUT error, and the other will get the LIBUSB_TRANSFER_STALL error.

troywweber7 commented 6 years ago

I rearranged my code, and it does seem that even if these errors occur, I can still send a command to clear the leds shortly after... which may be sufficient of a solution. I would still love to know more, though.

troywweber7 commented 6 years ago

The problem seems MOST prevalent when one is trying to run multiple blinksticks at a time on one usb hub using the setColors command to produce animations. It does occur even when only one is running, but far less frequently.

troywweber7 commented 6 years ago

I've further narrowed it down to occurring only when I run the code from the beaglebone. Does not appear to happen on my laptop (with or without a usb hub).

diversemix commented 5 years ago

If this helps anyone ... I had to rewrite from :

const leds = [0,1,2,3,4,5,6,7]
const allLeds_old = async (color) => {
  const resultArray = leds.map( async index => (
    setColorAsync(`#${color}`, { channel, index })
  ))
  await Promise.all(resultArray)
 ...

to:

const allLeds = async (color) => {
  for (var index = 0; index < 8; index++) {
    const r = await setColorAsync(`#${color}`, { channel, index })
    console.log(r)
  }
}

Now everything works without the above messages.