Monday, 30 March 2015

Keep on Running

Smart watches may be flavour of the month but I've been using one, in the form of the Garmin Forerunner 305, for over 7 years now.

The software that came with the watch allows you to track your runs and build up a history of activity. This can be very addictive (but also a great motivator!).
I soon discovered the excellent SportTracks application from Zone Five Software where you can play around with even more statistics and also get nice view of your runs on a map. This is one of the few windows applications where it is actually worth paying for the full features.

Unfortunately though, about 18 months ago, a combination of SportTracks and Windows updates managed to frazzle the driver to such an extent I was unable to import any data from the watch. Many hours were spent trying to reinstall and update the driver to no avail and I was seriously considering whether I would end up manually inputting data to the app (or at least the summary).

It then occurred to me that I could perhaps use my Linux laptop to obtain the data.

A quick Google showed that yes, this indeed had been done and the steps I followed are listed below:
Details were originally taken from braiden.org, This is now unavailable but the sources are listed on Gitbub. https://github.com/cstrelioff/garmin-dev

1. Install Garmin Forerunner tools
 sudo apt-get install garmin-forerunner-tools

2. Install Java 1.6 VM. I used OpenJDK.
 sudo apt-get install opendk-6-jre

3. Create a folder for your scripts and uploaded files, I used Garmin

4. Download the files from the Github location

5. Change access permissions to allow us to use scripts in this folder
 chmod u+x gmn2tcx and saxon-xslt

6. Upload the data from the watch
 garmin_save_runs

This will save the raw .gmn files to dated folders under the Garmin Root. Take a look at one of them and you'll see this is really just an XML format and the script is simply going to run a transformation into the .tcx format that's used by SportTracks.

7. Run the transform
./gmn2tcx 2015/02/20150227T125809.gmn > 20150227.tcx

Linux note #1: Prefix the script name with the ./ otherwise the script won't get found as an executable
Linux note #2: The Pipe command > redirects the output to the file called 20150227.tcx

I get output looking something like this:

jonathan@easynote1:~/Garmin$ garmin_save_runs
Extracting data from Garmin Forerunner305 Software Version 2.80.
Files will be saved in '/home/jonathan/Garmin'
Wrote:   /home/jonathan/Garmin/2015/02/20150227T125809.gmn
Wrote:   /home/jonathan/Garmin/2015/03/20150303T064648.gmn
Wrote:   /home/jonathan/Garmin/2015/03/20150312T130929.gmn

jonathan@easynote1:~/Garmin$ ./gmn2tcx 2015/02/20150227T125809.gmn > 20150227.tcx
WARN: "xmllint" not found. Will not validate XML schema.
jonathan@easynote1:~/Garmin$ 

The xmllint warning can be ignored, I'm not worried so much about validation.

8. Finally, upload the files in SportTracks.
I set up Samba on my Window and Linux laptops to be able to transfer the data. This is unfortunately a bit flaky so I mainly transfer using the USB drive. If I get round to resolving the Samba problems it'll certainly appear in a future blog!

No comments: