rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions | Variables
bench_test.cpp File Reference

Detailed Description

Utility methods related to bench testing.

Date
Sep 8, 2013
Author
Andrey Belomutskiy, (c) 2012-2020

This file is part of rusEfi - see http://rusefi.com

rusEfi is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

rusEfi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file bench_test.cpp.

Functions

bool isRunningBenchTest ()
 
const OutputPingetOutputOnTheBenchTest ()
 
static void benchOn (OutputPin *output)
 
static void benchOff (OutputPin *output)
 
static void runBench (OutputPin *output, float onTimeMs, float offTimeMs, int count, bool swapOnOff)
 
static chibios_rt::CounterSemaphore benchSemaphore (0)
 
static void pinbench (float ontimeMs, float offtimeMs, int iterations, OutputPin *pinParam, bool p_swapOnOff=false)
 
static void cancelBenchTest ()
 
static void doRunFuelInjBench (size_t humanIndex, float onTimeMs, float offTimeMs, int count)
 
static void doRunSparkBench (size_t humanIndex, float onTime, float offTime, int count)
 
static void doRunSolenoidBench (size_t humanIndex, float onTime, float offTime, int count)
 
static void doRunBenchTestLuaOutput (size_t humanIndex, float onTimeMs, float offTimeMs, int count)
 
static void fuelInjBenchExt (float humanIndex, float onTimeMs, float offTimeMs, float count)
 
static void fuelInjBench (float onTimeMs, float offTimeMs, float count)
 
static void sparkBenchExt (float humanIndex, float onTime, float offTimeMs, float count)
 
static void sparkBench (float onTime, float offTimeMs, float count)
 
static void tcuSolenoidBench (float humanIndex, float onTime, float offTimeMs, float count)
 
static void luaOutBench2 (float humanIndex, float onTime, float offTimeMs, float count)
 
static void fanBenchExt (float onTimeMs)
 
void fanBench ()
 
void fan2Bench ()
 
void milBench ()
 
void starterRelayBench ()
 
static void fuelPumpBenchExt (float durationMs)
 
void acRelayBench ()
 
static void mainRelayBench ()
 
static void hpfpValveBench ()
 
void fuelPumpBench ()
 
static void vvtValveBench (int vvtIndex)
 
static void auxOutBench (int index)
 
static void hdAcrBench (int index)
 
void handleBenchCategory (uint16_t index)
 
int getSavedBenchTestPinStates (uint32_t durationsInStateMs[2])
 
static void handleCommandX14 (uint16_t index)
 
static void applyPreset (int index)
 
PUBLIC_API_WEAK void boardTsAction (uint16_t index)
 
void executeTSCommand (uint16_t subsystem, uint16_t index)
 
void onConfigurationChangeBenchTest ()
 
void initBenchTest ()
 

Variables

static bool isRunningBench = false
 
static OutputPinoutputOnTheBenchTest = nullptr
 
static scheduling_s benchSchedStart
 
static scheduling_s benchSchedEnd
 
static int savedPinToggleCounter = 0
 
static uint32_t savedDurationsInStateMs [2] = { 0, 0 }
 
static volatile bool isBenchTestPending = false
 
static bool widebandUpdatePending = false
 
static float globalOnTimeMs
 
static float globalOffTimeMs
 
static int globalCount
 
static OutputPinpinX
 
static bool swapOnOff = false
 
static BenchController instance
 
bool rebootForPresetPending
 

Function Documentation

◆ acRelayBench()

void acRelayBench ( )

Definition at line 278 of file bench_test.cpp.

278 {
279 pinbench(BENCH_AC_RELAY_DURATION, 100.0, 1, &enginePins.acRelay);
280}
static void pinbench(float ontimeMs, float offtimeMs, int iterations, OutputPin *pinParam, bool p_swapOnOff=false)
RegisteredOutputPin acRelay
Definition efi_gpio.h:90
EnginePins enginePins
Definition efi_gpio.cpp:24

Referenced by handleBenchCategory(), and initBenchTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ applyPreset()

static void applyPreset ( int  index)
static

Definition at line 534 of file bench_test.cpp.

534 {
535#if EFI_TUNER_STUDIO
537#endif // EFI_TUNER_STUDIO
538 setEngineType(index);
539}
void setEngineType(int value, bool isWriteToFlash)
Definition settings.cpp:733
void onApplyPreset()

Referenced by executeTSCommand().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ auxOutBench()

static void auxOutBench ( int  index)
static

Definition at line 328 of file bench_test.cpp.

328 {
329 // todo!
330}

Referenced by handleBenchCategory().

Here is the caller graph for this function:

◆ benchOff()

static void benchOff ( OutputPin output)
static

Definition at line 78 of file bench_test.cpp.

