On Wed, 9 Aug 2006, Andy Dalton wrote:

> Greetings,
> 
> I'm interested in controlling the port power on my USB hub based on
> the serial number of the device plugged into the respective port.
> I've read the archives and purchased a hub with the appropriate port
> power control circuitry (namely the Targus, Inc.'s PAUH212) .  Using
> the source available from http://www.gniibe.org/log/2006/01/14 I have
> been to successfully turn the port power on and off.
> 
> I've experimented a bit and have been able to identify the bus number
> and device number of the hub to which the device I'm interesting in
> powering on/off is connected.  What I've not been able to figure out,
> however, is the number of the port to which the device is connected.
> 
> One alternative I have been able to find is that instead of searching
> for the hub's bus/device information, I can search for the device's
> bus/device information, use that information to find an entry in
> /proc/bus/usb/devices (which lists both the parent device number and
> port), then carry on from there.  However, I'd really rather stay away
> from parsing out that information.
> 
> I've attached a copy of the code I've been working with so far.  Any
> suggestions you might have would be greatly appreciated.

The API doesn't offer any easy way to do this.  One possibility is to mess 
around in sysfs.  For example, iterate through the entries in 
/sys/bus/usb/devices/.  If /sys/bus/usb/devices/X/devnum contains the 
device number you want and X begins with the correct bus number, then you 
can read the port number directly from the end of X.

Alternatively, parsing /proc/bus/usb/devices isn't such a big deal.  You 
only need to look at the lines beginning with "T:", and they have a very 
rigid format.

Alan Stern


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Linux-usb-users@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-users

Reply via email to