auto-sync
This commit is contained in:
parent
da02e246fe
commit
2eff8cce6f
|
@ -20,7 +20,7 @@ void setDodgeRam1996(DECLARE_ENGINE_PARAMETER_F) {
|
|||
|
||||
setOperationMode(engineConfiguration, FOUR_STROKE_CAM_SENSOR);
|
||||
engineConfiguration->trigger.type = TT_DODGE_RAM;
|
||||
engineConfiguration->injector.flow = 243.6;
|
||||
engineConfiguration->injector.flow = 243.6; // 23.2lb/h
|
||||
engineConfiguration->map.sensor.type = MT_DODGE_NEON_2003;
|
||||
|
||||
// set_cranking_charge_angle 30
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package com.rusefi.io;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* (c) Andrey Belomutskiy
|
||||
*
|
||||
* 5/11/2015.
|
||||
*/
|
||||
public interface IoStream {
|
||||
void close();
|
||||
|
||||
void write(byte[] bytes) throws IOException;
|
||||
|
||||
void purge();
|
||||
|
||||
void addEventListener(DataListener listener);
|
||||
}
|
|
@ -1,11 +1,10 @@
|
|||
package com.rusefi.io.serial;
|
||||
|
||||
import com.rusefi.FileLog;
|
||||
import com.rusefi.core.EngineState;
|
||||
import com.rusefi.core.MessagesCentral;
|
||||
import com.rusefi.io.CommandQueue;
|
||||
import com.rusefi.io.LinkConnector;
|
||||
import com.rusefi.io.LinkManager;
|
||||
import com.rusefi.io.tcp.TcpConnector;
|
||||
|
||||
/**
|
||||
* @author Andrey Belomutskiy
|
||||
|
@ -19,12 +18,29 @@ public class SerialConnector implements LinkConnector {
|
|||
@Override
|
||||
public void connect(LinkManager.LinkStateListener listener) {
|
||||
FileLog.MAIN.logLine("SerialConnector: connecting");
|
||||
SerialManager.scheduleOpening(listener);
|
||||
SerialManager.listener = listener;
|
||||
FileLog.MAIN.logLine("scheduleOpening");
|
||||
LinkManager.IO_EXECUTOR.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FileLog.MAIN.logLine("scheduleOpening>openPort");
|
||||
PortHolder.getInstance().openPort(SerialManager.port, SerialManager.dataListener, SerialManager.listener);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restart() {
|
||||
SerialManager.restart();
|
||||
LinkManager.IO_EXECUTOR.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MessagesCentral.getInstance().postMessage(SerialManager.class, "Restarting serial IO");
|
||||
// if (closed)
|
||||
// return;
|
||||
PortHolder.getInstance().close();
|
||||
PortHolder.getInstance().openPort(SerialManager.port, SerialManager.dataListener, SerialManager.listener);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
package com.rusefi.io.serial;
|
||||
|
||||
import com.rusefi.FileLog;
|
||||
import com.rusefi.Logger;
|
||||
import com.rusefi.io.DataListener;
|
||||
import com.rusefi.io.IoStream;
|
||||
import jssc.SerialPort;
|
||||
import jssc.SerialPortException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* (c) Andrey Belomutskiy
|
||||
* 5/11/2015.
|
||||
*/
|
||||
public class SerialIoStream implements IoStream {
|
||||
private final SerialPort serialPort;
|
||||
private final Logger logger;
|
||||
|
||||
public SerialIoStream(SerialPort serialPort, Logger logger) {
|
||||
this.serialPort = serialPort;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
try {
|
||||
FileLog.MAIN.logLine("CLOSING PORT...");
|
||||
serialPort.closePort();
|
||||
FileLog.MAIN.logLine("PORT CLOSED");
|
||||
} catch (SerialPortException e) {
|
||||
logger.error("Error closing port: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] bytes) throws IOException {
|
||||
try {
|
||||
serialPort.writeBytes(bytes);
|
||||
} catch (SerialPortException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void purge() {
|
||||
try {
|
||||
serialPort.purgePort(SerialPort.PURGE_RXCLEAR | SerialPort.PURGE_TXCLEAR);
|
||||
} catch (SerialPortException e) {
|
||||
logger.info("Error while purge: " + e);
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEventListener(DataListener listener) {
|
||||
try {
|
||||
serialPort.addEventListener(new SerialPortReader(serialPort, listener));
|
||||
} catch (SerialPortException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -20,33 +20,9 @@ class SerialManager {
|
|||
LinkManager.engineState.processNewData(new String(freshData));
|
||||
}
|
||||
};
|
||||
private static LinkManager.LinkStateListener listener;
|
||||
public static LinkManager.LinkStateListener listener;
|
||||
|
||||
public static void scheduleOpening(LinkManager.LinkStateListener listener) {
|
||||
SerialManager.listener = listener;
|
||||
FileLog.MAIN.logLine("scheduleOpening");
|
||||
LinkManager.IO_EXECUTOR.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FileLog.MAIN.logLine("scheduleOpening>openPort");
|
||||
PortHolder.getInstance().openPort(port, SerialManager.dataListener, SerialManager.listener);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void restart() {
|
||||
LinkManager.IO_EXECUTOR.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MessagesCentral.getInstance().postMessage(SerialManager.class, "Restarting serial IO");
|
||||
// if (closed)
|
||||
// return;
|
||||
PortHolder.getInstance().close();
|
||||
PortHolder.getInstance().openPort(port, dataListener, SerialManager.listener);
|
||||
}
|
||||
});
|
||||
}
|
||||
/*
|
||||
/*
|
||||
static String[] findSerialPorts() {
|
||||
List<String> result = new ArrayList<String>();
|
||||
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package com.rusefi.io.tcp;
|
||||
|
||||
import com.rusefi.io.DataListener;
|
||||
import com.rusefi.io.IoStream;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* (c) Andrey Belomutskiy
|
||||
* 5/11/2015.
|
||||
*/
|
||||
public class TcpIoStream implements IoStream {
|
||||
@Override
|
||||
public void close() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] bytes) throws IOException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void purge() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEventListener(DataListener listener) {
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue