IndexOutOfBoundsException adds Garmin FIT RecordMesg custom field

My application creates a .Fit file.

It works great with the standard API. But when I try to add a custom field, it is ignored or cannot be parsed by the client.

I am using FIT SDK 2.0.

fit::DeveloperDataIdMesg DPSdevIdMesg; uint8_t appId[] = { 0x67, 0x72, 0x69, 0x73, 0x68, 0x61, 0x20, 0x68, 0x61, 0x20, 0x6d, 0x65, 0x6c, 0x65, 0x6b, 0x68 }; for (int appIdx = 0; appIdx < 16; ++appIdx) { DPSdevIdMesg.SetApplicationId( appIdx, appId[appIdx] ); } DPSdevIdMesg.SetDeveloperDataIndex(0); encode.Write(DPSdevIdMesg); fit::FieldDescriptionMesg DPSfieldDescMesg; DPSfieldDescMesg.SetDeveloperDataIndex(0); DPSfieldDescMesg.SetFieldDefinitionNumber(0); DPSfieldDescMesg.SetFitBaseTypeId(FIT_FIT_BASE_TYPE_FLOAT64); FIT_WSTRING DPSname = L"DPS"; DPSfieldDescMesg.SetFieldName(0,DPSname ); DPSfieldDescMesg.SetUnits( 0, L"m" ); encode.Write(DPSfieldDescMesg); for (size_t k = 0; k < intervals_size; k++) { std::vector<commons::timestamped<commons::gps_point>> gps_points = interval_report.gps_points; size_t gpsPointsSize = gps_points.size(); for (size_t j = 0; j < gpsPointsSize; j++) { commons::timestamped<commons::gps_point> obj = gps_points[j]; commons::gps_point point = obj.value; . . fit::RecordMesg record; fit::DeveloperField df(DPSfieldDescMesg, DPSdevIdMesg); double dps = point.dps; record.AddDeveloperField(df); df.SetFLOAT64Value(0.0); . . record.SetPositionLong(pow(2, 31) * (longitudeX) / 180.0); record.SetPositionLat(pow(2, 31) * (latitudeY) / 180.0); record.SetGpsAccuracy(accuracy); encode.Write(record); } } 

An exception occurs when you try to parse it in a CSV file.

 FIT CSV Tool - Protocol 2.0 Profile 20.22 Release Exception in thread "main" java.lang.RuntimeException: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1 at com.garmin.fit.csv.CSVTool.run(CSVTool.java:232) at com.garmin.fit.csv.CSVTool.main(CSVTool.java:302) Caused by: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1 at java.util.ArrayList.rangeCheck(Unknown Source) at java.util.ArrayList.get(Unknown Source) at com.garmin.fit.Decode.read(Decode.java:975) at com.garmin.fit.Decode.resume(Decode.java:365) at com.garmin.fit.Decode.read(Decode.java:344) at com.garmin.fit.csv.CSVTool.run(CSVTool.java:206) 
+7
garmin
source share

No one has answered this question yet.

See related questions:

one
How to encode pauses in Garmin Fit files
0
Which Garmin devices support the vibe method?
0
Does Garmin provide the number of user steps in their API?
0
Garmin user card does not have a name
0
Garmin fenix 3 native color
0
Garmin GPS Navigator for Garmin Watches
0
Garmin Bulk Logging API
-one
Garmin.fit timestamp file

All Articles