Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

FIT workout help: Garmin Edge 520 reads only one file

Rank

Total Posts: 3

Joined 2018-07-18

PM

Hello guys, I developed a C++ program that creates MRC and FIT files for Indoor power based cycling workouts. Source Code: https://github.com/helderlopes/MRC_creator

The problem is that, when I put more than one workout FIT file on my Garmin Edge 520 (I tried to put in Workouts folder and in NewFiles folder, the behaviour is the same), my unit just interpret the first workout, and delete the others. Is this a limitation on Garmin Edge unit, or do I need to put more info on FIT workout file? The code that creates the FIT file is located in WriteFIT.cpp file, but basically I insert a file ID message, a file Creator message, a workout message and the workout steps. The code looks like this:

fit::FileIdMesg fileIdMesg
fileIdMesg.SetType(FIT_FILE_WORKOUT); 
fileIdMesg.SetManufacturer(FIT_MANUFACTURER_GARMIN); 
encode.Write(fileIdMesg); 

fit::FileCreatorMesg fileCreatorMesg
fileCreatorMesg.SetSoftwareVersion(0); 
fileCreatorMesg.SetHardwareVersion(0); 
encode.Write(fileCreatorMesg); 

fit::WorkoutMesg workoutMesg
workoutMesg.SetCapabilities(FIT_WORKOUT_CAPABILITIES_TCX); 
workoutMesg.SetNumValidSteps(numValidSteps); 
workoutMesg.SetSport(FIT_SPORT_CYCLING); 
workoutMesg.SetWktName(s2ws(workoutName)); 
encode.Write(workoutMesg); 

for (
unsigned int i 0data.numberOfStepsi++) 

  fit
::WorkoutStepMesg workoutStepMesg
  
//...
  //<fill workout step mesg>
  //...
  
encode.Write(WorkoutStepMesg ); 


Am I missing something or is this a normal behaviour? It's really annoying because I would like to create my weekday workouts on Sunday and put all of them at once on my garmin edge unit...

Thanks.      
Rank

Total Posts: 10

Joined 2018-10-12

PM

helder.lopes - 22 August 2019 11:00 AM
Hello guys, I developed a C++ program that creates MRC and FIT files for Indoor power based cycling workouts. Source Code: https://github.com/helderlopes/MRC_creator

The problem is that, when I put more than one workout FIT file on my Garmin Edge 520 (I tried to put in Workouts folder and in NewFiles folder, the behaviour is the same), my unit just interpret the first workout, and delete the others. Is this a limitation on Garmin Edge unit, or do I need to put more info on FIT workout file? The code that creates the FIT file is located in WriteFIT.cpp file, but basically I insert a file ID message, a file Creator message, a workout message and the workout steps. The code looks like this:

fit::FileIdMesg fileIdMesg
fileIdMesg.SetType(FIT_FILE_WORKOUT); 
fileIdMesg.SetManufacturer(FIT_MANUFACTURER_GARMIN); 
encode.Write(fileIdMesg); 

fit::FileCreatorMesg fileCreatorMesg
fileCreatorMesg.SetSoftwareVersion(0); 
fileCreatorMesg.SetHardwareVersion(0); 
encode.Write(fileCreatorMesg); 

fit::WorkoutMesg workoutMesg
workoutMesg.SetCapabilities(FIT_WORKOUT_CAPABILITIES_TCX); 
workoutMesg.SetNumValidSteps(numValidSteps); 
workoutMesg.SetSport(FIT_SPORT_CYCLING); 
workoutMesg.SetWktName(s2ws(workoutName)); 
encode.Write(workoutMesg); 

for (
unsigned int i 0data.numberOfStepsi++) 

  fit
::WorkoutStepMesg workoutStepMesg
  
//...
  //<fill workout step mesg>
  //...
  
encode.Write(WorkoutStepMesg ); 


Am I missing something or is this a normal behaviour? It's really annoying because I would like to create my weekday workouts on Sunday and put all of them at once on my garmin edge unit...

Thanks.


It looks like you are writing the same FileIdMesg to each .FIT file. The FileIdMesg is used to uniquely identify a file. So currently the Edge 520 thinks all the files you try to load are duplicates.

Try setting the product, serial_number, and time_created, in addition to the type and manufacturer, in the FileIdMesg and see if that helps.      
Rank

Total Posts: 3

Joined 2018-07-18

PM

That makes sense. I'll try this later and then I post the result here. Thank you!      
Rank

Total Posts: 3

Joined 2018-07-18

PM

npierce, thank you.
That worked.
According to documentation (FIT File Types.pdf), page 13:
----------------------------------------
3.1.1 “file_id” Message
The file_id message identifies the format/content of the FIT file (type field) and the combination of fields provides a globally unique identifier for the file. Each FIT file should contain one and only one file_id message. If the combination of type, manufacturer, product and serial_number is insufficient, for example on a device supporting multiple device files, the time_created or number fields must be populated to differentiate the files.
If the file is created offline (for example using a PC application) the file_id fields could be set as per the creating application or to the values of the destination device, if known. If the file is in an intermediate state, only type need be set, so long as the other fields are later updated by the target device.
----------------------------------------
I just had to set the "number" field, that is the file identifier. I generated it by hashing the outputfile name. That way, every workout will have a different "number" and Garmin identifies it as a different workout.