Addition of "System Time" mode where frames are timestamped by
absolute time from the PC clock.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include <QDateTime>
|
||||
#include <QSettings>
|
||||
|
||||
#include "canconmanager.h"
|
||||
|
||||
@@ -24,6 +25,14 @@ CANConManager::CANConManager(QObject *parent): QObject(parent)
|
||||
mNumActiveBuses = 0;
|
||||
|
||||
resetTimeBasis();
|
||||
|
||||
QSettings settings;
|
||||
|
||||
if (settings.value("Main/TimeClock", false).toBool())
|
||||
{
|
||||
useSystemTime = true;
|
||||
}
|
||||
else useSystemTime = false;
|
||||
}
|
||||
|
||||
void CANConManager::resetTimeBasis()
|
||||
@@ -168,7 +177,8 @@ bool CANConManager::sendFrame(const CANFrame& pFrame)
|
||||
{
|
||||
workingFrame.bus -= busBase;
|
||||
workingFrame.isReceived = false;
|
||||
workingFrame.timestamp = ((QDateTime::currentMSecsSinceEpoch() * 1000) - mTimestampBasis);
|
||||
workingFrame.timestamp = (QDateTime::currentMSecsSinceEpoch() * 1000);
|
||||
if (!useSystemTime) workingFrame.timestamp -= mTimestampBasis;
|
||||
txFrame = conn->getQueue().get();
|
||||
*txFrame = workingFrame;
|
||||
conn->getQueue().queue();
|
||||
|
||||
@@ -74,6 +74,7 @@ private:
|
||||
QTimer mTimer;
|
||||
uint64_t mTimestampBasis;
|
||||
uint32_t mNumActiveBuses;
|
||||
bool useSystemTime;
|
||||
};
|
||||
|
||||
#endif // CANCONNECTIONMODEL_H
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <QSettings>
|
||||
#include <QThread>
|
||||
#include "canconnection.h"
|
||||
|
||||
@@ -79,6 +80,14 @@ void CANConnection::start()
|
||||
/* set started flag */
|
||||
mStarted = true;
|
||||
|
||||
QSettings settings;
|
||||
|
||||
if (settings.value("Main/TimeClock", false).toBool())
|
||||
{
|
||||
useSystemTime = true;
|
||||
}
|
||||
else useSystemTime = false;
|
||||
|
||||
/* in multithread case, this will be called before entering thread event loop */
|
||||
return piStarted();
|
||||
}
|
||||
|
||||
@@ -237,6 +237,7 @@ protected:
|
||||
void setCapSuspended(bool pIsSuspended);
|
||||
|
||||
protected:
|
||||
bool useSystemTime;
|
||||
|
||||
/**************************************************************/
|
||||
/*********** protected interface to implement *******/
|
||||
|
||||
@@ -400,6 +400,10 @@ void GVRetSerial::procRXChar(unsigned char c)
|
||||
buildFrame.timestamp |= (uint)c << 24;
|
||||
|
||||
buildFrame.timestamp += timeBasis;
|
||||
if (useSystemTime)
|
||||
{
|
||||
buildFrame.timestamp = QDateTime::currentMSecsSinceEpoch() * 1000l;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
buildFrame.ID = c;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
#include <QCanBusFrame>
|
||||
#include <QDateTime>
|
||||
|
||||
#include "socketcan.h"
|
||||
|
||||
@@ -189,7 +190,10 @@ void SocketCan::framesReceived()
|
||||
frame_p->extended = false;
|
||||
frame_p->ID = recFrame.frameId();
|
||||
frame_p->isReceived = true;
|
||||
frame_p->timestamp = (recFrame.timeStamp().seconds()*1000000 + recFrame.timeStamp().microSeconds()) - timeBasis;
|
||||
if (useSystemTime) {
|
||||
frame_p->timestamp = QDateTime::currentMSecsSinceEpoch() * 1000ul;
|
||||
}
|
||||
else frame_p->timestamp = (recFrame.timeStamp().seconds() * 1000000ul + recFrame.timeStamp().microSeconds()) - timeBasis;
|
||||
|
||||
checkTargettedFrame(*frame_p);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user