5 use Data::Dump qw(dump);
7 use POSIX qw(strftime);
10 use lib "$FindBin::Bin/.";
13 my $debug = $ENV{DEBUG} // 0;
17 warn "## protocol = ",dump( $protocol );
18 warn "## function_code_description = ",dump( $function_code_description );
23 foreach my $filename ( @ARGV ) {
25 if ( $filename =~ m/(\d+)\.(up|down|sent)/ ) {
29 warn "ERROR: can't parse $filename, skipping\n";
32 my $raw = read_file $filename;
33 print "# ",strftime("%Y-%m-%dT%H:%M:%S",localtime($t)), " $filename size:", -s $filename, " ";
34 $up_down = 'down' if $up_down eq 'sent';
35 my $hash = protocol_decode( $up_down, $raw );
37 warn "hash = ",dump($hash) if $debug;
39 my $imei = $1 if $filename =~ m{queue/(\d+)};
41 my $function_code = $hash->{function_code} || die "no function_code";
42 my $fc_desc = $function_code_description->{$up_down}->{$function_code} || die "no function_code_description for $up_down $function_code";
43 print " function_code=$function_code ",
45 " ver=", $hash->{ver},
46 " len=", $hash->{len},
49 foreach my $data_id ( @{ $hash->{data_id_order} } ) {
53 unpack('H*', chr($data_id)),
54 $protocol->{$data_id}->{description},
55 $hash->{data_id}->{$data_id},
56 "hex:" . unpack('H*', $hash->{data_range}->{$data_id}),
57 "len:" . $hash->{data_len}->{$data_id},
58 "fmt:" . $protocol->{$data_id}->{pack_fmt},
59 "range:" . $protocol->{$data_id}->{range},
60 "remark:" . $protocol->{$data_id}->{remark}