#!/usr/bin/perl use warnings; use strict; use Data::Dump qw(dump); use File::Slurp; use lib '.'; use Protocol; my $debug = $ENV{DEBUG}; $| = 1; if ( $debug > 1 ) { warn "## protocol = ",dump( $protocol ); warn "## function_code_description = ",dump( $function_code_description ); } my $raw; foreach my $filename ( @ARGV ) { my $up_down = $1 if $filename =~ m/(up|down|sent)/; my $raw = read_file $filename; print "# $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 $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 ", $fc_desc, " ver=", $hash->{ver}, " len=", $hash->{len}, "\n"; foreach my $data_id ( @{ $hash->{data_id_order} } ) { print join(" | ", $hash->{up_down}, unpack('H*', chr($data_id)), $protocol->{$data_id}->{description}, $hash->{data_id}->{$data_id}, "hex:" . unpack('H*', $hash->{data_range}->{$data_id}), "len:" . $hash->{data_len}->{$data_id}, "fmt:" . $protocol->{$data_id}->{pack_fmt}, "range:" . $protocol->{$data_id}->{range}, "remark:" . $protocol->{$data_id}->{remark} ),"\n"; } print "\n"; }