perf trace button causes exception fix #3853
This commit is contained in:
parent
4c6e8e2776
commit
dca698720e
|
@ -6,7 +6,7 @@ import java.net.URL;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
public class rusEFIVersion {
|
public class rusEFIVersion {
|
||||||
public static final int CONSOLE_VERSION = 20220127;
|
public static final int CONSOLE_VERSION = 20220128;
|
||||||
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
||||||
|
|
||||||
public static long classBuildTimeMillis() {
|
public static long classBuildTimeMillis() {
|
||||||
|
|
|
@ -51,13 +51,11 @@ public class BenchTestPane {
|
||||||
|
|
||||||
private Component grabPerformanceTrace() {
|
private Component grabPerformanceTrace() {
|
||||||
JButton button = new JButton("Grab PTrace");
|
JButton button = new JButton("Grab PTrace");
|
||||||
button.addActionListener(new ActionListener() {
|
ActionListener actionListener = e -> uiContext.getLinkManager().COMMUNICATION_EXECUTOR.execute(() -> {
|
||||||
@Override
|
BinaryProtocol bp = uiContext.getLinkManager().getCurrentStreamState();
|
||||||
public void actionPerformed(ActionEvent e) {
|
PerformanceTraceHelper.grabPerformanceTrace(button, bp);
|
||||||
BinaryProtocol bp = uiContext.getLinkManager().getCurrentStreamState();
|
|
||||||
PerformanceTraceHelper.grabPerformanceTrace(bp);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
button.addActionListener(actionListener);
|
||||||
return UiUtils.wrap(button);
|
return UiUtils.wrap(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
package com.rusefi;
|
package com.rusefi;
|
||||||
|
|
||||||
import com.opensr5.ConfigurationImage;
|
|
||||||
import com.opensr5.Logger;
|
import com.opensr5.Logger;
|
||||||
import com.opensr5.ini.IniFileModel;
|
|
||||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||||
import com.rusefi.config.generated.Fields;
|
import com.rusefi.config.generated.Fields;
|
||||||
import com.rusefi.tracing.Entry;
|
import com.rusefi.tracing.Entry;
|
||||||
import com.rusefi.tracing.JsonOutput;
|
import com.rusefi.tracing.JsonOutput;
|
||||||
import com.rusefi.ui.RpmModel;
|
import com.rusefi.ui.RpmModel;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -17,7 +16,11 @@ import static com.rusefi.binaryprotocol.IoHelper.checkResponseCode;
|
||||||
import static com.rusefi.tools.ConsoleTools.startAndConnect;
|
import static com.rusefi.tools.ConsoleTools.startAndConnect;
|
||||||
|
|
||||||
public class PerformanceTraceHelper {
|
public class PerformanceTraceHelper {
|
||||||
public static void grabPerformanceTrace(BinaryProtocol bp) {
|
public static void grabPerformanceTrace(JComponent parent, BinaryProtocol bp) {
|
||||||
|
if (bp == null) {
|
||||||
|
JOptionPane.showMessageDialog(parent, "Failed to located serial ports");
|
||||||
|
return;
|
||||||
|
}
|
||||||
bp.executeCommand(new byte[]{Fields.TS_PERF_TRACE_BEGIN}, "begin trace");
|
bp.executeCommand(new byte[]{Fields.TS_PERF_TRACE_BEGIN}, "begin trace");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -25,7 +28,7 @@ public class PerformanceTraceHelper {
|
||||||
|
|
||||||
byte[] packet = bp.executeCommand(new byte[]{Fields.TS_PERF_TRACE_GET_BUFFER}, "get trace", true);
|
byte[] packet = bp.executeCommand(new byte[]{Fields.TS_PERF_TRACE_GET_BUFFER}, "get trace", true);
|
||||||
if (!checkResponseCode(packet, (byte) Fields.TS_RESPONSE_OK) || ((packet.length - 1) % 8) != 0)
|
if (!checkResponseCode(packet, (byte) Fields.TS_RESPONSE_OK) || ((packet.length - 1) % 8) != 0)
|
||||||
throw new IllegalStateException("Unexpected packet");
|
throw new IllegalStateException("Unexpected packet, length=" + (packet != null ? 0 : packet.length));
|
||||||
|
|
||||||
List<Entry> data = Entry.parseBuffer(packet);
|
List<Entry> data = Entry.parseBuffer(packet);
|
||||||
|
|
||||||
|
@ -42,7 +45,7 @@ public class PerformanceTraceHelper {
|
||||||
public static void getPerformanceTune() {
|
public static void getPerformanceTune() {
|
||||||
startAndConnect(linkManager -> {
|
startAndConnect(linkManager -> {
|
||||||
BinaryProtocol binaryProtocol = linkManager.getConnector().getBinaryProtocol();
|
BinaryProtocol binaryProtocol = linkManager.getConnector().getBinaryProtocol();
|
||||||
grabPerformanceTrace(binaryProtocol);
|
grabPerformanceTrace(null, binaryProtocol);
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue