From d489fdbbd1e6fb2a9573e6663b3fb07c400c6d04 Mon Sep 17 00:00:00 2001 From: rusefi Date: Thu, 7 Oct 2021 21:15:46 -0400 Subject: [PATCH] Explicit error in case of error --- .../main/java/com/rusefi/maintenance/DfuFlasher.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/java_console/ui/src/main/java/com/rusefi/maintenance/DfuFlasher.java b/java_console/ui/src/main/java/com/rusefi/maintenance/DfuFlasher.java index 29a7a3edc4..0b1458e20c 100644 --- a/java_console/ui/src/main/java/com/rusefi/maintenance/DfuFlasher.java +++ b/java_console/ui/src/main/java/com/rusefi/maintenance/DfuFlasher.java @@ -40,15 +40,20 @@ public class DfuFlasher { if (!PortDetector.isAutoPort(port)) { messages.append("Using selected " + port + "\n"); IoStream stream = SerialIoStreamJSerialComm.openPort(port); - AtomicReference result = new AtomicReference<>(); + AtomicReference signature = new AtomicReference<>(); new SerialAutoChecker(port, new CountDownLatch(1)).checkResponse(stream, new Function() { @Override public Void apply(SerialAutoChecker.CallbackContext callbackContext) { - result.set(callbackContext.getSignature()); + signature.set(callbackContext.getSignature()); return null; } }); - boolean isSignatureValidatedLocal = DfuHelper.sendDfuRebootCommand(parent, result.get(), stream, messages); + if (signature.get() == null) { + JOptionPane.showMessageDialog(ConsoleUI.getFrame(), "rusEFI has not responded on selected " + port + "\n" + + "Maybe try automatic serial port detection?"); + return; + } + boolean isSignatureValidatedLocal = DfuHelper.sendDfuRebootCommand(parent, signature.get(), stream, messages); isSignatureValidated.set(isSignatureValidatedLocal); } else { messages.append("Auto-detecting port...\n");