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 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 requestWidebandUpdate (int hwIndex)
 
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)
 
void boardTsAction (uint16_t index)
 
static void processCanUserControl (const CANRxFrame &frame)
 
static void processCanSetCalibration (const CANRxFrame &frame)
 
static void processCanRequestCalibration (const CANRxFrame &frame)
 
void processCanEcuControl (const CANRxFrame &frame)
 
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 uint8_t widebandUpdateHwId = 0
 
static float globalOnTimeMs
 
static float globalOffTimeMs
 
static int globalCount
 
static OutputPinpinX
 
static bool swapOnOff = false
 
static BenchController instance
 
int luaCommandCounters [LUA_BUTTON_COUNT] = {}
 
bool rebootForPresetPending
 
std::optional< setup_custom_board_ts_command_override_typecustom_board_ts_command
 

Function Documentation

◆ acRelayBench()

void acRelayBench ( )

Definition at line 283 of file bench_test.cpp.

283 {
284 pinbench(BENCH_AC_RELAY_DURATION, 100.0, 1, &enginePins.acRelay);
285}
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 599 of file bench_test.cpp.

599 {
600 setEngineType(index);
601#if EFI_TUNER_STUDIO
603#endif // EFI_TUNER_STUDIO
604}
void setEngineType(int value, bool isWriteToFlash)
Definition settings.cpp:739
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 340 of file bench_test.cpp.

340 {
341 // todo!
342 UNUSED(index);
343}
UNUSED(samplingTimeSeconds)

Referenced by handleBenchCategory().

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

◆ benchOff()

static void benchOff ( OutputPin output)
static

Definition at line 86 of file bench_test.cpp.

86 {
87#if EFI_PROD_CODE && (BOARD_EXT_GPIOCHIPS > 0)
88 static char pin_error[64];
89
90 brain_pin_diag_e diag = output->getDiag();
91 if (diag == PIN_UNKNOWN) {
92 efiPrintf("No Diag on this pin");
93 } else {
94 pinDiag2string(pin_error, sizeof(pin_error), diag);
95 efiPrintf("Diag says %s", pin_error);
96 }
97#endif // EFI_PROD_CODE
98 output->setValue(BENCH_MSG, false, /*isForce*/ true);
99}
brain_pin_diag_e getDiag() const
Definition efi_gpio.cpp:678
void setValue(const char *msg, int logicValue, bool isForce=false)
Definition efi_gpio.cpp:604
void pinDiag2string(char *buffer, size_t size, brain_pin_diag_e pin_diag)
brain_pin_diag_e
Here is the call graph for this function:

◆ benchOn()

static void benchOn ( OutputPin output)
static

Definition at line 82 of file bench_test.cpp.

82 {
83 output->setValue(BENCH_MSG, true, /*isForce*/ true);
84}
Here is the call graph for this function:

◆ benchSemaphore()

static chibios_rt::CounterSemaphore benchSemaphore ( )
static

Referenced by pinbench(), and requestWidebandUpdate().

Here is the caller graph for this function:

◆ boardTsAction()

void boardTsAction ( uint16_t  index)

Definition at line 607 of file bench_test.cpp.

607{ UNUSED(index); }
Here is the call graph for this function:

◆ cancelBenchTest()

static void cancelBenchTest ( )
static

Definition at line 177 of file bench_test.cpp.

177 {
178 isRunningBench = false;
179}
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 208 of file bench_test.cpp.

208 {
209 if (humanIndex < 1 || humanIndex > LUA_PWM_COUNT) {
210 efiPrintf("Invalid index: %d", humanIndex);
211 return;
212 }
213 pinbench(onTimeMs, offTimeMs, count,
214 &enginePins.luaOutputPins[humanIndex - 1]);
215}
OutputPin luaOutputPins[LUA_PWM_COUNT]
Definition efi_gpio.h:100
uint16_t count
Definition tunerstudio.h:1

Referenced by executeTSCommand(), and initBenchTest().

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 183 of file bench_test.cpp.

183 {
184 if (humanIndex < 1 || humanIndex > engineConfiguration->cylindersCount) {
185 efiPrintf("Invalid index: %d", humanIndex);
186 return;
187 }
188 pinbench(onTimeMs, offTimeMs, count,
189 &enginePins.injectors[humanIndex - 1]);
190}
InjectorOutputPin injectors[MAX_CYLINDER_COUNT]
Definition efi_gpio.h:127
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 200 of file bench_test.cpp.

200 {
201 if (humanIndex < 1 || humanIndex > TCU_SOLENOID_COUNT) {
202 efiPrintf("Invalid index: %d", humanIndex);
203 return;
204 }
205 pinbench(onTime, offTime, count, &enginePins.tcuSolenoids[humanIndex - 1]);
206}
OutputPin tcuSolenoids[TCU_SOLENOID_COUNT]
Definition efi_gpio.h:132

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 192 of file bench_test.cpp.

192 {
193 if (humanIndex < 1 || humanIndex > engineConfiguration->cylindersCount) {
194 efiPrintf("Invalid index: %d", humanIndex);
195 return;
196 }
197 pinbench(onTime, offTime, count, &enginePins.coils[humanIndex - 1]);
198}
IgnitionOutputPin coils[MAX_CYLINDER_COUNT]
Definition efi_gpio.h:129

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 679 of file bench_test.cpp.

679 {
680 efiPrintf("IO test subsystem=%d index=%d", subsystem, index);
681
683
684 switch (subsystem) {
687 break;
688
689 case TS_DEBUG_MODE:
691 break;
692
694 if (!running) {
697 }
698 break;
699
701 if (!running) {
704 }
705 break;
706
708 if (!running) {
709 doRunSolenoidBench(index, 1000.0,
711 }
712 break;
713
715 if (!running) {
716 doRunBenchTestLuaOutput(index, 4.0,
718 }
719 break;
720
721 case TS_X14:
722 handleCommandX14(index);
723 break;
724#if EFI_CAN_SUPPORT
725 case TS_WIDEBAND:
726 setWidebandOffset(0xff, index);
727 break;
729 {
730 uint8_t hwIndex = index >> 8;
731 uint8_t canIndex = index & 0xff;
732
733 // Hack until we fix canReWidebandHwIndex and set "Broadcast" to 0xff
734 // TODO:
735 hwIndex = hwIndex < 8 ? hwIndex : 0xff;
736 setWidebandOffset(hwIndex, canIndex);
737 }
738 break;
740 {
741 uint8_t hwIndex = index >> 8;
742 uint8_t sensType = index & 0xff;
743
744 // Hack until we fix canReWidebandHwIndex and set "Broadcast" to 0xff
745 // TODO:
746 hwIndex = hwIndex < 8 ? hwIndex : 0xff;
747 setWidebandSensorType(hwIndex, sensType);
748 }
749 break;
751 pingWideband(index >> 8);
752 break;
753
755 {
756 uint8_t hwIndex = index >> 8;
757
758 // Hack until we fix canReWidebandHwIndex and set "Broadcast" to 0xff
759 // TODO:
760 widebandUpdateHwId = hwIndex < 8 ? hwIndex : 0xff;
762 }
763 break;
764#endif // EFI_CAN_SUPPORT
766 handleBenchCategory(index);
767 break;
768
770 applyPreset(index);
771 break;
772
773 case TS_BOARD_ACTION:
774 // TODO: use call_board_override
775 if (custom_board_ts_command.has_value()) {
776 custom_board_ts_command.value()(subsystem, index);
777 }
778 break;
779
781 applyPreset((int)DEFAULT_ENGINE_TYPE);
782 break;
783
784 case TS_STOP_ENGINE:
786 break;
787
788 case 0xba:
789#if EFI_PROD_CODE && EFI_DFU_JUMP
791#endif /* EFI_DFU_JUMP */
792 break;
793
794 case REBOOT_COMMAND:
795#if EFI_PROD_CODE
796 rebootNow();
797#endif /* EFI_PROD_CODE */
798 break;
799
800#if EFI_USE_OPENBLT
801 case 0xbc:
802 /* Jump to OpenBLT if present */
804 break;
805#endif
806
807 default:
808 criticalError("Unexpected bench subsystem %d %d", subsystem, index);
809 }
810}
void jump_to_openblt()
void jump_to_bootloader()
static void requestWidebandUpdate(int hwIndex)
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)
std::optional< setup_custom_board_ts_command_override_type > custom_board_ts_command
static void doRunSparkBench(size_t humanIndex, float onTime, float offTime, int count)
static uint8_t widebandUpdateHwId
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:306
bool isStopped() const override
static EngineAccessor engine
Definition engine.h:413
debug_mode_e
@ TS_WIDEBAND_SET_IDX_BY_ID
@ 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_WIDEBAND_SET_SENS_BY_ID
@ TS_WIDEBAND_PING_BY_ID
@ TS_WIDEBAND_FLASH_BY_ID
@ TS_SET_DEFAULT_ENGINE
@ TS_INJECTOR_CATEGORY
@ TS_STOP_ENGINE
void clearWarnings(void)
void rebootNow()
Definition rusefi.cpp:150
void setWidebandSensorType(uint8_t hwIndex, uint8_t type)
void pingWideband(uint8_t hwIndex)
void setWidebandOffset(uint8_t hwIndex, uint8_t index)
running("running", SensorCategory.SENSOR_INPUTS, FieldType.INT, 888, 1.0, -1.0, -1.0, "")
void doScheduleStopEngine(StopRequestedReason reason)

Referenced by TunerStudio::handleCrcCommand(), and processCanUserControl().

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

◆ fan2Bench()

void fan2Bench ( )

Definition at line 263 of file bench_test.cpp.

263 {
264 pinbench(3000.0, 100.0, 1, &enginePins.fanRelay2);
265}
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 259 of file bench_test.cpp.

259 {
260 fanBenchExt(BENCH_FAN_DURATION);
261}
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 255 of file bench_test.cpp.

255 {
256 pinbench(onTimeMs, 100.0, 1, &enginePins.fanRelay);
257}
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 228 of file bench_test.cpp.

228 {
229 fuelInjBenchExt(1, onTimeMs, offTimeMs, count);
230}
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 221 of file bench_test.cpp.

221 {
222 doRunFuelInjBench((int)humanIndex, onTimeMs, offTimeMs, (int)count);
223}

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 296 of file bench_test.cpp.

296 {
297 fuelPumpBenchExt(BENCH_FUEL_PUMP_DURATION);
298}
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 278 of file bench_test.cpp.

278 {
279 pinbench(durationMs, 100.0, 1,
281}
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 40 of file bench_test.cpp.

40 {
42}
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 463 of file bench_test.cpp.

463 {
464#if EFI_SIMULATOR
465 durationsInStateMs[0] = savedDurationsInStateMs[0];
466 durationsInStateMs[1] = savedDurationsInStateMs[1];
468#else
469 UNUSED(durationsInStateMs);
470 return 0;
471#endif // EFI_SIMULATOR
472}
static uint32_t savedDurationsInStateMs[2]
static int savedPinToggleCounter

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 354 of file bench_test.cpp.

354 {
355 switch(index) {
356 case BENCH_VVT0_VALVE:
357 vvtValveBench(0);
358 return;
359 case BENCH_VVT1_VALVE:
360 vvtValveBench(1);
361 return;
362 case BENCH_VVT2_VALVE:
363 vvtValveBench(2);
364 return;
365 case BENCH_VVT3_VALVE:
366 vvtValveBench(3);
367 return;
368 case BENCH_AUXOUT0:
369 auxOutBench(0);
370 return;
371 case BENCH_AUXOUT1:
372 auxOutBench(1);
373 return;
374 case BENCH_AUXOUT2:
375 auxOutBench(2);
376 return;
377 case BENCH_AUXOUT3:
378 auxOutBench(3);
379 return;
380 case BENCH_AUXOUT4:
381 auxOutBench(4);
382 return;
383 case BENCH_AUXOUT5:
384 auxOutBench(5);
385 return;
386 case BENCH_AUXOUT6:
387 auxOutBench(6);
388 return;
389 case BENCH_AUXOUT7:
390 auxOutBench(7);
391 return;
392 case LUA_COMMAND_1:
394 return;
395 case LUA_COMMAND_2:
397 return;
398 case LUA_COMMAND_3:
400 return;
401 case LUA_COMMAND_4:
403 return;
404#if EFI_LTFT_CONTROL
405 case LTFT_RESET:
407 return;
408 case LTFT_APPLY_TO_VE:
410 return;
411 case LTFT_DEV_POKE:
413 return;
414#endif // EFI_LTFT_CONTROL
415#if EFI_HD_ACR
416 case HD_ACR:
417 hdAcrBench(0);
418 return;
419 case HD_ACR2:
420 hdAcrBench(1);
421 return;
422#endif // EFI_HD_ACR
423 case BENCH_HPFP_VALVE:
425 return;
426 case BENCH_FUEL_PUMP:
427 // cmd_test_fuel_pump
429 return;
430 case BENCH_MAIN_RELAY:
432 return;
435 return;
437 // cmd_test_check_engine_light
438 milBench();
439 return;
441 acRelayBench();
442 return;
443 case BENCH_FAN_RELAY:
444 fanBench();
445 return;
446 case BENCH_IDLE_VALVE:
447 // cmd_test_idle_valve
448#if EFI_IDLE_CONTROL
450#endif /* EFI_IDLE_CONTROL */
451 return;
453 fan2Bench();
454 return;
455 case BENCH_CANCEL:
457 return;
458 default:
459 criticalError("Unexpected bench function %d", index);
460 }
461}
int luaCommandCounters[LUA_BUTTON_COUNT]
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)
@ LUA_COMMAND_3
@ BENCH_AC_COMPRESSOR_RELAY
@ LUA_COMMAND_2
@ BENCH_FAN_RELAY
@ BENCH_CANCEL
@ BENCH_VVT0_VALVE
@ BENCH_AUXOUT4
@ BENCH_AUXOUT2
@ LUA_COMMAND_1
@ BENCH_MAIN_RELAY
@ BENCH_AUXOUT7
@ HD_ACR2
@ BENCH_IDLE_VALVE
@ LTFT_APPLY_TO_VE
@ LTFT_DEV_POKE
@ HD_ACR
@ BENCH_AUXOUT3
@ BENCH_CHECK_ENGINE_LIGHT
@ BENCH_VVT3_VALVE
@ BENCH_AUXOUT5
@ LUA_COMMAND_4
@ BENCH_AUXOUT1
@ BENCH_VVT1_VALVE
@ BENCH_AUXOUT0
@ BENCH_FAN_RELAY_2
@ LTFT_RESET
@ BENCH_HPFP_VALVE
@ BENCH_FUEL_PUMP
@ BENCH_AUXOUT6
@ BENCH_STARTER_ENABLE_RELAY
@ BENCH_VVT2_VALVE
void startIdleBench(void)
void applyLongTermFuelTrimToVe()
void resetLongTermFuelTrim()
void devPokeLongTermFuelTrim()

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 474 of file bench_test.cpp.

474 {
475// todo: define ts_14_command magic constants and use those in tunerstudio.template.ini file!
476 switch (index) {
477 case TS_GRAB_PEDAL_UP:
479 return;
482 return;
485 return;
486 case TS_GRAB_TPS_OPEN:
488 return;
489 case TS_RESET_TLE8888:
490 #if (BOARD_TLE8888_COUNT > 0)
492 #endif
493 return;
494 case TS_RESET_MC33810:
495 #if EFI_PROD_CODE && (BOARD_MC33810_COUNT > 0)
497 #endif
498 return;
499#if EFI_SHAFT_POSITION_INPUT
501 // this is different from starter relay bench test!
503 return;
504#endif // EFI_SHAFT_POSITION_INPUT
505 case TS_WRITE_FLASH:
506 // cmd_write_config
507 #if EFI_CONFIGURATION_STORAGE
509 #endif /* EFI_CONFIGURATION_STORAGE */
510 return;
512 #if EFI_EMULATE_POSITION_SENSORS == TRUE
514 #endif /* EFI_EMULATE_POSITION_SENSORS == TRUE */
515 return;
517 #if EFI_EMULATE_POSITION_SENSORS == TRUE
519 #endif /* EFI_EMULATE_POSITION_SENSORS == TRUE */
520 return;
522 #if EFI_EMULATE_POSITION_SENSORS == TRUE
524 #endif /* EFI_EMULATE_POSITION_SENSORS == TRUE */
525 return;
526/*
527 case TS_ETB_RESET:
528 #if EFI_ELECTRONIC_THROTTLE_BODY == TRUE
529 #if EFI_PROD_CODE
530 etbPidReset();
531 #endif
532 #endif // EFI_ELECTRONIC_THROTTLE_BODY
533 return;
534*/
535#if EFI_ELECTRONIC_THROTTLE_BODY
536 case TS_ETB_AUTOCAL_0:
537 etbAutocal(DC_Throttle1);
538 return;
539 case TS_ETB_AUTOCAL_1:
540 etbAutocal(DC_Throttle2);
541 return;
543 etbAutocal(DC_Throttle1, false);
544 return;
546 etbAutocal(DC_Throttle2, false);
547 return;
549 engine->etbAutoTune = true;
550 return;
552 engine->etbAutoTune = false;
553 #if EFI_TUNER_STUDIO
555 #endif // EFI_TUNER_STUDIO
556 return;
559 return;
560 case TS_EWG_AUTOCAL_0:
561 etbAutocal(DC_Wastegate);
562 return;
564 etbAutocal(DC_Wastegate, false);
565 return;
566#endif // EFI_ELECTRONIC_THROTTLE_BODY
568 // broadcast, for old WBO FWs
570 return;
572 return;
573
574#if EFI_PROD_CODE && EFI_FILE_LOGGING
575 case TS_SD_MOUNT_PC:
577 return;
578 case TS_SD_MOUNT_ECU:
580 return;
581 case TS_SD_UNMOUNT:
583 return;
584 case TS_SD_FORMAT:
586 return;
589 return;
590#endif // EFI_FILE_LOGGING
591
592 default:
593 criticalError("Unexpected bench x14 %d", index);
594 }
595}
bool etbAutoTune
Definition engine.h:296
bool etbIgnoreJamProtection
Definition engine.h:297
void etbAutocal(dc_function_e function, bool reportToTs)
@ TS_GRAB_TPS_CLOSED
@ TS_TRIGGER_STIMULATOR_ENABLE
@ TS_ETB_STOP_AUTOTUNE
@ TS_WRITE_FLASH
@ TS_ETB_DISABLE_JAM_DETECT
@ TS_SD_FORMAT
@ TS_SD_MOUNT_PC
@ TS_GRAB_PEDAL_UP
@ TS_ETB_AUTOCAL_0_FAST
@ TS_START_STOP_ENGINE
@ 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_EWG_AUTOCAL_0_FAST
@ TS_EWG_AUTOCAL_0
@ TS_ETB_START_AUTOTUNE
@ TS_GRAB_PEDAL_WOT
@ TS_GRAB_TPS_OPEN
@ TS_SD_DELETE_REPORTS
@ COMMAND_X14_UNUSED_15
@ TS_ETB_AUTOCAL_1_FAST
@ TS_EXTERNAL_TRIGGER_STIMULATOR_ENABLE
@ TS_WIDEBAND_UPDATE
void writeToFlashNow()
void mc33810_req_init()
Definition mc33810.cpp:993
void sdCardRemoveReportFiles()
void sdCardRequestMode(SD_MODE mode)
@ SD_MODE_UNMOUNT
Definition mmc_card.h:20
@ SD_MODE_PC
Definition mmc_card.h:19
@ SD_MODE_ECU
Definition mmc_card.h:18
@ SD_MODE_FORMAT
Definition mmc_card.h:21
void startStopButtonToggle()
void tle8888_req_init()
Definition tle8888.cpp:1272
void grabPedalIsUp()
Definition tps.cpp:31
void grapTps1PrimaryIsClosed()
Definition tps.cpp:45
void grapTps1PrimaryIsOpen()
Definition tps.cpp:50
void grabPedalIsWideOpen()
Definition tps.cpp:39
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 346 of file bench_test.cpp.

346 {
348 pinbench(BENCH_AC_RELAY_DURATION, 100.0, 1, pin);
349}
RegisteredOutputPin harleyAcr2
Definition efi_gpio.h:96
RegisteredNamedOutputPin harleyAcr
Definition efi_gpio.h:95
Single output pin reference and state.
Definition efi_output.h:49
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 291 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 827 of file bench_test.cpp.

827 {
828 addConsoleAction("fuelpumpbench", fuelPumpBench);
829 addConsoleActionF("fuelpumpbench2", fuelPumpBenchExt);
830
831 addConsoleActionFFF(CMD_FUEL_BENCH, fuelInjBench);
833
834 addConsoleActionFFF(CMD_SPARK_BENCH, sparkBench);
835 addConsoleActionFFFF("sparkbench2", sparkBenchExt);
836
838
839 addConsoleAction(CMD_AC_RELAY_BENCH, acRelayBench);
840
841 addConsoleAction(CMD_FAN_BENCH, fanBench);
842 addConsoleAction(CMD_FAN2_BENCH, fan2Bench);
843 addConsoleActionF("fanbench2", fanBenchExt);
844
845 addConsoleAction("mainrelaybench", mainRelayBench);
846
847#if EFI_CAN_SUPPORT
848#if EFI_WIDEBAND_FIRMWARE_UPDATE
849 addConsoleActionI("update_wideband", requestWidebandUpdate);
850#endif // EFI_WIDEBAND_FIRMWARE_UPDATE
851 addConsoleActionII("set_wideband_index", [](int hwIndex, int index) { setWidebandOffset(hwIndex, index); });
852#endif // EFI_CAN_SUPPORT
853
854 addConsoleAction(CMD_STARTER_BENCH, starterRelayBench);
855 addConsoleAction(CMD_MIL_BENCH, milBench);
856 addConsoleAction(CMD_HPFP_BENCH, hpfpValveBench);
857
858#if EFI_CAN_SUPPORT
859 addConsoleActionI("ping_wideband", [](int index) {
860 pingWideband(index);
861 });
862#endif // EFI_CAN_SUPPORT
863
864#if EFI_LUA
865 // this commands facilitates TS Lua Button scripts development
866 addConsoleActionI("lua_button", [](int index) {
867 if (index < 0 || index > LUA_BUTTON_COUNT)
868 return;
869 luaCommandCounters[index - 1]++;
870 });
871 addConsoleActionFFFF("luabench2", [](float humanIndex, float onTime, float offTimeMs, float count) {
872 doRunBenchTestLuaOutput((int)humanIndex, onTime, offTimeMs, (int)count);
873 });
874#endif // EFI_LUA
875 instance.start();
877}
static void sparkBenchExt(float humanIndex, float onTime, float offTimeMs, float count)
static void sparkBench(float onTime, float offTimeMs, float count)
void onConfigurationChangeBenchTest()
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 addConsoleActionII(const char *token, VoidIntInt callback)
Register a console command with two Integer 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 36 of file bench_test.cpp.

36 {
37 return isRunningBench;
38}

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

Here is the caller graph for this function:

◆ mainRelayBench()

static void mainRelayBench ( )
static

Definition at line 287 of file bench_test.cpp.

287 {
288 pinbench(BENCH_MAIN_RELAY_DURATION, 100.0, 1, &enginePins.mainRelay, true);
289}
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 270 of file bench_test.cpp.

270 {
271 pinbench(500.0, 500.0, 16, &enginePins.checkEnginePin);
272}
RegisteredOutputPin checkEnginePin
Definition efi_gpio.h:118

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 812 of file bench_test.cpp.

812 {
813 // default values if configuration was not specified
816 }
817
820 }
821
824 }
825}

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 160 of file bench_test.cpp.

162{
163 globalOnTimeMs = ontimeMs;
164 globalOffTimeMs = offtimeMs;
165#if EFI_SIMULATOR
166 globalCount = maxI(2, iterations);
167#else
168 globalCount = iterations;
169#endif // EFI_SIMULATOR
170 pinX = pinParam;
171 swapOnOff = p_swapOnOff;
172 // let's signal bench thread to wake up
173 isBenchTestPending = true;
174 benchSemaphore.signal();
175}
static int globalCount
static float globalOnTimeMs
static volatile bool isBenchTestPending
static chibios_rt::CounterSemaphore benchSemaphore(0)
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:

◆ processCanEcuControl()

void processCanEcuControl ( const CANRxFrame frame)

Definition at line 660 of file bench_test.cpp.

660 {
661 if (frame.data8[0] != (int)bench_test_magic_numbers_e::BENCH_HEADER) {
662 return;
663 }
664
665 int eid = CAN_EID(frame);
666 if (eid == (int)bench_test_packet_ids_e::ECU_SET_CALIBRATION) {
668 } else if (eid == (int)bench_test_packet_ids_e::ECU_REQ_CALIBRATION) {
670 } else if (eid == (int)bench_test_packet_ids_e::ECU_CAN_BUS_USER_CONTROL) {
672 }
673}
static void processCanRequestCalibration(const CANRxFrame &frame)
static void processCanSetCalibration(const CANRxFrame &frame)
static void processCanUserControl(const CANRxFrame &frame)
uint8_t data8[8]
Frame data.
Definition can_mocks.h:55

