+13
-13
@@ -48,7 +48,7 @@ bool DBC_SIGNAL::processAsText(const CANFrame &frame, QString &outString, bool o
|
||||
QString buildString;
|
||||
int startByte = startBit / 8;
|
||||
int bytes = signalSize / 8;
|
||||
for (int x = 0; x < bytes; x++) buildString.append(frame.data[startByte + x]);
|
||||
for (int x = 0; x < bytes; x++) buildString.append(frame.payload().data()[startByte + x]);
|
||||
outString = buildString;
|
||||
cachedValue = outString;
|
||||
return true;
|
||||
@@ -69,7 +69,7 @@ bool DBC_SIGNAL::processAsText(const CANFrame &frame, QString &outString, bool o
|
||||
if (valType == SIGNED_INT) isSigned = true;
|
||||
if (valType == SIGNED_INT || valType == UNSIGNED_INT)
|
||||
{
|
||||
result = Utility::processIntegerSignal(frame.data, startBit, signalSize, intelByteOrder, isSigned);
|
||||
result = Utility::processIntegerSignal(frame.payload(), startBit, signalSize, intelByteOrder, isSigned);
|
||||
endResult = ((double)result * factor) + bias;
|
||||
result = (int64_t)endResult;
|
||||
// if factor is an integer, we don't need the possibly human-unreadable float representation
|
||||
@@ -82,19 +82,19 @@ bool DBC_SIGNAL::processAsText(const CANFrame &frame, QString &outString, bool o
|
||||
//that the bytes that make up the integer are instead treated as having made up
|
||||
//a 32 bit single precision float. That's evil incarnate but it is very fast and small
|
||||
//in terms of new code.
|
||||
result = Utility::processIntegerSignal(frame.data, startBit, 32, intelByteOrder, false);
|
||||
result = Utility::processIntegerSignal(frame.payload(), startBit, 32, intelByteOrder, false);
|
||||
endResult = (*((float *)(&result)) * factor) + bias;
|
||||
}
|
||||
else //double precision float
|
||||
{
|
||||
if ( frame.len < 8 )
|
||||
if ( frame.payload().length() < 8 )
|
||||
{
|
||||
result = 0;
|
||||
return false;
|
||||
}
|
||||
//like the above, this is rotten and evil and wrong in so many ways. Force
|
||||
//calculation of a 64 bit integer and then cast it into a double.
|
||||
result = Utility::processIntegerSignal(frame.data, 0, 64, intelByteOrder, false);
|
||||
result = Utility::processIntegerSignal(frame.payload(), 0, 64, intelByteOrder, false);
|
||||
endResult = (*((double *)(&result)) * factor) + bias;
|
||||
}
|
||||
|
||||
@@ -158,13 +158,13 @@ bool DBC_SIGNAL::processAsInt(const CANFrame &frame, int32_t &outValue)
|
||||
}
|
||||
|
||||
if (valType == SIGNED_INT) isSigned = true;
|
||||
if ( static_cast<int>(frame.len * 8) < (startBit + signalSize) )
|
||||
if ( static_cast<int>(frame.payload().length() * 8) < (startBit + signalSize) )
|
||||
{
|
||||
result = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
result = static_cast<int32_t>(Utility::processIntegerSignal(frame.data, startBit, signalSize, intelByteOrder, isSigned));
|
||||
result = static_cast<int32_t>(Utility::processIntegerSignal(frame.payload(), startBit, signalSize, intelByteOrder, isSigned));
|
||||
|
||||
double endResult = (result * factor) + bias;
|
||||
result = static_cast<int32_t>(endResult);
|
||||
@@ -203,19 +203,19 @@ bool DBC_SIGNAL::processAsDouble(const CANFrame &frame, double &outValue)
|
||||
if (valType == SIGNED_INT) isSigned = true;
|
||||
if (valType == SIGNED_INT || valType == UNSIGNED_INT)
|
||||
{
|
||||
if ( frame.len*8 < (startBit+signalSize) )
|
||||
if ( frame.payload().length() * 8 < (startBit+signalSize) )
|
||||
{
|
||||
result = 0;
|
||||
return false;
|
||||
}
|
||||
result = Utility::processIntegerSignal(frame.data, startBit, signalSize, intelByteOrder, isSigned);
|
||||
result = Utility::processIntegerSignal(frame.payload(), startBit, signalSize, intelByteOrder, isSigned);
|
||||
endResult = ((double)result * factor) + bias;
|
||||
result = (int64_t)endResult;
|
||||
}
|
||||
/*TODO: It should be noted that the below floating point has not even been tested. For shame! Test it!*/
|
||||
else if (valType == SP_FLOAT)
|
||||
{
|
||||
if ( frame.len*8 < (startBit+32) )
|
||||
if ( frame.payload().length() * 8 < (startBit + 32) )
|
||||
{
|
||||
result = 0;
|
||||
return false;
|
||||
@@ -225,19 +225,19 @@ bool DBC_SIGNAL::processAsDouble(const CANFrame &frame, double &outValue)
|
||||
//that the bytes that make up the integer are instead treated as having made up
|
||||
//a 32 bit single precision float. That's evil incarnate but it is very fast and small
|
||||
//in terms of new code.
|
||||
result = Utility::processIntegerSignal(frame.data, startBit, 32, false, false);
|
||||
result = Utility::processIntegerSignal(frame.payload(), startBit, 32, false, false);
|
||||
endResult = (*((float *)(&result)) * factor) + bias;
|
||||
}
|
||||
else //double precision float
|
||||
{
|
||||
if ( frame.len < 8 )
|
||||
if ( frame.payload().length() < 8 )
|
||||
{
|
||||
result = 0;
|
||||
return false;
|
||||
}
|
||||
//like the above, this is rotten and evil and wrong in so many ways. Force
|
||||
//calculation of a 64 bit integer and then cast it into a double.
|
||||
result = Utility::processIntegerSignal(frame.data, 0, 64, false, false);
|
||||
result = Utility::processIntegerSignal(frame.payload(), 0, 64, false, false);
|
||||
endResult = (*((double *)(&result)) * factor) + bias;
|
||||
}
|
||||
cachedValue = endResult;
|
||||
|
||||
Reference in New Issue
Block a user