Slaven Rezić > perl-GPS-0.17 > GPS::Garmin



Annotate this POD

View/Report Bugs
Module Version: 1.34   Source  


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:

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

To transfer Waypoints:

    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,
                              'Return'    => 'hash',
                           ) 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).

If Return is set to 'hash', then waypoints and tracks are returned as hashes, possibly containing more information. XXX This is not implemented completely for all data and device types. An undefined 'Return' value would cause to return lists with basic information (latitude and longitude) instead.

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

With 'Return' => 'hash' this would be

    while($gps->records) {
        %trk_data = $gps->grab;



- 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: