-
Notifications
You must be signed in to change notification settings - Fork 1
/
sirfbin_to_gp2.pl
executable file
·34 lines (27 loc) · 1.12 KB
/
sirfbin_to_gp2.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/perl -w
#
# by Matija Nalis <mnalis-android@voyager.hr> GPLv3+, started 2014-07-14
# parses raw SiRF binary commands (like SLCLog.bin) and creates SLCLog.gp2 text file.
# Note: depends od A0A2 / B0B3, so only SiRF OSP (and perhaps enc4t) can be converted.
# FIXME - sometimes it incorrectly splits into two packets when (B0 B3 found in payload). We could use packet size for raw binary SiRF OSP to fix that, but then this script could not process enc4t (it would need separate script). probably should be done, but can't bother right now, as it is easy to manually join a line or two in broken output
#
# Usage: ./sirfbin_to_gp2.pl < SLCLog.bin > SLCLog.gp2
#
use strict;
use autodie;
my $DEBUG = 0;
#$|=1;
my $count2=0; my $count1=0;
my $out = '';
my $last_x = '';
while (read (STDIN, my $c, 1)) {
my $x = uc unpack 'H*', $c;
$out .= "$x ";
$DEBUG && print "char=0x$x out=$out\n" ;
if ($x eq 'B3' and $last_x eq 'B0') { # packet ended, print it
if ($count1++ > 999) { $count2++; $count1=0; }
printf "00/00/0007 00:00:%02d.%03d (0) $out\n", $count2, $count1;
$out = '';
}
$last_x = $x;
}