Correctly unpack bytes from a cabana file

Frames were always showing up as 8 bytes and were padded with 0's from the left incorrectly
This commit is contained in:
Chris Whiteford
2021-07-08 21:12:26 -04:00
parent 3269fb2f74
commit 4fa194a4d4
+11 -1
View File
@@ -3966,7 +3966,17 @@ bool FrameFileIO::loadCabanaFile(QString filename, QVector<CANFrame>* frames)
bytes[6] = ((tempData >> 8) & 0xFF);
bytes[7] = (tempData & 0xFF);
}
thisFrame.setPayload(bytes);
// Shift the bytes back correctly so we have a frame that is the proper length
unsigned int framelength = tokens[3].length() / 2;
QByteArray finalbytes(framelength,0);
uint8_t bytes_shifted_by = 8 - framelength;
for (unsigned int j = 0; j < framelength; j++)
{
finalbytes[j] = bytes[j + bytes_shifted_by];
}
thisFrame.setPayload(finalbytes);
frames->append(thisFrame);
}
else foundErrors = true;