new command line tool works now!
This commit is contained in:
parent
02d4515b53
commit
ce17e945b1
|
@ -0,0 +1,11 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Launcher save_binary_configuration" type="Application" factoryName="Application">
|
||||
<option name="MAIN_CLASS_NAME" value="com.rusefi.Launcher" />
|
||||
<module name="ui" />
|
||||
<option name="PROGRAM_PARAMETERS" value="save_binary_configuration rusefi_configuration.image" />
|
||||
<option name="VM_PARAMETERS" value="-Dini_file_path=../firmware/tunerstudio -Dshow_etb_pane=true" />
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
|
@ -175,7 +175,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
|||
}
|
||||
|
||||
public void uploadChanges(ConfigurationImage newVersion, Logger logger) throws InterruptedException, EOFException, SerialPortException {
|
||||
ConfigurationImage current = getController();
|
||||
ConfigurationImage current = getControllerConfiguration();
|
||||
// let's have our own copy which no one would be able to change
|
||||
newVersion = newVersion.clone();
|
||||
int offset = 0;
|
||||
|
@ -329,7 +329,10 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
|||
}
|
||||
}
|
||||
|
||||
public ConfigurationImage getController() {
|
||||
/**
|
||||
* Configuration as it is in the controller to the best of our knowledge
|
||||
*/
|
||||
public ConfigurationImage getControllerConfiguration() {
|
||||
synchronized (imageLock) {
|
||||
if (controller == null)
|
||||
return null;
|
||||
|
|
|
@ -134,12 +134,12 @@ public class LinkManager {
|
|||
public static boolean isSimulationMode;
|
||||
|
||||
public static void startAndConnect(String port, ConnectionStateListener stateListener) {
|
||||
FileLog.MAIN.logLine("LinkManager: Starting " + port);
|
||||
start(port);
|
||||
connect(stateListener);
|
||||
connector.connectAndReadConfiguration(stateListener);
|
||||
}
|
||||
|
||||
public static void start(String port) {
|
||||
FileLog.MAIN.logLine("LinkManager: Starting " + port);
|
||||
if (isLogViewerMode(port)) {
|
||||
connector = LinkConnector.VOID;
|
||||
} else if (TcpConnector.isTcpPort(port)) {
|
||||
|
@ -158,12 +158,6 @@ public class LinkManager {
|
|||
return connector == LinkConnector.VOID;
|
||||
}
|
||||
|
||||
public static void connect(ConnectionStateListener listener) {
|
||||
if (connector == null)
|
||||
throw new NullPointerException("connector");
|
||||
connector.connectAndReadConfiguration(listener);
|
||||
}
|
||||
|
||||
public static void send(String command, boolean fireEvent) throws InterruptedException {
|
||||
if (connector == null)
|
||||
throw new NullPointerException("connector");
|
||||
|
|
|
@ -112,7 +112,7 @@ public class BinaryProtocolServer implements BinaryProtocolCommands {
|
|||
short count = dis.readShort(); // no swap here? interesting!
|
||||
System.out.println("CRC check " + page + "/" + offset + "/" + count);
|
||||
BinaryProtocol bp = BinaryProtocolHolder.getInstance().getCurrentStreamState();
|
||||
int result = IoHelper.getCrc32(bp.getController().getContent(), offset, count);
|
||||
int result = IoHelper.getCrc32(bp.getControllerConfiguration().getContent(), offset, count);
|
||||
ByteArrayOutputStream response = new ByteArrayOutputStream();
|
||||
response.write(TS_OK.charAt(0));
|
||||
new DataOutputStream(response).write(result);
|
||||
|
@ -130,7 +130,7 @@ public class BinaryProtocolServer implements BinaryProtocolCommands {
|
|||
BinaryProtocol bp = BinaryProtocolHolder.getInstance().getCurrentStreamState();
|
||||
byte[] response = new byte[1 + count];
|
||||
response[0] = (byte) TS_OK.charAt(0);
|
||||
System.arraycopy(bp.getController().getContent(), offset, response, 1, count);
|
||||
System.arraycopy(bp.getControllerConfiguration().getContent(), offset, response, 1, count);
|
||||
stream.sendPacket(response, FileLog.LOGGER);
|
||||
}
|
||||
} else if (command == COMMAND_OUTPUTS) {
|
||||
|
|
|
@ -59,6 +59,7 @@ public class ConfigurationImageFile {
|
|||
}
|
||||
|
||||
public static void saveToFile(ConfigurationImage configurationImage, String fileName) throws IOException {
|
||||
System.out.printf("Saving " + configurationImage.getSize() + " bytes of configuration into " + fileName);
|
||||
FileOutputStream fos = new FileOutputStream(fileName);
|
||||
fos.write(getFileContent(configurationImage));
|
||||
fos.close();
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.rusefi.io.LinkManager;
|
|||
import com.rusefi.io.serial.BaudRateHolder;
|
||||
import com.rusefi.maintenance.FirmwareFlasher;
|
||||
import com.rusefi.maintenance.VersionChecker;
|
||||
import com.rusefi.tools.ConsoleTools;
|
||||
import com.rusefi.ui.FormulasPane;
|
||||
import com.rusefi.ui.GaugesPanel;
|
||||
import com.rusefi.ui.MessagesPane;
|
||||
|
@ -21,7 +22,6 @@ import com.rusefi.ui.logview.LogViewer;
|
|||
import com.rusefi.ui.util.DefaultExceptionHandler;
|
||||
import com.rusefi.ui.util.JustOneInstance;
|
||||
import jssc.SerialPortList;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
|
|
|
@ -151,7 +151,7 @@ public class SensorLogger {
|
|||
int debugMode = -1;
|
||||
BinaryProtocol bp = BinaryProtocolHolder.getInstance().getCurrentStreamState();
|
||||
if (bp != null) {
|
||||
ConfigurationImage ci = bp.getController();
|
||||
ConfigurationImage ci = bp.getControllerConfiguration();
|
||||
if (ci != null) {
|
||||
debugMode = ConfigField.getIntValue(ci, Fields.DEBUGMODE);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public class TableEditorPane extends JPanel {
|
|||
BinaryProtocol instance = BinaryProtocolHolder.getInstance().getCurrentStreamState();
|
||||
if (instance == null)
|
||||
throw new NullPointerException("instance");
|
||||
ConfigurationImage image = instance.getController();
|
||||
ConfigurationImage image = instance.getControllerConfiguration();
|
||||
byte[] fileContent = ConfigurationImageFile.getFileContent(image);
|
||||
ECUEditor.openImage(fileContent);
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -41,7 +41,7 @@ public class BinaryProtocolCmdSandbox {
|
|||
//
|
||||
// image.saveToFile("rusefi_configuration.bin");
|
||||
//
|
||||
doShowImage(bp.getController());
|
||||
doShowImage(bp.getControllerConfiguration());
|
||||
}
|
||||
|
||||
private static void doShowImage(ConfigurationImage image) throws Exception {
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package com.rusefi;
|
||||
package com.rusefi.tools;
|
||||
|
||||
import com.fathzer.soft.javaluator.DoubleEvaluator;
|
||||
import com.opensr5.ConfigurationImage;
|
||||
import com.opensr5.io.ConfigurationImageFile;
|
||||
import com.rusefi.*;
|
||||
import com.rusefi.autodetect.PortDetector;
|
||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||
import com.rusefi.config.generated.Fields;
|
||||
|
@ -15,6 +18,7 @@ import org.jetbrains.annotations.Nullable;
|
|||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class ConsoleTools {
|
||||
|
@ -39,20 +43,41 @@ public class ConsoleTools {
|
|||
}
|
||||
}
|
||||
|
||||
private static void saveBinaryConfig(String[] args) {
|
||||
private static void saveBinaryConfig(String[] args) throws IOException {
|
||||
if (args.length < 2) {
|
||||
System.out.println("Please specify output file name for binary configuration");
|
||||
System.exit(-1);
|
||||
}
|
||||
String fileName = args[1];
|
||||
|
||||
String autoDetectedPort = autoDetectPort();
|
||||
if (autoDetectedPort == null)
|
||||
return;
|
||||
LinkManager.startAndConnect(autoDetectedPort, ConnectionStateListener.VOID);
|
||||
LinkManager.startAndConnect(autoDetectedPort, new ConnectionStateListener() {
|
||||
@Override
|
||||
public void onConnectionEstablished() {
|
||||
BinaryProtocol binaryProtocol = LinkManager.connector.getBinaryProtocol();
|
||||
Objects.requireNonNull(binaryProtocol, "binaryProtocol");
|
||||
ConfigurationImage configurationImage = binaryProtocol.getControllerConfiguration();
|
||||
Objects.requireNonNull(configurationImage, "configurationImage");
|
||||
|
||||
try {
|
||||
ConfigurationImageFile.saveToFile(configurationImage, fileName);
|
||||
System.exit(0);
|
||||
} catch (IOException e) {
|
||||
System.out.println("While writing " + e);
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionFailed() {
|
||||
System.out.println("onConnectionFailed");
|
||||
System.exit(-1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private static void sendCommand(String command) throws IOException {
|
||||
String autoDetectedPort = autoDetectPort();
|
||||
if (autoDetectedPort == null)
|
||||
|
@ -156,7 +181,8 @@ public class ConsoleTools {
|
|||
consoleTool.runTool(args);
|
||||
return true;
|
||||
}
|
||||
return false; }
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String autoDetectPort() {
|
|
@ -108,7 +108,7 @@ public class FormulasPane {
|
|||
BinaryProtocol bp = BinaryProtocolHolder.getInstance().getCurrentStreamState();
|
||||
if (bp == null)
|
||||
return;
|
||||
ConfigurationImage ci = bp.getController();
|
||||
ConfigurationImage ci = bp.getControllerConfiguration();
|
||||
if (ci == null)
|
||||
return;
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ public class FuelTunePane {
|
|||
BinaryProtocol bp = BinaryProtocolHolder.getInstance().getCurrentStreamState();
|
||||
if (newVeMap == null || bp == null)
|
||||
return;
|
||||
ConfigurationImage ci = bp.getController().clone();
|
||||
ConfigurationImage ci = bp.getControllerConfiguration().clone();
|
||||
System.arraycopy(newVeMap, 0, ci.getContent(), Fields.VETABLE.getOffset(), newVeMap.length);
|
||||
Runnable afterBurn = new Runnable() {
|
||||
@Override
|
||||
|
@ -315,7 +315,7 @@ public class FuelTunePane {
|
|||
private byte[] reloadVeTable() {
|
||||
BinaryProtocol bp = BinaryProtocolHolder.getInstance().getCurrentStreamState();
|
||||
|
||||
byte[] content = bp.getController().getContent();
|
||||
byte[] content = bp.getControllerConfiguration().getContent();
|
||||
loadData(veTable.getXAxis(), content, veRpmOffset);
|
||||
loadData(veTable.getYAxis(), content, veLoadOffset);
|
||||
loadData(veTable, content, Fields.VETABLE.getOffset());
|
||||
|
@ -335,7 +335,7 @@ public class FuelTunePane {
|
|||
return;
|
||||
}
|
||||
for (int i = 0; i < array.length; i++)
|
||||
array[i] = bp.getController().getByteBuffer(offset + 4 * i, 4).getFloat();
|
||||
array[i] = bp.getControllerConfiguration().getByteBuffer(offset + 4 * i, 4).getFloat();
|
||||
System.out.println("FuelTunePane: Loaded " + Arrays.toString(array));
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ public abstract class BaseConfigField {
|
|||
BinaryProtocol bp = BinaryProtocolHolder.getInstance().getCurrentStreamState();
|
||||
if (bp == null)
|
||||
return;
|
||||
ConfigurationImage ci = bp.getController();
|
||||
ConfigurationImage ci = bp.getControllerConfiguration();
|
||||
if (ci == null)
|
||||
return;
|
||||
loadValue(ci);
|
||||
|
|
|
@ -102,7 +102,7 @@ public class LiveDocPanel {
|
|||
result.actionsListAdd(new LiveDataContext(Fields.LDS_ENGINE_STATE_INDEX), new RefreshActions() {
|
||||
@Override
|
||||
public void refresh(BinaryProtocol bp, byte[] response) {
|
||||
String value = field.getAnyValue(bp.getController()).toString();
|
||||
String value = field.getAnyValue(bp.getControllerConfiguration()).toString();
|
||||
label.setText(value);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue