minor checkResponse refactor

This commit is contained in:
Matthew Kennedy 2023-10-27 21:52:15 -07:00
parent 7fb99bbbf6
commit b75b54bcda
3 changed files with 6 additions and 5 deletions

View File

@ -29,6 +29,10 @@ public class SerialAutoChecker {
this.portFound = portFound;
}
public static String checkResponse(IoStream stream) {
return checkResponse(stream, null);
}
/**
* @return ECU signature from specified stream
*/

View File

@ -242,7 +242,7 @@ public enum SerialPortScanner {
public static boolean isPortFomeEcu(String port) {
try (IoStream stream = BufferedSerialIoStream.openPort(port)) {
String signature = SerialAutoChecker.checkResponse(stream, null);
String signature = SerialAutoChecker.checkResponse(stream);
if (signature == null) {
return false;

View File

@ -82,10 +82,7 @@ public class DfuFlasher {
callbacks.log("Using selected " + port + "\n");
IoStream stream = BufferedSerialIoStream.openPort(port);
AtomicReference<String> signature = new AtomicReference<>();
new SerialAutoChecker(PortDetector.DetectorMode.DETECT_TS, port, new CountDownLatch(1)).checkResponse(stream, callbackContext -> {
signature.set(callbackContext.getSignature());
return null;
});
signature.set(SerialAutoChecker.checkResponse(stream));
if (signature.get() == null) {
callbacks.log("*** ERROR *** FOME has not responded on selected " + port + "\n" +
"Maybe try automatic serial port detection?");