vfilimonov/co2meter

Raspberry Pi: does not work under user account

vfilimonov opened this issue · 1 comments

Module does not work under default user pi in raspberry py, only under root.

Despite setting permissions in /etc/udev/rules.d98-co2mon.rules:

KERNEL=="hidraw*", ATTRS{idVendor}=="04d9", ATTRS{idProduct}=="a052", GROUP="plugdev", MODE="0666"

and the fact that device is visible in hid.enumerate():

(system3) pi@raspberrypi:~ $ python -c "import hid; print(hid.enumerate())"
[{'product_id': 41042, 'usage_page': 0, 'interface_number': 0, 'product_string': '', 'serial_number': '', 'vendor_id': 1241, 'manufacturer_string': '', 'path': b'0001:0005:00', 'usage': 0, 'release_number': 256}]

it does not work when trying to open it:

(system3) pi@raspberrypi:~ $ python -c "import hid; h = hid.device(); h.open(0x04d9, 0xa052)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "hid.pyx", line 66, in hid.device.open
OSError: open failed

Most likely, some permissions are not set.

Issue on the hidapi repo: trezor/cython-hidapi#47

OK, the solution is to have both KERNEL=="hidraw*" and SUBSYSTEM=="usb" records in /etc/udev/rules.d98-co2mon.rules as a separate lines:

KERNEL=="hidraw*", ATTRS{idVendor}=="04d9", ATTRS{idProduct}=="a052", GROUP="plugdev", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04d9", ATTRS{idProduct}=="a052", GROUP="plugdev", MODE="0666"

Having only KERNEL record, or only one record which combined KERNEL and SUBSYSTEM did not work...