From 4fa194a4d436c0204852b6c0c44f54533014b553 Mon Sep 17 00:00:00 2001 From: Chris Whiteford Date: Thu, 8 Jul 2021 21:12:26 -0400 Subject: [PATCH] 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 --- framefileio.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/framefileio.cpp b/framefileio.cpp index 41f0434..043d19c 100644 --- a/framefileio.cpp +++ b/framefileio.cpp @@ -3966,7 +3966,17 @@ bool FrameFileIO::loadCabanaFile(QString filename, QVector* 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;