Files
GoldenCheetah/util/fit/README
Mark Liversedge 943deb67ea Generic Support for Session and Lap in FIT files
GENERIC SUPPORT FOR PARSING INTO XDATA

.. Generically parse FIT file messages into XDATA. The current
   implementation does this for session, lap and totals messages
   but could very easily be extended to any other message type

.. Generic parsing uses metadata rather than hard coding the
   message and field types and so on

.. The FIT metadata (FITmetadata.json) has been expanded to
   include definitions of message types and all the standard
   fields within the message types

.. The existing hard-coded parsing remains to extract data
   and apply directly to ridefile samples and metadata. The
   generic parser simply adds additional tabs on the data
   view as XDATA so users can access it.

   CODE REFACTORING, COMMENTS AND BUG FIXES

.. At some point the code needs to be refactored as it is
   janky and needs to align with the rest of the codebase

.. Includes a mild refactor renaming some of the classes/structs
   and variables to reflect what they actually are, for example:

       FitFileReadState -> FitFileParser
       FitDefinition -> FitMessage

.. Added lots of code comments and re-organised the code
   into clear sections to help navigate what is a very
   cumbersome source file, this breaks git blame history
   but is worth the loss (you can checkout an earlier commit
   to do a full blame)

.. Changed debugging levels to be more helpful

.. Generally I did not change any code, but there were a
   couple of serious bugs that needed to be corrected:

      Field definitions gets the type wrong in a couple of
      places since the type is stored in the low 4 bits:
      type = value & 0x1F

      The decodeDeveloperFieldDescription function did not
      check for NA_VALUEs for scale, offset, native field

.. For less serious bugs I added FIXME comments throughout the code

Fixes #4416
2023-11-10 17:14:50 +00:00

57 lines
2.4 KiB
Plaintext

FITmetadata.json generator
For Garmin device updates:
Make sure you download the latest FIT SDK from https://developer.garmin.com/fit/download/
and extract the c/fit_example.h file and place it in this directory.
Do not edit this file, we expect it to be lifted directly from the SDK
and it will be replaced as new versions of the SDK are released
For Garmin profile updates:
The fields.json file in this directory is metadata describing most of the standard
fields and is based upon the Profile.xls file in the SDK. If new fields are or profiles
are added and you want them to be parsed via metadata then update fields.json to
include the entries.
At present the FIT ride file reader code is a mix of hard coded parsing for
the majority of the message types, but the code for parsing session and lap
message types does use the metadata to control parsing (and puts the results
into the XDATA section of a ridefile)
If you add new profile then you should use metadata to drive the parsing and
add the data to the XDATA section to avoid impacting existing code.
Generate a new FITmetadata.json file
There is a Makefile in this directory that will refresh baed upon the timestamp
of the fit_example.h. To refresh simply run 'make'. If you wish to re-run and
regenerate 'touch fit_example.h; make' will do that.
You will need python3 installed since the generator is a python script. Please
do not edit this script but raise a github issue if you find it is broken.
When Garmin devices are not yet supported by the SDK
The SDK lags behind device availability in this case you should add
the Garmin device to the nongarmin.json file, this will override any
value found in the Garmin SDK and is typically because a device is
reported by a user at the forums before the SDK is updated or is a
legacy device that Garmin no longer supports.
For non-Garmin device updates:
Update the file nongarmin.json to add the manufacturer and product combination
and associated description. See existing values in there as examples. Note
that a product number of -1 is to set the default description for any device
from that manufacturer that is not defined
Once the updates have been made you can regenerate FITmetadata.json with:
$ make
A new FITmetadata.json file will be created in the src/Resources/json directory,