Referenced by processCanRxMessage().

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

◆ processCanRequestCalibration()

static void processCanRequestCalibration ( const CANRxFrame frame)
static

CANbus protocol to query scalar calibrations using hash keys

see fields_api.txt for well-known fields see generated_fields_api_header.h for corresponding hashes

Definition at line 640 of file bench_test.cpp.

640 {
641#if EFI_LUA_LOOKUP
642 int hash = getFourBytesLsb(frame, 2);
643 efiPrintf("processCanRequestCalibration=%x", hash);
644 FloatIntBytes fb;
645 fb.f = getConfigValueByHash(hash);
646
647 CanTxMessage msg(CanCategory::BENCH_TEST, (int)bench_test_packet_ids_e::ECU_GET_CALIBRATION, 8, /*bus*/0, /*isExtended*/true);
648 for (size_t i = 0;i<sizeof(float);i++) {
649 msg[4 + i] = fb.bytes[i];
650 }
651
652 fb.i = hash;
653 // first half of the packed is copy of that hash value so that recipients know what they are processing
654 for (size_t i = 0;i<sizeof(float);i++) {
655 msg[i] = fb.bytes[i];
656 }
657#endif // EFI_LUA_LOOKUP
658}
uint32_t getFourBytesLsb(const CANRxFrame &frame, int offset)
Definition can_rx.cpp:119
float getConfigValueByHash(const int hash)

