removing a bit of dead code
This commit is contained in:
parent
c0a2dc99de
commit
372d321878
|
@ -53,14 +53,11 @@ public class PortHolder {
|
|||
* @return true if everything fine
|
||||
*/
|
||||
private boolean open(String port, final DataListener listener) {
|
||||
EstablishConnection establishConnection = new EstablishConnection(port).invoke();
|
||||
if (!establishConnection.isConnected())
|
||||
return false;
|
||||
IoStream stream = EstablishConnection.create(port);
|
||||
synchronized (portLock) {
|
||||
PortHolder.this.serialPort = establishConnection.stream;
|
||||
PortHolder.this.serialPort = stream;
|
||||
portLock.notifyAll();
|
||||
}
|
||||
IoStream stream = establishConnection.getStream();
|
||||
|
||||
bp = BinaryProtocolHolder.getInstance().create(FileLog.LOGGER, stream);
|
||||
|
||||
|
@ -100,27 +97,8 @@ public class PortHolder {
|
|||
}
|
||||
|
||||
public static class EstablishConnection {
|
||||
private boolean isConnected;
|
||||
private String port;
|
||||
private IoStream stream;
|
||||
|
||||
public EstablishConnection(String port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
// todo: remove dead code - always true?
|
||||
public boolean isConnected() {
|
||||
return isConnected;
|
||||
}
|
||||
|
||||
public IoStream getStream() {
|
||||
return stream;
|
||||
}
|
||||
|
||||
public EstablishConnection invoke() {
|
||||
stream = SerialIoStreamJSerialComm.open(port, BAUD_RATE, FileLog.LOGGER);
|
||||
isConnected = true;
|
||||
return this;
|
||||
public static IoStream create(String port) {
|
||||
return SerialIoStreamJSerialComm.open(port, BAUD_RATE, FileLog.LOGGER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -278,10 +278,7 @@ public class Launcher {
|
|||
String autoDetectedPort = autoDetectPort();
|
||||
if (autoDetectedPort == null)
|
||||
return;
|
||||
PortHolder.EstablishConnection establishConnection = new PortHolder.EstablishConnection(autoDetectedPort).invoke();
|
||||
if (!establishConnection.isConnected())
|
||||
return;
|
||||
IoStream stream = establishConnection.getStream();
|
||||
IoStream stream = PortHolder.EstablishConnection.create(autoDetectedPort);
|
||||
byte[] commandBytes = BinaryProtocol.getTextCommandBytes(command);
|
||||
stream.sendPacket(commandBytes, FileLog.LOGGER);
|
||||
}
|
||||
|
|
|
@ -27,10 +27,7 @@ class SerialAutoChecker implements Runnable {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
PortHolder.EstablishConnection establishConnection = new PortHolder.EstablishConnection(serialPort).invoke();
|
||||
if (!establishConnection.isConnected())
|
||||
return;
|
||||
IoStream stream = establishConnection.getStream();
|
||||
IoStream stream = PortHolder.EstablishConnection.create(serialPort);
|
||||
Logger logger = FileLog.LOGGER;
|
||||
IncomingDataBuffer incomingData = new IncomingDataBuffer(logger);
|
||||
stream.setInputListener(incomingData::addData);
|
||||
|
|
Loading…
Reference in New Issue