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)
 
PUBLIC_API_WEAK 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
 

Function Documentation

◆ acRelayBench()

void acRelayBench ( )

Definition at line 282 of file bench_test.cpp.

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

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

339 {
340 // todo!
341 UNUSED(index);
342}
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 85 of file bench_test.cpp.

85 {
86#if EFI_PROD_CODE && (BOARD_EXT_GPIOCHIPS > 0)
87 static char pin_error[64];
88
89 brain_pin_diag_e diag = output->getDiag();
90 if (diag == PIN_UNKNOWN) {
91 efiPrintf("No Diag on this pin");
92 } else {
93 pinDiag2string(pin_error, sizeof(pin_error), diag);
94 efiPrintf("Diag says %s", pin_error);
95 }
96#endif // EFI_PROD_CODE
97 output->setValue(BENCH_MSG, false, /*isForce*/ true);
98}
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 81 of file bench_test.cpp.

81 {
82 output->setValue(BENCH_MSG, true, /*isForce*/ true);
83}
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()

PUBLIC_API_WEAK void boardTsAction ( uint16_t  index)

Definition at line 605 of file bench_test.cpp.

605{ UNUSED(index); }

Referenced by executeTSCommand().

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

◆ cancelBenchTest()

static void cancelBenchTest ( )
static

Definition at line 176 of file bench_test.cpp.

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

207 {
208 if (humanIndex < 1 || humanIndex > LUA_PWM_COUNT) {
209 efiPrintf("Invalid index: %d", humanIndex);
210 return;
211 }
212 pinbench(onTimeMs, offTimeMs, count,
213 &enginePins.luaOutputPins[humanIndex - 1]);
214}
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 182 of file bench_test.cpp.

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

199 {
200 if (humanIndex < 1 || humanIndex > TCU_SOLENOID_COUNT) {
201 efiPrintf("Invalid index: %d", humanIndex);
202 return;
203 }
204 pinbench(onTime, offTime, count, &enginePins.tcuSolenoids[humanIndex - 1]);
205}
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 191 of file bench_test.cpp.

191 {
192 if (humanIndex < 1 || humanIndex > engineConfiguration->cylindersCount) {
193 efiPrintf("Invalid index: %d", humanIndex);
194 return;
195 }
196 pinbench(onTime, offTime, count, &enginePins.coils[humanIndex - 1]);
197}
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 675 of file bench_test.cpp.

