Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
Hi~ i have little problem with USB devices (ex:Bluetooth or USB disk). If i want to know the power consumption of USB devices using C# or C/C++ API, is't possible?? Please give me some guide or advice. :doh:


Thank you :)
Posted

A USB device specifies its power consumption expressed in 2mA units in the configuration descriptor (bMaxPower).

This shows how to obtain device configuration descriptor.

http://msdn.microsoft.com/en-us/library/windows/hardware/ff540174(v=vs.85).aspx[^]

About device configuration descriptors:

http://www.beyondlogic.org/usbnutshell/usb5.shtml#DeviceDescriptors[^]
 
Share this answer
 
v4
Comments
Jαved 21-Jun-12 7:31am    
Good links +5.
I think you are out of luck.
You might be able to catch an OS level exception if the thing over-draws, but I don't think current is reported.
If you need it to test stuff, I'd recommend getting a good volt ohm meter and a short USB A male-female cable. Splice a milli Ohm high precision resister inline with the power wire in the cable and measure the voltage drop across the resister to get the current.
You may be able to get a VOM with a serial output (or even USB) and use it to read the current back into a computer.
 
Share this answer
 
Seriously, a volt-ohm meter? My thinking is if Windows is able to display the power requirements of an attached USB device, there must be a way to do it in C#/C++. Anyone?
 
Share this answer
 
Comments
[no name] 20-Jun-12 22:53pm    
A USB device specifies its power consumption expressed in 2mA units in the configuration descriptor.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900