diff --git a/communication/decoder.cpp b/communication/decoder.cpp index 8c756ad..5499ed9 100644 --- a/communication/decoder.cpp +++ b/communication/decoder.cpp @@ -40,6 +40,7 @@ bool Decoder::decode(std::shared_ptr& result, const std::shared_ptrdlc.DLC; + msg->dlcOnWire = length; // This will hold the real DLC on wire 0x0 - 0xF if(data->header.EDL && data->timestamp.IsExtended) { // CAN FD msg->isCANFD = true; msg->baudrateSwitch = data->header.BRS; // CAN FD Baudrate Switch @@ -70,6 +71,10 @@ bool Decoder::decode(std::shared_ptr& result, const std::shared_ptr 8) { // This is a standard CAN frame with a length of more than 8 + // Yes, this is possible. On the wire, the length field is a nibble, and we do want to return an accurate value + // We don't want to overread our buffer, though, so make sure we cap the length + length = 8; } // Data diff --git a/communication/message/include/canmessage.h b/communication/message/include/canmessage.h index bfcb109..ea750f1 100644 --- a/communication/message/include/canmessage.h +++ b/communication/message/include/canmessage.h @@ -8,6 +8,7 @@ namespace icsneo { class CANMessage : public Message { public: uint32_t arbid; + uint8_t dlcOnWire; bool isRemote = false; bool isExtended = false; bool isCANFD = false; diff --git a/communication/message/include/neomessage.h b/communication/message/include/neomessage.h index d886449..ef10c79 100644 --- a/communication/message/include/neomessage.h +++ b/communication/message/include/neomessage.h @@ -112,7 +112,8 @@ typedef struct { uint32_t arbid; uint16_t netid; uint8_t type; - char reserved[9]; + uint8_t dlcOnWire; + char reserved[8]; } neomessage_can_t; #pragma pack(pop) diff --git a/communication/message/neomessage.cpp b/communication/message/neomessage.cpp index 497212e..97aa0fa 100644 --- a/communication/message/neomessage.cpp +++ b/communication/message/neomessage.cpp @@ -19,6 +19,7 @@ neomessage_t icsneo::CreateNeoMessage(const std::shared_ptr message) { neomessage_can_t& can = *(neomessage_can_t*)&neomsg; auto canmsg = std::static_pointer_cast(message); can.arbid = canmsg->arbid; + can.dlcOnWire = canmsg->dlcOnWire; can.status.extendedFrame = canmsg->isExtended; can.status.remoteFrame = canmsg->isRemote; can.status.canfdRTR = canmsg->isRemote;