[Xastir] Fetch GPS Track question (Garmin Astro)

Wes Johnston, AI4PX wes at ai4px.com
Tue Oct 12 10:36:26 EDT 2010


Several years ago, Curt wrote a menu item for xastir that would publish the
waypoints within a rino GPS unit and it worked great.  Later, I wrote an
external script that would only publish waypoints that moved.  It also did
icon mapping.

I'm going to assume that you could hook up the astro GPS unit to the PC
running xastir and if you can d/l the waypoints via GPSMAN, ths script
should work.

Wes
---
God help those who do not help themselves.

#!/usr/local/bin/perl
################################################################################
# RINO GPS polling script by Wes Johnston AI4PX.  April 07
2006                #
# This script uses GPSMan to poll a garmin rino gps unit and detects
changes   #
# in the location or symbol used from one iteration to the next.  If a
waypoint#
# moves, it will be published to xastir via the xastir_udp_client
program.     #
# The waypoints from the RINO unit are pulled every 10
seconds.                #
# Press <cntrl c> to stop
execution                                            #
################################################################################
#use strict;
#use warnings;
#use LWP::Simple;
##############################################
# Edit callsign, RF path and passcode        #
##############################################
$mysourcecall="n0clu";
$mypasscode="18614";
$mysourcepath="WIDE1-1,WIDE2-1";
##############################################
# Nothing below this line needs to be edited.#
##############################################
my $gps_file_source="gps.txt";
my $gps_old_file_source="gpsold.txt";
use POSIX qw(strftime);
# We call GPSman upon startup to establish a baseline of waypoints
# so that we don't generate bunches of aprs objects the first iteration
print "Initializing Waypoints...\n";
#Call gpsman to get waypoints with symbols and pipe the output to a dummy
file to keep screen clean.
my $cmd="gpsman getwrite WP GPSMan ".$gps_old_file_source." >gpsman.txt" ;
system $cmd;

while (1==1){
 print qq|\nPolling RINO unit...\n|;

#Call gpsman to get waypoints with symbols and pipe the output to a dummy
file to keep screen clean.
 $cmd="gpsman getwrite WP GPSMan ".$gps_file_source." >gpsman.txt" ;
 system $cmd;
 print qq|Reading RINO waypoints...\n|;
 open (DB, "<$gps_file_source") or &cgierr("unable to open GPSMan file:
$gps_file_source.\nReason: $!");
  LINE: while (<DB>) {
   (/^#/)      and next LINE;  # Skip comment Lines.
   (/^!/)      and next LINE;  # Skip comment Lines.
   (/^%/)      and next LINE;  # Skip comment Lines.
   (/^\s*$/)   and next LINE;  # Skip blank lines.
    my $line = $_; chomp ($line);  # Remove trailing new line.

# need to open the file used on the last time 'round and look for an
identical line.
# if such an identical line is found, then NEXT and skip processing...
nothing new to do.
   my $dupedataflag=0;
   open (OLD, "<$gps_old_file_source") or &cgierr("unable to open GPSMan
file: $gps_old_file_source.\nReason: $!");
    OLDGPS: while (<OLD>) {
     (/^#/)      and next OLDGPS;  # Skip comment Lines.
     (/^!/)      and next OLDGPS;  # Skip comment Lines.
     (/^%/)      and next OLDGPS;  # Skip comment Lines.
     (/^\s*$/)   and next OLDGPS;  # Skip blank lines.
      my $oldgps = $_; chomp ($oldgps);  # Remove trailing new line.

      if ($oldgps eq $line){
       $dupedataflag=1;
     }
    }
   close OLD;
# split line into callsign, lat lon and symbol.
   my ($callsign,$null1,$lat,$lon,$symbol,$null2)= split (/\t/, $line);
# If callsign starts with APRS, truncate the APRS portion.
# The orginial concept of this script was to only transmit objects who's
first four
# characters were APRS, but that is no longer necessary with a more
intelligent method
# of only transmitting waypoints that move.
     if (substr($callsign,0,4) eq "APRS"){
      $callsign=substr($callsign,4,100);
     }
# check to see if we did NOT find a duplicate line of text in the gpsman
file.
   if ($dupedataflag eq "0"){
# Here we check that the particular waypoint has the correct form of a rino
contact symbol.
    $sym="";
    if (substr($symbol,0,7) eq "symbol="){
     $sym="1";
# First we set the default symbol.... just in case
     $aprssymbol="[";
     $aprssymbol="[" if ($symbol eq "symbol=cntct_smiley");
     $aprssymbol="b" if ($symbol eq "symbol=cntct_ball_cap");
     $aprssymbol="j" if ($symbol eq "symbol=cntct_big_ears");
     $aprssymbol="f" if ($symbol eq "symbol=cntct_spike");
     $aprssymbol="s" if ($symbol eq "symbol=cntct_goatee");
     $aprssymbol="U" if ($symbol eq "symbol=cntct_afro");
     $aprssymbol="Y" if ($symbol eq "symbol=cntct_dreads");
     $aprssymbol="R" if ($symbol eq "symbol=cntct_female1");
     $aprssymbol="v" if ($symbol eq "symbol=cntct_female2");
     $aprssymbol=">" if ($symbol eq "symbol=cntct_female3");
     $aprssymbol="," if ($symbol eq "symbol=cntct_ranger");
     $aprssymbol="u" if ($symbol eq "symbol=cntct_kung_fu");
     $aprssymbol="X" if ($symbol eq "symbol=cntct_sumo");
     $aprssymbol="<" if ($symbol eq "symbol=cntct_pirate");
     $aprssymbol="k" if ($symbol eq "symbol=cntct_biker");
     $aprssymbol="O" if ($symbol eq "symbol=cntct_alien");
     $aprssymbol="'" if ($symbol eq "symbol=cntct_bug");
     $aprssymbol="a" if ($symbol eq "symbol=cntct_cat");
     $aprssymbol="e" if ($symbol eq "symbol=cntct_dog");
     $aprssymbol="P" if ($symbol eq "symbol=cntct_pig");

# If callsign length greater than 9, we have to truncate it to be within
aprs spec for item reports.
     if (length($callsign) > 9){
      $callsign=substr($callsign,0,9);
     }
# split degrees mins and secs into individual variables.
      my ($deg,$min,$sec)= split (/ /, $lat);
      $hemi=substr($deg,0,1);
      $deg=substr($deg,1,10);
# make certain the length of degrees is 2 by way of adding leading 0's.
# this is crude and can be done more easily.
      if (length($deg)!=2){
       $deg="0".$deg;
      }
      if (length($deg)!=2){
       $deg="0".$deg;
      }
      $sec=substr($sec/60,1,3);
      if ($sec eq ""){
       $sec=".00";
      }
      if (length($sec) ne "3") {
       $sec=$sec."0";
      }
      $min=$min.$sec;
# make certain the length of minutes is 2 by way of adding leading 0's.

      if (substr($min,2,1) ne "."){
       $min="0".$min;
      }
      $aprslat=$deg.$min.$hemi;
# split degrees mins and secs into individual variables.
      my ($deg,$min,$sec)= split (/ /, $lon);
      $hemi=substr($deg,0,1);
      $deg=substr($deg,1,10);
# make certain the length of degrees is 3 by way of adding leading 0's.
      if (length($deg)!=3){
       $deg="0".$deg;
      }
      if (length($deg)!=3){
       $deg="0".$deg;
      }
      $sec=substr($sec/60,1,3);
      if ($sec eq ""){
       $sec=".00";
      }
      if (length($sec) ne "3") {
       $sec=$sec."0";
      }
      $min=$min.$sec;
# make certain the length of minutes is 2 by way of adding leading 0's.

      if (substr($min,2,1) ne "."){
       $min="0".$min;
      }
      $aprslon=$deg.$min.$hemi;
# here is the format we're looking to create: "KD4RDB>WIDE1-1,WIDE2-2:)" +
Name$ + "!" + Lat$ + "/" + Lon$ + Symbol$
       $packet=$mysourcecall.">".$mysourcepath .":)". $callsign . "!" .
$aprslat . "/" . $aprslon . $aprssymbol;

# shell out and make call to xastir udp client.
# This is a sample of the line to be sent: xastir_udp_client localhost 2023
ab7cd 1234 "APRS packet goes here"
     $cmd="xastir_udp_client localhost 2023 ".$mysourcecall."
".$mypasscode." -to_rf -to_inet \"".$packet."\" >udp.txt";
     system $cmd;
    }

   }
   if (substr($symbol,0,7) eq "symbol=") {
    if ($dupedataflag eq "0" ){
     print qq|MOVED:|;
    }else{
     print qq|      |;
    }
    $callsign=$callsign."          ";
    $callsign=substr($callsign,0,10);
     print qq|$callsign $lat $lon $symbol\n|;
    }
   }
 close DB;
# copy current gps.txt file over the old one.. so we can use it for dupe
checks the next time thru.
 $cmd="cp gps.txt gpsold.txt";
  system $cmd;
# sleep 10 seconds before downloading the waypoints again.
 sleep 10
}
sub cgierr {
# --------------------------------------------------------
# Displays any errors and prints out ENVIRONMENT
# information. Useful for debugging.
    print "We encountered an internal error. ";
        print "\n\nCGI ERROR\n==========================================\n";
        $_[0]      and print "Error Message       : $_[0]\n";
        $0         and print "Script Location     : $0\n";
        $]         and print "Perl Version        : $]\n";
        print "\n";
    exit -1;
}





On Tue, Oct 12, 2010 at 10:25, Kevin Ratcliff <kevin at kevinratcliff.com>wrote:

> Greetings,
>
> I have some questions about how the "Fetch GPS Track" feature works.
> Another SAR team in the area has started using Garmin Astro units. My
> team uses APRS. The Astro is designed as a dog collar with a
> transmitter and a receiver that looks similar to a 60CSx. I know that
> APRS and the Garmin Astro use incompatible over-the-air formats, but
> I'm hoping that I can download track data from an Astro receiver to
> Xastir.
>
> Xastir has a "Fetch GPS Track" option, but I've never used it. I do
> not have any Astro units to test with right now. I do know that the
> Astro receivers store the received positions for the transmitters as
> track points, with a separate track log and name for each transmitter.
> Unlike the Garmin Rino units, the Astro is VHF and can be attached to
> an external antenna for increased range.
>
> The ideal behavior as I see it would be for Xastir to be able to
> download these tracks from the GPS receiver and display them on the
> map, with each track a different color, and labeled with each
> transmitter's name. Google Earth does something similar to this when
> downloading from Astro units. Even better would be the ability to
> schedule a periodic download.
>
> Since the Astros use the Garmin USB protocol I'm hoping the above is
> possible. Has anyone already tried interfacing an Astro unit to Xastir
> with the current code to see what happens?
>
> There was a recent post on the SAR_APRS list about the Astros and
> APRS, but it wasn't specific to Xastir so I thought I would ask my
> questions here and forward the response to that list if there is a
> workable solution.
>
> Thanks!
>
> Kevin
> KB9MQU
> _______________________________________________
> Xastir mailing list
> Xastir at lists.xastir.org
> http://lists.xastir.org/cgi-bin/mailman/listinfo/xastir
>



More information about the Xastir mailing list