From 39f07fac32b9b06cbf574b9f1acb54c869ac8d7e Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Wed, 13 Feb 2019 20:58:30 -0500 Subject: [PATCH] Fixed Vector ASC loading to work a bit better --- framefileio.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/framefileio.cpp b/framefileio.cpp index d0be115..29b866a 100644 --- a/framefileio.cpp +++ b/framefileio.cpp @@ -655,25 +655,28 @@ bool FrameFileIO::loadCanalyzerASC(QString filename, QVector* frames) } if (inHeader) continue; if (line.length() > 2) - { + { QList tokens = line.simplified().split(' '); - thisFrame.timestamp = (uint32_t)(tokens[0].toFloat() * 1000000.0); - thisFrame.ID = tokens[2].toUInt(NULL, 16); - thisFrame.len = tokens[5].toUInt(); - thisFrame.isReceived = tokens[3].toUpper().contains("RX"); - thisFrame.bus = tokens[1].toUInt(); - thisFrame.extended = (thisFrame.ID > 0x7FF); - thisFrame.remote = false; - for (unsigned int d = 6; d < (6 + thisFrame.len); d++) + if (tokens.length() > 4) { - if (tokens.count() > d) - { - thisFrame.data[d - 6] = tokens[d].toInt(NULL, 16); - } - else //expected byte wasn't there to read. Set it zero and set error flag + thisFrame.timestamp = (uint32_t)(tokens[0].toFloat() * 1000000.0); + thisFrame.ID = tokens[2].toUInt(NULL, 16); + thisFrame.len = tokens[5].toUInt(); + thisFrame.isReceived = tokens[3].toUpper().contains("RX"); + thisFrame.bus = tokens[1].toUInt(); + thisFrame.extended = (thisFrame.ID > 0x7FF); + thisFrame.remote = false; + for (unsigned int d = 6; d < (6 + thisFrame.len); d++) { + if (tokens.count() > d) + { + thisFrame.data[d - 6] = tokens[d].toInt(NULL, 16); + } + else //expected byte wasn't there to read. Set it zero and set error flag + { thisFrame.data[d - 6] = 0; foundErrors = true; + } } } frames->append(thisFrame);