Fix signal interpretation when signals get near the end of the 64 bits.
This commit is contained in:
@@ -67,22 +67,12 @@ bool DBC_SIGNAL::processAsText(const CANFrame &frame, QString &outString)
|
|||||||
if (valType == SIGNED_INT) isSigned = true;
|
if (valType == SIGNED_INT) isSigned = true;
|
||||||
if (valType == SIGNED_INT || valType == UNSIGNED_INT)
|
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);
|
result = Utility::processIntegerSignal(frame.data, startBit, signalSize, intelByteOrder, isSigned);
|
||||||
endResult = ((double)result * factor) + bias;
|
endResult = ((double)result * factor) + bias;
|
||||||
result = (int64_t)endResult;
|
result = (int64_t)endResult;
|
||||||
}
|
}
|
||||||
else if (valType == SP_FLOAT)
|
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
|
//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
|
//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
|
//that the bytes that make up the integer are instead treated as having made up
|
||||||
|
|||||||
@@ -189,8 +189,10 @@ public:
|
|||||||
bit = startBit;
|
bit = startBit;
|
||||||
for (int bitpos = 0; bitpos < sigSize; bitpos++)
|
for (int bitpos = 0; bitpos < sigSize; bitpos++)
|
||||||
{
|
{
|
||||||
|
if (bit < 64) {
|
||||||
if (data[bit / 8] & (1 << (bit % 8)))
|
if (data[bit / 8] & (1 << (bit % 8)))
|
||||||
result += (1ULL << bitpos);
|
result += (1ULL << bitpos);
|
||||||
|
}
|
||||||
bit++;
|
bit++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -199,8 +201,10 @@ public:
|
|||||||
bit = startBit;
|
bit = startBit;
|
||||||
for (int bitpos = 0; bitpos < sigSize; bitpos++)
|
for (int bitpos = 0; bitpos < sigSize; bitpos++)
|
||||||
{
|
{
|
||||||
|
if (bit < 64) {
|
||||||
if (data[bit / 8] & (1 << (bit % 8)))
|
if (data[bit / 8] & (1 << (bit % 8)))
|
||||||
result += (1ULL << (sigSize - bitpos - 1));
|
result += (1ULL << (sigSize - bitpos - 1));
|
||||||
|
}
|
||||||
|
|
||||||
if ((bit % 8) == 0)
|
if ((bit % 8) == 0)
|
||||||
bit += 15;
|
bit += 15;
|
||||||
|
|||||||
Reference in New Issue
Block a user