mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-06 03:50:13 +02:00
✨ track pylon LV compatible inverter responses for checking if inverter is dead
This commit is contained in:
parent
c8b2c427ef
commit
0047a346bc
1 changed files with 8 additions and 2 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue