rusEFI
The most advanced open source ECU
bench_test.cpp
Go to the documentation of this file.
1 /**
2  * @file bench_test.cpp
3  * @brief Utility methods related to bench testing.
4  *
5  *
6  * @date Sep 8, 2013
7  * @author Andrey Belomutskiy, (c) 2012-2020
8  *
9  * This file is part of rusEfi - see http://rusefi.com
10  *
11  * rusEfi is free software; you can redistribute it and/or modify it under the terms of
12  * the GNU General Public License as published by the Free Software Foundation; either
13  * version 3 of the License, or (at your option) any later version.
14  *
15  * rusEfi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
16  * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along with this program.
20  * If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #include "pch.h"
24 
25 static bool isRunningBench = false;
26 static OutputPin *outputOnTheBenchTest = nullptr;
27 
29  return isRunningBench;
30 }
31 
33  return outputOnTheBenchTest;
34 }
35 
36 #if !EFI_UNIT_TEST
37 
38 #include "flash_main.h"
39 #include "bench_test.h"
40 #include "main_trigger_callback.h"
42 #include "electronic_throttle.h"
44 #include "malfunction_central.h"
45 #include "trigger_emulator_algo.h"
46 #include "vvt.h"
47 #include "microsecond_timer.h"
48 
49 #if EFI_WIDEBAND_FIRMWARE_UPDATE
50 #include "rusefi_wideband.h"
51 #endif // EFI_WIDEBAND_FIRMWARE_UPDATE
52 
53 #if EFI_PROD_CODE
54 #include "rusefi.h"
55 #include "mpu_util.h"
56 #endif /* EFI_PROD_CODE */
57 
58 #if (BOARD_TLE8888_COUNT > 0)
59 #include "gpio/tle8888.h"
60 #endif // BOARD_TLE8888_COUNT
61 
64 
65 #if EFI_SIMULATOR
66 static int savedPinToggleCounter = 0;
67 static uint32_t savedDurationsInStateMs[2] = { 0, 0 };
68 #endif // EFI_SIMULATOR
69 
70 
71 #define BENCH_MSG "bench"
72 
73 static void benchOn(OutputPin* output) {
74  output->setValue(BENCH_MSG, true, /*isForce*/ true);
75 }
76 
77 static void benchOff(OutputPin* output) {
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 }
91 
92 static void runBench(OutputPin *output, float onTimeMs, float offTimeMs, int count, bool swapOnOff) {
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->scheduler.schedule("bstart", &benchSchedStart, startTime, {(swapOnOff ? benchOff : benchOn), output});
116  engine->scheduler.schedule("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 }
135 
136 // todo: migrate to smarter getOutputOnTheBenchTest() approach?
137 static volatile bool isBenchTestPending = false;
138 static bool widebandUpdatePending = false;
139 static float globalOnTimeMs;
140 static float globalOffTimeMs;
141 static int globalCount;
142 static OutputPin* pinX;
143 static bool swapOnOff = false;
144 
145 static chibios_rt::CounterSemaphore benchSemaphore(0);
146 
147 static void pinbench(float ontimeMs, float offtimeMs, int iterations,
148  OutputPin* pinParam, bool p_swapOnOff = false)
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 }
163 
164 static void cancelBenchTest() {
165  isRunningBench = false;
166 }
167 
168 /*==========================================================================*/
169 
170 static void doRunFuelInjBench(size_t humanIndex, float onTimeMs, float offTimeMs, int count) {
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 }
178 
179 static void doRunSparkBench(size_t humanIndex, float onTime, float offTime, int count) {
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 }
186 
187 static void doRunSolenoidBench(size_t humanIndex, float onTime, float offTime, int count) {
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 }
194 
195 static void doRunBenchTestLuaOutput(size_t humanIndex, float onTimeMs, float offTimeMs, int count) {
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 }
203 
204 /**
205  * cylinder #2, 5ms ON, 1000ms OFF, repeat 3 times
206  * fuelInjBenchExt 2 5 1000 3
207  */
208 static void fuelInjBenchExt(float humanIndex, float onTimeMs, float offTimeMs, float count) {
209  doRunFuelInjBench((int)humanIndex, onTimeMs, offTimeMs, (int)count);
210 }
211 
212 /**
213  * fuelbench 5 1000 2
214  */
215 static void fuelInjBench(float onTimeMs, float offTimeMs, float count) {
216  fuelInjBenchExt(1, onTimeMs, offTimeMs, count);
217 }
218 
219 /**
220  * sparkbench2 1 5 1000 2
221  */
222 static void sparkBenchExt(float humanIndex, float onTime, float offTimeMs, float count) {
223  doRunSparkBench((int)humanIndex, onTime, offTimeMs, (int)count);
224 }
225 
226 /**
227  * sparkbench 5 400 2
228  * 5 ms ON, 400 ms OFF, two times
229  */
230 static void sparkBench(float onTime, float offTimeMs, float count) {
231  sparkBenchExt(1, onTime, offTimeMs, count);
232 }
233 
234 /**
235  * solenoid #2, 1000ms ON, 1000ms OFF, repeat 3 times
236  * tcusolbench 2 1000 1000 3
237  */
238 static void tcuSolenoidBench(float humanIndex, float onTime, float offTimeMs, float count) {
239  doRunSolenoidBench((int)humanIndex, onTime, offTimeMs, (int)count);
240 }
241 
242 /**
243  * channel #1, 5ms ON, 1000ms OFF, repeat 3 times
244  */
245 static void luaOutBench2(float humanIndex, float onTime, float offTimeMs, float count) {
246  doRunBenchTestLuaOutput((int)humanIndex, onTime, offTimeMs, (int)count);
247 }
248 
249 static void fanBenchExt(float onTimeMs) {
250  pinbench(onTimeMs, 100.0, 1, &enginePins.fanRelay);
251 }
252 
253 void fanBench() {
254  fanBenchExt(BENCH_FAN_DURATION);
255 }
256 
257 void fan2Bench() {
258  pinbench(3000.0, 100.0, 1, &enginePins.fanRelay2);
259 }
260 
261 /**
262  * we are blinking for 16 seconds so that one can click the button and walk around to see the light blinking
263  */
264 void milBench() {
265  pinbench(500.0, 500.0, 16, &enginePins.checkEnginePin);
266 }
267 
269  pinbench(BENCH_STARTER_DURATION, 100.0, 1, &enginePins.starterControl);
270 }
271 
272 static void fuelPumpBenchExt(float durationMs) {
273  pinbench(durationMs, 100.0, 1,
275 }
276 
277 void acRelayBench() {
278  pinbench(BENCH_AC_RELAY_DURATION, 100.0, 1, &enginePins.acRelay);
279 }
280 
281 static void mainRelayBench() {
282  pinbench(BENCH_MAIN_RELAY_DURATION, 100.0, 1, &enginePins.mainRelay, true);
283 }
284 
285 static void hpfpValveBench() {
288 }
289 
291  fuelPumpBenchExt(BENCH_FUEL_PUMP_DURATION);
292 }
293 
294 static void vvtValveBench(int vvtIndex) {
295 #if EFI_VVT_PID
296  pinbench(BENCH_VVT_DURATION, 100.0, 1, getVvtOutputPin(vvtIndex));
297 #endif // EFI_VVT_PID
298 }
299 
300 class BenchController : public ThreadController<UTILITY_THREAD_STACK_SIZE> {
301 public:
302  BenchController() : ThreadController("BenchTest", PRIO_BENCH_TEST) { }
303 private:
304  void ThreadTask() override {
305  while (true) {
306  benchSemaphore.wait();
307 
308  assertStackVoid("Bench", ObdCode::STACK_USAGE_MISC, EXPECTED_REMAINING_STACK);
309 
310  if (isBenchTestPending) {
311  isBenchTestPending = false;
313  }
314 
315  if (widebandUpdatePending) {
316  #if EFI_WIDEBAND_FIRMWARE_UPDATE && EFI_CAN_SUPPORT
318  #endif
319  widebandUpdatePending = false;
320  }
321  }
322  }
323 };
324 
325 static BenchController instance;
326 
327 static void auxOutBench(int index) {
328  // todo!
329 }
330 
331 #if EFI_HD_ACR
332 static void hdAcrBench(int index) {
334  pinbench(BENCH_AC_RELAY_DURATION, 100.0, 1, pin);
335 }
336 #endif // EFI_HD_ACR
337 
338 void handleBenchCategory(uint16_t index) {
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 }
423 
424 int getSavedBenchTestPinStates(uint32_t durationsInStateMs[2]) {
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 }
434 
435 static void handleCommandX14(uint16_t index) {
436 // todo: define ts_14_command magic constants and use those in tunerstudio.template.ini file!
437  switch (index) {
438  case TS_GRAB_PEDAL_UP:
439  grabPedalIsUp();
440  return;
441  case TS_GRAB_PEDAL_WOT:
443  return;
444  case TS_RESET_TLE8888:
445  #if (BOARD_TLE8888_COUNT > 0)
447  #endif
448  return;
449  case TS_RESET_MC33810:
450  #if EFI_PROD_CODE && (BOARD_MC33810_COUNT > 0)
452  #endif
453  return;
454  case TS_WRITE_FLASH:
455  // cmd_write_config
456  #if EFI_CONFIGURATION_STORAGE
457  writeToFlashNow();
458  #endif /* EFI_CONFIGURATION_STORAGE */
459  return;
461  #if EFI_EMULATE_POSITION_SENSORS == TRUE
463  #endif /* EFI_EMULATE_POSITION_SENSORS == TRUE */
464  return;
466  #if EFI_EMULATE_POSITION_SENSORS == TRUE
468  #endif /* EFI_EMULATE_POSITION_SENSORS == TRUE */
469  return;
471  #if EFI_EMULATE_POSITION_SENSORS == TRUE
473  #endif /* EFI_EMULATE_POSITION_SENSORS == TRUE */
474  return;
475 /*
476  case TS_ETB_RESET:
477  #if EFI_ELECTRONIC_THROTTLE_BODY == TRUE
478  #if EFI_PROD_CODE
479  etbPidReset();
480  #endif
481  #endif // EFI_ELECTRONIC_THROTTLE_BODY
482  return;
483 */
484  case TS_ETB_AUTOCAL_0:
485  #if EFI_ELECTRONIC_THROTTLE_BODY == TRUE
486  etbAutocal(0);
487  #endif /* EFI_ELECTRONIC_THROTTLE_BODY == TRUE */
488  return;
489  case TS_ETB_AUTOCAL_1:
490  #if EFI_ELECTRONIC_THROTTLE_BODY == TRUE
491  etbAutocal(1);
492  #endif /* EFI_ELECTRONIC_THROTTLE_BODY == TRUE */
493  return;
495  #if EFI_ELECTRONIC_THROTTLE_BODY == TRUE
496  engine->etbAutoTune = true;
497  #endif /* EFI_ELECTRONIC_THROTTLE_BODY == TRUE */
498  return;
500  #if EFI_ELECTRONIC_THROTTLE_BODY == TRUE
501  engine->etbAutoTune = false;
502  #if EFI_TUNER_STUDIO
504  #endif // EFI_TUNER_STUDIO
505  #endif /* EFI_ELECTRONIC_THROTTLE_BODY == TRUE */
506  return;
507  case TS_WIDEBAND_UPDATE:
508  widebandUpdatePending = true;
509  benchSemaphore.signal();
510  return;
512  #if EFI_PROD_CODE && EFI_CONFIGURATION_STORAGE
513  extern bool burnWithoutFlash;
514  burnWithoutFlash = true;
515  #endif /* EFI_PROD_CODE && EFI_CONFIGURATION_STORAGE */
516  return;
517  default:
518  criticalError("Unexpected bench x14 %d", index);
519  }
520 }
521 
522 extern bool rebootForPresetPending;
523 
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 }
532 
533 PUBLIC_API_WEAK void boardTsAction(uint16_t index) { }
534 
535 void executeTSCommand(uint16_t subsystem, uint16_t index) {
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 }
630 
632  // default values if configuration was not specified
635  }
636 
639  }
640 
643  }
644 }
645 
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 }
679 
680 #endif /* EFI_UNIT_TEST */
void jump_to_openblt()
void jump_to_bootloader()
static int globalCount
Definition: bench_test.cpp:141
static float globalOnTimeMs
Definition: bench_test.cpp:139
static scheduling_s benchSchedStart
Definition: bench_test.cpp:62
void executeTSCommand(uint16_t subsystem, uint16_t index)
Definition: bench_test.cpp:535
void fatalErrorForPresetApply()
Definition: bench_test.cpp:524
static void runBench(OutputPin *output, float onTimeMs, float offTimeMs, int count, bool swapOnOff)
Definition: bench_test.cpp:92
static void sparkBenchExt(float humanIndex, float onTime, float offTimeMs, float count)
Definition: bench_test.cpp:222
PUBLIC_API_WEAK void boardTsAction(uint16_t index)
Definition: bench_test.cpp:533
static volatile bool isBenchTestPending
Definition: bench_test.cpp:137
int getSavedBenchTestPinStates(uint32_t durationsInStateMs[2])
Definition: bench_test.cpp:424
void fanBench()
Definition: bench_test.cpp:253
static void benchOff(OutputPin *output)
Definition: bench_test.cpp:77
static void doRunFuelInjBench(size_t humanIndex, float onTimeMs, float offTimeMs, int count)
Definition: bench_test.cpp:170
void milBench()
Definition: bench_test.cpp:264
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 sparkBench(float onTime, float offTimeMs, float count)
Definition: bench_test.cpp:230
static void cancelBenchTest()
Definition: bench_test.cpp:164
static void fanBenchExt(float onTimeMs)
Definition: bench_test.cpp:249
static void doRunSparkBench(size_t humanIndex, float onTime, float offTime, int count)
Definition: bench_test.cpp:179
const OutputPin * getOutputOnTheBenchTest()
Definition: bench_test.cpp:32
static void pinbench(float ontimeMs, float offtimeMs, int iterations, OutputPin *pinParam, bool p_swapOnOff=false)
Definition: bench_test.cpp:147
void starterRelayBench()
Definition: bench_test.cpp:268
void initBenchTest()
Definition: bench_test.cpp:646
static bool isRunningBench
Definition: bench_test.cpp:25
static chibios_rt::CounterSemaphore benchSemaphore(0)
static void hdAcrBench(int index)
Definition: bench_test.cpp:332
static void hpfpValveBench()
Definition: bench_test.cpp:285
void onConfigurationChangeBenchTest()
Definition: bench_test.cpp:631
static float globalOffTimeMs
Definition: bench_test.cpp:140
bool isRunningBenchTest()
Definition: bench_test.cpp:28
static void mainRelayBench()
Definition: bench_test.cpp:281
static void doRunBenchTestLuaOutput(size_t humanIndex, float onTimeMs, float offTimeMs, int count)
Definition: bench_test.cpp:195
static uint32_t savedDurationsInStateMs[2]
Definition: bench_test.cpp:67
static void auxOutBench(int index)
Definition: bench_test.cpp:327
static OutputPin * outputOnTheBenchTest
Definition: bench_test.cpp:26
bool rebootForPresetPending
static void luaOutBench2(float humanIndex, float onTime, float offTimeMs, float count)
Definition: bench_test.cpp:245
void fan2Bench()
Definition: bench_test.cpp:257
static bool widebandUpdatePending
Definition: bench_test.cpp:138
static void fuelInjBench(float onTimeMs, float offTimeMs, float count)
Definition: bench_test.cpp:215
void fuelPumpBench()
Definition: bench_test.cpp:290
static bool swapOnOff
Definition: bench_test.cpp:143
static void fuelInjBenchExt(float humanIndex, float onTimeMs, float offTimeMs, float count)
Definition: bench_test.cpp:208
void acRelayBench()
Definition: bench_test.cpp:277
void handleBenchCategory(uint16_t index)
Definition: bench_test.cpp:338
static OutputPin * pinX
Definition: bench_test.cpp:142
static int savedPinToggleCounter
Definition: bench_test.cpp:66
static scheduling_s benchSchedEnd
Definition: bench_test.cpp:63
static void vvtValveBench(int vvtIndex)
Definition: bench_test.cpp:294
static void tcuSolenoidBench(float humanIndex, float onTime, float offTimeMs, float count)
Definition: bench_test.cpp:238
static void benchOn(OutputPin *output)
Definition: bench_test.cpp:73
static BenchController instance
Definition: bench_test.cpp:325
static void fuelPumpBenchExt(float durationMs)
Definition: bench_test.cpp:272
Utility methods related to bench testing.
bool etbAutoTune
Definition: engine.h:265
SingleTimerExecutor scheduler
Definition: engine.h:242
RpmCalculator rpmCalculator
Definition: engine.h:274
TunerStudioOutputChannels outputChannels
Definition: engine.h:101
RegisteredOutputPin harleyAcr2
Definition: efi_gpio.h:94
RegisteredNamedOutputPin harleyAcr
Definition: efi_gpio.h:93
RegisteredOutputPin mainRelay
Definition: efi_gpio.h:76
OutputPin tcuSolenoids[TCU_SOLENOID_COUNT]
Definition: efi_gpio.h:130
RegisteredOutputPin fanRelay
Definition: efi_gpio.h:86
RegisteredOutputPin starterControl
Definition: efi_gpio.h:82
OutputPin luaOutputPins[LUA_PWM_COUNT]
Definition: efi_gpio.h:98
RegisteredOutputPin fanRelay2
Definition: efi_gpio.h:87
InjectorOutputPin injectors[MAX_CYLINDER_COUNT]
Definition: efi_gpio.h:125
RegisteredOutputPin fuelPumpRelay
Definition: efi_gpio.h:91
RegisteredOutputPin acRelay
Definition: efi_gpio.h:90
IgnitionOutputPin coils[MAX_CYLINDER_COUNT]
Definition: efi_gpio.h:127
RegisteredOutputPin checkEnginePin
Definition: efi_gpio.h:116
RegisteredNamedOutputPin hpfpValve
Definition: efi_gpio.h:80
Single output pin reference and state.
Definition: efi_output.h:50
brain_pin_diag_e getDiag() const
Definition: efi_gpio.cpp:663
uint32_t durationsInStateMs[2]
Definition: efi_output.h:82
void setValue(const char *msg, int logicValue, bool isForce=false)
Definition: efi_gpio.cpp:588
int pinToggleCounter
Definition: efi_output.h:77
brain_pin_e brainPin
Definition: efi_output.h:87
bool isStopped() const override
void schedule(const char *msg, scheduling_s *scheduling, efitick_t timeNt, action_s action) override
Schedule an action to be executed in the future.
A base class for a controller that requires its own thread.
virtual void ThreadTask()=0
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)
EnginePins enginePins
Definition: efi_gpio.cpp:24
efitick_t getTimeNowNt()
Definition: efitime.cpp:19
void etbAutocal(size_t throttleIndex)
Engine * engine
debug_mode_e
Definition: engine_types.h:280
@ TS_TRIGGER_STIMULATOR_ENABLE
Definition: engine_types.h:452
@ TS_BURN_WITHOUT_FLASH
Definition: engine_types.h:460
@ TS_ETB_STOP_AUTOTUNE
Definition: engine_types.h:455
@ TS_WRITE_FLASH
Definition: engine_types.h:449
@ TS_GRAB_PEDAL_UP
Definition: engine_types.h:445
@ TS_ETB_AUTOCAL_0
Definition: engine_types.h:453
@ TS_RESET_TLE8888
Definition: engine_types.h:447
@ TS_ETB_AUTOCAL_1
Definition: engine_types.h:456
@ TS_TRIGGER_STIMULATOR_DISABLE
Definition: engine_types.h:454
@ TS_RESET_MC33810
Definition: engine_types.h:459
@ TS_ETB_START_AUTOTUNE
Definition: engine_types.h:451
@ TS_GRAB_PEDAL_WOT
Definition: engine_types.h:446
@ TS_EXTERNAL_TRIGGER_STIMULATOR_ENABLE
Definition: engine_types.h:458
@ TS_WIDEBAND_UPDATE
Definition: engine_types.h:457
@ 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
@ 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 firmwareError(ObdCode code, const char *fmt,...)
void writeToFlashNow()
Definition: flash_main.cpp:162
bool burnWithoutFlash
Definition: flash_main.cpp:160
void startIdleBench(void)
UNUSED(samplingTimeSeconds)
Main logic header.
void clearWarnings(void)
This data structure holds current malfunction codes.
void mc33810_req_init()
Definition: mc33810.cpp:812
@ STACK_USAGE_MISC
@ OBD_PCM_Processor_Fault
@ CUSTOM_ERR_BENCH_PARAM
engine_configuration_s * engineConfiguration
void pinDiag2string(char *buffer, size_t size, brain_pin_diag_e pin_diag)
const char * hwPortname(brain_pin_e brainPin)
void rebootNow()
Definition: rusefi.cpp:150
brain_pin_diag_e
Definition: rusefi_enums.h:43
void setWidebandOffset(uint8_t index)
void updateWidebandFirmware()
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
brain_pin_e pin
Definition: stm32_adc.cpp:15
void tle8888_req_init()
Definition: tle8888.cpp:1272
void grabPedalIsUp()
Definition: tps.cpp:21
void grabPedalIsWideOpen()
Definition: tps.cpp:30
void disableTriggerStimulator()
void enableExternalTriggerStimulator()
void enableTriggerStimulator(bool incGlobalConfiguration)
OutputPin * getVvtOutputPin(int index)
Definition: vvt.cpp:145