rusEFI
The most advanced open source ECU
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 luaOutBench2 (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 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 fatalErrorForPresetApply ()
 
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 float globalOnTimeMs
 
static float globalOffTimeMs
 
static int globalCount
 
static OutputPinpinX
 
static bool swapOnOff = false
 
static BenchController instance
 
bool rebootForPresetPending
 

Function Documentation

◆ acRelayBench()

void acRelayBench ( )

Definition at line 278 of file bench_test.cpp.

278  {
279  pinbench(BENCH_AC_RELAY_DURATION, 100.0, 1, &enginePins.acRelay);
280 }
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:

◆ auxOutBench()

static void auxOutBench ( int  index)
static

Definition at line 329 of file bench_test.cpp.

329  {
330  // todo!
331 }

Referenced by handleBenchCategory().

Here is the caller graph for this function:

◆ benchOff()

static void benchOff ( OutputPin output)
static

Definition at line 77 of file bench_test.cpp.

77  {
78 #if EFI_PROD_CODE && (BOARD_EXT_GPIOCHIPS > 0)
79  static char pin_error[64];
80 
81  brain_pin_diag_e diag = output->getDiag();
82  if (diag == PIN_UNKNOWN) {
83  efiPrintf("No Diag on this pin");
84  } else {
85  pinDiag2string(pin_error, sizeof(pin_error), diag);
86  efiPrintf("Diag says %s", pin_error);
87  }
88 #endif // EFI_PROD_CODE
89  output->setValue(BENCH_MSG, false, /*isForce*/ true);
90 }
brain_pin_diag_e getDiag() const
Definition: efi_gpio.cpp:657
void setValue(const char *msg, int logicValue, bool isForce=false)
Definition: efi_gpio.cpp:583
void pinDiag2string(char *buffer, size_t size, brain_pin_diag_e pin_diag)
brain_pin_diag_e
Definition: rusefi_enums.h:43

Referenced by runBench().

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

◆ benchOn()

static void benchOn ( OutputPin output)
static

Definition at line 73 of file bench_test.cpp.

73  {
74  output->setValue(BENCH_MSG, true, /*isForce*/ true);
75 }

Referenced by runBench().

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

◆ benchSemaphore()

static chibios_rt::CounterSemaphore benchSemaphore ( )
static

Referenced by handleCommandX14(), and pinbench().

Here is the caller graph for this function:

◆ cancelBenchTest()

static void cancelBenchTest ( )
static

Definition at line 164 of file bench_test.cpp.

164  {
165  isRunningBench = false;
166 }
static bool isRunningBench
Definition: bench_test.cpp:25

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

195  {
196  if (humanIndex < 1 || humanIndex > LUA_PWM_COUNT) {
197  efiPrintf("Invalid index: %d", humanIndex);
198  return;
199  }
200  pinbench(onTimeMs, offTimeMs, count,
201  &enginePins.luaOutputPins[humanIndex - 1]);
202 }
OutputPin luaOutputPins[LUA_PWM_COUNT]
Definition: efi_gpio.h:98

Referenced by executeTSCommand(), and luaOutBench2().

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

170  {
171  if (humanIndex < 1 || humanIndex > engineConfiguration->cylindersCount) {
172  efiPrintf("Invalid index: %d", humanIndex);
173  return;
174  }
175  pinbench(onTimeMs, offTimeMs, count,
176  &enginePins.injectors[humanIndex - 1]);
177 }
InjectorOutputPin injectors[MAX_CYLINDER_COUNT]
Definition: efi_gpio.h:125
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 187 of file bench_test.cpp.

187  {
188  if (humanIndex < 1 || humanIndex > TCU_SOLENOID_COUNT) {
189  efiPrintf("Invalid index: %d", humanIndex);
190  return;
191  }
192  pinbench(onTime, offTime, count, &enginePins.tcuSolenoids[humanIndex - 1]);
193 }
OutputPin tcuSolenoids[TCU_SOLENOID_COUNT]
Definition: efi_gpio.h:130

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

179  {
180  if (humanIndex < 1 || humanIndex > engineConfiguration->cylindersCount) {
181  efiPrintf("Invalid index: %d", humanIndex);
182  return;
183  }
184  pinbench(onTime, offTime, count, &enginePins.coils[humanIndex - 1]);
185 }
IgnitionOutputPin coils[MAX_CYLINDER_COUNT]
Definition: efi_gpio.h:127

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

541  {
542  efiPrintf("IO test subsystem=%d index=%d", subsystem, index);
543 
545 
546  switch (subsystem) {
547  case TS_CLEAR_WARNINGS:
548  clearWarnings();
549  break;
550 
551  case TS_DEBUG_MODE:
553  break;
554 
556  if (!running) {
559  }
560  break;
561 
563  if (!running) {
566  }
567  break;
568 
570  if (!running) {
571  doRunSolenoidBench(index, 1000.0,
573  }
574  break;
575 
577  if (!running) {
578  doRunBenchTestLuaOutput(index, 4.0,
580  }
581  break;
582 
583  case TS_X14:
584  handleCommandX14(index);
585  break;
586 #if defined(EFI_WIDEBAND_FIRMWARE_UPDATE) && EFI_CAN_SUPPORT
587  case TS_WIDEBAND:
588  setWidebandOffset(index);
589  break;
590 #endif // EFI_WIDEBAND_FIRMWARE_UPDATE && EFI_CAN_SUPPORT
591  case TS_BENCH_CATEGORY:
592  handleBenchCategory(index);
593  break;
594 
595  case TS_SET_ENGINE_TYPE:
597  setEngineType(index);
598  break;
599 
602  setEngineType((int)DEFAULT_ENGINE_TYPE);
603  break;
604 
605  case 0x79:
607  break;
608 
609  case 0xba:
610 #if EFI_PROD_CODE && EFI_DFU_JUMP
612 #endif /* EFI_DFU_JUMP */
613  break;
614 
615  case 0xbb:
616 #if EFI_PROD_CODE
617  rebootNow();
618 #endif /* EFI_PROD_CODE */
619  break;
620 
621 #if EFI_USE_OPENBLT
622  case 0xbc:
623  /* Jump to OpenBLT if present */
624  jump_to_openblt();
625  break;
626 #endif
627 
628  default:
629  criticalError("Unexpected bench subsystem %d %d", subsystem, index);
630  }
631 }
void jump_to_openblt()
void jump_to_bootloader()
static void fatalErrorForPresetApply()
Definition: bench_test.cpp:532
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:437
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:340
RpmCalculator rpmCalculator
Definition: engine.h:273
bool isStopped() const override
Engine * engine
debug_mode_e
Definition: engine_types.h:280
@ TS_WIDEBAND
Definition: engine_types.h:478
@ TS_CLEAR_WARNINGS
Definition: engine_types.h:473
@ TS_SOLENOID_CATEGORY
Definition: engine_types.h:482
@ TS_LUA_OUTPUT_CATEGORY
Definition: engine_types.h:489
@ TS_DEBUG_MODE
Definition: engine_types.h:456
@ TS_SET_ENGINE_TYPE
Definition: engine_types.h:487
@ TS_X14
Definition: engine_types.h:476
@ TS_IGNITION_CATEGORY
Definition: engine_types.h:474
@ TS_BENCH_CATEGORY
Definition: engine_types.h:479
@ TS_SET_DEFAULT_ENGINE
Definition: engine_types.h:488
@ TS_INJECTOR_CATEGORY
Definition: engine_types.h:475
void clearWarnings(void)
void rebootNow()
Definition: rusefi.cpp:150
void setWidebandOffset(uint8_t index)
running("running", SensorCategory.SENSOR_INPUTS, FieldType.INT, 836, 1.0, -1.0, -1.0, "")
void setEngineType(int value, bool isWriteToFlash)
Definition: settings.cpp:941
void scheduleStopEngine()
Definition: settings.cpp:650

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

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

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

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

250  {
251  pinbench(onTimeMs, 100.0, 1, &enginePins.fanRelay);
252 }
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:

◆ fatalErrorForPresetApply()

static void fatalErrorForPresetApply ( )
static

Definition at line 532 of file bench_test.cpp.

532  {
533  rebootForPresetPending = true;
535  "\n\nTo complete preset apply:\n"
536  " 1. Close TunerStudio\n"
537  " 2. Power cycle ECU\n"
538  " 3. Open TunerStudio and reconnect\n\n");
539 }
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:

◆ fuelInjBench()

static void fuelInjBench ( float  onTimeMs,
float  offTimeMs,
float  count 
)
static

fuelbench 5 1000 2

Definition at line 215 of file bench_test.cpp.

215  {
216  fuelInjBenchExt(1, onTimeMs, offTimeMs, count);
217 }
static void fuelInjBenchExt(float humanIndex, float onTimeMs, float offTimeMs, float count)
Definition: bench_test.cpp:208

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

208  {
209  doRunFuelInjBench((int)humanIndex, onTimeMs, offTimeMs, (int)count);
210 }

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

292  {
293  fuelPumpBenchExt(BENCH_FUEL_PUMP_DURATION);
294 }
static void fuelPumpBenchExt(float durationMs)
Definition: bench_test.cpp:273

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

273  {
274  pinbench(durationMs, 100.0, 1,
276 }
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 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 426 of file bench_test.cpp.

426  {
427 #if EFI_SIMULATOR
428  durationsInStateMs[0] = savedDurationsInStateMs[0];
429  durationsInStateMs[1] = savedDurationsInStateMs[1];
430  return savedPinToggleCounter;
431 #else
432  UNUSED(durationsInStateMs);
433  return 0;
434 #endif // EFI_SIMULATOR
435 }
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 340 of file bench_test.cpp.

340  {
341  switch(index) {
342  case BENCH_VVT0_VALVE:
343  vvtValveBench(0);
344  return;
345  case BENCH_VVT1_VALVE:
346  vvtValveBench(1);
347  return;
348  case BENCH_VVT2_VALVE:
349  vvtValveBench(2);
350  return;
351  case BENCH_VVT3_VALVE:
352  vvtValveBench(3);
353  return;
354  case BENCH_AUXOUT0:
355  auxOutBench(0);
356  return;
357  case BENCH_AUXOUT1:
358  auxOutBench(1);
359  return;
360  case BENCH_AUXOUT2:
361  auxOutBench(2);
362  return;
363  case BENCH_AUXOUT3:
364  auxOutBench(3);
365  return;
366  case BENCH_AUXOUT4:
367  auxOutBench(4);
368  return;
369  case BENCH_AUXOUT5:
370  auxOutBench(5);
371  return;
372  case BENCH_AUXOUT6:
373  auxOutBench(6);
374  return;
375  case BENCH_AUXOUT7:
376  auxOutBench(7);
377  return;
378 #if EFI_HD_ACR
379  case HD_ACR:
380  hdAcrBench(0);
381  return;
382  case HD_ACR2:
383  hdAcrBench(1);
384  return;
385 #endif // EFI_HD_ACR
386  case BENCH_HPFP_VALVE:
387  hpfpValveBench();
388  return;
389  case BENCH_FUEL_PUMP:
390  // cmd_test_fuel_pump
391  fuelPumpBench();
392  return;
393  case BENCH_MAIN_RELAY:
394  mainRelayBench();
395  return;
398  return;
400  // cmd_test_check_engine_light
401  milBench();
402  return;
404  acRelayBench();
405  return;
406  case BENCH_FAN_RELAY:
407  fanBench();
408  return;
409  case BENCH_IDLE_VALVE:
410  // cmd_test_idle_valve
411 #if EFI_IDLE_CONTROL
412  startIdleBench();
413 #endif /* EFI_IDLE_CONTROL */
414  return;
415  case BENCH_FAN_RELAY_2:
416  fan2Bench();
417  return;
418  case BENCH_CANCEL:
419  cancelBenchTest();
420  return;
421  default:
422  criticalError("Unexpected bench function %d", index);
423  }
424 }
void fanBench()
Definition: bench_test.cpp:254
void milBench()
Definition: bench_test.cpp:265
static void cancelBenchTest()
Definition: bench_test.cpp:164
void starterRelayBench()
Definition: bench_test.cpp:269
static void hdAcrBench(int index)
Definition: bench_test.cpp:334
static void hpfpValveBench()
Definition: bench_test.cpp:287
static void mainRelayBench()
Definition: bench_test.cpp:282
static void auxOutBench(int index)
Definition: bench_test.cpp:329
void fan2Bench()
Definition: bench_test.cpp:258
void fuelPumpBench()
Definition: bench_test.cpp:292
void acRelayBench()
Definition: bench_test.cpp:278
static void vvtValveBench(int vvtIndex)
Definition: bench_test.cpp:296
@ BENCH_AC_COMPRESSOR_RELAY
Definition: engine_types.h:499
@ BENCH_FAN_RELAY
Definition: engine_types.h:497
@ BENCH_CANCEL
Definition: engine_types.h:508
@ BENCH_VVT0_VALVE
Definition: engine_types.h:509
@ BENCH_AUXOUT4
Definition: engine_types.h:517
@ BENCH_AUXOUT2
Definition: engine_types.h:515
@ BENCH_MAIN_RELAY
Definition: engine_types.h:493
@ BENCH_AUXOUT7
Definition: engine_types.h:520
@ HD_ACR2
Definition: engine_types.h:522
@ BENCH_IDLE_VALVE
Definition: engine_types.h:501
@ HD_ACR
Definition: engine_types.h:521
@ BENCH_AUXOUT3
Definition: engine_types.h:516
@ BENCH_CHECK_ENGINE_LIGHT
Definition: engine_types.h:500
@ BENCH_VVT3_VALVE
Definition: engine_types.h:512
@ BENCH_AUXOUT5
Definition: engine_types.h:518
@ BENCH_AUXOUT1
Definition: engine_types.h:514
@ BENCH_VVT1_VALVE
Definition: engine_types.h:510
@ BENCH_AUXOUT0
Definition: engine_types.h:513
@ BENCH_FAN_RELAY_2
Definition: engine_types.h:498
@ BENCH_HPFP_VALVE
Definition: engine_types.h:502
@ BENCH_FUEL_PUMP
Definition: engine_types.h:494
@ BENCH_AUXOUT6
Definition: engine_types.h:519
@ BENCH_STARTER_ENABLE_RELAY
Definition: engine_types.h:495
@ BENCH_VVT2_VALVE
Definition: engine_types.h:511
void startIdleBench(void)

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

437  {
438 // todo: define ts_14_command magic constants and use those in tunerstudio.template.ini file!
439  switch (index) {
440  case TS_GRAB_TPS_CLOSED:
441  grabTPSIsClosed();
442  return;
443  case TS_GRAB_TPS_WOT:
445  return;
446  // case 4: tps2_closed
447  // case 5: tps2_wot
448  case TS_GRAB_PEDAL_UP:
449  grabPedalIsUp();
450  return;
451  case TS_GRAB_PEDAL_WOT:
453  return;
454  case TS_RESET_TLE8888:
455  #if (BOARD_TLE8888_COUNT > 0)
457  #endif
458  return;
459  case TS_RESET_MC33810:
460  #if EFI_PROD_CODE && (BOARD_MC33810_COUNT > 0)
462  #endif
463  return;
464  case TS_WRITE_FLASH:
465  // cmd_write_config
466  #if EFI_CONFIGURATION_STORAGE
467  writeToFlashNow();
468  #endif /* EFI_CONFIGURATION_STORAGE */
469  return;
471  #if EFI_EMULATE_POSITION_SENSORS == TRUE
473  #endif /* EFI_EMULATE_POSITION_SENSORS == TRUE */
474  return;
476  #if EFI_EMULATE_POSITION_SENSORS == TRUE
478  #endif /* EFI_EMULATE_POSITION_SENSORS == TRUE */
479  return;
481  #if EFI_EMULATE_POSITION_SENSORS == TRUE
483  #endif /* EFI_EMULATE_POSITION_SENSORS == TRUE */
484  return;
485  case TS_ETB_RESET:
486  #if EFI_ELECTRONIC_THROTTLE_BODY == TRUE
487  #if EFI_PROD_CODE
488  etbPidReset();
489  #endif
490  #endif /* EFI_ELECTRONIC_THROTTLE_BODY == TRUE */
491  return;
492  case TS_ETB_AUTOCAL_0:
493  #if EFI_ELECTRONIC_THROTTLE_BODY == TRUE
494  etbAutocal(0);
495  #endif /* EFI_ELECTRONIC_THROTTLE_BODY == TRUE */
496  return;
497  case TS_ETB_AUTOCAL_1:
498  #if EFI_ELECTRONIC_THROTTLE_BODY == TRUE
499  etbAutocal(1);
500  #endif /* EFI_ELECTRONIC_THROTTLE_BODY == TRUE */
501  return;
503  #if EFI_ELECTRONIC_THROTTLE_BODY == TRUE
504  engine->etbAutoTune = true;
505  #endif /* EFI_ELECTRONIC_THROTTLE_BODY == TRUE */
506  return;
508  #if EFI_ELECTRONIC_THROTTLE_BODY == TRUE
509  engine->etbAutoTune = false;
510  #if EFI_TUNER_STUDIO
512  #endif // EFI_TUNER_STUDIO
513  #endif /* EFI_ELECTRONIC_THROTTLE_BODY == TRUE */
514  return;
515  case TS_WIDEBAND_UPDATE:
516  widebandUpdatePending = true;
517  benchSemaphore.signal();
518  return;
520  #if EFI_PROD_CODE && EFI_CONFIGURATION_STORAGE
521  extern bool burnWithoutFlash;
522  burnWithoutFlash = true;
523  #endif /* EFI_PROD_CODE && EFI_CONFIGURATION_STORAGE */
524  return;
525  default:
526  criticalError("Unexpected bench x14 %d", index);
527  }
528 }
static chibios_rt::CounterSemaphore benchSemaphore(0)
static bool widebandUpdatePending
Definition: bench_test.cpp:138
bool etbAutoTune
Definition: engine.h:264
TunerStudioOutputChannels outputChannels
Definition: engine.h:99
void etbAutocal(size_t throttleIndex)
void etbPidReset()
@ TS_GRAB_TPS_CLOSED
Definition: engine_types.h:433
@ TS_TRIGGER_STIMULATOR_ENABLE
Definition: engine_types.h:444
@ TS_BURN_WITHOUT_FLASH
Definition: engine_types.h:452
@ TS_ETB_STOP_AUTOTUNE
Definition: engine_types.h:447
@ TS_WRITE_FLASH
Definition: engine_types.h:441
@ TS_GRAB_PEDAL_UP
Definition: engine_types.h:437
@ TS_GRAB_TPS_WOT
Definition: engine_types.h:434
@ TS_ETB_AUTOCAL_0
Definition: engine_types.h:445
@ TS_RESET_TLE8888
Definition: engine_types.h:439
@ TS_ETB_AUTOCAL_1
Definition: engine_types.h:448
@ TS_TRIGGER_STIMULATOR_DISABLE
Definition: engine_types.h:446
@ TS_ETB_RESET
Definition: engine_types.h:442
@ TS_RESET_MC33810
Definition: engine_types.h:451
@ TS_ETB_START_AUTOTUNE
Definition: engine_types.h:443
@ TS_GRAB_PEDAL_WOT
Definition: engine_types.h:438
@ TS_EXTERNAL_TRIGGER_STIMULATOR_ENABLE
Definition: engine_types.h:450
@ TS_WIDEBAND_UPDATE
Definition: engine_types.h:449
void writeToFlashNow()
Definition: flash_main.cpp:135
bool burnWithoutFlash
Definition: flash_main.cpp:133
void mc33810_req_init()
Definition: mc33810.cpp:795
void tle8888_req_init()
Definition: tle8888.cpp:1272
void grabPedalIsUp()
Definition: tps.cpp:23
void grabTPSIsWideOpen()
Definition: tps.cpp:15
void grabTPSIsClosed()
Definition: tps.cpp:7
void grabPedalIsWideOpen()
Definition: tps.cpp:32
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 334 of file bench_test.cpp.

334  {
336  pinbench(BENCH_AC_RELAY_DURATION, 100.0, 1, pin);
337 }
RegisteredOutputPin harleyAcr2
Definition: efi_gpio.h:94
RegisteredNamedOutputPin harleyAcr
Definition: efi_gpio.h:93
Single output pin reference and state.
Definition: efi_output.h:50
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 287 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 648 of file bench_test.cpp.

648  {
649  addConsoleAction("fuelpumpbench", fuelPumpBench);
650  addConsoleActionF("fuelpumpbench2", fuelPumpBenchExt);
651 
652  addConsoleActionFFF(CMD_FUEL_BENCH, fuelInjBench);
653  addConsoleActionFFFF("fuelbench2", fuelInjBenchExt);
654 
655  addConsoleActionFFF(CMD_SPARK_BENCH, sparkBench);
656  addConsoleActionFFFF("sparkbench2", sparkBenchExt);
657 
658  addConsoleActionFFFF("tcusolbench", tcuSolenoidBench);
659 
660  addConsoleAction(CMD_AC_RELAY_BENCH, acRelayBench);
661 
662  addConsoleAction(CMD_FAN_BENCH, fanBench);
663  addConsoleAction(CMD_FAN2_BENCH, fan2Bench);
664  addConsoleActionF("fanbench2", fanBenchExt);
665 
666  addConsoleAction("mainrelaybench", mainRelayBench);
667 
668 #if EFI_WIDEBAND_FIRMWARE_UPDATE && EFI_CAN_SUPPORT
669  addConsoleAction("update_wideband", []() { widebandUpdatePending = true; });
670  addConsoleActionI("set_wideband_index", [](int index) { setWidebandOffset(index); });
671 #endif // EFI_WIDEBAND_FIRMWARE_UPDATE && EFI_CAN_SUPPORT
672 
673  addConsoleAction(CMD_STARTER_BENCH, starterRelayBench);
674  addConsoleAction(CMD_MIL_BENCH, milBench);
675  addConsoleAction(CMD_HPFP_BENCH, hpfpValveBench);
676 
677  addConsoleActionFFFF("luabench2", luaOutBench2);
678  instance.start();
680 }
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:633
static void luaOutBench2(float humanIndex, float onTime, float offTimeMs, float count)
Definition: bench_test.cpp:246
static void fuelInjBench(float onTimeMs, float offTimeMs, float count)
Definition: bench_test.cpp:215
static void tcuSolenoidBench(float humanIndex, float onTime, float offTimeMs, float count)
Definition: bench_test.cpp:238
static BenchController instance
Definition: bench_test.cpp:327
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 }

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

Here is the caller graph for this function:

◆ luaOutBench2()

static void luaOutBench2 ( float  humanIndex,
float  onTime,
float  offTimeMs,
float  count 
)
static

channel #1, 5ms ON, 1000ms OFF, repeat 3 times fsiobench2 1 5 1000 3

Definition at line 246 of file bench_test.cpp.

246  {
247  doRunBenchTestLuaOutput((int)humanIndex, onTime, offTimeMs, (int)count);
248 }

Referenced by initBenchTest().

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

◆ mainRelayBench()

static void mainRelayBench ( )
static

Definition at line 282 of file bench_test.cpp.

282  {
283  // main relay is usually "ON" via FSIO thus bench testing that one is pretty unusual
284  pinbench(BENCH_MAIN_RELAY_DURATION, 100.0, 1, &enginePins.mainRelay, true);
285 }
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 265 of file bench_test.cpp.

265  {
266  pinbench(500.0, 500.0, 16, &enginePins.checkEnginePin);
267 }
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 633 of file bench_test.cpp.

633  {
634  // default values if configuration was not specified
637  }
638 
641  }
642 
645  }
646 }

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

