diff --git a/firmware/config/engines/custom_engine.cpp b/firmware/config/engines/custom_engine.cpp index de46a676ca..48472ac1d8 100644 --- a/firmware/config/engines/custom_engine.cpp +++ b/firmware/config/engines/custom_engine.cpp @@ -44,7 +44,7 @@ static void toggleTestAndScheduleNext(void *) { testPin.toggle(); periodIndex = (periodIndex + 1) % TEST_LEN; testTime += test557[periodIndex]; - engine->executor.scheduleByTimestamp(&testScheduling, testTime, &toggleTestAndScheduleNext); + engine->executor.scheduleByTimestamp("test", &testScheduling, testTime, &toggleTestAndScheduleNext); } /** diff --git a/firmware/controllers/bench_test.cpp b/firmware/controllers/bench_test.cpp index 23fc908f65..cf791e9c6d 100644 --- a/firmware/controllers/bench_test.cpp +++ b/firmware/controllers/bench_test.cpp @@ -102,8 +102,8 @@ static void runBench(brain_pin_e brainPin, OutputPin *output, float delayMs, flo efitick_t endTime = startTime + US2NT(onTimeUs); // Schedule both events - engine->executor.scheduleByTimestampNt(&benchSchedStart, startTime, {benchOn, output}); - engine->executor.scheduleByTimestampNt(&benchSchedEnd, endTime, {benchOff, output}); + engine->executor.scheduleByTimestampNt("bstart", &benchSchedStart, startTime, {benchOn, output}); + engine->executor.scheduleByTimestampNt("bend", &benchSchedEnd, endTime, {benchOff, output}); // Wait one full cycle time for the event + delay to happen chThdSleepMicroseconds(onTimeUs + offTimeUs); diff --git a/firmware/controllers/engine_cycle/main_trigger_callback.cpp b/firmware/controllers/engine_cycle/main_trigger_callback.cpp index a04c3caa39..595d08f661 100644 --- a/firmware/controllers/engine_cycle/main_trigger_callback.cpp +++ b/firmware/controllers/engine_cycle/main_trigger_callback.cpp @@ -296,7 +296,7 @@ void InjectionEvent::onTriggerTooth(size_t trgEventIndex, int rpm, efitick_t now efitick_t startTime = scheduleByAngle(&signalTimerUp, nowNt, injectionStart.angleOffsetFromTriggerEvent, startAction PASS_ENGINE_PARAMETER_SUFFIX); efitick_t turnOffTime = startTime + US2NT((int)durationUs); - engine->executor.scheduleByTimestampNt(&endOfInjectionEvent, turnOffTime, endAction); + engine->executor.scheduleByTimestampNt("inj", &endOfInjectionEvent, turnOffTime, endAction); #if EFI_UNIT_TEST printf("scheduling injection angle=%.2f/delay=%.2f injectionDuration=%.2f\r\n", injectionStart.angleOffsetFromTriggerEvent, NT2US(startTime - nowNt), injectionDuration); diff --git a/firmware/controllers/engine_cycle/rpm_calculator.cpp b/firmware/controllers/engine_cycle/rpm_calculator.cpp index 1f7d9d0196..7188c8c3e4 100644 --- a/firmware/controllers/engine_cycle/rpm_calculator.cpp +++ b/firmware/controllers/engine_cycle/rpm_calculator.cpp @@ -404,7 +404,7 @@ efitick_t scheduleByAngle(scheduling_s *timer, efitick_t edgeTimestamp, angle_t int32_t delayNt = USF2NT(delayUs); efitime_t delayedTime = edgeTimestamp + delayNt; - ENGINE(executor.scheduleByTimestampNt(timer, delayedTime, action)); + ENGINE(executor.scheduleByTimestampNt("angle", timer, delayedTime, action)); return delayedTime; } diff --git a/firmware/controllers/engine_cycle/spark_logic.cpp b/firmware/controllers/engine_cycle/spark_logic.cpp index a6cb2011aa..16dd63a07a 100644 --- a/firmware/controllers/engine_cycle/spark_logic.cpp +++ b/firmware/controllers/engine_cycle/spark_logic.cpp @@ -201,8 +201,8 @@ if (engineConfiguration->debugMode == DBG_DWELL_METRIC) { efitick_t nextFiring = nextDwellStart + engine->engineState.multispark.dwell; // We can schedule both of these right away, since we're going for "asap" not "particular angle" - engine->executor.scheduleByTimestampNt(&event->dwellStartTimer, nextDwellStart, { &turnSparkPinHigh, event }); - engine->executor.scheduleByTimestampNt(&event->sparkEvent.scheduling, nextFiring, { fireSparkAndPrepareNextSchedule, event }); + engine->executor.scheduleByTimestampNt("dwell", &event->dwellStartTimer, nextDwellStart, { &turnSparkPinHigh, event }); + engine->executor.scheduleByTimestampNt("firing", &event->sparkEvent.scheduling, nextFiring, { fireSparkAndPrepareNextSchedule, event }); } else { if (CONFIG(enableTrailingSparks)) { // Trailing sparks are enabled - schedule an event for the corresponding trailing coil diff --git a/firmware/controllers/system/timer/pwm_generator_logic.cpp b/firmware/controllers/system/timer/pwm_generator_logic.cpp index ab8554e28a..18671e5233 100644 --- a/firmware/controllers/system/timer/pwm_generator_logic.cpp +++ b/firmware/controllers/system/timer/pwm_generator_logic.cpp @@ -269,7 +269,7 @@ static void timerCallback(PwmConfig *state) { return; } - state->executor->scheduleByTimestampNt(&state->scheduling, switchTimeNt, { timerCallback, state }); + state->executor->scheduleByTimestampNt("pwm", &state->scheduling, switchTimeNt, { timerCallback, state }); state->dbgNestingLevel--; } diff --git a/firmware/controllers/system/timer/scheduler.h b/firmware/controllers/system/timer/scheduler.h index ddf872b34e..514c258d95 100644 --- a/firmware/controllers/system/timer/scheduler.h +++ b/firmware/controllers/system/timer/scheduler.h @@ -66,7 +66,7 @@ struct ExecutorInterface { /** * see also scheduleByAngle */ - virtual void scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t timeUs, action_s action) = 0; - virtual void scheduleByTimestampNt(scheduling_s *scheduling, efitime_t timeUs, action_s action) = 0; + virtual void scheduleByTimestamp(const char *msg, scheduling_s *scheduling, efitimeus_t timeUs, action_s action) = 0; + virtual void scheduleByTimestampNt(const char *msg, scheduling_s *scheduling, efitime_t timeUs, action_s action) = 0; virtual void scheduleForLater(scheduling_s *scheduling, int delayUs, action_s action) = 0; }; diff --git a/firmware/controllers/system/timer/signal_executor_sleep.cpp b/firmware/controllers/system/timer/signal_executor_sleep.cpp index 41dcbb06b5..9b1a2f82ed 100644 --- a/firmware/controllers/system/timer/signal_executor_sleep.cpp +++ b/firmware/controllers/system/timer/signal_executor_sleep.cpp @@ -38,12 +38,12 @@ bool printSchedulerDebug = true; #if EFI_SIGNAL_EXECUTOR_SLEEP -void SleepExecutor::scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t timeUs, action_s action) { +void SleepExecutor::scheduleByTimestamp(const char *msg, scheduling_s *scheduling, efitimeus_t timeUs, action_s action) { scheduleForLater(scheduling, timeUs - getTimeNowUs(), action); } -void SleepExecutor::scheduleByTimestampNt(scheduling_s* scheduling, efitick_t timeNt, action_s action) { - scheduleByTimestamp(scheduling, NT2US(timeNt), action); +void SleepExecutor::scheduleByTimestampNt(const char *msg, scheduling_s* scheduling, efitick_t timeNt, action_s action) { + scheduleByTimestamp(msg, scheduling, NT2US(timeNt), action); } static void timerCallback(scheduling_s *scheduling) { diff --git a/firmware/controllers/system/timer/signal_executor_sleep.h b/firmware/controllers/system/timer/signal_executor_sleep.h index 25f3ed1869..5e3d478fb0 100644 --- a/firmware/controllers/system/timer/signal_executor_sleep.h +++ b/firmware/controllers/system/timer/signal_executor_sleep.h @@ -11,7 +11,7 @@ class SleepExecutor : public ExecutorInterface { public: - void scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t timeUs, action_s action) override; - void scheduleByTimestampNt(scheduling_s *scheduling, efitick_t timeNt, action_s action) override; + void scheduleByTimestamp(const char *msg, scheduling_s *scheduling, efitimeus_t timeUs, action_s action) override; + void scheduleByTimestampNt(const char *msg, scheduling_s *scheduling, efitick_t timeNt, action_s action) override; void scheduleForLater(scheduling_s *scheduling, int delayUs, action_s action) override; }; diff --git a/firmware/controllers/system/timer/single_timer_executor.cpp b/firmware/controllers/system/timer/single_timer_executor.cpp index a36de7d2c0..717b2d145c 100644 --- a/firmware/controllers/system/timer/single_timer_executor.cpp +++ b/firmware/controllers/system/timer/single_timer_executor.cpp @@ -50,7 +50,7 @@ SingleTimerExecutor::SingleTimerExecutor() } void SingleTimerExecutor::scheduleForLater(scheduling_s *scheduling, int delayUs, action_s action) { - scheduleByTimestamp(scheduling, getTimeNowUs() + delayUs, action); + scheduleByTimestamp("scheduleForLater", scheduling, getTimeNowUs() + delayUs, action); } /** @@ -63,11 +63,11 @@ void SingleTimerExecutor::scheduleForLater(scheduling_s *scheduling, int delayUs * @param [in] delayUs the number of microseconds before the output signal immediate output if delay is zero. * @param [in] dwell the number of ticks of output duration. */ -void SingleTimerExecutor::scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t timeUs, action_s action) { - scheduleByTimestampNt(scheduling, US2NT(timeUs), action); +void SingleTimerExecutor::scheduleByTimestamp(const char *msg, scheduling_s *scheduling, efitimeus_t timeUs, action_s action) { + scheduleByTimestampNt(msg, scheduling, US2NT(timeUs), action); } -void SingleTimerExecutor::scheduleByTimestampNt(scheduling_s* scheduling, efitime_t nt, action_s action) { +void SingleTimerExecutor::scheduleByTimestampNt(const char *msg, scheduling_s* scheduling, efitime_t nt, action_s action) { ScopePerf perf(PE::SingleTimerExecutorScheduleByTimestamp); #if EFI_ENABLE_ASSERTS diff --git a/firmware/controllers/system/timer/single_timer_executor.h b/firmware/controllers/system/timer/single_timer_executor.h index 234726afb5..edab40df97 100644 --- a/firmware/controllers/system/timer/single_timer_executor.h +++ b/firmware/controllers/system/timer/single_timer_executor.h @@ -13,8 +13,8 @@ class SingleTimerExecutor final : public ExecutorInterface { public: SingleTimerExecutor(); - void scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t timeUs, action_s action) override; - void scheduleByTimestampNt(scheduling_s *scheduling, efitime_t timeNt, action_s action) override; + void scheduleByTimestamp(const char *msg, scheduling_s *scheduling, efitimeus_t timeUs, action_s action) override; + void scheduleByTimestampNt(const char *msg, scheduling_s *scheduling, efitime_t timeNt, action_s action) override; void scheduleForLater(scheduling_s *scheduling, int delayUs, action_s action) override; void onTimerCallback(); int timerCallbackCounter = 0; diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 5a6af8bc23..1302da111e 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -200,7 +200,7 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index DECL #if EFI_PROD_CODE writePad("cam debug", CONFIG(camInputsDebug[index]), 1); #endif /* EFI_PROD_CODE */ - engine->executor.scheduleByTimestamp(&debugToggleScheduling, nowNt + DEBUG_PIN_DELAY, &turnOffAllDebugFields); + engine->executor.scheduleByTimestamp("dbg_on", &debugToggleScheduling, nowNt + DEBUG_PIN_DELAY, &turnOffAllDebugFields); } if (CONFIG(displayLogicLevelsInEngineSniffer) && isImportantFront) { @@ -421,7 +421,7 @@ void handleShaftSignal(int signalIndex, bool isRising, efitick_t timestamp DECLA #if EFI_PROD_CODE writePad("trigger debug", CONFIG(triggerInputDebugPins[signalIndex]), 1); #endif /* EFI_PROD_CODE */ - engine->executor.scheduleByTimestamp(&debugToggleScheduling, timestamp + DEBUG_PIN_DELAY, &turnOffAllDebugFields); + engine->executor.scheduleByTimestamp("dbg_off", &debugToggleScheduling, timestamp + DEBUG_PIN_DELAY, &turnOffAllDebugFields); } #if EFI_TOOTH_LOGGER diff --git a/unit_tests/global_execution_queue.cpp b/unit_tests/global_execution_queue.cpp index cf786eaeae..11e6e3261c 100644 --- a/unit_tests/global_execution_queue.cpp +++ b/unit_tests/global_execution_queue.cpp @@ -24,7 +24,7 @@ void TestExecutor::scheduleForLater(scheduling_s *scheduling, int delayUs, actio return; } - scheduleByTimestamp(scheduling, getTimeNowUs() + delayUs, action); + scheduleByTimestamp("test", scheduling, getTimeNowUs() + delayUs, action); } int TestExecutor::executeAll(efitime_t now) { @@ -47,26 +47,26 @@ scheduling_s* TestExecutor::getForUnitTest(int index) { return schedulingQueue.getElementAtIndexForUnitText(index); } -void TestExecutor::scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t timeUs, action_s action) { +void TestExecutor::scheduleByTimestamp(const char *msg, scheduling_s *scheduling, efitimeus_t timeUs, action_s action) { if (debugSignalExecutor) { printf("scheduleByTime %d\r\n", timeUs); } if (m_mockExecutor) { - m_mockExecutor->scheduleByTimestamp(scheduling, timeUs, action); + m_mockExecutor->scheduleByTimestamp("test", scheduling, timeUs, action); return; } schedulingQueue.insertTask(scheduling, timeUs, action); } -void TestExecutor::scheduleByTimestampNt(scheduling_s* scheduling, efitick_t timeNt, action_s action) { +void TestExecutor::scheduleByTimestampNt(const char *msg, scheduling_s* scheduling, efitick_t timeNt, action_s action) { if (m_mockExecutor) { - m_mockExecutor->scheduleByTimestampNt(scheduling, timeNt, action); + m_mockExecutor->scheduleByTimestampNt(msg, scheduling, timeNt, action); return; } - scheduleByTimestamp(scheduling, NT2US(timeNt), action); + scheduleByTimestamp("test", scheduling, NT2US(timeNt), action); } void TestExecutor::setMockExecutor(ExecutorInterface* exec) { diff --git a/unit_tests/global_execution_queue.h b/unit_tests/global_execution_queue.h index 8d7d0e3fc7..72e3de0873 100644 --- a/unit_tests/global_execution_queue.h +++ b/unit_tests/global_execution_queue.h @@ -14,8 +14,8 @@ class TestExecutor : public ExecutorInterface { public: ~TestExecutor(); - void scheduleByTimestamp(scheduling_s *scheduling, efitimeus_t timeUs, action_s action) override; - void scheduleByTimestampNt(scheduling_s *scheduling, efitick_t timeNt, action_s action) override; + void scheduleByTimestamp(const char *msg, scheduling_s *scheduling, efitimeus_t timeUs, action_s action) override; + void scheduleByTimestampNt(const char *msg, scheduling_s *scheduling, efitick_t timeNt, action_s action) override; void scheduleForLater(scheduling_s *scheduling, int delayUs, action_s action) override; void clear(); int executeAll(efitime_t now); diff --git a/unit_tests/mocks.h b/unit_tests/mocks.h index 0a9c50f065..c22d4c6da4 100644 --- a/unit_tests/mocks.h +++ b/unit_tests/mocks.h @@ -54,8 +54,8 @@ public: class MockExecutor : public TestExecutor { public: - MOCK_METHOD(void, scheduleByTimestamp, (scheduling_s *scheduling, efitimeus_t timeUs, action_s action), (override)); - MOCK_METHOD(void, scheduleByTimestampNt, (scheduling_s *scheduling, efitime_t timeUs, action_s action), (override)); + MOCK_METHOD(void, scheduleByTimestamp, (const char *msg, scheduling_s *scheduling, efitimeus_t timeUs, action_s action), (override)); + MOCK_METHOD(void, scheduleByTimestampNt, (const char *msg, scheduling_s *scheduling, efitime_t timeUs, action_s action), (override)); MOCK_METHOD(void, scheduleForLater, (scheduling_s *scheduling, int delayUs, action_s action), (override)); }; diff --git a/unit_tests/tests/trigger/test_injection_scheduling.cpp b/unit_tests/tests/trigger/test_injection_scheduling.cpp index 71a1691f30..b7cda3da80 100644 --- a/unit_tests/tests/trigger/test_injection_scheduling.cpp +++ b/unit_tests/tests/trigger/test_injection_scheduling.cpp @@ -33,9 +33,9 @@ TEST(injectionScheduling, NormalDutyCycle) { // Should schedule one normal injection: // rising edge now - EXPECT_CALL(mockExec, scheduleByTimestampNt(&event.signalTimerUp, nowNt + 0, _)); + EXPECT_CALL(mockExec, scheduleByTimestampNt("test", &event.signalTimerUp, nowNt + 0, _)); // falling edge 10ms later - EXPECT_CALL(mockExec, scheduleByTimestampNt(&event.endOfInjectionEvent, nowNt + MS2NT(20), _)); + EXPECT_CALL(mockExec, scheduleByTimestampNt("test", &event.endOfInjectionEvent, nowNt + MS2NT(20), _)); } engine->rpmCalculator.oneDegreeUs = 100; diff --git a/unit_tests/tests/trigger/test_nissan_vq_vvt.cpp b/unit_tests/tests/trigger/test_nissan_vq_vvt.cpp index 1886439d35..663fc9294e 100644 --- a/unit_tests/tests/trigger/test_nissan_vq_vvt.cpp +++ b/unit_tests/tests/trigger/test_nissan_vq_vvt.cpp @@ -58,7 +58,7 @@ static void scheduleTriggerEvents(TriggerWaveform *shape, param->vvtBankIndex = vvtBankIndex; scheduling_s *sch = new scheduling_s(); - engine->executor.scheduleByTimestamp(sch, timeScale * 1000 * angle, { func, param }); + engine->executor.scheduleByTimestamp("test", sch, timeScale * 1000 * angle, { func, param }); totalIndex++; } }