Skip to content
This repository has been archived by the owner on Apr 1, 2022. It is now read-only.

Commit

Permalink
Fixed endianness in GetTimestamp(). Tests pass on linux now. Relates to
Browse files Browse the repository at this point in the history
  • Loading branch information
smerchek committed Feb 28, 2013
1 parent 0a3885b commit 1cc8ce6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion libfit/fit_field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,13 @@ FIT_UINT32 Field::GetUINT32Value(const FIT_UINT8 fieldArrayIndex, const FIT_UINT
if ((fieldArrayIndex >= values.size()) || (values[fieldArrayIndex].size() < sizeof(FIT_UINT32)))
return FIT_UINT32_INVALID;

return ((FIT_UINT32) values[fieldArrayIndex][3] << 24) | ((FIT_UINT32) values[fieldArrayIndex][2] << 16) | ((FIT_UINT32) values[fieldArrayIndex][1] << 8) | values[fieldArrayIndex][0];
if (fit::GetArch()) {
//Big Endian
return ((FIT_UINT32) values[fieldArrayIndex][3] << 24) | ((FIT_UINT32) values[fieldArrayIndex][2] << 16) | ((FIT_UINT32) values[fieldArrayIndex][1] << 8) | values[fieldArrayIndex][0];
}
else {
return ((FIT_UINT32) values[fieldArrayIndex][0] << 24) | ((FIT_UINT32) values[fieldArrayIndex][1] << 16) | ((FIT_UINT32) values[fieldArrayIndex][2] << 8) | values[fieldArrayIndex][3];
}
}

FIT_UINT32Z Field::GetUINT32ZValue(const FIT_UINT8 fieldArrayIndex, const FIT_UINT16 subFieldIndex) const
Expand Down

0 comments on commit 1cc8ce6

Please sign in to comment.