From 5e0ad401330f23a6524c745b133e32b9d04a7ecd Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 26 Feb 2009 15:30:48 -0300 Subject: Move parse-sniffusb2.pl to the right dir From: Mauro Carvalho Chehab As pointed by Cityk, this file were at the wrong place. Priority: normal Signed-off-by: Mauro Carvalho Chehab --- v4l2-apps/util/parse-sniffusb2.pl | 84 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100755 v4l2-apps/util/parse-sniffusb2.pl (limited to 'v4l2-apps/util') diff --git a/v4l2-apps/util/parse-sniffusb2.pl b/v4l2-apps/util/parse-sniffusb2.pl new file mode 100755 index 000000000..34406b0ea --- /dev/null +++ b/v4l2-apps/util/parse-sniffusb2.pl @@ -0,0 +1,84 @@ +#!/usr/bin/perl +# +# Author: Franklin Meng +# Parser for USB snoops captured from SniffUSB 2.0. +# + +use strict; +use warnings; +use Data::Dumper; + +foreach my $curfile (@ARGV) { + parsefile($curfile); + #we can only process 1 file + exit; +} + +sub parsefile { + my $curfile = shift; + my $SetupPacket =''; + my $preS = ''; + my $TransferBuffer =''; + my $preT = ''; + my $Direction =''; + my $preD = ''; + my @tmpsplit; + my $t=0; + my $s=0; + + open(FD, $curfile) || die("Error: $!\n"); + + while() { + chomp; + if($t==1 && /^\s+\d{8}/) { +# print $_ . "\n"; + @tmpsplit = split(/\:\s/,$_); + $TransferBuffer = $TransferBuffer . $tmpsplit[1] . " "; + } elsif($s==1 && /^\s+\d{8}/) { +# print $_ . "\n"; + @tmpsplit = split(/\:\s/,$_); + $SetupPacket = $SetupPacket . $tmpsplit[1] ; + } else { + $t=0; + $s=0; + } + if(/[<>]{3}/){ + #print out last packet if valid + if($SetupPacket) { + if($preT) { + print "$SetupPacket $preD $preT\n"; + + } else { + print "$SetupPacket $Direction $TransferBuffer\n"; + } + } +# print "$SetupPacket $Direction $TransferBuffer\n"; + #clear variables + $preT = $TransferBuffer; + $TransferBuffer = ''; + $preS = $SetupPacket; + $SetupPacket = ''; + $preD = $Direction; + $t = 0; + $s = 0; + # get direction + @tmpsplit = split(/\s+/, $_); + $Direction = $tmpsplit[2]; +# print $_ . "\n"; + } elsif(/TransferBufferMDL/) { + $t = 1 + } elsif(/SetupPacket/) { + $s = 1; + } + } + #print last packet +# print "$SetupPacket $Direction $TransferBuffer\n"; + if($SetupPacket) { + if($preT) { + print "$SetupPacket $preD $preT\n"; + } else { + print "$SetupPacket $Direction $TransferBuffer\n"; + } + } +} + -- cgit v1.2.3