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: Print output on a compact format, close to the one used by the parsing 
tools
Author:  Mauro Carvalho Chehab <[email protected]>
Date:    Tue Mar 8 10:08:31 2011 -0300

Yet, parsing from wireshark parser seems to be broken, as long outputs
would be shown as:

000093248 ms 000000 ms (000304 us EP=0x00) 40 >>> 03 00 00 A0 00 02 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 .. .

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

 contrib/wireshark_parser.pl |  147 ++++++++++++++++++++++++++++++++++++------
 1 files changed, 126 insertions(+), 21 deletions(-)

---

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

diff --git a/contrib/wireshark_parser.pl b/contrib/wireshark_parser.pl
index e5e0b22..1c74ae1 100755
--- a/contrib/wireshark_parser.pl
+++ b/contrib/wireshark_parser.pl
@@ -1,22 +1,118 @@
 #!/usr/bin/perl
 use strict;
+use Date::Parse;
 
 my $debug = 1;
 
-sub process_frame(%) {
-       my %frame = @_;
+my @pending;
+
+my $initial_time;
+my $last_time;
+
+sub print_frame($$)
+{
+       my %req = %{ @_[0] };
+       my %resp = %{ @_[1] };
+
+#      # For now, let's concern only when there are some data
+#      return if (!$resp{"ApplicationData"});
+
+       my $rel_time = $req{"Arrival"} - $initial_time;
+
+       # Print timestamps:
+       #       relative time from resp 1
+       #       relative time from last resp
+       #       time to complete
+       printf "%09d ms %06d ms (%06d us",
+               1000 * $req{"Time"},
+               1000 * ($req{"Time"} - $last_time),
+               ($resp{"Time"} - $req{"Time"}) * 1000000;
+       $last_time = $req{"Time"};
+
+       printf " EP=%s)", $resp{"Endpoint"};
+
+       printf " %02x", $req{"bmRequestType"};
+       printf " %02x", $req{"bRequest"} if ($req{"bRequest"});
+       printf " %02x", $req{"Index"} if ($req{"Index"});
+       printf " %02x", $req{"bDescriptorType"} if ($req{"bDescriptorType"});
+       printf " %02x %02x", $req{"LanguageId"} & 0xff, $req{"LanguageId"} >> 8 
if ($req{"LanguageId"});
+       printf " %02x %02x", $req{"wLength"} & 0xff, $req{"wLength"} >> 8  if 
($req{"wLength"});
+
+       my $app_data = $req{"ApplicationData"};
+       if ($app_data ne "") {
+               printf " >>>";
+       }
+       while ($app_data ne "") {
+               printf " %s", substr($app_data, 0, 2);
+               $app_data = substr ($app_data, 2);
+       }
 
-       while (my ($key, $value) = each(%frame) ) {
-               print "$key => $value\n";
+       my $app_data = $resp{"ApplicationData"};
+       if ($app_data ne "") {
+               printf " <<<";
+       }
+       while ($app_data ne "") {
+               printf " %s", substr($app_data, 0, 2);
+               $app_data = substr ($app_data, 2);
        }
 
+
        print "\n";
+
+       if ($debug) {
+               my ($key, $value);
+               print "\tREQ:  $key => $value\n" while (($key, $value) = 
each(%req));
+               print "\tRESP: $key => $value\n" while (($key, $value) = 
each(%resp));
+               print "\n";
+       }
+
+       return;
 }
 
+sub process_frame(%) {
+       my %frame = @_;
+
+       $initial_time = $frame{"Arrival"} if (!$initial_time);
+
+       if ($debug > 1) {
+               my ($key, $value);
+               print "\t\tRAW: $key => $value\n" while (($key, $value) = 
each(%frame));
+               print "\n";
+       }
+
+       # For now, we'll take a look only on control frames
+       return if ($frame{"TransferType"} ne "URB_CONTROL");
+
+       if ($frame{"Status"} eq "-EINPROGRESS") {
+               push @pending, \%frame;
+               return;
+       }
+
+       # Seek for operation origin
+       my $related = $frame{"__RelatedTo"};
+       if (!$related) {
+               print "URB %d incomplete\n", $frame{"Number"};
+               return;
+       }
+       for (my $i = 0; $i < scalar(@pending); $i++) {
+               if ($related == $pending[$i]{"Number"}) {
+                       my %req = %{$pending[$i]};
+
+                       print_frame (\%req, \%frame);
+
+                       # Remove from array, as it were already used
+                       splice(@pending, $i, 1);
+                       return;
+               }
+       }
+       printf "URB %d incomplete: Couldn't find related URB %d\n", 
$frame{"Number"}, $related;
+       return;
+}
 
 sub wireshark_parser() {
        my %frame;
        my $next_is_time_frame;
+
        while (<>) {
                next if (m/^\n/);
                next if 
(m/^\s+(INTERFACE|ENDPOINT|DEVICE|CONFIGURATION|STRING)\s+DESCRIPTOR/);
@@ -28,7 +124,14 @@ sub wireshark_parser() {
                        next;
                }
                if ($next_is_time_frame) {
-                       $frame{"Time"} = $2 if 
(m/^\s*([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)/);
+                       if 
(m/^\s*([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)/) {
+                               $frame{"Time"} = $2 + 0;
+                               if ($3 eq "host") {
+                                       $frame{"Direction"} = "Device";
+                               } else {
+                                       $frame{"Direction"} = "Host";
+                               }
+                       }
                        $next_is_time_frame = 0;
                        next;
                }
@@ -69,8 +172,8 @@ sub wireshark_parser() {
                        $frame{"HasData"} = 1 if ($1 eq "present");
                        next;
                }
-               if (m/^\s+URB\s+status\:\s+([^\(]*)\s+\(/) {
-                       $frame{"Status"} = $1;
+               if (m/^\s+URB\s+status\:\s+([^\(]*)\s+\((.*)\)\s+\(/ || 
m/^\s+URB\s+status\:\s+([^\(]*)\s+\((.*)\)/) {
+                       $frame{"Status"} = $2;
                        next;
                }
                if (m/^\s+URB\s+length\s+\[bytes\]\:\s+(.*)/) {
@@ -91,40 +194,41 @@ sub wireshark_parser() {
                        next;
                }
                if (m/^\s+\[(Request|Response)\s+in\:\s+(\d+)\]/) {
-                       $frame{$1} = $2;
-                       next;
-               }
-               if (m/^\s+\[bInterfaceClass\:\s+(.*)\s+\(/) {
-                       $frame{"bInterfaceClass"} = $1;
+                       $frame{"__RelatedTo"} = $2;
+                       $frame{"__RelationType"} = $1;
                        next;
                }
                if (m/^\s+Configuration\s+bmAttributes\:\s+(.*)/) {
                        $frame{"ConfigurationbmAttributes"} = $1;
                        next;
                }
-               if (m/^\s+bMaxPower\:\s+(.*)\s+\(/) {
-                       $frame{"bInterfaceClass"} = $1;
+               if (m/^\s+bMaxPower\:\s+(.*)\s+\((.*)\)/) {
+                       $frame{"bMaxPower"} = $2;
                        next;
                }
                next if (m/^\s+URB\s+setup/);
                if (m/^\s+bmRequestType\:\s+(.*)/) {
-                       $frame{"bmRequestType"} = $1;
+                       $frame{"bmRequestType"} = hex($1);
                        next;
                }
                if (m/^\s+bmAttributes\:\s+(.*)/) {
                        $frame{"bmAttributes"} = $1;
                        next;
                }
-               if (m/^\s+bRequest\:\s+(.*)\s+\(/) {
-                       $frame{"bRequest"} = $1;
+               if (m/^\s+bRequest\:\s+(.*)\s+\((.*)\)/) {
+                       $frame{"bRequest"} = hex($2);
                        next;
                }
                if (m/^\s+Descriptor\s+Index\:\s+(.*)/) {
                        $frame{"DescriptorIndex"} = $1;
                        next;
                }
-               if (m/^\s+(bDescriptorType|bInterfaceClass)\:\s+(.*)\s+\(/) {
-                       $frame{$1} = $2;
+               if 
(m/^\s+(bDescriptorType|bInterfaceClass)\:\s+(.*)\s+\((.*)\)/) {
+                       $frame{$1} = hex($3);
+                       next;
+               }
+               if (m/^\s+\[(bInterfaceClass)\:\s+(.*)\s+\((.*)\)\]/) {
+                       $frame{$1} = hex($3);
                        next;
                }
                if 
(m/^\s+(bInterval|bInterfaceNumber|bInterfaceSubClass|bInterfaceProtocol)\:\s+(.*)/)
 {
@@ -183,8 +287,9 @@ sub wireshark_parser() {
                        $frame{"$1Length"} = $2;
                        next;
                }
+
                if (m/^\s+Arrival\s+Time:\s+(.*)/) {
-                       $frame{"ArrivalTime"} = $1;
+                       $frame{"ArrivalTime"} = str2time($1);
                        next;
                }
                if (m/^\s+\[Time\s+from\s+request\:\s+(.*)\s+seconds\]/) {
@@ -215,7 +320,7 @@ sub wireshark_parser() {
 
 
                # Prints unparsed strings
-               print "# Unparsed: $_" if ($debug > 2);
+               print "# Unparsed: $_" if ($debug);
        }
 }
 

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

Reply via email to