auto-sync

This commit is contained in:
rusEfi 2015-02-23 19:07:48 -06:00
parent 9086cca726
commit 7b1a55ba93
5 changed files with 22 additions and 12 deletions

View File

@ -20,6 +20,8 @@ void setMazda626EngineConfiguration(engine_configuration_s *engineConfiguration)
board_configuration_s *boardConfiguration = &engineConfiguration->bc;
engineConfiguration->trigger.type = TT_MAZDA_DOHC_1_4;
engineConfiguration->digitalChartSize = 150;
boardConfiguration->analogChartMode = AC_TRIGGER;
engineConfiguration->analogChartFrequency = 2;

View File

@ -35,6 +35,7 @@ static int consoleActionCount = 0;
static TokenCallback consoleActions[CONSOLE_MAX_ACTIONS];
#define SECURE_LINE_PREFIX "sec!"
#define SECURE_LINE_PREFIX_LENGTH 4
void resetConsoleActions(void) {
consoleActionCount = 0;
@ -400,11 +401,11 @@ void initConsoleLogic(Logging *sharedLogger) {
char *validateSecureLine(char *line) {
if (line == NULL)
return NULL;
if (strncmp(SECURE_LINE_PREFIX, line, 4) == 0) {
if (strncmp(SECURE_LINE_PREFIX, line, SECURE_LINE_PREFIX_LENGTH) == 0) {
// COM protocol looses bytes, this is a super-naive error detection
// print("Got secure mode request header [%s]\r\n", line);
line += 4;
line += SECURE_LINE_PREFIX_LENGTH;
// print("Got secure mode request command [%s]\r\n", line);
char *divider = line;

View File

@ -21,6 +21,7 @@ public class AutoTest {
static int currentEngineType;
static void mainTestBody() {
sendCommand("fl 1"); // just in case it was disabled
testCitroenBerlingo();
testMazda626();
test2003DodgeNeon();
@ -39,8 +40,8 @@ public class AutoTest {
private static void setEngineType(int type) {
currentEngineType = type;
sendCommand("set_engine_type " + type, 10000);
sleep(5);
sendCommand("set_engine_type " + type, 10000, 600);
sleep(10);
sendCommand("enable self_stimulation");
}

View File

@ -7,14 +7,10 @@ import com.rusefi.io.CommandQueue;
import com.rusefi.io.InvocationConfirmationListener;
import com.rusefi.io.LinkManager;
import com.rusefi.io.tcp.TcpConnector;
import com.rusefi.waves.WaveChart;
import com.rusefi.waves.WaveChartParser;
import com.rusefi.waves.WaveReport;
import jssc.SerialPortList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import static com.rusefi.waves.WaveReport.isCloseEnough;
@ -31,22 +27,26 @@ public class IoUtil {
* @throws IllegalStateException if command was not confirmed
*/
static void sendCommand(String command) {
sendCommand(command, CommandQueue.DEFAULT_TIMEOUT);
sendCommand(command, CommandQueue.DEFAULT_TIMEOUT, CMD_TIMEOUT);
}
static void sendCommand(String command, int timeoutMs) {
static void sendCommand(String command, int retryTimeoutMs, int totalTimeoutSeconds) {
final CountDownLatch responseLatch = new CountDownLatch(1);
long time = System.currentTimeMillis();
if (LinkManager.hasError())
throw new IllegalStateException("IO error");
FileLog.MAIN.logLine("Sending command [" + command + "]");
CommandQueue.getInstance().write(command, timeoutMs, new InvocationConfirmationListener() {
final long begin = System.currentTimeMillis();
CommandQueue.getInstance().write(command, retryTimeoutMs, new InvocationConfirmationListener() {
@Override
public void onCommandConfirmation() {
responseLatch.countDown();
FileLog.MAIN.logLine("Got confirmation in " + (System.currentTimeMillis() - begin) + "ms");
}
});
wait(responseLatch, CMD_TIMEOUT);
wait(responseLatch, totalTimeoutSeconds);
if (responseLatch.getCount() > 0)
FileLog.MAIN.logLine("No confirmation in " + retryTimeoutMs);
if (LinkManager.hasError())
throw new IllegalStateException("IO error");
FileLog.MAIN.logLine("Command [" + command + "] executed in " + (System.currentTimeMillis() - time));
@ -139,6 +139,7 @@ public class IoUtil {
@SuppressWarnings("UnusedDeclaration")
static void sleep(int seconds) {
FileLog.MAIN.logLine("Sleeping " + seconds + " seconds");
try {
Thread.sleep(seconds * 1000L);
} catch (InterruptedException e) {

View File

@ -1,5 +1,6 @@
package com.rusefi.io;
import com.rusefi.FileLog;
import com.rusefi.core.MessagesCentral;
import org.jetbrains.annotations.NotNull;
@ -34,6 +35,7 @@ public class CommandQueue {
try {
sendPendingCommand();
} catch (InterruptedException e) {
FileLog.MAIN.logLine("CommandQueue error");
e.printStackTrace();
throw new IllegalStateException(e);
}
@ -140,6 +142,9 @@ public class CommandQueue {
/**
* Non-blocking command request
* Command is placed in the queue where it would be until it is confirmed
* @param command dev console command
* @param timeoutMs retry timeout
*/
public void write(String command, int timeoutMs, InvocationConfirmationListener listener) {