Problem with "decode" in C examples

Hello,
I just downloaded the FIT SDK. I can transform one of my FIT file into CSV thanks to the java FitCSVTool.

But then I compile under linux without error the "decode" example provided in the "c" folder but when I try to decode the same file, I have: "File is not FIT."

I tried with other files with same results...

I put one example fit file attached

Any hints?

Thanks

  • Using the Visual Studio project that is included in the SDK, I was able to decode the file that you attached with the C SDK. So the issue is not the file. The issue may be a compiler flag that is, or is not, being used. But that is just a guess. 

    The error that you are getting is happening when the decoder is reading the file header and checking that bytes 8-11 (zero based indices) are the ascii equivalent of ".FIT". Look at fit_convert.c line 143 and you will see where the return code that results in "File is not FIT." being printed is returned.

    The C decoder is a state machine that decodes the file one byte at at time. The error that you are getting is happening after 14 bytes are read, so you should be able to step through the code and see if anything looks off. Maybe start by setting a break point on line 143 in fit_convert.c and inspect the value of state->u.file_hdr and see what the value of data_type is. It should be ".FIT"; aka the array of these four values {0x2E,0x46, 0x49, 0x54}.

    Also, you can open the file in a hex editor to see what the first 14 bytes in the file are. Table 1 here will tell you how to interpret them. And compare the values to what is in state->u.file_hdr 
    https://developer.garmin.com/fit/protocol/ 

    Another thing to try is to #define FIT_USE_STDINT_H, see the top of fit.h. It could be something as simple as a data type being defined differently than expected.

  • I simply compiled with gcc without any options...may-be an option was needed indeed...to be checked

  • Solution was here: https://www.thisisant.com/forum/viewthread/6444/  uncomment the #define FIT_USE_STDINT_H  line in fit_config.h