I'm using Ubuntu 23.10, and trying to use a device with WebHID. I've added all appropriate rules, i.e.
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="d035", GROUP="plugdev", MODE="0660"
to /etc/udev/rules.d/99-oledscope.rules
.
And, I can see that hidraw* is correctly configured:
ls -lah /dev/hidraw*
crw-rw---- 1 root plugdev 241, 0 Apr 24 04:40 /dev/hidraw0
crw-rw---- 1 root plugdev 241, 1 Apr 24 04:40 /dev/hidraw1
I've also validated that I am in the plugdev group.
Here is my report descriptor:
HID_USAGE_PAGE ( 0xff ), // Vendor-defined page.
HID_USAGE ( 0x00 ),
HID_REPORT_SIZE ( 8 ),
HID_COLLECTION ( HID_COLLECTION_LOGICAL ),
HID_REPORT_COUNT ( 254 ),
HID_REPORT_ID ( 0xaa )
HID_USAGE ( 0x01 ),
HID_FEATURE ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,
HID_REPORT_COUNT ( 63 ), // For use with `hidapitester --vidpid 1209/D003 --open --read-feature 171`
HID_REPORT_ID ( 0xab )
HID_USAGE ( 0x01 ),
HID_FEATURE ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,
HID_COLLECTION_END,
With the above, I can use hidapi.h to access the device and send/receive appropriate reports, but when I use Chrome (124.0.6367.60 from Snap), I get the following error: Could not open; NotAllowedError: Failed to open the device.
Then, if I look in the device log at chrome://device-log/
, I have a constant stream of
HIDEvent[04:40:26] Failed to open '/dev/hidraw1': FILE_ERROR_ACCESS_DENIED
HIDEvent[04:40:26] Access denied opening device read-write, trying read-only.
I don't know for sure that this is because I am using the snap package, but, either way, I can't, from Chrome access my WebHID device.
Any ideas what I could do to make sure snap packages have access to hidraw?
Wow! I just had to ask here! It turns out it's because of some draconian rules in snap, and there's a way around it:
https://askubuntu.com/a/1296762 points out that you can create a launcher to chrome, but un-snap it, as follows. Though it is very cursed.
/snap/chromium/current/usr/lib/chromium-browser/chrome --user-data-dir=~/ChrUnsnapped --class="ChrUnsnapped" %U
If anyone has other solutions, I would love to know!