Garmin simple text convertor script


I needed to test some XBee long-range radios. Hmm, how can we make this test useful and fun at the same time? Well, let’s put one end of the radio in the lab connected to a computer, and wander around with the other radio while transmitting the current position obtained from a GPS.

Using the XBee evaluation kit, my (t)rusty eTrex GPS, a 12V battery and some cables, the hardware was quickly in place. Now, what to transmit over the link? Full NMEA? Hmm, maybe this is a bit overkill. Sending the position once a second ought to be enough. But then I need a microcontroller between the GPS and the radio to reformat the NMEA into simple position beacons. There has to be an easier way…

Going through the option menu of the eTrex, various output formats can be selected for the data output port. One of them is called ‘Text out’. Garmin has nicely documented this format (kudos!). When selecting this output mode, a simple ASCII string reporting position and speed is sent once a second. There we go!

Now, I also wanted to be able to plot the logged samples on a map to get a quick view on how far the link actually works fine. Enter GPS Visualizer. The only thing required to plot the logs on a map is a small format conversion.

Time to put together a small Perl script to re-write the output of the serial port of the XBee module into a format that is understood by GPS Visualizer.

The script is available in SVN (direct download).

Manpage is listed below.


NAME
 garmin_simpletext_parser - Perl script to convert a Garmin simple text
 logfile into a CSV file for GPS Visualiser

SYNOPSIS
 garmin_simpletext_parser [options] <inputfile>
 where valid options are
 --o <fname> - force output file name
 --help      - display this help
 --debug     - print debug messages
 # Convert the file using the default outputfile
 garmin_simpletext_parser log1.txt
DESCRIPTION
 This script is converts a logfile written in the Garmin simpletext
 format into a comma separated value file that can be used to plot a map
 on GPS Visualiser.

 By default the outputfile name is equal to the input filename, but the
 extension is changed to 'csv'.

 If the output file exists, the output of the script is appended to the
 existing files.

 Resources: Garmin simple text format:
 http://www8.garmin.com/support/text_out.html GPS Visualiser:
 http://www.gpsvisualizer.com/

BUGS/LIMITATIONS
 This script assumes the log was made in the year 2000 or later. It
 prepends '20' before the date generated by the GPS.

 If the outputfile exists, it is overwritten.

SEE ALSO
 Project website: http://electronics.lika.be/

AUTHOR
 Lieven Hollevoet

COPYRIGHT
 Copyright (C) 2010 by Lieven Hollevoet

 This library is free software; you can redistribute it and/or modify it
 under the same terms as Perl itself, either Perl version 5.8.8 or, at
 your option, any later version of Perl 5 you may have available.
,