From: realraum Date: Tue, 13 Dec 2011 00:02:14 +0000 (+0000) Subject: added basic decoder X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=df71a4e96592d60eaaf409591b590326db3ee9f4;p=svn42.git added basic decoder --- diff --git a/rf433rcv/pc/decode.pl b/rf433rcv/pc/decode.pl new file mode 100755 index 0000000..c5822e5 --- /dev/null +++ b/rf433rcv/pc/decode.pl @@ -0,0 +1,56 @@ +#!/usr/bin/perl +use strict; +my @data = split /,/,<>; + +my @statistics; + +my $start = $data[0]; +my $current = $start; +my @lengths; +my $count=0; +for my $input (@data) +{ + $count++; + if ($input != $current) + { + push @lengths,[$current,$count]; + $statistics[$current]{$count}++; + $count=0; + $current=$input; + } +} + +for my $i (0..1) +{ + print "$i:\n"; + my $stat = $statistics[$i]; + for my $key (sort {$a <=> $b} keys %$stat) + { + print "$key $stat->{$key}\n"; + } +} +my $seq; +if (my $delemiter = $ARGV[0]) +{ + print "Starting decoding: $delemiter\n"; + my ($state,$time)=split /,/,$delemiter; + my $start = 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; + } else { + $start =1; + } + } + } + chop $seq; + print STDERR "$seq\n"; +}