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

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

688 {
689 efiPrintf("IO test subsystem=%d index=%d", subsystem, index);
690
692
693 switch (subsystem) {
696 break;
697
698 case TS_DEBUG_MODE:
700 break;
701
703 if (!running) {
706 }
707 break;
708
710 if (!running) {
713 }
714 break;
715
717 if (!running) {
718 doRunSolenoidBench(index, 1000.0,
720 }
721 break;
722
724 if (!running) {
725 doRunBenchTestLuaOutput(index, 4.0,
727 }
728 break;
729
730 case TS_X14:
731 handleCommandX14(index);
732 break;
733#if EFI_CAN_SUPPORT
734 case TS_WIDEBAND:
735 setWidebandOffset(0xff, index);
736 break;
738 {
739 uint8_t hwIndex = index >> 8;
740 uint8_t canIndex = index & 0xff;
741
742 // Hack until we fix canReWidebandHwIndex and set "Broadcast" to 0xff
743 // TODO:
744 hwIndex = hwIndex < 8 ? hwIndex : 0xff;
745 setWidebandOffset(hwIndex, canIndex);
746 }
747 break;
749 {
750 uint8_t hwIndex = index >> 8;
751 uint8_t sensType = index & 0xff;
752
753 // Hack until we fix canReWidebandHwIndex and set "Broadcast" to 0xff
754 // TODO:
755 hwIndex = hwIndex < 8 ? hwIndex : 0xff;
756 setWidebandSensorType(hwIndex, sensType);
757 }
758 break;
760 pingWideband(index >> 8);
761 break;
762
764 {
765 uint8_t hwIndex = index >> 8;
766
767 // Hack until we fix canReWidebandHwIndex and set "Broadcast" to 0xff
768 // TODO:
769 widebandUpdateHwId = hwIndex < 8 ? hwIndex : 0xff;
771 }
772 break;
773#endif // EFI_CAN_SUPPORT
775 handleBenchCategory(index);
776 break;
777
779 applyPreset(index);
780 break;
781
782 case TS_BOARD_ACTION:
783 // TODO: use call_board_override
784 if (custom_board_ts_command.has_value()) {
785 custom_board_ts_command.value()(subsystem, index);
786 }
787 break;
788
790 applyPreset((int)DEFAULT_ENGINE_TYPE);
791 break;
792
793 case TS_STOP_ENGINE:
795 break;
796
797 case 0xba:
798#if EFI_PROD_CODE && EFI_DFU_JUMP
800#endif /* EFI_DFU_JUMP */
801 break;
802
803 case REBOOT_COMMAND:
804#if EFI_PROD_CODE
805 rebootNow();
806#endif /* EFI_PROD_CODE */
807 break;
808
809#if EFI_USE_OPENBLT
810 case 0xbc:
811 /* Jump to OpenBLT if present */
813 break;
814#endif
815
816 default:
817 criticalError("Unexpected bench subsystem %d %d", subsystem, index);
818 }
819}
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
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_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 264 of file bench_test.cpp.

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

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

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

43 {
45}
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 464 of file bench_test.cpp.

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

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

836 {
837 addConsoleAction("fuelpumpbench", fuelPumpBench);
838 addConsoleActionF("fuelpumpbench2", fuelPumpBenchExt);
839
840 addConsoleActionFFF(CMD_FUEL_BENCH, fuelInjBench);
842
843 addConsoleActionFFF(CMD_SPARK_BENCH, sparkBench);
844 addConsoleActionFFFF("sparkbench2", sparkBenchExt);
845
847
848 addConsoleAction(CMD_AC_RELAY_BENCH, acRelayBench);
849
850 addConsoleAction(CMD_FAN_BENCH, fanBench);
851 addConsoleAction(CMD_FAN2_BENCH, fan2Bench);
852 addConsoleActionF("fanbench2", fanBenchExt);
853
854 addConsoleAction("mainrelaybench", mainRelayBench);
855
856#if EFI_CAN_SUPPORT
857#if EFI_WIDEBAND_FIRMWARE_UPDATE
858 addConsoleActionI("update_wideband", requestWidebandUpdate);
859#endif // EFI_WIDEBAND_FIRMWARE_UPDATE
860 addConsoleActionII("set_wideband_index", [](int hwIndex, int index) { setWidebandOffset(hwIndex, index); });
861#endif // EFI_CAN_SUPPORT
862
863 addConsoleAction(CMD_STARTER_BENCH, starterRelayBench);
864 addConsoleAction(CMD_MIL_BENCH, milBench);
865 addConsoleAction(CMD_HPFP_BENCH, hpfpValveBench);
866
867#if EFI_CAN_SUPPORT
868 addConsoleActionI("ping_wideband", [](int index) {
869 pingWideband(index);
870 });
871#endif // EFI_CAN_SUPPORT
872
873#if EFI_LUA
874 // this commands facilitates TS Lua Button scripts development
875 addConsoleActionI("lua_button", [](int index) {
876 if (index < 0 || index > LUA_BUTTON_COUNT)
877 return;
878 luaCommandCounters[index - 1]++;
879 });
880 addConsoleActionFFFF("luabench2", [](float humanIndex, float onTime, float offTimeMs, float count) {
881 doRunBenchTestLuaOutput((int)humanIndex, onTime, offTimeMs, (int)count);
882 });
883#endif // EFI_LUA
884 instance.start();
886}
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 39 of file bench_test.cpp.

39 {
40 return isRunningBench;
41}
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 271 of file bench_test.cpp.

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

821 {
822 // default values if configuration was not specified
825 }
826
829 }
830
833 }
834}

Referenced by incrementGlobalConfigurationVersion(), and initBenchTest().

Here is the caller graph for this function:

◆ processCanEcuControl()

void processCanEcuControl ( const CANRxFrame frame)

Definition at line 669 of file bench_test.cpp.

669 {
670 if (frame.data8[0] != (int)bench_test_magic_numbers_e::BENCH_HEADER) {
671 return;
672 }
673
674 int eid = CAN_EID(frame);
675 if (eid == (int)bench_test_packet_ids_e::ECU_SET_CALIBRATION) {
677 } else if (eid == (int)bench_test_packet_ids_e::ECU_REQ_CALIBRATION) {
679 } else if (eid == (int)bench_test_packet_ids_e::ECU_CAN_BUS_USER_CONTROL) {
681 }
682}
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 275 of file bench_test.cpp.

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