Referenced by processCanEcuControl().

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

◆ processCanSetCalibration()

static void processCanSetCalibration ( const CANRxFrame frame)
static

Definition at line 630 of file bench_test.cpp.

630 {
631 // todo allow changes of scalar settings via CANbus
632 UNUSED(frame);
633}

Referenced by processCanEcuControl().

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

◆ processCanUserControl()

static void processCanUserControl ( const CANRxFrame frame)
static

for example to bench test injector 1 0x77000C 0x66 0x00 ?? ?? ?? ?? 0x77000C 0x66 0x00 0x14 0x00 0x09 0x00 start/stop engine

See also more complicated ISO-TP CANBus wrapper of complete TS protocol

Definition at line 617 of file bench_test.cpp.

617 {
618 // reserved data8[1]
619 uint16_t subsystem = getTwoBytesLsb(frame, 2);
620 uint16_t index = getTwoBytesLsb(frame, 4);
621 executeTSCommand(subsystem, index);
622}
void executeTSCommand(uint16_t subsystem, uint16_t index)
uint16_t getTwoBytesLsb(const CANRxFrame &frame, int offset)
Definition can_rx.cpp:126

Referenced by processCanEcuControl().

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

◆ requestWidebandUpdate()

static void requestWidebandUpdate ( int  hwIndex)
static

