auto-sync
This commit is contained in:
parent
2b9d7e2a8e
commit
36d6274e0e
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue