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/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;