Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

SDK 14.0 has Session Mesg Encode problem

Rank

Total Posts: 2

Joined 2015-02-20

PM

SDK 14.0 c examples defines:
in fit_example.h:
#define FIT_SESSION_MESG_DEF_SIZE 269

Here is how this definition is used:
// write Session record

FIT_SESSION_MESG fit_session;
Fit_InitMesg(fit_mesg_defs[FIT_MESG_SESSION], &fit;_session);
fit_session.timestamp = (FIT_DATE_TIME) next_second;
fit_session.sport = FIT_SPORT_SWIMMING;
fit_session.total_elapsed_time = nDurationInMillis;
fit_session.total_timer_time = nDurationInMillis;
fit_session.total_distance = 0;
fit_session.total_ascent = 0;
WriteMessageDefinition(0, fit_mesg_defs[FIT_MESG_SESSION], FIT_SESSION_MESG_DEF_SIZE, fp);
WriteMessage(0, &fit;_session, FIT_SESSION_MESG_SIZE, fp);


but the encode routines call for FIT_UINT8 for the param which is too small to contain the value 269.

Here are the encode routines:
void WriteMessageDefinition(FIT_UINT8 local_mesg_number, const void *mesg_def_pointer, FIT_UINT8 mesg_def_size, FILE *fp)
void WriteMessage(FIT_UINT8 local_mesg_number, const void *mesg_pointer, FIT_UINT8 mesg_size, FILE *fp)
void WriteData(const void *data, FIT_UINT8 data_size, FILE *fp)

If I change the params to FIT_UNIT16 it breaks the crc.
The session message has too many fields which makes it too large to have msg size fit in an unsigned char (8 bits) field. The largest size allowed should be 255.

when I use decode on the encoded fit file I get Error decoding file. when it gets to reading the session message.


Strava fit files ask for session messages for their uploads. they claim they use the following fields:
session
sport
total_elapsed_time
total_timer_time
total_distance
total_ascent





     
RankRankRank

Total Posts: 91

Joined 2012-10-12

PM

Hi Dan,

Individual FIT messages are limited to 255 bytes. Some shared messages (such as session) include specialized fields for different applications such as swimming or cycling. The are not all intended to be used simultaneously.

In the C SDK you can disable fields you are not using by modifying your config.csv file and running FITGen to regenerate the C files. I will update the 'EXAMPLE' product configuration to include fewer fields by default.

     
Rank

Total Posts: 2

Joined 2015-02-20

PM

Thank you sir. I will remember this in the future.