diff --git a/dbc/dbc_classes.cpp b/dbc/dbc_classes.cpp index 67c2bf8..7d8f013 100644 --- a/dbc/dbc_classes.cpp +++ b/dbc/dbc_classes.cpp @@ -67,22 +67,12 @@ bool DBC_SIGNAL::processAsText(const CANFrame &frame, QString &outString) if (valType == SIGNED_INT) isSigned = true; if (valType == SIGNED_INT || valType == UNSIGNED_INT) { - if ( frame.len*8 < (startBit+signalSize) ) - { - result = 0; - return false; - } result = Utility::processIntegerSignal(frame.data, startBit, signalSize, intelByteOrder, isSigned); endResult = ((double)result * factor) + bias; result = (int64_t)endResult; } else if (valType == SP_FLOAT) { - if ( frame.len*8 < (startBit+32) ) - { - result = 0; - return false; - } //The theory here is that we force the integer signal code to treat this as //a 32 bit unsigned integer. This integer is then cast into a float in such a way //that the bytes that make up the integer are instead treated as having made up diff --git a/framefileio.cpp b/framefileio.cpp index 502884b..d0be115 100644 --- a/framefileio.cpp +++ b/framefileio.cpp @@ -240,6 +240,7 @@ bool FrameFileIO::loadVehicleSpyFile(QString filename, QVector *frames if (tokens.length() > 20) { thisFrame.bus = 0; + thisFrame.remote = false; tempTime = now; tempTime.addMSecs(tokens[1].toDouble() * 1000.0); thisFrame.timestamp = tempTime.toMSecsSinceEpoch() * 1000ul; @@ -350,6 +351,7 @@ bool FrameFileIO::loadCRTDFile(QString filename, QVector* frames) else thisFrame.isReceived = true; thisFrame.bus = 0; thisFrame.len = tokens.length() - 3; + thisFrame.remote = false; for (unsigned int d = 0; d < thisFrame.len; d++) { if (tokens[d + 3] != "") @@ -418,6 +420,7 @@ bool FrameFileIO::loadCANHackerFile(QString filename, QVector* frames) thisFrame.ID = tokens[1].toInt(NULL, 16); thisFrame.extended = (thisFrame.ID > 0x7FF); thisFrame.isReceived = true; + thisFrame.remote = false; thisFrame.bus = 0; thisFrame.len = tokens[2].toInt(NULL, 16); for (unsigned int d = 0; d < thisFrame.len; d++) @@ -717,7 +720,7 @@ bool FrameFileIO::loadNativeCSVFile(QString filename, QVector* frames) lineCounter = 0; } - line = inFile->readLine(); + line = inFile->readLine().simplified(); if (line.length() > 2) { QList tokens = line.split(','); @@ -738,6 +741,8 @@ bool FrameFileIO::loadNativeCSVFile(QString filename, QVector* frames) if (tokens[2].toUpper().contains("TRUE")) thisFrame.extended = 1; else thisFrame.extended = 0; + thisFrame.remote = false; + if (fileVersion == 1) { thisFrame.isReceived = true; @@ -950,6 +955,7 @@ bool FrameFileIO::loadGenericCSVFile(QString filename, QVector* frames if (thisFrame.ID > 0x7FF) thisFrame.extended = true; else thisFrame.extended = false; thisFrame.bus = 0; + thisFrame.remote = false; QList dataTok = tokens[1].split(' '); thisFrame.len = dataTok.length(); if (thisFrame.len > 8) thisFrame.len = 8; @@ -1240,6 +1246,7 @@ bool FrameFileIO::loadIXXATFile(QString filename, QVector* frames) thisFrame.isReceived = true; thisFrame.bus = 0; + thisFrame.remote = false; QStringList dataToks = Utility::unQuote(tokens[4]).simplified().split(' '); thisFrame.len = dataToks.length(); @@ -1343,6 +1350,7 @@ bool FrameFileIO::loadCANDOFile(QString filename, QVector* frames) thisFrame.bus = 0; thisFrame.isReceived = true; thisFrame.extended = false; //format is incapable of extended frames + thisFrame.remote = false; thisFrame.timestamp = 1000000ul * ((unsigned char)data[0] >> 2); thisFrame.timestamp += (((data[0] & 3) << 8) + (unsigned char)data[1]) * 1000; @@ -1476,6 +1484,7 @@ bool FrameFileIO::loadMicrochipFile(QString filename, QVector* frames) thisFrame.timestamp = timeStamp; if (tokens[1].at(0) == 'R') thisFrame.isReceived = true; else thisFrame.isReceived = false; + thisFrame.remote = false; thisFrame.ID = Utility::ParseStringToNum(tokens[2]); if (thisFrame.ID <= 0x7FF) thisFrame.extended = false; else thisFrame.extended = true; @@ -1639,6 +1648,7 @@ bool FrameFileIO::loadTraceFile(QString filename, QVector* frames) if (thisFrame.ID <= 0x7FF) thisFrame.extended = false; else thisFrame.extended = true; thisFrame.bus = 0; + thisFrame.remote = false; thisFrame.len = tokens[3].toUInt(); if (thisFrame.len > 8) thisFrame.len = 8; QList dataToks = tokens[4].split(' '); @@ -1927,6 +1937,7 @@ bool FrameFileIO::loadKvaserFile(QString filename, QVector *frames, bo thisFrame.ID = line.mid(4,10).simplified().toInt(NULL, base); if (thisFrame.ID > 0x7FF) thisFrame.extended = true; else thisFrame.extended = false; + thisFrame.remote = false; thisFrame.len = line.mid(21, 3).simplified().toInt(); for (int i = 0; i < 8; i++) { thisFrame.data[i] = line.mid(25 + i * 4, 3).simplified().toInt(NULL, base); diff --git a/utility.h b/utility.h index 09ec074..ec62b7e 100644 --- a/utility.h +++ b/utility.h @@ -189,8 +189,10 @@ public: bit = startBit; for (int bitpos = 0; bitpos < sigSize; bitpos++) { - if (data[bit / 8] & (1 << (bit % 8))) - result += (1ULL << bitpos); + if (bit < 64) { + if (data[bit / 8] & (1 << (bit % 8))) + result += (1ULL << bitpos); + } bit++; } } @@ -199,8 +201,10 @@ public: bit = startBit; for (int bitpos = 0; bitpos < sigSize; bitpos++) { - if (data[bit / 8] & (1 << (bit % 8))) - result += (1ULL << (sigSize - bitpos - 1)); + if (bit < 64) { + if (data[bit / 8] & (1 << (bit % 8))) + result += (1ULL << (sigSize - bitpos - 1)); + } if ((bit % 8) == 0) bit += 15;