From d3feb284a1dfb71d39fcbf978abe559b814ccdbc Mon Sep 17 00:00:00 2001 From: Brice Gaulupeau Date: Thu, 10 Dec 2020 08:12:22 +0100 Subject: [PATCH] Fix PCAN loading issues Uses numBytes instead of thisFrame.payload().length() as the payload is not yet defined Scan the first 25 lines intead of 10 as version 1 has a long header --- framefileio.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/framefileio.cpp b/framefileio.cpp index 20e7fb0..d086013 100644 --- a/framefileio.cpp +++ b/framefileio.cpp @@ -1258,7 +1258,7 @@ bool FrameFileIO::isPCANFile(QString filename) { while (!inFile->atEnd()) { lineCounter++; - if (lineCounter > 10) + if (lineCounter > 25) { break; } @@ -1375,7 +1375,7 @@ bool FrameFileIO::loadPCANFile(QString filename, QVector* frames) if (line.at(41) == 'R') { thisFrame.setFrameType(QCanBusFrame::RemoteRequestFrame); } else { - QList tokens = line.mid(41, thisFrame.payload().length() * 3).split(' '); + QList tokens = line.mid(41, numBytes * 3).split(' '); thisFrame.setFrameType(QCanBusFrame::DataFrame); for (int d = 0; d < numBytes; d++) { @@ -1398,7 +1398,7 @@ bool FrameFileIO::loadPCANFile(QString filename, QVector* frames) { int numBytes = line.mid(37,2).trimmed().toInt(); QByteArray bytes(numBytes, 0); - qDebug() << thisFrame.payload().length(); + //qDebug() << thisFrame.payload().length(); thisFrame.isReceived = true; thisFrame.bus = 0; if (line.at(25) == ' ') { @@ -1409,7 +1409,7 @@ bool FrameFileIO::loadPCANFile(QString filename, QVector* frames) if (line.at(40) == 'R') { thisFrame.setFrameType(QCanBusFrame::RemoteRequestFrame); } else { - QList tokens = line.mid(40, thisFrame.payload().length() * 3).split(' '); + QList tokens = line.mid(40, numBytes * 3).split(' '); thisFrame.setFrameType(QCanBusFrame::DataFrame); for (int d = 0; d < numBytes; d++) {