July 13, 2023

Garmin FIT files - "fitdecode"

I cloned this from github, hoping it would be readable and instructive.
git clone https://github.com/polyvertex/fitdecode.git
cd fitdecode
cd cmd
./fittxt /home/tom/c.fit | more
This program does run without issue and the output looks like this:
TXT
	name             c.fit
	filter           []
	frames           1193
	size             48980
	missing_headers  0
	fit_files (1)
		definition_messages  8
		data_messages        1183
		has_footer           yes
		header_crc_matched   yes
		footer_crc_matched   yes

chunk#0 - fit_header
	header_size  14

......
......
......

chunk#1192 - fit_crc
	crc      0xfad7
	matched  yes
	chunk
		index   1192
		offset  48978
		size    2
So, we have 1193 frames (or chunks), the last of which is a CRC.

The "fittxt" program is 16 lines of python, most of which is boilerplate. The important part boils down to two lines:

from fitdecode.cmd import fittxt
sys.exit(fittxt.main())
A big part of the code is the file "profile.py". This is a 12966 line files obtained from the Garmin SDK that has all kinds of "enum" statements for fields in a FIT file.

My file

Here is a hex dump of the first 90 bytes from my FIT file.
00000000 0e10 6d08 44bf 0000 2e46 4954 dd09 4000     m D   .FIT  @
00000010 0000 0007 0304 8c04 0486 0704 8601 0284
00000020 0202 8405 0284 0001 0000 5426 50c8 4185             T&P A
00000030 123f ffff ffff 0100 d40c ffff 0441 0000    ?           A
00000040 3100 0302 1407 0002 8401 0102 0100 0000   1
00000050 0000 0000 0000 0000 0000 0000 0000 0000
1193 is 0x4a9 -- I don't see that in there.
48960 is the size of the file in bytes, so I don't expect to see that in there.
The only thing recognizable is ".FIT" in ascii.
Have any comments? Questions? Drop me a line!

Tom's backpacking pages / [email protected]