From a8de570ead0ffdf6df7b0c8f6711297ebe4bcd2e Mon Sep 17 00:00:00 2001 From: rusEfi Date: Mon, 12 Sep 2016 20:02:56 -0400 Subject: [PATCH] auto-sync --- firmware/controllers/algo/signal_executor.cpp | 18 +++++++++++++----- firmware/controllers/alternatorController.cpp | 3 +++ firmware/controllers/system/efiGpio.h | 2 +- unit_tests/test_trigger_decoder.cpp | 10 +++------- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/firmware/controllers/algo/signal_executor.cpp b/firmware/controllers/algo/signal_executor.cpp index ef04b30551..4495732799 100644 --- a/firmware/controllers/algo/signal_executor.cpp +++ b/firmware/controllers/algo/signal_executor.cpp @@ -114,7 +114,15 @@ extern LoggingWithStorage sharedLogger; #endif /* FUEL_MATH_EXTREME_LOGGING */ // todo: make these macro? kind of a penny optimization if compiler is not smart to inline -void seTurnPinHigh(NamedOutputPin *output) { +void seTurnPinHigh(InjectorOutputPin *output) { + if (output->currentLogicValue == 1) { + /** + * #299 + * this is another kind of overlap which happens in case of a small duty cycle after a large duty cycle + */ + output->cancelNextTurningInjectorOff = true; + return; + } #if FUEL_MATH_EXTREME_LOGGING || defined(__DOXYGEN__) const char * w = output->currentLogicValue == true ? "err" : ""; scheduleMsg(&sharedLogger, "^ %spin=%s eventIndex %d %d", w, output->name, @@ -122,8 +130,8 @@ void seTurnPinHigh(NamedOutputPin *output) { #endif /* FUEL_MATH_EXTREME_LOGGING */ #if EFI_UNIT_TEST -// if (output->currentLogicValue == 1) -// firmwareError("Already high"); + if (output->currentLogicValue == 1) + firmwareError("Already high"); #endif turnPinHigh(output); @@ -151,8 +159,8 @@ void seTurnPinLow(InjectorOutputPin *output) { #endif /* FUEL_MATH_EXTREME_LOGGING */ #if EFI_UNIT_TEST -// if (output->currentLogicValue == 0) -// firmwareError("Already low"); + if (output->currentLogicValue == 0) + firmwareError("Already low"); #endif turnPinLow(output); diff --git a/firmware/controllers/alternatorController.cpp b/firmware/controllers/alternatorController.cpp index 967509089a..5c4fdbafd2 100644 --- a/firmware/controllers/alternatorController.cpp +++ b/firmware/controllers/alternatorController.cpp @@ -125,6 +125,9 @@ static void applyAlternatorPinState(PwmConfig *state, int stateIndex) { efiAssertVoid(state->multiWave.waveCount == 1, "invalid idle waveCount"); OutputPin *output = state->outputPins[0]; int value = state->multiWave.waves[0].pinStates[stateIndex]; + /** + * 'engine->isAlternatorControlEnabled' would be false is RPM is too low + */ if (!value || engine->isAlternatorControlEnabled) output->setValue(value); } diff --git a/firmware/controllers/system/efiGpio.h b/firmware/controllers/system/efiGpio.h index 1657e18f69..1ad52daf87 100644 --- a/firmware/controllers/system/efiGpio.h +++ b/firmware/controllers/system/efiGpio.h @@ -139,7 +139,7 @@ public: void outputPinRegisterExt2(const char *msg, OutputPin *output, brain_pin_e brainPin, pin_output_mode_e *outputMode); -void seTurnPinHigh(NamedOutputPin *output); +void seTurnPinHigh(InjectorOutputPin *output); void seTurnPinLow(InjectorOutputPin *output); void turnPinHigh(NamedOutputPin *output); void turnPinLow(NamedOutputPin *output); diff --git a/unit_tests/test_trigger_decoder.cpp b/unit_tests/test_trigger_decoder.cpp index 1a6852970d..b8ba907f74 100644 --- a/unit_tests/test_trigger_decoder.cpp +++ b/unit_tests/test_trigger_decoder.cpp @@ -909,7 +909,7 @@ void testFuelSchedulerBug299smallAndMedium(void) { assertEqualsM("Queue.size#03", 9, schedulingQueue.size()); engine->periodicFastCallback(PASS_ENGINE_PARAMETER_F); assertInjectorUpEvent("07@0", 0, MS2US(7.5), 1); - // todo index 1 + assertInjectorDownEvent("07@1", 1, MS2US(10), 0); assertInjectorUpEvent("07@2", 2, MS2US(17.5), 0); assertInjectorDownEvent("07@3", 3, MS2US(20), 1); assertInjectorUpEvent("07@4", 4, MS2US(27.5), 1); @@ -982,7 +982,6 @@ void testFuelSchedulerBug299smallAndMedium(void) { assertInjectionEvent("#4", &t->injectionEvents.elements[3], 1, 0, 45, false); // todo: what's what? a mix of new something and old something? - assertEqualsM("qs#5", 10, schedulingQueue.size()); assertInjectorDownEvent("8@0", 0, MS2US(5.0), 1); assertInjectorUpEvent("8@1", 1, MS2US(7.5), 1); @@ -992,8 +991,8 @@ void testFuelSchedulerBug299smallAndMedium(void) { assertInjectorUpEvent("8@5", 5, MS2US(27.5), 1); assertInjectorDownEvent("8@6", 6, MS2US(35), 0); assertInjectorUpEvent("8@7", 7, MS2US(37.5), 0); - // todo index 8 9 - + assertInjectorDownEvent("8@8", 8, MS2US(45), 1); + assertInjectorDownEvent("8@9", 9, MS2US(55), 0); schedulingQueue.executeAll(timeNow); @@ -1009,9 +1008,6 @@ void testFuelSchedulerBug299smallAndLarge(void) { setTestBug299(ð); assertEqualsM("Lqs#0", 4, schedulingQueue.size()); - FuelSchedule * t; - - int engineLoadIndex = findIndex(config->fuelLoadBins, FUEL_LOAD_COUNT, testMafValue); assertEquals(8, engineLoadIndex); setArrayValues(fuelMap.pointers[engineLoadIndex], FUEL_RPM_COUNT, 35);