simplify
This commit is contained in:
@@ -209,7 +209,6 @@ void LAWICELSerial::rebuildLocalTimeBasis()
|
|||||||
timeBasis = 0;
|
timeBasis = 0;
|
||||||
lastHWTimestamp = -1;
|
lastHWTimestamp = -1;
|
||||||
wrapAdder = 0;
|
wrapAdder = 0;
|
||||||
lastSysMs = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LAWICELSerial::readSettings()
|
void LAWICELSerial::readSettings()
|
||||||
@@ -531,22 +530,17 @@ void LAWICELSerial::readSerialData()
|
|||||||
len_index = 4;
|
len_index = 4;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dlc = mBuildLine.mid(len_index, 1).toInt();
|
int dlc = mBuildLine.mid(len_index, 1).toInt();
|
||||||
int byteCount = isFD ? (int)dlc_code_to_bytes(dlc) : dlc;
|
int byteCount = isFD ? (int)dlc_code_to_bytes(dlc) : dlc;
|
||||||
int frameStringLen = offset + byteCount * 2;
|
int frameStringLen = offset + byteCount * 2;
|
||||||
if (mBuildLine.length() > frameStringLen + 1)
|
if (mBuildLine.length() > frameStringLen + 1)
|
||||||
{
|
{
|
||||||
qint64 hwTs = mBuildLine.mid(frameStringLen, 4).toInt(nullptr, 16);
|
qint64 hardwareMs = mBuildLine.mid(frameStringLen, 4).toInt(nullptr, 16);
|
||||||
qint64 sysMs = QDateTime::currentMSecsSinceEpoch();
|
if (lastHWTimestamp >= 0 && hardwareMs < lastHWTimestamp) { wrapAdder += 60000; }
|
||||||
if (lastHWTimestamp >= 0 && hwTs < lastHWTimestamp) {
|
lastHWTimestamp = hardwareMs;
|
||||||
qint64 sysDelta = sysMs - lastSysMs;
|
qint64 unwrappedMs = wrapAdder + hardwareMs;
|
||||||
wrapAdder += lastHWTimestamp + sysDelta - hwTs;
|
if (timeBasis == 0) { timeBasis = QDateTime::currentMSecsSinceEpoch() - unwrappedMs; }
|
||||||
}
|
|
||||||
lastHWTimestamp = hwTs;
|
|
||||||
lastSysMs = sysMs;
|
|
||||||
qint64 unwrappedMs = wrapAdder + hwTs;
|
|
||||||
if (timeBasis == 0)
|
|
||||||
timeBasis = sysMs - unwrappedMs;
|
|
||||||
buildFrame.setTimeStamp(QCanBusFrame::TimeStamp(0, (timeBasis + unwrappedMs) * 1000ll));
|
buildFrame.setTimeStamp(QCanBusFrame::TimeStamp(0, (timeBasis + unwrappedMs) * 1000ll));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ protected:
|
|||||||
qint64 timeBasis;
|
qint64 timeBasis;
|
||||||
qint64 lastHWTimestamp;
|
qint64 lastHWTimestamp;
|
||||||
qint64 wrapAdder;
|
qint64 wrapAdder;
|
||||||
qint64 lastSysMs;
|
|
||||||
bool can0Enabled;
|
bool can0Enabled;
|
||||||
bool can0ListenOnly;
|
bool can0ListenOnly;
|
||||||
bool canFd;
|
bool canFd;
|
||||||
|
|||||||
Reference in New Issue
Block a user