Add info messages. Fix CAN recovery

This commit is contained in:
Daniel 2024-02-12 22:58:52 +02:00
parent fbd70b584c
commit 362824f944
11 changed files with 23 additions and 3 deletions

View file

@ -103,6 +103,7 @@ void update_values_i3_battery() { //This function maps all the values fetched v
set_event(EVENT_CAN_RX_FAILURE, 0); set_event(EVENT_CAN_RX_FAILURE, 0);
} else { } else {
CANstillAlive--; CANstillAlive--;
clear_event(EVENT_CAN_RX_FAILURE);
} }
#ifdef DEBUG_VIA_USB #ifdef DEBUG_VIA_USB

View file

@ -108,6 +108,7 @@ void update_values_chademo_battery() { //This function maps all the values fetc
set_event(EVENT_CAN_RX_FAILURE, 0); set_event(EVENT_CAN_RX_FAILURE, 0);
} else { } else {
CANstillAlive--; CANstillAlive--;
clear_event(EVENT_CAN_RX_FAILURE);
} }
#ifdef DEBUG_VIA_USB #ifdef DEBUG_VIA_USB

View file

@ -109,6 +109,7 @@ void update_values_imiev_battery() { //This function maps all the values fetche
set_event(EVENT_CAN_RX_FAILURE, 0); set_event(EVENT_CAN_RX_FAILURE, 0);
} else { } else {
CANstillAlive--; CANstillAlive--;
clear_event(EVENT_CAN_RX_FAILURE);
} }
if (!BMU_Detected) { if (!BMU_Detected) {

View file

@ -200,6 +200,7 @@ void update_values_kiaHyundai_64_battery() { //This function maps all the value
set_event(EVENT_CAN_RX_FAILURE, 0); set_event(EVENT_CAN_RX_FAILURE, 0);
} else { } else {
CANstillAlive--; CANstillAlive--;
clear_event(EVENT_CAN_RX_FAILURE);
} }
if (waterleakageSensor == 0) { if (waterleakageSensor == 0) {

View file

@ -104,7 +104,7 @@ static int16_t LB_SOC = 500; //0 - 100.0 % (0-1000) The real S
static int16_t CalculatedSOC = 0; // Temporary value used for calculating SOC static int16_t CalculatedSOC = 0; // Temporary value used for calculating SOC
static uint16_t LB_TEMP = 0; //Temporary value used in status checks static uint16_t LB_TEMP = 0; //Temporary value used in status checks
static uint16_t LB_Wh_Remaining = 0; //Amount of energy in battery, in Wh static uint16_t LB_Wh_Remaining = 0; //Amount of energy in battery, in Wh
static uint16_t LB_GIDS = 0; static uint16_t LB_GIDS = 273; //Startup in 24kWh mode
static uint16_t LB_MAX = 0; static uint16_t LB_MAX = 0;
static uint16_t LB_Max_GIDS = 273; //Startup in 24kWh mode static uint16_t LB_Max_GIDS = 273; //Startup in 24kWh mode
static uint16_t LB_StateOfHealth = 99; //State of health % static uint16_t LB_StateOfHealth = 99; //State of health %
@ -247,8 +247,9 @@ void update_values_leaf_battery() { /* This function maps all the values fetched
} }
/*Extra safety functions below*/ /*Extra safety functions below*/
if (LB_GIDS < 10) //800Wh left in battery if (LB_GIDS < 6) //500Wh left in battery
{ //Battery is running abnormally low, some discharge logic might have failed. Zero it all out. { //Battery is running abnormally low, some discharge logic might have failed. Zero it all out.
set_event(EVENT_BATTERY_EMPTY, 0);
SOC = 0; SOC = 0;
max_target_discharge_power = 0; max_target_discharge_power = 0;
} }
@ -264,10 +265,12 @@ void update_values_leaf_battery() { /* This function maps all the values fetched
} }
if (LB_Full_CHARGE_flag) { //Battery reports that it is fully charged stop all further charging incase it hasn't already if (LB_Full_CHARGE_flag) { //Battery reports that it is fully charged stop all further charging incase it hasn't already
set_event(EVENT_BATTERY_FULL, 0);
max_target_charge_power = 0; max_target_charge_power = 0;
} }
if (LB_Capacity_Empty) { //Battery reports that it is fully discharged. Stop all further discharging incase it hasn't already if (LB_Capacity_Empty) { //Battery reports that it is fully discharged. Stop all further discharging incase it hasn't already
set_event(EVENT_BATTERY_EMPTY, 0);
max_target_discharge_power = 0; max_target_discharge_power = 0;
} }
@ -347,6 +350,7 @@ void update_values_leaf_battery() { /* This function maps all the values fetched
set_event(EVENT_CAN_RX_FAILURE, 0); set_event(EVENT_CAN_RX_FAILURE, 0);
} else { } else {
CANstillAlive--; CANstillAlive--;
clear_event(EVENT_CAN_RX_FAILURE);
} }
if (CANerror > if (CANerror >
MAX_CAN_FAILURES) //Also check if we have recieved too many malformed CAN messages. If so, signal via LED MAX_CAN_FAILURES) //Also check if we have recieved too many malformed CAN messages. If so, signal via LED

View file

@ -126,6 +126,7 @@ void update_values_kangoo_battery() { //This function maps all the values fetch
set_event(EVENT_CAN_RX_FAILURE, 0); set_event(EVENT_CAN_RX_FAILURE, 0);
} else { } else {
CANstillAlive--; CANstillAlive--;
clear_event(EVENT_CAN_RX_FAILURE);
} }
if (LB_Cell_Max_Voltage >= ABSOLUTE_CELL_MAX_VOLTAGE) { if (LB_Cell_Max_Voltage >= ABSOLUTE_CELL_MAX_VOLTAGE) {

View file

@ -87,6 +87,7 @@ void update_values_zoe_battery() { //This function maps all the values fetched
set_event(EVENT_CAN_RX_FAILURE, 0); set_event(EVENT_CAN_RX_FAILURE, 0);
} else { } else {
CANstillAlive--; CANstillAlive--;
clear_event(EVENT_CAN_RX_FAILURE);
} }
if (LB_Cell_Max_Voltage >= ABSOLUTE_CELL_MAX_VOLTAGE) { if (LB_Cell_Max_Voltage >= ABSOLUTE_CELL_MAX_VOLTAGE) {

View file

@ -84,6 +84,7 @@ void update_values_santafe_phev_battery() { //This function maps all the values
set_event(EVENT_CAN_RX_FAILURE, 0); set_event(EVENT_CAN_RX_FAILURE, 0);
} else { } else {
CANstillAlive--; CANstillAlive--;
clear_event(EVENT_CAN_RX_FAILURE);
} }
#ifdef DEBUG_VIA_USB #ifdef DEBUG_VIA_USB

View file

@ -231,6 +231,7 @@ void update_values_tesla_model_3_battery() { //This function maps all the value
set_event(EVENT_CAN_RX_FAILURE, 0); set_event(EVENT_CAN_RX_FAILURE, 0);
} else { } else {
stillAliveCAN--; stillAliveCAN--;
clear_event(EVENT_CAN_RX_FAILURE);
} }
if (hvil_status == 3) { //INTERNAL_OPEN_FAULT - Someone disconnected a high voltage cable while battery was in use if (hvil_status == 3) { //INTERNAL_OPEN_FAULT - Someone disconnected a high voltage cable while battery was in use

View file

@ -112,6 +112,8 @@ void init_events(void) {
events.entries[EVENT_12V_LOW].level = EVENT_LEVEL_WARNING; events.entries[EVENT_12V_LOW].level = EVENT_LEVEL_WARNING;
events.entries[EVENT_SOC_PLAUSIBILITY_ERROR].level = EVENT_LEVEL_ERROR; events.entries[EVENT_SOC_PLAUSIBILITY_ERROR].level = EVENT_LEVEL_ERROR;
events.entries[EVENT_KWH_PLAUSIBILITY_ERROR].level = EVENT_LEVEL_WARNING; events.entries[EVENT_KWH_PLAUSIBILITY_ERROR].level = EVENT_LEVEL_WARNING;
events.entries[EVENT_BATTERY_EMPTY].level = EVENT_LEVEL_INFO;
events.entries[EVENT_BATTERY_FULL].level = EVENT_LEVEL_INFO;
events.entries[EVENT_BATTERY_CHG_STOP_REQ].level = EVENT_LEVEL_ERROR; events.entries[EVENT_BATTERY_CHG_STOP_REQ].level = EVENT_LEVEL_ERROR;
events.entries[EVENT_BATTERY_DISCHG_STOP_REQ].level = EVENT_LEVEL_ERROR; events.entries[EVENT_BATTERY_DISCHG_STOP_REQ].level = EVENT_LEVEL_ERROR;
events.entries[EVENT_BATTERY_CHG_DISCHG_STOP_REQ].level = EVENT_LEVEL_ERROR; events.entries[EVENT_BATTERY_CHG_DISCHG_STOP_REQ].level = EVENT_LEVEL_ERROR;
@ -173,6 +175,10 @@ const char* get_event_message_string(EVENTS_ENUM_TYPE event) {
return "ERROR: SOC% reported by battery not plausible. Restart battery!"; return "ERROR: SOC% reported by battery not plausible. Restart battery!";
case EVENT_KWH_PLAUSIBILITY_ERROR: case EVENT_KWH_PLAUSIBILITY_ERROR:
return "Warning: kWh remaining reported by battery not plausible. Battery needs cycling."; return "Warning: kWh remaining reported by battery not plausible. Battery needs cycling.";
case EVENT_BATTERY_EMPTY:
return "Info: Battery is completely discharged";
case EVENT_BATTERY_FULL:
return "Info: Battery is fully charged";
case EVENT_BATTERY_CHG_STOP_REQ: case EVENT_BATTERY_CHG_STOP_REQ:
return "ERROR: Battery raised caution indicator AND requested charge stop. Inspect battery status!"; return "ERROR: Battery raised caution indicator AND requested charge stop. Inspect battery status!";
case EVENT_BATTERY_DISCHG_STOP_REQ: case EVENT_BATTERY_DISCHG_STOP_REQ:

View file

@ -28,6 +28,8 @@
XX(EVENT_12V_LOW) \ XX(EVENT_12V_LOW) \
XX(EVENT_SOC_PLAUSIBILITY_ERROR) \ XX(EVENT_SOC_PLAUSIBILITY_ERROR) \
XX(EVENT_KWH_PLAUSIBILITY_ERROR) \ XX(EVENT_KWH_PLAUSIBILITY_ERROR) \
XX(EVENT_BATTERY_EMPTY) \
XX(EVENT_BATTERY_FULL) \
XX(EVENT_BATTERY_CHG_STOP_REQ) \ XX(EVENT_BATTERY_CHG_STOP_REQ) \
XX(EVENT_BATTERY_DISCHG_STOP_REQ) \ XX(EVENT_BATTERY_DISCHG_STOP_REQ) \
XX(EVENT_BATTERY_CHG_DISCHG_STOP_REQ) \ XX(EVENT_BATTERY_CHG_DISCHG_STOP_REQ) \