TCP open refactoring

This commit is contained in:
rusefillc 2020-10-08 23:58:08 -04:00
parent b5058dff2b
commit c97ccd98bc
2 changed files with 9 additions and 1 deletions

View File

@ -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);

View File

@ -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 {