675 {
676 efiPrintf("IO test subsystem=%d index=%d", subsystem, index);
677
679
680 switch (subsystem) {
683 break;
684
685 case TS_DEBUG_MODE:
687 break;
688
690 if (!running) {
693 }
694 break;
695
697 if (!running) {
700 }
701 break;
702
704 if (!running) {
705 doRunSolenoidBench(index, 1000.0,
707 }
708 break;
709
711 if (!running) {
712 doRunBenchTestLuaOutput(index, 4.0,
714 }
715 break;
716
717 case TS_X14:
718 handleCommandX14(index);
719 break;
720#if EFI_CAN_SUPPORT
721 case TS_WIDEBAND:
722 setWidebandOffset(0xff, index);
723 break;
725 {
726 uint8_t hwIndex = index >> 8;
727 uint8_t canIndex = index & 0xff;
728
729 // Hack until we fix canReWidebandHwIndex and set "Broadcast" to 0xff
730 // TODO:
731 hwIndex = hwIndex < 8 ? hwIndex : 0xff;
732 setWidebandOffset(hwIndex, canIndex);
733 }
734 break;
736 {
737 uint8_t hwIndex = index >> 8;
738 uint8_t sensType = index & 0xff;
739
740 // Hack until we fix canReWidebandHwIndex and set "Broadcast" to 0xff
741 // TODO:
742 hwIndex = hwIndex < 8 ? hwIndex : 0xff;
743 setWidebandSensorType(hwIndex, sensType);
744 }
745 break;
747 pingWideband(index >> 8);
748 break;
749
751 {
752 uint8_t hwIndex = index >> 8;
753
754 // Hack until we fix canReWidebandHwIndex and set "Broadcast" to 0xff
755 // TODO:
756 widebandUpdateHwId = hwIndex < 8 ? hwIndex : 0xff;
758 }
759 break;
760#endif // EFI_CAN_SUPPORT
762 handleBenchCategory(index);
763 break;
764
766 applyPreset(index);
767 break;
768
769 case TS_BOARD_ACTION:
770 boardTsAction(index);
771 break;
772
774 applyPreset((int)DEFAULT_ENGINE_TYPE);
775 break;
776
777 case TS_STOP_ENGINE:
779 break;
780
781 case 0xba:
782#if EFI_PROD_CODE && EFI_DFU_JUMP
784#endif /* EFI_DFU_JUMP */
785 break;
786
787 case REBOOT_COMMAND:
788#if EFI_PROD_CODE
789 rebootNow();
790#endif /* EFI_PROD_CODE */
791 break;
792
793#if EFI_USE_OPENBLT
794 case 0xbc:
795 /* Jump to OpenBLT if present */
797 break;
798#endif
799
800 default:
801 criticalError("Unexpected bench subsystem %d %d", subsystem, index);
802 }
803}
void jump_to_openblt()
void jump_to_bootloader()
static void requestWidebandUpdate(int hwIndex)
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 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, 892, 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 262 of file bench_test.cpp.

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

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

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

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

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

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

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

277 {
278 pinbench(durationMs, 100.0, 1,
280}
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 39 of file bench_test.cpp.

39 {
41}
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 462 of file bench_test.cpp.

462 {
463#if EFI_SIMULATOR
464 durationsInStateMs[0] = savedDurationsInStateMs[0];
465 durationsInStateMs[1] = savedDurationsInStateMs[1];
467#else
468 UNUSED(durationsInStateMs);
469 return 0;
470#endif // EFI_SIMULATOR
471}
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 353 of file bench_test.cpp.

353 {
354 switch(index) {
355 case BENCH_VVT0_VALVE:
356 vvtValveBench(0);
357 return;
358 case BENCH_VVT1_VALVE:
359 vvtValveBench(1);
360 return;
361 case BENCH_VVT2_VALVE:
362 vvtValveBench(2);
363 return;
364 case BENCH_VVT3_VALVE:
365 vvtValveBench(3);
366 return;
367 case BENCH_AUXOUT0:
368 auxOutBench(0);
369 return;
370 case BENCH_AUXOUT1:
371 auxOutBench(1);
372 return;
373 case BENCH_AUXOUT2:
374 auxOutBench(2);
375 return;
376 case BENCH_AUXOUT3:
377 auxOutBench(3);
378 return;
379 case BENCH_AUXOUT4:
380 auxOutBench(4);
381 return;
382 case BENCH_AUXOUT5:
383 auxOutBench(5);
384 return;
385 case BENCH_AUXOUT6:
386 auxOutBench(6);
387 return;
388 case BENCH_AUXOUT7:
389 auxOutBench(7);
390 return;
391 case LUA_COMMAND_1:
393 return;
394 case LUA_COMMAND_2:
396 return;
397 case LUA_COMMAND_3:
399 return;
400 case LUA_COMMAND_4:
402 return;
403#if EFI_LTFT_CONTROL
404 case LTFT_RESET:
406 return;
407 case LTFT_APPLY_TO_VE:
409 return;
410 case LTFT_DEV_POKE:
412 return;
413#endif // EFI_LTFT_CONTROL
414#if EFI_HD_ACR
415 case HD_ACR:
416 hdAcrBench(0);
417 return;
418 case HD_ACR2:
419 hdAcrBench(1);
420 return;
421#endif // EFI_HD_ACR
422 case BENCH_HPFP_VALVE:
424 return;
425 case BENCH_FUEL_PUMP:
426 // cmd_test_fuel_pump
428 return;
429 case BENCH_MAIN_RELAY:
431 return;
434 return;
436 // cmd_test_check_engine_light
437 milBench();
438 return;
440 acRelayBench();
441 return;
442 case BENCH_FAN_RELAY:
443 fanBench();
444 return;
445 case BENCH_IDLE_VALVE:
446 // cmd_test_idle_valve
447#if EFI_IDLE_CONTROL
449#endif /* EFI_IDLE_CONTROL */
450 return;
452 fan2Bench();
453 return;
454 case BENCH_CANCEL:
456 return;
457 default:
458 criticalError("Unexpected bench function %d", index);
459 }
460}
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 473 of file bench_test.cpp.

473 {
474// todo: define ts_14_command magic constants and use those in tunerstudio.template.ini file!
475 switch (index) {
476 case TS_GRAB_PEDAL_UP:
478 return;
481 return;
484 return;
485 case TS_GRAB_TPS_OPEN:
487 return;
488 case TS_RESET_TLE8888:
489 #if (BOARD_TLE8888_COUNT > 0)
491 #endif
492 return;
493 case TS_RESET_MC33810:
494 #if EFI_PROD_CODE && (BOARD_MC33810_COUNT > 0)
496 #endif
497 return;
498#if EFI_SHAFT_POSITION_INPUT
500 // this is different from starter relay bench test!
502 return;
503#endif // EFI_SHAFT_POSITION_INPUT
504 case TS_WRITE_FLASH:
505 // cmd_write_config
506 #if EFI_CONFIGURATION_STORAGE
508 #endif /* EFI_CONFIGURATION_STORAGE */
509 return;
511 #if EFI_EMULATE_POSITION_SENSORS == TRUE
513 #endif /* EFI_EMULATE_POSITION_SENSORS == TRUE */
514 return;
516 #if EFI_EMULATE_POSITION_SENSORS == TRUE
518 #endif /* EFI_EMULATE_POSITION_SENSORS == TRUE */
519 return;
521 #if EFI_EMULATE_POSITION_SENSORS == TRUE
523 #endif /* EFI_EMULATE_POSITION_SENSORS == TRUE */
524 return;
525/*
526 case TS_ETB_RESET:
527 #if EFI_ELECTRONIC_THROTTLE_BODY == TRUE
528 #if EFI_PROD_CODE
529 etbPidReset();
530 #endif
531 #endif // EFI_ELECTRONIC_THROTTLE_BODY
532 return;
533*/
534#if EFI_ELECTRONIC_THROTTLE_BODY
535 case TS_ETB_AUTOCAL_0:
536 etbAutocal(DC_Throttle1);
537 return;
538 case TS_ETB_AUTOCAL_1:
539 etbAutocal(DC_Throttle2);
540 return;
542 etbAutocal(DC_Throttle1, false);
543 return;
545 etbAutocal(DC_Throttle2, false);
546 return;
548 engine->etbAutoTune = true;
549 return;
551 engine->etbAutoTune = false;
552 #if EFI_TUNER_STUDIO
554 #endif // EFI_TUNER_STUDIO
555 return;
558 return;
559 case TS_EWG_AUTOCAL_0:
560 etbAutocal(DC_Wastegate);
561 return;
563 etbAutocal(DC_Wastegate, false);
564 return;
565#endif // EFI_ELECTRONIC_THROTTLE_BODY
567 // broadcast, for old WBO FWs
569 return;
571 return;
572
573#if EFI_PROD_CODE && EFI_FILE_LOGGING
574 case TS_SD_MOUNT_PC:
576 return;
577 case TS_SD_MOUNT_ECU:
579 return;
580 case TS_SD_UNMOUNT:
582 return;
583 case TS_SD_FORMAT:
585 return;
588 return;
589#endif // EFI_FILE_LOGGING
590
591 default:
592 criticalError("Unexpected bench x14 %d", index);
593 }
594}
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 345 of file bench_test.cpp.

345 {
347 pinbench(BENCH_AC_RELAY_DURATION, 100.0, 1, pin);
348}
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 290 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 820 of file bench_test.cpp.

820 {
821 addConsoleAction("fuelpumpbench", fuelPumpBench);
822 addConsoleActionF("fuelpumpbench2", fuelPumpBenchExt);
823
824 addConsoleActionFFF(CMD_FUEL_BENCH, fuelInjBench);
826
827 addConsoleActionFFF(CMD_SPARK_BENCH, sparkBench);
828 addConsoleActionFFFF("sparkbench2", sparkBenchExt);
829
831
832 addConsoleAction(CMD_AC_RELAY_BENCH, acRelayBench);
833
834 addConsoleAction(CMD_FAN_BENCH, fanBench);
835 addConsoleAction(CMD_FAN2_BENCH, fan2Bench);
836 addConsoleActionF("fanbench2", fanBenchExt);
837
838 addConsoleAction("mainrelaybench", mainRelayBench);
839
840#if EFI_CAN_SUPPORT
841#if EFI_WIDEBAND_FIRMWARE_UPDATE
842 addConsoleActionI("update_wideband", requestWidebandUpdate);
843#endif // EFI_WIDEBAND_FIRMWARE_UPDATE
844 addConsoleActionII("set_wideband_index", [](int hwIndex, int index) { setWidebandOffset(hwIndex, index); });
845#endif // EFI_CAN_SUPPORT
846
847 addConsoleAction(CMD_STARTER_BENCH, starterRelayBench);
848 addConsoleAction(CMD_MIL_BENCH, milBench);
849 addConsoleAction(CMD_HPFP_BENCH, hpfpValveBench);
850
851#if EFI_CAN_SUPPORT
852 addConsoleActionI("ping_wideband", [](int index) {
853 pingWideband(index);
854 });
855#endif // EFI_CAN_SUPPORT
856
857#if EFI_LUA
858 // this commands facilitates TS Lua Button scripts development
859 addConsoleActionI("lua_button", [](int index) {
860 if (index < 0 || index > LUA_BUTTON_COUNT)
861 return;
862 luaCommandCounters[index - 1]++;
863 });
864 addConsoleActionFFFF("luabench2", [](float humanIndex, float onTime, float offTimeMs, float count) {
865 doRunBenchTestLuaOutput((int)humanIndex, onTime, offTimeMs, (int)count);
866 });
867#endif // EFI_LUA
868 instance.start();
870}
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 35 of file bench_test.cpp.

35 {
36 return isRunningBench;
37}

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

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

269 {
270 pinbench(500.0, 500.0, 16, &enginePins.checkEnginePin);
271}
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 805 of file bench_test.cpp.

805 {
806 // default values if configuration was not specified
809 }
810
813 }
814
817 }
818}

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