78 {
79#if EFI_PROD_CODE && (BOARD_EXT_GPIOCHIPS > 0)
80 static char pin_error[64];
81
82 brain_pin_diag_e diag = output->getDiag();
83 if (diag == PIN_UNKNOWN) {
84 efiPrintf("No Diag on this pin");
85 } else {
86 pinDiag2string(pin_error, sizeof(pin_error), diag);
87 efiPrintf("Diag says %s", pin_error);
88 }
89#endif // EFI_PROD_CODE
90 output->setValue(BENCH_MSG, false, /*isForce*/ true);
91}
brain_pin_diag_e getDiag() const
Definition efi_gpio.cpp:664
void setValue(const char *msg, int logicValue, bool isForce=false)
Definition efi_gpio.cpp:590
void pinDiag2string(char *buffer, size_t size, brain_pin_diag_e pin_diag)
brain_pin_diag_e

Referenced by runBench().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ benchOn()

static void benchOn ( OutputPin output)
static

Definition at line 74 of file bench_test.cpp.

74 {
75 output->setValue(BENCH_MSG, true, /*isForce*/ true);
76}

Referenced by runBench().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ benchSemaphore()

static chibios_rt::CounterSemaphore benchSemaphore ( )
static

Referenced by handleCommandX14(), and pinbench().

Here is the caller graph for this function:

◆ boardTsAction()

PUBLIC_API_WEAK void boardTsAction ( uint16_t  index)

Definition at line 541 of file bench_test.cpp.

541{ }

Referenced by executeTSCommand().

Here is the caller graph for this function:

◆ cancelBenchTest()

static void cancelBenchTest ( )
static

Definition at line 165 of file bench_test.cpp.

165 {
166 isRunningBench = false;
167}
static bool isRunningBench

Referenced by handleBenchCategory().

Here is the caller graph for this function:

◆ doRunBenchTestLuaOutput()

static void doRunBenchTestLuaOutput ( size_t  humanIndex,
float  onTimeMs,
float  offTimeMs,
int  count 
)
static

Definition at line 196 of file bench_test.cpp.

196 {
197 if (humanIndex < 1 || humanIndex > LUA_PWM_COUNT) {
198 efiPrintf("Invalid index: %d", humanIndex);
199 return;
200 }
201 pinbench(onTimeMs, offTimeMs, count,
202 &enginePins.luaOutputPins[humanIndex - 1]);
203}
OutputPin luaOutputPins[LUA_PWM_COUNT]
Definition efi_gpio.h:99

Referenced by executeTSCommand(), and luaOutBench2().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ doRunFuelInjBench()

static void doRunFuelInjBench ( size_t  humanIndex,
float  onTimeMs,
float  offTimeMs,
int  count 
)
static

Definition at line 171 of file bench_test.cpp.

171 {
172 if (humanIndex < 1 || humanIndex > engineConfiguration->cylindersCount) {
173 efiPrintf("Invalid index: %d", humanIndex);
174 return;
175 }
176 pinbench(onTimeMs, offTimeMs, count,
177 &enginePins.injectors[humanIndex - 1]);
178}
InjectorOutputPin injectors[MAX_CYLINDER_COUNT]
Definition efi_gpio.h:126
static constexpr engine_configuration_s * engineConfiguration

Referenced by executeTSCommand(), and fuelInjBenchExt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ doRunSolenoidBench()

static void doRunSolenoidBench ( size_t  humanIndex,
float  onTime,
float  offTime,
int  count 
)
static

Definition at line 188 of file bench_test.cpp.

188 {
189 if (humanIndex < 1 || humanIndex > TCU_SOLENOID_COUNT) {
190 efiPrintf("Invalid index: %d", humanIndex);
191 return;
192 }
193 pinbench(onTime, offTime, count, &enginePins.tcuSolenoids[humanIndex - 1]);
194}
OutputPin tcuSolenoids[TCU_SOLENOID_COUNT]
Definition efi_gpio.h:131

Referenced by executeTSCommand(), and tcuSolenoidBench().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ doRunSparkBench()

static void doRunSparkBench ( size_t  humanIndex,
float  onTime,
float  offTime,
int  count 
)
static

Definition at line 180 of file bench_test.cpp.

180 {
181 if (humanIndex < 1 || humanIndex > engineConfiguration->cylindersCount) {
182 efiPrintf("Invalid index: %d", humanIndex);
183 return;
184 }
185 pinbench(onTime, offTime, count, &enginePins.coils[humanIndex - 1]);
186}
IgnitionOutputPin coils[MAX_CYLINDER_COUNT]
Definition efi_gpio.h:128

Referenced by executeTSCommand(), and sparkBenchExt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ executeTSCommand()

void executeTSCommand ( uint16_t  subsystem,
uint16_t  index 
)

