bench test delay parameter is not useful (#5491)

Co-authored-by: Matthew Kennedy <matthewkennedy@outlook.com>
This commit is contained in:
rusefillc 2023-08-05 14:32:24 -04:00 committed by GitHub
parent 45bafe99e6
commit 03a714055f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 55 additions and 61 deletions

View File

@ -135,7 +135,7 @@ typedef void (*VoidIntVoidPtr)(int, void*);
typedef void (*VoidFloat)(float); typedef void (*VoidFloat)(float);
typedef void (*VoidFloatFloat)(float, float); typedef void (*VoidFloatFloat)(float, float);
typedef void (*VoidFloatFloatFloat)(float, float, float); typedef void (*VoidFloatFloatFloat)(float, float, float);
typedef void (*VoidFloatFloatFloatFloatFloat)(float, float, float, float, float); typedef void (*VoidFloatFloatFloatFloat)(float, float, float, float);
typedef void (*VoidFloatFloatVoidPtr)(float, float, void*); typedef void (*VoidFloatFloatVoidPtr)(float, float, void*);
typedef void (*VoidIntInt)(int, int); typedef void (*VoidIntInt)(int, int);
typedef void (*VoidIntIntVoidPtr)(int, int, void*); typedef void (*VoidIntIntVoidPtr)(int, int, void*);

View File

@ -78,9 +78,7 @@ static void benchOff(OutputPin* output) {
output->setValue(BENCH_MSG, false); output->setValue(BENCH_MSG, false);
} }
static void runBench(OutputPin *output, float startDelayMs, float onTimeMs, float offTimeMs, static void runBench(OutputPin *output, float onTimeMs, float offTimeMs, int count) {
int count) {
int startDelayUs = MS2US(maxF(0.1, startDelayMs));
int onTimeUs = MS2US(maxF(0.1, onTimeMs)); int onTimeUs = MS2US(maxF(0.1, onTimeMs));
int offTimeUs = MS2US(maxF(0.1, offTimeMs)); int offTimeUs = MS2US(maxF(0.1, offTimeMs));
@ -92,8 +90,6 @@ static void runBench(OutputPin *output, float startDelayMs, float onTimeMs, floa
efiPrintf("Running bench: ON_TIME=%d us OFF_TIME=%d us Counter=%d", onTimeUs, offTimeUs, count); efiPrintf("Running bench: ON_TIME=%d us OFF_TIME=%d us Counter=%d", onTimeUs, offTimeUs, count);
efiPrintf("output on %s", hwPortname(output->brainPin)); efiPrintf("output on %s", hwPortname(output->brainPin));
chThdSleepMicroseconds(startDelayUs);
isRunningBench = true; isRunningBench = true;
for (int i = 0; isRunningBench && i < count; i++) { for (int i = 0; isRunningBench && i < count; i++) {
@ -121,16 +117,14 @@ static volatile bool isBenchTestPending = false;
static bool widebandUpdatePending = false; static bool widebandUpdatePending = false;
static float onTimeMs; static float onTimeMs;
static float offTimeMs; static float offTimeMs;
static float startDelayMs;
static int count; static int count;
static OutputPin* pinX; static OutputPin* pinX;
static chibios_rt::CounterSemaphore benchSemaphore(0); static chibios_rt::CounterSemaphore benchSemaphore(0);
static void pinbench(float startdelay, float p_ontimeMs, float p_offtimeMs, int iterations, static void pinbench(float p_ontimeMs, float p_offtimeMs, int iterations,
OutputPin* pinParam) OutputPin* pinParam)
{ {
startDelayMs = startdelay;
onTimeMs = p_ontimeMs; onTimeMs = p_ontimeMs;
offTimeMs = p_offtimeMs; offTimeMs = p_offtimeMs;
count = iterations; count = iterations;
@ -146,60 +140,60 @@ static void cancelBenchTest() {
/*==========================================================================*/ /*==========================================================================*/
static void doRunFuelInjBench(size_t humanIndex, float delay, float onTimeMs, float offTimeMs, int count) { static void doRunFuelInjBench(size_t humanIndex, float onTimeMs, float offTimeMs, int count) {
if (humanIndex < 1 || humanIndex > engineConfiguration->cylindersCount) { if (humanIndex < 1 || humanIndex > engineConfiguration->cylindersCount) {
efiPrintf("Invalid index: %d", humanIndex); efiPrintf("Invalid index: %d", humanIndex);
return; return;
} }
pinbench(delay, onTimeMs, offTimeMs, count, pinbench(onTimeMs, offTimeMs, count,
&enginePins.injectors[humanIndex - 1]); &enginePins.injectors[humanIndex - 1]);
} }
static void doRunSparkBench(size_t humanIndex, float delay, float onTime, float offTime, int count) { static void doRunSparkBench(size_t humanIndex, float onTime, float offTime, int count) {
if (humanIndex < 1 || humanIndex > engineConfiguration->cylindersCount) { if (humanIndex < 1 || humanIndex > engineConfiguration->cylindersCount) {
efiPrintf("Invalid index: %d", humanIndex); efiPrintf("Invalid index: %d", humanIndex);
return; return;
} }
pinbench(delay, onTime, offTime, count, &enginePins.coils[humanIndex - 1]); pinbench(onTime, offTime, count, &enginePins.coils[humanIndex - 1]);
} }
static void doRunSolenoidBench(size_t humanIndex, float delay, float onTime, float offTime, int count) { static void doRunSolenoidBench(size_t humanIndex, float onTime, float offTime, int count) {
if (humanIndex < 1 || humanIndex > TCU_SOLENOID_COUNT) { if (humanIndex < 1 || humanIndex > TCU_SOLENOID_COUNT) {
efiPrintf("Invalid index: %d", humanIndex); efiPrintf("Invalid index: %d", humanIndex);
return; return;
} }
pinbench(delay, onTime, offTime, count, &enginePins.tcuSolenoids[humanIndex - 1]); pinbench(onTime, offTime, count, &enginePins.tcuSolenoids[humanIndex - 1]);
} }
static void doRunBenchTestLuaOutput(size_t humanIndex, float delay, float onTimeMs, float offTimeMs, int count) { static void doRunBenchTestLuaOutput(size_t humanIndex, float onTimeMs, float offTimeMs, int count) {
if (humanIndex < 1 || humanIndex > LUA_PWM_COUNT) { if (humanIndex < 1 || humanIndex > LUA_PWM_COUNT) {
efiPrintf("Invalid index: %d", humanIndex); efiPrintf("Invalid index: %d", humanIndex);
return; return;
} }
pinbench(delay, onTimeMs, offTimeMs, count, pinbench(onTimeMs, offTimeMs, count,
&enginePins.luaOutputPins[humanIndex - 1]); &enginePins.luaOutputPins[humanIndex - 1]);
} }
/** /**
* delay 100, cylinder #2, 5ms ON, 1000ms OFF, repeat 3 times * cylinder #2, 5ms ON, 1000ms OFF, repeat 3 times
* fuelInjBenchExt 100 2 5 1000 3 * fuelInjBenchExt 2 5 1000 3
*/ */
static void fuelInjBenchExt(float delay, float humanIndex, float onTimeMs, float offTimeMs, float count) { static void fuelInjBenchExt(float humanIndex, float onTimeMs, float offTimeMs, float count) {
doRunFuelInjBench((int)humanIndex, delay, onTimeMs, offTimeMs, (int)count); doRunFuelInjBench((int)humanIndex, onTimeMs, offTimeMs, (int)count);
} }
/** /**
* fuelbench 5 1000 2 * fuelbench 5 1000 2
*/ */
static void fuelInjBench(float onTimeMs, float offTimeMs, float count) { static void fuelInjBench(float onTimeMs, float offTimeMs, float count) {
fuelInjBenchExt(0.0, 1, onTimeMs, offTimeMs, count); fuelInjBenchExt(1, onTimeMs, offTimeMs, count);
} }
/** /**
* sparkbench2 0 1 5 1000 2 * sparkbench2 1 5 1000 2
*/ */
static void sparkBenchExt(float delay, float humanIndex, float onTime, float offTimeMs, float count) { static void sparkBenchExt(float humanIndex, float onTime, float offTimeMs, float count) {
doRunSparkBench((int)humanIndex, delay, onTime, offTimeMs, (int)count); doRunSparkBench((int)humanIndex, onTime, offTimeMs, (int)count);
} }
/** /**
@ -207,28 +201,27 @@ static void sparkBenchExt(float delay, float humanIndex, float onTime, float off
* 5 ms ON, 400 ms OFF, two times * 5 ms ON, 400 ms OFF, two times
*/ */
static void sparkBench(float onTime, float offTimeMs, float count) { static void sparkBench(float onTime, float offTimeMs, float count) {
sparkBenchExt(0.0, 1, onTime, offTimeMs, count); sparkBenchExt(1, onTime, offTimeMs, count);
} }
/** /**
* delay 100, solenoid #2, 1000ms ON, 1000ms OFF, repeat 3 times * solenoid #2, 1000ms ON, 1000ms OFF, repeat 3 times
* tcusolbench 100 2 1000 1000 3 * tcusolbench 2 1000 1000 3
*/ */
static void tcuSolenoidBench(float delay, float humanIndex, float onTime, float offTimeMs, float count) { static void tcuSolenoidBench(float humanIndex, float onTime, float offTimeMs, float count) {
doRunSolenoidBench((int)humanIndex, delay, onTime, offTimeMs, (int)count); doRunSolenoidBench((int)humanIndex, onTime, offTimeMs, (int)count);
} }
/** /**
* delay 100, channel #1, 5ms ON, 1000ms OFF, repeat 3 times * channel #1, 5ms ON, 1000ms OFF, repeat 3 times
* fsiobench2 100 1 5 1000 3 * fsiobench2 1 5 1000 3
*/ */
static void luaOutBench2(float delay, float humanIndex, float onTime, float offTimeMs, float count) { static void luaOutBench2(float humanIndex, float onTime, float offTimeMs, float count) {
doRunBenchTestLuaOutput((int)humanIndex, delay, onTime, offTimeMs, (int)count); doRunBenchTestLuaOutput((int)humanIndex, onTime, offTimeMs, (int)count);
} }
static void fanBenchExt(float onTimeMs) { static void fanBenchExt(float onTimeMs) {
pinbench(0.0, onTimeMs, 100.0, 1.0, pinbench(onTimeMs, 100.0, 1.0, &enginePins.fanRelay);
&enginePins.fanRelay);
} }
void fanBench(void) { void fanBench(void) {
@ -236,27 +229,27 @@ void fanBench(void) {
} }
void fan2Bench(void) { void fan2Bench(void) {
pinbench(0.0, 3000.0, 100.0, 1.0, &enginePins.fanRelay2); pinbench(3000.0, 100.0, 1.0, &enginePins.fanRelay2);
} }
/** /**
* we are blinking for 16 seconds so that one can click the button and walk around to see the light blinking * we are blinking for 16 seconds so that one can click the button and walk around to see the light blinking
*/ */
void milBench(void) { void milBench(void) {
pinbench(0.0, 500.0, 500.0, 16, &enginePins.checkEnginePin); pinbench(500.0, 500.0, 16, &enginePins.checkEnginePin);
} }
void starterRelayBench(void) { void starterRelayBench(void) {
pinbench(0.0, 6000.0, 100.0, 1, &enginePins.starterControl); pinbench(6000.0, 100.0, 1, &enginePins.starterControl);
} }
static void fuelPumpBenchExt(float durationMs) { static void fuelPumpBenchExt(float durationMs) {
pinbench(/*startdelay*/0, durationMs, 100.0, 1.0, pinbench(durationMs, 100.0, 1.0,
&enginePins.fuelPumpRelay); &enginePins.fuelPumpRelay);
} }
void acRelayBench(void) { void acRelayBench(void) {
pinbench(/*startdelay*/0, 1000.0, 100.0, 1, &enginePins.acRelay); pinbench(1000.0, 100.0, 1, &enginePins.acRelay);
} }
static void mainRelayBench(void) { static void mainRelayBench(void) {
@ -265,7 +258,7 @@ static void mainRelayBench(void) {
} }
static void hpfpValveBench(void) { static void hpfpValveBench(void) {
pinbench(/*startdelay*/0, engineConfiguration->benchTestOnTime, engineConfiguration->benchTestOffTime, engineConfiguration->benchTestCount, pinbench(engineConfiguration->benchTestOnTime, engineConfiguration->benchTestOffTime, engineConfiguration->benchTestCount,
&enginePins.hpfpValve); &enginePins.hpfpValve);
} }
@ -285,7 +278,7 @@ private:
if (isBenchTestPending) { if (isBenchTestPending) {
isBenchTestPending = false; isBenchTestPending = false;
runBench(pinX, startDelayMs, onTimeMs, offTimeMs, count); runBench(pinX, onTimeMs, offTimeMs, count);
} }
if (widebandUpdatePending) { if (widebandUpdatePending) {
@ -458,28 +451,28 @@ void executeTSCommand(uint16_t subsystem, uint16_t index) {
case TS_IGNITION_CATEGORY: case TS_IGNITION_CATEGORY:
if (!running) { if (!running) {
doRunSparkBench(index, 300.0, engineConfiguration->benchTestOnTime, doRunSparkBench(index, engineConfiguration->benchTestOnTime,
engineConfiguration->benchTestOffTime, engineConfiguration->benchTestCount); engineConfiguration->benchTestOffTime, engineConfiguration->benchTestCount);
} }
break; break;
case TS_INJECTOR_CATEGORY: case TS_INJECTOR_CATEGORY:
if (!running) { if (!running) {
doRunFuelInjBench(index, 300.0 , engineConfiguration->benchTestOnTime, doRunFuelInjBench(index, engineConfiguration->benchTestOnTime,
engineConfiguration->benchTestOffTime, engineConfiguration->benchTestCount); engineConfiguration->benchTestOffTime, engineConfiguration->benchTestCount);
} }
break; break;
case TS_SOLENOID_CATEGORY: case TS_SOLENOID_CATEGORY:
if (!running) { if (!running) {
doRunSolenoidBench(index, 300.0, 1000.0, doRunSolenoidBench(index, 1000.0,
1000.0, engineConfiguration->benchTestCount); 1000.0, engineConfiguration->benchTestCount);
} }
break; break;
case TS_LUA_OUTPUT_CATEGORY: case TS_LUA_OUTPUT_CATEGORY:
if (!running) { if (!running) {
doRunBenchTestLuaOutput(index, 300.0, 4.0, doRunBenchTestLuaOutput(index, 4.0,
engineConfiguration->benchTestOffTime, engineConfiguration->benchTestCount); engineConfiguration->benchTestOffTime, engineConfiguration->benchTestCount);
} }
break; break;
@ -554,12 +547,12 @@ void initBenchTest() {
addConsoleActionF("fuelpumpbench2", fuelPumpBenchExt); addConsoleActionF("fuelpumpbench2", fuelPumpBenchExt);
addConsoleActionFFF(CMD_FUEL_BENCH, fuelInjBench); addConsoleActionFFF(CMD_FUEL_BENCH, fuelInjBench);
addConsoleActionFFFFF("fuelbench2", fuelInjBenchExt); addConsoleActionFFFF("fuelbench2", fuelInjBenchExt);
addConsoleActionFFF(CMD_SPARK_BENCH, sparkBench); addConsoleActionFFF(CMD_SPARK_BENCH, sparkBench);
addConsoleActionFFFFF("sparkbench2", sparkBenchExt); addConsoleActionFFFF("sparkbench2", sparkBenchExt);
addConsoleActionFFFFF("tcusolbench", tcuSolenoidBench); addConsoleActionFFFF("tcusolbench", tcuSolenoidBench);
addConsoleAction(CMD_AC_RELAY_BENCH, acRelayBench); addConsoleAction(CMD_AC_RELAY_BENCH, acRelayBench);
@ -578,7 +571,7 @@ void initBenchTest() {
addConsoleAction(CMD_MIL_BENCH, milBench); addConsoleAction(CMD_MIL_BENCH, milBench);
addConsoleAction(CMD_HPFP_BENCH, hpfpValveBench); addConsoleAction(CMD_HPFP_BENCH, hpfpValveBench);
addConsoleActionFFFFF("luabench2", luaOutBench2); addConsoleActionFFFF("luabench2", luaOutBench2);
instance.start(); instance.start();
onConfigurationChangeBenchTest(); onConfigurationChangeBenchTest();
} }

View File

@ -136,8 +136,8 @@ void addConsoleActionFFF(const char *token, VoidFloatFloatFloat callback) {
doAddAction(token, FLOAT_FLOAT_FLOAT_PARAMETER, (Void) callback, NULL); doAddAction(token, FLOAT_FLOAT_FLOAT_PARAMETER, (Void) callback, NULL);
} }
void addConsoleActionFFFFF(const char *token, VoidFloatFloatFloatFloatFloat callback) { void addConsoleActionFFFF(const char *token, VoidFloatFloatFloatFloat callback) {
doAddAction(token, FLOAT_FLOAT_FLOAT_FLOAT_FLOAT_PARAMETER, (Void) callback, NULL); doAddAction(token, FLOAT_FLOAT_FLOAT_FLOAT_PARAMETER, (Void) callback, NULL);
} }
void addConsoleActionFFP(const char *token, VoidFloatFloatVoidPtr callback, void *param) { void addConsoleActionFFP(const char *token, VoidFloatFloatVoidPtr callback, void *param) {
@ -165,8 +165,9 @@ static int getParameterCount(action_type_e parameterType) {
case STRING3_PARAMETER: case STRING3_PARAMETER:
case FLOAT_FLOAT_FLOAT_PARAMETER: case FLOAT_FLOAT_FLOAT_PARAMETER:
return 3; return 3;
case FLOAT_FLOAT_FLOAT_FLOAT_PARAMETER:
return 4;
case STRING5_PARAMETER: case STRING5_PARAMETER:
case FLOAT_FLOAT_FLOAT_FLOAT_FLOAT_PARAMETER:
return 5; return 5;
default: default:
return -1; return -1;
@ -400,18 +401,18 @@ int handleActionWithParameter(TokenCallback *current, char *argv[], int argc) {
(*callbackS)(value[0], value[1], value[2]); (*callbackS)(value[0], value[1], value[2]);
return 0; return 0;
} }
case FLOAT_FLOAT_FLOAT_FLOAT_FLOAT_PARAMETER: case FLOAT_FLOAT_FLOAT_FLOAT_PARAMETER:
{ {
float value[5]; float value[4];
for (int i = 0; i < 5; i++) { for (int i = 0; i < 4; i++) {
value[i] = atoff(argv[i]); value[i] = atoff(argv[i]);
if (cisnan(value[i])) { if (cisnan(value[i])) {
efiPrintf("invalid float [%s]", argv[i]); efiPrintf("invalid float [%s]", argv[i]);
return -1; return -1;
} }
} }
VoidFloatFloatFloatFloatFloat callbackS = (VoidFloatFloatFloatFloatFloat) current->callback; VoidFloatFloatFloatFloat callbackS = (VoidFloatFloatFloatFloat) current->callback;
(*callbackS)(value[0], value[1], value[2], value[3], value[4]); (*callbackS)(value[0], value[1], value[2], value[3]);
return 0; return 0;
} }
case INT_FLOAT_PARAMETER: case INT_FLOAT_PARAMETER:

View File

@ -28,7 +28,7 @@ typedef enum {
TWO_INTS_PARAMETER_P, TWO_INTS_PARAMETER_P,
FLOAT_FLOAT_PARAMETER, FLOAT_FLOAT_PARAMETER,
FLOAT_FLOAT_FLOAT_PARAMETER, FLOAT_FLOAT_FLOAT_PARAMETER,
FLOAT_FLOAT_FLOAT_FLOAT_FLOAT_PARAMETER, FLOAT_FLOAT_FLOAT_FLOAT_PARAMETER,
FLOAT_FLOAT_PARAMETER_P, FLOAT_FLOAT_PARAMETER_P,
INT_FLOAT_PARAMETER, INT_FLOAT_PARAMETER,
} action_type_e; } action_type_e;
@ -71,7 +71,7 @@ void addConsoleActionNANF(const char *token, VoidFloat callback);
void addConsoleActionFF(const char *token, VoidFloatFloat callback); void addConsoleActionFF(const char *token, VoidFloatFloat callback);
void addConsoleActionFFF(const char *token, VoidFloatFloatFloat callback); void addConsoleActionFFF(const char *token, VoidFloatFloatFloat callback);
void addConsoleActionFFFFF(const char *token, VoidFloatFloatFloatFloatFloat callback); void addConsoleActionFFFF(const char *token, VoidFloatFloatFloatFloat callback);
void addConsoleActionFFP(const char *token, VoidFloatFloatVoidPtr callback, void *param); void addConsoleActionFFP(const char *token, VoidFloatFloatVoidPtr callback, void *param);
void addConsoleActionS(const char *token, VoidCharPtr callback); void addConsoleActionS(const char *token, VoidCharPtr callback);