469,327 Members | 1,219 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,327 developers. It's quick & easy.

How to use .NET framework to toggle the power on a USB-powered dev


We have a C#.NET win-forms application that talks to a device plugged into
the USB port. Sometimes when severe communications interruptions occur, such
as from a burst of ESD electricity, we need to toggle the power on that
device in order to bring it back to life.

We can do this by unplugging the usb cable from the PC, obviously, but our
program needs to recover without manual intervention.

Can anyone tell me how to toggle the power off, then back on, to a
particular USB port, programmatically? If I can do this via the .NET
framework, that would be best, but if I have to I can call win32 api calls...

This is critical as it is needed to pass an agency certification test, and
is delaying a product launch. Any help is much appreciated!

Jul 21 '05 #1
3 15034
Hi Robb,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to turn off a certain usb
device and turn it back on. If there is any misunderstanding, please feel
free to let me know.

As far as I know, USB is a hardware bus and as such not directly exposed to
user-mode (Win32) applications (or even .NET). Only Windows device-drivers
do control the USB. So you have to get a driver from manufacturer.

So if you connect a printer with USB, use the Win32/.NET printer-API. Or if
you connect a modem with USB, use the Win32 serial-API. Or if you connect
an imaging device (camera/scanner), use TWAIN/WIA.

If you want to design your own external, USB compliant hardware, you have
to understand the USB bus protocol and implement a controller chip. Then on
Windows side, you have to write your own device driver with the Windows
DDK. Sure there are OEM kits making all this easier.

Please visit the following sites for more information.


In Windows, you can use Win32_USBController to power off a certain device.
For more information, please check the following link:


Besides posting here, you can also post in microsoft.public.ddk. There are
more professionals in that group to help you with this issue. HTH.

Kevin Yu
"This posting is provided "AS IS" with no warranties, and confers no

Jul 21 '05 #2

We do have a driver we are using, which is from Texas Instruments. My
question is how do I use the .NET framework to access that driver and tell it
to reset itself? The Win32 serial API seems to have some of the correct
commands in it (thanks) but I'm not sure how to use them to tell a specific
device on a specific COM port to reset. I know the COM port #, and I know
the name of the driver..how do I say "reset yourself"? Even if I could reset
that port it would accomplish what I need.

Basically I am trying to do one of two things:

1. Ideally, tell windows to stop sending power to a certain port. This
will cause the USB device on that port to see the power loss and reset itself.

2. If that is not possible, another idea is to just "reset" the port in
question. If ai Can do that, it might interupt the flow of USB traffic to
the device long enough for the device to detect it, and reset itself.

Can you tell me if either of these is possible via the .NET framework?

Jul 21 '05 #3
Hi Robb,

As far as I know, we cannot power off a certain USB port. However, we can
tell a certain USB device to reset itself if the device's driver supports
this operation. Based on my research, there is a Reset method in
CIM_USBDevice class that can request a reset of the logical device. You can
check the following link for more information.


Since I'm not quite familiar with WMI, I suggest you post in
microsoft.public.win32.programmer.wmi newsgroup. It is a managed newsgroup.

If this can be done with WMI, the method can be called via .NET framework
through System.Management namespace. Here is an example of how to perform
this using .NET.



Kevin Yu
"This posting is provided "AS IS" with no warranties, and confers no

Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Al Dykes | last post: by
6 posts views Thread by Stephane Belzile | last post: by
2 posts views Thread by leegold2 | last post: by
5 posts views Thread by Steven | last post: by
50 posts views Thread by sksoule | last post: by
reply views Thread by Ole | last post: by
reply views Thread by =?Utf-8?B?cmZsYXphcm8=?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by listenups61195 | last post: by
reply views Thread by Purva khokhar | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.