Re: Modified usb-devices.sh script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 19 Jun 2009, Frans Pop wrote:

> Maybe we can support both cases without a kernel version test.
> Something like:
>         maxps=`cat $eppath/wMaxPacketSize`
>         if `echo $maxps | grep -Eq "^[0-9a-fA-F]{4}$"`; then
>                 maxps=`printf "%i\n" 0x$maxps`
>         fi
> That assumes that there are no actual max packet sizes >=1000.
> 
> If there are, then this could be an option:
>         maxps=`cat $eppath/wMaxPacketSize`
>         if `echo $maxps | grep -Eq "^0[0-9a-fA-F]{3}$"`; then
>                 maxps=`printf "%i\n" 0x$maxps`
>         fi
> That assumes there are no max packet sizes >=0x1000 (>=4096).
> 
> Is either of those assumptions valid in practice?

Not really.

> The values I see on my system are quite small. A quick google seems to 
> indicate that USB 3 has a maximum of 1024, so the second option would 
> work for the foreseeable future. At some point this workaround could be 
> replaced by a kernel version test, or just dropped.

On second thought, maybe it is better for sysfs to continue exporting 
the raw value in hex.  The script can do all the necessary processing.

Here is how the value is encoded: Bits 0 - 10 contain the actual 
maxpacket size (this corresponds to a mask of 0x7ff).  Bits 11 - 12 
contain a multiplicity value, to which you should add 1.  (Bits 13 - 15 
are reserved for future use.)

So for example, if the value in the attribute file is 1400 then the
script should print something like: MxPS=1024*3.  For the value 0040 it
should print something like: MxPS=  64*1.

The real devices file doesn't include the multiplicity.  Multiplicity
is a USB-2.0 addition; I guess nobody added it into the devices file.

> I see that /proc/bus/usb/devices also omits the E: line for endpoint 0,
> so with the above explained I see no problems with dropping it.
> 
> Is it possible there are multiple endpoints on the device level (as 
> opposed to on the interfaces level)?

No.  There is always exactly one.

>  I.e, is it safe to just remove the 
> entire 'for endpoint in ep_??' loop in print_device()?

Yes.

> BTW, are there plans to include this script in some source repository 
> somewhere?

Ask Greg.  I imagine it would be a useful addition to the usbutils 
package.

Alan Stern

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

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux