track pylon LV compatible inverter responses for checking if inverter is dead

This commit is contained in:
Jakob Löw 2024-10-15 09:07:35 +02:00
parent c8b2c427ef
commit 0047a346bc
No known key found for this signature in database
GPG key ID: B77685F55C7C46C6

View file

@ -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;