On Mon, 9 Oct 2017, Kai Hendry wrote:

> Hi there,
> 
> Can't see the /{proc,sys} interface documented in places I expect to be
> like https://github.com/torvalds/linux/tree/master/drivers/usb
> 
> And the mailing list search is pretty awful:
> https://marc.info/?l=linux-usb&w=2&r=1&s=power+measure&q=b
> 
> My use case is to examine the power draw from my USB port of my iPhone:
> lsusb | grep iPhone
> Bus 001 Device 009: ID 05ac:12a8 Apple, Inc. iPhone5/5C/5S/6
> 
> First problem is to identify the USB port! Currently I am `find
> /sys/devices | grep usb` & wondering how on earth it maps to "Bus 001
> Device 009: ID 05ac:12a8".

The mapping goes the other way.  Given the bus and port you can find
the device number by reading the /sys/bus/usb/devices/B-P/devnum file,
where B is the bus number and P is the port number (or path if the
device is plugged into a hub).

> Next I am hoping the see the power consumption my mA or something like
> that?

Have you tried running lsusb with the -v flag?  Or reading the 
/sys/bus/usb/devices/B-P/bMaxPower file?

> I did eventually find https://unix.stackexchange.com/a/81615/27433 but
> why isn't the a /proc like interface to this?

There is, but it's under /sys rather than /proc.

> Is there a way to see the
> negotiation somehow since my iPhone doesn't seem to like 500mA.

What negotation are you referring to?

If your iPhone doesn't like 500 mA, it doesn't have to use that much.  
The amount of current drawn by a USB device is determined almost
entirely by the device; the host won't do anything about it other than
to shut off the port if the device tries to take too much current.

In general, it's possible to see all USB traffic by using usbmon or 
wireshark.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to