Garmin Connect & Linux
I recently picked up a Garmin forerunner 305 to replace the broken Garmin Edge on my bike. While researching my options for a GPS and linux, I found Garmin Connect. Its Garmin’s online training software. For windows and mac there’s a plugin which links the website and GPS device, but for linux no direct support. This article covers what I did to get it working.
Garmintools (garmin-forerunner-tools package on Ubuntu) is where I started. It provides a tool for communicating with the GPS receiver over USB. It works with the older receivers (Forunner 305/Edge 305). It doesn’t sound like it works with the 405. (Too bad I really wanted the newer model.)
Garmintools has the ability to dump to an XML format. Garmin publishes the schema (TCXv2) required for manual uploads to Garmin Connect. To integrate the two I created a pretty simple XSLT stylesheet. I’m actually quite surprised couldn’t find an existing solution.
If your interested you can grab a copy from svn (or just browse);
svn co http://linuxnerd.net/svn/trunk/projects/garmin-dev
In order for the script to work you’ll need an XSLT2 processor (XSLT1 won’t work). The script assumes you’ll be using saxon-xslt, which is provided by the ubuntu package ‘libsaxonb-java’. Once saxon’s installed the process is pretty simple;
[Updated] In order for the script to work you’ll need install Java 1.6 VM (either Sun’s or OpenJDK). Included in SVN export is a copy of Saxon 9 (which requires java). Make sure your not using GCC/GIJ’s JRE, it won’t work. Once the JRE’s installed, execution is pretty simple;
- Save the runs on the device; garmin_save_runs
- Convert the .gmn files to .tcx; ./gmn2tcx 2005/05/20090529T091703.gmn > run.tcx
(hint: you can list as many gmn files as you’d like and save to one .tcx)
- Login to connect.garmin.com and upload the file.
The next step is to automate these steps. I think it should be pretty easy to automatically run these tasks whenever the device is attached.
I’ve added a couple extra scripts to the project;
- saveruns, basically a wrapper arround garmin_save_runs from garmin tools, but it creates a pending folder with symlinks to all .gmn files which are pending upload to Garmin Connect.
- uploadruns, which uploads the pending queue to garmin connect.
Now synchronizing can be done in a single command line;
./saveruns && USER=braiden PASSWORD=abc123 ./uploadruns
Update 2: (Apr 03, 2010)
It looks like garmin changed the login screen to force https. I’ve had to tweak the scripts. If you’re start to see “403 Forbidden” when uploading data, make sure to get the latest from SVN. I’ve update both branches to use https when logging in.