Definition at line 543 of file bench_test.cpp.

543 {
544 efiPrintf("IO test subsystem=%d index=%d", subsystem, index);
545
547
548 switch (subsystem) {
551 break;
552
553 case TS_DEBUG_MODE:
555 break;
556
558 if (!running) {
561 }
562 break;
563
565 if (!running) {
568 }
569 break;
570
572 if (!running) {
573 doRunSolenoidBench(index, 1000.0,
575 }
576 break;
577
579 if (!running) {
580 doRunBenchTestLuaOutput(index, 4.0,
582 }
583 break;
584
585 case TS_X14:
586 handleCommandX14(index);
587 break;
588#if defined(EFI_WIDEBAND_FIRMWARE_UPDATE) && EFI_CAN_SUPPORT
589 case TS_WIDEBAND:
590 setWidebandOffset(index);
591 break;
592#endif // EFI_WIDEBAND_FIRMWARE_UPDATE && EFI_CAN_SUPPORT
594 handleBenchCategory(index);
595 break;
596
598 applyPreset(index);
599 break;
600
601 case TS_BOARD_ACTION:
602 boardTsAction(index);
603 break;
604
606 applyPreset((int)DEFAULT_ENGINE_TYPE);
607 break;
608
609 case 0x79:
611 break;
612
613 case 0xba:
614#if EFI_PROD_CODE && EFI_DFU_JUMP
616#endif /* EFI_DFU_JUMP */
617 break;
618
619 case REBOOT_COMMAND:
620#if EFI_PROD_CODE
621 rebootNow();
622#endif /* EFI_PROD_CODE */
623 break;
624
625#if EFI_USE_OPENBLT
626 case 0xbc:
627 /* Jump to OpenBLT if present */
629 break;
630#endif
631
632 default:
633 criticalError("Unexpected bench subsystem %d %d", subsystem, index);
634 }
635}
void jump_to_openblt()
void jump_to_bootloader()
PUBLIC_API_WEAK void boardTsAction(uint16_t index)
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 doRunSparkBench(size_t humanIndex, float onTime, float offTime, int count)
static void doRunBenchTestLuaOutput(size_t humanIndex, float onTimeMs, float offTimeMs, int count)
void handleBenchCategory(uint16_t index)
static void applyPreset(int index)
RpmCalculator rpmCalculator
Definition engine.h:287
bool isStopped() const override
static Engine *const engine
Definition engine.h:389
debug_mode_e
@ TS_WIDEBAND
@ TS_CLEAR_WARNINGS
@ TS_BOARD_ACTION
@ TS_SOLENOID_CATEGORY
@ TS_LUA_OUTPUT_CATEGORY
@ TS_DEBUG_MODE
@ TS_SET_ENGINE_TYPE
@ TS_X14
@ TS_IGNITION_CATEGORY
@ TS_BENCH_CATEGORY
@ TS_SET_DEFAULT_ENGINE
@ TS_INJECTOR_CATEGORY
void clearWarnings(void)
void rebootNow()
Definition rusefi.cpp:150
void setWidebandOffset(uint8_t index)
running("running", SensorCategory.SENSOR_INPUTS, FieldType.INT, 864, 1.0, -1.0, -1.0, "")
void scheduleStopEngine()
Definition settings.cpp:458

Referenced by TunerStudio::handleCrcCommand().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fan2Bench()

void fan2Bench ( )

Definition at line 258 of file bench_test.cpp.

258 {
259 pinbench(3000.0, 100.0, 1, &enginePins.fanRelay2);
260}
RegisteredOutputPin fanRelay2
Definition efi_gpio.h:87

Referenced by handleBenchCategory(), and initBenchTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fanBench()

void fanBench ( )

Definition at line 254 of file bench_test.cpp.

254 {
255 fanBenchExt(BENCH_FAN_DURATION);
256}
static void fanBenchExt(float onTimeMs)

Referenced by handleBenchCategory(), and initBenchTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fanBenchExt()

static void fanBenchExt ( float  onTimeMs)
static

Definition at line 250 of file bench_test.cpp.

250 {
251 pinbench(onTimeMs, 100.0, 1, &enginePins.fanRelay);
252}
RegisteredOutputPin fanRelay
Definition efi_gpio.h:86

Referenced by fanBench(), and initBenchTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fuelInjBench()

static void fuelInjBench ( float  onTimeMs,
float  offTimeMs,
float  count 
)
static

fuelbench 5 1000 2

Definition at line 216 of file bench_test.cpp.

216 {
217 fuelInjBenchExt(1, onTimeMs, offTimeMs, count);
218}
static void fuelInjBenchExt(float humanIndex, float onTimeMs, float offTimeMs, float count)

Referenced by initBenchTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fuelInjBenchExt()

static void fuelInjBenchExt ( float  humanIndex,
float  onTimeMs,
float  offTimeMs,
float  count 
)
static

cylinder #2, 5ms ON, 1000ms OFF, repeat 3 times fuelInjBenchExt 2 5 1000 3

Definition at line 209 of file bench_test.cpp.

209 {
210 doRunFuelInjBench((int)humanIndex, onTimeMs, offTimeMs, (int)count);
211}

Referenced by fuelInjBench(), and initBenchTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fuelPumpBench()

void fuelPumpBench ( )

Definition at line 291 of file bench_test.cpp.

291 {
292 fuelPumpBenchExt(BENCH_FUEL_PUMP_DURATION);
293}
static void fuelPumpBenchExt(float durationMs)

Referenced by handleBenchCategory(), and initBenchTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fuelPumpBenchExt()

static void fuelPumpBenchExt ( float  durationMs)
static

Definition at line 273 of file bench_test.cpp.

273 {
274 pinbench(durationMs, 100.0, 1,
276}
RegisteredOutputPin fuelPumpRelay
Definition efi_gpio.h:91

Referenced by fuelPumpBench(), and initBenchTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getOutputOnTheBenchTest()

const OutputPin * getOutputOnTheBenchTest ( )

Definition at line 33 of file bench_test.cpp.

33 {
35}
static OutputPin * outputOnTheBenchTest

Referenced by applyVvtPinState(), and OutputPin::setValue().

Here is the caller graph for this function:

◆ getSavedBenchTestPinStates()

int getSavedBenchTestPinStates ( uint32_t  durationsInStateMs[2])

Definition at line 425 of file bench_test.cpp.

425 {
426#if EFI_SIMULATOR
427 durationsInStateMs[0] = savedDurationsInStateMs[0];
428 durationsInStateMs[1] = savedDurationsInStateMs[1];
430#else
431 UNUSED(durationsInStateMs);
432 return 0;
433#endif // EFI_SIMULATOR
434}
static uint32_t savedDurationsInStateMs[2]
static int savedPinToggleCounter
UNUSED(samplingTimeSeconds)

Referenced by sendSavedBenchStatePackets().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleBenchCategory()

void handleBenchCategory ( uint16_t  index)

Definition at line 339 of file bench_test.cpp.

339 {
340 switch(index) {
341 case BENCH_VVT0_VALVE:
342 vvtValveBench(0);
343 return;
344 case BENCH_VVT1_VALVE:
345 vvtValveBench(1);
346 return;
347 case BENCH_VVT2_VALVE:
348 vvtValveBench(2);
349 return;
350 case BENCH_VVT3_VALVE:
351 vvtValveBench(3);
352 return;
353 case BENCH_AUXOUT0:
354 auxOutBench(0);
355 return;
356 case BENCH_AUXOUT1:
357 auxOutBench(1);
358 return;
359 case BENCH_AUXOUT2:
360 auxOutBench(2);
361 return;
362 case BENCH_AUXOUT3:
363 auxOutBench(3);
364 return;
365 case BENCH_AUXOUT4:
366 auxOutBench(4);
367 return;
368 case BENCH_AUXOUT5:
369 auxOutBench(5);
370 return;
371 case BENCH_AUXOUT6:
372 auxOutBench(6);
373 return;
374 case BENCH_AUXOUT7:
375 auxOutBench(7);
376 return;
377#if EFI_HD_ACR
378 case HD_ACR:
379 hdAcrBench(0);
380 return;
381 case HD_ACR2:
382 hdAcrBench(1);
383 return;
384#endif // EFI_HD_ACR
385 case BENCH_HPFP_VALVE:
387 return;
388 case BENCH_FUEL_PUMP:
389 // cmd_test_fuel_pump
391 return;
392 case BENCH_MAIN_RELAY:
394 return;
397 return;
399 // cmd_test_check_engine_light
400 milBench();
401 return;
403 acRelayBench();
404 return;
405 case BENCH_FAN_RELAY:
406 fanBench();
407 return;
408 case BENCH_IDLE_VALVE:
409 // cmd_test_idle_valve
410#if EFI_IDLE_CONTROL
412#endif /* EFI_IDLE_CONTROL */
413 return;
415 fan2Bench();
416 return;
417 case BENCH_CANCEL:
419 return;
420 default:
421 criticalError("Unexpected bench function %d", index);
422 }
423}
void fanBench()
void milBench()
static void cancelBenchTest()
void starterRelayBench()
static void hdAcrBench(int index)
static void hpfpValveBench()
static void mainRelayBench()
static void auxOutBench(int index)
void fan2Bench()
void fuelPumpBench()
void acRelayBench()
static void vvtValveBench(int vvtIndex)
@ BENCH_AC_COMPRESSOR_RELAY
@ BENCH_FAN_RELAY
@ BENCH_CANCEL
@ BENCH_VVT0_VALVE
@ BENCH_AUXOUT4
@ BENCH_AUXOUT2
@ BENCH_MAIN_RELAY
@ BENCH_AUXOUT7
@ HD_ACR2
@ BENCH_IDLE_VALVE
@ HD_ACR
@ BENCH_AUXOUT3
@ BENCH_CHECK_ENGINE_LIGHT
@ BENCH_VVT3_VALVE
@ BENCH_AUXOUT5
@ BENCH_AUXOUT1
@ BENCH_VVT1_VALVE
@ BENCH_AUXOUT0
@ BENCH_FAN_RELAY_2
@ BENCH_HPFP_VALVE
@ BENCH_FUEL_PUMP
@ BENCH_AUXOUT6
@ BENCH_STARTER_ENABLE_RELAY
@ BENCH_VVT2_VALVE
void startIdleBench(void)

Referenced by executeTSCommand(), and processCanQcBenchTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleCommandX14()

static void handleCommandX14 ( uint16_t  index)
static

Definition at line 436 of file bench_test.cpp.

436 {
437// todo: define ts_14_command magic constants and use those in tunerstudio.template.ini file!
438 switch (index) {
439 case TS_GRAB_PEDAL_UP:
441 return;
444 return;
445 case TS_RESET_TLE8888:
446 #if (BOARD_TLE8888_COUNT > 0)
448 #endif
449 return;
450 case TS_RESET_MC33810:
451 #if EFI_PROD_CODE && (BOARD_MC33810_COUNT > 0)
453 #endif
454 return;
455 case TS_WRITE_FLASH:
456 // cmd_write_config
457 #if EFI_CONFIGURATION_STORAGE
459 #endif /* EFI_CONFIGURATION_STORAGE */
460 return;
462 #if EFI_EMULATE_POSITION_SENSORS == TRUE
464 #endif /* EFI_EMULATE_POSITION_SENSORS == TRUE */
465 return;
467 #if EFI_EMULATE_POSITION_SENSORS == TRUE
469 #endif /* EFI_EMULATE_POSITION_SENSORS == TRUE */
470 return;
472 #if EFI_EMULATE_POSITION_SENSORS == TRUE
474 #endif /* EFI_EMULATE_POSITION_SENSORS == TRUE */
475 return;
476/*
477 case TS_ETB_RESET:
478 #if EFI_ELECTRONIC_THROTTLE_BODY == TRUE
479 #if EFI_PROD_CODE
480 etbPidReset();
481 #endif
482 #endif // EFI_ELECTRONIC_THROTTLE_BODY
483 return;
484*/
485#if EFI_ELECTRONIC_THROTTLE_BODY
486 case TS_ETB_AUTOCAL_0:
487 etbAutocal(0);
488 return;
489 case TS_ETB_AUTOCAL_1:
490 etbAutocal(1);
491 return;
493 engine->etbAutoTune = true;
494 return;
496 engine->etbAutoTune = false;
497 #if EFI_TUNER_STUDIO
499 #endif // EFI_TUNER_STUDIO
500 return;
503 return;
504#endif // EFI_ELECTRONIC_THROTTLE_BODY
507 benchSemaphore.signal();
508 return;
510 #if EFI_PROD_CODE && EFI_CONFIGURATION_STORAGE
511 extern bool burnWithoutFlash;
512 burnWithoutFlash = true;
513 #endif /* EFI_PROD_CODE && EFI_CONFIGURATION_STORAGE */
514 return;
515
516#if EFI_FILE_LOGGING
517 case TS_SD_MOUNT_PC:
518 return;
519 case TS_SD_MOUNT_ECU:
520 return;
521 case TS_SD_UNMOUNT:
522 return;
523 case TS_SD_FORMAT:
524 return;
525#endif // EFI_FILE_LOGGING
526
527 default:
528 criticalError("Unexpected bench x14 %d", index);
529 }
530}
static chibios_rt::CounterSemaphore benchSemaphore(0)
static bool widebandUpdatePending
bool etbAutoTune
Definition engine.h:276
bool etbIgnoreJamProtection
Definition engine.h:277
TunerStudioOutputChannels outputChannels
Definition engine.h:102
void etbAutocal(size_t throttleIndex)
@ TS_TRIGGER_STIMULATOR_ENABLE
@ TS_BURN_WITHOUT_FLASH
@ TS_ETB_STOP_AUTOTUNE
@ TS_WRITE_FLASH
@ TS_ETB_DISABLE_JAM_DETECT
@ TS_SD_FORMAT
@ TS_SD_MOUNT_PC
@ TS_GRAB_PEDAL_UP
@ TS_SD_UNMOUNT
@ TS_ETB_AUTOCAL_0
@ TS_RESET_TLE8888
@ TS_ETB_AUTOCAL_1
@ TS_TRIGGER_STIMULATOR_DISABLE
@ TS_SD_MOUNT_ECU
@ TS_RESET_MC33810
@ TS_ETB_START_AUTOTUNE
@ TS_GRAB_PEDAL_WOT
@ TS_EXTERNAL_TRIGGER_STIMULATOR_ENABLE
@ TS_WIDEBAND_UPDATE
void writeToFlashNow()
bool burnWithoutFlash
void mc33810_req_init()
Definition mc33810.cpp:838
void tle8888_req_init()
Definition tle8888.cpp:1272
void grabPedalIsUp()
Definition tps.cpp:30
void grabPedalIsWideOpen()
Definition tps.cpp:40
void disableTriggerStimulator()
void enableExternalTriggerStimulator()
void enableTriggerStimulator(bool incGlobalConfiguration)

Referenced by executeTSCommand().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hdAcrBench()

static void hdAcrBench ( int  index)
static

Definition at line 333 of file bench_test.cpp.

333 {
335 pinbench(BENCH_AC_RELAY_DURATION, 100.0, 1, pin);
336}
RegisteredOutputPin harleyAcr2
Definition efi_gpio.h:95
RegisteredNamedOutputPin harleyAcr
Definition efi_gpio.h:94
Single output pin reference and state.
Definition efi_output.h:50
brain_pin_e pin
Definition stm32_adc.cpp:15

Referenced by handleBenchCategory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hpfpValveBench()

static void hpfpValveBench ( )
static

Definition at line 286 of file bench_test.cpp.

Referenced by handleBenchCategory(), and initBenchTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initBenchTest()

void initBenchTest ( )

Definition at line 652 of file bench_test.cpp.

652 {
653 addConsoleAction("fuelpumpbench", fuelPumpBench);
654 addConsoleActionF("fuelpumpbench2", fuelPumpBenchExt);
655
656 addConsoleActionFFF(CMD_FUEL_BENCH, fuelInjBench);
658
659 addConsoleActionFFF(CMD_SPARK_BENCH, sparkBench);
660 addConsoleActionFFFF("sparkbench2", sparkBenchExt);
661
663
664 addConsoleAction(CMD_AC_RELAY_BENCH, acRelayBench);
665
666 addConsoleAction(CMD_FAN_BENCH, fanBench);
667 addConsoleAction(CMD_FAN2_BENCH, fan2Bench);
668 addConsoleActionF("fanbench2", fanBenchExt);
669
670 addConsoleAction("mainrelaybench", mainRelayBench);
671
672#if EFI_WIDEBAND_FIRMWARE_UPDATE && EFI_CAN_SUPPORT
673 addConsoleAction("update_wideband", []() { widebandUpdatePending = true; });
674 addConsoleActionI("set_wideband_index", [](int index) { setWidebandOffset(index); });
675#endif // EFI_WIDEBAND_FIRMWARE_UPDATE && EFI_CAN_SUPPORT
676
677 addConsoleAction(CMD_STARTER_BENCH, starterRelayBench);
678 addConsoleAction(CMD_MIL_BENCH, milBench);
679 addConsoleAction(CMD_HPFP_BENCH, hpfpValveBench);
680
682 instance.start();
684}
static void sparkBenchExt(float humanIndex, float onTime, float offTimeMs, float count)
static void sparkBench(float onTime, float offTimeMs, float count)
void onConfigurationChangeBenchTest()
static void luaOutBench2(float humanIndex, float onTime, float offTimeMs, float count)
static void fuelInjBench(float onTimeMs, float offTimeMs, float count)
static void tcuSolenoidBench(float humanIndex, float onTime, float offTimeMs, float count)
static BenchController instance
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)

Referenced by commonInitEngineController().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isRunningBenchTest()

bool isRunningBenchTest ( )

Definition at line 29 of file bench_test.cpp.

29 {
30 return isRunningBench;
31}

Referenced by Engine::efiWatchdog(), FanController::onSlowCallback(), and FuelPumpController::onSlowCallback().

Here is the caller graph for this function:

◆ luaOutBench2()

static void luaOutBench2 ( float  humanIndex,
float  onTime,
float  offTimeMs,
float  count 
)
static

channel #1, 5ms ON, 1000ms OFF, repeat 3 times

Definition at line 246 of file bench_test.cpp.

246 {
247 doRunBenchTestLuaOutput((int)humanIndex, onTime, offTimeMs, (int)count);
248}

Referenced by initBenchTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mainRelayBench()

static void mainRelayBench ( )
static

Definition at line 282 of file bench_test.cpp.

282 {
283 pinbench(BENCH_MAIN_RELAY_DURATION, 100.0, 1, &enginePins.mainRelay, true);
284}
RegisteredOutputPin mainRelay
Definition efi_gpio.h:76

Referenced by handleBenchCategory(), and initBenchTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ milBench()

void milBench ( )

we are blinking for 16 seconds so that one can click the button and walk around to see the light blinking

Definition at line 265 of file bench_test.cpp.

265 {
266 pinbench(500.0, 500.0, 16, &enginePins.checkEnginePin);
267}
RegisteredOutputPin checkEnginePin
Definition efi_gpio.h:117

Referenced by handleBenchCategory(), and initBenchTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onConfigurationChangeBenchTest()

void onConfigurationChangeBenchTest ( )

Definition at line 637 of file bench_test.cpp.

637 {
638 // default values if configuration was not specified
641 }
642
645 }
646
649 }
650}