161{
162 globalOnTimeMs = ontimeMs;
163 globalOffTimeMs = offtimeMs;
164#if EFI_SIMULATOR
165 globalCount = maxI(2, iterations);
166#else
167 globalCount = iterations;
168#endif // EFI_SIMULATOR
169 pinX = pinParam;
170 swapOnOff = p_swapOnOff;
171 // let's signal bench thread to wake up
172 isBenchTestPending = true;
173 benchSemaphore.signal();
174}
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 658 of file bench_test.cpp.

658 {
659 if (frame.data8[0] != (int)bench_test_magic_numbers_e::BENCH_HEADER) {
660 return;
661 }
662
663 int eid = CAN_EID(frame);
664 if (eid == (int)bench_test_packet_ids_e::ECU_SET_CALIBRATION) {
666 } else if (eid == (int)bench_test_packet_ids_e::ECU_REQ_CALIBRATION) {
668 } else if (eid == (int)bench_test_packet_ids_e::ECU_CAN_BUS_USER_CONTROL) {
670 }
671}
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 638 of file bench_test.cpp.

638 {
639#if EFI_LUA_LOOKUP
640 int hash = getFourBytesLsb(frame, 2);
641 efiPrintf("processCanRequestCalibration=%x", hash);
642 FloatIntBytes fb;
643 fb.f = getConfigValueByHash(hash);
644
645 CanTxMessage msg(CanCategory::BENCH_TEST, (int)bench_test_packet_ids_e::ECU_GET_CALIBRATION, 8, /*bus*/0, /*isExtended*/true);
646 for (size_t i = 0;i<sizeof(float);i++) {
647 msg[4 + i] = fb.bytes[i];
648 }
649
650 fb.i = hash;
651 // first half of the packed is copy of that hash value so that recipients know what they are processing
652 for (size_t i = 0;i<sizeof(float);i++) {
653 msg[i] = fb.bytes[i];
654 }
655#endif // EFI_LUA_LOOKUP
656}
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 628 of file bench_test.cpp.

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

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

