Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#1.0 C#2.0 C#3.0 C++ C C# C#4.0 , +
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. D'Oh! | :doh:
 

Thank you Smile | :)
Posted 2-Mar-10 6:55am
cates327
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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[^]
  Permalink  
v4
Comments
Jαved at 21-Jun-12 7:31am
   
Good links +5.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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?
  Permalink  
Comments
pwasser at 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)

  Print Answers RSS
0 OriginalGriff 439
1 ChintanShukla 310
2 Gihan Liyanage 298
3 RyanDev 250
4 Richard Deeming 220
0 Sergey Alexandrovich Kryukov 8,906
1 OriginalGriff 7,771
2 CPallini 2,603
3 Richard MacCutchan 2,121
4 Abhinav S 1,928


Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 20 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100