Skip to content

Commit

Permalink
Merge pull request #801 from superwofy/master
Browse files Browse the repository at this point in the history
Added/corrected timestamps for LAWICEL protocol.
  • Loading branch information
collin80 authored Jul 9, 2024
2 parents 2cf6398 + 1b61ae6 commit d97c8d4
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 d97c8d4

Please sign in to comment.