This commit is contained in:
rusefi 2020-05-15 01:17:41 -04:00
parent b252150298
commit 28ce458e5b
2 changed files with 7 additions and 5 deletions

View File

@ -258,9 +258,11 @@ public class Launcher {
}
private static void runHeadless() {
String autoDetectedPort = getString();
if (autoDetectedPort == null)
String autoDetectedPort = PortDetector.autoDetectSerial();
if (autoDetectedPort == null) {
System.err.println("rusEFI not detected");
return;
}
new SerialConnector(autoDetectedPort).connect(new ConnectionStateListener() {
@Override
public void onConnectionEstablished() {
@ -282,7 +284,7 @@ public class Launcher {
}
private static void sendCommand(String command) throws IOException {
String autoDetectedPort = getString();
String autoDetectedPort = autoDetectPort();
if (autoDetectedPort == null)
return;
PortHolder.EstablishConnection establishConnection = new PortHolder.EstablishConnection(autoDetectedPort).invoke();
@ -294,7 +296,7 @@ public class Launcher {
}
@Nullable
private static String getString() {
private static String autoDetectPort() {
String autoDetectedPort = PortDetector.autoDetectPort(null);
if (autoDetectedPort == null) {
System.err.println("rusEFI not detected");

View File

@ -24,7 +24,7 @@ public class PortDetector {
System.err.println("No serial ports detected");
return null;
}
System.out.printf("Trying " + Arrays.toString(serialPorts));
System.out.println("Trying " + Arrays.toString(serialPorts));
List<Thread> serialFinder = new ArrayList<>();
CountDownLatch portFound = new CountDownLatch(1);
AtomicReference<String> result = new AtomicReference<>();