#!/usr/bin/perl # hack to gather APRS reports from xastir's server port, calculate # balloon ascent rate and announce ballon burst and burst altitude by # mac "say" command # j winningham # kg4wsv use Time::localtime; use IO::Socket::INET; $socket = IO::Socket::INET->new("localhost:2023") or die "could not connect to server!"; $debug=1; $balloon="KJ4NKE-11"; $mycall="KG4WSV-15"; print STDOUT "user $mycall pass 00000 vers fubar 0.0.0a\n"; print $socket "user $mycall pass 00000 vers fubar 0.0.0a\n"; while (<$socket>) { if (/^$balloon/) { # print $_ if $debug; chop; ($header, @rest) = split ":"; $payload = join ":", @rest; if ($history{$payload}) # duplicate packet { # print "duplicate\n" if $debug; next; } $history{$payload} = $payload; if (/A=[0-9]*/) { $t = time(); $alt = $payload; $alt =~ s!.*/A=!!; # $alt =~ s![^0-9]*$!!; $alt =~ s!([0-9]*).*$!$1!; # print "altitude=$alt\n" if $debug; if ($alt) { # $alt = $alt / 0.3048; if (!$first_t) { $first_t = $t;} if (!$first_alt) { $first_alt = $alt;} if ($alt > $maxalt) { $maxt = $t; $maxalt = $alt; } if ($last_t && $last_alt && ($t - $last_t)) { print "ascent rate: ", int (($alt - $last_alt) / ($t - $last_t) * 60) , " ft/min, ", " / ", int ((($alt - $first_alt) / ($t - $first_t)) * 60) , " ft/min at ", ctime($t), "\n"; } if ( ($alt + 250) < $maxalt) { `say "balloon burst at $maxalt feet"` unless $saycount++ >5; } print "$alt at ", ctime($t), ", max $maxalt at ", ctime($maxt), "\n"; $last_alt = $alt; $last_t = $t; } } } }