diff options
Diffstat (limited to 'Documentation/usb/usbmon.txt')
-rw-r--r-- | Documentation/usb/usbmon.txt | 42 |
1 files changed, 9 insertions, 33 deletions
diff --git a/Documentation/usb/usbmon.txt b/Documentation/usb/usbmon.txt index 66f92d1194c1..a4efa0462f05 100644 --- a/Documentation/usb/usbmon.txt +++ b/Documentation/usb/usbmon.txt | |||
@@ -12,6 +12,10 @@ Controller Drivers (HCD). So, if HCD is buggy, the traces reported by | |||
12 | usbmon may not correspond to bus transactions precisely. This is the same | 12 | usbmon may not correspond to bus transactions precisely. This is the same |
13 | situation as with tcpdump. | 13 | situation as with tcpdump. |
14 | 14 | ||
15 | Two APIs are currently implemented: "text" and "binary". The binary API | ||
16 | is available through a character device in /dev namespace and is an ABI. | ||
17 | The text API is deprecated since 2.6.35, but available for convenience. | ||
18 | |||
15 | * How to use usbmon to collect raw text traces | 19 | * How to use usbmon to collect raw text traces |
16 | 20 | ||
17 | Unlike the packet socket, usbmon has an interface which provides traces | 21 | Unlike the packet socket, usbmon has an interface which provides traces |
@@ -162,39 +166,11 @@ Here is the list of words, from left to right: | |||
162 | not machine words, but really just a byte stream split into words to make | 166 | not machine words, but really just a byte stream split into words to make |
163 | it easier to read. Thus, the last word may contain from one to four bytes. | 167 | it easier to read. Thus, the last word may contain from one to four bytes. |
164 | The length of collected data is limited and can be less than the data length | 168 | The length of collected data is limited and can be less than the data length |
165 | report in Data Length word. | 169 | reported in the Data Length word. In the case of an Isochronous input (Zi) |
166 | 170 | completion where the received data is sparse in the buffer, the length of | |
167 | Here is an example of code to read the data stream in a well known programming | 171 | the collected data can be greater than the Data Length value (because Data |
168 | language: | 172 | Length counts only the bytes that were received whereas the Data words |
169 | 173 | contain the entire transfer buffer). | |
170 | class ParsedLine { | ||
171 | int data_len; /* Available length of data */ | ||
172 | byte data[]; | ||
173 | |||
174 | void parseData(StringTokenizer st) { | ||
175 | int availwords = st.countTokens(); | ||
176 | data = new byte[availwords * 4]; | ||
177 | data_len = 0; | ||
178 | while (st.hasMoreTokens()) { | ||
179 | String data_str = st.nextToken(); | ||
180 | int len = data_str.length() / 2; | ||
181 | int i; | ||
182 | int b; // byte is signed, apparently?! XXX | ||
183 | for (i = 0; i < len; i++) { | ||
184 | // data[data_len] = Byte.parseByte( | ||
185 | // data_str.substring(i*2, i*2 + 2), | ||
186 | // 16); | ||
187 | b = Integer.parseInt( | ||
188 | data_str.substring(i*2, i*2 + 2), | ||
189 | 16); | ||
190 | if (b >= 128) | ||
191 | b *= -1; | ||
192 | data[data_len] = (byte) b; | ||
193 | data_len++; | ||
194 | } | ||
195 | } | ||
196 | } | ||
197 | } | ||
198 | 174 | ||
199 | Examples: | 175 | Examples: |
200 | 176 | ||