Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EvseManager: Fix bug where HLC is not stopped on unexpected CP state #669

Merged
merged 2 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions modules/EvseManager/Charger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,20 @@ void Charger::process_cp_events_state(CPEvent cp_event) {
if (cp_event == CPEvent::CarRequestedStopPower) {
shared_context.iec_allow_close_contactor = false;
shared_context.current_state = EvseState::ChargingPausedEV;
// Tell HLC stack to stop the session. Normally the session should have already been stopped by the EV, but
// if this is not the case, we have to do it here.
if (shared_context.hlc_charging_active) {
signal_hlc_stop_charging();
session_log.evse(false, "CP state transition C->B at this stage violates ISO15118-2");
}
} else if (cp_event == CPEvent::BCDtoEF) {
shared_context.iec_allow_close_contactor = false;
shared_context.current_state = EvseState::StoppingCharging;
// Tell HLC stack to stop the session in case of an E/F event while charging.
if (shared_context.hlc_charging_active) {
signal_hlc_stop_charging();
session_log.evse(false, "CP state transition C->E/F at this stage violates ISO15118-2");
}
}
break;

Expand Down
11 changes: 11 additions & 0 deletions modules/EvseManager/IECStateMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,24 @@ std::queue<CPEvent> IECStateMachine::state_machine() {
if (last_cp_state != RawCPState::E) {
timer = TimerControl::stop;
call_allow_power_on_bsp(false);
pwm_running = false;
r_bsp->call_pwm_off();
if (last_cp_state == RawCPState::B || last_cp_state == RawCPState::C ||
last_cp_state == RawCPState::D) {
events.push(CPEvent::BCDtoEF);
}
}
break;

case RawCPState::F:
connector_unlock();
timer = TimerControl::stop;
call_allow_power_on_bsp(false);
pwm_running = false;
r_bsp->call_pwm_off();
if (last_cp_state == RawCPState::B || last_cp_state == RawCPState::C || last_cp_state == RawCPState::D) {
events.push(CPEvent::BCDtoEF);
}
break;
}

Expand Down
Loading