473,387 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

Hi,

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!

thanks!
Robb
Jul 21 '05 #1
3 15681
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.

http://www.usb.org/
http://www.microsoft.com/hwdev/bus/USB/
http://www.lvr.com/usb.htm
http://www.beyondlogic.org

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

http://msdn.microsoft.com/library/de...us/wmisdk/wmi/
win32_usbcontroller.asp

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
rights."

Jul 21 '05 #2
Kevin,

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?

thanks
Robb
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.

http://msdn.microsoft.com/library/de...us/wmisdk/wmi/
cim_usbdevice.asp

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.

http://www.codeproject.com/csharp/Pr...erUsingWMI.asp

HTH.

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

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Al Dykes | last post by:
I've just grabbed a PHP book and can deal with the syntax and now I need to decide to learn specific packages and features. Define "framework". What are the major framework flavors ? Under...
6
by: Stephane Belzile | last post by:
Is there a way I can detect in vb.Net the power has switched to a UPS unit in case of power failure? Thanks
0
by: Helge Jensen | last post by:
Having posted in microsoft.public.dotnet.framework.sdk and microsoft.public.dotnet.framework.wmi without receiving any response, I posthere on the off-chance that someone who isn't following those...
2
by: leegold2 | last post by:
I wondered if anyone would give me code- I think it would be easy, but I'm a complete newbie. What I want to do is to show many tables in a brief truncated format and then for each table offer the...
11
by: MLH | last post by:
Why is that? If I choose the tiny check boxes which are hard to hit with a mouse, it works fine. But option buttions, shich can be sized big enough for people with limited sight and dexterity...
5
by: Steven | last post by:
Can anyone tell me how to toggle the "Caps Lock" key? Thanks in advance
50
by: sksoule | last post by:
Hi, Can anyone please tell me how to toggle a nth bit. For example, I am having a variable which is of 8 bits. I want to toggle the nth bit. Regards, Santosh
0
by: Ole | last post by:
Hi, Is there a way to turn on/off the USB power switch from C#? Is it also possible to get a "short curcuit" event from the USB port? Thanks Ole
0
by: =?Utf-8?B?cmZsYXphcm8=?= | last post by:
Hi All, We are trying to build an automation utility to configure OS. May I ask for anyone who could help me find a way to automate in C# the processes below via WMI/API/Registry? Control...
1
by: swiftouch | last post by:
I'm getting an error message in FF2.0: document.getElementById(toggle) has no properties The goal of the script is, when I hover my mouse over an image, to make one div element visible while...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.