Fix startup crash

This commit is contained in:
Daniel Öster 2025-08-03 20:52:50 +03:00
parent 2d56ab8916
commit 6ab63497f4
3 changed files with 46 additions and 63 deletions

View file

@ -302,10 +302,6 @@ void setup_battery() {
battery2 = new SELECTED_BATTERY_CLASS(&datalayer.battery2, &datalayer_extended.KiaHyundai64_2,
&datalayer.system.status.battery2_allowed_contactor_closing,
can_config.battery_double);
#elif defined(HYUNDAI_IONIQ_28_BATTERY)
battery2 = new SELECTED_BATTERY_CLASS(&datalayer.battery2, &datalayer_extended.ioniq28,
&datalayer.system.status.battery2_allowed_contactor_closing,
can_config.battery_double);
#elif defined(SANTA_FE_PHEV_BATTERY) || defined(TEST_FAKE_BATTERY)
battery2 = new SELECTED_BATTERY_CLASS(&datalayer.battery2, can_config.battery_double);
#else

View file

@ -298,19 +298,15 @@ void HyundaiIoniq28Battery::transmit_can(unsigned long currentMillis) {
if (currentMillis - previousMillis100 >= INTERVAL_100_MS) {
previousMillis100 = currentMillis;
if (contactor_closing_allowed == nullptr || *contactor_closing_allowed) {
transmit_can_frame(&IONIQ_553);
transmit_can_frame(&IONIQ_57F);
transmit_can_frame(&IONIQ_2A1);
}
}
// Send 10ms CAN Message
if (currentMillis - previousMillis10 >= INTERVAL_10_MS) {
previousMillis10 = currentMillis;
if (contactor_closing_allowed == nullptr || *contactor_closing_allowed) {
switch (counter_200) {
case 0:
IONIQ_200.data.u8[5] = 0x17;
@ -355,7 +351,6 @@ void HyundaiIoniq28Battery::transmit_can(unsigned long currentMillis) {
transmit_can_frame(&IONIQ_523);
transmit_can_frame(&IONIQ_524);
}
}
}
void HyundaiIoniq28Battery::setup(void) { // Performs one time setup at startup
@ -368,9 +363,7 @@ void HyundaiIoniq28Battery::setup(void) { // Performs one time setup at startup
datalayer_battery->info.max_cell_voltage_mV = MAX_CELL_VOLTAGE_MV;
datalayer_battery->info.min_cell_voltage_mV = MIN_CELL_VOLTAGE_MV;
datalayer_battery->info.max_cell_voltage_deviation_mV = MAX_CELL_DEVIATION_MV;
if (allows_contactor_closing) {
*allows_contactor_closing = true;
}
datalayer.system.status.battery_allows_contactor_closing = true;
}
uint16_t HyundaiIoniq28Battery::get_lead_acid_voltage() const {

View file

@ -35,12 +35,6 @@ class HyundaiIoniq28Battery : public CanBattery {
DATALAYER_BATTERY_TYPE* datalayer_battery;
// If not null, this battery decides when the contactor can be closed and writes the value here.
bool* allows_contactor_closing;
// If not null, this battery listens to this boolean to determine whether contactor closing is allowed
bool* contactor_closing_allowed;
static const int MAX_PACK_VOLTAGE_DV = 4050; //5000 = 500.0V
static const int MIN_PACK_VOLTAGE_DV = 2880;
static const int MAX_CELL_DEVIATION_MV = 150;