From 6e560e7f124cd758c2a13c81076ba4e36ec72250 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Mon, 8 Aug 2022 17:18:20 -0400 Subject: [PATCH] openblt into console --- .../rusefi/maintenance/ProgramSelector.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/java_console/ui/src/main/java/com/rusefi/maintenance/ProgramSelector.java b/java_console/ui/src/main/java/com/rusefi/maintenance/ProgramSelector.java index 71774d353e..26894e7dc6 100644 --- a/java_console/ui/src/main/java/com/rusefi/maintenance/ProgramSelector.java +++ b/java_console/ui/src/main/java/com/rusefi/maintenance/ProgramSelector.java @@ -1,5 +1,6 @@ package com.rusefi.maintenance; +import com.rusefi.Launcher; import com.rusefi.autodetect.PortDetector; import com.rusefi.autoupdate.AutoupdateUtil; import com.rusefi.ui.StatusWindow; @@ -10,9 +11,11 @@ import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.io.File; import java.util.Arrays; import java.util.Objects; +import static com.rusefi.StartupFrame.appendBundleName; import static com.rusefi.ui.storage.PersistentConfiguration.getConfig; public class ProgramSelector { @@ -22,6 +25,8 @@ public class ProgramSelector { private static final String DFU_SWITCH = "Switch to DFU Mode"; private static final String DFU_ERASE = "Full Chip Erase"; private static final String ST_LINK = "ST-LINK Update"; + private static final String OPENBLT_CAN = "OpenBLT via CAN"; + public static final boolean IS_WIN = System.getProperty("os.name").toLowerCase().contains("win"); private static final String HELP = "https://github.com/rusefi/rusefi/wiki/HOWTO-Update-Firmware"; @@ -38,6 +43,7 @@ public class ProgramSelector { mode.addItem(MANUAL_DFU); mode.addItem(DFU_ERASE); mode.addItem(ST_LINK); + mode.addItem(OPENBLT_CAN); } mode.addItem(DFU_SWITCH); @@ -76,6 +82,8 @@ public class ProgramSelector { String port = selected == null ? PortDetector.AUTO : selected.toString(); DfuFlasher.rebootToDfu(comboPorts, port, wnd); break; + case OPENBLT_CAN: + flashOpenBltCan(); case DFU_ERASE: DfuFlasher.runDfuErase(); break; @@ -87,6 +95,18 @@ public class ProgramSelector { } + private void flashOpenBltCan() { + StatusWindow wnd = new StatusWindow(); + wnd.showFrame(appendBundleName("OpenBLT via CAN " + Launcher.CONSOLE_VERSION)); + ExecHelper.submitAction(() -> { + ExecHelper.executeCommand(Launcher.TOOLS_PATH + File.separator + "openblt", + "BootCommander.exe -s=xcp -t=xcp_can -d=peak_pcanusb -t1=1000 -t3=2000 -t4=10000 -t5=1000 -t7=2000 ../../rusefi_update.srec", + "BootCommander.exe", wnd, new StringBuffer()); + // it's a lengthy operation let's signal end + Toolkit.getDefaultToolkit().beep(); + }, "OpenBLT via CAN"); + } + @NotNull public static JComponent createHelpButton() { return new URLLabel("HOWTO Update Firmware", HELP);