Scheduled timestamp priming error #6588

This commit is contained in:
rusefillc 2024-06-07 01:23:27 -04:00
parent 6b2019adf2
commit 3c38230e4f
2 changed files with 12 additions and 3 deletions

View File

@ -7,6 +7,9 @@
#include "injection_gpio.h"
#include "sensor.h"
#include "backup_ram.h"
#if EFI_PROD_CODE
#include "microsecond_timer.h"
#endif
floatms_t PrimeController::getPrimeDuration() const {
auto clt = Sensor::get(SensorType::Clt);
@ -60,7 +63,7 @@ void PrimeController::onIgnitionStateChanged(bool ignitionOn) {
int32_t primeDelayNt = assertFloatFitsInto32BitsAndCast("primingDelay", MSF2NT(engineConfiguration->primingDelay * 1000));
auto startTime = getTimeNowNt() + primeDelayNt;
getExecutorInterface()->scheduleByTimestampNt("prime", nullptr, startTime, { PrimeController::onPrimeStartAdapter, this });
getExecutorInterface()->scheduleByTimestampNt("primingDelay", nullptr, startTime, { PrimeController::onPrimeStartAdapter, this });
} else {
efiPrintf("Skipped priming pulse since ignSwitchCounter = %d", ignSwitchCounter);
}
@ -91,6 +94,11 @@ void PrimeController::onPrimeStart() {
efiPrintf("Skipped zero-duration priming pulse.");
return;
}
#if EFI_PROD_CODE
if (durationMs >= TOO_FAR_INTO_FUTURE_MS) {
criticalError("Priming duration too long %dms", durationMs);
}
#endif
efiPrintf("Firing priming pulse of %.2f ms", durationMs);
engine->outputChannels.injectionPrimingCounter++;
@ -100,7 +108,7 @@ void PrimeController::onPrimeStart() {
// Open all injectors, schedule closing later
m_isPriming = true;
startSimultaneousInjection();
getExecutorInterface()->scheduleByTimestampNt("prime", nullptr, endTime, { onPrimeEndAdapter, this });
getExecutorInterface()->scheduleByTimestampNt("onPrimeStart", nullptr, endTime, { onPrimeEndAdapter, this });
}
void PrimeController::onPrimeEnd() {

View File

@ -10,5 +10,6 @@
void initMicrosecondTimer();
void setHardwareSchedulerTimer(efitick_t nowNt, efitick_t setTimeNt);
#define TOO_FAR_INTO_FUTURE_US (10 * US_PER_SECOND)
#define TOO_FAR_INTO_FUTURE_MS (10 * MS_PER_SECOND)
#define TOO_FAR_INTO_FUTURE_US MS2US(TOO_FAR_INTO_FUTURE_MS)
#define TOO_FAR_INTO_FUTURE_NT US2NT(TOO_FAR_INTO_FUTURE_US)