Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to issue USB device reconnection under Windows

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.

like image 268
datacompboy Avatar asked Dec 22 '12 06:12

datacompboy


People also ask

Why do my USB port keep disconnecting and reconnecting?

A faulty driver can be the reason why your USB keeps disconnecting and reconnecting in your windows version. But the same can be solved by reinstalling the Universal Serial Bus Controllers Driver in Drive Manager.


1 Answers

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.

like image 150
Mike Mackintosh Avatar answered Oct 12 '22 09:10

Mike Mackintosh