arvydas / blinkstick-python

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

occasional errors from blinkstick command line #42

Open cjdaly opened 8 years ago

cjdaly commented 8 years ago

I have a Java program running on several raspberry Pis (models 2 and 3) with blinksticks (Nanos, Squares and Strips). The java program spawns a process with a blinkstick command line invocation (random change) once every 5-10 seconds.

This program has been running for 5+ days now on 4 similar systems. In that time, one of the systems has accumulated 6 errors. There are 2 kinds of errors. In one case I issued a command like:

blinkstick -s BS004471-3.0 --index 0 --limit 63 maroon

and got this to stdout: [Errno 32] Pipe error

and this to stderr:

Traceback (most recent call last):
  File "/usr/local/bin/blinkstick", line 324, in <module>
    sys.exit(main())
  File "/usr/local/bin/blinkstick", line 243, in main
    stick.set_max_rgb_value(int(float(options.limit) / 100.0 * 255))
AttributeError: 'NoneType' object has no attribute 'set_max_rgb_value'

For an example of the other error, I issued a very similar command:

blinkstick -s BS004471-3.0 --index 4 --limit 35 purple

and in this case nothing comes to stdout, and I get this stack trace from stderr:

Traceback (most recent call last):
  File "/usr/local/bin/blinkstick", line 324, in <module>
    sys.exit(main())
  File "/usr/local/bin/blinkstick", line 215, in main
    sticks = [blinkstick.find_by_serial(options.serial)]
  File "/usr/local/lib/python2.7/dist-packages/blinkstick/blinkstick.py", line 1537, in find_by_serial
    return BlinkStick(device=devices[0])
  File "/usr/local/lib/python2.7/dist-packages/blinkstick/blinkstick.py", line 209, in __init__
    self.bs_serial = self.get_serial()
  File "/usr/local/lib/python2.7/dist-packages/blinkstick/blinkstick.py", line 272, in get_serial
    return self._usb_get_string(self.device, 256, 3)
  File "/usr/local/lib/python2.7/dist-packages/blinkstick/blinkstick.py", line 218, in _usb_get_string
    if self._refresh_device():
  File "/usr/local/lib/python2.7/dist-packages/blinkstick/blinkstick.py", line 249, in _refresh_device
    d = find_by_serial(self.bs_serial)
AttributeError: 'BlinkStick' object has no attribute 'bs_serial'

Also, all 6 errors that I've seen so far have been from the same blinkstick (4471).

This doesn't prevent the blinkstick from working on subsequent calls, but I want to report it in case anyone else sees it too. Also maybe some change can be made to the python to better handle these errors?

I have also opened an issue about this in my repo: https://github.com/cjdaly/CompuCanvas-code/issues/1

wfalkwallace commented 7 years ago

I get the bs_serial error about 80% (approximate estimate) of calls 😞

graemerae commented 6 years ago

Is there any solution for this? I have the same issue. Once it starts, a reboot is the only recourse.

p0ke234 commented 6 years ago

The only thing I´ve found is a solution approach in the reference link above: https://github.com/cjdaly/CompuCanvas-code/issues/1