Closed Geobert closed 5 years ago
You can call HidApi::refresh_devices. HidApi caches the device list from its initialization, and you have to manually refresh the list later.
This should at least allow you to discover, if the new device can actually be found.
If it is found, but you still get an error on open, then you are perhaps running into a permissions issue.
Another thing which could go wrong is, that the device is noit immediately ready. Maybe add a timeout, or watch the device list for changes.
Thank you for your answer!
Sorry I forgot this part: I do refresh the list (so I know the device is back online).
I've added 5s sleep to be sure but with no luck.
What kind of permission? I've tried in both way (Mode1 -> Mode2 and Mode2 -> Mode 1) and both fail on the second step :-/
I've done a quick test and if I recreate the api, it works :-/
Oh that's strange.
I agree :grin:
Do you recreate the API by dropping the HidApi instance? The only thing that it really does is deinitialize the C library.
To figure out the problem, you will have to inspect the error, or use a debugger. Anyway, what is the exact error you get?
https://gist.github.com/Geobert/05d3ae9e474642ba27bdd55aa009180f
here is a crude exemple
and the error I got is a OpenHidDeviceError
which print into Failed opening hid device
It might be a C lib error as well though :-/
Are you using HidDeviceInfo::open_device, or one of the open_XXX functions on HidApi?
I am pretty sure, that you are hitting a problem with signal11/hidapi (the underlying C library).
I've tried open_device
and open_path
with the same issue.
I am closing this issue now.
Hi there,
I'm creating a HidApi at the beginning of my program and then open a device with V1/P1 as vid/pid and send a message to it to switch mode. The device is then dropped but I keep my HidApi instance.
It happens that in this mode, the vid is not the same and HipApi::open(V2, P1) fails with this error:
Failed opening hid device
Is that expected behavior?