Skip to content

Commit

Permalink
Charger Auth state: Add some more warning logging
Browse files Browse the repository at this point in the history
Signed-off-by: Cornelius Claussen <[email protected]>
  • Loading branch information
corneliusclaussen committed May 13, 2024
1 parent 86c9131 commit 43cccb6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
17 changes: 15 additions & 2 deletions modules/EvseManager/Charger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ void Charger::run_state_machine() {
// to make sure control_pilot does not switch on relais even if
// we start PWM here
if (initialize_state) {
internal_context.pp_warning_printed = false;
internal_context.no_energy_warning_printed = false;

bsp->allow_power_on(false, types::evse_board_support::Reason::PowerOff);

if (internal_context.last_state == EvseState::Replug) {
Expand Down Expand Up @@ -264,6 +267,10 @@ void Charger::run_state_machine() {
shared_context.max_current_cable = bsp->read_pp_ampacity();
// retry if the value is not yet available. Some BSPs may take some time to measure the PP.
if (shared_context.max_current_cable == 0) {
if (not internal_context.pp_warning_printed) {
EVLOG_warning << "PP ampacity is zero, still retrying to read PP ampacity...";
internal_context.pp_warning_printed = true;
}
break;
}
}
Expand All @@ -274,6 +281,10 @@ void Charger::run_state_machine() {
// Create a copy of the atomic struct
types::iso15118_charger::DC_EVSEMaximumLimits evse_limit = shared_context.current_evse_max_limits;
if (not(evse_limit.EVSEMaximumCurrentLimit > 0 and evse_limit.EVSEMaximumPowerLimit > 0)) {
if (not internal_context.no_energy_warning_printed) {
EVLOG_warning << "No energy available, still retrying...";
internal_context.no_energy_warning_printed = true;
}
break;
}
}
Expand Down Expand Up @@ -302,8 +313,9 @@ void Charger::run_state_machine() {

// If we are restarting, the transaction may already be active
if (not shared_context.transaction_active) {
if (!start_transaction())
if (!start_transaction()) {
break;
}
}

const EvseState target_state(EvseState::PrepareCharging);
Expand Down Expand Up @@ -384,8 +396,9 @@ void Charger::run_state_machine() {
}
} else if (shared_context.authorized and shared_context.authorized_pnc) {

if (!start_transaction())
if (!start_transaction()) {
break;
}

const EvseState target_state(EvseState::PrepareCharging);

Expand Down
3 changes: 3 additions & 0 deletions modules/EvseManager/Charger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ class Charger {
std::chrono::system_clock::time_point current_state_started;
EvseState last_state_detect_state_change;
EvseState last_state;

bool pp_warning_printed{false};
bool no_energy_warning_printed{false};
} internal_context;

// main Charger thread
Expand Down

0 comments on commit 43cccb6

Please sign in to comment.