From fd0fca0f45d1d501d99befe349fa1c382465249e Mon Sep 17 00:00:00 2001 From: Heikki Perea Date: Wed, 8 Oct 2025 15:36:55 -0600 Subject: [PATCH 1/2] fix: dynamic timestamp extraction for LAWICEL CAN frames Fixed timestamp extraction in LAWICEL CAN frames by accounting for the CAN frame type. --- connections/lawicel_serial.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/connections/lawicel_serial.cpp b/connections/lawicel_serial.cpp index e45067d..3fd38d7 100644 --- a/connections/lawicel_serial.cpp +++ b/connections/lawicel_serial.cpp @@ -497,11 +497,29 @@ void LAWICELSerial::readSerialData() } else { + char offset; + char len_index; + switch(mBuildLine[0].toLatin1()) { + case 't': + case 'd': + offset = 5; + len_index = 4; + break; + case 'T': + case 'D': + offset = 10; + len_index = 9; + break; + default: + offset = 5; + len_index = 4; + break; + } //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)) + if (data.length() > (offset + mBuildLine.mid(len_index, 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; + buildTimestamp = mBuildLine.mid(offset + mBuildLine.mid(len_index, 1).toInt() * 2, 4).toInt(nullptr, 16) * 1000l; buildFrame.setTimeStamp(QCanBusFrame::TimeStamp(0, buildTimestamp)); } else From 87fbc633d45e3713c94c104f217f8fc547512739 Mon Sep 17 00:00:00 2001 From: Heikki Perea Date: Mon, 13 Oct 2025 10:47:55 -0600 Subject: [PATCH 2/2] fix: timestamp in milliseconds Lawicel defined the timestamp in milliseconds --- connections/lawicel_serial.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connections/lawicel_serial.cpp b/connections/lawicel_serial.cpp index 3fd38d7..3b46d80 100644 --- a/connections/lawicel_serial.cpp +++ b/connections/lawicel_serial.cpp @@ -519,7 +519,7 @@ void LAWICELSerial::readSerialData() if (data.length() > (offset + mBuildLine.mid(len_index, 1).toInt() * 2 + 1)) { //Four bytes after the end of the data bytes. - buildTimestamp = mBuildLine.mid(offset + mBuildLine.mid(len_index, 1).toInt() * 2, 4).toInt(nullptr, 16) * 1000l; + buildTimestamp = mBuildLine.mid(offset + mBuildLine.mid(len_index, 1).toInt() * 2, 4).toInt(nullptr, 16); buildFrame.setTimeStamp(QCanBusFrame::TimeStamp(0, buildTimestamp)); } else