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;

  1. Save the runs on the device; garmin_save_runs
  2. 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)
  3. 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.

Update 1:

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.

http://linuxnerd.net/svn/trunk/projects/garmin-dev (latest)
Update 3: (Oct 23, 2010)
As a few people have noted, looks like garmin made a small change to API. If you’re getting errors uploading, make sure to upgrade to the lastest version: http://linuxnerd.net/svn/trunk/projects/garmin-dev
Update 4: (Apr 13, 2011)
You may also want to try this plugin: http://www.andreas-diesner.de/garminplugin/doku.php/start
Update 5: (Feb 25, 2012)
I’ve lost my Garmin 305, and replaced with with a 405CX. You can find my device download and Garmin Connect upload tool on github: http://github.com/braiden/python-ant-downloader

Tags: , , ,

70 Responses to “Garmin Connect & Linux”

  1. Victor Says:

    you have a typo on line 52 of the upload script. it says $GARMIN_SABE_RUNS and not $GARMIN_SAVE_RUNS which causes a problem if you execute the script from somewhere other than the desired storage directory. love your script though!!!!!

  2. braiden Says:

    Fixed. Thanks for the catch. Glad to hear the scripts are useful.

  3. RobW Says:

    Very useful indeed. One thing– where can I get a copy of the saxonb-xslt command used by gmn2tcx? I usually just use ‘java -jar saxon.jar….’

  4. Michele Says:

    Hi,

    I’m writing a small application and I’m focusing on the interaction with the Garmin Connect site.
    I found the script to upload tcx file to garmin connect quite interesting, but I’m mostly interested in the opposite process: download the tcx from Garmin Connect (or any other XML format that contains similar information).

    Any idea where I can find this information?

    Thanks!

  5. braiden Says:

    where can I get a copy of the saxonb-xslt command used by gmn2tcx?

    ‘saxon-xslt’ is just a help script installed by the ubuntu saxon package. On Ubuntu the contents are;
    #!/bin/sh
    exec java -classpath /usr/share/java/saxonb.jar net.sf.saxon.Transform "$@"

  6. braiden Says:

    This is the URL used by the export link, e.g. export event;
    http://connect.garmin.com/proxy/activity-service-1.0/tcx/activity/EVENT_ID?full=true

    You can use the first two wget’s in my upload script as an example of how to login.
    And a third wget on an URL similar to the one above. (actually, login is probably only
    required if your trying to export private data).

    The harder problem might be finding the id’s you want to export.
    Maybe you can get this from your connect rss feed?
    Otherwise, the activities page on connect seems to use an ajax/json service, it probably possible to build a client to talk to this.

  7. Duncan Sargeant Says:

    Hi Braiden,

    I’m getting the following error…

    dunc-laptop[pts/6]% saxonb-xslt /tmp/foo.xml garmin/gmn2tcx.xslt
    Validation error at xsl:value-of on line 72 of file:///home/dunc/garmin/gmn2tcx.xslt:
    FORG0001: Invalid duration value ‘PT0:38:53.77H’ (non-numeric component)
    Transformation failed: Run-time errors were reported

    dunc-laptop[pts/3]% head /tmp/foo.xml

    3.71505451
    298

    Haven’t touch xslt in years and 2.0 is beyond me :-) I could probably fix it with a perl script in the middle but ew.

    Any ideas? Appreciate your sharing of your solution.

    I guess a hint would be I’m in GMT+0800, the timezone might catch you out, although I couldn’t pick any dependence there in the xslt.

    TIA!

  8. braiden Says:
    Hi Braiden, I’m getting the following error… dunc-laptop[pts/6]% saxonb-xslt /tmp/foo.xml garmin/gmn2tcx.xslt Validation error at xsl:value-of on line 72 of file:///home/dunc/garmin/gmn2tcx.xslt: FORG0001: …

    Hmm, I’ll take a look. I have a pretty bad hack for converting hour,minute, and seconds into a ‘duration in seconds’ at this part of xsl.

    Its not tokenizing the semi-colon for some reason. Maybe this has something to do with your locale? I just commited new version of the script which makes sure both gmn2tcx and gmn2tcx.xsl use UTF-8. You can give this version a try.

    [EDIT] See below, updating your JRE to Java 1.6 (Sun or OpenJDK) will probably fix this.

  9. Frederik Says:

    Hi there,
    I try to use your script with Open Suse 11.1 and saxon8 () but I get the following error:

    ~/Skript> gmn2tcx /home/rissling/2009/07/20090716T201526.gmn > run.tcx
    ./tcx.xsd:262: parser error : Entity ‘nbsp’ not defined
     
    ^
    ./tcx.xsd:277: parser error : Entity ‘nbsp’ not defined
     
    ^
    ./tcx.xsd:313: parser error : Entity ‘copy’ not defined
    © Braiden Kindt, L
    ^
    ./tcx.xsd:318: parser error : Entity ‘nbsp’ not defined
     
    ^
    Schemas parser error : The XML document ‘./tcx.xsd’ is not a schema document.
    WXS schema ./tcx.xsd failed to compile
    Exception in thread “main” java.lang.NoClassDefFoundError: net/sf/saxon/Transform
    -:1: parser error : Document is empty

    ^
    -:1: parser error : Start tag expected, ‘<’ not found

    ^

    Can you help me?

  10. braiden Says:

    Hi there, I try to use your script with Open Suse 11.1 and saxon8 () but I get the following error…

    I’ve made couple changes to the project which should fixes the issues reported so far:

    • The distribution now includes saxon.jar. This should make install somewhat easier. You don’t need to install saxon anymore, or create a saxon-xslt script.
    • You need to install a java 1.6 for saxon to work. Make sure you use either openjdk or sun’s vm. gij (GNU) doesn’t work correctly with saxon, you’ll get an error;
      FORG0001: Invalid duration value 'PT...'
  11. Frederik Says:

    I put some things together (with the help of braiden :-) ), and now you can download a package with the following at http://sporttracks.rissling.name/ :
    - Download Tracks from a garmin sportswatch
    - Convert .gmn-files to .tcx
    - Import tcx-file into SportTracks
    - Enjoy!
    It’s all written in german, so i hope you understand it. If you are interested, I could translate it to english…
    Write to: frederik [at] rissling.name

  12. Lutz Says:

    Great work, but I found an issue with some old tracks in my forerunner:

    Suppose you have an old track, which does not contain any track and point (just remove those lines from the output from garmin_dump). Your XSLT stylesheet produces an empty track from this (), which cannot be validated by xmllint, because the XST schema expects the Track to have some childs:

    element Track: Schemas validity error : Element ‘{http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2}Track’: Missing child element(s). Expected is ( {http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2}Trackpoint ).

    To get rid of this empty track, I just encapsulated the Track in an , and it seems to work. Please be aware, tha XSLT is absolute new to me, but here is my small patch:

    — gmn2tcx.xslt (revision 211)
    +++ gmn2tcx.xslt (working copy)
    @@ -103,6 +103,7 @@
    Manual

    +

    @@ -118,6 +119,7 @@

    +

  13. Lutz Says:

    Excuse me please, I missed to mask the XML-code in my last comment.

    If you like, I’ll send you the patch by mail, but it was really nothing more than a ‘xsl:if test=”../&track”‘ around the Track.

  14. braiden Says:

    Excuse me please, I missed to mask the XML-code in my last comment.

    If you like, I’ll send you the patch by mail, but it was really nothing more than a ‘xsl:if test=”../&track”‘ around the Track.

    Yes, wordpress mangled your patch :( . Send it by email and I’ll apply the patch.

  15. jorges Says:

    The saveruns script was complaining that the pending directory could not be created when saving multiple runs. I added an if to check if the directory is already there, and thus skip its creation.
    Thanks for sharing this, I was struggling to upload to Garmin.

    jorge

    #!/bin/bash

    export GARMIN_SAVE_RUNS
    while read line ; do
    if [ -z "$GARMIN_SAVE_RUNS" ] ; then
    GARMIN_SAVE_RUNS=`pwd`
    fi
    if [ ! -d "$GARMIN_SAVE_RUNS/pending" ]; then
    mkdir “$GARMIN_SAVE_RUNS/pending”
    else
    ln -s “$line” “$GARMIN_SAVE_RUNS/pending/`basename $line`”
    fi
    done < (garmin_save_runs | grep '^Wrote:' | cut -b7-)

  16. braiden Says:

    The saveruns script was complaining that the pending directory could not be created when saving multiple runs… I added an if to check if the directory is already there…

    Thanks, I will apply fix.

  17. Peter Says:

    Thanks for the script, works great! One small suggestion: instead of “mkdir pending” do “mkdir -p pending”. That way when the pending directory already exists, it won’t print a warning.

  18. braiden Says:

    I’ve applied all the mentioned fixes / patches to the latest version in svn.

    • should no longer see “pending: directory already exists” warnings
    • generates valid tcx for runs which have no track/point data when dumped from garmin_dump
    • gives a warning, instead of failing, if xmllint is unavailable for schema validation
  19. Marek Says:

    Does it also work for the 405?

  20. braiden Says:

    Does it also work for the 405?

    Sorry, I don’t think so.

    It should work with any device supported by garmintools, but I don’t think that includes the 405.

  21. bjrnfrdnnd Says:

    Hi there,
    I use your program for the forerunner 305, great work.
    Do you have any idea how to make it work for the 310xt?
    lsusb resulte into:
    Bus 002 Device 011: ID 0fcf:1004 Dynastream Innovations, Inc.

    but ./saveruns does nothing.
    Would be cool if this wireless transfer could work under linux as well…

  22. braiden Says:

    Do you have any idea how to make it work for the 310xt?

    Sorry, I’ve really only written a collection of scripts on top of garmintools. If garmintools supported the device it would probably work, but my understanding is the wireless devices are quite different.

    There was a project which had limited support for the 405 (which was also wireless and i’m guessing might be similar to the 310′s wireless protocols). Maybe worth a try, but wouldn’t have much hope that it will work without modification:

    http://cgit.gromotion.com/cgit.cgi/gant/

  23. Sebastien Carrillo Says:

    Thanks! That was exactely what I was looking for. Worked like a charm on my ubuntu. One more reason not to reboot to my windows partition!

  24. Scott Bauer Says:

    Thanks for this terrific set of scripts. Happy Cycling and Linuxing!

  25. Adam Says:

    Thank you! This works wonderfully and I echo the sentiments from above. I could not find any solutions in Linux Mint Helena until this.

  26. Garmin Forerunner 305 unter Linux « dzys Says:

    [...] werden, so ist eine weitere Konvertierung sinnvoll. Dazu verwendet man das Tool gmn2tcx, welches hier beschrieben wird. Es lässt sich ganz leicht über den Subversion-Server [...]

  27. retsin2000 Says:

    Cool scripts! Working well. One thing, it seems to keep adding activities even if they have been added already. Obviously the device can be cleared of all activities after uploading but is there any way to prevent duplicate activities from being uploaded without removing them fom the device?

    Thanks!!!

  28. braiden Says:

    @retsin2000

    The scripts should only upload new content. Let me explain a bit about how it works, and let me know if you think you have a bug.

    “saveruns” really does two things.

    1) It calls “garmin_save_runs” from the garmintools project. This program should download only new runs. (if it is your very first time running “garmin_save_runs” it will download -everything-, and I should probably add a warning that this will happen). “garmin_save_runs” dumps its output to the directory sepcified by “$GARMIN_SAVE_RUNS” variable. If that’s not defined it uses current directory. So its best to defined “$GARMIN_SAVE_RUNS” with path where you want to write your local cache of data. (If the cache can’t be found, it might duplicate data.)

    2) Once “garmin_save_runs” finishes “saveruns”, my script, updates $GARMIN_SAVE_RUNS/pending. This directory should contain a sym link to every new .gmn file. Its basically the queue of stuff that needs to be uploaded. Processing pretty much stops here.

    When you run “uploadruns” it goes to $GARMIN_SAVE_RUNS/pending and prepares a TCX file for upload. If upload to garmin is successful, it deletes the contents of pending. If garmin returns an errors code we leave the files queued.

    So.. if its duplicating runs for you every time:

    1) Make sure to explicitly set the value of GARMIN_SAVE_RUNS.
    2) Run “saveruns” and check the “pending” folder contains only new data.
    3) Rune “uploadruns” and make sure “pending” is empty once the command completes.

    If #2,3 look to not be working, let me know can I can take a look.

  29. Jari Says:

    Thanks a lot for the scripts! I did have some problems, but was able to fix them. First, the garmin_dump seems to produce bad content in the “name” element. I ended up to edit that manually.
    The second problem was finding out that the correct package for Saxon was libsaxonb-java, not libsaxon-java (error message about missing adjust-dateTime-to-timezone function.)

    Finally I have a working environment with my Forerunner 301 and Linux Mint!

  30. vincent Says:

    Thanks again for the great scripts. Everything has been working well so far, but today when I tried to upload my run somehow gmn2tcx did not encode the GPS points anymore (it encodes general data such as time, calories, etc., but not the GPS points, so no map nor pace graphs etc.). So I tried to see what has changed since last time I uploaded my runs, and I think the only change is that I’ve updated packages on ubuntu, including the OpenJDK java package (I now have package build openjdk-6-jre_6b16-1.6.1-3ubuntu1_i386 ). Since your script uses a custom copy of Saxon, could this be where the problem lies? Otherwise I have no idea what has changed since last time I uploaded a run last week…

    Any idea? Thanks a lot! :-)

  31. Greg Says:

    I love your scripts. Very clever. For some reason, though, my file is not uploading. During the POST, I’m getting an HTTP 500 Server Error from Garmin Connect. Is anybody else experiencing this problem? I’m able to manually upload the .tcx file just fine. Also, I’ve compared the wget POST operation in your script, with the output from the Firefox LiveHTTPHeaders plugin. Everything seems to match. Weird.

  32. braiden Says:

    @vincent
    I’ll follow up in email. I’m curious to know what the output of garmin_dump (from garmin tools) looks like. I’d guess maybe this isn’t working. Occasionally, but rarely, garmin tools won’t give me any geo data for my run.

    I always wait until I have a GPS lock before starting the timer. Seems to cause the issue less, but can’t be sure.

  33. braiden Says:

    @greg

    For 500 error. I’ve had a couple people get this error. I get it occasionally, but it always seems to go away.

    I have a development version of the scripts ;

    SVN is http://bam4.linuxnerd.net/svn/trunk/projects/garmin-dev/

    This has a couple improvements. It uploads one activity at a time, this is slower, but seems to have better success. Garmin may not like it when I try to send a file too big.

    This version also verifies that login was successful before POST’ing.

    Just a warning, the URL in this post is a dev version. Its under a separate path because I’m waiting until weather improves and I can regularly use and test it.

  34. Greg Says:

    Braiden, the new version of your scripts uncovered my problem. I was following an example that you used earlier where you set the USER and PASSWORD variables on the command line. With bash, you actually have to export those values before the script will pick them up. So, it works (with bash) if I execute “./saveruns && USER=username && PASSWORD=password && export USER PASSWORD && ./uploadruns”.

    Alternately, I modified the “uploadruns” script and just hardcoded them.

    I believe what was happening before is that the PASSWORD variable was not set, and Garmin must not do any server-side checking on that POST parameter (since they’re bombing with 500′s). So the POST would fail.

    Also, it may be worth mentioning that several shells, I believe, already use the “USER” variable name, to indicate the OS-logged-in-user. In my case, my OS-user name and Garmin Connect user name are different, so setting and exporting that in a shell could cause other problems for people using the script that way. If you ever run into that issue, you may want to reconsider the name for that variable.

    Anyhow, everything works like a champ. Thanks for the help.

    Greg

  35. Jon Says:

    Braiden,
    I have an older (not sure exactly which revision) of uploadruns that worked fine for me until the recent https change by garmin. While trying to get it working again (before your update), I tried your newest version and instead started getting “500 Internal Server Error” errors. The absolute latest version (267) still gives me the same 500 errors. I went back to the older version that I’ve been using and changed the login url to use https and now it work again. Still can’t get the newest version to do anything besides give me errors. I tried hard coding in the username and password like Greg suggested above, but that didn’t help. If you’d like I can email you the version I have that works for me.
    Thanks for an awesome set of tools!

  36. Brock Says:

    I was running a Windows via VirtualBox to get the plugin to work, but found it easier to run the Windows version Firefox via Wine and it works perfectly. Sure its not a native Linux solution, but it works for all models I have tried.

    Here is my write up.
    http://dropoff.tumblr.com/post/505336492/garmin-connect-running-on-ubuntu-linux

  37. Regis Says:

    I’m also trying to use your scripts. First I had to fight with the Garmin connect website – now it seems to be OK.
    Unfortunately, the script is ending with the following error:

    2010-04-09 17:39:44 (274 MB/s) – »/dev/null« gespeichert [12970/12970]

    –2010-04-09 17:39:44– https://connect.garmin.com/proxy/upload-service-1.1/json/upload
    Auflösen des Hostnamen »connect.garmin.com«…. 92.123.150.235
    Verbindungsaufbau zu connect.garmin.com|92.123.150.235|:443… verbunden.
    HTTP Anforderung gesendet, warte auf Antwort… 403 Forbidden
    2010-04-09 17:39:46 FEHLER 403: Forbidden.

    The USER and PASSWORD variables are set correctly – I tried two ways: included in `xxx` and not.

    Thanks for your help – your the hope of all garmin-enabled and running LINUX users :-)

  38. thomas Says:

    I get the exact same error:

    –2010-04-27 12:31:38– http://connect.garmin.com/proxy/upload-service-1.1/json/upload
    Løser connect.garmin.com (connect.garmin.com)…92.123.246.235
    Connecting to connect.garmin.com (connect.garmin.com)|92.123.246.235|:80… forbundet.
    HTTP forespørgsel sendt, afventer svar… 403 Forbidden
    2010-04-27 12:31:40 FEJL 403: Forbidden.

    Any solution??

  39. braiden Says:

    @thomas, @regis

    Sorry, I’ve been busy and neglecting comments. I have one issue with the -dev version.

    There’s a bug where it will report a 403 when trying to upload (but it acutally succeed in uploading in an earlier POST). For me, everything does get posted to the website despite the error. But, Its worth giving it a try again once i’ve fixed the bug.

    Will patch this weekend (05/01).

  40. Rémy Says:

    Thank you very much for your job. I used the dev version and it work perfectly ;)

  41. braiden Says:

    @thomas, @regis,

    …and anyone else seeing 403 with, try updating to the latest version of -dev. I was stupidly deleting authentication data after trying to upload the first file.

  42. thomas Says:

    @braiden

    I updated to the latest version and now everything works again. Thanks!

  43. Søren Jacobsen Says:

    Hey, thanks for these scripts – so far the most hassle-free solution I’ve come across (tried sporttracks for linux and the “raw” garmintools). Great job!

  44. Ricard Says:

    it’s not for Garmin Connect but you can try a good project for Garmin & GNU/Linux: Pytrainer. It use garmintools and gpx files for work, and you can upload to Garmin Connect.

  45. Florian Says:

    Thank you for this nice tools! Worked like a charm.

  46. Christopher Kelly Says:

    Very well done, this just worked perfectly for me using Ubuntu Lucid and Java sun-java6-jre-6.20dlj-1ubuntu3

    I’ve been looking for a fix for uploading to Garmin Connect from my Forerunner 305 for ages!

  47. Chmouel Says:

    exactly what I need thanks a lot man.

  48. Jens Stein Says:

    i also had the “500 internal server error” errors (with both the ‘stable’ and dev versions) and i couldn’t resolve them by changing the way USER and PASSWORD is read by the script.
    however i was able to deal with the problem by using curl for the upload instead:
    curl -b $COOKIES -F “file=@$TCX;type=application/octet-stream” http://connect.garmin.com/proxy/upload-service-1.1/json/upload
    (add > output.html if your terminal can’t read the output)
    off course this solution depends on curl but has an advantage of being more readable. and as far as i can see, it doesn’t require the mime part.

  49. Niels den Otter Says:

    This really looks like a nice set of tools. I like to keep the rough data myself, to be able to switch between software (Garmin Connect, Sporttracks, etc) when needed. The new announced paid policy for Sporttracks 3.0 makes me switch to Garmin Connect and your tools are great for this.

    – Niels

  50. braiden Says:

    @Jens Stein,

    Thanks for the help. I didn’t know curl had built-in support for http file uploads.
    Definitely smarter than the crap I wrote. I’ve replaced wget with curl in latest version (garmin-dev).

    Hope this helps anyone else anyone else who was seeing 500 errors.

  51. Chmouel Says:

    @braiden Thanks this is fixing my problem

  52. Chmouel Says:

    I by the way reuploaded some of your upload functions in a Python Library :

    http://github.com/chmouel/python-garmin-upload

    it has an added function to name the last workout and probably will add a bit more functions to allow me to automate my workout workflow…..

    All inspired from your shell script, tks again…

  53. Josh Vickery Says:

    Freaking spectacular, especially the automatic uploading. Do you take donations?

  54. Barry O'Donovan Says:

    Extremely useful, thanks a million. I can now retire my Windows Virtual Box. Woot!

  55. Glenn Strong Says:

    Great work, this is invaluable to me.

    It looks like Garmin have changed the API slightly in the last few days, as I started getting upload failures. Looks like the URL for the upload on line 78 of the script now needs to be: http://connect.garmin.com/proxy/upload-service-1.1/json/upload/.tcx

  56. braiden Says:

    @Glenn,

    Thanks for pointing out the issue. I’ll update the version in SVN in the next day or two.

  57. Scott Says:

    This is a great tool.

    I noticed that it stopped working after Garmin’s update today. Anybody (Glenn maybe) come up with a fix yet?

    I’d figure it out myself, but I’m not experienced in tools/methods for reverse engineering which URLs to call, etc. If somebody could point me in the right direction, though, I’m happy to do some leg work toward finding a solution.

  58. braiden Says:

    If you haven’t already, make sure to check-out the latest code from;
    http://linuxnerd.net/svn/trunk/projects/garmin-dev

    This code hasn’t changed since Oct 23rd, so you may already be up-to-date.

    Did something change today on garmin’s site?
    I just test uploaded some data using the scripts and it succeeded.

  59. Scott Says:

    The Oct 23rd code is working for me again. (Whew)

    I tried several times yesterday over a several-hour period, with no luck. Very glad it’s working again!

  60. Jeremy Says:

    Cool stuff, man. Not sure if you’ve seen this before, but I found this nice PERL script (see tedlogan.com) that outputs a summary table of laps, time, duration, HR, etc. into the terminal through garmin_dump on the .gmn files. I’m currently writing a PyGTK implementation that will pipe the dump from the terminal, allow me to attach a run type to it, and write it to a MySQL table.

  61. gunity Says:

    I have problems with the safe connection in uploadruns. So I change every “curl” to “curl -f” in the file.

  62. Doug Says:

    I’ve downloaded the latest, run ./saveruns && USER=UserName PASSWORD=Password ./uploadruns (using my user ID and P/W).

    After the Garmin 305 beeps and seems to be pulling data I see the following:
    - validates
    –2011-01-15 00:03:06– http://connect.garmin.com/signin
    Resolving connect.garmin.com… 184.50.254.235
    Connecting to connect.garmin.com|184.50.254.235|:80… connected.
    HTTP request sent, awaiting response… 302 Moved Temporarily
    Location: https://connect.garmin.com/signin [following]
    –2011-01-15 00:03:06– https://connect.garmin.com/signin
    Connecting to connect.garmin.com|184.50.254.235|:443… connected.
    HTTP request sent, awaiting response… 200 OK
    Length: 14135 (14K) [text/html]
    Saving to: `/dev/null’

    100%[======================================>] 14,135 –.-K/s in 0s

    2011-01-15 00:03:07 (413 MB/s) – `/dev/null’ saved [14135/14135]

    –2011-01-15 00:03:07– https://connect.garmin.com/signin
    Resolving connect.garmin.com… 184.50.254.235
    Connecting to connect.garmin.com|184.50.254.235|:443… connected.
    HTTP request sent, awaiting response… 302 Moved Temporarily
    Location: http://connect.garmin.com/dashboard?cid=500270 [following]
    –2011-01-15 00:03:08– http://connect.garmin.com/dashboard?cid=500270
    Connecting to connect.garmin.com|184.50.254.235|:80… connected.
    HTTP request sent, awaiting response… 200 OK
    Length: 27929 (27K) [text/html]
    Saving to: `/dev/null’

    100%[======================================>] 27,929 50.6K/s in 0.5s

    2011-01-15 00:03:09 (50.6 KB/s) – `/dev/null’ saved [27929/27929]

    –2011-01-15 00:03:09– http://connect.garmin.com/proxy/upload-service-1.1/json/upload
    Resolving connect.garmin.com… 184.50.254.235
    Connecting to connect.garmin.com|184.50.254.235|:80… connected.
    HTTP request sent, awaiting response… 599 Unknown
    2011-01-15 00:03:10 ERROR 599: Unknown.

  63. Combining Garmin Forerunner 305, GNU/Linux and RunKeeper « yerga blog Says:

    [...] data from the Garmin to the computer using GNU/Linux. To do this, I found a great reference at braiden.org and I did everything, more or less, following the same steps, but our goal is to upload the data to [...]

  64. Sandro Says:

    Hi,
    your scripts work great on my Ubuntu 10.10 box !

    Thanks a lot for the great work
    Sandro

  65. brook Says:

    I tried to upload a run this afternoon and got the exact same error message as Doug (ERROR 599). Does anyone have any idea what this might mean?

  66. braiden Says:

    @Doug, @brook:

    Sorry for slow reply looks like you might be using the old version? Give this version a try: http://linuxnerd.net/svn/trunk/projects/garmin-dev. I need to update the post, this is the better (newer) version.

  67. Susan Says:

    Hi,
    The saveruns/uploadruns worked great on my ubuntu box. Thanks! Got a question though: How can I prevent uploading duplicate runs?
    Thanks for great work! linux as a home pc is always a challenge and it’s fun to get things to work despite not doing Windoze.
    Susan

  68. Susan Says:

    Hi again,
    Sorry. I got only one duplicate the first time and it was caused by having originally loading it manually without your updated saveruns/uploadruns design. Reran and no reloads.
    Thanks.
    Susan

  69. braiden Says:

    @Susan,

    The first time you execute the script it will upload everything on the gps device. Subsequently it will only upload new data.

    More Details:
    You can check what is queued for upload to garmin by checking the “pending” directory. It contains symlinks to everything not yet uploaded. The very first time you run this program you might want to delete these links (to avoid uploading old data).

    if $GARMIN_SAVE_RUNS is defined, the script looks for $GARMIN_SAVE_RUNS/pending if not, it uses current directory. So to make sure you don’t duplicated, either 1) always run the script from same working directory, or 2) define $GARMIN_SAVE_RUNS to location on your PC where you want to save your runs. If you change the value of GARMIN_SAVE_RUNS, you need to manually clean out “pending” subdirectory before running uploadRuns the first time after change.

  70. Susan Says:

    @braiden,

    Beautiful. Thanks.