better state validation, better error codes

This commit is contained in:
rusefi 2019-11-29 23:41:26 -05:00
parent fd4412a2cd
commit a78dc22bf1
6 changed files with 15 additions and 11 deletions

View File

@ -264,6 +264,11 @@ void EtbController::PeriodicTask() {
#endif /* EFI_TUNER_STUDIO */ #endif /* EFI_TUNER_STUDIO */
} }
if (cisnan(targetPosition)) {
// this could happen while changing settings
warning(CUSTOM_ERR_ETB_TARGET, "target");
return;
}
engine->engineState.etbFeedForward = interpolate2d("etbb", targetPosition, engineConfiguration->etbBiasBins, engineConfiguration->etbBiasValues); engine->engineState.etbFeedForward = interpolate2d("etbb", targetPosition, engineConfiguration->etbBiasBins, engineConfiguration->etbBiasValues);
etbPid.iTermMin = engineConfiguration->etb_iTermMin; etbPid.iTermMin = engineConfiguration->etb_iTermMin;

View File

@ -2026,14 +2026,14 @@ typedef enum {
CUSTOM_ERR_6665 = 6665, CUSTOM_ERR_6665 = 6665,
CUSTOM_ERR_6666 = 6666, CUSTOM_ERR_6666 = 6666,
CUSTOM_ERR_ADCANCE_CALC_ANGLE = 6667, CUSTOM_ERR_ADCANCE_CALC_ANGLE = 6667,
CUSTOM_ERR_6668 = 6668, CUSTOM_ERR_ETB_TARGET = 6668,
CUSTOM_ERR_6669 = 6669, CUSTOM_ERR_6669 = 6669,
CUSTOM_ERR_6670 = 6670, CUSTOM_ERR_6670 = 6670,
CUSTOM_ERR_6671 = 6671, CUSTOM_STACK_ADC_6671 = 6671,
CUSTOM_ERR_6672 = 6672, CUSTOM_ICU_DRIVER = 6672,
CUSTOM_ERR_6673 = 6673, CUSTOM_ICU_DRIVER_STATE = 6673,
CUSTOM_ERR_6674 = 6674, CUSTOM_STACK_SPI = 6674,
CUSTOM_ERR_6675 = 6675, CUSTOM_ERR_6675 = 6675,
CUSTOM_ERR_6676 = 6676, CUSTOM_ERR_6676 = 6676,
CUSTOM_IH_STACK = 6677, CUSTOM_IH_STACK = 6677,

View File

@ -468,7 +468,7 @@ static void adc_callback_slow(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
if (adcp->state == ADC_COMPLETE) { if (adcp->state == ADC_COMPLETE) {
slowAdc.invalidateSamplesCache(); slowAdc.invalidateSamplesCache();
efiAssertVoid(CUSTOM_ERR_6671, getCurrentRemainingStack() > 128, "lowstck#9c"); efiAssertVoid(CUSTOM_STACK_ADC_6671, getCurrentRemainingStack() > 128, "lowstck#9c");
/* Calculates the average values from the ADC samples.*/ /* Calculates the average values from the ADC samples.*/
for (int i = 0; i < slowAdc.size(); i++) { for (int i = 0; i < slowAdc.size(); i++) {

View File

@ -281,8 +281,8 @@ void startInputDriver(const char *msg, /*nullable*/digital_input_s *hw, bool isA
} }
wave_icucfg.channel = getInputCaptureChannel(hw->brainPin); wave_icucfg.channel = getInputCaptureChannel(hw->brainPin);
efiIcuStart(msg, driver, &wave_icucfg); efiIcuStart(msg, driver, &wave_icucfg);
efiAssertVoid(CUSTOM_ERR_6672, driver != NULL, "di: driver is NULL"); efiAssertVoid(CUSTOM_ICU_DRIVER, driver != NULL, "di: driver is NULL");
efiAssertVoid(CUSTOM_ERR_6673, driver->state == ICU_READY, "di: driver not ready"); efiAssertVoid(CUSTOM_ICU_DRIVER_STATE, driver->state == ICU_READY, "di: driver not ready");
icuStartCapture(driver); // this would change state from READY to WAITING icuStartCapture(driver); // this would change state from READY to WAITING
icuEnableNotifications(driver); icuEnableNotifications(driver);
} }

View File

@ -93,7 +93,7 @@ bool rtcWorks = true;
*/ */
void lockSpi(spi_device_e device) { void lockSpi(spi_device_e device) {
UNUSED(device); UNUSED(device);
efiAssertVoid(CUSTOM_ERR_6674, getCurrentRemainingStack() > 128, "lockSpi"); efiAssertVoid(CUSTOM_STACK_SPI, getCurrentRemainingStack() > 128, "lockSpi");
// todo: different locks for different SPI devices! // todo: different locks for different SPI devices!
chMtxLock(&spiMtx); chMtxLock(&spiMtx);
} }

View File

@ -197,8 +197,7 @@ bool brain_pin_markUsed(brain_pin_e brainPin, const char *msg) {
* See also brain_pin_markUsed() * See also brain_pin_markUsed()
*/ */
void brain_pin_markUnused(brain_pin_e brainPin) void brain_pin_markUnused(brain_pin_e brainPin) {
{
int index; int index;
if (!initialized) { if (!initialized) {