Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

Inconsistency in FIT SDK while processing fields with default values

Rank

Total Posts: 23

Joined 2019-05-06

PM

I am on SDK 20.66.00-0-gc7b345b. As for me there is some inconsistency in FIT SDK while processing developer fields with default values.
1) FIT SDK C++ decoder does not save value for fields with defaults. However it still saves this entry. As a result we have an entry with no value. I am referring to FieldBase::Read() with returns FIT_TRUE even for entries with default values, i.e:
if (memcmp(pointbaseTypeInvalids[GetType() & FIT_BASE_TYPE_NUM_MASK]typeSize) != 0)
{
  values
.insert(values.end(), byteDatabyteData bytesLeft);
  break;

2) FIT SDK C++ encoder on the other hand does not ignore fields with default value and writes them to file.

It seems to me that SDK should have the same behavior while processing default values. Either ignore them completely or save as is.
Also I do not see any reason to save field, but do not save it's value. So propose to update FieldBase::Read() to return FIT_FALSE when field with default values is encountered. This way we can detect such fields and ignore them during decoding. For example, add a check like to Decode::ReadByte():
if (FIT_TRUE == field.Read(&fieldData;, fldDefn->GetSize()))
{
  mesg
.AddDeveloperField(field);
     
RankRankRankRank

Total Posts: 120

Joined 2013-05-07

PM

Hi Ros,

When encoding a field, if the value is invalid, it is encoded as invalid. The record is not removed, because to some decoders, the presence of the record, even with a null value, is valuable information.

When decoding an invalid, the value is reported as null. From what I understand, reporting invalids as nulls is the behavior for native and developer data fields alike.

BK      
Rank

Total Posts: 23

Joined 2019-05-06

PM

Hello DK,

actually I am pointing to the fact that when some field is decoded that has invalid value, this field is not decoded. For example, after `FieldBase::Read()` returns and field.GetNumValues() is 0, field won't be added to this message. File `fit_decode.cpp`, lines 815-857:
if ( read )
{
  field
.Read(&fieldData;, defn.GetFieldByIndex(fieldIndex)->GetSize()))                            
}

....

if (
field.GetNumValues() > 0)
{
  mesg
.AddField(field);


On the other hand, when the same occurs for developer field - this field is saved. File `fit_decode.cpp`, lines 932-933:
field.Read(&fieldData;, fldDefn->GetSize()));
mesg.AddDeveloperField(field); 


This cause issues on my side when decoding a FIT file. So I believe that `FieldBase::Read()` can return FIT_FALSE when field could not be read. This field can be then skipped and not added to message.

P.S. Not able to attach example diff due to some security issues on this forum. Attaching it as JPEG...      

Image Attachments

fit_sdk_skip_invalid_devfields.jpg

Click thumbnail to see full-size image