Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
922 views
in Technique[技术] by (71.8m points)

winapi - Power off an USB device in software on Windows

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Some USB hubs have the ability to turn power off to its downstream devices.

"Is it possible to power up ports on a USB hub from Ubuntu?" https://askubuntu.com/questions/149242/is-it-possible-to-power-up-ports-on-a-usb-hub-from-ubuntu Which points to some c source for hub-ctrl.c

See: http://www.gniibe.org/development/ac-power-control-by-USB-hub/index

I tested this on Ubuntu with a Dream-Cheeky USB LED unit, and it did seem to turn the power off - although when turned on again, the device had remembered (!) its LED on/off state ??? - This did not happen when I unplugged and repluged the USB lead to the LED...

It looks like someone has looked at compiling this for Windows, but I could not find the result, sorry.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...