new command line tool: read_tune

This commit is contained in:
rusefi 2020-07-29 19:25:25 -04:00
parent 950acff11b
commit 7e646d74d9
7 changed files with 40 additions and 11 deletions

View File

@ -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

View File

@ -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<String, String> 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<String, DialogModel.Field> 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<String> list) {

View File

@ -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);
}

View File

@ -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");

View File

@ -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<LinkManager, Void> 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;

View File

@ -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();

View File

@ -211,6 +211,7 @@ public class RemoteTab {
AtomicReference<ServerSocketReference> 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();