Beyond Logic Serial Analyser Log Printing

This was a quick hack with some perl to chop up the logs and spit out the results I wanted.

This is not normally something I would share, but I want to be able to find it again, should I have a need for it. The first one replaces the non-printable characters and separates the transmit and receive lines to improve printed readability.
[perl]
open FILE, "$ARGV[0]" or die "Couldn’t open file: $!";
while (<FILE>){
$string .= $_;
}
close FILE;
$string =~ s/x1B/+/g;
$string =~ s/x04/=/g;

@array = ( $string =~ m/../g );

$tran = "";
$rec = "";

foreach $chunk (@array) {
#print $chunk . "n";
if ($chunk =~ /^T/){
$chunk =~ s/^T//;
$tran = $tran . $chunk;
$rec = $rec . " ";
}
elsif ($chunk =~ /^R/){
$chunk =~ s/^R//;
$rec = $rec . $chunk;
$tran = $tran . " ";
}
}

my ( $chunksize, $longtextlength ) = ( 80, length($tran) );
my @stringChunksArray = ();
my @stringChunksArray2 = ();

for( my $counter = 0; $counter< $longtextlength; $counter += $chunksize ) {
push @stringChunksArray, substr( $tran, $counter, $chunksize );
push @stringChunksArray2, substr( $rec, $counter, $chunksize );
}

for($i=0;$i<@stringChunksArray;$i++){
print STDOUT $stringChunksArray2[$i]."n";
print STDOUT $stringChunksArray[$i]."nnn";
}
[/perl]

The second one is specific to the rimage RAS 13 autoloader (DTP-4500) and splits on the ASCII ESC character.

[perl]
open FILE, "$ARGV[0]" or die "Couldn’t open file: $!";
while (<FILE>){
$string .= $_;
}
close FILE;
#$string =~ s/x1B/+/g;
$string =~ s/x04/=/g;

@array = ( $string =~ m/../g );

$tran = "";
$rec = "";

foreach $chunk (@array) {
#print $chunk . "n";
if ($chunk =~ /^T/){
$chunk =~ s/^T//;
$tran = $tran . $chunk;
# $rec = $rec . " ";
}
elsif ($chunk =~ /^R/){
$chunk =~ s/^R//;
$rec = $rec . $chunk;
# $tran = $tran . " ";
}
}

@reclist = split(/x1B/, $rec);
@tranlist = split(/x1B/, $tran);

for($i=0;$i<@reclist;$i++){
print "+" . $reclist[$i]."t";
print "+" . $tranlist[$i]."n";
}
[/perl]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: