From 421541a89e429d1e8d29af9c9ad1be678b993260 Mon Sep 17 00:00:00 2001 From: rusefi Date: Sat, 22 Jun 2019 08:02:07 -0400 Subject: [PATCH] Windows 10: rusEfi console sometimes crashes within SerialIoStreamJSSC #849 --- java_console/io/src/com/rusefi/io/serial/PortHolder.java | 5 ++--- java_console/logging/src/com/rusefi/FileLog.java | 8 ++++++++ java_console/ui/src/com/rusefi/Launcher.java | 2 -- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/java_console/io/src/com/rusefi/io/serial/PortHolder.java b/java_console/io/src/com/rusefi/io/serial/PortHolder.java index 4284e2cb32..0365125f02 100644 --- a/java_console/io/src/com/rusefi/io/serial/PortHolder.java +++ b/java_console/io/src/com/rusefi/io/serial/PortHolder.java @@ -16,7 +16,6 @@ import org.jetbrains.annotations.Nullable; * (c) Andrey Belomutskiy */ public class PortHolder { - public static final String OS_VERSION = "os.version"; public static int BAUD_RATE = 115200; private static PortHolder instance = new PortHolder(); private final Object portLock = new Object(); @@ -71,8 +70,8 @@ public class PortHolder { } private static boolean isWindows10() { - // numeric winnt version for "Windows 10" is 7 - return System.getProperty(OS_VERSION).startsWith("7"); + // todo: this code is fragile! What about Windows 11, 12 etc!? this is a problem for the later day :( + return System.getProperty(FileLog.OS_VERSION).startsWith("10"); } public void close() { diff --git a/java_console/logging/src/com/rusefi/FileLog.java b/java_console/logging/src/com/rusefi/FileLog.java index f7fd94c20f..8702cf2d6c 100644 --- a/java_console/logging/src/com/rusefi/FileLog.java +++ b/java_console/logging/src/com/rusefi/FileLog.java @@ -17,6 +17,7 @@ public enum FileLog { public static final String DIR = "logs/"; public static final String LOG_INFO_TEXT = "Writing logs to '" + DIR + "'"; + public static final String OS_VERSION = "os.version"; public static String currentLogName; public static final String END_OF_TIMESTAND_TAG = ": "; public static final Logger LOGGER = new Logger() { @@ -50,6 +51,13 @@ public enum FileLog { } catch (FileNotFoundException e) { throw new IllegalStateException(e); } + // a bit strange spot for this invocation for sure + printOsInfo(); + } + + private static void printOsInfo() { + MAIN.logLine("OS name: " + System.getProperty("os.name")); + MAIN.logLine("OS version: " + System.getProperty(OS_VERSION)); } private FileOutputStream openLog() throws FileNotFoundException { diff --git a/java_console/ui/src/com/rusefi/Launcher.java b/java_console/ui/src/com/rusefi/Launcher.java index dc8c03f5ee..2652defca8 100644 --- a/java_console/ui/src/com/rusefi/Launcher.java +++ b/java_console/ui/src/com/rusefi/Launcher.java @@ -317,8 +317,6 @@ public class Launcher { System.out.println("Starting rusEfi UI console " + CONSOLE_VERSION); FileLog.MAIN.start(); - FileLog.MAIN.logLine("OS name: " + System.getProperty("os.name")); - FileLog.MAIN.logLine("OS version: " + System.getProperty(PortHolder.OS_VERSION)); getConfig().load(); FileLog.suspendLogging = getConfig().getRoot().getBoolProperty(GaugesPanel.DISABLE_LOGS); Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler());