View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
João Pedro Gonçalves > perl-GPS-0.12 > GPS::Garmin



Annotate this POD

View/Report Bugs
Module Version: 0.12   Source   Latest Release: perl-GPS-0.17


GPS::Garmin - Perl interface to GPS equipment using the Garmin Protocol


  use GPS::Garmin;
  $gps = new GPS::Garmin(  'Port'      => '/dev/ttyS0', 
                                                   'Baud'      => 9600,

To transfer current position, and direction symbols:

  ($latsign,$lat,$lonsign,$lon) = $gps->get_position;

To transfer current time:

  ($sec,$min,$hour,$mday,$mon,$year) = $gps->get_time;

To transfer trackpoints:

$gps->prepare_transfer("trk"); while($gps->records) { ($lat,$lon,$time) = $gps->grab; }

To transfer Waypoints:

$gps->prepare_transfer("wpt"); while($gps->records) { ($title,$lat,$lon,$desc) = $gps->grab; }


GPS::Garmin allow the connection and use of of a GPS receiver in perl scripts. Currently only the GRMN/GRMN protocol is implemented but NMEA is a work in progress.

This module currently works with Garmin GPS II+ equipments, but should work on most Garmin receivers that support the GRMN/GRMN protocol.


Make sure your GPS receiver is in host mode, GRMN/GRMN protocol. To start a connection in your script, just:

        use GPS::Garmin;
        $gps = new GPS::Garmin (  'Port'      => '/dev/ttyS0',
                                  'Baud'      => 9600,
                               ) or die "Unable to connect to receiver: $!";

Where Port is the port that your GPS is connected to, and Baud the speed of connection ( default is 9600 bps).

To know current coordinates:

     ($latsign,$lat,$lnsign,$lon) = $gps->get_position;

     $ltsign is "S" or "N" (South or North)
     $lat is current latitude in degrees.minutes.
     $lnsign is "W" or "E" (West or East)
     $lon is current longitude in degrees.minutes.

To transfer the track records:


while($gps->records) { ($lat,$lon,$time) = $gps->grab; }

$time is in unix epoch seconds


- Trackpoint transfer won't work in the following Garmin devices, since they don't support it:

GPS 50 GPS 55 GPS 150 GPS 150 XL GPS 165 GNC 250 GNC 250XL GNC 300 GNC 300XL

You can check you GPS capabilities by looking at the table in page 50 of the Garmin protocol specification at

- You need to have Win32::SerialPort to have GPS::Garmin working in Windows.


Lacks documentation


Joao Pedro B Gonçalves ,


Peter Bennett's GPS www and ftp directory:'

Official Garmin Communication Protocol Reference
syntax highlighting: