From a327e080ced1aff8e8f54e619ed844b1eef6365d Mon Sep 17 00:00:00 2001 From: khoulihan27 Date: Mon, 16 Feb 2026 15:07:59 -0800 Subject: [PATCH 01/15] init w/ temp pinging file --- ECU/Application/Src/Pinging.c | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 ECU/Application/Src/Pinging.c diff --git a/ECU/Application/Src/Pinging.c b/ECU/Application/Src/Pinging.c new file mode 100644 index 000000000..e69de29bb From 9bad69b9c222e4a0c7f92a9115488a6d905ebde9 Mon Sep 17 00:00:00 2001 From: khoulihan27 Date: Mon, 16 Feb 2026 15:07:59 -0800 Subject: [PATCH 02/15] init w/ temp pinging file --- ECU/Application/Src/Pinging.c | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 ECU/Application/Src/Pinging.c diff --git a/ECU/Application/Src/Pinging.c b/ECU/Application/Src/Pinging.c new file mode 100644 index 000000000..e69de29bb From b0f474898d8fc98171dd6fd385704eb01e7c0bed Mon Sep 17 00:00:00 2001 From: Casey Zwicker Date: Thu, 19 Feb 2026 21:53:48 -0800 Subject: [PATCH 03/15] MVP --- ECU/Application/Inc/Pinging.h | 14 ++++++++++ ECU/Application/Src/CANdler.c | 3 ++- ECU/Application/Src/Pinging.c | 51 +++++++++++++++++++++++++++++++++++ ECU/CMakeLists.txt | 1 + ECU/Core/Src/main.c | 10 ++++++- 5 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 ECU/Application/Inc/Pinging.h diff --git a/ECU/Application/Inc/Pinging.h b/ECU/Application/Inc/Pinging.h new file mode 100644 index 000000000..da546ab5d --- /dev/null +++ b/ECU/Application/Inc/Pinging.h @@ -0,0 +1,14 @@ +#include + +#ifndef PINGING_H +#define PINGING_H + +#define PINGTIMEOUT 250 + + +void pingAll(void); // ping all IDs specified, to be run every PINGTIMEOUT milliseconds +uint32_t getRTT(uint8_t id); // get latest RTT by ID +void respondToPing(uint8_t srcID, uint32_t timestamp); // "callback" + + +#endif diff --git a/ECU/Application/Src/CANdler.c b/ECU/Application/Src/CANdler.c index cd12c47e9..12d55464c 100644 --- a/ECU/Application/Src/CANdler.c +++ b/ECU/Application/Src/CANdler.c @@ -8,6 +8,7 @@ #include "Logomatic.h" #include "StateData.h" #include "bitManipulations.h" +#include "Pinging.h" extern ECU_StateData stateLump; @@ -48,7 +49,7 @@ void ECU_CAN_MessageHandler(ECU_StateData *state_data, GR_OLD_BUS_ID bus_id, GR_ ReportBadMessageLength(bus_id, msg_id, sender_id); break; } - // TODO See Issue #143 + respondToPing(sender_id, ((GR_OLD_PING_MSG *)data)->timestamp); break; case MSG_BCU_STATUS_1: diff --git a/ECU/Application/Src/Pinging.c b/ECU/Application/Src/Pinging.c index e69de29bb..3a3012018 100644 --- a/ECU/Application/Src/Pinging.c +++ b/ECU/Application/Src/Pinging.c @@ -0,0 +1,51 @@ +#include "Pinging.h" +#include "GR_OLD_NODE_ID.h" +#include "GR_OLD_MSG_ID.h" +#include "GR_OLD_MSG_DAT.h" +#include "StateUtils.h" +#include "CANutils.h" + + +const uint8_t IDsToBePinged[] = { + GR_BCU, + GR_DASH_PANEL, + //GR_CCU, +}; + +const uint8_t PingsToBeIDed[] = { + [GR_BCU] = 0, + [GR_DASH_PANEL] = 1 +}; + +static uint32_t sentTimestamps[sizeof(IDsToBePinged)]; +static uint32_t receivedTimestamps[sizeof(IDsToBePinged)]; +static uint8_t RTTs[sizeof(IDsToBePinged)]; + +void pingAll(void) { + for(uint8_t i = 0; i < sizeof(IDsToBePinged); i++) { + uint32_t timestamp = MillisecondsSinceBoot(); + + if(receivedTimestamps[i] >= sentTimestamps[i]) { + // no timeout + RTTs[i] = receivedTimestamps[i] - sentTimestamps[i]; + } else { + // timeout + RTTs[i] = 255; + } + + sentTimestamps[i] = timestamp; + ECU_CAN_Send(GR_OLD_BUS_PRIMARY, IDsToBePinged[i], MSG_PING, &(GR_OLD_PING_MSG){timestamp}, sizeof(GR_OLD_PING_MSG)); + } +} + +uint32_t getRTT(uint8_t ID) { + return RTTs[PingsToBeIDed[ID]]; +} + + +void respondToPing(uint8_t srcID, uint32_t timestamp) { + uint8_t index = PingsToBeIDed[srcID]; + if(timestamp == sentTimestamps[index]) { + receivedTimestamps[index] = MillisecondsSinceBoot(); + } +} diff --git a/ECU/CMakeLists.txt b/ECU/CMakeLists.txt index f2cd5ca54..0a1a887c9 100644 --- a/ECU/CMakeLists.txt +++ b/ECU/CMakeLists.txt @@ -80,6 +80,7 @@ target_sources( Application/Src/StateTicks.c Application/Src/StateUtils.c Application/Src/CANutils.c + Application/Src/Pinging.c ) target_link_libraries( diff --git a/ECU/Core/Src/main.c b/ECU/Core/Src/main.c index f9c541989..1ffbeb9d6 100644 --- a/ECU/Core/Src/main.c +++ b/ECU/Core/Src/main.c @@ -38,6 +38,7 @@ #include "StateUtils.h" #include "adc.h" #include "can.h" +#include "Pinging.h" /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -433,10 +434,17 @@ int main(void) // TODO: determine alpha ADC_UpdateAnalogValues_EMA(ADC_buffers, NUM_SIGNALS, 0.3, ADC_outputs); SendECUStateDataOverCAN(&stateLump); + + static uint32_t nextPing; + if(MillisecondsSinceBoot() >= nextPing) { + pingAll(); + nextPing += PINGTIMEOUT; + } + + write_adc_values_to_state_data(); ECU_State_Tick(); LOGOMATIC("Main Loop Tick Complete. I use Arch btw\n"); - LL_mDelay(250); // FIXME Reduce or remove de } /* USER CODE END 3 */ } From 6254e3baf3b84ef86633c8149750ea69429cf708 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 20 Feb 2026 06:22:20 +0000 Subject: [PATCH 04/15] Automatic Clang-Format: Standardized formatting automatically --- ECU/Application/Inc/Pinging.h | 6 ++-- ECU/Application/Src/CANdler.c | 2 +- ECU/Application/Src/Pinging.c | 66 +++++++++++++++++------------------ ECU/Core/Src/main.c | 5 ++- 4 files changed, 37 insertions(+), 42 deletions(-) diff --git a/ECU/Application/Inc/Pinging.h b/ECU/Application/Inc/Pinging.h index da546ab5d..04be80fca 100644 --- a/ECU/Application/Inc/Pinging.h +++ b/ECU/Application/Inc/Pinging.h @@ -5,10 +5,8 @@ #define PINGTIMEOUT 250 - -void pingAll(void); // ping all IDs specified, to be run every PINGTIMEOUT milliseconds -uint32_t getRTT(uint8_t id); // get latest RTT by ID +void pingAll(void); // ping all IDs specified, to be run every PINGTIMEOUT milliseconds +uint32_t getRTT(uint8_t id); // get latest RTT by ID void respondToPing(uint8_t srcID, uint32_t timestamp); // "callback" - #endif diff --git a/ECU/Application/Src/CANdler.c b/ECU/Application/Src/CANdler.c index 12d55464c..f00fa29e1 100644 --- a/ECU/Application/Src/CANdler.c +++ b/ECU/Application/Src/CANdler.c @@ -6,9 +6,9 @@ #include "GR_OLD_MSG_ID.h" #include "GR_OLD_NODE_ID.h" #include "Logomatic.h" +#include "Pinging.h" #include "StateData.h" #include "bitManipulations.h" -#include "Pinging.h" extern ECU_StateData stateLump; diff --git a/ECU/Application/Src/Pinging.c b/ECU/Application/Src/Pinging.c index 3a3012018..8e75a2c5a 100644 --- a/ECU/Application/Src/Pinging.c +++ b/ECU/Application/Src/Pinging.c @@ -1,51 +1,49 @@ #include "Pinging.h" -#include "GR_OLD_NODE_ID.h" -#include "GR_OLD_MSG_ID.h" + +#include "CANutils.h" #include "GR_OLD_MSG_DAT.h" +#include "GR_OLD_MSG_ID.h" +#include "GR_OLD_NODE_ID.h" #include "StateUtils.h" -#include "CANutils.h" - const uint8_t IDsToBePinged[] = { - GR_BCU, - GR_DASH_PANEL, - //GR_CCU, + GR_BCU, GR_DASH_PANEL, + // GR_CCU, }; -const uint8_t PingsToBeIDed[] = { - [GR_BCU] = 0, - [GR_DASH_PANEL] = 1 -}; +const uint8_t PingsToBeIDed[] = {[GR_BCU] = 0, [GR_DASH_PANEL] = 1}; static uint32_t sentTimestamps[sizeof(IDsToBePinged)]; static uint32_t receivedTimestamps[sizeof(IDsToBePinged)]; static uint8_t RTTs[sizeof(IDsToBePinged)]; -void pingAll(void) { - for(uint8_t i = 0; i < sizeof(IDsToBePinged); i++) { - uint32_t timestamp = MillisecondsSinceBoot(); - - if(receivedTimestamps[i] >= sentTimestamps[i]) { - // no timeout - RTTs[i] = receivedTimestamps[i] - sentTimestamps[i]; - } else { - // timeout - RTTs[i] = 255; - } - - sentTimestamps[i] = timestamp; - ECU_CAN_Send(GR_OLD_BUS_PRIMARY, IDsToBePinged[i], MSG_PING, &(GR_OLD_PING_MSG){timestamp}, sizeof(GR_OLD_PING_MSG)); - } +void pingAll(void) +{ + for (uint8_t i = 0; i < sizeof(IDsToBePinged); i++) { + uint32_t timestamp = MillisecondsSinceBoot(); + + if (receivedTimestamps[i] >= sentTimestamps[i]) { + // no timeout + RTTs[i] = receivedTimestamps[i] - sentTimestamps[i]; + } else { + // timeout + RTTs[i] = 255; + } + + sentTimestamps[i] = timestamp; + ECU_CAN_Send(GR_OLD_BUS_PRIMARY, IDsToBePinged[i], MSG_PING, &(GR_OLD_PING_MSG){timestamp}, sizeof(GR_OLD_PING_MSG)); + } } -uint32_t getRTT(uint8_t ID) { - return RTTs[PingsToBeIDed[ID]]; +uint32_t getRTT(uint8_t ID) +{ + return RTTs[PingsToBeIDed[ID]]; } - -void respondToPing(uint8_t srcID, uint32_t timestamp) { - uint8_t index = PingsToBeIDed[srcID]; - if(timestamp == sentTimestamps[index]) { - receivedTimestamps[index] = MillisecondsSinceBoot(); - } +void respondToPing(uint8_t srcID, uint32_t timestamp) +{ + uint8_t index = PingsToBeIDed[srcID]; + if (timestamp == sentTimestamps[index]) { + receivedTimestamps[index] = MillisecondsSinceBoot(); + } } diff --git a/ECU/Core/Src/main.c b/ECU/Core/Src/main.c index 3b4bde2d0..1dcccec2e 100644 --- a/ECU/Core/Src/main.c +++ b/ECU/Core/Src/main.c @@ -35,11 +35,11 @@ #include "CANutils.h" #include "Lights.h" #include "Logomatic.h" +#include "Pinging.h" #include "StateTicks.h" #include "StateUtils.h" #include "adc.h" #include "can.h" -#include "Pinging.h" /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -438,12 +438,11 @@ int main(void) SendECUStateDataOverCAN(&stateLump); static uint32_t nextPing; - if(MillisecondsSinceBoot() >= nextPing) { + if (MillisecondsSinceBoot() >= nextPing) { pingAll(); nextPing += PINGTIMEOUT; } - write_adc_values_to_state_data(); ECU_State_Tick(); lightControl(&stateLump); From ecf53d8672a8d190384f47c178857942deb98780 Mon Sep 17 00:00:00 2001 From: Casey Zwicker Date: Thu, 19 Feb 2026 22:24:37 -0800 Subject: [PATCH 05/15] volatile --- ECU/Application/Src/Pinging.c | 4 ++-- ECU/Core/Src/main.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ECU/Application/Src/Pinging.c b/ECU/Application/Src/Pinging.c index 8e75a2c5a..4834c17bc 100644 --- a/ECU/Application/Src/Pinging.c +++ b/ECU/Application/Src/Pinging.c @@ -13,8 +13,8 @@ const uint8_t IDsToBePinged[] = { const uint8_t PingsToBeIDed[] = {[GR_BCU] = 0, [GR_DASH_PANEL] = 1}; -static uint32_t sentTimestamps[sizeof(IDsToBePinged)]; -static uint32_t receivedTimestamps[sizeof(IDsToBePinged)]; +static volatile uint32_t sentTimestamps[sizeof(IDsToBePinged)]; +static volatile uint32_t receivedTimestamps[sizeof(IDsToBePinged)]; static uint8_t RTTs[sizeof(IDsToBePinged)]; void pingAll(void) diff --git a/ECU/Core/Src/main.c b/ECU/Core/Src/main.c index 1dcccec2e..f309b5bbf 100644 --- a/ECU/Core/Src/main.c +++ b/ECU/Core/Src/main.c @@ -440,7 +440,7 @@ int main(void) static uint32_t nextPing; if (MillisecondsSinceBoot() >= nextPing) { pingAll(); - nextPing += PINGTIMEOUT; + nextPing = MillisecondsSinceBoot() + PINGTIMEOUT; } write_adc_values_to_state_data(); From 52dcc248a0173b336199c1f1500a33206364899f Mon Sep 17 00:00:00 2001 From: Casey Zwicker Date: Mon, 23 Feb 2026 20:10:17 -0800 Subject: [PATCH 06/15] Refactor ping timeout definitions and usage for consistency --- ECU/Application/Inc/Pinging.h | 5 +++-- ECU/Application/Src/Pinging.c | 24 ++++++++++++++++-------- ECU/Core/Src/main.c | 2 +- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/ECU/Application/Inc/Pinging.h b/ECU/Application/Inc/Pinging.h index 04be80fca..1108893b7 100644 --- a/ECU/Application/Inc/Pinging.h +++ b/ECU/Application/Inc/Pinging.h @@ -3,9 +3,10 @@ #ifndef PINGING_H #define PINGING_H -#define PINGTIMEOUT 250 +#define PINGTIMEOUT_TIME 250U +#define PINGTIMEOUT_VALUE 255U -void pingAll(void); // ping all IDs specified, to be run every PINGTIMEOUT milliseconds +void pingAll(void); // ping all IDs specified, to be run every PINGTIMEOUT_TIME milliseconds uint32_t getRTT(uint8_t id); // get latest RTT by ID void respondToPing(uint8_t srcID, uint32_t timestamp); // "callback" diff --git a/ECU/Application/Src/Pinging.c b/ECU/Application/Src/Pinging.c index 4834c17bc..c75fe4bf2 100644 --- a/ECU/Application/Src/Pinging.c +++ b/ECU/Application/Src/Pinging.c @@ -6,20 +6,28 @@ #include "GR_OLD_NODE_ID.h" #include "StateUtils.h" +// add node IDs of devices to be pinged here, and add their indices in here to Pings ToBe IDed const uint8_t IDsToBePinged[] = { - GR_BCU, GR_DASH_PANEL, - // GR_CCU, + GR_BCU, + GR_DASH_PANEL, + //GR_CCU }; -const uint8_t PingsToBeIDed[] = {[GR_BCU] = 0, [GR_DASH_PANEL] = 1}; +const uint8_t PingsToBeIDed[] = { + [GR_BCU] = 0, + [GR_DASH_PANEL] = 1, + //[GR_CCU] = 2 +}; + +#define NUMBER_OF_PING_DEVICES (sizeof(IDsToBePinged)/sizeof(IDsToBePinged[0])) -static volatile uint32_t sentTimestamps[sizeof(IDsToBePinged)]; -static volatile uint32_t receivedTimestamps[sizeof(IDsToBePinged)]; -static uint8_t RTTs[sizeof(IDsToBePinged)]; +static volatile uint32_t sentTimestamps[NUMBER_OF_PING_DEVICES]; +static volatile uint32_t receivedTimestamps[NUMBER_OF_PING_DEVICES]; +static uint8_t RTTs[NUMBER_OF_PING_DEVICES]; void pingAll(void) { - for (uint8_t i = 0; i < sizeof(IDsToBePinged); i++) { + for (uint8_t i = 0; i < NUMBER_OF_PING_DEVICES; i++) { uint32_t timestamp = MillisecondsSinceBoot(); if (receivedTimestamps[i] >= sentTimestamps[i]) { @@ -27,7 +35,7 @@ void pingAll(void) RTTs[i] = receivedTimestamps[i] - sentTimestamps[i]; } else { // timeout - RTTs[i] = 255; + RTTs[i] = PINGTIMEOUT_VALUE; } sentTimestamps[i] = timestamp; diff --git a/ECU/Core/Src/main.c b/ECU/Core/Src/main.c index f309b5bbf..e22269a6d 100644 --- a/ECU/Core/Src/main.c +++ b/ECU/Core/Src/main.c @@ -440,7 +440,7 @@ int main(void) static uint32_t nextPing; if (MillisecondsSinceBoot() >= nextPing) { pingAll(); - nextPing = MillisecondsSinceBoot() + PINGTIMEOUT; + nextPing = MillisecondsSinceBoot() + PINGTIMEOUT_TIME; } write_adc_values_to_state_data(); From fd39f1e659876e0eff9aebd4e56a3e680cf852ec Mon Sep 17 00:00:00 2001 From: Casey Zwicker Date: Mon, 23 Feb 2026 20:14:59 -0800 Subject: [PATCH 07/15] Log error for ping timeout --- ECU/Core/Src/main.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/ECU/Core/Src/main.c b/ECU/Core/Src/main.c index e22269a6d..2d64d092a 100644 --- a/ECU/Core/Src/main.c +++ b/ECU/Core/Src/main.c @@ -432,17 +432,25 @@ int main(void) /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ - read_digital(); - // TODO: determine alpha - ADC_UpdateAnalogValues_EMA(ADC_buffers, NUM_SIGNALS, 0.3, ADC_outputs); - SendECUStateDataOverCAN(&stateLump); - static uint32_t nextPing; if (MillisecondsSinceBoot() >= nextPing) { pingAll(); nextPing = MillisecondsSinceBoot() + PINGTIMEOUT_TIME; + + if(getRTT(GR_BCU) == PINGTIMEOUT_VALUE) { + LOGOMATIC("ERROR: BCU is not responding to pings!\n"); + } + if(getRTT(GR_DASH_PANEL) == PINGTIMEOUT_VALUE) { + LOGOMATIC("ERROR: Dash Panel is not responding to pings!\n"); + } } + read_digital(); + // TODO: determine alpha + ADC_UpdateAnalogValues_EMA(ADC_buffers, NUM_SIGNALS, 0.3, ADC_outputs); + SendECUStateDataOverCAN(&stateLump); + + write_adc_values_to_state_data(); ECU_State_Tick(); lightControl(&stateLump); From b7807284d304ed7b96d4905b6b54a006b43d5838 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 24 Feb 2026 04:16:12 +0000 Subject: [PATCH 08/15] Automatic Clang-Format: Standardized formatting automatically --- ECU/Application/Src/Pinging.c | 12 +++++------- ECU/Core/Src/main.c | 5 ++--- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/ECU/Application/Src/Pinging.c b/ECU/Application/Src/Pinging.c index c75fe4bf2..f5701211a 100644 --- a/ECU/Application/Src/Pinging.c +++ b/ECU/Application/Src/Pinging.c @@ -8,18 +8,16 @@ // add node IDs of devices to be pinged here, and add their indices in here to Pings ToBe IDed const uint8_t IDsToBePinged[] = { - GR_BCU, - GR_DASH_PANEL, - //GR_CCU + GR_BCU, GR_DASH_PANEL, + // GR_CCU }; const uint8_t PingsToBeIDed[] = { - [GR_BCU] = 0, - [GR_DASH_PANEL] = 1, - //[GR_CCU] = 2 + [GR_BCU] = 0, [GR_DASH_PANEL] = 1, + //[GR_CCU] = 2 }; -#define NUMBER_OF_PING_DEVICES (sizeof(IDsToBePinged)/sizeof(IDsToBePinged[0])) +#define NUMBER_OF_PING_DEVICES (sizeof(IDsToBePinged) / sizeof(IDsToBePinged[0])) static volatile uint32_t sentTimestamps[NUMBER_OF_PING_DEVICES]; static volatile uint32_t receivedTimestamps[NUMBER_OF_PING_DEVICES]; diff --git a/ECU/Core/Src/main.c b/ECU/Core/Src/main.c index 2d64d092a..2bd2d9117 100644 --- a/ECU/Core/Src/main.c +++ b/ECU/Core/Src/main.c @@ -437,10 +437,10 @@ int main(void) pingAll(); nextPing = MillisecondsSinceBoot() + PINGTIMEOUT_TIME; - if(getRTT(GR_BCU) == PINGTIMEOUT_VALUE) { + if (getRTT(GR_BCU) == PINGTIMEOUT_VALUE) { LOGOMATIC("ERROR: BCU is not responding to pings!\n"); } - if(getRTT(GR_DASH_PANEL) == PINGTIMEOUT_VALUE) { + if (getRTT(GR_DASH_PANEL) == PINGTIMEOUT_VALUE) { LOGOMATIC("ERROR: Dash Panel is not responding to pings!\n"); } } @@ -450,7 +450,6 @@ int main(void) ADC_UpdateAnalogValues_EMA(ADC_buffers, NUM_SIGNALS, 0.3, ADC_outputs); SendECUStateDataOverCAN(&stateLump); - write_adc_values_to_state_data(); ECU_State_Tick(); lightControl(&stateLump); From a622c5fff20624ab0d1a102659820665acea9093 Mon Sep 17 00:00:00 2001 From: Casey Zwicker Date: Mon, 23 Feb 2026 20:59:36 -0800 Subject: [PATCH 09/15] Add CCU functionality --- ECU/Application/Src/Pinging.c | 10 ++++++---- ECU/Core/Src/main.c | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/ECU/Application/Src/Pinging.c b/ECU/Application/Src/Pinging.c index f5701211a..a1efee16d 100644 --- a/ECU/Application/Src/Pinging.c +++ b/ECU/Application/Src/Pinging.c @@ -8,13 +8,15 @@ // add node IDs of devices to be pinged here, and add their indices in here to Pings ToBe IDed const uint8_t IDsToBePinged[] = { - GR_BCU, GR_DASH_PANEL, - // GR_CCU + GR_BCU, + GR_DASH_PANEL, + GR_CCU }; const uint8_t PingsToBeIDed[] = { - [GR_BCU] = 0, [GR_DASH_PANEL] = 1, - //[GR_CCU] = 2 + [GR_BCU] = 0, + [GR_DASH_PANEL] = 1, + [GR_CCU] = 2 }; #define NUMBER_OF_PING_DEVICES (sizeof(IDsToBePinged) / sizeof(IDsToBePinged[0])) diff --git a/ECU/Core/Src/main.c b/ECU/Core/Src/main.c index 2bd2d9117..ddd799041 100644 --- a/ECU/Core/Src/main.c +++ b/ECU/Core/Src/main.c @@ -435,14 +435,20 @@ int main(void) static uint32_t nextPing; if (MillisecondsSinceBoot() >= nextPing) { pingAll(); - nextPing = MillisecondsSinceBoot() + PINGTIMEOUT_TIME; - if (getRTT(GR_BCU) == PINGTIMEOUT_VALUE) { - LOGOMATIC("ERROR: BCU is not responding to pings!\n"); - } - if (getRTT(GR_DASH_PANEL) == PINGTIMEOUT_VALUE) { - LOGOMATIC("ERROR: Dash Panel is not responding to pings!\n"); + if (nextPing != 0) { + if (getRTT(GR_BCU) == PINGTIMEOUT_VALUE) { + LOGOMATIC("ERROR: BCU is not responding to pings!\n"); + } + if (getRTT(GR_DASH_PANEL) == PINGTIMEOUT_VALUE) { + LOGOMATIC("ERROR: Dash Panel is not responding to pings!\n"); + } + if (getRTT(GR_CCU) != PINGTIMEOUT_VALUE) { + // halt if CCU is connected + return; + } } + nextPing = MillisecondsSinceBoot() + PINGTIMEOUT_TIME; } read_digital(); From 04ea9676954be19fdb1e01240790311da97e7052 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 24 Feb 2026 05:00:47 +0000 Subject: [PATCH 10/15] Automatic Clang-Format: Standardized formatting automatically --- ECU/Application/Src/Pinging.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/ECU/Application/Src/Pinging.c b/ECU/Application/Src/Pinging.c index a1efee16d..cb1a9ce3a 100644 --- a/ECU/Application/Src/Pinging.c +++ b/ECU/Application/Src/Pinging.c @@ -7,17 +7,9 @@ #include "StateUtils.h" // add node IDs of devices to be pinged here, and add their indices in here to Pings ToBe IDed -const uint8_t IDsToBePinged[] = { - GR_BCU, - GR_DASH_PANEL, - GR_CCU -}; - -const uint8_t PingsToBeIDed[] = { - [GR_BCU] = 0, - [GR_DASH_PANEL] = 1, - [GR_CCU] = 2 -}; +const uint8_t IDsToBePinged[] = {GR_BCU, GR_DASH_PANEL, GR_CCU}; + +const uint8_t PingsToBeIDed[] = {[GR_BCU] = 0, [GR_DASH_PANEL] = 1, [GR_CCU] = 2}; #define NUMBER_OF_PING_DEVICES (sizeof(IDsToBePinged) / sizeof(IDsToBePinged[0])) From 5a87b8884a9febb1f549ddcc8f27c20836c722eb Mon Sep 17 00:00:00 2001 From: Casey Zwicker Date: Mon, 23 Feb 2026 21:15:13 -0800 Subject: [PATCH 11/15] teehee oopsie --- ECU/Core/Src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ECU/Core/Src/main.c b/ECU/Core/Src/main.c index ddd799041..3ea450de8 100644 --- a/ECU/Core/Src/main.c +++ b/ECU/Core/Src/main.c @@ -445,7 +445,7 @@ int main(void) } if (getRTT(GR_CCU) != PINGTIMEOUT_VALUE) { // halt if CCU is connected - return; + return 1; } } nextPing = MillisecondsSinceBoot() + PINGTIMEOUT_TIME; From d5c78b725f28ebaf44e2fc94b366cc45dc3462b5 Mon Sep 17 00:00:00 2001 From: Casey Zwicker Date: Mon, 23 Feb 2026 22:06:19 -0800 Subject: [PATCH 12/15] Cool suggestion --- ECU/Application/Src/Pinging.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ECU/Application/Src/Pinging.c b/ECU/Application/Src/Pinging.c index cb1a9ce3a..332c9874c 100644 --- a/ECU/Application/Src/Pinging.c +++ b/ECU/Application/Src/Pinging.c @@ -7,9 +7,21 @@ #include "StateUtils.h" // add node IDs of devices to be pinged here, and add their indices in here to Pings ToBe IDed -const uint8_t IDsToBePinged[] = {GR_BCU, GR_DASH_PANEL, GR_CCU}; -const uint8_t PingsToBeIDed[] = {[GR_BCU] = 0, [GR_DASH_PANEL] = 1, [GR_CCU] = 2}; +#define PING_LIST(X) \ + X(GR_BCU, 0) \ + X(GR_DASH_PANEL, 1) \ + X(GR_CCU, 2) + +const uint8_t IDsToBePinged[] = { + #define AS_ID(id, idx) id, + PING_LIST(AS_ID) +}; + +const uint8_t PingsToBeIDed[] = { + #define AS_LOOKUP(id, idx) [id] = idx, + PING_LIST(AS_LOOKUP) +}; #define NUMBER_OF_PING_DEVICES (sizeof(IDsToBePinged) / sizeof(IDsToBePinged[0])) From 4837982de8eb7b44881b2f8b636af61bb5d19cdb Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 24 Feb 2026 06:07:34 +0000 Subject: [PATCH 13/15] Automatic Clang-Format: Standardized formatting automatically --- ECU/Application/Src/Pinging.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/ECU/Application/Src/Pinging.c b/ECU/Application/Src/Pinging.c index 332c9874c..edb860a81 100644 --- a/ECU/Application/Src/Pinging.c +++ b/ECU/Application/Src/Pinging.c @@ -8,20 +8,18 @@ // add node IDs of devices to be pinged here, and add their indices in here to Pings ToBe IDed -#define PING_LIST(X) \ - X(GR_BCU, 0) \ - X(GR_DASH_PANEL, 1) \ - X(GR_CCU, 2) +#define PING_LIST(X) \ + X(GR_BCU, 0) \ + X(GR_DASH_PANEL, 1) \ + X(GR_CCU, 2) const uint8_t IDsToBePinged[] = { - #define AS_ID(id, idx) id, - PING_LIST(AS_ID) -}; +#define AS_ID(id, idx) id, + PING_LIST(AS_ID)}; const uint8_t PingsToBeIDed[] = { - #define AS_LOOKUP(id, idx) [id] = idx, - PING_LIST(AS_LOOKUP) -}; +#define AS_LOOKUP(id, idx) [id] = idx, + PING_LIST(AS_LOOKUP)}; #define NUMBER_OF_PING_DEVICES (sizeof(IDsToBePinged) / sizeof(IDsToBePinged[0])) From 2e9a0f14233512865371630f6faed97294a95615 Mon Sep 17 00:00:00 2001 From: Casey Zwicker Date: Mon, 23 Feb 2026 22:08:04 -0800 Subject: [PATCH 14/15] fixs --- ECU/Application/Inc/Pinging.h | 5 +++-- ECU/Application/Src/Pinging.c | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ECU/Application/Inc/Pinging.h b/ECU/Application/Inc/Pinging.h index 1108893b7..7dd0cadbb 100644 --- a/ECU/Application/Inc/Pinging.h +++ b/ECU/Application/Inc/Pinging.h @@ -3,8 +3,9 @@ #ifndef PINGING_H #define PINGING_H -#define PINGTIMEOUT_TIME 250U -#define PINGTIMEOUT_VALUE 255U + +#define PINGTIMEOUT_TIME 250U // time in ms before a ping is considered timed out +#define PINGTIMEOUT_VALUE (UINT8_MAX-1) // return time value representing a timed out ping void pingAll(void); // ping all IDs specified, to be run every PINGTIMEOUT_TIME milliseconds uint32_t getRTT(uint8_t id); // get latest RTT by ID diff --git a/ECU/Application/Src/Pinging.c b/ECU/Application/Src/Pinging.c index 332c9874c..c7fe7d84c 100644 --- a/ECU/Application/Src/Pinging.c +++ b/ECU/Application/Src/Pinging.c @@ -6,8 +6,7 @@ #include "GR_OLD_NODE_ID.h" #include "StateUtils.h" -// add node IDs of devices to be pinged here, and add their indices in here to Pings ToBe IDed - +// add new pingable devices here, arrays are updated automagically #define PING_LIST(X) \ X(GR_BCU, 0) \ X(GR_DASH_PANEL, 1) \ From c77b34eb3ab15238bba8aba766984c1d335d48d6 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 24 Feb 2026 06:10:08 +0000 Subject: [PATCH 15/15] Automatic Clang-Format: Standardized formatting automatically --- ECU/Application/Inc/Pinging.h | 5 ++--- ECU/Application/Src/Pinging.c | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/ECU/Application/Inc/Pinging.h b/ECU/Application/Inc/Pinging.h index 7dd0cadbb..97e7ca166 100644 --- a/ECU/Application/Inc/Pinging.h +++ b/ECU/Application/Inc/Pinging.h @@ -3,9 +3,8 @@ #ifndef PINGING_H #define PINGING_H - -#define PINGTIMEOUT_TIME 250U // time in ms before a ping is considered timed out -#define PINGTIMEOUT_VALUE (UINT8_MAX-1) // return time value representing a timed out ping +#define PINGTIMEOUT_TIME 250U // time in ms before a ping is considered timed out +#define PINGTIMEOUT_VALUE (UINT8_MAX - 1) // return time value representing a timed out ping void pingAll(void); // ping all IDs specified, to be run every PINGTIMEOUT_TIME milliseconds uint32_t getRTT(uint8_t id); // get latest RTT by ID diff --git a/ECU/Application/Src/Pinging.c b/ECU/Application/Src/Pinging.c index 290512620..858c41dfd 100644 --- a/ECU/Application/Src/Pinging.c +++ b/ECU/Application/Src/Pinging.c @@ -7,10 +7,10 @@ #include "StateUtils.h" // add new pingable devices here, arrays are updated automagically -#define PING_LIST(X) \ - X(GR_BCU, 0) \ - X(GR_DASH_PANEL, 1) \ - X(GR_CCU, 2) +#define PING_LIST(X) \ + X(GR_BCU, 0) \ + X(GR_DASH_PANEL, 1) \ + X(GR_CCU, 2) const uint8_t IDsToBePinged[] = { #define AS_ID(id, idx) id,