Skip to content

Commit

Permalink
Added/corrected timestamps for LAWICEL protocol.
Browse files Browse the repository at this point in the history
Fixed System Clock timestamps and added decoding for timestamps coming from the tool.
  • Loading branch information
superwofy committed Jun 21, 2024
1 parent 53c0dae commit 1b61ae6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
21 changes: 20 additions & 1 deletion connections/lawicel_serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,26 @@ void LAWICELSerial::readSerialData()
{
qDebug() << "Got CR!";

buildFrame.setTimeStamp(QDateTime::currentMSecsSinceEpoch() * 1000l);
if (useSystemTime)
{
buildTimestamp = QDateTime::currentMSecsSinceEpoch() * 1000l;
}
else
{
//If total length is greater than command, header and data, timestamps must be enabled.
if (data.length() > (5 + mBuildLine.mid(4, 1).toInt() * 2 + 1))
{
//Four bytes after the end of the data bytes.
buildTimestamp = mBuildLine.mid(5 + mBuildLine.mid(4, 1).toInt() * 2, 4).toInt(nullptr, 16) * 1000l;
}
else
{
//Default to system time if timestamps are disabled.
buildTimestamp = QDateTime::currentMSecsSinceEpoch() * 1000l;
}
}
buildFrame.setTimeStamp(QCanBusFrame::TimeStamp(0, buildTimestamp));

switch (mBuildLine[0].toLatin1())
{
case 't': //standard frame
Expand Down
1 change: 1 addition & 0 deletions connections/lawicel_serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ private slots:
QSerialPort *serial;
int framesRapid;
CANFrame buildFrame;
qint64 buildTimestamp;
bool can0Enabled;
bool can0ListenOnly;
bool canFd;
Expand Down

0 comments on commit 1b61ae6

Please sign in to comment.