Skip to content

Commit 5bf6514

Browse files
committed
Fix race condition in fail_cable_check causing permanent charger inoperability
When a car is unplugged during DC cable check, the detached cable_check thread can call fail_cable_check() after clear_errors_on_unplug() has already run, leaving MREC11CableCheckFault permanently raised. This makes the charger inoperative until EVerest is restarted. Add a state check before raising the fault: if the session has already ended (Idle or Finished state), log the failure but skip raising the error. Fixes #1392 Signed-off-by: Rishabh Vaish <rishabhvaish.904@gmail.com>
1 parent 9c84a9a commit 5bf6514

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

modules/EVSE/EvseManager/EvseManager.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2535,6 +2535,16 @@ void EvseManager::fail_cable_check(const std::string& reason) {
25352535
}
25362536
r_hlc[0]->call_cable_check_finished(false);
25372537
}
2538+
// Do not raise a cable check fault if the car has already been unplugged.
2539+
// This prevents a race condition where the detached cable check thread raises an error
2540+
// after clear_errors_on_unplug() has already run, leaving the charger permanently
2541+
// inoperative (see GitHub issue #1392).
2542+
const auto current_state = charger->get_current_state();
2543+
if (current_state == Charger::EvseState::Idle || current_state == Charger::EvseState::Finished) {
2544+
EVLOG_info << "Cable check failed due to: " << reason
2545+
<< ", but session already ended (car unplugged). Not raising cable check fault error.";
2546+
return;
2547+
}
25382548

25392549
// Raising a cable check fault should not happen if a cancel_transaction (DeAuthorized) is triggered
25402550
// during cable check

0 commit comments

Comments
 (0)