From 0047a346bcdda770dfa6bf6b52212c0c15e0a0a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakob=20L=C3=B6w?= Date: Tue, 15 Oct 2024 09:07:35 +0200 Subject: [PATCH] :sparkles: track pylon LV compatible inverter responses for checking if inverter is dead --- Software/src/inverter/PYLON-LV-CAN.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Software/src/inverter/PYLON-LV-CAN.cpp b/Software/src/inverter/PYLON-LV-CAN.cpp index 15efe829..401153b1 100644 --- a/Software/src/inverter/PYLON-LV-CAN.cpp +++ b/Software/src/inverter/PYLON-LV-CAN.cpp @@ -5,6 +5,7 @@ /* Do not change code below unless you are sure what you are doing */ +static unsigned long previousInverterPacketMillis = 0; static unsigned long previousMillis1000ms = 0; CAN_frame PYLON_351 = {.FD = false, @@ -120,8 +121,9 @@ void update_values_can_inverter() { void receive_can_inverter(CAN_frame rx_frame) { switch (rx_frame.ID) { case 0x305: //Message originating from inverter. - // TODO: according to the spec, this message includes only 0-bytes - // we could however use this to check if the inverter is still alive + // according to the spec, this message includes only 0-bytes + datalayer.system.status.CAN_inverter_still_alive = true; + previousInverterPacketMillis = millis(); break; default: break; @@ -131,6 +133,10 @@ void receive_can_inverter(CAN_frame rx_frame) { void send_can_inverter() { unsigned long currentMillis = millis(); + if(currentMillis - previousInverterPacketMillis >= 3000) { + datalayer.system.status.CAN_inverter_still_alive = false; + } + if (currentMillis - previousMillis1000ms >= 1000) { previousMillis1000ms = currentMillis;