This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/v4l-utils.git tree:

Subject: Add a generic parser for USB logs
Author:  Mauro Carvalho Chehab <[email protected]>
Date:    Tue Dec 7 07:36:03 2010 -0200

This parser just decodes the standard USB fields. It is probably more useful
as a basis for more specific parsers.

Signed-off-by: Mauro Carvalho Chehab <[email protected]>

 contrib/usb_parse/parse_usb.pl |   76 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 76 insertions(+), 0 deletions(-)

---

http://git.linuxtv.org/v4l-utils.git?a=commitdiff;h=8d0729e618a5b8a2a96ea1f2b0c156e9dab0ce46

diff --git a/contrib/usb_parse/parse_usb.pl b/contrib/usb_parse/parse_usb.pl
new file mode 100755
index 0000000..45fafd3
--- /dev/null
+++ b/contrib/usb_parse/parse_usb.pl
@@ -0,0 +1,76 @@
+#!/usr/bin/perl
+use strict;
+
+#   Copyright (C) 2010 Mauro Carvalho Chehab <[email protected]>
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation, version 2 of the License.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+# This small script parses USB dumps generated by several drivers,
+# decoding USB bits.
+#
+# To use it, do:
+# dmesg | ./parse_usb.pl
+#
+# Also, there are other utilities that produce similar outputs, and it
+# is not hard to parse some USB analyzers log into the expected format.
+#
+
+sub type_req($)
+{
+       my $reqtype = shift;
+       my $s;
+
+       if ($reqtype & 0x80) {
+               $s = "WR ";
+       } else {
+               $s = "RD ";
+       }
+       if (($reqtype & 0x60) == 0x20) {
+               $s .= "CLAS ";
+       } elsif (($reqtype & 0x60) == 0x40) {
+               $s .= "VEND ";
+       } elsif (($reqtype & 0x60) == 0x60) {
+               $s .= "RSVD ";
+       }
+
+       if (($reqtype & 0x1f) == 0x00) {
+               $s .= "DEV ";
+       } elsif (($reqtype & 0x1f) == 0x01) {
+               $s .= "INT ";
+       } elsif (($reqtype & 0x1f) == 0x02) {
+               $s .= "EP ";
+       } elsif (($reqtype & 0x1f) == 0x03) {
+               $s .= "OTHER ";
+       } elsif (($reqtype & 0x1f) == 0x04) {
+               $s .= "PORT ";
+       } elsif (($reqtype & 0x1f) == 0x05) {
+               $s .= "RPIPE ";
+       } else {
+               $s .= sprintf "RECIP 0x%02x ", $reqtype & 0x1f;
+       }
+
+       $s =~ s/\s+$//;
+       return $s;
+}
+
+while (<>) {
+       tr/A-F/a-f/;
+       if (m/([0-9a-f].) ([0-9a-f].) ([0-9a-f].) ([0-9a-f].) ([0-9a-f].) 
([0-9a-f].) ([0-9a-f].) ([0-9a-f].)[\<\>\s]+(.*)/) {
+               my $reqtype = hex($1);
+               my $req = hex($2);
+               my $wvalue = hex("$4$3");
+               my $windex = hex("$6$5");
+               my $wlen = hex("$8$7");
+               my $payload = $9;
+
+               printf("%s, Req %3d, wValue: 0x%04x, wIndex 0x%04x, wlen %d: 
%s\n",
+                       type_req($reqtype), $req, $wvalue, $windex, $wlen, 
$payload);
+       }
+}

_______________________________________________
linuxtv-commits mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to