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
Windows: libusb Windows hotplug support #86
Comments
Last known tree back in the libusbx time. |
libusb hotplug for Windows is really important. But if I unplug the device and plug it back to the same USB port very quickly, and Windows's driver searching program is disabled(to make system recognize device faster), my program can get device remove and device add event correctly, but libusb_get_device_list() will get a usb device list the same as the previous saved one. Here is the reason: Because my program is event driven, this causes 2 events missing. I really hope that hotplug feature can be implemented for Windows. |
https://github.com/dickens/libusbx-hp/tree/windows-hotplug-3
You may want to try the above old branch to see the hotplug code there
works for your application. I am not so sure how much efforts need to bring
that branch up to date though.
|
I tried that before, I even tried to merge the change into libusb 1.0.19, but I failed to merge it to newer code. I still need to use latest branch, because there are tons of bug/leak fixes for Windows platform. Hope Windows hotplug support can be implemented soon. |
Will be part of the next release. Unfortunately it is a complicated set of Regards, |
This is a great news! |
were there any changes regarding the hotplug issue since then? Currently having the problem with LibUsbDotNet that communication with an unplugged-replugged device is only possible again after reinstalling the driver using the Inf-Wizard OR restarting Windows. This device is a CardReader. On the other hand, i dont have issues hotplugging a USB Keyboard. Does anyone have suggestions? |
@chrisba77 strange w/o any "hotplug" support you should be able to re-use the device without driver re-install reboot etc then run again lib usb init , device detect ,re-open re claim etc .. That is what i do to get control again of unplugged and re-pluged device |
@diabolo38 I do all this. And actually after plugging in the device again, communication is possible. BUT the read values coming from the device are not valid anymore. |
@chrisba77 if device is hid using standard os hid device driver then the issue could be os driver or the device itlsef. I can't see such issue with non hid device at least. |
It looks like this didn't make it into 1.0.21 as planned. Edit: I see now that it is included in the 1.0.22 milestone. I'll also take a look at the mailing list archives to see if there is recent discussion. Any additional info would still be welcome! |
Hi guys, what's the status of this issue ? |
Did the hotplug supported on windows? |
Has this now been moved to 1.0.23? :( |
I just checked the latest code, it seems that windows hotplug hasn't been implemented. |
+1 for Windows hotplug support. Without hotplug support, what are the standard ways of determining when a device connects or disconnects on Windows? Does one just repeatedly poll a device list and determine when there are changes detected? |
It's really inconvenient that libusb doesn't support hotplug capability on Windows. I finely turn to libusbK. It can be downloaded from https://sourceforge.net/projects/libusbk/, after setting up, you can download the whole src zip in https://sourceforge.net/projects/libusbk/files/libusbK-release/3.0.7.0/libusbK-3.0.7.0-src.zip/download which includes an example hot-plug-monitor.c shows the hotplug ability. |
Hi all, did it support on Windows now? |
Unfortunately not. Right now only Chris is working on the Windows side and
it will take some time to get this.
|
Unfortunately Chris seems to be busy and has not been active in libusb development for a while. So I have to remove this from libusb 1.0.26 milestones unless he is back or a new Windows developer can join the project and look at this feature. |
Ref: #1047 (comment)
|
Is this why Talon is working for me?
Searching for this lead me here. Edit: Nevermind, false thingie. |
Please provide more details. What is your question? Do you have some issues with regard to Talon? In that case, then you have to get support from them. If Talon is using libusb, then they have to fall back to polling for USB hotplug under Windows, since libusb Windows does not support hotplug yet. |
Polling for USB hotplug under Windows, Will it affect the device communication? I tested and found that the device change can be detected according to idVendor, idProduct, port from libusb_get_port_number, address from libusb_get_device_address. |
Basically you have to deal with hotplug by yourself since hotplug is not supported by Windows. You need to keep polling. |
unfortunately! 2023 is coming to an end and this feature is still not supported |
This feature will not be supported, unless we get an active Windows developer for libusb project who can actively working on this feature. You want to volunteer? PRs are welcome. |
It is really unfortunate that the payoff from having hotplug (not needing to do like a loop or something) is absolutely not worth the person-weeks of work of someone highly competent to get it in upstream libusb. I know I cannot justify it for any of my projects, and at least one would decently benefit from having hotplug. Just not enough. |
Contributors are more than welcome for libusb projects now that we are short of developers and reviewers which makes 1.0.27 release not happening yet. As for this paticular issue (Windows Hotplug support), it may be even more difficult as we do not have an active Windows developer for quite some time (last commit done by Chris Dickens was on 9-Feb-2021). |
My current solution is to listen for WM_DEVICECHANGE events, but this solution is not a good idea for cross-platform library because it requires binding Windows and you have to create a virtual window to do this. Finally, I added a usb_event_cb api to the libusb library to be called by the upper layer to handle device hotplug,Device monitoring is implemented by the upper layer This is an approach that hopefully will help other developers, although it's not a perfect solution. |
You might look at |
Please see #1406 . Comments welcome. |
@mcuee while #1406 is being reviewed, is there an official recommended way to poll on system without hotplug? I tried the method mentioned by @Aii-Wei above.
I can confirm that using < Note that it does not work on Macos (both port and address are constant). |
For Windows, I think we should focus on reviewing and testing PR #1406 to get it merged. As for the work-around, let's see if @tormodvolden has some recommendations for platforms without hotplug support. |
This is one of the long standing missing feature for Windows.
The text was updated successfully, but these errors were encountered: