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:
@@ -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;
|
||||
if (useSystemTime)
|
||||
{
|
||||
workingFrame.timestamp = (QDateTime::currentMSecsSinceEpoch() * 1000);
|
||||
if (!useSystemTime) workingFrame.timestamp -= mTimestampBasis;
|
||||
}
|
||||
else
|
||||
{
|
||||
workingFrame.timestamp = mElapsedTimer.nsecsElapsed() / 1000;
|
||||
//workingFrame.timestamp -= mTimestampBasis;
|
||||
}
|
||||
txFrame = conn->getQueue().get();
|
||||
*txFrame = workingFrame;
|
||||
conn->getQueue().queue();
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
#include <QElapsedTimer>
|
||||
|
||||
#include "canconnection.h"
|
||||
|
||||
@@ -73,6 +74,7 @@ private:
|
||||
static CANConManager* mInstance;
|
||||
QList<CANConnection*> mConns;
|
||||
QTimer mTimer;
|
||||
QElapsedTimer mElapsedTimer;
|
||||
uint64_t mTimestampBasis;
|
||||
uint32_t mNumActiveBuses;
|
||||
bool useSystemTime;
|
||||
|
||||
Reference in New Issue
Block a user