Make sent frames have a timestamp resolution of microseconds just like incoming frames. Previously sent frame

time stamps were rounded to the nearest millisecond.

Note, however, that this time stamp is when we first tried to send the frame to hardware,
not when the hardware sent the frame. That will probably be later on but there's no way
to know for sure if/when it will send the frame.
This commit is contained in:
Collin Kidder
2017-11-08 21:20:17 -05:00
parent ed2cd7bd8c
commit 545f258b8e
2 changed files with 12 additions and 2 deletions
+10 -2
View File
@@ -36,6 +36,7 @@ CANConManager::CANConManager(QObject *parent): QObject(parent)
void CANConManager::resetTimeBasis()
{
mTimestampBasis = QDateTime::currentMSecsSinceEpoch() * 1000;
mElapsedTimer.restart();
}
CANConManager::~CANConManager()
@@ -182,8 +183,15 @@ bool CANConManager::sendFrame(const CANFrame& pFrame)
{
workingFrame.bus -= busBase;
workingFrame.isReceived = false;
workingFrame.timestamp = (QDateTime::currentMSecsSinceEpoch() * 1000);
if (!useSystemTime) workingFrame.timestamp -= mTimestampBasis;
if (useSystemTime)
{
workingFrame.timestamp = (QDateTime::currentMSecsSinceEpoch() * 1000);
}
else
{
workingFrame.timestamp = mElapsedTimer.nsecsElapsed() / 1000;
//workingFrame.timestamp -= mTimestampBasis;
}
txFrame = conn->getQueue().get();
*txFrame = workingFrame;
conn->getQueue().queue();