direwolf/telemetry-toolkit/telem-data91.pl

65 lines
1.3 KiB
Perl
Raw Permalink Normal View History

Development snapshot 1.3 dev F. Changes to be committed: modified: .gitattributes modified: CHANGES.md modified: Makefile modified: Makefile.linux new file: Makefile.macosx modified: Makefile.win modified: aclients.c modified: aprs_tt.c modified: aprs_tt.h modified: atest.c modified: audio.c modified: audio.h new file: audio_portaudio.c new file: audio_stats.c new file: audio_stats.h modified: audio_win.c modified: ax25_pad.c modified: ax25_pad.h modified: beacon.c modified: config.c modified: config.h modified: decode_aprs.c modified: decode_aprs.h modified: demod.c modified: digipeater.c modified: direwolf.c modified: direwolf.h modified: dlq.c modified: doc/README.md modified: doc/Raspberry-Pi-APRS.pdf modified: doc/User-Guide.pdf new file: doc/WA8LMF-TNC-Test-CD-Results.pdf modified: dtime_now.c modified: dtmf.c modified: dw-start.sh modified: encode_aprs.c modified: encode_aprs.h modified: gen_packets.c modified: gen_tone.c modified: gen_tone.h new file: generic.conf modified: grm_sym.h modified: hdlc_rec.c modified: hdlc_rec.h modified: igate.c modified: kiss.c modified: kiss_frame.c modified: kissnet.c modified: latlong.c modified: man1/direwolf.1 modified: mgn_icon.h modified: misc/README-dire-wolf.txt new file: misc/strlcat.c new file: misc/strlcpy.c modified: morse.c new file: morse.h modified: nmea.c modified: pfilter.c modified: ptt.c new file: serial_port.c new file: serial_port.h modified: server.c modified: symbols.c modified: symbols.h new file: telemetry-toolkit/telem-balloon.conf new file: telemetry-toolkit/telem-balloon.pl new file: telemetry-toolkit/telem-bits.pl new file: telemetry-toolkit/telem-data.pl new file: telemetry-toolkit/telem-data91.pl new file: telemetry-toolkit/telem-eqns.pl new file: telemetry-toolkit/telem-m0xer-3.txt new file: telemetry-toolkit/telem-parm.pl new file: telemetry-toolkit/telem-unit.pl new file: telemetry-toolkit/telem-volts.conf new file: telemetry-toolkit/telem-volts.py modified: telemetry.c modified: textcolor.c modified: tq.c modified: tt_text.c modified: tt_text.h modified: tt_user.c modified: tt_user.h modified: utm2ll.c modified: version.h new file: walk96.c modified: xmit.c
2015-09-07 23:56:20 +00:00
#!/usr/bin/perl
# Part of Dire Wolf APRS Telemetry Toolkit, WB2OSZ, 2015
# For explanation of encoding see:
# http://he.fi/doc/aprs-base91-comment-telemetry.txt
if ($#ARGV+1 < 2 || $#ARGV+1 > 7) {
print STDERR "2 to 7 command line arguments must be provided.\n";
usage();
}
if ($#ARGV+1 == 7) {
if ( ! ($ARGV[6] =~ m/^[01]{8}$/)) {
print STDERR "The sixth value must be 8 binary digits.\n";
usage();
}
# Convert binary digits to value.
$ARGV[6] = oct("0b" . reverse($ARGV[6]));
}
$result = "|";
for ($n = 0 ; $n <= $#ARGV; $n++) {
#print $n . " = " . $ARGV[$n] . "\n";
$v = $ARGV[$n];
if ($v != int($v) || $v < 0 || $v > 8280) {
print STDERR "$v is not an integer in range of 0 to 8280.\n";
usage();
}
$result .= base91($v);
}
$result .= "|";
print "$result\n";
exit 0;
sub base91 ()
{
my $x = @_[0];
my $d1 = int ($x / 91);
my $d2 = $x % 91;
return chr($d1+33) . chr($d2+33);
}
sub usage ()
{
print STDERR "\n";
print STDERR "telem-data91.pl - Format data into compressed base 91 telemetry.\n";
print STDERR "\n";
print STDERR "Usage: telem-data91.pl sequence value1 [ value2 ... ]\n";
print STDERR "\n";
print STDERR "A sequence number and up to 5 analog values can be specified.\n";
print STDERR "Any sixth value must be 8 binary digits.\n";
print STDERR "Values must be integers in range of 0 to 8280.\n";
exit 1;
}