ロジアナのカードバス観測ファイルをアクセスログに変換するツールを追加

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlToolsRED@577 7061adef-622a-194b-ae81-725974e89856
This commit is contained in:
n1481 2011-12-02 08:19:29 +00:00
parent 7c6879cf78
commit 92ce284969
2 changed files with 70 additions and 0 deletions

View File

@ -0,0 +1,3 @@
C:\cygwin\bin\perl.exe "%~dp0read_command_text.pl" "%~1" > "%~dpn1_out.txt"
pause

View File

@ -0,0 +1,67 @@
#!/usr/bin/perl --
use strict;
my $file = $ARGV[0] or die "Usage: $0 [TXT File]\n\n";
open IN, $file or die "Cannot open $file.\n";
my $start = 0;
my $size = 0;
my $step = 0;
my $addr = 0;
my $bkup = 0;
while (<IN>) {
my @data = split /\t/;
# pre-read
if ( $step == 0 ) {
$step = 1 if ( $data[2] == 1 && $data[3] == 1 );
# backup access
if ( $data[2] == 1 && $data[3] == 0 )
{
$bkup = 1;
}
}
# read
elsif ( $step == 1 ) {
if ( $data[4] =~ /B7/ ) {
$step++;
$addr = 0; # initialize
} else {
$step = 0; # restart
}
}
# first address
elsif ( $step == 2 || $step == 3 || $step == 4 || $step == 5 ) {
$addr = $addr*256 + hex($data[4]);
if ( $step == 5 ) {
if ( $start + $size == $addr && $bkup == 0 ) {
$size += 512;
} else {
printf "Read: 0x%08x-0x%08x (%6d bytes)\n", $start, $start+$size-1, $size if ($start);
$start = $addr;
$size = 512;
if ( $bkup == 1 ) {
print "<<BACKUP ACCESS>>\n" ;
$bkup = 0;
}
}
$step = 0; # restart
} else {
$step++;
}
}
}
close IN;
if ($start) {
printf "Read: 0x%08x-0x%08x (%6d bytes)\n", $start, $start+$size-1, $size
} else {
printf "Never read.\n";
}
if ( $bkup == 1 ) {
print "<<BACKUP ACCESS>>\n" ;
}