diff --git a/firmware/flash_dfu.bat b/firmware/flash_dfu.bat index 20a5ee80e0..4f35e6c134 100644 --- a/firmware/flash_dfu.bat +++ b/firmware/flash_dfu.bat @@ -5,7 +5,7 @@ rem ..\misc\encedo_hex2dfu\hex2dfu.exe -i build/rusefi.hex -o build/rusefi.dfu rem on linux that would be rem dfu-util -a 0 -D rusefi_no_asserts.dfu -R -DfuSeCommand.exe -c -d --fn build/rusefi.dfu +DfuSeCommand.exe -c -d --fn deliver/rusefi.dfu rem to read from comtroller use rem DfuSeCommand.exe -c -u --fn downloaded.dfu diff --git a/java_console/inifile/src/main/java/com/opensr5/ini/IniFileModel.java b/java_console/inifile/src/main/java/com/opensr5/ini/IniFileModel.java index debd001b61..c62f81dd1e 100644 --- a/java_console/inifile/src/main/java/com/opensr5/ini/IniFileModel.java +++ b/java_console/inifile/src/main/java/com/opensr5/ini/IniFileModel.java @@ -1,5 +1,6 @@ package com.opensr5.ini; +import com.devexperts.logging.Logging; import com.opensr5.ini.field.*; import org.jetbrains.annotations.Nullable; @@ -11,6 +12,7 @@ import java.util.*; * 12/23/2015. */ public class IniFileModel { + private static final Logging log = Logging.getLogging(IniFileModel.class); public static final String RUSEFI_INI_PREFIX = "rusefi"; public static final String RUSEFI_INI_SUFFIX = ".ini"; public static final String INI_FILE_PATH = System.getProperty("ini_file_path", ".."); @@ -32,7 +34,7 @@ public class IniFileModel { public Map tooltips = new TreeMap<>(); public static void main(String[] args) { - System.out.println(IniFileModel.getInstance().dialogs); + log.info("Dialogs: " + IniFileModel.getInstance().dialogs); } private boolean isInSettingContextHelp = false; @@ -48,11 +50,11 @@ public class IniFileModel { if (fileName != null) input = new File(fileName); if (fileName == null || !input.exists()) { - System.out.println("No such file: " + fileName); + log.error("No such file: " + fileName); return null; } - System.out.println("Reading " + fileName); + log.info("Reading " + fileName); RawIniFile content = IniFileReader.read(input); readIniFile(content); @@ -76,6 +78,7 @@ public class IniFileModel { File dir = new File(fileDirectory); if (!dir.isDirectory()) return null; + log.info("Searching for " + prefix + "*" + suffix + " in " + fileDirectory); for (String file : dir.list()) { if (file.startsWith(prefix) && file.endsWith(suffix)) return fileDirectory + File.separator + file; @@ -176,7 +179,7 @@ public class IniFileModel { allFields.put(key, field); } fieldsOfCurrentDialog.add(field); - System.out.println("IniFileModel: Field label=[" + uiFieldName + "] : key=[" + key + "]"); + log.debug("IniFileModel: Field label=[" + uiFieldName + "] : key=[" + key + "]"); } public Map getAllFields() { @@ -198,7 +201,7 @@ public class IniFileModel { dialogId = keyword; dialogUiName = name; - System.out.println("IniFileModel: Dialog key=" + keyword + ": name=[" + name + "]"); + log.debug("IniFileModel: Dialog key=" + keyword + ": name=[" + name + "]"); } private void trim(LinkedList list) { diff --git a/java_console/inifile/src/main/java/com/rusefi/tune/xml/Msq.java b/java_console/inifile/src/main/java/com/rusefi/tune/xml/Msq.java index 778a762e81..1c0a590b69 100644 --- a/java_console/inifile/src/main/java/com/rusefi/tune/xml/Msq.java +++ b/java_console/inifile/src/main/java/com/rusefi/tune/xml/Msq.java @@ -69,6 +69,9 @@ public class Msq { public void writeXmlFile(String outputXmlFileName) throws JAXBException, IOException { Objects.requireNonNull(versionInfo, "versionInfo"); versionInfo.validate(); + Page page = findPage(); + if (page.constant.isEmpty()) + throw new IllegalStateException("No data?"); XmlUtil.writeXml(this, Msq.class, outputXmlFileName); } diff --git a/java_console/io/src/main/java/com/rusefi/binaryprotocol/BinaryProtocol.java b/java_console/io/src/main/java/com/rusefi/binaryprotocol/BinaryProtocol.java index 37bf3d93f4..4e46ad07eb 100644 --- a/java_console/io/src/main/java/com/rusefi/binaryprotocol/BinaryProtocol.java +++ b/java_console/io/src/main/java/com/rusefi/binaryprotocol/BinaryProtocol.java @@ -479,7 +479,7 @@ public class BinaryProtocol implements BinaryProtocolCommands { } } - public void burn(Logger logger) throws InterruptedException, EOFException { + public void burn(Logger logger) { if (!isBurnPending) return; logger.info("Need to burn"); diff --git a/java_console/ui/src/main/java/com/rusefi/tools/ConsoleTools.java b/java_console/ui/src/main/java/com/rusefi/tools/ConsoleTools.java index 742058828a..0733fa0cbc 100644 --- a/java_console/ui/src/main/java/com/rusefi/tools/ConsoleTools.java +++ b/java_console/ui/src/main/java/com/rusefi/tools/ConsoleTools.java @@ -34,6 +34,7 @@ import java.io.IOException; import java.util.Arrays; import java.util.Map; import java.util.TreeMap; +import java.util.function.Function; import static com.rusefi.binaryprotocol.BinaryProtocol.sleep; import static com.rusefi.binaryprotocol.IoHelper.getCrc32; @@ -49,7 +50,7 @@ public class ConsoleTools { registerTool("help", args -> printTools(), "Print this help."); registerTool("headless", ConsoleTools::runHeadless, "Connect to rusEFI controller and start saving logs."); - registerTool("ptrace_enums", ConsoleTools::runPerfTraceTool, "NOT A USER TOOL. Development tool to process pefrormance trace enums"); + registerTool("ptrace_enums", ConsoleTools::runPerfTraceTool, "NOT A USER TOOL. Development tool to process performance trace enums"); registerTool("firing_order", ConsoleTools::runFiringOrderTool, "NOT A USER TOOL. Development tool relating to adding new firing order into rusEFI firmware."); registerTool("functional_test", ConsoleTools::runFunctionalTest, "NOT A USER TOOL. Development tool related to functional testing"); registerTool("convert_binary_configuration_to_xml", ConsoleTools::convertBinaryToXml, "NOT A USER TOOL. Development tool to convert binary configuration into XML form."); @@ -65,7 +66,9 @@ public class ConsoleTools { registerTool("print_auth_token", args -> printAuthToken(), "Print current rusEFI Online authentication token."); registerTool(SET_AUTH_TOKEN, ConsoleTools::setAuthToken, "Set rusEFI authentication token."); - registerTool("upload_tune", ConsoleTools::uploadTune, "Upload specified tune file using auth token from settings"); + registerTool("upload_tune", ConsoleTools::uploadTune, "Upload specified tune file to rusEFI Online using auth token from settings"); + + registerTool("read_tune", strings1 -> readTune(), "Read tune from controller"); registerTool("version", ConsoleTools::version, "Only print version"); @@ -117,7 +120,7 @@ public class ConsoleTools { LightweightGUI.start(); } - private static void uploadTune(String[] args) throws IOException { + private static void uploadTune(String[] args) { String fileName = args[1]; String authToken = AuthTokenPanel.getAuthToken(); System.out.println("Trying to upload " + fileName + " using " + authToken); @@ -200,6 +203,14 @@ public class ConsoleTools { } }); + startAndConnect(linkManager -> { + new BinaryProtocolServer().start(linkManager); + return null; + }); + } + + private static void startAndConnect(final Function onConnectionEstablished) { + String autoDetectedPort = PortDetector.autoDetectSerial(null); if (autoDetectedPort == null) { System.err.println(RUS_EFI_NOT_DETECTED); @@ -209,7 +220,7 @@ public class ConsoleTools { linkManager.startAndConnect(autoDetectedPort, new ConnectionStateListener() { @Override public void onConnectionEstablished() { - new BinaryProtocolServer().start(linkManager); + onConnectionEstablished.apply(linkManager); } @Override @@ -219,6 +230,14 @@ public class ConsoleTools { }); } + private static void readTune() { + startAndConnect(linkManager -> { + System.out.println("Loaded! Exiting");; + System.exit(0); + return null; + }); + } + private static void invokeCallback(String callback) { if (callback == null) return; diff --git a/java_console/ui/src/test/java/com/rusefi/io/BinaryProtocolServerSandbox.java b/java_console/ui/src/test/java/com/rusefi/io/BinaryProtocolServerSandbox.java index 3cd98c65af..04fc02d5b3 100644 --- a/java_console/ui/src/test/java/com/rusefi/io/BinaryProtocolServerSandbox.java +++ b/java_console/ui/src/test/java/com/rusefi/io/BinaryProtocolServerSandbox.java @@ -5,6 +5,9 @@ import com.rusefi.binaryprotocol.BinaryProtocolState; import com.rusefi.config.generated.Fields; import com.rusefi.io.tcp.BinaryProtocolServer; +/** + * Starts a fake device with TCP connector at {@link BinaryProtocolServer#DEFAULT_PROXY_PORT} port + */ class BinaryProtocolServerSandbox { public static void main(String[] args) { BinaryProtocolState state = new BinaryProtocolState(); diff --git a/java_tools/ts_plugin/src/main/java/com/rusefi/ts_plugin/RemoteTab.java b/java_tools/ts_plugin/src/main/java/com/rusefi/ts_plugin/RemoteTab.java index c5a1d57eb4..74252b6dd5 100644 --- a/java_tools/ts_plugin/src/main/java/com/rusefi/ts_plugin/RemoteTab.java +++ b/java_tools/ts_plugin/src/main/java/com/rusefi/ts_plugin/RemoteTab.java @@ -211,6 +211,7 @@ public class RemoteTab { AtomicReference serverHolderAtomicReference = new AtomicReference<>(); TcpIoStream.DisconnectListener disconnectListener = message -> SwingUtilities.invokeLater(() -> { + System.out.println("Disconnected " + message); setStatus("Disconnected"); RemoteTabController.INSTANCE.setState(RemoteTabController.State.NOT_CONNECTED); ServerSocketReference serverHolder = serverHolderAtomicReference.get();