Replies: 1 comment 1 reply
-
I think your assumption is correct. After all, libusb is listening To make this work properly (and w/o delay+retry, which is also an option/workaround) - you'd have to make your own implementation of a hotplug detection using |
Beta Was this translation helpful? Give feedback.
-
I have a small program written in Rust that uses
libusb
's hotplug API to detect when a device with a specific VID/PID is connected. Once this is detected, I wake up a waiting thread via a channel where I again enumerate the devices viahidapi
, find it, open it and try to read data.The problem is that when I try to open the device, I get a permission denied error. If I add a 2 second delay before I try to open the device then everything works, if I run my program as sudo then it also works.
If I the device is already plugged in when my program starts then I get no error either.
Below are my udev rules.
The device itself is a wireless transmitter for a SteelSeries Arctis Nova 7 gaming headset and my program implements the ChatMix functionality.
The fact that adding a delay fixes my problem makes me think that there is some sort of timing issue going on and somehow my program tries to open the USB device before all the rules are applied, but at the same time, I also found libusb/libusb#718 which directly contradicts this.
Here are the system logs when the device is plugged in:
I have restarted my computer. Nothing looks wrong I am at a bit of a loss on where to continue the investigation.
P.S.:
The hotplug support was an afterthought after it became too much trouble to have my program invoked by
systemd
when the USB device was connected. Ideally I would not have a half and half solution, but I already had my code written for talking to the device viahidapi
and I thought I can uselibusb
's hotplug support untilhidapi
gets it's own.It is not feasible to run my program as root because it needs to talk to services that are started via
systemctl --user
.Beta Was this translation helpful? Give feedback.
All reactions