149 {
150  globalOnTimeMs = ontimeMs;
151  globalOffTimeMs = offtimeMs;
152 #if EFI_SIMULATOR
153  globalCount = maxI(2, iterations);
154 #else
155  globalCount = iterations;
156 #endif // EFI_SIMULATOR
157  pinX = pinParam;
158  swapOnOff = p_swapOnOff;
159  // let's signal bench thread to wake up
160  isBenchTestPending = true;
161  benchSemaphore.signal();
162 }
static int globalCount
Definition: bench_test.cpp:141
static float globalOnTimeMs
Definition: bench_test.cpp:139
static volatile bool isBenchTestPending
Definition: bench_test.cpp:137
static float globalOffTimeMs
Definition: bench_test.cpp:140
static bool swapOnOff
Definition: bench_test.cpp:143
static OutputPin * pinX
Definition: bench_test.cpp:142

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:

◆ runBench()

static void runBench ( OutputPin output,
float  onTimeMs,
float  offTimeMs,
int  count,
bool  swapOnOff 
)
static

Definition at line 92 of file bench_test.cpp.

92  {
93  int onTimeUs = MS2US(maxF(0.1, onTimeMs));
94  int offTimeUs = MS2US(maxF(0.1, offTimeMs));
95 
96  if (onTimeUs > TOO_FAR_INTO_FUTURE_US) {
97  firmwareError(ObdCode::CUSTOM_ERR_BENCH_PARAM, "onTime above limit %dus", TOO_FAR_INTO_FUTURE_US);
98  return;
99  }
100 
101  efiPrintf("Running bench: ON_TIME=%d us OFF_TIME=%d us Counter=%d", onTimeUs, offTimeUs, count);
102  efiPrintf("output on %s", hwPortname(output->brainPin));
103 
104  isRunningBench = true;
105  outputOnTheBenchTest = output;
106 
107  for (int i = 0; isRunningBench && i < count; i++) {
109  efitick_t nowNt = getTimeNowNt();
110  // start in a short time so the scheduler can precisely schedule the start event
111  efitick_t startTime = nowNt + US2NT(50);
112  efitick_t endTime = startTime + US2NT(onTimeUs);
113 
114  // Schedule both events
115  engine->executor.scheduleByTimestampNt("bstart", &benchSchedStart, startTime, {(swapOnOff ? benchOff : benchOn), output});
116  engine->executor.scheduleByTimestampNt("bend", &benchSchedEnd, endTime, {(swapOnOff ? benchOn : benchOff), output});
117 
118  // Wait one full cycle time for the event + delay to happen
119  chThdSleepMicroseconds(onTimeUs + offTimeUs);
120  }
121  /* last */
123 
124 #if EFI_SIMULATOR
125  // save the current counters and durations after the test while the pin is still controlled
129 #endif // EFI_SIMULATOR
130 
131  efiPrintf("Done!");
132  outputOnTheBenchTest = nullptr;
133  isRunningBench = false;
134 }
static scheduling_s benchSchedStart
Definition: bench_test.cpp:62
static void benchOff(OutputPin *output)
Definition: bench_test.cpp:77
static scheduling_s benchSchedEnd
Definition: bench_test.cpp:63
static void benchOn(OutputPin *output)
Definition: bench_test.cpp:73
SingleTimerExecutor executor
Definition: engine.h:241
uint32_t durationsInStateMs[2]
Definition: efi_output.h:82
int pinToggleCounter
Definition: efi_output.h:77
brain_pin_e brainPin
Definition: efi_output.h:87
void scheduleByTimestampNt(const char *msg, scheduling_s *scheduling, efitick_t timeNt, action_s action) override
efitick_t getTimeNowNt()
Definition: efitime.cpp:19
@ 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 230 of file bench_test.cpp.

