perf trace button causes exception fix #3853

This commit is contained in:
rusefillc 2022-01-28 21:07:56 -05:00
parent 4c6e8e2776
commit dca698720e
3 changed files with 13 additions and 12 deletions

View File

@ -6,7 +6,7 @@ import java.net.URL;
import java.util.concurrent.atomic.AtomicReference;
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 long classBuildTimeMillis() {

View File

@ -51,13 +51,11 @@ public class BenchTestPane {
private Component grabPerformanceTrace() {
JButton button = new JButton("Grab PTrace");
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
BinaryProtocol bp = uiContext.getLinkManager().getCurrentStreamState();
PerformanceTraceHelper.grabPerformanceTrace(bp);
}
ActionListener actionListener = e -> uiContext.getLinkManager().COMMUNICATION_EXECUTOR.execute(() -> {
BinaryProtocol bp = uiContext.getLinkManager().getCurrentStreamState();
PerformanceTraceHelper.grabPerformanceTrace(button, bp);
});
button.addActionListener(actionListener);
return UiUtils.wrap(button);
}

View File

@ -1,14 +1,13 @@
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 javax.swing.*;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
@ -17,7 +16,11 @@ import static com.rusefi.binaryprotocol.IoHelper.checkResponseCode;
import static com.rusefi.tools.ConsoleTools.startAndConnect;
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");
try {
@ -25,7 +28,7 @@ public class PerformanceTraceHelper {
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)
throw new IllegalStateException("Unexpected packet");
throw new IllegalStateException("Unexpected packet, length=" + (packet != null ? 0 : packet.length));
List<Entry> data = Entry.parseBuffer(packet);
@ -42,7 +45,7 @@ public class PerformanceTraceHelper {
public static void getPerformanceTune() {
startAndConnect(linkManager -> {
BinaryProtocol binaryProtocol = linkManager.getConnector().getBinaryProtocol();
grabPerformanceTrace(binaryProtocol);
grabPerformanceTrace(null, binaryProtocol);
System.exit(0);
return null;
});