From ce172e0e26b952bda038712f6138b9b57026a595 Mon Sep 17 00:00:00 2001 From: Andrey Gusakov Date: Wed, 6 Dec 2023 23:19:42 +0300 Subject: [PATCH] can: add counter to last byte of StandartData and DiagData --- firmware/can.cpp | 5 +++++ for_rusefi/wideband_can.h | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/firmware/can.cpp b/firmware/can.cpp index 470b9394..eea6da12 100644 --- a/firmware/can.cpp +++ b/firmware/can.cpp @@ -139,6 +139,7 @@ void InitCan() void SendRusefiFormat(uint8_t ch) { + uint8_t counter = 0; auto baseAddress = WB_DATA_BASE_ADDR + 2 * (ch + configuration->CanIndexOffset); const auto& sampler = GetSampler(ch); @@ -158,6 +159,7 @@ void SendRusefiFormat(uint8_t ch) bool heaterClosedLoop = heater.IsRunningClosedLoop(); bool nernstValid = nernstDc > (NERNST_TARGET - 0.1f) && nernstDc < (NERNST_TARGET + 0.1f); frame.get().Valid = (heaterClosedLoop && nernstValid) ? 0x01 : 0x00; + frame.get().counter = counter; } { @@ -170,7 +172,10 @@ void SendRusefiFormat(uint8_t ch) frame.get().PumpDuty = GetPumpOutputDuty(ch) * 255; frame.get().Status = GetCurrentFault(ch); frame.get().HeaterDuty = GetHeaterDuty(ch) * 255; + frame.get().counter = counter; } + + counter++; } // Weak link so boards can override it diff --git a/for_rusefi/wideband_can.h b/for_rusefi/wideband_can.h index 01f79371..da9102eb 100644 --- a/for_rusefi/wideband_can.h +++ b/for_rusefi/wideband_can.h @@ -52,7 +52,9 @@ struct StandardData uint16_t Lambda; uint16_t TemperatureC; - uint16_t pad; + uint8_t pad; + + uint8_t counter; }; struct DiagData @@ -63,7 +65,7 @@ struct DiagData Fault Status; uint8_t HeaterDuty; - uint8_t pad; + uint8_t counter; }; static inline const char* describeFault(Fault fault) {