bench test cancellation

This commit is contained in:
Matthew Kennedy 2023-08-03 20:18:20 -04:00 committed by Andrey
parent 1d6410c420
commit 1ee41382c7
2 changed files with 9 additions and 2 deletions

View File

@ -504,4 +504,5 @@ typedef enum {
BENCH_GPPWM3_VALVE,
BENCH_GPPWM4_VALVE,
BENCH_SECOND_IDLE_VALVE,
BENCH_CANCEL,
} bench_mode_e;

View File

@ -34,7 +34,6 @@ bool isRunningBenchTest() {
#include "flash_main.h"
#include "bench_test.h"
#include "main_trigger_callback.h"
#include "idle_thread.h"
#include "periodic_thread_controller.h"
#include "electronic_throttle.h"
#include "electronic_throttle_impl.h"
@ -97,7 +96,7 @@ static void runBench(OutputPin *output, float startDelayMs, float onTimeMs, floa
isRunningBench = true;
for (int i = 0; i < count; i++) {
for (int i = 0; isRunningBench && i < count; i++) {
engine->outputChannels.testBenchIter = i;
efitick_t nowNt = getTimeNowNt();
// start in a short time so the scheduler can precisely schedule the start event
@ -141,6 +140,10 @@ static void pinbench(float startdelay, float p_ontimeMs, float p_offtimeMs, int
benchSemaphore.signal();
}
static void cancelBenchTest() {
isRunningBench = false;
}
/*==========================================================================*/
static void doRunFuelInjBench(size_t humanIndex, float delay, float onTimeMs, float offTimeMs, int count) {
@ -331,6 +334,9 @@ static void handleBenchCategory(uint16_t index) {
case BENCH_FAN_RELAY_2:
fan2Bench();
return;
case BENCH_CANCEL:
cancelBenchTest();
return;
default:
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Unexpected bench function %d", index);
}