X-Git-Url: https://git.realraum.at/?p=svn42.git;a=blobdiff_plain;f=rf433rcv%2Fpc%2Fdecode.pl;h=f9aeb3204fad992aa5595e74d52cd8f8fa377e13;hp=c5822e50f4ca827b9816ca4f77b8a71feb0b8eaa;hb=5b00dab1a7d2ac2d8a593f0bd6e85a7194e2c9bd;hpb=df71a4e96592d60eaaf409591b590326db3ee9f4 diff --git a/rf433rcv/pc/decode.pl b/rf433rcv/pc/decode.pl index c5822e5..f9aeb32 100755 --- a/rf433rcv/pc/decode.pl +++ b/rf433rcv/pc/decode.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl use strict; -my @data = split /,/,<>; +my @data = split //,<>; my @statistics; @@ -22,35 +22,45 @@ for my $input (@data) for my $i (0..1) { - print "$i:\n"; + print STDERR "$i:\n"; my $stat = $statistics[$i]; for my $key (sort {$a <=> $b} keys %$stat) { - print "$key $stat->{$key}\n"; + if ($stat->{$key+1}) + { + if ($stat->{$key+1}>$stat->{$key}) + { + $stat->{$key+1}+=$stat->{$key}; + delete $stat->{$key}; + } else { + $stat->{$key}+=$stat->{$key+1}; + delete $stat->{$key+1}; + } + } + print STDERR "$key $stat->{$key}\n"; } } my $seq; -if (my $delemiter = $ARGV[0]) +if (defined $ARGV[0]) { - print "Starting decoding: $delemiter\n"; - my ($state,$time)=split /,/,$delemiter; + my ($state)=$ARGV[0]; + my ($time) = reverse sort {$a <=> $b} keys %{$statistics[$state]} ; my $start = 0; + my $counter=0; for my $data (@lengths) { - if ($start) - { - print $data->[0] . " => " . $data->[1] ."\n"; - $seq.= ($data->[0].',') x $data->[1]; - } if ($data->[0]==$state && $data->[1]==$time) { if ($start) - { last; + { + print $counter-2,"\n"; + last; } else { $start =1; + print $counter-1," "; } } + $counter+=$data->[1]; } - chop $seq; - print STDERR "$seq\n"; } +