230  {
231  sparkBenchExt(1, onTime, offTimeMs, count);
232 }

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

222  {
223  doRunSparkBench((int)humanIndex, onTime, offTimeMs, (int)count);
224 }

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

269  {
270  pinbench(BENCH_STARTER_DURATION, 100.0, 1, &enginePins.starterControl);
271 }
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 238 of file bench_test.cpp.

238  {
239  doRunSolenoidBench((int)humanIndex, onTime, offTimeMs, (int)count);
240 }

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

296  {
297 #if EFI_VVT_PID
298  pinbench(BENCH_VVT_DURATION, 100.0, 1, getVvtOutputPin(vvtIndex));
299 #endif // EFI_VVT_PID
300 }
OutputPin * getVvtOutputPin(int index)
Definition: vvt.cpp:145

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

Referenced by runBench().

◆ benchSchedStart

scheduling_s benchSchedStart
static

Definition at line 62 of file bench_test.cpp.

Referenced by runBench().

◆ globalCount

int globalCount
static

Definition at line 141 of file bench_test.cpp.

Referenced by pinbench().

◆ globalOffTimeMs

float globalOffTimeMs
static

Definition at line 140 of file bench_test.cpp.

Referenced by pinbench().

◆ globalOnTimeMs

float globalOnTimeMs
static

