basic hw in the loop - pwm self validation #2028
This commit is contained in:
parent
1b657bba2e
commit
aaef77fd8a
|
@ -0,0 +1,43 @@
|
||||||
|
package com.rusefi;
|
||||||
|
|
||||||
|
import com.rusefi.autodetect.PortDetector;
|
||||||
|
import com.rusefi.config.generated.Fields;
|
||||||
|
import com.rusefi.core.EngineState;
|
||||||
|
import com.rusefi.io.LinkManager;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this class helps us to connect to real ECU once per JVM invocation
|
||||||
|
*/
|
||||||
|
public class ControllerConnectorState {
|
||||||
|
public volatile static String firmwareVersion;
|
||||||
|
private static LinkManager linkManager;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public synchronized static LinkManager getLinkManager() {
|
||||||
|
if (linkManager != null)
|
||||||
|
return linkManager;
|
||||||
|
|
||||||
|
LinkManager linkManager = new LinkManager().setCompositeLogicEnabled(false);
|
||||||
|
linkManager.getEngineState().registerStringValueAction(Fields.PROTOCOL_VERSION_TAG, new EngineState.ValueCallback<String>() {
|
||||||
|
@Override
|
||||||
|
public void onUpdate(String firmwareVersion1) {
|
||||||
|
firmwareVersion = firmwareVersion1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* with real hardware we have noise on all analog inputs which gives us random sensor data, we cannot really
|
||||||
|
* test exact numbers yet
|
||||||
|
*/
|
||||||
|
TestingUtils.isRealHardware = true;
|
||||||
|
FileLog.MAIN.start();
|
||||||
|
String port = System.getProperty("ecu.port");
|
||||||
|
if (port == null)
|
||||||
|
port = PortDetector.autoDetectPort(null);
|
||||||
|
|
||||||
|
IoUtil.realHardwareConnect(linkManager, port);
|
||||||
|
ControllerConnectorState.linkManager = linkManager;
|
||||||
|
return linkManager;
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,7 +6,6 @@ import com.rusefi.io.CommandQueue;
|
||||||
import com.rusefi.io.LinkManager;
|
import com.rusefi.io.LinkManager;
|
||||||
|
|
||||||
import static com.rusefi.IoUtil.*;
|
import static com.rusefi.IoUtil.*;
|
||||||
import static com.rusefi.RealHwTest.startRealHardwareTest;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this command utility confirms that rusEFI hardware stays alive for long periods of time
|
* this command utility confirms that rusEFI hardware stays alive for long periods of time
|
||||||
|
@ -16,21 +15,14 @@ public class EnduranceTestUtility {
|
||||||
private static final int DEFAULT_COUNT = 2000;
|
private static final int DEFAULT_COUNT = 2000;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
LinkManager linkManager = new LinkManager();
|
|
||||||
CommandQueue commandQueue = linkManager.getCommandQueue();
|
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
int count = parseCount(args);
|
int count = parseCount(args);
|
||||||
|
FileLog.MAIN.logLine("Running " + count + " cycles");
|
||||||
try {
|
try {
|
||||||
String port = startRealHardwareTest(args);
|
|
||||||
|
|
||||||
if (port == null) {
|
LinkManager linkManager = ControllerConnectorState.getLinkManager();
|
||||||
System.out.println("EnduranceTest [SERIAL] [COUNT]");
|
CommandQueue commandQueue = linkManager.getCommandQueue();
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FileLog.MAIN.logLine("Running " + count + " cycles");
|
|
||||||
|
|
||||||
IoUtil.realHardwareConnect(linkManager, port);
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
BaseTest.currentEngineType = Fields.ET_FORD_ASPIRE;
|
BaseTest.currentEngineType = Fields.ET_FORD_ASPIRE;
|
||||||
sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 3, BaseTest.COMPLEX_COMMAND_RETRY, Timeouts.SET_ENGINE_TIMEOUT, commandQueue);
|
sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 3, BaseTest.COMPLEX_COMMAND_RETRY, Timeouts.SET_ENGINE_TIMEOUT, commandQueue);
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
package com.rusefi;
|
package com.rusefi;
|
||||||
|
|
||||||
import com.devexperts.logging.Logging;
|
import com.devexperts.logging.Logging;
|
||||||
import com.rusefi.autodetect.PortDetector;
|
|
||||||
import com.rusefi.config.generated.Fields;
|
|
||||||
import com.rusefi.core.EngineState;
|
|
||||||
import com.rusefi.io.LinkManager;
|
import com.rusefi.io.LinkManager;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
@ -27,7 +23,6 @@ import static com.rusefi.Timeouts.SECOND;
|
||||||
public class RealHwTest {
|
public class RealHwTest {
|
||||||
private static final Logging log = getLogging(RealHwTest.class);
|
private static final Logging log = getLogging(RealHwTest.class);
|
||||||
private static final int STARTUP_SLEEP = 20;
|
private static final int STARTUP_SLEEP = 20;
|
||||||
private volatile static String firmwareVersion;
|
|
||||||
|
|
||||||
public static void main(String[] args) throws InterruptedException {
|
public static void main(String[] args) throws InterruptedException {
|
||||||
log.info("Sleeping " + STARTUP_SLEEP + " seconds to give OS time to connect VCP driver");
|
log.info("Sleeping " + STARTUP_SLEEP + " seconds to give OS time to connect VCP driver");
|
||||||
|
@ -46,21 +41,16 @@ public class RealHwTest {
|
||||||
* @return true if test is a SUCCESS, false if a FAILURE
|
* @return true if test is a SUCCESS, false if a FAILURE
|
||||||
*/
|
*/
|
||||||
public static boolean runHardwareTest(String[] args) {
|
public static boolean runHardwareTest(String[] args) {
|
||||||
String port = startRealHardwareTest(args);
|
return runHardwareTest();
|
||||||
if (port == null) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return runHardwareTest(port);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if test is a SUCCESS, false if a FAILURE
|
* @return true if test is a SUCCESS, false if a FAILURE
|
||||||
*/
|
*/
|
||||||
public static boolean runHardwareTest(String port) {
|
public static boolean runHardwareTest() {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
runRealHardwareTest(port);
|
runRealHardwareTest(ControllerConnectorState.getLinkManager());
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
PrintWriter pw = new PrintWriter(sw);
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
|
@ -74,38 +64,10 @@ public class RealHwTest {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static String startRealHardwareTest(@NotNull String[] args) {
|
private static void runRealHardwareTest(LinkManager linkManager) {
|
||||||
/**
|
|
||||||
* with real hardware we have noise on all analog inputs which gives us random sensor data, we cannot really
|
|
||||||
* test exact numbers yet
|
|
||||||
*/
|
|
||||||
TestingUtils.isRealHardware = true;
|
|
||||||
FileLog.MAIN.start();
|
|
||||||
String port;
|
|
||||||
if (args.length == 1 || args.length == 2) {
|
|
||||||
port = args[0];
|
|
||||||
} else if (args.length == 0) {
|
|
||||||
port = PortDetector.autoDetectPort(null);
|
|
||||||
} else {
|
|
||||||
System.out.println("Only one optional argument expected: port number");
|
|
||||||
port = null;
|
|
||||||
}
|
|
||||||
return port;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void runRealHardwareTest(String port) {
|
|
||||||
LinkManager linkManager = new LinkManager().setCompositeLogicEnabled(false);
|
|
||||||
linkManager.getEngineState().registerStringValueAction(Fields.PROTOCOL_VERSION_TAG, new EngineState.ValueCallback<String>() {
|
|
||||||
@Override
|
|
||||||
public void onUpdate(String firmwareVersion) {
|
|
||||||
RealHwTest.firmwareVersion = firmwareVersion;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
IoUtil.realHardwareConnect(linkManager, port);
|
|
||||||
// first run tests which require real hardware
|
// first run tests which require real hardware
|
||||||
new HardwareTests(linkManager.getCommandQueue()).runRealHardwareTests();
|
new HardwareTests(linkManager.getCommandQueue()).runRealHardwareTests();
|
||||||
if (firmwareVersion == null)
|
if (ControllerConnectorState.firmwareVersion == null)
|
||||||
throw new IllegalStateException("firmwareVersion has not arrived");
|
throw new IllegalStateException("firmwareVersion has not arrived");
|
||||||
|
|
||||||
// now run common part of the test which should be same on real hardware and simulator
|
// now run common part of the test which should be same on real hardware and simulator
|
||||||
|
|
Loading…
Reference in New Issue