rusEFI console should not close on disconnect #4008
This commit is contained in:
parent
40938be509
commit
30dc9bb16d
|
@ -2,7 +2,7 @@ package com.rusefi.io;
|
|||
|
||||
import com.devexperts.logging.Logging;
|
||||
import com.rusefi.config.generated.Fields;
|
||||
import com.rusefi.core.MessagesCentral;
|
||||
import com.rusefi.util.IoUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -11,7 +11,6 @@ import java.util.concurrent.CountDownLatch;
|
|||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static com.devexperts.logging.Logging.getLogging;
|
||||
|
||||
|
@ -111,8 +110,7 @@ public class CommandQueue {
|
|||
try {
|
||||
sendPendingCommand();
|
||||
} catch (Throwable e) {
|
||||
log.error("CommandQueue error" + e);
|
||||
System.exit(-2);
|
||||
IoUtils.exit("CommandQueue error" + e, -2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.rusefi.io.serial.StreamConnector;
|
|||
import com.rusefi.io.stream.PCanIoStream;
|
||||
import com.rusefi.io.tcp.TcpConnector;
|
||||
import com.rusefi.io.tcp.TcpIoStream;
|
||||
import com.rusefi.util.IoUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
@ -93,8 +94,7 @@ public class LinkManager implements Closeable {
|
|||
startAndConnect(port, new ConnectionStateListener() {
|
||||
@Override
|
||||
public void onConnectionFailed() {
|
||||
System.out.println("CONNECTION FAILED, did you specify the right port name?");
|
||||
System.exit(-1);
|
||||
IoUtils.exit("CONNECTION FAILED, did you specify the right port name?", -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.rusefi.io.ConnectionStateListener;
|
|||
import com.opensr5.io.DataListener;
|
||||
import com.rusefi.io.IoStream;
|
||||
import com.rusefi.io.LinkManager;
|
||||
import com.rusefi.util.IoUtils;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
@ -89,7 +90,7 @@ public class PortHolder {
|
|||
Window window = windows.length == 0 ? null : windows[0];
|
||||
JOptionPane.showMessageDialog(window, "No connectivity, will close",
|
||||
"Error", JOptionPane.ERROR_MESSAGE);
|
||||
System.exit(-1);
|
||||
IoUtils.exit("No connectivity, will close",-1);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
package com.rusefi.util;
|
||||
|
||||
import com.devexperts.logging.Logging;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static com.devexperts.logging.Logging.getLogging;
|
||||
|
||||
public class IoUtils {
|
||||
private static final Logging log = getLogging(IoUtils.class);
|
||||
|
||||
public static final Charset CHARSET = StandardCharsets.ISO_8859_1;
|
||||
|
||||
public static void exit(String s, int exitCode) {
|
||||
log.error(s, new Exception());
|
||||
System.exit(exitCode);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.net.URL;
|
|||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class rusEFIVersion {
|
||||
public static final int CONSOLE_VERSION = 20220310;
|
||||
public static final int CONSOLE_VERSION = 20220323;
|
||||
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
||||
|
||||
public static long classBuildTimeMillis() {
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.rusefi.maintenance.*;
|
|||
import com.rusefi.ui.util.HorizontalLine;
|
||||
import com.rusefi.ui.util.URLLabel;
|
||||
import com.rusefi.ui.util.UiUtils;
|
||||
import com.rusefi.util.IoUtils;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
@ -83,7 +84,7 @@ public class StartupFrame {
|
|||
public void windowClosed(WindowEvent ev) {
|
||||
if (!isProceeding) {
|
||||
getConfig().save();
|
||||
System.exit(0);
|
||||
IoUtils.exit("windowClosed", 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.rusefi.maintenance.VersionChecker;
|
|||
import com.rusefi.ui.storage.Node;
|
||||
import com.rusefi.ui.util.FrameHelper;
|
||||
import com.rusefi.ui.util.UiUtils;
|
||||
import com.rusefi.util.IoUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
@ -131,6 +132,6 @@ public class MainFrame {
|
|||
BinaryProtocol bp = consoleUI.uiContext.getLinkManager().getCurrentStreamState();
|
||||
if (bp != null && !bp.isClosed)
|
||||
bp.close(); // it could be that serial driver wants to be closed explicitly
|
||||
System.exit(0);
|
||||
IoUtils.exit("windowClosedHandler", 0);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue