1

I have a USB light sensor that I have been using for almost a year without any issues on a Raspberry Pi 3. I am now trying to use it on a Raspberry Pi Zero Wireless instead.

I followed the sensor manufacturer's documentation to create a udev rule on the Pi Zero (which was identical to the rule I had on the Pi3) in order to give the "pi" user permissions to use the USB device (as I don't want to use it as root):

sudo nano /etc/udev/rules.d/51-yoctopuce.rules

Added the following lines into the file:

# udev rules to allow write access to all users for Yoctopuce USB devices
SUBSYSTEM=="usb", ATTR{idVendor}=="24e0", MODE="0666"

I rebooted, and then ran the command from the manufacturer to use the sensor:

YModule inventory

It's at this point that I get an error message:

ERR: Cannot register usb: the user has insufficient permissions to access USB devices (ypkt_lin:406)

If I plug the same sensor into my RPi3 and run the same command, I instead get a list of the sensors serial numbers output to terminal (the expected output from this command).

If I run the command (on the Pi Zero) as root, i.e. sudo ./bin/YModule inventory, then the command runs correctly and the output is the serial number of the sensor (the expected output for the command).

So clearly there is a permission issue at play. I just don't know how to fix it.

I'm assuming there's an error somewhere in my udev rules, but I don't know where, given that the rule file on the Pi Zero is identical to the rule file on my (working) Pi 3 (which is identical to what is on the manufacturer's website).

Output of lsusb:

Bus 001 Device 002: ID 24e0:0050
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

The first device is the Yoctopuce light sensor (24e0 is definitely the correct vendor ID).

Output of sudo lsusb -v -d 24e0:0050:

Bus 001 Device 002: ID 24e0:0050

Device Descriptor:

bLength 18

bDescriptorType 1

bcdUSB 2.00

bDeviceClass 0 (Defined at Interface level)

bDeviceSubClass 0

bDeviceProtocol 0

bMaxPacketSize0 8

idVendor 0x24e0

idProduct 0x0050

bcdDevice 0.01

iManufacturer 1 Yoctopuce

iProduct 2 Yocto-Light-V3

iSerial 3 LIGHTMK3-1136C5

bNumConfigurations 1

Configuration Descriptor:

bLength 9

bDescriptorType 2

wTotalLength 41

bNumInterfaces 1

bConfigurationValue 1

iConfiguration 0

bmAttributes 0x80

 (Bus Powered)

MaxPower 100mA

Interface Descriptor:

 bLength                 9

 bDescriptorType         4

 bInterfaceNumber        0

 bAlternateSetting       0

 bNumEndpoints           2

 bInterfaceClass         3 Human Interface Device

 bInterfaceSubClass      0 No Subclass

 bInterfaceProtocol      0 None

 iInterface              0 

   HID Device Descriptor:

     bLength                 9

     bDescriptorType        33

     bcdHID               1.11

     bCountryCode            0 Not supported

     bNumDescriptors         1

     bDescriptorType        34 Report

     wDescriptorLength      29

    Report Descriptors: 

      ** UNAVAILABLE **

 Endpoint Descriptor:

   bLength                 7

   bDescriptorType         5

   bEndpointAddress     0x81  EP 1 IN

   bmAttributes            3

     Transfer Type            Interrupt

     Synch Type               None

     Usage Type               Data

   wMaxPacketSize     0x0040  1x 64 bytes

   bInterval               1

 Endpoint Descriptor:

   bLength                 7

   bDescriptorType         5

   bEndpointAddress     0x01  EP 1 OUT

   bmAttributes            3

     Transfer Type            Interrupt

     Synch Type               None

     Usage Type               Data

   wMaxPacketSize     0x0040  1x 64 bytes

   bInterval               1

Device Status: 0x0000

(Bus Powered)

The contents of my directory /etc/udev/rules.d/ is: 51-yoctopuce.rules 99-com.rules

I also tried renaming it to 100-yoctopuce.rules, in case something in the 99-com.rules file was causing the issue, but that resulted in the same error.

My understanding is that after editing the rules file, all I have to do to apply it is to reboot the system. Is that right, or is there some command I'm missing?

Any suggestions please on how to go about fixing this? Thanks in advance.

Contents of the file /etc/udev/rules.d/99-com.rules (on Pi Zero):

SUBSYSTEM=="input", GROUP="input", MODE="0660"
SUBSYSTEM=="i2c-dev", GROUP="i2c", MODE="0660"
SUBSYSTEM=="spidev", GROUP="spi", MODE="0660"
SUBSYSTEM=="bcm2835-gpiomem", GROUP="gpio", MODE="0660"

SUBSYSTEM=="gpio*", PROGRAM="/bin/sh -c '\
        chown -R root:gpio /sys/class/gpio && chmod -R 770 /sys/class/gpio;\
        chown -R root:gpio /sys/devices/virtual/gpio && chmod -R 770 /sys/devices/virtual/gpio;\
        chown -R root:gpio /sys$devpath && chmod -R 770 /sys$devpath\
'"

KERNEL=="ttyAMA[01]", PROGRAM="/bin/sh -c '\
        ALIASES=/proc/device-tree/aliases; \
        if cmp -s $ALIASES/uart0 $ALIASES/serial0; then \
                echo 0;\
        elif cmp -s $ALIASES/uart0 $ALIASES/serial1; then \
                echo 1; \
        else \
                exit 1; \
        fi\
'", SYMLINK+="serial%c"

KERNEL=="ttyS0", PROGRAM="/bin/sh -c '\
        ALIASES=/proc/device-tree/aliases; \
        if cmp -s $ALIASES/uart1 $ALIASES/serial0; then \
                echo 0; \
        elif cmp -s $ALIASES/uart1 $ALIASES/serial1; then \
                echo 1; \
        else \
                exit 1; \
        fi \
'", SYMLINK+="serial%c"

1 Answer 1

0

I just solved the issue by putting the two lines from /etc/udev/rules.d/51-yoctopuce.rules onto the end of the pre-existing rules file (at /etc/udev/rules.d/99-com.rules), then I deleted the 51-yoctopuce.rules file, and then rebooted.

1
  • This indicates there is something in the standard udev rules that overrides your rule, unles your rule is placed last in the ruleset. Simply renaming your rules file to /etc/udev/rules.d/99-yoctopuce.rules and rebooting might have sufficed. Also, the standard rules might allow you to access the device if you add your user account to the plugdev group: sudo usermod -a -G plugdev <your_username> and logout+login to allow the new group membership to take effect.
    – telcoM
    Sep 14, 2019 at 8:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .