-
-
Save ledvinap/d603d929e9444340f3b9033e30cd547a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use warnings; | |
use strict; | |
use List::Util qw(reduce); | |
sub pkt2 { | |
my ($id, $w, $r) = @_; | |
my $bw = pack("H*" x 41, $w); | |
my @v = unpack("n" x 20 . "C", $bw); | |
my @b = unpack("C" x 41, $bw); | |
# printf("%d\n", ((reduce { $a + $b} @b[4..39]) - $b[40])%256); | |
printf "%s\n", join(',', (map {sprintf("%5d", $_)} @v[0..1]), (map {sprintf("%5d", $_ - 2000)} @v[2..19]), sprintf("%d", $v[20]) ); | |
} | |
my $lid = 0; | |
my ($rpkt, $wpkt); | |
sub pkt { | |
my ($id, $tx, $rx) = @_; | |
return if $id eq ""; | |
if($id != $lid) { | |
pkt2($lid, $wpkt, $rpkt); | |
($rpkt, $wpkt, $lid)=("", "", $id); | |
} | |
$wpkt.=$tx; | |
$rpkt.=$rx; | |
} | |
$/ = "\r\n"; | |
<>; | |
while(<>) { | |
chomp; | |
s/0x//g; | |
my ($tme,$id,$tx,$rx) = split /,/; | |
pkt($id,$tx,$rx); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment