Linux and the Polar F6 Heart Rate Monitor (2)
In the first post in the matter, I introduced you to a quick way of getting your Polar data into a Linux computer. I found that the transfer of data using sound is a nifty way of doing things, and the utilities written work pretty well.
There is one thing, though, that totally annoyed me about the process of transferring data: once you get the FRD files out of the watch, you have to manually add each exercise into SportsTracker – which is a tedious task at best, especially because it’s obvious SportsTracker is meant to track distances more than anything else. I mean, after all it was born as a way to track cycling and running workouts.
The oddest thing is that the FRD files are binary, while the final output of SportsTracker is XML. It was just a matter of looking at the file format and figuring out how to write the corresponding XML, which I did in the following.
Please note: I have used Tcl for this task, not because it’s particularly suited, but because it was there and I knew it. I could have just as well used Python, Java, or any other language, but for now it’s Tcl. From your perspective, you may have to install Tcl on your Linux box if you want to use the utility – not a big deal. apt-get install tcl will do the trick (or emerge tcl, or whatever you use).
You invoke the utility with the files you want to convert to XML as parameters. The utility will then:
- decode the files
- check whether a workout at exactly that time is already in the exercises file
- spit out useful XML
Not much error checking, so far, and the utility doesn’t store back to the exercises file. I have an improved version that takes my workout schedule and assigns workout types accordingly (for instance, on Wednesday nights at 6p I always spin), but the logic is just mine, so there is no need to discuss it here.
```
#!/usr/bin/tclsh set exercise_file [glob ~/.sportstracker/exercises.xml] set template {
} if {[regexp {
</span>