5 use Data::Dump qw(dump);
7 use POSIX qw(strftime);
12 my $debug = $ENV{DEBUG} // 0;
16 warn "## protocol = ",dump( $protocol );
17 warn "## function_code_description = ",dump( $function_code_description );
22 foreach my $filename ( @ARGV ) {
24 if ( $filename =~ m/(\d+)\.(up|down|sent)/ ) {
28 warn "ERROR: can't parse $filename, skipping\n";
31 my $raw = read_file $filename;
32 print "# ",strftime("%Y-%m-%dT%H:%M:%S",localtime($t)), " $filename size:", -s $filename, " ";
33 $up_down = 'down' if $up_down eq 'sent';
34 my $hash = protocol_decode( $up_down, $raw );
36 warn "hash = ",dump($hash) if $debug;
38 my $imei = $1 if $filename =~ m{queue/(\d+)};
40 my $function_code = $hash->{function_code} || die "no function_code";
41 my $fc_desc = $function_code_description->{$up_down}->{$function_code} || die "no function_code_description for $up_down $function_code";
42 print " function_code=$function_code ",
44 " ver=", $hash->{ver},
45 " len=", $hash->{len},
48 foreach my $data_id ( @{ $hash->{data_id_order} } ) {
52 unpack('H*', chr($data_id)),
53 $protocol->{$data_id}->{description},
54 $hash->{data_id}->{$data_id},
55 "hex:" . unpack('H*', $hash->{data_range}->{$data_id}),
56 "len:" . $hash->{data_len}->{$data_id},
57 "fmt:" . $protocol->{$data_id}->{pack_fmt},
58 "range:" . $protocol->{$data_id}->{range},
59 "remark:" . $protocol->{$data_id}->{remark}