refactoring: removing validateConfiguration by moving logic into another similar method

This commit is contained in:
rusefillc 2024-06-09 11:33:17 -04:00
parent 7affcba3ab
commit d706537893
7 changed files with 9 additions and 16 deletions

View File

@ -364,8 +364,6 @@ trigger_type_e getVvtTriggerType(vvt_mode_e vvtMode);
void applyNonPersistentConfiguration();
void prepareOutputSignals();
// todo: huh we also have validateConfig()?!
void validateConfiguration();
void scheduleReboot();
bool isLockedFromUser();
void unlockEcu(int password);

View File

@ -1058,13 +1058,6 @@ void resetConfigurationExt(engine_type_e engineType) {
resetConfigurationExt(&emptyCallbackWithConfiguration, engineType);
}
void validateConfiguration() {
if (engineConfiguration->adcVcc > 5.0f || engineConfiguration->adcVcc < 1.0f) {
engineConfiguration->adcVcc = 3.0f;
}
}
void applyNonPersistentConfiguration() {
#if EFI_PROD_CODE
efiAssertVoid(ObdCode::CUSTOM_APPLY_STACK, hasLotsOfRemainingStack(), "apply c");

View File

@ -530,11 +530,16 @@ void commonInitEngineController() {
}
// Returns false if there's an obvious problem with the loaded configuration
bool validateConfig() {
// todo: shall we also invoke this from 'burn'?
bool validateConfigOnStartUp() {
if (engineConfiguration->cylindersCount > MAX_CYLINDER_COUNT) {
criticalError("Invalid cylinder count: %d", engineConfiguration->cylindersCount);
return false;
}
if (engineConfiguration->adcVcc > 5.0f || engineConfiguration->adcVcc < 1.0f) {
criticalError("Invalid adcVcc: %f", engineConfiguration->adcVcc);
return false;
}
ensureArrayIsAscending("Batt Lag", engineConfiguration->injector.battLagCorrBins);

View File

@ -11,9 +11,7 @@
#define FAST_CALLBACK_PERIOD_MS 5
#define SLOW_CALLBACK_PERIOD_MS 50
// todo: huh we also have validateConfiguration()?!
bool validateConfig();
bool validateConfigOnStartUp();
char * getPinNameByAdcChannel(const char *msg, adc_channel_e hwChannel, char *buffer);
void initPeriodicEvents();
// see also applyNewHardwareSettings

View File

@ -325,7 +325,6 @@ void readFromFlash() {
// we can only change the state after the CRC check
engineConfiguration->byFirmwareVersion = getRusEfiVersion();
memset(persistentState.persistentConfiguration.warning_message , 0, sizeof(persistentState.persistentConfiguration.warning_message));
validateConfiguration();
engine->preCalculate();
}

View File

@ -263,7 +263,7 @@ void runRusEfiWithConfig() {
#endif
// Config could be completely bogus - don't start anything else!
if (validateConfig()) {
if (validateConfigOnStartUp()) {
/**
* Now let's initialize actual engine control logic
* todo: should we initialize some? most? controllers before hardware?

View File

@ -110,7 +110,7 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType, configuration_callb
resetConfigurationExt(configurationCallback, engineType);
validateConfig();
validateConfigOnStartUp();
enginePins.startPins();