615 {
616 // reserved data8[1]
617 uint16_t subsystem = getTwoBytesLsb(frame, 2);
618 uint16_t index = getTwoBytesLsb(frame, 4);
619 executeTSCommand(subsystem, index);
620}
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 305 of file bench_test.cpp.

306{
307 widebandUpdateHwId = hwIndex;
309 benchSemaphore.signal();
310}
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 100 of file bench_test.cpp.

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

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

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

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

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

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

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

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

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

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

Referenced by runBench().

◆ benchSchedStart

scheduling_s benchSchedStart
static

Definition at line 70 of file bench_test.cpp.

Referenced by runBench().

◆ globalCount

int globalCount
static

Definition at line 153 of file bench_test.cpp.

Referenced by pinbench().

◆ globalOffTimeMs

float globalOffTimeMs
static

Definition at line 152 of file bench_test.cpp.

Referenced by pinbench().

◆ globalOnTimeMs

float globalOnTimeMs
static

Definition at line 151 of file bench_test.cpp.

Referenced by pinbench().

◆ instance

BenchController instance
static

◆ isBenchTestPending

volatile bool isBenchTestPending = false
static

Definition at line 148 of file bench_test.cpp.

Referenced by pinbench().

◆ isRunningBench

bool isRunningBench = false
static

