auto-sync
This commit is contained in:
parent
0296d8e95b
commit
2487c536bb
|
@ -307,6 +307,7 @@ void updateDevConsoleState(void) {
|
|||
static void showFuelMap2(float rpm, float engineLoad) {
|
||||
float baseFuel = getBaseTableFuel((int) rpm, engineLoad);
|
||||
|
||||
scheduleMsg(&logger2, "algo=%d", engineConfiguration->algorithm);
|
||||
float iatCorrection = getIatCorrection(getIntakeAirTemperature());
|
||||
float cltCorrection = getCltCorrection(getCoolantTemperature());
|
||||
float injectorLag = getInjectorLag(getVBatt());
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<jvmarg value="-ea"/>
|
||||
<jvmarg value="-XX:+HeapDumpOnOutOfMemoryError"/>
|
||||
<formatter type="brief"/>
|
||||
<classpath path="build/classes:lib/junit.jar:lib/SteelSeries-3.9.30.jar"/>
|
||||
<classpath path="lib/jssc.jar:build/classes:lib/junit.jar:lib/SteelSeries-3.9.30.jar"/>
|
||||
<batchtest todir="build">
|
||||
<fileset dir="autotest/src" includes="**/test/**/*Test.java"/>
|
||||
<fileset dir="io/src" includes="**/test/**/*Test.java"/>
|
||||
|
|
|
@ -2,8 +2,6 @@ package com.rusefi.io.serial;
|
|||
|
||||
import com.irnems.FileLog;
|
||||
import com.irnems.core.EngineState;
|
||||
import com.irnems.core.MessagesCentral;
|
||||
import com.rusefi.io.CommandQueue;
|
||||
import com.rusefi.io.DataListener;
|
||||
import jssc.SerialPort;
|
||||
import jssc.SerialPortException;
|
||||
|
@ -15,7 +13,7 @@ import org.jetbrains.annotations.Nullable;
|
|||
* 7/25/13
|
||||
* (c) Andrey Belomutskiy
|
||||
*/
|
||||
class PortHolder {
|
||||
public class PortHolder {
|
||||
// private static final int BAUD_RATE = 8 * 115200;// 921600;
|
||||
// private static final int BAUD_RATE = 2 * 115200;
|
||||
private static final int BAUD_RATE = 115200;
|
||||
|
@ -26,22 +24,19 @@ class PortHolder {
|
|||
|
||||
public static long startedAt = System.currentTimeMillis();
|
||||
|
||||
public PortHolderListener listener = PortHolderListener.VOID;
|
||||
|
||||
private PortHolder() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private SerialPort serialPort;
|
||||
|
||||
void openPort(String port, final EngineState es) {
|
||||
MessagesCentral.getInstance().postMessage(SerialManager.class, "Opening port: " + port);
|
||||
void openPort(String port, DataListener dataListener) {
|
||||
listener.onPortHolderMessage(SerialManager.class, "Opening port: " + port);
|
||||
if (port == null)
|
||||
return;
|
||||
open(port, new DataListener() {
|
||||
public void onStringArrived(String string) {
|
||||
// jTextAreaIn.append(string);
|
||||
es.processNewData(string);
|
||||
}
|
||||
});
|
||||
open(port, dataListener);
|
||||
}
|
||||
|
||||
public boolean open(String port, DataListener listener) {
|
||||
|
@ -105,14 +100,14 @@ class PortHolder {
|
|||
*/
|
||||
public void packAndSend(String command) throws InterruptedException {
|
||||
FileLog.MAIN.logLine("Sending [" + command + "]");
|
||||
MessagesCentral.getInstance().postMessage(CommandQueue.class, "Sending [" + command + "]");
|
||||
listener.onPortHolderMessage(PortHolder.class, "Sending [" + command + "]");
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
synchronized (portLock) {
|
||||
while (serialPort == null) {
|
||||
if (System.currentTimeMillis() - now > 3 * MINUTE)
|
||||
MessagesCentral.getInstance().postMessage(PortHolder.class, "Looks like connection is gone :(");
|
||||
listener.onPortHolderMessage(PortHolder.class, "Looks like connection is gone :(");
|
||||
portLock.wait(MINUTE);
|
||||
}
|
||||
// we are here only when serialPort!=null, that means we have a connection
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package com.rusefi.io.serial;
|
||||
|
||||
/**
|
||||
* (c) Andrey Belomutskiy
|
||||
* 9/4/14
|
||||
*/
|
||||
public interface PortHolderListener {
|
||||
PortHolderListener VOID = new PortHolderListener() {
|
||||
@Override
|
||||
public void onPortHolderMessage(Class clazz, String message) {
|
||||
}
|
||||
};
|
||||
|
||||
void onPortHolderMessage(final Class clazz, final String message);
|
||||
}
|
|
@ -2,6 +2,7 @@ package com.rusefi.io.serial;
|
|||
|
||||
import com.irnems.FileLog;
|
||||
import com.irnems.core.MessagesCentral;
|
||||
import com.rusefi.io.DataListener;
|
||||
import com.rusefi.io.LinkManager;
|
||||
|
||||
/**
|
||||
|
@ -13,13 +14,20 @@ class SerialManager {
|
|||
|
||||
private static boolean closed;
|
||||
|
||||
static DataListener listener = new DataListener() {
|
||||
public void onStringArrived(String string) {
|
||||
// jTextAreaIn.append(string);
|
||||
LinkManager.engineState.processNewData(string);
|
||||
}
|
||||
};
|
||||
|
||||
public static void scheduleOpening() {
|
||||
FileLog.rlog("scheduleOpening");
|
||||
LinkManager.IO_EXECUTOR.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FileLog.rlog("scheduleOpening>openPort");
|
||||
PortHolder.getInstance().openPort(port, LinkManager.engineState);
|
||||
PortHolder.getInstance().openPort(port, listener);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -32,7 +40,7 @@ class SerialManager {
|
|||
if (closed)
|
||||
return;
|
||||
PortHolder.getInstance().close();
|
||||
PortHolder.getInstance().openPort(port, LinkManager.engineState);
|
||||
PortHolder.getInstance().openPort(port, listener);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package com.rusefi.io.test;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Andrey Belomutskiy
|
||||
* 9/4/14
|
||||
*/
|
||||
public class LinkManagerTest {
|
||||
@Test
|
||||
public void testEncoding() {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
package com.irnems.core;
|
||||
|
||||
import com.irnems.FileLog;
|
||||
import com.rusefi.io.serial.PortHolder;
|
||||
import com.rusefi.io.serial.PortHolderListener;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
|
@ -17,6 +19,12 @@ public class MessagesCentral {
|
|||
private final List<MessageListener> listeners = new CopyOnWriteArrayList<MessageListener>();
|
||||
|
||||
private MessagesCentral() {
|
||||
PortHolder.getInstance().listener = new PortHolderListener() {
|
||||
@Override
|
||||
public void onPortHolderMessage(Class clazz, String message) {
|
||||
postMessage(clazz, message);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static MessagesCentral getInstance() {
|
||||
|
|
Loading…
Reference in New Issue