49 #if EFI_WIDEBAND_FIRMWARE_UPDATE
58 #if (BOARD_TLE8888_COUNT > 0)
71 #define BENCH_MSG "bench"
74 output->
setValue(BENCH_MSG,
true,
true);
78 #if EFI_PROD_CODE && (BOARD_EXT_GPIOCHIPS > 0)
79 static char pin_error[64];
82 if (diag == PIN_UNKNOWN) {
83 efiPrintf(
"No Diag on this pin");
86 efiPrintf(
"Diag says %s", pin_error);
89 output->
setValue(BENCH_MSG,
false,
true);
93 int onTimeUs = MS2US(maxF(0.1, onTimeMs));
94 int offTimeUs = MS2US(maxF(0.1, offTimeMs));
96 if (onTimeUs > TOO_FAR_INTO_FUTURE_US) {
101 efiPrintf(
"Running bench: ON_TIME=%d us OFF_TIME=%d us Counter=%d", onTimeUs, offTimeUs, count);
111 efitick_t startTime = nowNt + US2NT(50);
112 efitick_t endTime = startTime + US2NT(onTimeUs);
119 chThdSleepMicroseconds(onTimeUs + offTimeUs);
147 static void pinbench(
float ontimeMs,
float offtimeMs,
int iterations,
148 OutputPin* pinParam,
bool p_swapOnOff =
false)
172 efiPrintf(
"Invalid index: %d", humanIndex);
175 pinbench(onTimeMs, offTimeMs, count,
179 static void doRunSparkBench(
size_t humanIndex,
float onTime,
float offTime,
int count) {
181 efiPrintf(
"Invalid index: %d", humanIndex);
188 if (humanIndex < 1 || humanIndex > TCU_SOLENOID_COUNT) {
189 efiPrintf(
"Invalid index: %d", humanIndex);
196 if (humanIndex < 1 || humanIndex > LUA_PWM_COUNT) {
197 efiPrintf(
"Invalid index: %d", humanIndex);
200 pinbench(onTimeMs, offTimeMs, count,
208 static void fuelInjBenchExt(
float humanIndex,
float onTimeMs,
float offTimeMs,
float count) {
215 static void fuelInjBench(
float onTimeMs,
float offTimeMs,
float count) {
222 static void sparkBenchExt(
float humanIndex,
float onTime,
float offTimeMs,
float count) {
230 static void sparkBench(
float onTime,
float offTimeMs,
float count) {
238 static void tcuSolenoidBench(
float humanIndex,
float onTime,
float offTimeMs,
float count) {
245 static void luaOutBench2(
float humanIndex,
float onTime,
float offTimeMs,
float count) {
300 class BenchController :
public ThreadController<UTILITY_THREAD_STACK_SIZE> {
316 #if EFI_WIDEBAND_FIRMWARE_UPDATE && EFI_CAN_SUPPORT
420 criticalError(
"Unexpected bench function %d", index);
430 UNUSED(durationsInStateMs);
445 #if (BOARD_TLE8888_COUNT > 0)
450 #if EFI_PROD_CODE && (BOARD_MC33810_COUNT > 0)
456 #if EFI_CONFIGURATION_STORAGE
461 #if EFI_EMULATE_POSITION_SENSORS == TRUE
466 #if EFI_EMULATE_POSITION_SENSORS == TRUE
471 #if EFI_EMULATE_POSITION_SENSORS == TRUE
485 #if EFI_ELECTRONIC_THROTTLE_BODY == TRUE
490 #if EFI_ELECTRONIC_THROTTLE_BODY == TRUE
495 #if EFI_ELECTRONIC_THROTTLE_BODY == TRUE
500 #if EFI_ELECTRONIC_THROTTLE_BODY == TRUE
512 #if EFI_PROD_CODE && EFI_CONFIGURATION_STORAGE
518 criticalError(
"Unexpected bench x14 %d", index);
527 "\n\nTo complete preset apply:\n"
528 " 1. Close TunerStudio\n"
529 " 2. Power cycle ECU\n"
530 " 3. Open TunerStudio and reconnect\n\n");
536 efiPrintf(
"IO test subsystem=%d index=%d", subsystem, index);
580 #if defined(EFI_WIDEBAND_FIRMWARE_UPDATE) && EFI_CAN_SUPPORT
608 #if EFI_PROD_CODE && EFI_DFU_JUMP
627 criticalError(
"Unexpected bench subsystem %d %d", subsystem, index);
666 #if EFI_WIDEBAND_FIRMWARE_UPDATE && EFI_CAN_SUPPORT
void jump_to_bootloader()
static float globalOnTimeMs
static scheduling_s benchSchedStart
void executeTSCommand(uint16_t subsystem, uint16_t index)
void fatalErrorForPresetApply()
static void runBench(OutputPin *output, float onTimeMs, float offTimeMs, int count, bool swapOnOff)
static void sparkBenchExt(float humanIndex, float onTime, float offTimeMs, float count)
PUBLIC_API_WEAK void boardTsAction(uint16_t index)
static volatile bool isBenchTestPending
int getSavedBenchTestPinStates(uint32_t durationsInStateMs[2])
static void benchOff(OutputPin *output)
static void doRunFuelInjBench(size_t humanIndex, float onTimeMs, float offTimeMs, int count)
static void handleCommandX14(uint16_t index)
static void doRunSolenoidBench(size_t humanIndex, float onTime, float offTime, int count)
static void sparkBench(float onTime, float offTimeMs, float count)
static void cancelBenchTest()
static void fanBenchExt(float onTimeMs)
static void doRunSparkBench(size_t humanIndex, float onTime, float offTime, int count)
const OutputPin * getOutputOnTheBenchTest()
static void pinbench(float ontimeMs, float offtimeMs, int iterations, OutputPin *pinParam, bool p_swapOnOff=false)
static bool isRunningBench
static chibios_rt::CounterSemaphore benchSemaphore(0)
static void hdAcrBench(int index)
static void hpfpValveBench()
void onConfigurationChangeBenchTest()
static float globalOffTimeMs
bool isRunningBenchTest()
static void mainRelayBench()
static void doRunBenchTestLuaOutput(size_t humanIndex, float onTimeMs, float offTimeMs, int count)
static uint32_t savedDurationsInStateMs[2]
static void auxOutBench(int index)
static OutputPin * outputOnTheBenchTest
bool rebootForPresetPending
static void luaOutBench2(float humanIndex, float onTime, float offTimeMs, float count)
static bool widebandUpdatePending
static void fuelInjBench(float onTimeMs, float offTimeMs, float count)
static void fuelInjBenchExt(float humanIndex, float onTimeMs, float offTimeMs, float count)
void handleBenchCategory(uint16_t index)
static int savedPinToggleCounter
static scheduling_s benchSchedEnd
static void vvtValveBench(int vvtIndex)
static void tcuSolenoidBench(float humanIndex, float onTime, float offTimeMs, float count)
static void benchOn(OutputPin *output)
static BenchController instance
static void fuelPumpBenchExt(float durationMs)
Utility methods related to bench testing.
SingleTimerExecutor scheduler
RpmCalculator rpmCalculator
TunerStudioOutputChannels outputChannels
RegisteredOutputPin harleyAcr2
RegisteredNamedOutputPin harleyAcr
RegisteredOutputPin mainRelay
OutputPin tcuSolenoids[TCU_SOLENOID_COUNT]
RegisteredOutputPin fanRelay
RegisteredOutputPin starterControl
OutputPin luaOutputPins[LUA_PWM_COUNT]
RegisteredOutputPin fanRelay2
InjectorOutputPin injectors[MAX_CYLINDER_COUNT]
RegisteredOutputPin fuelPumpRelay
RegisteredOutputPin acRelay
IgnitionOutputPin coils[MAX_CYLINDER_COUNT]
RegisteredOutputPin checkEnginePin
RegisteredNamedOutputPin hpfpValve
Single output pin reference and state.
brain_pin_diag_e getDiag() const
uint32_t durationsInStateMs[2]
void setValue(const char *msg, int logicValue, bool isForce=false)
bool isStopped() const override
void schedule(const char *msg, scheduling_s *scheduling, efitick_t timeNt, action_s action) override
Schedule an action to be executed in the future.
A base class for a controller that requires its own thread.
virtual void ThreadTask()=0
void addConsoleActionF(const char *token, VoidFloat callback)
void addConsoleAction(const char *token, Void callback)
Register console action without parameters.
void addConsoleActionI(const char *token, VoidInt callback)
Register a console command with one Integer parameter.
void addConsoleActionFFFF(const char *token, VoidFloatFloatFloatFloat callback)
void addConsoleActionFFF(const char *token, VoidFloatFloatFloat callback)
void etbAutocal(size_t throttleIndex)
@ TS_TRIGGER_STIMULATOR_ENABLE
@ TS_TRIGGER_STIMULATOR_DISABLE
@ TS_EXTERNAL_TRIGGER_STIMULATOR_ENABLE
@ BENCH_AC_COMPRESSOR_RELAY
@ BENCH_CHECK_ENGINE_LIGHT
@ BENCH_STARTER_ENABLE_RELAY
void firmwareError(ObdCode code, const char *fmt,...)
void startIdleBench(void)
UNUSED(samplingTimeSeconds)
This data structure holds current malfunction codes.
@ OBD_PCM_Processor_Fault
engine_configuration_s * engineConfiguration
void pinDiag2string(char *buffer, size_t size, brain_pin_diag_e pin_diag)
const char * hwPortname(brain_pin_e brainPin)
void setWidebandOffset(uint8_t index)
void updateWidebandFirmware()
running("running", SensorCategory.SENSOR_INPUTS, FieldType.INT, 852, 1.0, -1.0, -1.0, "")
void setEngineType(int value, bool isWriteToFlash)
void scheduleStopEngine()
scaled_channel< uint16_t, 100, 1 > benchTestOnTime
scaled_channel< uint16_t, 10, 1 > benchTestOffTime
void grabPedalIsWideOpen()
void disableTriggerStimulator()
void enableExternalTriggerStimulator()
void enableTriggerStimulator(bool incGlobalConfiguration)
OutputPin * getVvtOutputPin(int index)