Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

Fit Java API Bug

Rank

Total Posts: 2

Joined 2014-05-28

PM

I just realized that the java fit api has a severe bug.
Any call to Decode.skipHeader() ( The API call telling the decoder to ignore CRC values) will result in FitRuntimeExceptions beeing thrown for every file.

The stacktrace will look like this:
com.garmin.fit.FitRuntimeException: FIT decode error: Missing message definition for local message number 14.
at com.garmin.fit.Decode.read(Decode.java:509)
at com.garmin.fit.Decode.resume(Decode.java:256)
at com.garmin.fit.Decode.read(Decode.java:233)
at com.garmin.fit.Decode.read(Decode.java:228)
at com.garmin.fit.MesgBroadcaster.run(MesgBroadcaster.java:130)

Not making a call to skipHeader() will fix this problem and i can parse the fit file without any problem.

Anybody having the same problem?
Will there be an update API available?
     
RankRankRank

Total Posts: 91

Joined 2012-10-12

PM

Hi Sengewald,

I will try this feature again, but it seems your FIT stream actually does contain the header and this is confusing the decoder (header byte 0 usually is 0x0E which also looks like the start of data message 14 as in your exception). This feature is intended to be used on FIT streams that do not contain the header or have already been advanced to the first definition message.      
Rank

Total Posts: 2

Joined 2014-05-28

PM

This makes sense to me.
The fit files actually contain a header and from the documentation i assumed that the API would still read the header but does not decode or process it.
In this way i understood it would be possible to read files with an invalid CRC but valid data otherwise.

     
RankRankRank

Total Posts: 91

Joined 2012-10-12

PM

To deal with your FIT file with invalid CRC I would suggest:
-Just handle the FitRuntimeException at the end when you hit the bad CRC (you would skip calling Decode.checkIntegrity(in) also) OR
-Strip off the last 2 bytes (the bad CRC) and call Decoder.incompleteStream() prior to starting decode to suppress the crc error.

HTH
ShaneP