Usb.core library in Skill

Hey guys!
I am pretty new to the Mycroft community and like what you are doing here! :smiley:

I decided to develop a skill that controls the LEDs of the Respeaker Mic Array v2.0, however I have run into a problem:
When I try to tell the device to change the LEDs, it gives me the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pi/pixel_ring/pixel_ring/usb_pixel_ring_v2.py", line 25, in off
    self.mono(0)
  File "/home/pi/pixel_ring/pixel_ring/usb_pixel_ring_v2.py", line 16, in mono
    self.write(1, [(color >> 16) & 0xFF, (color >> 8) & 0xFF, color & 0xFF, 0])
  File "/home/pi/pixel_ring/pixel_ring/usb_pixel_ring_v2.py", line 66, in write
    0, cmd, 0x1C, data, self.TIMEOUT)
  File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/usb/core.py", line 1071, in ctrl_transfer
    self._ctx.managed_open()
  File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/usb/core.py", line 113, in wrapper
    return f(self, *args, **kwargs)
  File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/usb/core.py", line 131, in managed_open
    self.handle = self.backend.open_device(self.dev)
  File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/usb/backend/libusb1.py", line 804, in open_device
    return _DeviceHandle(dev)
  File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/usb/backend/libusb1.py", line 652, in __init__
    _check(_lib.libusb_open(self.devid, byref(self.handle)))
  File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/usb/backend/libusb1.py", line 604, in _check
    raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 13] Access denied (insufficient permissions)

Is it not allowed for skills to access USB devices or am I doing something wrong?
Help is much appreciated! :slight_smile:

You will have to check the udev rules to make sure your user has access to the USB devices.

That did it, thank you very much!

1 Like

For those looking for the udev rule to create:

SUBSYSTEM=="usb", ATTR{idVendor}=="2886", ATTR{idProduct}=="0018", MODE="0666", GROUP="plugdev"