From fea15f24e8ffc34b6c92e776ea96b677fdd4bb5b Mon Sep 17 00:00:00 2001 From: cfif Date: Mon, 8 Jun 2026 12:38:53 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=BB=D0=B0=D1=82=D1=8B=20=D0=BD?= =?UTF-8?q?=D0=B0=20V2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CanSpamTransmitter.c | 13 ++++++++----- CanSpamTransmitter.h | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CanSpamTransmitter.c b/CanSpamTransmitter.c index 8d01374..91dccac 100644 --- a/CanSpamTransmitter.c +++ b/CanSpamTransmitter.c @@ -102,7 +102,7 @@ static eTimeEventTransmit isEventTransmitter(tCanSpamTransmitter *env) { env->time_CCU_HVC_Req_Msg = env->timeMs + CCU_HVC_Req_Msg_CYC; // Rolling Counter [0 - 15] - if (env->CCU_HVC_Req_Msg_CCU_HVC_Req_RC > 15) { + if (env->CCU_HVC_Req_Msg_CCU_HVC_Req_RC >= 15) { env->CCU_HVC_Req_Msg_CCU_HVC_Req_RC = 0; } else { ++env->CCU_HVC_Req_Msg_CCU_HVC_Req_RC; @@ -174,12 +174,15 @@ static eTimeEventTransmit isEventTransmitter(tCanSpamTransmitter *env) { env->time_CCU_Msg1 = env->timeMs + CCU_Msg1_CYC; // Rolling Counter [0 - 15] - if (ccu_candb_tx.CCU_Msg1.CCU_MSG1_RC > 15) { - ccu_candb_tx.CCU_Msg1.CCU_MSG1_RC = 0; + if (env->CCU_Msg1_CCU_MSG1_RC >= 15) { + env->CCU_Msg1_CCU_MSG1_RC = 0; } else { - ++ccu_candb_tx.CCU_Msg1.CCU_MSG1_RC; + ++env->CCU_Msg1_CCU_MSG1_RC; } + ccu_candb_tx.CCU_Msg1.CCU_MSG1_RC = env->CCU_Msg1_CCU_MSG1_RC; + + // Checksum XOR8 of the data field this message // Checksum computed as per XOR algorithm: // Byte 1 XOR byte 2 .... XOR byte n-1. (n = packet length.) @@ -217,7 +220,7 @@ static eTimeEventTransmit isEventTransmitter(tCanSpamTransmitter *env) { env->time_CCU_Msg3 = env->timeMs + CCU_Msg3_CYC; // Rolling Counter [0 - 15] - if (env->CCU_Msg3_CCU_MSG3_RC > 15) { + if (env->CCU_Msg3_CCU_MSG3_RC >= 15) { env->CCU_Msg3_CCU_MSG3_RC = 0; } else { ++env->CCU_Msg3_CCU_MSG3_RC; diff --git a/CanSpamTransmitter.h b/CanSpamTransmitter.h index 22f5bcc..17fb762 100644 --- a/CanSpamTransmitter.h +++ b/CanSpamTransmitter.h @@ -62,6 +62,7 @@ typedef struct { uint32_t time_CCU_AC_Ctrl; uint8_t CCU_HVC_Req_Msg_CCU_HVC_Req_RC; + uint8_t CCU_Msg1_CCU_MSG1_RC; uint8_t CCU_Msg3_CCU_MSG3_RC; bool isMute;