TCP open refactoring
This commit is contained in:
parent
b5058dff2b
commit
c97ccd98bc
|
@ -14,6 +14,7 @@ import com.rusefi.io.tcp.TcpIoStream;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.*;
|
||||
|
@ -64,6 +65,13 @@ public class LinkManager implements Closeable {
|
|||
commandQueue = new CommandQueue(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static IoStream open(String port) throws IOException {
|
||||
if (TcpConnector.isTcpPort(port))
|
||||
return TcpIoStream.open(port);
|
||||
return SerialIoStreamJSerialComm.openPort(port);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public CountDownLatch connect(String port) {
|
||||
final CountDownLatch connected = new CountDownLatch(1);
|
||||
|
|
|
@ -42,7 +42,7 @@ public class TcpConnector {
|
|||
return confirmation.substring(0, length);
|
||||
}
|
||||
*/
|
||||
public static class InvalidTcpPort extends Exception {
|
||||
public static class InvalidTcpPort extends IOException {
|
||||
}
|
||||
|
||||
public static int getTcpPort(String port) throws InvalidTcpPort {
|
||||
|
|
Loading…
Reference in New Issue