From 2a961319234b4be8b6e2db62850cb5c8b5fcd4f5 Mon Sep 17 00:00:00 2001 From: rusefi Date: Fri, 23 Aug 2019 21:01:37 -0400 Subject: [PATCH] command line utiity to reboot rusEfi --- firmware/reboot_ecu.bat | 5 +++++ java_console/ui/src/com/rusefi/Launcher.java | 23 ++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 firmware/reboot_ecu.bat diff --git a/firmware/reboot_ecu.bat b/firmware/reboot_ecu.bat new file mode 100644 index 0000000000..17f7c995ea --- /dev/null +++ b/firmware/reboot_ecu.bat @@ -0,0 +1,5 @@ +rem +rem auto-detects connected running rusEfi serial port and send text 'reboot' command +rem + +java -jar ../java_console_binary/rusefi_console.jar reboot_ecu diff --git a/java_console/ui/src/com/rusefi/Launcher.java b/java_console/ui/src/com/rusefi/Launcher.java index 285a986a43..6134f3d82e 100644 --- a/java_console/ui/src/com/rusefi/Launcher.java +++ b/java_console/ui/src/com/rusefi/Launcher.java @@ -48,13 +48,14 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig; * @see EngineSnifferPanel */ public class Launcher { - public static final int CONSOLE_VERSION = 20190818; + public static final int CONSOLE_VERSION = 20190823; public static final String INPUT_FILES_PATH = System.getProperty("input_files_path", ".."); public static final String TOOLS_PATH = System.getProperty("tools_path", "."); private static final String TAB_INDEX = "main_tab"; protected static final String PORT_KEY = "port"; protected static final String SPEED_KEY = "speed"; private static final String TOOL_NAME_COMPILE_FSIO_FILE = "compile_fsio_file"; + private static final String TOOL_NAME_REBOOT_ECU = "reboot_ecu"; // todo: rename to something more FSIO-specific? would need to update documentation somewhere private static final String TOOL_NAME_COMPILE = "compile"; private final String port; @@ -328,10 +329,28 @@ public class Launcher { System.out.println(DoubleEvaluator.process(input).getPosftfixExpression()); System.exit(0); } - System.out.println("Optional tools: " + Arrays.asList(TOOL_NAME_COMPILE_FSIO_FILE, TOOL_NAME_COMPILE)); + System.out.println("Optional tools: " + Arrays.asList(TOOL_NAME_COMPILE_FSIO_FILE, TOOL_NAME_COMPILE, TOOL_NAME_REBOOT_ECU)); System.out.println("Starting rusEfi UI console " + CONSOLE_VERSION); FileLog.MAIN.start(); + + if (TOOL_NAME_REBOOT_ECU.equalsIgnoreCase(toolName)) { + String autoDetectedPort = PortDetector.autoDetectPort(null); + if (autoDetectedPort == null) { + System.err.println("rusEfi not detected"); + return; + } + PortHolder.EstablishConnection establishConnection = new PortHolder.EstablishConnection(autoDetectedPort).invoke(); + if (!establishConnection.isConnected()) + return; + IoStream stream = establishConnection.getStream(); + byte[] commandBytes = BinaryProtocol.getTextCommandBytes(Fields.CMD_REBOOT); + stream.sendPacket(commandBytes, FileLog.LOGGER); + + return; + } + + getConfig().load(); FileLog.suspendLogging = getConfig().getRoot().getBoolProperty(GaugesPanel.DISABLE_LOGS); Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler());