decode parts of control data
[vrDialog] / dumps / portmon-parse.pl
1 #!/usr/bin/perl
2 use warnings;
3 use strict;
4
5 my $in_read = 0;
6 my $wait = 0;
7 my $read = '';
8
9 while(<>) {
10         s/[\n\r]+$//;
11
12         my $time = $1 if /(\d+:\d+:\d+)/;
13         $time .= ' | ';
14
15         if ( /IRP_MJ_WRITE.*:\s*(.*)/ ) {
16                 print ">> $time $1\n";
17         } elsif ( /(IRP_MJ_READ|IOCTL_SERIAL_WAIT_ON_MASK)/ ) {
18                 $in_read++;
19                 print "#[$in_read] $_\n";
20         } elsif (  $in_read && /SUCCESS\s+Length\s+\d+:\s*([0-9a-fA-F\s]+)/ ) {
21                 $read .= $1;
22                 print "#<$in_read $_\n";
23                 my $len = hex($1) if ( $read =~ m/^([0-9a-f]{2})/i );
24                 print "#< $read [$len]\n";
25                 if ( length($read) >= ( $len * 3 - 1 ) ) {
26                         print "<< $time $read\n";
27                         $in_read = 0;
28                         $read = '';
29                 }
30         } else {
31                 print "# $_\n";
32         }
33 }