X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=zc-queue-inspect;h=63fcd53f97be3d468f7464f15bea7ca617cd0d1d;hb=23b719f022c0094200a85b0c526ae49bc0780f12;hp=34dc1515fd99b41f565e14ab09cd5ad2499aa937;hpb=c7836240ae5f90e9cf47152fd18e3fcddec63810;p=zc diff --git a/zc-queue-inspect b/zc-queue-inspect index 34dc151..63fcd53 100755 --- a/zc-queue-inspect +++ b/zc-queue-inspect @@ -4,11 +4,12 @@ use strict; use Data::Dump qw(dump); use File::Slurp; +use POSIX qw(strftime); use lib '.'; use Protocol; -my $debug = $ENV{DEBUG}; +my $debug = $ENV{DEBUG} // 0; $| = 1; if ( $debug > 1 ) { @@ -19,14 +20,23 @@ if ( $debug > 1 ) { my $raw; foreach my $filename ( @ARGV ) { - my $up_down = $1 if $filename =~ m/(up|down|sent)/; + my ( $up_down, $t ); + if ( $filename =~ m/(\d+)\.(up|down|sent)/ ) { + $t = $1; + $up_down = $2; + } else { + warn "ERROR: can't parse $filename, skipping\n"; + next; + } my $raw = read_file $filename; - print "# $filename size:", -s $filename, " "; + print "# ",strftime("%Y-%m-%dT%H:%M:%S",localtime($t)), " $filename size:", -s $filename, " "; $up_down = 'down' if $up_down eq 'sent'; my $hash = protocol_decode( $up_down, $raw ); warn "hash = ",dump($hash) if $debug; + my $imei = $1 if $filename =~ m{queue/(\d+)}; + my $function_code = $hash->{function_code} || die "no function_code"; my $fc_desc = $function_code_description->{$up_down}->{$function_code} || die "no function_code_description for $up_down $function_code"; print " function_code=$function_code ", @@ -37,6 +47,7 @@ foreach my $filename ( @ARGV ) { foreach my $data_id ( @{ $hash->{data_id_order} } ) { print join(" | ", + $imei, $hash->{up_down}, unpack('H*', chr($data_id)), $protocol->{$data_id}->{description},