93 |
andreas |
1 |
===========================================================================
|
|
|
2 |
GARMINTOOLS
|
|
|
3 |
===========================================================================
|
|
|
4 |
|
|
|
5 |
This software provides Linux users with the ability to communicate with the
|
|
|
6 |
Garmin Forerunner 305 via the USB interface. While this is the only Garmin
|
|
|
7 |
unit that I own, I did implement all of the documented Garmin protocols
|
|
|
8 |
(http://www.garmin.com/support/pdf/IOSDK.zip) as of Rev C (May 19, 2006)
|
|
|
9 |
over the USB physical link. This means that if you have a Garmin with a
|
|
|
10 |
USB connection to a PC, you ought to be able to use this software to
|
|
|
11 |
communicate with it.
|
|
|
12 |
|
|
|
13 |
==> You will need to make sure that the 'garmin_gps' kernel module is not
|
|
|
14 |
loaded or compiled into your kernel. This module conflicts with the
|
|
|
15 |
garmintools software.
|
|
|
16 |
|
|
|
17 |
If you're looking for a complete solution to all of your Linux Garmin GPS
|
|
|
18 |
needs, this is not it. I own a Garmin Forerunner 305 and wrote this code
|
|
|
19 |
specifically so I could download and save data from that particular GPS
|
|
|
20 |
unit to my Linux machine. I tried gpsbabel (http://www.gpsbabel.org), but
|
|
|
21 |
found that it did not have command line options specific to the Forerunner
|
|
|
22 |
run and lap data - all I could do was get the tracklog. That's how all of
|
|
|
23 |
this got started. I also wanted a few other things, like the ability to
|
|
|
24 |
convert a track log into a Google maps encoded polyline, and (eventually)
|
|
|
25 |
the ability to generate PNG images of heart rate and elevation data.
|
|
|
26 |
|
|
|
27 |
You need to have the libusb library (http://libusb.sf.net) installed. You
|
|
|
28 |
must also have read and write permissions to the device file through which
|
|
|
29 |
the Garmin unit is accessed. The easiest thing to do is run the programs
|
|
|
30 |
as root. Alternatively, you can write a hotplug script. I haven't tried
|
|
|
31 |
this yet.
|
|
|
32 |
|
|
|
33 |
As of version 0.01, this software gives you the ability to do the following:
|
|
|
34 |
|
|
|
35 |
1) Get basic information from the Garmin unit, such as its software version
|
|
|
36 |
and supported protocols. To do this, use 'garmin_get_info'.
|
|
|
37 |
|
|
|
38 |
2) Save runs and associated track logs from the Garmin unit to disk. To do
|
|
|
39 |
this, use 'garmin_save_runs'. Files are saved with the extension ".gmn"
|
|
|
40 |
and are named by the run start time (e.g. '20070121T151814.gmn'). The
|
|
|
41 |
.gmn file format is a binary file format that can be unpacked with the
|
|
|
42 |
same functions that unpack the raw data from the Garmin unit itself. It
|
|
|
43 |
is substantially more efficient than the bloated XML format that Garmin
|
|
|
44 |
uses.
|
|
|
45 |
|
|
|
46 |
IMPORTANT NOTE: The output of garmin_save_runs will tell you where on
|
|
|
47 |
your filesystem the actual .gmn files were saved. The default is to
|
|
|
48 |
save them in a directory tree (by year and month) under the current
|
|
|
49 |
directory. You can override this by setting the environment variable
|
|
|
50 |
GARMIN_SAVE_RUNS to whatever directory you like.
|
|
|
51 |
|
|
|
52 |
ANOTHER IMPORTANT NOTE: Old workouts are not deleted from the watch,
|
|
|
53 |
and their laps hang around for a long time. This once led me to
|
|
|
54 |
clobber half a dozen saved runs with truncated files containing
|
|
|
55 |
only the lap data (because the associated track logs had long since
|
|
|
56 |
been overwritten in the Forerunner's memory). Therefore, if a file
|
|
|
57 |
with the same name already exists, it is *not* overwritten.
|
|
|
58 |
|
|
|
59 |
FINAL NOTE: As a result of that rather unpleasant experience, I wrote
|
|
|
60 |
a Perl script 'fore2gmn.pl' (included in the 'extras' directory) that
|
|
|
61 |
can convert a .hst file (the XML format exported from Garmin Training
|
|
|
62 |
Center) to a set of .gmn files. These .gmn files are saved in the
|
|
|
63 |
current working directory without any of the year/month hierarchy
|
|
|
64 |
business. Using this script, I was able to restore the six files
|
|
|
65 |
that I had lost.
|
|
|
66 |
|
|
|
67 |
3) Dump the contents of a .gmn file. To do this, use 'garmin_dump'. The
|
|
|
68 |
output of garmin_dump is XML-like, and is mainly meant to be used for
|
|
|
69 |
debugging.
|
|
|
70 |
|
|
|
71 |
4) Print, in an XML-like format, the encoded polyline representation of a
|
|
|
72 |
.gmn file (for Google maps) along with other information such as the
|
|
|
73 |
start and center latitude/longitude, and the lat/lon bounding box.
|
|
|
74 |
To do this, use 'garmin_gmap' on a .gmn file.
|
|
|
75 |
|
|
|
76 |
In addition, the garmintools API in src/garmin.h gives you the ability to
|
|
|
77 |
read a .gmn file and do pretty much anything you want to it.
|
|
|
78 |
|
|
|
79 |
I chose to write this software in C. C++ programmers (and I am one of
|
|
|
80 |
them) might have a look at the code and ask, "Why not do this in C++ and
|
|
|
81 |
spare yourself all of the switch statements?" I don't have a good answer,
|
|
|
82 |
just a bunch of half-answers, and I may end up changing my mind. The
|
|
|
83 |
bottom line is that even after years of C++ programming, I still like to
|
|
|
84 |
stick with C when I can. If you've ever had to deal with aCC on HP-UX,
|
|
|
85 |
you understand.
|
|
|
86 |
|
|
|
87 |
CAVEAT: I have only tested this software with the Forerunner 305 that I
|
|
|
88 |
own. I don't know if it works with the Edge 205/305 or the Forerunner 205.
|
|
|
89 |
In principle, it should at least save the files successfully.
|
|
|
90 |
|
|
|
91 |
ONE MORE CAVEAT: The 'garmin_gmap' utility expects a .gmn file with a
|
|
|
92 |
D304 track point data type. This is the data type used by the Forerunner
|
|
|
93 |
305. I WILL FIX THIS SOON. Also, the output of garmin_gmap is not for
|
|
|
94 |
the faint of heart. You will need to have your own website where you
|
|
|
95 |
can put this encoded polyline in an HTML file, following the instructions
|
|
|
96 |
on the Google maps API reference pages:
|
|
|
97 |
|
|
|
98 |
http://www.google.com/apis/maps/documentation/
|
|
|
99 |
|
|
|
100 |
I may make this easier some day. For now, this is how it is.
|
|
|
101 |
|
|
|
102 |
Dave Bailey
|
|
|
103 |
Truckee, CA
|
|
|
104 |
22 February 2007
|
|
|
105 |
|