Windows 10: rusEfi console sometimes crashes within SerialIoStreamJSSC #849

This commit is contained in:
rusefi 2019-06-22 07:16:12 -04:00
parent 0487076809
commit ba6c1fdca5
2 changed files with 18 additions and 4 deletions

View File

@ -16,6 +16,7 @@ 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();
@ -47,9 +48,15 @@ public class PortHolder {
* @return true if everything fine
*/
private boolean open(String port, final DataListener listener) {
IoStream stream = SerialIoStreamJSSC.open(port, BAUD_RATE, FileLog.LOGGER);
// this implementation is way simpler but seems to kind of work, keeping just in case
//IoStream stream = SerialIoStreamJSerialComm.open(port, BAUD_RATE, FileLog.LOGGER);
IoStream stream;
boolean windows10 = isWindows10();
FileLog.MAIN.logLine("Is windows10: " + windows10);
if (windows10) {
// this implementation is way simpler but seems to kind of work, keeping just in case
stream = SerialIoStreamJSerialComm.open(port, BAUD_RATE, FileLog.LOGGER);
} else {
stream = SerialIoStreamJSSC.open(port, BAUD_RATE, FileLog.LOGGER);
}
if (stream == null)
return false;
@ -63,6 +70,11 @@ public class PortHolder {
return bp.connectAndReadConfiguration(listener);
}
private static boolean isWindows10() {
// numeric winnt version for "Windows 10" is 7
return System.getProperty(OS_VERSION).startsWith("7");
}
public void close() {
synchronized (portLock) {
if (serialPort != null) {

View File

@ -46,7 +46,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
* @see EngineSnifferPanel
*/
public class Launcher {
public static final int CONSOLE_VERSION = 20190617;
public static final int CONSOLE_VERSION = 20190622;
public static final boolean SHOW_STIMULATOR = false;
public static final String INPUT_FILES_PATH = "..";
private static final String TAB_INDEX = "main_tab";
@ -317,6 +317,8 @@ 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());