From 5b3e21fa7ca8dfa2c61105d8f36a0638eb177dca Mon Sep 17 00:00:00 2001 From: Kyle Johannes Date: Thu, 22 Jun 2023 18:17:00 +0000 Subject: [PATCH] LIN: C API protected ID automatic calculation --- api/icsneolegacy/icsneolegacy.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/api/icsneolegacy/icsneolegacy.cpp b/api/icsneolegacy/icsneolegacy.cpp index 51bf399..2527f4a 100644 --- a/api/icsneolegacy/icsneolegacy.cpp +++ b/api/icsneolegacy/icsneolegacy.cpp @@ -200,6 +200,11 @@ static bool SpyMessageToNeoMessage(const icsSpyMessage& oldmsg, neomessage_frame linFrame.linStatus.txResponder = true; copyFrameDataPtr(); + uint8_t protID = linFrame.header[0] & 0x3Fu; + auto bit = [&](uint8_t pos)->uint8_t { return ((protID >> pos) & 0x1u); }; + protID |= (~(bit(1) ^ bit(3) ^ bit(4) ^ bit(5)) << 7); + protID |= ((bit(0) ^ bit(1) ^ bit(2) ^ bit(4)) << 6); + linFrame.header[0] = protID; if (frame.length > 2) { size_t checksum = 0; uint8_t* lastByte = nullptr;