From 36d6274e0e3c5ba0f571c9768133cbba37d0d99f Mon Sep 17 00:00:00 2001 From: rusEfi Date: Tue, 12 May 2015 14:04:48 -0400 Subject: [PATCH] auto-sync --- firmware/config/engines/ford_fiesta.cpp | 1 + .../rusefi/binaryprotocol/BinaryProtocol.java | 2 - .../src/com/rusefi/io/tcp/TcpConnector.java | 50 +++++++++++-------- .../editor/ecu/ECUEditorManager.java | 5 +- 4 files changed, 34 insertions(+), 24 deletions(-) diff --git a/firmware/config/engines/ford_fiesta.cpp b/firmware/config/engines/ford_fiesta.cpp index d2cb59686c..655c4318f3 100644 --- a/firmware/config/engines/ford_fiesta.cpp +++ b/firmware/config/engines/ford_fiesta.cpp @@ -26,6 +26,7 @@ void setFordFiestaDefaultEngineConfiguration(engine_configuration_s *engineConfi engineConfiguration->ignitionMode = IM_WASTED_SPARK; engineConfiguration->specs.firingOrder = FO_1_THEN_3_THEN_4_THEN2; engineConfiguration->hasMafSensor = true; + engineConfiguration->mafAdcChannel = EFI_ADC_1; } #endif /* EFI_SUPPORT_FORD_FIESTA */ diff --git a/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java b/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java index 908aa122f4..86fece8a0c 100644 --- a/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java +++ b/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java @@ -89,8 +89,6 @@ public class BinaryProtocol { Future f = LinkManager.COMMUNICATION_EXECUTOR.submit(new Runnable() { @Override public void run() { - if (this == null) - throw new NullPointerException("bp"); sendTextCommand(command); } diff --git a/java_console/io/src/com/rusefi/io/tcp/TcpConnector.java b/java_console/io/src/com/rusefi/io/tcp/TcpConnector.java index 51fb25894a..204dd08ebf 100644 --- a/java_console/io/src/com/rusefi/io/tcp/TcpConnector.java +++ b/java_console/io/src/com/rusefi/io/tcp/TcpConnector.java @@ -1,9 +1,11 @@ package com.rusefi.io.tcp; import com.rusefi.FileLog; +import com.rusefi.binaryprotocol.BinaryProtocol; import com.rusefi.core.EngineState; import com.rusefi.core.ResponseBuffer; import com.rusefi.io.*; +import com.rusefi.io.serial.SerialIoStream; import java.io.*; import java.net.Socket; @@ -20,7 +22,8 @@ public class TcpConnector implements LinkConnector { private final int port; private boolean withError; private BufferedInputStream stream; - private IoStream ioStream; +// private IoStream ioStream; + private BinaryProtocol bp; public TcpConnector(String port) { try { @@ -59,10 +62,8 @@ public class TcpConnector implements LinkConnector { } static class InvalidTcpPort extends Exception { - } - public static int getTcpPort(String port) throws InvalidTcpPort { try { return Integer.parseInt(port); @@ -86,15 +87,15 @@ public class TcpConnector implements LinkConnector { @Override public void connect(LinkManager.LinkStateListener listener) { FileLog.MAIN.logLine("Connecting to " + port); + OutputStream os; try { Socket socket = new Socket(LOCALHOST, port); - OutputStream os = socket.getOutputStream(); + os = socket.getOutputStream(); stream = new BufferedInputStream(socket.getInputStream()); - ioStream = new TcpIoStream(os, stream); +// ioStream = new TcpIoStream(os, stream); } catch (IOException e) { throw new IllegalStateException("Failed to connect to simulator", e); } -// listener.onConnectionEstablished(); final ResponseBuffer rb = new ResponseBuffer(new ResponseBuffer.ResponseListener() { @Override @@ -103,15 +104,22 @@ public class TcpConnector implements LinkConnector { } }); - ioStream.addEventListener(new DataListener() { + DataListener listener1 = new DataListener() { @Override public void onDataArrived(byte[] freshData) { rb.append(new String(freshData)); } - }); - + }; +// ioStream.addEventListener(listener1); + bp = new BinaryProtocol(FileLog.LOGGER, new TcpIoStream(os, stream)); + boolean result = bp.connect(listener1); + if (result) { + listener.onConnectionEstablished(); + } else { + listener.onConnectionFailed(); + } } @Override @@ -126,20 +134,22 @@ public class TcpConnector implements LinkConnector { @Override public String unpack(String packet) { - return EngineState.unpackString(packet); + return packet; +// return EngineState.unpackString(packet); } @Override - public void send(String text) throws InterruptedException { - String command = LinkManager.encodeCommand(text); - FileLog.MAIN.logLine("Writing " + command); - try { - ioStream.write((command + "\n").getBytes()); - } catch (IOException e) { - withError = true; - System.err.println("err in send"); - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. - } + public void send(String command) throws InterruptedException { + bp.doSend(command); +// String command = LinkManager.encodeCommand(text); +// FileLog.MAIN.logLine("Writing " + command); +// try { +// ioStream.write((command + "\n").getBytes()); +// } catch (IOException e) { +// withError = true; +// System.err.println("err in send"); +// e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. +// } } @Override diff --git a/java_console/romraider/src/com/romraider/editor/ecu/ECUEditorManager.java b/java_console/romraider/src/com/romraider/editor/ecu/ECUEditorManager.java index a04d9a3216..a312006f42 100644 --- a/java_console/romraider/src/com/romraider/editor/ecu/ECUEditorManager.java +++ b/java_console/romraider/src/com/romraider/editor/ecu/ECUEditorManager.java @@ -19,7 +19,7 @@ package com.romraider.editor.ecu; -import javax.swing.SwingUtilities; +import com.rusefi.ui.util.UiUtils; public class ECUEditorManager { @@ -32,7 +32,7 @@ public class ECUEditorManager { public static ECUEditor getECUEditor() { if (editor == null) { try { - SwingUtilities.invokeAndWait(new Runnable() { + UiUtils.invokeAndWait(new Runnable() { public void run() { editor = new ECUEditor(); } @@ -43,4 +43,5 @@ public class ECUEditorManager { } return editor; } + }