rusEFI
The most advanced open source ECU
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 fatalErrorForPresetApply ()
 
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])
 

Function Documentation

◆ acRelayBench()

void acRelayBench ( )

Definition at line 277 of file bench_test.cpp.

277  {
278  pinbench(BENCH_AC_RELAY_DURATION, 100.0, 1, &enginePins.acRelay);
279 }
static void pinbench(float ontimeMs, float offtimeMs, int iterations, OutputPin *pinParam, bool p_swapOnOff=false)
Definition: bench_test.cpp:147
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 535 of file bench_test.cpp.

535  {
536  efiPrintf("IO test subsystem=%d index=%d", subsystem, index);
537 
539 
540  switch (subsystem) {
541  case TS_CLEAR_WARNINGS:
542  clearWarnings();
543  break;
544 
545  case TS_DEBUG_MODE:
547  break;
548 
550  if (!running) {
553  }
554  break;
555 
557  if (!running) {
560  }
561  break;
562 
564  if (!running) {
565  doRunSolenoidBench(index, 1000.0,
567  }
568  break;
569 
571  if (!running) {
572  doRunBenchTestLuaOutput(index, 4.0,
574  }
575  break;
576 
577  case TS_X14:
578  handleCommandX14(index);
579  break;
580 #if defined(EFI_WIDEBAND_FIRMWARE_UPDATE) && EFI_CAN_SUPPORT
581  case TS_WIDEBAND:
582  setWidebandOffset(index);
583  break;
584 #endif // EFI_WIDEBAND_FIRMWARE_UPDATE && EFI_CAN_SUPPORT
585  case TS_BENCH_CATEGORY:
586  handleBenchCategory(index);
587  break;
588 
589  case TS_SET_ENGINE_TYPE:
591  setEngineType(index);
592  break;
593 
594  case TS_BOARD_ACTION:
595  boardTsAction(index);
596  break;
597 
600  setEngineType((int)DEFAULT_ENGINE_TYPE);
601  break;
602 
603  case 0x79:
605  break;
606 
607  case 0xba:
608 #if EFI_PROD_CODE && EFI_DFU_JUMP
610 #endif /* EFI_DFU_JUMP */
611  break;
612 
613  case REBOOT_COMMAND:
614 #if EFI_PROD_CODE
615  rebootNow();
616 #endif /* EFI_PROD_CODE */
617  break;
618 
619 #if EFI_USE_OPENBLT
620  case 0xbc:
621  /* Jump to OpenBLT if present */
622  jump_to_openblt();
623  break;
624 #endif
625 
626  default:
627  criticalError("Unexpected bench subsystem %d %d", subsystem, index);
628  }
629 }
void jump_to_openblt()
void jump_to_bootloader()
void fatalErrorForPresetApply()
Definition: bench_test.cpp:524
PUBLIC_API_WEAK void boardTsAction(uint16_t index)
Definition: bench_test.cpp:533
static void doRunFuelInjBench(size_t humanIndex, float onTimeMs, float offTimeMs, int count)
Definition: bench_test.cpp:170
static void handleCommandX14(uint16_t index)
Definition: bench_test.cpp:435
static void doRunSolenoidBench(size_t humanIndex, float onTime, float offTime, int count)
Definition: bench_test.cpp:187
static void doRunSparkBench(size_t humanIndex, float onTime, float offTime, int count)
Definition: bench_test.cpp:179
static void doRunBenchTestLuaOutput(size_t humanIndex, float onTimeMs, float offTimeMs, int count)
Definition: bench_test.cpp:195
void handleBenchCategory(uint16_t index)
Definition: bench_test.cpp:338
RpmCalculator rpmCalculator
Definition: engine.h:274
bool isStopped() const override
Engine * engine
debug_mode_e
Definition: engine_types.h:280
@ TS_WIDEBAND
Definition: engine_types.h:486
@ TS_CLEAR_WARNINGS
Definition: engine_types.h:481
@ TS_BOARD_ACTION
Definition: engine_types.h:494
@ TS_SOLENOID_CATEGORY
Definition: engine_types.h:490
@ TS_LUA_OUTPUT_CATEGORY
Definition: engine_types.h:497
@ TS_DEBUG_MODE
Definition: engine_types.h:464
@ TS_SET_ENGINE_TYPE
Definition: engine_types.h:495
@ TS_X14
Definition: engine_types.h:484
@ TS_IGNITION_CATEGORY
Definition: engine_types.h:482
@ TS_BENCH_CATEGORY
Definition: engine_types.h:487
@ TS_SET_DEFAULT_ENGINE
Definition: engine_types.h:496
@ TS_INJECTOR_CATEGORY
Definition: engine_types.h:483
void clearWarnings(void)
engine_configuration_s * engineConfiguration
void rebootNow()
Definition: rusefi.cpp:150
void setWidebandOffset(uint8_t index)
running("running", SensorCategory.SENSOR_INPUTS, FieldType.INT, 852, 1.0, -1.0, -1.0, "")
void setEngineType(int value, bool isWriteToFlash)
Definition: settings.cpp:729
void scheduleStopEngine()
Definition: settings.cpp:456

Referenced by TunerStudio::handleCrcCommand().

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

◆ fan2Bench()

void fan2Bench ( )

Definition at line 257 of file bench_test.cpp.

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

253  {
254  fanBenchExt(BENCH_FAN_DURATION);
255 }
static void fanBenchExt(float onTimeMs)
Definition: bench_test.cpp:249

Referenced by handleBenchCategory(), and initBenchTest().

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

◆ fatalErrorForPresetApply()

void fatalErrorForPresetApply ( )

Definition at line 524 of file bench_test.cpp.

524  {
525  rebootForPresetPending = true;
527  "\n\nTo complete preset apply:\n"
528  " 1. Close TunerStudio\n"
529  " 2. Power cycle ECU\n"
530  " 3. Open TunerStudio and reconnect\n\n");
531 }
bool rebootForPresetPending
void firmwareError(ObdCode code, const char *fmt,...)
@ OBD_PCM_Processor_Fault

Referenced by executeTSCommand().

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

◆ fuelPumpBench()

void fuelPumpBench ( )

Definition at line 290 of file bench_test.cpp.

290  {
291  fuelPumpBenchExt(BENCH_FUEL_PUMP_DURATION);
292 }
static void fuelPumpBenchExt(float durationMs)
Definition: bench_test.cpp:272

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

32  {
33  return outputOnTheBenchTest;
34 }
static OutputPin * outputOnTheBenchTest
Definition: bench_test.cpp:26

Referenced by applyVvtPinState(), and OutputPin::setValue().

Here is the caller graph for this function:

◆ getSavedBenchTestPinStates()

int getSavedBenchTestPinStates ( uint32_t  durationsInStateMs[2])

Definition at line 424 of file bench_test.cpp.

424  {
425 #if EFI_SIMULATOR
426  durationsInStateMs[0] = savedDurationsInStateMs[0];
427  durationsInStateMs[1] = savedDurationsInStateMs[1];
428  return savedPinToggleCounter;
429 #else
430  UNUSED(durationsInStateMs);
431  return 0;
432 #endif // EFI_SIMULATOR
433 }
static uint32_t savedDurationsInStateMs[2]
Definition: bench_test.cpp:67
static int savedPinToggleCounter
Definition: bench_test.cpp:66
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 338 of file bench_test.cpp.

338  {
339  switch(index) {
340  case BENCH_VVT0_VALVE:
341  vvtValveBench(0);
342  return;
343  case BENCH_VVT1_VALVE:
344  vvtValveBench(1);
345  return;
346  case BENCH_VVT2_VALVE:
347  vvtValveBench(2);
348  return;
349  case BENCH_VVT3_VALVE:
350  vvtValveBench(3);
351  return;
352  case BENCH_AUXOUT0:
353  auxOutBench(0);
354  return;
355  case BENCH_AUXOUT1:
356  auxOutBench(1);
357  return;
358  case BENCH_AUXOUT2:
359  auxOutBench(2);
360  return;
361  case BENCH_AUXOUT3:
362  auxOutBench(3);
363  return;
364  case BENCH_AUXOUT4:
365  auxOutBench(4);
366  return;
367  case BENCH_AUXOUT5:
368  auxOutBench(5);
369  return;
370  case BENCH_AUXOUT6:
371  auxOutBench(6);
372  return;
373  case BENCH_AUXOUT7:
374  auxOutBench(7);
375  return;
376 #if EFI_HD_ACR
377  case HD_ACR:
378  hdAcrBench(0);
379  return;
380  case HD_ACR2:
381  hdAcrBench(1);
382  return;
383 #endif // EFI_HD_ACR
384  case BENCH_HPFP_VALVE:
385  hpfpValveBench();
386  return;
387  case BENCH_FUEL_PUMP:
388  // cmd_test_fuel_pump
389  fuelPumpBench();
390  return;
391  case BENCH_MAIN_RELAY:
392  mainRelayBench();
393  return;
396  return;
398  // cmd_test_check_engine_light
399  milBench();
400  return;
402  acRelayBench();
403  return;
404  case BENCH_FAN_RELAY:
405  fanBench();
406  return;
407  case BENCH_IDLE_VALVE:
408  // cmd_test_idle_valve
409 #if EFI_IDLE_CONTROL
410  startIdleBench();
411 #endif /* EFI_IDLE_CONTROL */
412  return;
413  case BENCH_FAN_RELAY_2:
414  fan2Bench();
415  return;
416  case BENCH_CANCEL:
417  cancelBenchTest();
418  return;
419  default:
420  criticalError("Unexpected bench function %d", index);
421  }
422 }
void fanBench()
Definition: bench_test.cpp:253
void milBench()
Definition: bench_test.cpp:264
static void cancelBenchTest()
Definition: bench_test.cpp:164
void starterRelayBench()
Definition: bench_test.cpp:268
static void hdAcrBench(int index)
Definition: bench_test.cpp:332
static void hpfpValveBench()
Definition: bench_test.cpp:285
static void mainRelayBench()
Definition: bench_test.cpp:281
static void auxOutBench(int index)
Definition: bench_test.cpp:327
void fan2Bench()
Definition: bench_test.cpp:257
void fuelPumpBench()
Definition: bench_test.cpp:290
void acRelayBench()
Definition: bench_test.cpp:277
static void vvtValveBench(int vvtIndex)
Definition: bench_test.cpp:294
@ BENCH_AC_COMPRESSOR_RELAY
Definition: engine_types.h:507
@ BENCH_FAN_RELAY
Definition: engine_types.h:505
@ BENCH_CANCEL
Definition: engine_types.h:516
@ BENCH_VVT0_VALVE
Definition: engine_types.h:517
@ BENCH_AUXOUT4
Definition: engine_types.h:525
@ BENCH_AUXOUT2
Definition: engine_types.h:523
@ BENCH_MAIN_RELAY
Definition: engine_types.h:501
@ BENCH_AUXOUT7
Definition: engine_types.h:528
@ HD_ACR2
Definition: engine_types.h:530
@ BENCH_IDLE_VALVE
Definition: engine_types.h:509
@ HD_ACR
Definition: engine_types.h:529
@ BENCH_AUXOUT3
Definition: engine_types.h:524
@ BENCH_CHECK_ENGINE_LIGHT
Definition: engine_types.h:508
@ BENCH_VVT3_VALVE
Definition: engine_types.h:520
@ BENCH_AUXOUT5
Definition: engine_types.h:526
@ BENCH_AUXOUT1
Definition: engine_types.h:522
@ BENCH_VVT1_VALVE
Definition: engine_types.h:518
@ BENCH_AUXOUT0
Definition: engine_types.h:521
@ BENCH_FAN_RELAY_2
Definition: engine_types.h:506
@ BENCH_HPFP_VALVE
Definition: engine_types.h:510
@ BENCH_FUEL_PUMP
Definition: engine_types.h:502
@ BENCH_AUXOUT6
Definition: engine_types.h:527
@ BENCH_STARTER_ENABLE_RELAY
Definition: engine_types.h:503
@ BENCH_VVT2_VALVE
Definition: engine_types.h:519
void startIdleBench(void)

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

646  {
647  addConsoleAction("fuelpumpbench", fuelPumpBench);
648  addConsoleActionF("fuelpumpbench2", fuelPumpBenchExt);
649 
650  addConsoleActionFFF(CMD_FUEL_BENCH, fuelInjBench);
651  addConsoleActionFFFF("fuelbench2", fuelInjBenchExt);
652 
653  addConsoleActionFFF(CMD_SPARK_BENCH, sparkBench);
654  addConsoleActionFFFF("sparkbench2", sparkBenchExt);
655 
656  addConsoleActionFFFF("tcusolbench", tcuSolenoidBench);
657 
658  addConsoleAction(CMD_AC_RELAY_BENCH, acRelayBench);
659 
660  addConsoleAction(CMD_FAN_BENCH, fanBench);
661  addConsoleAction(CMD_FAN2_BENCH, fan2Bench);
662  addConsoleActionF("fanbench2", fanBenchExt);
663 
664  addConsoleAction("mainrelaybench", mainRelayBench);
665 
666 #if EFI_WIDEBAND_FIRMWARE_UPDATE && EFI_CAN_SUPPORT
667  addConsoleAction("update_wideband", []() { widebandUpdatePending = true; });
668  addConsoleActionI("set_wideband_index", [](int index) { setWidebandOffset(index); });
669 #endif // EFI_WIDEBAND_FIRMWARE_UPDATE && EFI_CAN_SUPPORT
670 
671  addConsoleAction(CMD_STARTER_BENCH, starterRelayBench);
672  addConsoleAction(CMD_MIL_BENCH, milBench);
673  addConsoleAction(CMD_HPFP_BENCH, hpfpValveBench);
674 
675  addConsoleActionFFFF("luabench2", luaOutBench2);
676  instance.start();
678 }
static void sparkBenchExt(float humanIndex, float onTime, float offTimeMs, float count)
Definition: bench_test.cpp:222
static void sparkBench(float onTime, float offTimeMs, float count)
Definition: bench_test.cpp:230
void onConfigurationChangeBenchTest()
Definition: bench_test.cpp:631
static void luaOutBench2(float humanIndex, float onTime, float offTimeMs, float count)
Definition: bench_test.cpp:245
static bool widebandUpdatePending
Definition: bench_test.cpp:138
static void fuelInjBench(float onTimeMs, float offTimeMs, float count)
Definition: bench_test.cpp:215
static void fuelInjBenchExt(float humanIndex, float onTimeMs, float offTimeMs, float count)
Definition: bench_test.cpp:208
static void tcuSolenoidBench(float humanIndex, float onTime, float offTimeMs, float count)
Definition: bench_test.cpp:238
static BenchController instance
Definition: bench_test.cpp:325
void addConsoleActionF(const char *token, VoidFloat callback)
void addConsoleAction(const char *token, Void callback)
Register console action without 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 28 of file bench_test.cpp.

28  {
29  return isRunningBench;
30 }
static bool isRunningBench
Definition: bench_test.cpp:25

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

264  {
265  pinbench(500.0, 500.0, 16, &enginePins.checkEnginePin);
266 }
RegisteredOutputPin checkEnginePin
Definition: efi_gpio.h:116

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

631  {
632  // default values if configuration was not specified
635  }
636 
639  }
640 
643  }
644 }

Referenced by incrementGlobalConfigurationVersion(), and initBenchTest().

Here is the caller graph for this function:

◆ starterRelayBench()

void starterRelayBench ( )

Definition at line 268 of file bench_test.cpp.

268  {
269  pinbench(BENCH_STARTER_DURATION, 100.0, 1, &enginePins.starterControl);
270 }
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.