How to issue USB device reconnection under Windows
deadlock, device-driver, ftdi, usb
Solution
I would suggest that you move your thinking up a step. You are trying to restart the USB device directly, why not try the hub?
I had a similar problem, and doing:
devcon remove *ROOT_HUB* && devcon rescan
Re-attached the USB device to the hub when it was hung.
Note: This will remove ALL USB devices from the device manager and re-add them. You can use expect or alike to do `devcon findall *ROOT_HUB*` and remove either `ROOT_HUB20` or `ROOT_HUB30` as needed.
Problem
I have an USB device based on FTDI chip. Sometimes, its driver get stuck. Under linux, there no problem -- device get automatically disconnected, and reconnected by default kernel, and only problem is device name changed -- that can be fixed by udev rules. Under windows, when it stuck, application's thread that does `read()` or `write()` at that moment are completely hangs. It can't be killed nor by `TerminateThread`, nor by `KillProcess`. The only way to kill app -- is disconnect USB device physically. Any way to issue programmatically device reconnection, that will remove driver's deadlock and allow to re-open port and continue working after? Administrative rights application can have, if that required.