A tool like Bus hound under Linux
http://blog.csdn.net/liuqz2009/article/details/7886461
0
Recommended in Linux you sometimes need to debug USB interface serial message, but no similar to Windows Hound tool, feel more pain, in fact, the Linux kernel provides usbmon This tool, can collect serial information.
1. Prepare:
Hook up the Debugfs (this can be enabled in the kernel configuration) and load the Usbmon module (if Usbmon is compiled into a module). If Usbmon is compiled into the kernel, the second step can be omitted
# mount-t Debugfs None_debugs/sys/kernel/debug
# modprobe Usbmon
#
Make sure bus data is ready
# Ls/sys/kernel/debug/usb/usbmon
0s 0u 1s 1t 1u 2s 2t 2u 3s 3t 3u 4s 4t 4u
#
Now you can choose to either use ' 0u ' (grab all the packets on the bus) and jump straight to the third step, or take the second step to find the bus where your device is, so that it filters out a lot of annoying information
2. Find the bus where the device is located
Run "cat/proc/bus/usb/devices" and you will find the line at the beginning of the device T. The T line has a bus port, as shown below
t:bus=03 lev=01 prnt=01 port=00 cnt=01 dev#= 2 spd=12 mxch= 0
D:ver= 1.10 cls=00 (>ifc) sub=00 prot=00 mxps= 8 #Cfgs = 1
p:vendor=0557 prodid=2004 rev= 1.00
S:manufacturer=aten
s:product=uc100km V2.00
Bus=03 means it's on the Bus3 mouth.
3. Start viewing information
# cat/sys/kernel/debug/usb/usbmon/3u >/tmp/1.mon.out
command to listen to a bus port, or you can listen to all the bus ports
# cat/sys/kernel/debug/usb/usbmon/0u >/tmp/1.mon.out
* Data Format
Two types of data formats are now supported: ' 1t ' format and ' 1u ' format. ' 1t ' is not supported on kernel 2.6.21. The ' 1u ' data format adds some data items, such as ISO framework information, interval time, and so on. It produces a slightly redundant line, but it is indeed a valid addition to the ' 1t ' format.
Detailed description of the data content (from left to right)
-URB Tag. URB Address
-Timestamp, time interval
-Event Type. The time type.
The supported types are: S-submission, C-callback, e-submission error.
-"Address" (usually a "pipe"). It consists of 4 items, separated by colons: URB type, direction, Bus number, Device Address, Endpoint number.
The type and direction are encapsulated into the following data formats:
Ci Co Control input and output
Zi Zo isochronous input and output
Ii Io Interrupt input and output
Bi Bo Bulk input and output
Bus number, Device address, and endpoint are decimal digits, but they may be set to 0 because of the convenience of reading.
-URB Status Word. This is either a letter or some number separated by semicolons.
-Setup packet, if present, includes 5 strings: They are bmrequesttype,brequest, Wvalue, Windex, Wlength, (USB Specification 2.0. Details in the agreement)
-Sync Number
-Data Length. Data length
-Data tag. Even if the data length is not 0,usbmon, it is not always possible to capture the data, the packet content is only valid for this tag ' = '.
-Data Words large head hex number.
Example:
Example of input control to get port status
D5ea89a0 3575914555 s ci:1:001:0 s a3 0000 0003 0004 4 <
d5ea89a0 3575914560 C ci:1:001:0 0 4 = 01050000
Send a 31-byte block package (which holds a SCSI command 0x5E) to the storage device via the BUS5 port
Dd65f0e8 4128379752 S bo:1:005:2 -115 = 55534243 5e000000 00000000 00000600 00000000 00000000 00000000 000000
Dd65f0e8 4128379808 C bo:1:005:2 0 >
For more information, see: Http://www.mjmwired.net/kernel/Documentation/usb/usbmon.txt: http://hi.baidu.com/kahn_qiao/item/ cb1c57e151f4eeaace2d4f9d ======================================================================================= ===============================================================LINUXUSB driver Debugging: This is a detailed page of the preparation work under Linuxusb driver debugging--003:ubuntu , introduced and Linux, related knowledge, skills, experience, and some Linux source code and so on. Preparations under Ubuntu: (1) How to view the PRINTK output in the kernel: DMESG
Again with the pipeline command, DMESG |head, DMESG |tail through this command, we can see the contents of the PRINTK output, which is a useful tool. (2) USB Capture tool: Usb_mon In fact, Ubuntu has built-in USB capture tool---Usb_mon "in fact make menuconfig time will let us choose" using the method as follows: # mount-t Debugfs None/sys /kernel/debug
# modprobe Usbmon
To view the current USB device:
# cat/sys/kernel/debug/usb/devices
The following output:
t:bus=01 lev=01 prnt=01 port=00 cnt=01 dev#= 0 spd=480 mxch=
d:ver= 2.00 cls=00 (>ifc) sub=00 prot=00 mxps=64 #Cfgs = 1
P:VENDOR=601A prodid=4740 rev= 1.00
S:manufacturer=ingenic
s:product=jz4740 USB Boot Device
c:* #Ifs = 1 cfg#= 1 atr=c0 mxpwr= 2mA
i:* if#= 0 alt= 0 #EPs = 2 cls=ff (vend.) sub=00 prot=50 Driver=skeleton
E:AD=01 (O) atr=02 (Bulk) mxps= ivl=0ms
e:ad=81 (I) atr=02 (Bulk) mxps= ivl=0ms
How can I read the above output? Documentation/usb/usbmon.txt
Bus=01 means it's bus 1. The bus number of our device can be found through the above vendor=601a ProdID. Above bus=01. Using the following fame and fortune, you start to listen to all USB packets on the BUS01.
# cat/sys/kernel/debug/usb/usbmon/1u to start listening to all the USB packets on all Bus:
# cat/sys/kernel/debug/usb/usbmon/0u
Once a packet is available, it will print out:
# cat/sys/kernel/debug/usb/usbmon/1u
F07dbb80 3233986312 s co:1:012:0 s 80c0 0000 0000 0
F07dbb80 3234327703 C co:1:012:0 0 0
F07dbb80 3234327880 s co:1:012:0 s 40 02 0000 0200 0000 0
F07dbb80 3234329561 C co:1:012:0 0 0
F07dbb80 3234329625 S bi:1:012:1 -115 <
F07dbb80 3234331550 C bi:1:012:1-75 32 = 00000000 00000000 ... Read the above data, or to see Usbmon.txt URB tag: Flag
TimeStamp: Number of milliseconds
Event type:s-Submission, C-callback, e-submission error.
URBType:BusNo:DeviceAddr:EndPointNum
Ci Co Control input and output
Zi Zo isochronous input and output
Ii Io Interrupt input and output
Bi Bo Bulk input and output
URB status:0 for no error. -XXX is the error code. Transferred from: http://blog.csdn.net/peng654321/article/details/6949170
A tool like Bus hound under Linux