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

Detailed Description

Utility methods related to bench testing.

todo: rename this file

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

Definition in file bench_test.h.

Functions

void initBenchTest ()
 
void onConfigurationChangeBenchTest ()
 
bool isRunningBenchTest ()
 
const OutputPingetOutputOnTheBenchTest ()
 
void fanBench ()
 
void fan2Bench ()
 
void fuelPumpBench ()
 
void acRelayBench ()
 
void milBench ()
 
void starterRelayBench ()
 
void executeTSCommand (uint16_t subsystem, uint16_t index)
 
void handleBenchCategory (uint16_t index)
 
int getSavedBenchTestPinStates (uint32_t durationsInStateMs[2])
 
void processCanEcuControl (const CANRxFrame &frame)
 

Function Documentation

◆ acRelayBench()

void acRelayBench ( )

Definition at line 286 of file bench_test.cpp.

286 {
287 pinbench(BENCH_AC_RELAY_DURATION, 100.0, 1, &enginePins.acRelay);
288}
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:

◆ executeTSCommand()

void executeTSCommand ( uint16_t  subsystem,
uint16_t  index 
)

Definition at line 702 of file bench_test.cpp.

702 {
703 efiPrintf("IO test subsystem=%d index=%d", subsystem, index);
704
706
707 switch (subsystem) {
710 break;
711
712 case TS_DEBUG_MODE:
714 break;
715
717 if (!running) {
720 }
721 break;
722
724 if (!running) {
727 }
728 break;
729
731 if (!running) {
732 doRunSolenoidBench(index, 1000.0,
734 }
735 break;
736
738 if (!running) {
739 doRunBenchTestLuaOutput(index, 4.0,
741 }
742 break;
743
744 case TS_X14:
745 handleCommandX14(index);
746 break;
747#if EFI_CAN_SUPPORT
748 case TS_WIDEBAND:
749 setWidebandOffset(0xff, index);
750 break;
752 {
753 uint8_t hwIndex = index >> 8;
754 uint8_t canIndex = index & 0xff;
755
756 // Hack until we fix canReWidebandHwIndex and set "Broadcast" to 0xff
757 // TODO:
758 hwIndex = hwIndex < 8 ? hwIndex : 0xff;
759 setWidebandOffset(hwIndex, canIndex);
760 }
761 break;
763 {
764 uint8_t hwIndex = index >> 8;
765 uint8_t sensType = index & 0xff;
766
767 // Hack until we fix canReWidebandHwIndex and set "Broadcast" to 0xff
768 // TODO:
769 hwIndex = hwIndex < 8 ? hwIndex : 0xff;
770 setWidebandSensorType(hwIndex, sensType);
771 }
772 break;
774 pingWideband(index >> 8);
775 break;
776
779 {
780 uint8_t hwIndex = index >> 8;
781
782 // Hack until we fix canReWidebandHwIndex and set "Broadcast" to 0xff
783 // TODO:
784 widebandUpdateHwId = hwIndex < 8 ? hwIndex : 0xff;
786 }
787 break;
788
791 break;
792
793#endif // EFI_CAN_SUPPORT
795 handleBenchCategory(index);
796 break;
797
799 applyPreset(index);
800 break;
801
802 case TS_BOARD_ACTION:
803 // TODO: use call_board_override
804 if (custom_board_ts_command.has_value()) {
805 custom_board_ts_command.value()(subsystem, index);
806 }
807 break;
808
810 applyPreset((int)DEFAULT_ENGINE_TYPE);
811 break;
812
813 case TS_STOP_ENGINE:
815 break;
816
817 case 0xba:
818#if EFI_PROD_CODE && EFI_DFU_JUMP
820#endif /* EFI_DFU_JUMP */
821 break;
822
823 case REBOOT_COMMAND:
824#if EFI_PROD_CODE
825 rebootNow();
826#endif /* EFI_PROD_CODE */
827 break;
828
829#if EFI_USE_OPENBLT
830 case 0xbc:
831 /* Jump to OpenBLT if present */
833 break;
834#endif
835
836 default:
837 criticalError("Unexpected bench subsystem %d %d", subsystem, index);
838 }
839}
void jump_to_openblt()
void jump_to_bootloader()
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 requestWidebandUpdate(int hwIndex, bool fromFile)
static void applyPreset(int index)
RpmCalculator rpmCalculator
Definition engine.h:314
bool isStopped() const override
static EngineAccessor engine
Definition engine.h:421
static constexpr engine_configuration_s * engineConfiguration
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_WIDEBAND_RESTART
@ TS_WIDEBAND_FLASH_BY_ID_FILE
@ 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)
void restartWideband()
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 266 of file bench_test.cpp.

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

262 {
263 fanBenchExt(BENCH_FAN_DURATION);
264}
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:

◆ fuelPumpBench()

void fuelPumpBench ( )

Definition at line 299 of file bench_test.cpp.

299 {
300 fuelPumpBenchExt(BENCH_FUEL_PUMP_DURATION);
301}
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:

◆ getOutputOnTheBenchTest()

const OutputPin * getOutputOnTheBenchTest ( )

Definition at line 44 of file bench_test.cpp.

44 {
46}
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 473 of file bench_test.cpp.

473 {
474#if EFI_SIMULATOR
475 durationsInStateMs[0] = savedDurationsInStateMs[0];
476 durationsInStateMs[1] = savedDurationsInStateMs[1];
478#else
479 UNUSED(durationsInStateMs);
480 return 0;
481#endif // EFI_SIMULATOR
482}
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 364 of file bench_test.cpp.

364 {
365 switch(index) {
366 case BENCH_VVT0_VALVE:
367 vvtValveBench(0);
368 return;
369 case BENCH_VVT1_VALVE:
370 vvtValveBench(1);
371 return;
372 case BENCH_VVT2_VALVE:
373 vvtValveBench(2);
374 return;
375 case BENCH_VVT3_VALVE:
376 vvtValveBench(3);
377 return;
378 case BENCH_AUXOUT0:
379 auxOutBench(0);
380 return;
381 case BENCH_AUXOUT1:
382 auxOutBench(1);
383 return;
384 case BENCH_AUXOUT2:
385 auxOutBench(2);
386 return;
387 case BENCH_AUXOUT3:
388 auxOutBench(3);
389 return;
390 case BENCH_AUXOUT4:
391 auxOutBench(4);
392 return;
393 case BENCH_AUXOUT5:
394 auxOutBench(5);
395 return;
396 case BENCH_AUXOUT6:
397 auxOutBench(6);
398 return;
399 case BENCH_AUXOUT7:
400 auxOutBench(7);
401 return;
402 case LUA_COMMAND_1:
404 return;
405 case LUA_COMMAND_2:
407 return;
408 case LUA_COMMAND_3:
410 return;
411 case LUA_COMMAND_4:
413 return;
414#if EFI_LTFT_CONTROL
415 case LTFT_RESET:
417 return;
418 case LTFT_APPLY_TO_VE:
420 return;
421 case LTFT_DEV_POKE:
423 return;
424#endif // EFI_LTFT_CONTROL
425#if EFI_HD_ACR
426 case HD_ACR:
427 hdAcrBench(0);
428 return;
429 case HD_ACR2:
430 hdAcrBench(1);
431 return;
432#endif // EFI_HD_ACR
433 case BENCH_HPFP_VALVE:
435 return;
436 case BENCH_FUEL_PUMP:
437 // cmd_test_fuel_pump
439 return;
440 case BENCH_MAIN_RELAY:
442 return;
445 return;
447 // cmd_test_check_engine_light
448 milBench();
449 return;
451 acRelayBench();
452 return;
453 case BENCH_FAN_RELAY:
454 fanBench();
455 return;
456 case BENCH_IDLE_VALVE:
457 // cmd_test_idle_valve
458#if EFI_IDLE_CONTROL
460#endif /* EFI_IDLE_CONTROL */
461 return;
463 fan2Bench();
464 return;
465 case BENCH_CANCEL:
467 return;
468 default:
469 criticalError("Unexpected bench function %d", index);
470 }
471}
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:

◆ initBenchTest()

void initBenchTest ( )

Definition at line 856 of file bench_test.cpp.

856 {
857 addConsoleAction("fuelpumpbench", fuelPumpBench);
858 addConsoleActionF("fuelpumpbench2", fuelPumpBenchExt);
859
860 addConsoleActionFFF(CMD_FUEL_BENCH, fuelInjBench);
862
863 addConsoleActionFFF(CMD_SPARK_BENCH, sparkBench);
864 addConsoleActionFFFF("sparkbench2", sparkBenchExt);
865
867
868 addConsoleAction(CMD_AC_RELAY_BENCH, acRelayBench);
869
870 addConsoleAction(CMD_FAN_BENCH, fanBench);
871 addConsoleAction(CMD_FAN2_BENCH, fan2Bench);
872 addConsoleActionF("fanbench2", fanBenchExt);
873
874 addConsoleAction("mainrelaybench", mainRelayBench);
875
876#if EFI_CAN_SUPPORT
877#if EFI_WIDEBAND_FIRMWARE_UPDATE
878 addConsoleActionI("update_wideband", [](int hwIndex) { requestWidebandUpdate(hwIndex, false); });
879#endif // EFI_WIDEBAND_FIRMWARE_UPDATE
880 addConsoleActionII("set_wideband_index", [](int hwIndex, int index) { setWidebandOffset(hwIndex, index); });
881#endif // EFI_CAN_SUPPORT
882
883 addConsoleAction(CMD_STARTER_BENCH, starterRelayBench);
884 addConsoleAction(CMD_MIL_BENCH, milBench);
885 addConsoleAction(CMD_HPFP_BENCH, hpfpValveBench);
886
887#if EFI_CAN_SUPPORT
888 addConsoleActionI("ping_wideband", [](int index) {
889 pingWideband(index);
890 });
891#endif // EFI_CAN_SUPPORT
892
893#if EFI_LUA
894 // this commands facilitates TS Lua Button scripts development
895 addConsoleActionI("lua_button", [](int index) {
896 if (index < 0 || index > LUA_BUTTON_COUNT)
897 return;
898 luaCommandCounters[index - 1]++;
899 });
900 addConsoleActionFFFF("luabench2", [](float humanIndex, float onTime, float offTimeMs, float count) {
901 doRunBenchTestLuaOutput((int)humanIndex, onTime, offTimeMs, (int)count);
902 });
903#endif // EFI_LUA
904 instance.start();
906}
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 fuelInjBenchExt(float humanIndex, 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)
uint16_t count
Definition tunerstudio.h:1

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

40 {
41 return isRunningBench;
42}
static bool isRunningBench

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

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

273 {
274 pinbench(500.0, 500.0, 16, &enginePins.checkEnginePin);
275}
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 841 of file bench_test.cpp.

841 {
842 // default values if configuration was not specified
845 }
846
849 }
850
853 }
854}

Referenced by incrementGlobalConfigurationVersion(), and initBenchTest().

Here is the caller graph for this function:

◆ processCanEcuControl()

void processCanEcuControl ( const CANRxFrame frame)

Definition at line 683 of file bench_test.cpp.

683 {
684 if (frame.data8[0] != (int)bench_test_magic_numbers_e::BENCH_HEADER) {
685 return;
686 }
687
688 int eid = CAN_EID(frame);
689 if (eid == (int)bench_test_packet_ids_e::ECU_SET_CALIBRATION) {
691 } else if (eid == (int)bench_test_packet_ids_e::ECU_REQ_CALIBRATION) {
693 } else if (eid == (int)bench_test_packet_ids_e::ECU_CAN_BUS_USER_CONTROL) {
695 }
696}
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:

◆ starterRelayBench()

void starterRelayBench ( )

Definition at line 277 of file bench_test.cpp.

277 {
278 pinbench(BENCH_STARTER_DURATION, 100.0, 1, &enginePins.starterControl);
279}
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:

Go to the source code of this file.