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 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:

◆ 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
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, 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:

◆ 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:

◆ 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
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 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:

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

35 {
36 return isRunningBench;
37}
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 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:

◆ 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:

◆ 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:

Go to the source code of this file.