From 22d73f72e31d5fbc3b832316f322c56c176dae8f Mon Sep 17 00:00:00 2001 From: rusefi Date: Sat, 19 Jan 2019 19:45:35 -0500 Subject: [PATCH] #674 fix? --- firmware/controllers/trigger/rpm_calculator.cpp | 8 -------- unit_tests/tests/test_fasterEngineSpinningUp.cpp | 9 +++++---- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/firmware/controllers/trigger/rpm_calculator.cpp b/firmware/controllers/trigger/rpm_calculator.cpp index 76df9d05f7..113d6742f3 100644 --- a/firmware/controllers/trigger/rpm_calculator.cpp +++ b/firmware/controllers/trigger/rpm_calculator.cpp @@ -59,9 +59,6 @@ RpmCalculator::RpmCalculator() { // we need this initial to have not_running at first invocation lastRpmEventTimeNt = (efitime_t) -10 * US2NT(US_PER_SECOND_LL); revolutionCounterSinceBootForUnitTest = 0; - - // WAT? this was just assigned a non-zero value a few lines above? which one is right? - lastRpmEventTimeNt = 0; } bool RpmCalculator::isStopped(DECLARE_ENGINE_PARAMETER_SIGNATURE) { @@ -89,11 +86,6 @@ bool RpmCalculator::isRunning(DECLARE_ENGINE_PARAMETER_SIGNATURE) { * @return true if engine is spinning (cranking or running) */ bool RpmCalculator::checkIfSpinning(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - if (lastRpmEventTimeNt == 0) { - // here we assume 64 bit time does not overflow - // zero value is the default meaning no RPM events since reboot - return false; - } efitick_t nowNt = getTimeNowNt(); if (ENGINE(needToStopEngine(nowNt))) { setStopped(PASS_ENGINE_PARAMETER_SIGNATURE); diff --git a/unit_tests/tests/test_fasterEngineSpinningUp.cpp b/unit_tests/tests/test_fasterEngineSpinningUp.cpp index 4e42a3a9d9..b0385628a1 100644 --- a/unit_tests/tests/test_fasterEngineSpinningUp.cpp +++ b/unit_tests/tests/test_fasterEngineSpinningUp.cpp @@ -14,9 +14,10 @@ TEST(sensors, testFasterEngineSpinningUp) { EngineTestHelper eth(TEST_ENGINE); EXPAND_EngineTestHelper - // turn on FasterEngineSpinUp mode engineConfiguration->bc.isFasterEngineSpinUpEnabled = true; + eth.firePrimaryTriggerRise(); + // set ignition mode engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; // set cranking threshold (used below) @@ -65,7 +66,7 @@ TEST(sensors, testFasterEngineSpinningUp) { // check if the mode is changed when fully synched ASSERT_EQ(CRANKING, engine->rpmCalculator.getState()); // check RPM - ASSERT_EQ( 300, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)) << "RPM#2"; + ASSERT_EQ( 200, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)) << "RPM#2"; // test if they are simultaneous in cranking mode too ASSERT_EQ(IM_SIMULTANEOUS, engine->getCurrentInjectionMode(PASS_ENGINE_PARAMETER_SIGNATURE)); // test if ignition mode is restored to ind.coils @@ -73,8 +74,8 @@ TEST(sensors, testFasterEngineSpinningUp) { // two simultaneous injections ASSERT_EQ( 4, engine->executor.size()) << "plain#2"; // check real events - eth.assertEvent5(&engine->executor, "inj start#2", 0, (void*)startSimultaniousInjection, eth.getTimeNowUs(), 97975); - eth.assertEvent5(&engine->executor, "inj end#2", 1, (void*)endSimultaniousInjection, eth.getTimeNowUs(), 100000); + eth.assertEvent5(&engine->executor, "inj start#2", 0, (void*)startSimultaniousInjection, eth.getTimeNowUs(), 147975); + eth.assertEvent5(&engine->executor, "inj end#2", 1, (void*)endSimultaniousInjection, eth.getTimeNowUs(), 150000); // skip, clear & advance 1 more revolution at higher RPM eth.fireFall(60);