Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 235298
b: refs/heads/master
c: d25bc4d
h: refs/heads/master
v: v3
  • Loading branch information
Pete Zaitcev authored and Greg Kroah-Hartman committed Feb 4, 2011
1 parent b561aff commit 209fc7c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 34 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ac8d67417816fa7c568b24a8f2891eb02e6d0462
refs/heads/master: d25bc4db723a44c097268b466ff74bfba4bcc4f3
42 changes: 9 additions & 33 deletions trunk/Documentation/usb/usbmon.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Controller Drivers (HCD). So, if HCD is buggy, the traces reported by
usbmon may not correspond to bus transactions precisely. This is the same
situation as with tcpdump.

Two APIs are currently implemented: "text" and "binary". The binary API
is available through a character device in /dev namespace and is an ABI.
The text API is deprecated since 2.6.35, but available for convenience.

* How to use usbmon to collect raw text traces

Unlike the packet socket, usbmon has an interface which provides traces
Expand Down Expand Up @@ -162,39 +166,11 @@ Here is the list of words, from left to right:
not machine words, but really just a byte stream split into words to make
it easier to read. Thus, the last word may contain from one to four bytes.
The length of collected data is limited and can be less than the data length
report in Data Length word.

Here is an example of code to read the data stream in a well known programming
language:

class ParsedLine {
int data_len; /* Available length of data */
byte data[];

void parseData(StringTokenizer st) {
int availwords = st.countTokens();
data = new byte[availwords * 4];
data_len = 0;
while (st.hasMoreTokens()) {
String data_str = st.nextToken();
int len = data_str.length() / 2;
int i;
int b; // byte is signed, apparently?! XXX
for (i = 0; i < len; i++) {
// data[data_len] = Byte.parseByte(
// data_str.substring(i*2, i*2 + 2),
// 16);
b = Integer.parseInt(
data_str.substring(i*2, i*2 + 2),
16);
if (b >= 128)
b *= -1;
data[data_len] = (byte) b;
data_len++;
}
}
}
}
reported in the Data Length word. In the case of an Isochronous input (Zi)
completion where the received data is sparse in the buffer, the length of
the collected data can be greater than the Data Length value (because Data
Length counts only the bytes that were received whereas the Data words
contain the entire transfer buffer).

Examples:

Expand Down
3 changes: 3 additions & 0 deletions trunk/drivers/usb/mon/mon_text.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ static void mon_text_event(struct mon_reader_text *rp, struct urb *urb,
fp++;
dp++;
}
/* Wasteful, but simple to understand: ISO 'C' is sparse. */
if (ev_type == 'C')
ep->length = urb->transfer_buffer_length;
}

ep->setup_flag = mon_text_get_setup(ep, urb, ev_type, rp->r.m_bus);
Expand Down

0 comments on commit 209fc7c

Please sign in to comment.