auto-sync

This commit is contained in:
rusEfi 2015-05-12 14:04:48 -04:00
parent 2b9d7e2a8e
commit 36d6274e0e
4 changed files with 34 additions and 24 deletions

View File

@ -26,6 +26,7 @@ void setFordFiestaDefaultEngineConfiguration(engine_configuration_s *engineConfi
engineConfiguration->ignitionMode = IM_WASTED_SPARK; engineConfiguration->ignitionMode = IM_WASTED_SPARK;
engineConfiguration->specs.firingOrder = FO_1_THEN_3_THEN_4_THEN2; engineConfiguration->specs.firingOrder = FO_1_THEN_3_THEN_4_THEN2;
engineConfiguration->hasMafSensor = true; engineConfiguration->hasMafSensor = true;
engineConfiguration->mafAdcChannel = EFI_ADC_1;
} }
#endif /* EFI_SUPPORT_FORD_FIESTA */ #endif /* EFI_SUPPORT_FORD_FIESTA */

View File

@ -89,8 +89,6 @@ public class BinaryProtocol {
Future f = LinkManager.COMMUNICATION_EXECUTOR.submit(new Runnable() { Future f = LinkManager.COMMUNICATION_EXECUTOR.submit(new Runnable() {
@Override @Override
public void run() { public void run() {
if (this == null)
throw new NullPointerException("bp");
sendTextCommand(command); sendTextCommand(command);
} }

View File

@ -1,9 +1,11 @@
package com.rusefi.io.tcp; package com.rusefi.io.tcp;
import com.rusefi.FileLog; import com.rusefi.FileLog;
import com.rusefi.binaryprotocol.BinaryProtocol;
import com.rusefi.core.EngineState; import com.rusefi.core.EngineState;
import com.rusefi.core.ResponseBuffer; import com.rusefi.core.ResponseBuffer;
import com.rusefi.io.*; import com.rusefi.io.*;
import com.rusefi.io.serial.SerialIoStream;
import java.io.*; import java.io.*;
import java.net.Socket; import java.net.Socket;
@ -20,7 +22,8 @@ public class TcpConnector implements LinkConnector {
private final int port; private final int port;
private boolean withError; private boolean withError;
private BufferedInputStream stream; private BufferedInputStream stream;
private IoStream ioStream; // private IoStream ioStream;
private BinaryProtocol bp;
public TcpConnector(String port) { public TcpConnector(String port) {
try { try {
@ -59,10 +62,8 @@ public class TcpConnector implements LinkConnector {
} }
static class InvalidTcpPort extends Exception { static class InvalidTcpPort extends Exception {
} }
public static int getTcpPort(String port) throws InvalidTcpPort { public static int getTcpPort(String port) throws InvalidTcpPort {
try { try {
return Integer.parseInt(port); return Integer.parseInt(port);
@ -86,15 +87,15 @@ public class TcpConnector implements LinkConnector {
@Override @Override
public void connect(LinkManager.LinkStateListener listener) { public void connect(LinkManager.LinkStateListener listener) {
FileLog.MAIN.logLine("Connecting to " + port); FileLog.MAIN.logLine("Connecting to " + port);
OutputStream os;
try { try {
Socket socket = new Socket(LOCALHOST, port); Socket socket = new Socket(LOCALHOST, port);
OutputStream os = socket.getOutputStream(); os = socket.getOutputStream();
stream = new BufferedInputStream(socket.getInputStream()); stream = new BufferedInputStream(socket.getInputStream());
ioStream = new TcpIoStream(os, stream); // ioStream = new TcpIoStream(os, stream);
} catch (IOException e) { } catch (IOException e) {
throw new IllegalStateException("Failed to connect to simulator", e); throw new IllegalStateException("Failed to connect to simulator", e);
} }
// listener.onConnectionEstablished();
final ResponseBuffer rb = new ResponseBuffer(new ResponseBuffer.ResponseListener() { final ResponseBuffer rb = new ResponseBuffer(new ResponseBuffer.ResponseListener() {
@Override @Override
@ -103,15 +104,22 @@ public class TcpConnector implements LinkConnector {
} }
}); });
ioStream.addEventListener(new DataListener() { DataListener listener1 = new DataListener() {
@Override @Override
public void onDataArrived(byte[] freshData) { public void onDataArrived(byte[] freshData) {
rb.append(new String(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 @Override
@ -126,20 +134,22 @@ public class TcpConnector implements LinkConnector {
@Override @Override
public String unpack(String packet) { public String unpack(String packet) {
return EngineState.unpackString(packet); return packet;
// return EngineState.unpackString(packet);
} }
@Override @Override
public void send(String text) throws InterruptedException { public void send(String command) throws InterruptedException {
String command = LinkManager.encodeCommand(text); bp.doSend(command);
FileLog.MAIN.logLine("Writing " + command); // String command = LinkManager.encodeCommand(text);
try { // FileLog.MAIN.logLine("Writing " + command);
ioStream.write((command + "\n").getBytes()); // try {
} catch (IOException e) { // ioStream.write((command + "\n").getBytes());
withError = true; // } catch (IOException e) {
System.err.println("err in send"); // withError = true;
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. // System.err.println("err in send");
} // e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
// }
} }
@Override @Override

View File

@ -19,7 +19,7 @@
package com.romraider.editor.ecu; package com.romraider.editor.ecu;
import javax.swing.SwingUtilities; import com.rusefi.ui.util.UiUtils;
public class ECUEditorManager { public class ECUEditorManager {
@ -32,7 +32,7 @@ public class ECUEditorManager {
public static ECUEditor getECUEditor() { public static ECUEditor getECUEditor() {
if (editor == null) { if (editor == null) {
try { try {
SwingUtilities.invokeAndWait(new Runnable() { UiUtils.invokeAndWait(new Runnable() {
public void run() { public void run() {
editor = new ECUEditor(); editor = new ECUEditor();
} }
@ -43,4 +43,5 @@ public class ECUEditorManager {
} }
return editor; return editor;
} }
} }