new command line tool: read_tune
This commit is contained in:
parent
950acff11b
commit
7e646d74d9
|
@ -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 on linux that would be
|
||||||
rem dfu-util -a 0 -D rusefi_no_asserts.dfu -R
|
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 to read from comtroller use
|
||||||
rem DfuSeCommand.exe -c -u --fn downloaded.dfu
|
rem DfuSeCommand.exe -c -u --fn downloaded.dfu
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.opensr5.ini;
|
package com.opensr5.ini;
|
||||||
|
|
||||||
|
import com.devexperts.logging.Logging;
|
||||||
import com.opensr5.ini.field.*;
|
import com.opensr5.ini.field.*;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
@ -11,6 +12,7 @@ import java.util.*;
|
||||||
* 12/23/2015.
|
* 12/23/2015.
|
||||||
*/
|
*/
|
||||||
public class IniFileModel {
|
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_PREFIX = "rusefi";
|
||||||
public static final String RUSEFI_INI_SUFFIX = ".ini";
|
public static final String RUSEFI_INI_SUFFIX = ".ini";
|
||||||
public static final String INI_FILE_PATH = System.getProperty("ini_file_path", "..");
|
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 Map<String, String> tooltips = new TreeMap<>();
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println(IniFileModel.getInstance().dialogs);
|
log.info("Dialogs: " + IniFileModel.getInstance().dialogs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isInSettingContextHelp = false;
|
private boolean isInSettingContextHelp = false;
|
||||||
|
@ -48,11 +50,11 @@ public class IniFileModel {
|
||||||
if (fileName != null)
|
if (fileName != null)
|
||||||
input = new File(fileName);
|
input = new File(fileName);
|
||||||
if (fileName == null || !input.exists()) {
|
if (fileName == null || !input.exists()) {
|
||||||
System.out.println("No such file: " + fileName);
|
log.error("No such file: " + fileName);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Reading " + fileName);
|
log.info("Reading " + fileName);
|
||||||
RawIniFile content = IniFileReader.read(input);
|
RawIniFile content = IniFileReader.read(input);
|
||||||
|
|
||||||
readIniFile(content);
|
readIniFile(content);
|
||||||
|
@ -76,6 +78,7 @@ public class IniFileModel {
|
||||||
File dir = new File(fileDirectory);
|
File dir = new File(fileDirectory);
|
||||||
if (!dir.isDirectory())
|
if (!dir.isDirectory())
|
||||||
return null;
|
return null;
|
||||||
|
log.info("Searching for " + prefix + "*" + suffix + " in " + fileDirectory);
|
||||||
for (String file : dir.list()) {
|
for (String file : dir.list()) {
|
||||||
if (file.startsWith(prefix) && file.endsWith(suffix))
|
if (file.startsWith(prefix) && file.endsWith(suffix))
|
||||||
return fileDirectory + File.separator + file;
|
return fileDirectory + File.separator + file;
|
||||||
|
@ -176,7 +179,7 @@ public class IniFileModel {
|
||||||
allFields.put(key, field);
|
allFields.put(key, field);
|
||||||
}
|
}
|
||||||
fieldsOfCurrentDialog.add(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() {
|
public Map<String, DialogModel.Field> getAllFields() {
|
||||||
|
@ -198,7 +201,7 @@ public class IniFileModel {
|
||||||
|
|
||||||
dialogId = keyword;
|
dialogId = keyword;
|
||||||
dialogUiName = name;
|
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) {
|
private void trim(LinkedList<String> list) {
|
||||||
|
|
|
@ -69,6 +69,9 @@ public class Msq {
|
||||||
public void writeXmlFile(String outputXmlFileName) throws JAXBException, IOException {
|
public void writeXmlFile(String outputXmlFileName) throws JAXBException, IOException {
|
||||||
Objects.requireNonNull(versionInfo, "versionInfo");
|
Objects.requireNonNull(versionInfo, "versionInfo");
|
||||||
versionInfo.validate();
|
versionInfo.validate();
|
||||||
|
Page page = findPage();
|
||||||
|
if (page.constant.isEmpty())
|
||||||
|
throw new IllegalStateException("No data?");
|
||||||
XmlUtil.writeXml(this, Msq.class, outputXmlFileName);
|
XmlUtil.writeXml(this, Msq.class, outputXmlFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -479,7 +479,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void burn(Logger logger) throws InterruptedException, EOFException {
|
public void burn(Logger logger) {
|
||||||
if (!isBurnPending)
|
if (!isBurnPending)
|
||||||
return;
|
return;
|
||||||
logger.info("Need to burn");
|
logger.info("Need to burn");
|
||||||
|
|
|
@ -34,6 +34,7 @@ import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
import static com.rusefi.binaryprotocol.BinaryProtocol.sleep;
|
import static com.rusefi.binaryprotocol.BinaryProtocol.sleep;
|
||||||
import static com.rusefi.binaryprotocol.IoHelper.getCrc32;
|
import static com.rusefi.binaryprotocol.IoHelper.getCrc32;
|
||||||
|
@ -49,7 +50,7 @@ public class ConsoleTools {
|
||||||
registerTool("help", args -> printTools(), "Print this help.");
|
registerTool("help", args -> printTools(), "Print this help.");
|
||||||
registerTool("headless", ConsoleTools::runHeadless, "Connect to rusEFI controller and start saving logs.");
|
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("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("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.");
|
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("print_auth_token", args -> printAuthToken(), "Print current rusEFI Online authentication token.");
|
||||||
registerTool(SET_AUTH_TOKEN, ConsoleTools::setAuthToken, "Set rusEFI 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");
|
registerTool("version", ConsoleTools::version, "Only print version");
|
||||||
|
|
||||||
|
@ -117,7 +120,7 @@ public class ConsoleTools {
|
||||||
LightweightGUI.start();
|
LightweightGUI.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void uploadTune(String[] args) throws IOException {
|
private static void uploadTune(String[] args) {
|
||||||
String fileName = args[1];
|
String fileName = args[1];
|
||||||
String authToken = AuthTokenPanel.getAuthToken();
|
String authToken = AuthTokenPanel.getAuthToken();
|
||||||
System.out.println("Trying to upload " + fileName + " using " + authToken);
|
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);
|
String autoDetectedPort = PortDetector.autoDetectSerial(null);
|
||||||
if (autoDetectedPort == null) {
|
if (autoDetectedPort == null) {
|
||||||
System.err.println(RUS_EFI_NOT_DETECTED);
|
System.err.println(RUS_EFI_NOT_DETECTED);
|
||||||
|
@ -209,7 +220,7 @@ public class ConsoleTools {
|
||||||
linkManager.startAndConnect(autoDetectedPort, new ConnectionStateListener() {
|
linkManager.startAndConnect(autoDetectedPort, new ConnectionStateListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onConnectionEstablished() {
|
public void onConnectionEstablished() {
|
||||||
new BinaryProtocolServer().start(linkManager);
|
onConnectionEstablished.apply(linkManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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) {
|
private static void invokeCallback(String callback) {
|
||||||
if (callback == null)
|
if (callback == null)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -5,6 +5,9 @@ import com.rusefi.binaryprotocol.BinaryProtocolState;
|
||||||
import com.rusefi.config.generated.Fields;
|
import com.rusefi.config.generated.Fields;
|
||||||
import com.rusefi.io.tcp.BinaryProtocolServer;
|
import com.rusefi.io.tcp.BinaryProtocolServer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts a fake device with TCP connector at {@link BinaryProtocolServer#DEFAULT_PROXY_PORT} port
|
||||||
|
*/
|
||||||
class BinaryProtocolServerSandbox {
|
class BinaryProtocolServerSandbox {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
BinaryProtocolState state = new BinaryProtocolState();
|
BinaryProtocolState state = new BinaryProtocolState();
|
||||||
|
|
|
@ -211,6 +211,7 @@ public class RemoteTab {
|
||||||
AtomicReference<ServerSocketReference> serverHolderAtomicReference = new AtomicReference<>();
|
AtomicReference<ServerSocketReference> serverHolderAtomicReference = new AtomicReference<>();
|
||||||
|
|
||||||
TcpIoStream.DisconnectListener disconnectListener = message -> SwingUtilities.invokeLater(() -> {
|
TcpIoStream.DisconnectListener disconnectListener = message -> SwingUtilities.invokeLater(() -> {
|
||||||
|
System.out.println("Disconnected " + message);
|
||||||
setStatus("Disconnected");
|
setStatus("Disconnected");
|
||||||
RemoteTabController.INSTANCE.setState(RemoteTabController.State.NOT_CONNECTED);
|
RemoteTabController.INSTANCE.setState(RemoteTabController.State.NOT_CONNECTED);
|
||||||
ServerSocketReference serverHolder = serverHolderAtomicReference.get();
|
ServerSocketReference serverHolder = serverHolderAtomicReference.get();
|
||||||
|
|
Loading…
Reference in New Issue