Skip to content

Commit

Permalink
Move blocking to LEAF side to avoid OVERRUN events
Browse files Browse the repository at this point in the history
  • Loading branch information
dalathegreat committed Jan 23, 2025
1 parent cc97642 commit 39113a9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
14 changes: 12 additions & 2 deletions Software/src/battery/NISSAN-LEAF-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1064,9 +1064,19 @@ void handle_incoming_can_frame_battery(CAN_frame rx_frame) {
}
}
void transmit_can_battery() {
if (battery_can_alive) {

unsigned long currentMillis = millis();
unsigned long currentMillis = millis();

if (datalayer.system.status.BMS_reset_in_progress) {
// Transmitting towards battery is halted while BMS is being reset
// Reset sending counters to avoid overrun messages when reset is over
previousMillis10 = currentMillis;
previousMillis100 = currentMillis;
previousMillis10s = currentMillis;
return;
}

if (battery_can_alive) {

//Send 10ms message
if (currentMillis - previousMillis10 >= INTERVAL_10_MS) {
Expand Down
5 changes: 1 addition & 4 deletions Software/src/communication/can/comm_can.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,7 @@ void transmit_can() {
return; //Global block of CAN messages
}

if (!datalayer.system.status.BMS_reset_in_progress) {
//Transmitting towards battery is halted while BMS is being reset
transmit_can_battery();
}
transmit_can_battery();

#ifdef CAN_INVERTER_SELECTED
transmit_can_inverter();
Expand Down

0 comments on commit 39113a9

Please sign in to comment.