From 0c8785d7d3518f27349d858670de337676981589 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Thu, 15 Feb 2024 13:03:53 -0500 Subject: [PATCH] Empty PERF_TRACE response --- .../main/java/com/rusefi/PerformanceTraceHelper.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/java_console/ui/src/main/java/com/rusefi/PerformanceTraceHelper.java b/java_console/ui/src/main/java/com/rusefi/PerformanceTraceHelper.java index a93fce10e2..4b14a1c734 100644 --- a/java_console/ui/src/main/java/com/rusefi/PerformanceTraceHelper.java +++ b/java_console/ui/src/main/java/com/rusefi/PerformanceTraceHelper.java @@ -17,7 +17,8 @@ import static com.rusefi.tools.ConsoleTools.startAndConnect; public class PerformanceTraceHelper { public static void grabPerformanceTrace(JComponent parent, BinaryProtocol bp) { if (bp == null) { - JOptionPane.showMessageDialog(parent, "Failed to locate serial ports"); + String msg = "Failed to locate serial ports"; + JOptionPane.showMessageDialog(parent, msg, msg, JOptionPane.ERROR_MESSAGE); return; } bp.executeCommand(Fields.TS_PERF_TRACE_BEGIN, "begin trace"); @@ -30,11 +31,14 @@ public class PerformanceTraceHelper { throw new IllegalStateException("Unexpected packet, length=" + (packet != null ? 0 : packet.length)); List data = Entry.parseBuffer(packet); - + if (data.isEmpty()) { + String msg = "Empty PERF_TRACE response"; + JOptionPane.showMessageDialog(parent, msg, msg, JOptionPane.ERROR_MESSAGE); + return; + } int rpm = RpmModel.getInstance().getValue(); String fileName = FileLog.getDate() + "_rpm_" + rpm + "_rusEFI_trace" + ".json"; - JsonOutput.writeToStream(data, new FileOutputStream(fileName)); } catch (IOException | InterruptedException e1) { throw new IllegalStateException(e1);