From ba62727c25c573c88392021c3a9d098990fc6327 Mon Sep 17 00:00:00 2001 From: rusefi Date: Sat, 8 Aug 2020 18:28:43 -0400 Subject: [PATCH] trigger and VSS hw integrated testing #1668 --- firmware/controllers/settings.cpp | 9 ++++++++- firmware/hw_layer/vehicle_speed.cpp | 1 - .../autotest/src/com/rusefi/AutoTest.java | 13 ------------- .../autotest/src/com/rusefi/HardwareTests.java | 14 ++++++++++++++ .../com/rusefi/functional_tests/BaseTest.java | 17 ++++++++++++++++- .../com/rusefi/autodetect/PortDetector.java | 2 +- .../rusefi/binaryprotocol/BinaryProtocol.java | 2 +- 7 files changed, 40 insertions(+), 18 deletions(-) diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index a50f0687f4..695e7b39c4 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -583,6 +583,11 @@ static void setIndividualPin(const char *pinName, brain_pin_e *targetPin, const incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE); } +// set vss_pin +static void setVssPin(const char *pinName) { + setIndividualPin(pinName, &engineConfiguration->vehicleSpeedSensorInputPin, "VSS"); +} + // set_idle_pin none static void setIdlePin(const char *pinName) { setIndividualPin(pinName, &engineConfiguration->idle.solenoidPin, "idle"); @@ -1287,6 +1292,8 @@ static void setValue(const char *paramStr, const char *valueStr) { engineConfiguration->wwaeBeta = valueF; } else if (strEqualCaseInsensitive(paramStr, "cranking_dwell")) { engineConfiguration->ignitionDwellForCrankingMs = valueF; + } else if (strEqualCaseInsensitive(paramStr, CMD_VSS_PIN)) { + setVssPin(valueStr); } else if (strEqualCaseInsensitive(paramStr, "targetvbatt")) { engineConfiguration->targetVBatt = valueF; #if EFI_RTC @@ -1347,7 +1354,7 @@ void initSettings(void) { addConsoleActionS("showpin", showPinFunction); addConsoleActionSS("set_injection_pin", setInjectionPin); addConsoleActionSS("set_ignition_pin", setIgnitionPin); - addConsoleActionSS("set_trigger_input_pin", setTriggerInputPin); + addConsoleActionSS(CMD_TRIGGER_PIN, setTriggerInputPin); addConsoleActionSS("set_trigger_simulator_pin", setTriggerSimulatorPin); addConsoleActionSS("set_egt_cs_pin", (VoidCharPtrCharPtr) setEgtCSPin); diff --git a/firmware/hw_layer/vehicle_speed.cpp b/firmware/hw_layer/vehicle_speed.cpp index 40e02ad9c2..7a81ccb08b 100644 --- a/firmware/hw_layer/vehicle_speed.cpp +++ b/firmware/hw_layer/vehicle_speed.cpp @@ -64,7 +64,6 @@ static void speedInfo(void) { engine->engineState.vssEventCounter, getVehicleSpeed()); scheduleMsg(logger, "vss diff %d", vssDiff); - } bool hasVehicleSpeedSensor() { diff --git a/java_console/autotest/src/com/rusefi/AutoTest.java b/java_console/autotest/src/com/rusefi/AutoTest.java index d61d764402..a96117caff 100644 --- a/java_console/autotest/src/com/rusefi/AutoTest.java +++ b/java_console/autotest/src/com/rusefi/AutoTest.java @@ -466,19 +466,6 @@ public class AutoTest extends BaseTest { assertWaveNull("hard limit check", chart, EngineChart.INJECTOR_1); } - private static void assertEquals(double expected, double actual) { - assertEquals("", expected, actual); - } - - private static void assertEquals(String msg, double expected, double actual) { - assertEquals(msg, expected, actual, EngineReport.RATIO); - } - - private static void assertEquals(String msg, double expected, double actual, double ratio) { - if (!isCloseEnough(expected, actual, ratio)) - throw new IllegalStateException(msg + " Expected " + expected + " but got " + actual); - } - /** * This method waits for longer then usual. */ diff --git a/java_console/autotest/src/com/rusefi/HardwareTests.java b/java_console/autotest/src/com/rusefi/HardwareTests.java index 9c8f7deae3..a87501410e 100644 --- a/java_console/autotest/src/com/rusefi/HardwareTests.java +++ b/java_console/autotest/src/com/rusefi/HardwareTests.java @@ -1,11 +1,14 @@ package com.rusefi; import com.rusefi.config.generated.Fields; +import com.rusefi.core.Sensor; +import com.rusefi.core.SensorCentral; import com.rusefi.functional_tests.BaseTest; import com.rusefi.io.CommandQueue; import static com.rusefi.IoUtil.getDisableCommand; import static com.rusefi.IoUtil.getEnableCommand; +import static com.rusefi.binaryprotocol.BinaryProtocol.sleep; import static com.rusefi.config.generated.Fields.*; public class HardwareTests extends BaseTest { @@ -23,5 +26,16 @@ public class HardwareTests extends BaseTest { sendCommand(getDisableCommand(Fields.CMD_SELF_STIMULATION)); changeRpm(1400); + // moving second trigger to another pin + sendCommand(CMD_TRIGGER_PIN + " 1 PA8"); + + assertEquals("VSS no input", 0, SensorCentral.getInstance().getValue(Sensor.VSS)); + + // attaching VSS to trigger simulator since there is a jumper on test discovery + sendCommand("set " + CMD_VSS_PIN + " pa5"); + + sleep(2 * Timeouts.SECOND); + + assertEquals("VSS with input", 3, SensorCentral.getInstance().getValue(Sensor.VSS)); } } diff --git a/java_console/autotest/src/com/rusefi/functional_tests/BaseTest.java b/java_console/autotest/src/com/rusefi/functional_tests/BaseTest.java index 4c159a3dba..7c08979ef1 100644 --- a/java_console/autotest/src/com/rusefi/functional_tests/BaseTest.java +++ b/java_console/autotest/src/com/rusefi/functional_tests/BaseTest.java @@ -5,10 +5,12 @@ import com.rusefi.IoUtil; import com.rusefi.Timeouts; import com.rusefi.config.generated.Fields; import com.rusefi.io.CommandQueue; +import com.rusefi.waves.EngineReport; import static com.devexperts.logging.Logging.getLogging; import static com.rusefi.IoUtil.getEnableCommand; import static com.rusefi.IoUtil.sleepSeconds; +import static com.rusefi.waves.EngineReport.isCloseEnough; public class BaseTest { private static final Logging log = getLogging(BaseTest.class); @@ -21,6 +23,19 @@ public class BaseTest { this.commandQueue = commandQueue; } + protected static void assertEquals(double expected, double actual) { + BaseTest.assertEquals("", expected, actual); + } + + protected static void assertEquals(String msg, double expected, double actual) { + BaseTest.assertEquals(msg, expected, actual, EngineReport.RATIO); + } + + protected static void assertEquals(String msg, double expected, double actual, double ratio) { + if (!isCloseEnough(expected, actual, ratio)) + throw new IllegalStateException(msg + " Expected " + expected + " but got " + actual); + } + protected void sendCommand(String command) { sendCommand(command, CommandQueue.DEFAULT_TIMEOUT, Timeouts.CMD_TIMEOUT); } @@ -47,7 +62,7 @@ public class BaseTest { // sendCommand(CMD_PINS); sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + type, COMPLEX_COMMAND_RETRY, Timeouts.SET_ENGINE_TIMEOUT); // TODO: document the reason for this sleep?! - sleepSeconds(1); + sleepSeconds(3); sendCommand(getEnableCommand(Fields.CMD_SELF_STIMULATION)); } } diff --git a/java_console/io/src/main/java/com/rusefi/autodetect/PortDetector.java b/java_console/io/src/main/java/com/rusefi/autodetect/PortDetector.java index d06ce4e72e..18ae98a38a 100644 --- a/java_console/io/src/main/java/com/rusefi/autodetect/PortDetector.java +++ b/java_console/io/src/main/java/com/rusefi/autodetect/PortDetector.java @@ -49,7 +49,7 @@ public class PortDetector { } catch (InterruptedException e) { throw new IllegalStateException(e); } -// FileLog.MAIN.logLine("Found " + result.get()); + log.debug("Found " + result.get() + " now stopping threads"); for (Thread thread : serialFinder) thread.interrupt(); // FileLog.MAIN.logLine("Returning " + result.get()); diff --git a/java_console/io/src/main/java/com/rusefi/binaryprotocol/BinaryProtocol.java b/java_console/io/src/main/java/com/rusefi/binaryprotocol/BinaryProtocol.java index e258aa7519..d14a8bba53 100644 --- a/java_console/io/src/main/java/com/rusefi/binaryprotocol/BinaryProtocol.java +++ b/java_console/io/src/main/java/com/rusefi/binaryprotocol/BinaryProtocol.java @@ -171,7 +171,7 @@ public class BinaryProtocol implements BinaryProtocolCommands { }; } - public static void sleep(int millis) { + public static void sleep(long millis) { try { Thread.sleep(millis); } catch (InterruptedException e) {