A tool like Bus hound under Linux

Source: Internet
Author: User

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

A tool like Bus hound under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.