parent
e4d248dd32
commit
863a38675e
|
@ -4,6 +4,7 @@ import com.opensr5.Logger;
|
||||||
import com.opensr5.io.DataListener;
|
import com.opensr5.io.DataListener;
|
||||||
import com.opensr5.io.WriteStream;
|
import com.opensr5.io.WriteStream;
|
||||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||||
|
import com.rusefi.binaryprotocol.IncomingDataBuffer;
|
||||||
import com.rusefi.binaryprotocol.IoHelper;
|
import com.rusefi.binaryprotocol.IoHelper;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -48,4 +49,8 @@ public interface IoStream extends WriteStream {
|
||||||
boolean isClosed();
|
boolean isClosed();
|
||||||
|
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
|
void setDataBuffer(IncomingDataBuffer dataBuffer);
|
||||||
|
|
||||||
|
IncomingDataBuffer getDataBuffer();
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,8 +54,9 @@ public class PortHolder {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
IncomingDataBuffer dataBuffer = IncomingDataBuffer.createDataBuffer(stream, logger);
|
IncomingDataBuffer dataBuffer = IncomingDataBuffer.createDataBuffer(stream, logger);
|
||||||
|
stream.setDataBuffer(dataBuffer);
|
||||||
synchronized (portLock) {
|
synchronized (portLock) {
|
||||||
bp = new BinaryProtocol(linkManager, logger, stream, dataBuffer);
|
bp = new BinaryProtocol(linkManager, logger, stream, stream.getDataBuffer());
|
||||||
portLock.notifyAll();
|
portLock.notifyAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.fazecast.jSerialComm.SerialPortDataListener;
|
||||||
import com.fazecast.jSerialComm.SerialPortEvent;
|
import com.fazecast.jSerialComm.SerialPortEvent;
|
||||||
import com.opensr5.Logger;
|
import com.opensr5.Logger;
|
||||||
import com.opensr5.io.DataListener;
|
import com.opensr5.io.DataListener;
|
||||||
|
import com.rusefi.binaryprotocol.IncomingDataBuffer;
|
||||||
import com.rusefi.io.IoStream;
|
import com.rusefi.io.IoStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,6 +19,7 @@ public class SerialIoStreamJSerialComm implements IoStream {
|
||||||
private SerialPort sp;
|
private SerialPort sp;
|
||||||
private final String port;
|
private final String port;
|
||||||
private final Logger logger;
|
private final Logger logger;
|
||||||
|
private IncomingDataBuffer dataBuffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see #openPort(String, Logger)
|
* @see #openPort(String, Logger)
|
||||||
|
@ -59,6 +61,16 @@ public class SerialIoStreamJSerialComm implements IoStream {
|
||||||
return isClosed;
|
return isClosed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDataBuffer(IncomingDataBuffer dataBuffer) {
|
||||||
|
this.dataBuffer = dataBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IncomingDataBuffer getDataBuffer() {
|
||||||
|
return dataBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
logger.info(port + ": Closing port...");
|
logger.info(port + ": Closing port...");
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.rusefi.io.tcp;
|
||||||
|
|
||||||
import com.opensr5.Logger;
|
import com.opensr5.Logger;
|
||||||
import com.opensr5.io.DataListener;
|
import com.opensr5.io.DataListener;
|
||||||
|
import com.rusefi.binaryprotocol.IncomingDataBuffer;
|
||||||
import com.rusefi.io.ByteReader;
|
import com.rusefi.io.ByteReader;
|
||||||
import com.rusefi.io.IoStream;
|
import com.rusefi.io.IoStream;
|
||||||
|
|
||||||
|
@ -20,6 +21,7 @@ public class TcpIoStream implements IoStream {
|
||||||
private final OutputStream output;
|
private final OutputStream output;
|
||||||
private final Logger logger;
|
private final Logger logger;
|
||||||
private boolean isClosed;
|
private boolean isClosed;
|
||||||
|
private IncomingDataBuffer dataBuffer;
|
||||||
|
|
||||||
public TcpIoStream(Logger logger, Socket socket) throws IOException {
|
public TcpIoStream(Logger logger, Socket socket) throws IOException {
|
||||||
this(logger, new BufferedInputStream(socket.getInputStream()), socket.getOutputStream());
|
this(logger, new BufferedInputStream(socket.getInputStream()), socket.getOutputStream());
|
||||||
|
@ -35,6 +37,16 @@ public class TcpIoStream implements IoStream {
|
||||||
this.input = input;
|
this.input = input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDataBuffer(IncomingDataBuffer dataBuffer) {
|
||||||
|
this.dataBuffer = dataBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IncomingDataBuffer getDataBuffer() {
|
||||||
|
return dataBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
isClosed = true;
|
isClosed = true;
|
||||||
|
|
Loading…
Reference in New Issue