Merge remote-tracking branch 'upstream/master' into export-all-logicdata

This commit is contained in:
Matthew Kennedy 2020-07-20 18:48:54 -07:00
commit a6139c5c70
4 changed files with 41 additions and 48 deletions

View File

@ -1,2 +1,2 @@
#pragma once #pragma once
#define VCS_DATE 20200720 #define VCS_DATE 20200721

View File

@ -71,14 +71,22 @@ static Logging *logger;
//#endif //#endif
void startSimultaniousInjection(Engine *engine) { void startSimultaniousInjection(Engine *engine) {
#if EFI_UNIT_TEST
EXPAND_Engine;
#endif // EFI_UNIT_TEST
efitick_t nowNt = getTimeNowNt();
for (int i = 0; i < engine->engineConfigurationPtr->specs.cylindersCount; i++) { for (int i = 0; i < engine->engineConfigurationPtr->specs.cylindersCount; i++) {
enginePins.injectors[i].open(); enginePins.injectors[i].open(nowNt PASS_ENGINE_PARAMETER_SUFFIX);
} }
} }
static void endSimultaniousInjectionOnlyTogglePins(Engine *engine) { static void endSimultaniousInjectionOnlyTogglePins(Engine *engine) {
#if EFI_UNIT_TEST
EXPAND_Engine;
#endif
efitick_t nowNt = getTimeNowNt();
for (int i = 0; i < engine->engineConfigurationPtr->specs.cylindersCount; i++) { for (int i = 0; i < engine->engineConfigurationPtr->specs.cylindersCount; i++) {
enginePins.injectors[i].close(); enginePins.injectors[i].close(nowNt PASS_ENGINE_PARAMETER_SUFFIX);
} }
} }
@ -88,17 +96,16 @@ void endSimultaniousInjection(InjectionEvent *event) {
EXPAND_Engine; EXPAND_Engine;
#endif #endif
event->isScheduled = false; event->isScheduled = false;
endSimultaniousInjectionOnlyTogglePins(engine); endSimultaniousInjectionOnlyTogglePins(engine);
engine->injectionEvents.addFuelEventsForCylinder(event->ownIndex PASS_ENGINE_PARAMETER_SUFFIX); engine->injectionEvents.addFuelEventsForCylinder(event->ownIndex PASS_ENGINE_PARAMETER_SUFFIX);
} }
void InjectorOutputPin::open() { void InjectorOutputPin::open(efitick_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX) {
overlappingCounter++; overlappingCounter++;
#if FUEL_MATH_EXTREME_LOGGING #if FUEL_MATH_EXTREME_LOGGING
if (printFuelDebug) { if (printFuelDebug) {
printf("turnInjectionPinHigh %s %d %d\r\n", name, overlappingCounter, (int)getTimeNowUs()); printf("InjectorOutputPin::open %s %d now=%0.1fms\r\n", name, overlappingCounter, (int)getTimeNowUs() / 1000.0);
} }
#endif /* FUEL_MATH_EXTREME_LOGGING */ #endif /* FUEL_MATH_EXTREME_LOGGING */
@ -113,31 +120,29 @@ void InjectorOutputPin::open() {
} }
#endif /* FUEL_MATH_EXTREME_LOGGING */ #endif /* FUEL_MATH_EXTREME_LOGGING */
} else { } else {
#if EFI_TOOTH_LOGGER
LogTriggerInjectorState(nowNt, true PASS_ENGINE_PARAMETER_SUFFIX);
#endif // EFI_TOOTH_LOGGER
setHigh(); setHigh();
} }
} }
void turnInjectionPinHigh(InjectionEvent *event) { void turnInjectionPinHigh(InjectionEvent *event) {
efitick_t nowNt = getTimeNowNt();
#if EFI_TOOTH_LOGGER
#if EFI_UNIT_TEST #if EFI_UNIT_TEST
Engine *engine = event->engine; Engine *engine = event->engine;
EXPAND_Engine; EXPAND_Engine;
#endif // EFI_UNIT_TEST #endif // EFI_UNIT_TEST
LogTriggerInjectorState(nowNt, true PASS_ENGINE_PARAMETER_SUFFIX); efitick_t nowNt = getTimeNowNt();
#endif // EFI_TOOTH_LOGGER
for (int i = 0;i < MAX_WIRES_COUNT;i++) { for (int i = 0;i < MAX_WIRES_COUNT;i++) {
InjectorOutputPin *output = event->outputs[i]; InjectorOutputPin *output = event->outputs[i];
if (output) { if (output) {
output->open(); output->open(nowNt PASS_ENGINE_PARAMETER_SUFFIX);
} }
} }
} }
void InjectorOutputPin::close() { void InjectorOutputPin::close(efitick_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX) {
#if FUEL_MATH_EXTREME_LOGGING #if FUEL_MATH_EXTREME_LOGGING
if (printFuelDebug) { if (printFuelDebug) {
printf("InjectorOutputPin::close %s %d %d\r\n", name, overlappingCounter, (int)getTimeNowUs()); printf("InjectorOutputPin::close %s %d %d\r\n", name, overlappingCounter, (int)getTimeNowUs());
@ -152,6 +157,9 @@ void InjectorOutputPin::close() {
} }
#endif /* FUEL_MATH_EXTREME_LOGGING */ #endif /* FUEL_MATH_EXTREME_LOGGING */
} else { } else {
#if EFI_TOOTH_LOGGER
LogTriggerInjectorState(nowNt, false PASS_ENGINE_PARAMETER_SUFFIX);
#endif // EFI_TOOTH_LOGGER
setLow(); setLow();
} }
} }
@ -164,15 +172,11 @@ void turnInjectionPinLow(InjectionEvent *event) {
EXPAND_Engine; EXPAND_Engine;
#endif #endif
#if EFI_TOOTH_LOGGER
LogTriggerInjectorState(nowNt, false PASS_ENGINE_PARAMETER_SUFFIX);
#endif // EFI_TOOTH_LOGGER
event->isScheduled = false; event->isScheduled = false;
for (int i = 0;i<MAX_WIRES_COUNT;i++) { for (int i = 0;i<MAX_WIRES_COUNT;i++) {
InjectorOutputPin *output = event->outputs[i]; InjectorOutputPin *output = event->outputs[i];
if (output) { if (output) {
output->close(); output->close(nowNt PASS_ENGINE_PARAMETER_SUFFIX);
} }
} }
ENGINE(injectionEvents.addFuelEventsForCylinder(event->ownIndex PASS_ENGINE_PARAMETER_SUFFIX)); ENGINE(injectionEvents.addFuelEventsForCylinder(event->ownIndex PASS_ENGINE_PARAMETER_SUFFIX));

View File

@ -108,8 +108,8 @@ public:
InjectorOutputPin(); InjectorOutputPin();
void reset(); void reset();
void open(); void open(efitick_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX);
void close(); void close(efitick_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX);
int8_t getOverlappingCounter() const { return overlappingCounter; } int8_t getOverlappingCounter() const { return overlappingCounter; }

View File

@ -10,19 +10,19 @@
static void doRevolution(EngineTestHelper& eth, int periodMs) { static void doRevolution(EngineTestHelper& eth, int periodMs) {
float halfToothTime = (periodMs / 6.0f) / 2; float halfToothTime = (periodMs / 6.0f) / 2;
eth.fireRise(halfToothTime); eth.smartFireRise(halfToothTime);
eth.fireFall(halfToothTime); eth.fireFall(halfToothTime);
eth.fireRise(halfToothTime); eth.smartFireRise(halfToothTime);
eth.fireFall(halfToothTime); eth.fireFall(halfToothTime);
eth.fireRise(halfToothTime); eth.smartFireRise(halfToothTime);
eth.fireFall(halfToothTime); eth.fireFall(halfToothTime);
// now missing tooth // now missing tooth
eth.fireRise(halfToothTime); eth.smartFireRise(halfToothTime);
eth.fireFall(3 * halfToothTime); eth.fireFall(3 * halfToothTime);
// This tooth is the sync point! // This tooth is the sync point!
eth.fireRise(halfToothTime); eth.smartFireRise(halfToothTime);
eth.fireFall(halfToothTime); eth.fireFall(halfToothTime);
} }
@ -44,6 +44,8 @@ TEST(fuelControl, transitionIssue1592) {
fuelMap.setAll(13); fuelMap.setAll(13);
extern fuel_Map3D_t fuelPhaseMap; extern fuel_Map3D_t fuelPhaseMap;
fuelPhaseMap.setAll(0); fuelPhaseMap.setAll(0);
setArrayValues(config->crankingFuelCoef, 1.0f);
setArrayValues(config->crankingCycleCoef, 1.0f);
engineConfiguration->globalTriggerAngleOffset = 20; engineConfiguration->globalTriggerAngleOffset = 20;
@ -76,32 +78,19 @@ TEST(fuelControl, transitionIssue1592) {
ASSERT_EQ(sched_close->action.getCallback(), &turnInjectionPinLow); ASSERT_EQ(sched_close->action.getCallback(), &turnInjectionPinLow);
} }
// Execute the first of those two events - the injector opens, but doesn't yet close. // Run the engine for some revs
engine->executor.executeAll(getTimeNowUs() + MS2US(35)); for (size_t i = 0; i < 10; i++) {
doRevolution(eth, 150);
// Check that queue got shorter, and overlap counters were incremented on injectors 2/3 (batch mode, remember?)
{
// Check that it was exec'd
ASSERT_EQ(engine->executor.size(), 1);
// Injectors 2/3 should currently be open
EXPECT_EQ(enginePins.injectors[0].getOverlappingCounter(), 0);
EXPECT_EQ(enginePins.injectors[1].getOverlappingCounter(), 1);
EXPECT_EQ(enginePins.injectors[2].getOverlappingCounter(), 1);
EXPECT_EQ(enginePins.injectors[3].getOverlappingCounter(), 0);
} }
// Second sync point will transition to running // Check that no injectors are stuck open
// This needs to reset overlapping state as it may reschedule injector openings // Only injector 1 should currently be open
doRevolution(eth, 150); EXPECT_EQ(enginePins.injectors[0].getOverlappingCounter(), 1);
EXPECT_EQ(enginePins.injectors[1].getOverlappingCounter(), 0);
// Injectors should all be closed immediately after mode change
EXPECT_EQ(enginePins.injectors[0].getOverlappingCounter(), 0);
// !!!!!!!!! BUG !!!!!!!!!!!!!!! // !!!!!!!!! BUG !!!!!!!!!!!!!!!
// These next two should be equal to 0, not 1 // Injector #3 gets stuck open!
EXPECT_EQ(enginePins.injectors[1].getOverlappingCounter(), 1); EXPECT_EQ(enginePins.injectors[2].getOverlappingCounter(), 2);
EXPECT_EQ(enginePins.injectors[2].getOverlappingCounter(), 1);
// !!!!!!!!! BUG !!!!!!!!!!!!!!! // !!!!!!!!! BUG !!!!!!!!!!!!!!!
EXPECT_EQ(enginePins.injectors[3].getOverlappingCounter(), 0); EXPECT_EQ(enginePins.injectors[3].getOverlappingCounter(), 0);