Referenced by incrementGlobalConfigurationVersion(), and initBenchTest().

Here is the caller graph for this function:

◆ pinbench()

static void pinbench ( float  ontimeMs,
float  offtimeMs,
int  iterations,
OutputPin pinParam,
bool  p_swapOnOff = false 
)
static

Definition at line 148 of file bench_test.cpp.

150{
151 globalOnTimeMs = ontimeMs;
152 globalOffTimeMs = offtimeMs;
153#if EFI_SIMULATOR
154 globalCount = maxI(2, iterations);
155#else
156 globalCount = iterations;
157#endif // EFI_SIMULATOR
158 pinX = pinParam;
159 swapOnOff = p_swapOnOff;
160 // let's signal bench thread to wake up
161 isBenchTestPending = true;
162 benchSemaphore.signal();
163}
static int globalCount
static float globalOnTimeMs
static volatile bool isBenchTestPending
static float globalOffTimeMs
static bool swapOnOff
static OutputPin * pinX

Referenced by acRelayBench(), doRunBenchTestLuaOutput(), doRunFuelInjBench(), doRunSolenoidBench(), doRunSparkBench(), fan2Bench(), fanBenchExt(), fuelPumpBenchExt(), hdAcrBench(), hpfpValveBench(), mainRelayBench(), milBench(), starterRelayBench(), and vvtValveBench().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ runBench()

static void runBench ( OutputPin output,
float  onTimeMs,
float  offTimeMs,
int  count,
bool  swapOnOff 
)
static

Definition at line 93 of file bench_test.cpp.

93 {
94 int onTimeUs = MS2US(std::max(0.1f, onTimeMs));
95 int offTimeUs = MS2US(std::max(0.1f, offTimeMs));
96
97 if (onTimeUs > TOO_FAR_INTO_FUTURE_US) {
98 firmwareError(ObdCode::CUSTOM_ERR_BENCH_PARAM, "onTime above limit %dus", TOO_FAR_INTO_FUTURE_US);
99 return;
100 }
101
102 efiPrintf("Running bench: ON_TIME=%d us OFF_TIME=%d us Counter=%d", onTimeUs, offTimeUs, count);
103 efiPrintf("output on %s", hwPortname(output->brainPin));
104
105 isRunningBench = true;
106 outputOnTheBenchTest = output;
107
108 for (int i = 0; isRunningBench && i < count; i++) {
110 efitick_t nowNt = getTimeNowNt();
111 // start in a short time so the scheduler can precisely schedule the start event
112 efitick_t startTime = nowNt + US2NT(50);
113 efitick_t endTime = startTime + US2NT(onTimeUs);
114
115 // Schedule both events
116 engine->scheduler.schedule("bstart", &benchSchedStart, startTime, {(swapOnOff ? benchOff : benchOn), output});
117 engine->scheduler.schedule("bend", &benchSchedEnd, endTime, {(swapOnOff ? benchOn : benchOff), output});
118
119 // Wait one full cycle time for the event + delay to happen
120 chThdSleepMicroseconds(onTimeUs + offTimeUs);
121 }
122 /* last */
124
125#if EFI_SIMULATOR
126 // save the current counters and durations after the test while the pin is still controlled
130#endif // EFI_SIMULATOR
131
132 efiPrintf("Done!");
133 outputOnTheBenchTest = nullptr;
134 isRunningBench = false;
135}
static scheduling_s benchSchedStart
static void benchOff(OutputPin *output)
static scheduling_s benchSchedEnd
static void benchOn(OutputPin *output)
SingleTimerExecutor scheduler
Definition engine.h:252
uint32_t durationsInStateMs[2]
Definition efi_output.h:82
int pinToggleCounter
Definition efi_output.h:77
brain_pin_e brainPin
Definition efi_output.h:87
void schedule(const char *msg, scheduling_s *scheduling, efitick_t timeNt, action_s action) override
Schedule an action to be executed in the future.
efitick_t getTimeNowNt()
Definition efitime.cpp:19
void firmwareError(ObdCode code, const char *fmt,...)
@ CUSTOM_ERR_BENCH_PARAM
const char * hwPortname(brain_pin_e brainPin)
Here is the call graph for this function:

◆ sparkBench()

static void sparkBench ( float  onTime,
float  offTimeMs,
float  count 
)
static

sparkbench 5 400 2 5 ms ON, 400 ms OFF, two times

Definition at line 231 of file bench_test.cpp.

231 {
232 sparkBenchExt(1, onTime, offTimeMs, count);
233}

Referenced by initBenchTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sparkBenchExt()

static void sparkBenchExt ( float  humanIndex,
float  onTime,
float  offTimeMs,
float  count 
)
static

sparkbench2 1 5 1000 2

Definition at line 223 of file bench_test.cpp.

223 {
224 doRunSparkBench((int)humanIndex, onTime, offTimeMs, (int)count);
225}

Referenced by initBenchTest(), and sparkBench().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ starterRelayBench()

void starterRelayBench ( )

Definition at line 269 of file bench_test.cpp.

269 {
270 pinbench(BENCH_STARTER_DURATION, 100.0, 1, &enginePins.starterControl);
271}
RegisteredOutputPin starterControl
Definition efi_gpio.h:82

Referenced by handleBenchCategory(), and initBenchTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tcuSolenoidBench()

static void tcuSolenoidBench ( float  humanIndex,
float  onTime,
float  offTimeMs,
float  count 
)
static

solenoid #2, 1000ms ON, 1000ms OFF, repeat 3 times tcusolbench 2 1000 1000 3

Definition at line 239 of file bench_test.cpp.

239 {
240 doRunSolenoidBench((int)humanIndex, onTime, offTimeMs, (int)count);
241}

Referenced by initBenchTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vvtValveBench()

static void vvtValveBench ( int  vvtIndex)
static

Definition at line 295 of file bench_test.cpp.

295 {
296#if EFI_VVT_PID
297 pinbench(BENCH_VVT_DURATION, 100.0, 1, getVvtOutputPin(vvtIndex));
298#endif // EFI_VVT_PID
299}
OutputPin * getVvtOutputPin(int index)
Definition vvt.cpp:146

Referenced by handleBenchCategory().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ benchSchedEnd

scheduling_s benchSchedEnd
static

Definition at line 64 of file bench_test.cpp.

Referenced by runBench().

◆ benchSchedStart

scheduling_s benchSchedStart
static

Definition at line 63 of file bench_test.cpp.

Referenced by runBench().

◆ globalCount

int globalCount
static

Definition at line 142 of file bench_test.cpp.

Referenced by pinbench().

◆ globalOffTimeMs

float globalOffTimeMs
static

Definition at line 141 of file bench_test.cpp.

Referenced by pinbench().

◆ globalOnTimeMs

float globalOnTimeMs
static

Definition at line 140 of file bench_test.cpp.

Referenced by pinbench().

◆ instance

BenchController instance
static

Definition at line 326 of file bench_test.cpp.

Referenced by initBenchTest().

◆ isBenchTestPending

volatile bool isBenchTestPending = false
static

Definition at line 138 of file bench_test.cpp.

Referenced by pinbench().

◆ isRunningBench

bool isRunningBench = false
static

Definition at line 26 of file bench_test.cpp.

Referenced by cancelBenchTest(), isRunningBenchTest(), and runBench().

◆ outputOnTheBenchTest

OutputPin* outputOnTheBenchTest = nullptr
static

Definition at line 27 of file bench_test.cpp.

Referenced by getOutputOnTheBenchTest(), and runBench().

◆ pinX

OutputPin* pinX
static

Definition at line 143 of file bench_test.cpp.

Referenced by pinbench().

◆ rebootForPresetPending

bool rebootForPresetPending
extern

◆ savedDurationsInStateMs

uint32_t savedDurationsInStateMs[2] = { 0, 0 }
static

Definition at line 68 of file bench_test.cpp.

68{ 0, 0 };

Referenced by getSavedBenchTestPinStates(), runBench(), and sendSavedBenchStatePackets().

◆ savedPinToggleCounter

int savedPinToggleCounter = 0
static

Definition at line 67 of file bench_test.cpp.

Referenced by getSavedBenchTestPinStates(), runBench(), and sendSavedBenchStatePackets().

◆ swapOnOff

bool swapOnOff = false
static

Definition at line 144 of file bench_test.cpp.

Referenced by pinbench(), and runBench().

◆ widebandUpdatePending

bool widebandUpdatePending = false
static

Definition at line 139 of file bench_test.cpp.

Referenced by handleCommandX14(), and initBenchTest().

Go to the source code of this file.