Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turn off power to USB Port programmatically

Tags:

c#

.net

c#-4.0

I have a project that I'm working on and I want to use these: http://www.woot.com/blog/post/usb-powered-woot-off-lights-2

However it looks like they just have on/off switches. They aren't something that you can interface with programmatically.

So I was thinking, if I could find a way to cut the power to the USB port, that would allow me to turn the lights on and off with my app. However I cant find any way to cut the power to the USB port. Is this possible?

like image 205
Sugitime Avatar asked Feb 04 '13 15:02

Sugitime


People also ask

Can you turn off power to a USB port?

The simple answer is no, if you remove power to that USB port it will not function as a USB port. Part of the specification is for power, and all devices plugged into a USB port expect power.

How do I turn off my power surge USB port?

Solution. Initial troubleshooting should follow the on-screen directions: Disconnect all USB peripheral items, then Click the Reset button on the screen using the system touchpad and touchpad buttons. Once reset, it is recommended that you reboot the system then reconnect the USB device and see if the error re-occurs.


2 Answers

EDIT: unfortunately it seems the products from this company are not sold anymore.


The powered-woot-off-lights-2 are powered via a regular usb plug which mean they are 5 volts and there are in each one light and one motor.

I could not find how many Amps are needs but I know that this extension would be perfect if 200 mA for one powered-woot-off-lights is enough.

USB Controler Extension

The C# or VB.NET code would look like this.

// On
nusbio.GPIOS[NusbioGpio.Gpio0].DigitalWrite(true);
nusbio.GPIOS[NusbioGpio.Gpio1].DigitalWrite(true);
// Off
nusbio.GPIOS[NusbioGpio.Gpio0].DigitalWrite(false);
nusbio.GPIOS[NusbioGpio.Gpio1].DigitalWrite(false);

see Nusbio's website and I think the extension is in their store. I used a similar nusbio extension myself.

to turn on/off my a USB fan and a battery powered small lamp

like image 28
Eric Serrot Avatar answered Sep 19 '22 15:09

Eric Serrot


I had a similar problem and solved it using DevManView.exe (freeware):

  1. Download DevManView.exe and put the .exe file somewhere: http://www.nirsoft.net/utils/device_manager_view.html

  2. Go to your Device Manager and figure out which USB-Controller you have to enable/disable, so that your device does/doesn't get power anymore. For me disabling "USB Serial Converter" does cut the power of all USB slots.

USB Serial Converter in device manager

  1. In C#, create and start a new process for disabling the device (using the name of the USB-Controller).

    Process devManViewProc = new Process();
    devManViewProc.StartInfo.FileName = @"<path to DevManView.exe>\DevManView.exe";
    devManViewProc.StartInfo.Arguments = "/disable \"USB Serial Converter\"";
    devManViewProc.Start();
    devManViewProc.WaitForExit();
    
  2. And enable it again.

    devManViewProc.StartInfo.Arguments = "/enable \"USB Serial Converter\"";
    devManViewProc.Start();
    devManViewProc.WaitForExit();
    
like image 101
Jannis Kappertz Avatar answered Sep 19 '22 15:09

Jannis Kappertz