Definition at line 306 of file bench_test.cpp.

307{
308 widebandUpdateHwId = hwIndex;
310 benchSemaphore.signal();
311}
static bool widebandUpdatePending

Referenced by executeTSCommand(), handleCommandX14(), and initBenchTest().

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 101 of file bench_test.cpp.

101 {
102 int onTimeUs = MS2US(std::max(0.1f, onTimeMs));
103 int offTimeUs = MS2US(std::max(0.1f, offTimeMs));
104
105 if (onTimeUs > TOO_FAR_INTO_FUTURE_US) {
106 firmwareError(ObdCode::CUSTOM_ERR_BENCH_PARAM, "onTime above limit %dus", TOO_FAR_INTO_FUTURE_US);
107 return;
108 }
109
110 efiPrintf("Running bench: ON_TIME=%d us OFF_TIME=%d us Counter=%d", onTimeUs, offTimeUs, count);
111 efiPrintf("output on %s", hwPortname(output->brainPin));
112
113 isRunningBench = true;
114 outputOnTheBenchTest = output;
115
116 for (int i = 0; isRunningBench && i < count; i++) {
118 efitick_t nowNt = getTimeNowNt();
119 // start in a short time so the scheduler can precisely schedule the start event
120 efitick_t startTime = nowNt + US2NT(50);
121 efitick_t endTime = startTime + US2NT(onTimeUs);
122
123 auto const bstartAction{ swapOnOff ? action_s::make<benchOff>(output) : action_s::make<benchOn>(output) };
124 auto const bendAction{ swapOnOff ? action_s::make<benchOn>(output) : action_s::make<benchOff>(output) };
125
126 // Schedule both events
127 engine->scheduler.schedule("bstart", &benchSchedStart, startTime, bstartAction);
128 engine->scheduler.schedule("bend", &benchSchedEnd, endTime, bendAction);
129
130 // Wait one full cycle time for the event + delay to happen
131 chThdSleepMicroseconds(onTimeUs + offTimeUs);
132 }
133 /* last */
135
136#if EFI_SIMULATOR
137 // save the current counters and durations after the test while the pin is still controlled
141#endif // EFI_SIMULATOR
142
143 efiPrintf("Done!");
144 outputOnTheBenchTest = nullptr;
145 isRunningBench = false;
146}
static scheduling_s benchSchedStart
static void benchOff(OutputPin *output)
static scheduling_s benchSchedEnd
static void benchOn(OutputPin *output)
SingleTimerExecutor scheduler
Definition engine.h:271
TunerStudioOutputChannels outputChannels
Definition engine.h:109
uint32_t durationsInStateMs[2]
Definition efi_output.h:81
int pinToggleCounter
Definition efi_output.h:76
brain_pin_e brainPin
Definition efi_output.h:86
void schedule(const char *msg, scheduling_s *scheduling, efitick_t timeNt, action_s const &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 243 of file bench_test.cpp.

243 {
244 sparkBenchExt(1, onTime, offTimeMs, count);
245}

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 235 of file bench_test.cpp.

235 {
236 doRunSparkBench((int)humanIndex, onTime, offTimeMs, (int)count);
237}

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 274 of file bench_test.cpp.

274 {
275 pinbench(BENCH_STARTER_DURATION, 100.0, 1, &enginePins.starterControl);
276}
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 251 of file bench_test.cpp.

251 {
252 doRunSolenoidBench((int)humanIndex, onTime, offTimeMs, (int)count);
253}

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 300 of file bench_test.cpp.

300 {
301#if EFI_VVT_PID
302 pinbench(BENCH_VVT_DURATION, 100.0, 1, getVvtOutputPin(vvtIndex));
303#endif // EFI_VVT_PID
304}
OutputPin * getVvtOutputPin(int index)
Definition vvt.cpp:153

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 72 of file bench_test.cpp.

Referenced by runBench().

◆ benchSchedStart

scheduling_s benchSchedStart
static

Definition at line 71 of file bench_test.cpp.

Referenced by runBench().

◆ custom_board_ts_command

std::optional<setup_custom_board_ts_command_override_type> custom_board_ts_command

Definition at line 677 of file bench_test.cpp.

Referenced by executeTSCommand().

◆ globalCount

int globalCount
static

Definition at line 154 of file bench_test.cpp.

Referenced by pinbench().

◆ globalOffTimeMs

float globalOffTimeMs
static

Definition at line 153 of file bench_test.cpp.

Referenced by pinbench().

◆ globalOnTimeMs

float globalOnTimeMs
static

Definition at line 152 of file bench_test.cpp.

Referenced by pinbench().

◆ instance

BenchController instance
static

◆ isBenchTestPending

volatile bool isBenchTestPending = false
static

Definition at line 149 of file bench_test.cpp.

Referenced by pinbench().

◆ isRunningBench

bool isRunningBench = false
static

Definition at line 33 of file bench_test.cpp.

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

◆ luaCommandCounters

int luaCommandCounters[LUA_BUTTON_COUNT] = {}

Definition at line 352 of file bench_test.cpp.

352{};

Referenced by configureRusefiLuaHooks(), handleBenchCategory(), and initBenchTest().

◆ outputOnTheBenchTest

OutputPin* outputOnTheBenchTest = nullptr
static

Definition at line 34 of file bench_test.cpp.

Referenced by getOutputOnTheBenchTest(), and runBench().

◆ pinX

OutputPin* pinX
static

Definition at line 155 of file bench_test.cpp.

Referenced by pinbench().

◆ rebootForPresetPending

bool rebootForPresetPending
extern

◆ savedDurationsInStateMs

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

Definition at line 76 of file bench_test.cpp.

76{ 0, 0 };

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

◆ savedPinToggleCounter

int savedPinToggleCounter = 0
static

Definition at line 75 of file bench_test.cpp.

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

◆ swapOnOff

bool swapOnOff = false
static

Definition at line 156 of file bench_test.cpp.

Referenced by pinbench(), and runBench().

◆ widebandUpdateHwId

uint8_t widebandUpdateHwId = 0
static

Definition at line 151 of file bench_test.cpp.

Referenced by executeTSCommand(), and requestWidebandUpdate().

◆ widebandUpdatePending

bool widebandUpdatePending = false
static

Definition at line 150 of file bench_test.cpp.

Referenced by requestWidebandUpdate().

Go to the source code of this file.