-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Seeking advice on control_in: interface or device #120
Comments
I just saw in the docs:
So, maybe that's one part of it - I do support Windows so that might be an issue to use device::control_in always. |
On Linux and macOS, there is no difference -- they call the same implementation. The Device methods exist so you can use them without claiming an interface on platforms that support it, while the Interface methods exist for applications that only hold an Interface, and because WinUSB requires a claimed interface. So that doesn't explain why one works and the other doesn't. When it fails, what is the error? Can you post a debug log? (set |
That's annoying. Now I can't reproduce it. I've connected an additional (different) device by USB, but not remove any of the previous ones - and now it seems to be working. I'll leave this issue open for a short time until I can reproduce it, otherwise I will close (if that is OK). |
Saw this again today (will attempt to reproduce reliably). Message was "Could not be opened for exclusive access". I assume this is my issue, using claim_interface() within a loop over connected devices? |
That error would be expected if the interface of that device is already claimed, whether in another process, the same process, or by a kernel driver. |
I have an app that "discovers" attached devices (pi picos with my app) by USB.
I was using this code: https://github.com/andrewdavidmackenzie/pigg/blob/master/pignet/src/usb_host.rs#L235
to detect the matching devices, get their serial numbers, and then query each one for a description struct of mine, using interface::control_in
This was working fine, until I attached two devices via USB. Detection of one was failing.
I first thought it might be the device::claim_interface() in the loop. But debugging, that is not failing, it's the later control_in call that fails.
I did a hack locally to see if using device::control_in changed anything, and it seems to solve the problem (although then I'm not using the interface::set_alt_setting(1) call.
Basically, I'm looking for advice/direction on when to use device and when to use interface be able to use control_in to get information from the device.
The docs (https://docs.rs/nusb/latest/nusb/struct.Device.html#method.control_in) didn't really clarify that for me.
thanks!
The text was updated successfully, but these errors were encountered: