mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-19 04:02:09 +01:00
Added support for FIT files with developer data fields
This commit is contained in:
parent
62ff4bb7c4
commit
9e583a9dab
@ -18,11 +18,13 @@ FITParser::FITParser(QList<TrackData> &tracks, QList<RouteData> &routes,
|
|||||||
void FITParser::clearDefinitions()
|
void FITParser::clearDefinitions()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
if (_defs[i].fields) {
|
if (_defs[i].fields)
|
||||||
delete[] _defs[i].fields;
|
delete[] _defs[i].fields;
|
||||||
_defs[i].fields = 0;
|
if (_defs[i].devFields)
|
||||||
}
|
delete[] _defs[i].devFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset(_defs, 0, sizeof(_defs));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FITParser::warning(const char *text) const
|
void FITParser::warning(const char *text) const
|
||||||
@ -91,6 +93,10 @@ bool FITParser::parseDefinitionMessage(quint8 header)
|
|||||||
delete[] def->fields;
|
delete[] def->fields;
|
||||||
def->fields = 0;
|
def->fields = 0;
|
||||||
}
|
}
|
||||||
|
if (def->devFields) {
|
||||||
|
delete[] def->devFields;
|
||||||
|
def->devFields = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// reserved/unused
|
// reserved/unused
|
||||||
if (!readValue(i))
|
if (!readValue(i))
|
||||||
@ -121,6 +127,20 @@ bool FITParser::parseDefinitionMessage(quint8 header)
|
|||||||
_len -= sizeof(def->fields[i]);
|
_len -= sizeof(def->fields[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// developer definition records
|
||||||
|
if (header & 0x20) {
|
||||||
|
if (!readValue(def->numDevFields))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
def->devFields = new Field[def->numDevFields];
|
||||||
|
for (i = 0; i < def->numDevFields; i++) {
|
||||||
|
if (!readData((char*)&(def->devFields[i]),
|
||||||
|
sizeof(def->devFields[i])))
|
||||||
|
return false;
|
||||||
|
_len -= sizeof(def->devFields[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +193,7 @@ bool FITParser::parseData(MessageDefinition *def, quint8 offset)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
||||||
if (!def->fields) {
|
if (!def->fields && !def->devFields) {
|
||||||
_errorString = "Undefined data message";
|
_errorString = "Undefined data message";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -222,6 +242,13 @@ bool FITParser::parseData(MessageDefinition *def, quint8 offset)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < def->numDevFields; i++) {
|
||||||
|
field = &def->devFields[i];
|
||||||
|
if (!readField(field, val))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (def->globalId == RECORD_MESSAGE) {
|
if (def->globalId == RECORD_MESSAGE) {
|
||||||
if (trackpoint.coordinates().isValid()) {
|
if (trackpoint.coordinates().isValid()) {
|
||||||
trackpoint.setTimestamp(QDateTime::fromTime_t(timestamp
|
trackpoint.setTimestamp(QDateTime::fromTime_t(timestamp
|
||||||
@ -261,11 +288,6 @@ bool FITParser::parseRecord()
|
|||||||
if (!readValue(header))
|
if (!readValue(header))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (header & 0x20) {
|
|
||||||
_errorString = "Developer data not supported";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (header & 0x80)
|
if (header & 0x80)
|
||||||
return parseCompressedMessage(header);
|
return parseCompressedMessage(header);
|
||||||
else if (header & 0x40)
|
else if (header & 0x40)
|
||||||
|
@ -34,6 +34,8 @@ private:
|
|||||||
quint16 globalId;
|
quint16 globalId;
|
||||||
quint8 numFields;
|
quint8 numFields;
|
||||||
Field *fields;
|
Field *fields;
|
||||||
|
quint8 numDevFields;
|
||||||
|
Field *devFields;
|
||||||
} MessageDefinition;
|
} MessageDefinition;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user