unit_tests "logic analyzer" style output #6403

only:uaefi
This commit is contained in:
rusefillc 2024-12-27 15:38:07 -05:00
parent 11ac5415e1
commit 962483b405
5 changed files with 24 additions and 38 deletions

View File

@ -255,14 +255,20 @@ static void SetNextCompositeEntry(efitick_t timestamp) {
#endif // not EFI_UNIT_TEST
void LogTriggerTooth(trigger_event_e tooth, efitick_t timestamp) {
#define JSON_TRG_PID 4
#define JSON_CAM_PID 10
void LogTriggerCamTooth(bool isRising, efitick_t timestamp, int index) {
jsonTraceEntry("cam", JSON_CAM_PID + index, /*isEnter*/isRising, timestamp);
}
void LogTriggerTooth(trigger_event_e tooth, efitick_t timestamp) {
#if EFI_UNIT_TEST
if (tooth == SHAFT_PRIMARY_RISING) {
jsonTraceEntry("trg0", 54, /*isEnter*/true, timestamp);
jsonTraceEntry("trg0", JSON_TRG_PID, /*isEnter*/true, timestamp);
} else if (tooth == SHAFT_PRIMARY_FALLING) {
jsonTraceEntry("trg0", 54, /*isEnter*/false, timestamp);
jsonTraceEntry("trg0", JSON_TRG_PID, /*isEnter*/false, timestamp);
}
#endif // EFI_UNIT_TEST
@ -326,7 +332,10 @@ void LogTriggerTopDeadCenter(efitick_t timestamp) {
SetNextCompositeEntry(timestamp + 10);
}
void LogTriggerCoilState(efitick_t timestamp, bool state) {
void LogTriggerCoilState(efitick_t timestamp, size_t index, bool state) {
#if EFI_UNIT_TEST
jsonTraceEntry("coil", 20 + index, state, timestamp);
#endif // EFI_UNIT_TEST
if (!ToothLoggerEnabled) {
return;
}
@ -336,16 +345,14 @@ void LogTriggerCoilState(efitick_t timestamp, bool state) {
}
void LogTriggerInjectorState(efitick_t timestamp, size_t index, bool state) {
#if EFI_UNIT_TEST
jsonTraceEntry("inj", 30 + index, state, timestamp);
#endif // EFI_UNIT_TEST
if (!ToothLoggerEnabled) {
return;
}
currentInjectorState = state;
UNUSED(timestamp);
#if EFI_UNIT_TEST
jsonTraceEntry("inj", 10 + index, state, timestamp);
#endif // EFI_UNIT_TEST
//SetNextCompositeEntry(timestamp, trigger1, trigger2, trigger);
}

View File

@ -29,10 +29,11 @@ bool IsToothLoggerEnabled();
// A new tooth has arrived! Log to the buffer if enabled.
void LogTriggerTooth(trigger_event_e tooth, efitick_t timestamp);
void LogTriggerCamTooth(bool isRising, efitick_t timestamp, int index);
void LogTriggerTopDeadCenter(efitick_t timestamp);
void LogTriggerCoilState(efitick_t timestamp, bool state);
void LogTriggerCoilState(efitick_t timestamp, size_t index, bool state);
void LogTriggerInjectorState(efitick_t timestamp, size_t index, bool state);

View File

@ -56,7 +56,7 @@ typedef enum __attribute__ ((__packed__)) {
DBG_ION = 30,
DBG_TLE8888 = 31,
DBG_32 = 32,
DBG_DWELL_METRIC = 33,
DBG_33 = 33,
DBG_34 = 34,
DBG_35 = 35,
DBG_36 = 36,

View File

@ -210,7 +210,7 @@ void fireSparkAndPrepareNextSchedule(IgnitionEvent *event) {
efitick_t nowNt = getTimeNowNt();
#if EFI_TOOTH_LOGGER
LogTriggerCoilState(nowNt, false);
LogTriggerCoilState(nowNt, false, event->coilIndex);
#endif // EFI_TOOTH_LOGGER
float actualDwellMs = event->actualDwellTimer.getElapsedSeconds(nowNt) * 1e3;
@ -222,28 +222,6 @@ void fireSparkAndPrepareNextSchedule(IgnitionEvent *event) {
engine->outputChannels.sadDwellRatioCounter++;
}
#if !EFI_UNIT_TEST
if (engineConfiguration->debugMode == DBG_DWELL_METRIC) {
#if EFI_TUNER_STUDIO
// todo: smarted solution for index to field mapping
switch (event->cylinderIndex) {
case 0:
engine->outputChannels.debugFloatField1 = ratio;
break;
case 1:
engine->outputChannels.debugFloatField2 = ratio;
break;
case 2:
engine->outputChannels.debugFloatField3 = ratio;
break;
case 3:
engine->outputChannels.debugFloatField4 = ratio;
break;
}
#endif
}
#endif /* EFI_UNIT_TEST */
// now that we've just fired a coil let's prepare the new schedule for the next engine revolution
angle_t dwellAngleDuration = engine->ignitionState.dwellDurationAngle;
@ -358,7 +336,7 @@ void turnSparkPinHighStartCharging(IgnitionEvent *event) {
#endif
#if EFI_TOOTH_LOGGER
LogTriggerCoilState(nowNt, true);
LogTriggerCoilState(nowNt, true, event->coilIndex);
#endif // EFI_TOOTH_LOGGER
}

View File

@ -243,7 +243,7 @@ static void logVvtFront(bool useOnlyRise, bool isImportantFront, TriggerValue fr
addEngineSnifferVvtEvent(index, front == TriggerValue::RISE ? FrontDirection::UP : FrontDirection::DOWN);
#if EFI_TOOTH_LOGGER
LogTriggerTooth(front == TriggerValue::RISE ? SHAFT_SECONDARY_RISING : SHAFT_SECONDARY_FALLING, nowNt);
LogTriggerCamTooth(front == TriggerValue::RISE, nowNt, index);
#endif /* EFI_TOOTH_LOGGER */
} else {
if (isImportantFront) {
@ -252,8 +252,8 @@ static void logVvtFront(bool useOnlyRise, bool isImportantFront, TriggerValue fr
addEngineSnifferVvtEvent(index, FrontDirection::DOWN);
#if EFI_TOOTH_LOGGER
LogTriggerTooth(SHAFT_SECONDARY_RISING, nowNt);
LogTriggerTooth(SHAFT_SECONDARY_FALLING, nowNt);
LogTriggerCamTooth(true, nowNt, index);
LogTriggerCamTooth(false, nowNt, index);
#endif /* EFI_TOOTH_LOGGER */
}
}