get_performance_trace automation
This commit is contained in:
parent
f1d952b54b
commit
aacb5184ad
|
@ -0,0 +1,5 @@
|
|||
rem
|
||||
rem auto-detects connected running rusEfi serial port and downloads performance trace
|
||||
rem
|
||||
|
||||
java -jar ../java_console_binary/rusefi_console.jar get_performance_trace
|
|
@ -6,7 +6,7 @@ import java.net.URL;
|
|||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class rusEFIVersion {
|
||||
public static final int CONSOLE_VERSION = 20201001;
|
||||
public static final int CONSOLE_VERSION = 20201004;
|
||||
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
||||
|
||||
public static long classBuildTimeMillis() {
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
package com.rusefi;
|
||||
|
||||
import com.opensr5.Logger;
|
||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||
import com.rusefi.config.generated.Fields;
|
||||
import com.rusefi.tracing.Entry;
|
||||
import com.rusefi.tracing.JsonOutput;
|
||||
import com.rusefi.ui.MessagesView;
|
||||
import com.rusefi.ui.RpmModel;
|
||||
import com.rusefi.ui.UIContext;
|
||||
import com.rusefi.ui.util.UiUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -15,13 +11,8 @@ import javax.swing.*;
|
|||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static com.rusefi.CommandControl.TEST;
|
||||
import static com.rusefi.binaryprotocol.BinaryProtocolCommands.RESPONSE_OK;
|
||||
import static com.rusefi.binaryprotocol.IoHelper.checkResponseCode;
|
||||
|
||||
public class BenchTestPane {
|
||||
private final JPanel content = new JPanel(new GridLayout(2, 5));
|
||||
|
@ -62,25 +53,7 @@ public class BenchTestPane {
|
|||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
BinaryProtocol bp = uiContext.getLinkManager().getCurrentStreamState();
|
||||
bp.executeCommand(new byte[]{Fields.TS_PERF_TRACE_BEGIN}, "begin trace");
|
||||
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
|
||||
byte[] packet = bp.executeCommand(new byte[]{Fields.TS_PERF_TRACE_GET_BUFFER}, "get trace", true);
|
||||
if (!checkResponseCode(packet, RESPONSE_OK) || ((packet.length - 1) % 8) != 0)
|
||||
throw new IllegalStateException("Unexpected packet");
|
||||
|
||||
List<Entry> data = Entry.parseBuffer(packet);
|
||||
|
||||
int rpm = RpmModel.getInstance().getValue();
|
||||
String fileName = Logger.getDate() + "_rpm_" + rpm + "_rusEFI_trace" + ".json";
|
||||
|
||||
|
||||
JsonOutput.writeToStream(data, new FileOutputStream(fileName));
|
||||
} catch (IOException | InterruptedException e1) {
|
||||
throw new IllegalStateException(e1);
|
||||
}
|
||||
PerformanceTraceHelper.grabPerformanceTrace(bp);
|
||||
}
|
||||
});
|
||||
return UiUtils.wrap(button);
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
package com.rusefi;
|
||||
|
||||
import com.opensr5.ConfigurationImage;
|
||||
import com.opensr5.Logger;
|
||||
import com.opensr5.ini.IniFileModel;
|
||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||
import com.rusefi.config.generated.Fields;
|
||||
import com.rusefi.tracing.Entry;
|
||||
import com.rusefi.tracing.JsonOutput;
|
||||
import com.rusefi.ui.RpmModel;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static com.rusefi.binaryprotocol.BinaryProtocolCommands.RESPONSE_OK;
|
||||
import static com.rusefi.binaryprotocol.IoHelper.checkResponseCode;
|
||||
import static com.rusefi.tools.ConsoleTools.startAndConnect;
|
||||
|
||||
public class PerformanceTraceHelper {
|
||||
public static void grabPerformanceTrace(BinaryProtocol bp) {
|
||||
bp.executeCommand(new byte[]{Fields.TS_PERF_TRACE_BEGIN}, "begin trace");
|
||||
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
|
||||
byte[] packet = bp.executeCommand(new byte[]{Fields.TS_PERF_TRACE_GET_BUFFER}, "get trace", true);
|
||||
if (!checkResponseCode(packet, RESPONSE_OK) || ((packet.length - 1) % 8) != 0)
|
||||
throw new IllegalStateException("Unexpected packet");
|
||||
|
||||
List<Entry> data = Entry.parseBuffer(packet);
|
||||
|
||||
int rpm = RpmModel.getInstance().getValue();
|
||||
String fileName = Logger.getDate() + "_rpm_" + rpm + "_rusEFI_trace" + ".json";
|
||||
|
||||
|
||||
JsonOutput.writeToStream(data, new FileOutputStream(fileName));
|
||||
} catch (IOException | InterruptedException e1) {
|
||||
throw new IllegalStateException(e1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void getPerformanceTune() {
|
||||
startAndConnect(linkManager -> {
|
||||
BinaryProtocol binaryProtocol = linkManager.getConnector().getBinaryProtocol();
|
||||
grabPerformanceTrace(binaryProtocol);
|
||||
System.exit(0);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
|
@ -71,6 +71,7 @@ public class ConsoleTools {
|
|||
|
||||
registerTool("read_tune", args -> readTune(), "Read tune from controller");
|
||||
registerTool("write_tune", ConsoleTools::writeTune, "Write specified XML tune into controller");
|
||||
registerTool("get_performance_trace", args -> PerformanceTraceHelper.getPerformanceTune(), "DEV TOOL: Get performance trace from ECU");
|
||||
|
||||
registerTool("version", ConsoleTools::version, "Only print version");
|
||||
|
||||
|
@ -216,7 +217,7 @@ public class ConsoleTools {
|
|||
});
|
||||
}
|
||||
|
||||
private static void startAndConnect(final Function<LinkManager, Void> onConnectionEstablished) {
|
||||
public static void startAndConnect(final Function<LinkManager, Void> onConnectionEstablished) {
|
||||
|
||||
String autoDetectedPort = PortDetector.autoDetectSerial(null);
|
||||
if (autoDetectedPort == null) {
|
||||
|
|
Loading…
Reference in New Issue