auto-sync

This commit is contained in:
rusEfi 2016-08-26 17:02:37 -04:00
parent 8d44202569
commit 14c4941552
9 changed files with 84 additions and 32 deletions

View File

@ -78,6 +78,8 @@
#define EFI_SIGNAL_EXECUTOR_ONE_TIMER TRUE #define EFI_SIGNAL_EXECUTOR_ONE_TIMER TRUE
#define EFI_SIGNAL_EXECUTOR_HW_TIMER FALSE #define EFI_SIGNAL_EXECUTOR_HW_TIMER FALSE
#define FUEL_MATH_EXTREME_LOGGING FALSE
#define EFI_INTERNAL_FLASH TRUE #define EFI_INTERNAL_FLASH TRUE
/** /**

View File

@ -37,7 +37,7 @@ EXTERN_ENGINE;
#if EFI_ENGINE_SNIFFER || defined(__DOXYGEN__) #if EFI_ENGINE_SNIFFER || defined(__DOXYGEN__)
#include "engine_sniffer.h" #include "engine_sniffer.h"
extern WaveChart waveChart; extern WaveChart waveChart;
#endif #endif /* EFI_ENGINE_SNIFFER */
#include "efiGpio.h" #include "efiGpio.h"
@ -109,6 +109,42 @@ void turnPinLow(NamedOutputPin *output) {
int getRevolutionCounter(void); int getRevolutionCounter(void);
#if FUEL_MATH_EXTREME_LOGGING
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) {
#if FUEL_MATH_EXTREME_LOGGING || defined(__DOXYGEN__)
const char * w = output->currentLogicValue == true ? "err" : "";
scheduleMsg(&sharedLogger, "^ %spin=%s eventIndex %d", w, output->name,
getRevolutionCounter());
#endif /* FUEL_MATH_EXTREME_LOGGING */
turnPinHigh(output);
}
void seTurnPinLow(NamedOutputPin *output) {
#if FUEL_MATH_EXTREME_LOGGING || defined(__DOXYGEN__)
const char * w = output->currentLogicValue == false ? "err" : "";
scheduleMsg(&sharedLogger, "- %spin=%s eventIndex %d", w, output->name,
getRevolutionCounter());
#endif /* FUEL_MATH_EXTREME_LOGGING */
turnPinLow(output);
}
void seScheduleByTime(const char *prefix, scheduling_s *scheduling, efitimeus_t time, schfunc_t callback, NamedOutputPin *param) {
#if FUEL_MATH_EXTREME_LOGGING || defined(__DOXYGEN__)
scheduleMsg(&sharedLogger, "sch %s %x %d %s", prefix, scheduling,
time, param->name);
#endif /* FUEL_MATH_EXTREME_LOGGING */
scheduleByTime(prefix, scheduling, time, callback, param);
}
/** /**
* *
* @param delay the number of ticks before the output signal * @param delay the number of ticks before the output signal
@ -135,7 +171,7 @@ void scheduleOutput(OutputSignal *signal, efitimeus_t nowUs, float delayUs, floa
printf("scheduling output %s\r\n", output->name); printf("scheduling output %s\r\n", output->name);
#endif #endif
scheduleByTime("out up", sUp, nowUs + (int) delayUs, (schfunc_t) &turnPinHigh, output); seScheduleByTime("out up", sUp, nowUs + (int) delayUs, (schfunc_t) &seTurnPinHigh, output);
scheduleByTime("out down", sDown, nowUs + (int) (delayUs + durationUs), (schfunc_t) &turnPinLow, output); seScheduleByTime("out down", sDown, nowUs + (int) (delayUs + durationUs), (schfunc_t) &seTurnPinLow, output);
#endif #endif
} }

View File

@ -129,6 +129,8 @@ typedef struct {
void outputPinRegisterExt2(const char *msg, OutputPin *output, brain_pin_e brainPin, pin_output_mode_e *outputMode); void outputPinRegisterExt2(const char *msg, OutputPin *output, brain_pin_e brainPin, pin_output_mode_e *outputMode);
void seTurnPinHigh(NamedOutputPin *output);
void seTurnPinLow(NamedOutputPin *output);
void turnPinHigh(NamedOutputPin *output); void turnPinHigh(NamedOutputPin *output);
void turnPinLow(NamedOutputPin *output); void turnPinLow(NamedOutputPin *output);
void turnSparkPinHigh(NamedOutputPin *output); void turnSparkPinHigh(NamedOutputPin *output);

View File

@ -128,8 +128,10 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int eventIndex, bool limitedF
return; return;
} }
// scheduleMsg(logger, "handleFuel totalPerCycle=%f", totalPerCycle); #if EFI_ENGINE_SNIFFER || defined(__DOXYGEN__)
// scheduleMsg(logger, "handleFuel engineCycleDuration=%f", engineCycleDuration); scheduleMsg(logger, "handleFuel totalPerCycle=%f", totalPerCycle);
scheduleMsg(logger, "handleFuel engineCycleDuration=%f", engineCycleDuration);
#endif /* EFI_DEFAILED_LOGGING */
if (engine->isCylinderCleanupMode) { if (engine->isCylinderCleanupMode) {
return; return;
@ -137,12 +139,14 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int eventIndex, bool limitedF
floatus_t injectionStartDelayUs = ENGINE(rpmCalculator.oneDegreeUs) * event->injectionStart.angleOffset; floatus_t injectionStartDelayUs = ENGINE(rpmCalculator.oneDegreeUs) * event->injectionStart.angleOffset;
// scheduleMsg(logger, "handleFuel pin=%s eventIndex %d duration=%fms %d", event->output->name, #if EFI_ENGINE_SNIFFER || defined(__DOXYGEN__)
// eventIndex, scheduleMsg(logger, "handleFuel pin=%s eventIndex %d duration=%fms %d", event->output->name,
// injectionDuration, eventIndex,
// getRevolutionCounter()); injectionDuration,
// scheduleMsg(logger, "handleFuel pin=%s delay=%f %d", event->output->name, injectionStartDelayUs, getRevolutionCounter());
// getRevolutionCounter()); scheduleMsg(logger, "handleFuel pin=%s delay=%f %d", event->output->name, injectionStartDelayUs,
getRevolutionCounter());
#endif /* EFI_DEFAILED_LOGGING */
OutputSignal *signal = &ENGINE(engineConfiguration2)->fuelActuators[eventIndex]; OutputSignal *signal = &ENGINE(engineConfiguration2)->fuelActuators[eventIndex];
@ -196,7 +200,9 @@ static ALWAYS_INLINE void handleFuel(bool limitedFuel, uint32_t eventIndex, int
if (!fs->hasEvents[eventIndex]) if (!fs->hasEvents[eventIndex])
return; return;
// scheduleMsg(logger, "handleFuel ind=%d %d", eventIndex, getRevolutionCounter()); #if EFI_DEFAILED_LOGGING || defined(__DOXYGEN__)
scheduleMsg(logger, "handleFuel ind=%d %d", eventIndex, getRevolutionCounter());
#endif /* EFI_DEFAILED_LOGGING */
ENGINE(tpsAccelEnrichment.onNewValue(getTPS(PASS_ENGINE_PARAMETER_F) PASS_ENGINE_PARAMETER)); ENGINE(tpsAccelEnrichment.onNewValue(getTPS(PASS_ENGINE_PARAMETER_F) PASS_ENGINE_PARAMETER));
ENGINE(engineLoadAccelEnrichment.onEngineCycle(PASS_ENGINE_PARAMETER_F)); ENGINE(engineLoadAccelEnrichment.onEngineCycle(PASS_ENGINE_PARAMETER_F));

View File

@ -11,6 +11,7 @@
#include "speed_density.h" #include "speed_density.h"
#include "fuel_math.h" #include "fuel_math.h"
#include "accel_enrichment.h" #include "accel_enrichment.h"
#include "thermistors.h"
extern int timeNow; extern int timeNow;
@ -47,6 +48,10 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType) : engine (&persiste
resetConfigurationExt(NULL, engineType PASS_ENGINE_PARAMETER); resetConfigurationExt(NULL, engineType PASS_ENGINE_PARAMETER);
prepareShapes(PASS_ENGINE_PARAMETER_F); prepareShapes(PASS_ENGINE_PARAMETER_F);
engine->engineConfiguration->mafAdcChannel = (adc_channel_e)TEST_MAF_CHANNEL; engine->engineConfiguration->mafAdcChannel = (adc_channel_e)TEST_MAF_CHANNEL;
initThermistors(NULL PASS_ENGINE_PARAMETER);
// this is needed to have valid CLT and IAT.
engine->updateSlowSensors(PASS_ENGINE_PARAMETER_F);
} }
void EngineTestHelper::fireTriggerEvents(int count) { void EngineTestHelper::fireTriggerEvents(int count) {

View File

@ -106,6 +106,7 @@ int getRevolutionCounter(void) {
} }
int main(void) { int main(void) {
testFuelSchedulerBug299();
testLogicExpressions(); testLogicExpressions();
testOverflow64Counter(); testOverflow64Counter();
testInterpolate3d(); testInterpolate3d();

View File

@ -55,7 +55,6 @@ void testFuelMap(void) {
printf("*************************************************** initThermistors\r\n"); printf("*************************************************** initThermistors\r\n");
initThermistors(NULL PASS_ENGINE_PARAMETER);
printf("*** getInjectorLag\r\n"); printf("*** getInjectorLag\r\n");
assertEqualsM("lag", 1.04, getInjectorLag(12 PASS_ENGINE_PARAMETER)); assertEqualsM("lag", 1.04, getInjectorLag(12 PASS_ENGINE_PARAMETER));

View File

@ -123,7 +123,6 @@ void test1995FordInline6TriggerDecoder(void) {
assertEqualsM("triggerShapeSynchPointIndex", 0, shape->getTriggerShapeSynchPointIndex()); assertEqualsM("triggerShapeSynchPointIndex", 0, shape->getTriggerShapeSynchPointIndex());
// this is needed to have valid CLT and IAT. todo: extract method // this is needed to have valid CLT and IAT. todo: extract method
initThermistors(NULL PASS_ENGINE_PARAMETER);
engine->updateSlowSensors(PASS_ENGINE_PARAMETER_F); engine->updateSlowSensors(PASS_ENGINE_PARAMETER_F);
event_trigger_position_s position; event_trigger_position_s position;
@ -207,13 +206,6 @@ void testFordAspire(void) {
assertEqualsM("higher rpm dwell", 3.25, getSparkDwell(6000 PASS_ENGINE_PARAMETER)); assertEqualsM("higher rpm dwell", 3.25, getSparkDwell(6000 PASS_ENGINE_PARAMETER));
} }
void testMazda323(void) {
printf("*************************************************** testMazda323\r\n");
EngineTestHelper eth(MAZDA_323);
assertEquals(0, eth.engine.triggerShape.getTriggerShapeSynchPointIndex());
}
static void testTriggerDecoder2(const char *msg, engine_type_e type, int synchPointIndex, float channel1duty, float channel2duty) { static void testTriggerDecoder2(const char *msg, engine_type_e type, int synchPointIndex, float channel1duty, float channel2duty) {
printf("*************************************************** %s\r\n", msg); printf("*************************************************** %s\r\n", msg);
@ -241,7 +233,7 @@ extern EventQueue schedulingQueue;
extern int mockTps; extern int mockTps;
static void testStartupFuelPumping(void) { void testStartupFuelPumping(void) {
printf("*************************************************** testStartupFuelPumping\r\n"); printf("*************************************************** testStartupFuelPumping\r\n");
EngineTestHelper eth(FORD_INLINE_6_1995); EngineTestHelper eth(FORD_INLINE_6_1995);
EXPAND_EngineTestHelper; EXPAND_EngineTestHelper;
@ -307,16 +299,10 @@ void testRpmCalculator(void) {
efiAssertVoid(eth.engine.engineConfiguration!=NULL, "null config in engine"); efiAssertVoid(eth.engine.engineConfiguration!=NULL, "null config in engine");
// this is needed to have valid CLT and IAT. todo: extract method
initThermistors(NULL PASS_ENGINE_PARAMETER);
engine->updateSlowSensors(PASS_ENGINE_PARAMETER_F);
engineConfiguration->trigger.customTotalToothCount = 8; engineConfiguration->trigger.customTotalToothCount = 8;
engineConfiguration->globalFuelCorrection = 3; engineConfiguration->globalFuelCorrection = 3;
eth.initTriggerShapeAndRpmCalculator(); eth.initTriggerShapeAndRpmCalculator();
// this is a very dirty and sad hack. todo: eliminate
// engine.engineConfiguration = eth.engine.engineConfiguration;
setInjectorLag(0 PASS_ENGINE_PARAMETER); setInjectorLag(0 PASS_ENGINE_PARAMETER);
engine->updateSlowSensors(PASS_ENGINE_PARAMETER_F); engine->updateSlowSensors(PASS_ENGINE_PARAMETER_F);
@ -423,7 +409,7 @@ void testRpmCalculator(void) {
{ {
scheduling_s *ev0 = schedulingQueue.getForUnitText(0); scheduling_s *ev0 = schedulingQueue.getForUnitText(0);
assertREquals((void*)ev0->callback, (void*)turnPinHigh); assertREqualsM("turnHigh", (void*)ev0->callback, (void*)seTurnPinHigh);
assertEqualsM("ev 0/2", st + 26666 - 1515, ev0->momentX); assertEqualsM("ev 0/2", st + 26666 - 1515, ev0->momentX);
assertEqualsLM("o 0/2", (long)&enginePins.injectors[2], (long)ev0->param); assertEqualsLM("o 0/2", (long)&enginePins.injectors[2], (long)ev0->param);
@ -556,11 +542,12 @@ void testTriggerDecoder(void) {
// assertEqualsM2("rpm#2", 16666.3750, eth.engine.triggerCentral.triggerState.instantRpmValue[1], 0.5); // assertEqualsM2("rpm#2", 16666.3750, eth.engine.triggerCentral.triggerState.instantRpmValue[1], 0.5);
} }
// testTriggerDecoder2("miata 1990", MIATA_1990, 0, 0.6280, 0.0); testTriggerDecoder2("miata 1990", MIATA_1990, 11, 0.2985, 0.3890);
testTriggerDecoder3("miata 1994", MIATA_1994_DEVIATOR, 11, 0.2985, 0.3890, MIATA_NA_GAP); testTriggerDecoder3("miata 1994", MIATA_1994_DEVIATOR, 11, 0.2985, 0.3890, MIATA_NA_GAP);
testTriggerDecoder3("citroen", CITROEN_TU3JP, 0, 0.4833, 0.0, 2.9994); testTriggerDecoder3("citroen", CITROEN_TU3JP, 0, 0.4833, 0.0, 2.9994);
// testTriggerDecoder3("neon NGC4", DODGE_NEON_2003, 70, 0.5000, 0.4983, CHRYSLER_NGC4_GAP); testTriggerDecoder2("MAZDA_323", MAZDA_323, 0, 0.4833, 0);
testTriggerDecoder3("neon NGC4", DODGE_NEON_2003, 6, 0.5000, 0.0, CHRYSLER_NGC4_GAP); testTriggerDecoder3("neon NGC4", DODGE_NEON_2003, 6, 0.5000, 0.0, CHRYSLER_NGC4_GAP);
{ {
@ -586,8 +573,20 @@ void testTriggerDecoder(void) {
testTriggerDecoder2("vw ABA", VW_ABA, 114, 0.5000, 0.0); testTriggerDecoder2("vw ABA", VW_ABA, 114, 0.5000, 0.0);
testMazda323();
testStartupFuelPumping(); testStartupFuelPumping();
testRpmCalculator(); testRpmCalculator();
} }
void testFuelSchedulerBug299(void) {
printf("*************************************************** testFuelSchedulerBug299\r\n");
EngineTestHelper eth(TEST_ENGINE);
EXPAND_EngineTestHelper;
timeNow = 0;
schedulingQueue.clear();
assertEqualsM("CLT", 70, engine->engineState.clt);
}

View File

@ -9,7 +9,9 @@
#define TEST_TRIGGER_DECODER_H_ #define TEST_TRIGGER_DECODER_H_
void testTriggerDecoder(void); void testTriggerDecoder(void);
void testFuelSchedulerBug299(void);
void testRpmCalculator(void); void testRpmCalculator(void);
void testStartupFuelPumping(void);
void test1995FordInline6TriggerDecoder(void); void test1995FordInline6TriggerDecoder(void);
#endif /* TEST_TRIGGER_DECODER_H_ */ #endif /* TEST_TRIGGER_DECODER_H_ */