Definition at line 32 of file bench_test.cpp.

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

◆ luaCommandCounters

int luaCommandCounters[LUA_BUTTON_COUNT] = {}

Definition at line 351 of file bench_test.cpp.

351{};

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

◆ outputOnTheBenchTest

OutputPin* outputOnTheBenchTest = nullptr
static

Definition at line 33 of file bench_test.cpp.

Referenced by getOutputOnTheBenchTest(), and runBench().

◆ pinX

OutputPin* pinX
static

Definition at line 154 of file bench_test.cpp.

Referenced by pinbench().

◆ rebootForPresetPending

bool rebootForPresetPending
extern

◆ savedDurationsInStateMs

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

Definition at line 75 of file bench_test.cpp.

75{ 0, 0 };

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

◆ savedPinToggleCounter

int savedPinToggleCounter = 0
static

Definition at line 74 of file bench_test.cpp.

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

◆ swapOnOff

bool swapOnOff = false
static

Definition at line 155 of file bench_test.cpp.

Referenced by pinbench(), and runBench().

◆ widebandUpdateHwId

uint8_t widebandUpdateHwId = 0
static

Definition at line 150 of file bench_test.cpp.

Referenced by executeTSCommand(), and requestWidebandUpdate().

◆ widebandUpdatePending

bool widebandUpdatePending = false
static

Definition at line 149 of file bench_test.cpp.

Referenced by requestWidebandUpdate().

Go to the source code of this file.