Definition at line 139 of file bench_test.cpp.

Referenced by pinbench().

◆ instance

BenchController instance
static

Definition at line 327 of file bench_test.cpp.

Referenced by initBenchTest().

◆ isBenchTestPending

volatile bool isBenchTestPending = false
static

Definition at line 137 of file bench_test.cpp.

Referenced by pinbench().

◆ isRunningBench

bool isRunningBench = false
static

Definition at line 25 of file bench_test.cpp.

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

◆ outputOnTheBenchTest

OutputPin* outputOnTheBenchTest = nullptr
static

Definition at line 26 of file bench_test.cpp.

Referenced by getOutputOnTheBenchTest(), and runBench().

◆ pinX

OutputPin* pinX
static

Definition at line 142 of file bench_test.cpp.

Referenced by pinbench().

◆ rebootForPresetPending

bool rebootForPresetPending
extern

Definition at line 34 of file tunerstudio_commands.cpp.

Referenced by fatalErrorForPresetApply().

◆ savedDurationsInStateMs

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

Definition at line 67 of file bench_test.cpp.

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

◆ savedPinToggleCounter

int savedPinToggleCounter = 0
static

Definition at line 66 of file bench_test.cpp.

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

◆ swapOnOff

bool swapOnOff = false
static

Definition at line 143 of file bench_test.cpp.

Referenced by pinbench(), and runBench().

◆ widebandUpdatePending

bool widebandUpdatePending = false
static

Definition at line 138 of file bench_test.cpp.

Referenced by handleCommandX14(), and initBenchTest().

Go to the source code of this file.