Skip to content
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

Open
mcuee opened this issue Aug 10, 2015 · 23 comments

Comments

Projects
None yet
@mcuee
Copy link
Contributor

commented Aug 10, 2015

This is one of the long standing missing feature for Windows.

@mcuee mcuee added the enhancement label Aug 17, 2015

@mcuee

This comment has been minimized.

Copy link
Contributor Author

commented Nov 27, 2015

Last known tree back in the libusbx time.
https://github.com/dickens/libusbx-hp/tree/windows-hotplug-3

@mcuee mcuee changed the title libusb Windows hotplug support Windows: libusb Windows hotplug support Feb 25, 2016

@changyp6

This comment has been minimized.

Copy link

commented Mar 2, 2016

libusb hotplug for Windows is really important.
I have a program running on Linux/Window/MacOS, but Windows doesn't have hotplug support, I have to write my own device detection code for Windows.
But Windows only reports that there is a device arrived or there's a device removed, you have to find which one is added or removed.
So when I receive device remove event, I usb libusb_get_device_list() to get current device present in the system, and compare this list with the old one to find out which one is removed, and I use the same method to find which one is added, after I find the difference, my program will handle the removed/added device.

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:
When my program receives device remove event, and start to list all the USB devices, because the unplug/plug action is so fast, libusb_get_device_list() will give a list after the device is plugged back. So this USB device list is the same as the list before unplug/plug action, which means my program cannot find out which device is removed and which is added, there will be 2 missing actions for my program.

Because my program is event driven, this causes 2 events missing.

I really hope that hotplug feature can be implemented for Windows.

@mcuee

This comment has been minimized.

Copy link
Contributor Author

commented Mar 3, 2016

@changyp6

This comment has been minimized.

Copy link

commented Mar 3, 2016

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.

@dickens

This comment has been minimized.

Copy link
Member

commented Mar 3, 2016

Will be part of the next release. Unfortunately it is a complicated set of
changes.

Regards,
Chris

@changyp6

This comment has been minimized.

Copy link

commented Mar 3, 2016

This is a great news!

@hjelmn hjelmn added the windows label Mar 5, 2016

@mcuee mcuee added this to the 1.0.22 milestone Mar 6, 2016

@chrisba77

This comment has been minimized.

Copy link

commented Sep 2, 2016

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?

@diabolo38

This comment has been minimized.

Copy link

commented Sep 3, 2016

@chrisba77 strange w/o any "hotplug" support you should be able to re-use the device without driver re-install reboot etc
if:
-release any claimed interface
-close the device
-call exit on the libsusb context

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
not real nice but the simplest i did find.

@chrisba77

This comment has been minimized.

Copy link

commented Sep 5, 2016

@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.
After reading in a Tag / Card the device sends some HID reports with Number-Keys including a Return Hit. After unplug / replug, these values seem to be random. Checked with Port Sniffer that I read the right values coming from the device. But sent Key Hits are not valid anymore and change every time i read in the same Tag. Reconnecting or Restarting my Test-SW doesnt help. Only thing that helps is rerunning Inf-Wizard or a reboot.

@diabolo38

This comment has been minimized.

Copy link

commented Sep 5, 2016

@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.

@tony--

This comment has been minimized.

Copy link

commented Jan 5, 2017

It looks like this didn't make it into 1.0.21 as planned.
Any plans to include this in 1.0.22?
Thanks in advance!

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!

@Jam-Nibi

This comment has been minimized.

Copy link

commented Sep 13, 2017

Hi guys, what's the status of this issue ?

@leileigong

This comment has been minimized.

Copy link

commented Sep 25, 2017

Did the hotplug supported on windows?

@jazzy-crane

This comment has been minimized.

Copy link

commented Nov 15, 2017

Has this now been moved to 1.0.23? :(

@changyp6

This comment has been minimized.

Copy link

commented Jan 2, 2018

I just checked the latest code, it seems that windows hotplug hasn't been implemented.
Windows libusb hotplug definitely is my first 2018 new year wish.

@njk42

This comment has been minimized.

Copy link

commented Jan 5, 2018

+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?

@ryxuli

This comment has been minimized.

Copy link

commented Jan 11, 2018

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.

@rjgc2015

This comment has been minimized.

Copy link

commented Mar 20, 2018

Hi all, did it support on Windows now?

@mcuee

This comment has been minimized.

Copy link
Contributor Author

commented Mar 20, 2018

@cor3ntin

This comment has been minimized.

Copy link

commented Jul 20, 2018

Is there any update on that? Thanks a lot

@Timmmm

This comment has been minimized.

Copy link
Contributor

commented Jan 30, 2019

Is anybody working on this?

@changyp6

This comment has been minimized.

Copy link

commented May 21, 2019

Now, this Hotplug has become my 2019 new year wish.

1 similar comment
@wanpp

This comment has been minimized.

Copy link

commented Jun 6, 2019

Now, this Hotplug has become my 2019 new year wish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.