Open cjdaly opened 8 years ago
I also reported this in the blinkstick repo: https://github.com/arvydas/blinkstick-python/issues/42
The problem seems to be that the function get_serial
is calling this function:
def _usb_get_string(self, device, index):
try:
return usb.util.get_string(device, index)
except usb.USBError:
# Could not communicate with BlinkStick device
# attempt to find it again based on serial
if self._refresh_device():
return usb.util.get_string(self.device, index)
else:
raise BlinkStickException("Could not communicate with BlinkStick {0} - it may have been removed".format(self.bs_serial))
So.. To get the serial we use _usb_get_string
, and if that fails we attempt to find the device again based on the serial, that we do not have??
I think there should be a check before if self._refresh_device():
to see if self.bs_serial
exists.
If not, then there is no reason to try and refresh the device. Maybe just throw a BlinkStickException
that the caller of find_first
can except for.
Atm. we have to except for AttributeError
which is a bit icky...
Or better, catch a BlinkStickException
in find_first
and return None
I see this error intermittently when running a blickstick from an external usb hub. External usb hub firmware can interfere with oscillator calibration in the blinkstick VUSB firmware. Make sure your blinkstick is connected directly to an internal usb controller (usbview will show you this).
Running C3 on S2B I am seeing errors in the log from the blinkstick command. Have been running for several days now and there are a handful of these errors. Also, I am only (so far) seeing this with BS004471-3.0 (a blinkstick square), and not seeing it on the other several blinksticks currently running.
Below is the beginning of c3.log file:
c3 process: 1935 Starting c3... C3 internal version: 0.1.0.16 CompuCanvas model: S2B Loaded config: /home/pi/CompuCanvas-code/CompuCanvas-controller/C3-runtime/config/model/S2B.properties Initializing services: core, BlinkStick, audio, Show2, MaxSonar. Starting service 'core' ... Service 'core' started. Starting service 'BlinkStick' ... BlinkStick detected: BS004471-3.0 (kind: Square, mode: Random3) Service 'BlinkStick' started. Starting service 'audio' ... Service 'audio' started. Starting service 'Show2' ... Service 'Show2' started. Starting service 'MaxSonar' ... No MaxSonar device configured. Service 'MaxSonar' started. 2016-06-27 17:48:18.549:INFO::Start Level: Equinox Container: 20ee40fe-c93c-0016-1988-b8ee408a77bb: Logging initialized @8130ms Error (1) from: blinkstick -s BS004471-3.0 --index 0 --limit 63 maroon stdout: [Errno 32] Pipe error
stderr: Traceback (most recent call last): File "/usr/local/bin/blinkstick", line 324, in
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'
Error (1) from: blinkstick -s BS004471-3.0 --index 1 --limit 66 teal stdout: [Errno 32] Pipe error
stderr: Traceback (most recent call last): File "/usr/local/bin/blinkstick", line 324, in
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'
Error (1) from: blinkstick -s BS004471-3.0 --index 4 --limit 35 purple stdout: stderr: Traceback (most recent call last): File "/usr/local/bin/blinkstick", line 324, in
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'
... (the rest is several repeats of the above 2 stack traces) ...