Power off an USB device in software on Windows

Perpetual Student picture Perpetual Student · Dec 31, 2008 · Viewed 55.2k times · Source

I would like to power cycle an USB device through software on Windows.

I am doing development on a small USB power microcontroller. This chip will revert to native behavior on a power cycle and allow a code download. Since my code will crash the device when things go wrong -- making it ignore all USB commands -- I have to physically unplug the device from the system.

I want to do development remotely, and not have to be physically present.

So far I have tried using "devcon" to disable portions of the USB stack. While this takes the hubs into D3 (should be powered off!), there is still power being supplied to the device.

Are there any preexisting solutions or SetupAPI tricks that might help?

Answer

devstuff picture devstuff · Jan 1, 2009

Since it's for development/test instead of production, I'd recommend having a solid-state_relay as part of a second device and using that to cycle the power on the USB connection.