-
Throwing this out there to see if anyone has seen something similar or has advice - thanks in advance! I've used hidapi-libusb for a while with a custom USB device designed for software protection (ie, a license dongle). Recently a coworker re-worked our licensing module and now I consistently get hid_open failure unless I run my software with sudo privelege. I've set up my udev rules. Curiously, I can run the hidtest-libusb without issue; in other words, hid_open succeeds without sudo privilege when running the test app. Initially, I wondered if it was related to our threading of usb access (which is new), but all of the usb access occurs in the same thread; also, I removed the threading to try and isolate what is happening and it seems to behave the same: in my software, hid_open fails unless I run with sudo privilege (but the test app works fine). Has anyone seen a compiler/build option that could cause this to happen? At this point, I'm stumped as to why the test application succeeds in hid_open but my application does not. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
My best guess - your SW isn't consistent with your udev rules. Or you simply trying to open a wrong device. In any case, I don't believe a compiler/build option exists that may cause such effect as you observe. I may suggest inserting the code of the test app into your code in different place, e.g. try to execute the code of the test app inside your |
Beta Was this translation helpful? Give feedback.
-
Thank you for the quick reply! I'm quite sure that I'm using the correct VID/PID - in fact, the class controlling access to this specific device hasn't changed and I have confirmed normal operation with v0.13.1 in my previous software architecture (I updated from 0.11.0). In other words, my old code works and the hidtest-libusb works - but my new build (the software was re-organized and threaded) only works when run with sudo priveleges. I believe the udev rules are ok - though in trying to figure out what is happening I've tried variations of TAG+="uaccess" and MODE="0666" . I'll try your suggestion of executing the code in a different location to see if I can uncover what is happening. I'll also report back if I learn anything. Thanks! |
Beta Was this translation helpful? Give feedback.
-
Happy to help. |
Beta Was this translation helpful? Give feedback.
I think you are correct. I understand now what is happening, and thank you very much for your help!
It looks like in the new module my coworker added support for an additional device which is built by another company; in doing so, he linked their device's API library. It seems that their API library defines all of the hid_* calls (hid_init, hid_enumerate, hid_open, etc) - so even though I thought I was explicitly linking against hidapi-libusb, the linker was resolving my hid_* calls using their library. I did not anticipate they included i…