473,766 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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, programmaticall y? 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 15748
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 misunderstandin g, 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_USBContro ller to power off a certain device.
For more information, please check the following link:

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

Besides posting here, you can also post in microsoft.publi c.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.a sp

Since I'm not quite familiar with WMI, I suggest you post in
microsoft.publi c.win32.program mer.wmi newsgroup. It is a managed newsgroup.

If this can be done with WMI, the method can be called via .NET framework
through System.Manageme nt 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
3674
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 what conditions can I use two or more frameworks? Sorry for the beginners question.
6
4017
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
2285
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 groups knows a solution. I'm using code (roughly like): using System; using System.Management; public class Foo {
2
2290
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 user the ability to toggle so they can see the full content of each table individually. The code I got from the net below works fine for *one* table but when I try to add a 2nd table it does not work. How can I apply this toggle individually to...
11
4817
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 to hit - they don't work at all. Its true. I created 'em with the built-in wizard furnished with Access 97 but they do not work. I put 12 of 'em in the group, labeled the months of the year and giving
5
3445
by: Steven | last post by:
Can anyone tell me how to toggle the "Caps Lock" key? Thanks in advance
50
28299
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
1684
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
3196
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 Panel -System Properties -Hardware Tab ->Device Manager a. Click Universal Serial Bus Controllers b. Right Click USB Root HUB -properties -Power Management Tab c. Uncheck "Allow the computer to turn off this device to save power"
1
1964
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 making all the others div elements in the array, hidden. thisDocId is the element to avoid hiding. This is the script: <script>
0
9404
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10008
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9837
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8833
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6651
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3929
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.