From fe7c50f8a35d5057e1888766a02af8b59328ee45 Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Tue, 19 Nov 2019 17:07:26 +0100 Subject: [PATCH] Correctly shift received data --- communication/packet/flexraypacket.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/communication/packet/flexraypacket.cpp b/communication/packet/flexraypacket.cpp index 9d30d3f..a2433a0 100644 --- a/communication/packet/flexraypacket.cpp +++ b/communication/packet/flexraypacket.cpp @@ -59,7 +59,8 @@ std::shared_ptr HardwareFlexRayPacket::DecodeToMessage(const std if(int64_t(numBytes) != int64_t(data->Length) - 4) { // This is an error, probably need to flag it } else { - msg->data = std::vector((const uint8_t*)(data + 1), (const uint8_t*)(data + 1) + numBytes); + const uint8_t* dataStart = (const uint8_t*)(data) - 4 + sizeof(HardwareFlexRayPacket); + msg->data = std::vector(dataStart, dataStart + numBytes); } } }