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

◆ auxOutBench()

static void auxOutBench ( int  index)
static

Definition at line 327 of file bench_test.cpp.

327  {
328  // todo!
329 }

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:656
void setValue(const char *msg, int logicValue, bool isForce=false)
Definition: efi_gpio.cpp:581
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 539 of file bench_test.cpp.

539  {
540  efiPrintf("IO test subsystem=%d index=%d", subsystem, index);
541 
543 
544  switch (subsystem) {
545  case TS_CLEAR_WARNINGS:
546  clearWarnings();
547  break;
548 
549  case TS_DEBUG_MODE:
551  break;
552 
554  if (!running) {
557  }
558  break;
559 
561  if (!running) {
564  }
565  break;
566 
568  if (!running) {
569  doRunSolenoidBench(index, 1000.0,
571  }
572  break;
573 
575  if (!running) {
576  doRunBenchTestLuaOutput(index, 4.0,
578  }
579  break;
580 
581  case TS_X14:
582  handleCommandX14(index);
583  break;
584 #if defined(EFI_WIDEBAND_FIRMWARE_UPDATE) && EFI_CAN_SUPPORT
585  case TS_WIDEBAND:
586  setWidebandOffset(index);
587  break;
588 #endif // EFI_WIDEBAND_FIRMWARE_UPDATE && EFI_CAN_SUPPORT
589  case TS_BENCH_CATEGORY:
590  handleBenchCategory(index);
591  break;
592 
593  case TS_SET_ENGINE_TYPE:
595  setEngineType(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 0xbb:
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()
static void fatalErrorForPresetApply()
Definition: bench_test.cpp:530
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:273
bool isStopped() const override
Engine * engine
debug_mode_e
Definition: engine_types.h:280
@ TS_WIDEBAND
Definition: engine_types.h:480
@ TS_CLEAR_WARNINGS
Definition: engine_types.h:475
@ TS_SOLENOID_CATEGORY
Definition: engine_types.h:484
@ TS_LUA_OUTPUT_CATEGORY
Definition: engine_types.h:491
@ TS_DEBUG_MODE
Definition: engine_types.h:458
@ TS_SET_ENGINE_TYPE
Definition: engine_types.h:489
@ TS_X14
Definition: engine_types.h:478
@ TS_IGNITION_CATEGORY
Definition: engine_types.h:476
@ TS_BENCH_CATEGORY
Definition: engine_types.h:481
@ TS_SET_DEFAULT_ENGINE
Definition: engine_types.h:490
@ TS_INJECTOR_CATEGORY
Definition: engine_types.h:477
void clearWarnings(void)
void rebootNow()
Definition: rusefi.cpp:150
void setWidebandOffset(uint8_t index)
running("running", SensorCategory.SENSOR_INPUTS, FieldType.INT, 844, 1.0, -1.0, -1.0, "")
void setEngineType(int value, bool isWriteToFlash)
Definition: settings.cpp:874
void scheduleStopEngine()
Definition: settings.cpp:586

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:

◆ fanBenchExt()

static void fanBenchExt ( float  onTimeMs)
static

Definition at line 249 of file bench_test.cpp.

249  {
250  pinbench(onTimeMs, 100.0, 1, &enginePins.fanRelay);
251 }
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 530 of file bench_test.cpp.

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

◆ fuelPumpBenchExt()

static void fuelPumpBenchExt ( float  durationMs)
static

Definition at line 272 of file bench_test.cpp.

272  {
273  pinbench(durationMs, 100.0, 1,
275 }
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 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:501
@ BENCH_FAN_RELAY
Definition: engine_types.h:499
@ BENCH_CANCEL
Definition: engine_types.h:510
@ BENCH_VVT0_VALVE
Definition: engine_types.h:511
@ BENCH_AUXOUT4
Definition: engine_types.h:519
@ BENCH_AUXOUT2
Definition: engine_types.h:517
@ BENCH_MAIN_RELAY
Definition: engine_types.h:495
@ BENCH_AUXOUT7
Definition: engine_types.h:522
@ HD_ACR2
Definition: engine_types.h:524
@ BENCH_IDLE_VALVE
Definition: engine_types.h:503
@ HD_ACR
Definition: engine_types.h:523
@ BENCH_AUXOUT3
Definition: engine_types.h:518
@ BENCH_CHECK_ENGINE_LIGHT
Definition: engine_types.h:502
@ BENCH_VVT3_VALVE
Definition: engine_types.h:514
@ BENCH_AUXOUT5
Definition: engine_types.h:520
@ BENCH_AUXOUT1
Definition: engine_types.h:516
@ BENCH_VVT1_VALVE
Definition: engine_types.h:512
@ BENCH_AUXOUT0
Definition: engine_types.h:515
@ BENCH_FAN_RELAY_2
Definition: engine_types.h:500
@ BENCH_HPFP_VALVE
Definition: engine_types.h:504
@ BENCH_FUEL_PUMP
Definition: engine_types.h:496
@ BENCH_AUXOUT6
Definition: engine_types.h:521
@ BENCH_STARTER_ENABLE_RELAY
Definition: engine_types.h:497
@ BENCH_VVT2_VALVE
Definition: engine_types.h:513
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 435 of file bench_test.cpp.

435  {
436 // todo: define ts_14_command magic constants and use those in tunerstudio.template.ini file!
437  switch (index) {
438  case TS_GRAB_TPS_CLOSED:
439  grabTPSIsClosed();
440  return;
441  case TS_GRAB_TPS_WOT:
443  return;
444  // case 4: tps2_closed
445  // case 5: tps2_wot
446  case TS_GRAB_PEDAL_UP:
447  grabPedalIsUp();
448  return;
449  case TS_GRAB_PEDAL_WOT:
451  return;
452  case TS_RESET_TLE8888:
453  #if (BOARD_TLE8888_COUNT > 0)
455  #endif
456  return;
457  case TS_RESET_MC33810:
458  #if EFI_PROD_CODE && (BOARD_MC33810_COUNT > 0)
460  #endif
461  return;
462  case TS_WRITE_FLASH:
463  // cmd_write_config
464  #if EFI_CONFIGURATION_STORAGE
465  writeToFlashNow();
466  #endif /* EFI_CONFIGURATION_STORAGE */
467  return;
469  #if EFI_EMULATE_POSITION_SENSORS == TRUE
471  #endif /* EFI_EMULATE_POSITION_SENSORS == TRUE */
472  return;
474  #if EFI_EMULATE_POSITION_SENSORS == TRUE
476  #endif /* EFI_EMULATE_POSITION_SENSORS == TRUE */
477  return;
479  #if EFI_EMULATE_POSITION_SENSORS == TRUE
481  #endif /* EFI_EMULATE_POSITION_SENSORS == TRUE */
482  return;
483  case TS_ETB_RESET:
484  #if EFI_ELECTRONIC_THROTTLE_BODY == TRUE
485  #if EFI_PROD_CODE
486  etbPidReset();
487  #endif
488  #endif /* EFI_ELECTRONIC_THROTTLE_BODY == TRUE */
489  return;
490  case TS_ETB_AUTOCAL_0:
491  #if EFI_ELECTRONIC_THROTTLE_BODY == TRUE
492  etbAutocal(0);
493  #endif /* EFI_ELECTRONIC_THROTTLE_BODY == TRUE */
494  return;
495  case TS_ETB_AUTOCAL_1:
496  #if EFI_ELECTRONIC_THROTTLE_BODY == TRUE
497  etbAutocal(1);
498  #endif /* EFI_ELECTRONIC_THROTTLE_BODY == TRUE */
499  return;
501  #if EFI_ELECTRONIC_THROTTLE_BODY == TRUE
502  engine->etbAutoTune = true;
503  #endif /* EFI_ELECTRONIC_THROTTLE_BODY == TRUE */
504  return;
506  #if EFI_ELECTRONIC_THROTTLE_BODY == TRUE
507  engine->etbAutoTune = false;
508  #if EFI_TUNER_STUDIO
510  #endif // EFI_TUNER_STUDIO
511  #endif /* EFI_ELECTRONIC_THROTTLE_BODY == TRUE */
512  return;
513  case TS_WIDEBAND_UPDATE:
514  widebandUpdatePending = true;
515  benchSemaphore.signal();
516  return;
518  #if EFI_PROD_CODE && EFI_CONFIGURATION_STORAGE
519  extern bool burnWithoutFlash;
520  burnWithoutFlash = true;
521  #endif /* EFI_PROD_CODE && EFI_CONFIGURATION_STORAGE */
522  return;
523  default:
524  criticalError("Unexpected bench x14 %d", index);
525  }
526 }
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:435
@ TS_TRIGGER_STIMULATOR_ENABLE
Definition: engine_types.h:446
@ TS_BURN_WITHOUT_FLASH
Definition: engine_types.h:454
@ TS_ETB_STOP_AUTOTUNE
Definition: engine_types.h:449
@ TS_WRITE_FLASH
Definition: engine_types.h:443
@ TS_GRAB_PEDAL_UP
Definition: engine_types.h:439
@ TS_GRAB_TPS_WOT
Definition: engine_types.h:436
@ TS_ETB_AUTOCAL_0
Definition: engine_types.h:447
@ TS_RESET_TLE8888
Definition: engine_types.h:441
@ TS_ETB_AUTOCAL_1
Definition: engine_types.h:450
@ TS_TRIGGER_STIMULATOR_DISABLE
Definition: engine_types.h:448
@ TS_ETB_RESET
Definition: engine_types.h:444
@ TS_RESET_MC33810
Definition: engine_types.h:453
@ TS_ETB_START_AUTOTUNE
Definition: engine_types.h:445
@ TS_GRAB_PEDAL_WOT
Definition: engine_types.h:440
@ TS_EXTERNAL_TRIGGER_STIMULATOR_ENABLE
Definition: engine_types.h:452
@ TS_WIDEBAND_UPDATE
Definition: engine_types.h:451
void writeToFlashNow()
Definition: flash_main.cpp:135
bool burnWithoutFlash
Definition: flash_main.cpp:133
void mc33810_req_init()
Definition: mc33810.cpp:812
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 332 of file bench_test.cpp.

332  {
334  pinbench(BENCH_AC_RELAY_DURATION, 100.0, 1, pin);
335 }
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 285 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 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 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: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 }

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

Definition at line 245 of file bench_test.cpp.

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

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

281  {
282  pinbench(BENCH_MAIN_RELAY_DURATION, 100.0, 1, &enginePins.mainRelay, true);
283 }
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 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:

◆ 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
Schedule an action to be executed in the future.
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 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:

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

294  {
295 #if EFI_VVT_PID
296  pinbench(BENCH_VVT_DURATION, 100.0, 1, getVvtOutputPin(vvtIndex));
297 #endif // EFI_VVT_PID
298 }
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 325 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.