parent
9b761b438c
commit
dea9e4f24e
|
@ -3,6 +3,7 @@ package com.rusefi;
|
|||
import com.rusefi.common.MiscTest;
|
||||
import com.rusefi.f4discovery.CompositeLoggerTest;
|
||||
import com.rusefi.f4discovery.HighRevTest;
|
||||
import com.rusefi.f4discovery.PTraceTest;
|
||||
import com.rusefi.proteus.ProteusAnalogTest;
|
||||
|
||||
/**
|
||||
|
@ -11,6 +12,7 @@ import com.rusefi.proteus.ProteusAnalogTest;
|
|||
public class HwCiProteus {
|
||||
public static void main(String[] args) {
|
||||
CmdJUnitRunner.runHardwareTestAndExit(new Class[]{
|
||||
PTraceTest.class,
|
||||
CompositeLoggerTest.class,
|
||||
HighRevTest.class,
|
||||
MiscTest.class,
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package com.rusefi.f4discovery;
|
||||
|
||||
import com.rusefi.RusefiTestBase;
|
||||
import com.rusefi.io.LinkManager;
|
||||
import com.rusefi.io.commands.PTraceHelper;
|
||||
import com.rusefi.tracing.Entry;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class PTraceTest extends RusefiTestBase {
|
||||
@Test
|
||||
public void assertPTrace() throws InterruptedException {
|
||||
LinkManager linkManager = ecu.getLinkManager();
|
||||
AtomicReference<List<Entry>> result = new AtomicReference<>();
|
||||
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
linkManager.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
result.set(PTraceHelper.requestWaitAndGetPTrace(linkManager.getBinaryProtocol()));
|
||||
latch.countDown();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
latch.await(30, TimeUnit.SECONDS);
|
||||
List<Entry> entries = result.get();
|
||||
assertTrue(entries != null && !entries.isEmpty());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.rusefi.io.commands;
|
||||
|
||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||
import com.rusefi.config.generated.Fields;
|
||||
import com.rusefi.tracing.Entry;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.rusefi.binaryprotocol.IoHelper.checkResponseCode;
|
||||
|
||||
public class PTraceHelper {
|
||||
@NotNull
|
||||
public static List<Entry> requestWaitAndGetPTrace(BinaryProtocol bp) {
|
||||
bp.executeCommand(Fields.TS_PERF_TRACE_BEGIN, "begin trace");
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
||||
return executeGetPTraceCommand(bp);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<Entry> executeGetPTraceCommand(BinaryProtocol bp) {
|
||||
byte[] packet = bp.executeCommand(Fields.TS_PERF_TRACE_GET_BUFFER, "get trace");
|
||||
if (!checkResponseCode(packet, (byte) Fields.TS_RESPONSE_OK) || ((packet.length - 1) % 8) != 0)
|
||||
throw new IllegalStateException("Unexpected packet, length=" + (packet != null ? 0 : packet.length));
|
||||
|
||||
return Entry.parseBuffer(packet);
|
||||
}
|
||||
}
|
|
@ -1,19 +1,17 @@
|
|||
package com.rusefi;
|
||||
|
||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||
import com.rusefi.config.generated.Fields;
|
||||
import com.rusefi.core.MessagesCentral;
|
||||
import com.rusefi.io.commands.PTraceHelper;
|
||||
import com.rusefi.tracing.Entry;
|
||||
import com.rusefi.tracing.JsonOutput;
|
||||
import com.rusefi.ui.RpmModel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static com.rusefi.binaryprotocol.IoHelper.checkResponseCode;
|
||||
import static com.rusefi.tools.ConsoleTools.startAndConnect;
|
||||
|
||||
public class PerformanceTraceHelper {
|
||||
|
@ -25,7 +23,7 @@ public class PerformanceTraceHelper {
|
|||
}
|
||||
|
||||
try {
|
||||
List<Entry> data = requestWaitAndGetPTrace(bp);
|
||||
List<Entry> data = PTraceHelper.requestWaitAndGetPTrace(bp);
|
||||
if (data.isEmpty()) {
|
||||
String msg = "Empty PERF_TRACE response";
|
||||
JOptionPane.showMessageDialog(parent, msg, msg, JOptionPane.ERROR_MESSAGE);
|
||||
|
@ -41,27 +39,6 @@ public class PerformanceTraceHelper {
|
|||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<Entry> requestWaitAndGetPTrace(BinaryProtocol bp) {
|
||||
bp.executeCommand(Fields.TS_PERF_TRACE_BEGIN, "begin trace");
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
||||
return executeGetPTraceCommand(bp);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<Entry> executeGetPTraceCommand(BinaryProtocol bp) {
|
||||
byte[] packet = bp.executeCommand(Fields.TS_PERF_TRACE_GET_BUFFER, "get trace");
|
||||
if (!checkResponseCode(packet, (byte) Fields.TS_RESPONSE_OK) || ((packet.length - 1) % 8) != 0)
|
||||
throw new IllegalStateException("Unexpected packet, length=" + (packet != null ? 0 : packet.length));
|
||||
|
||||
return Entry.parseBuffer(packet);
|
||||
}
|
||||
|
||||
public static void getPerformanceTune() {
|
||||
startAndConnect(linkManager -> {
|
||||
BinaryProtocol binaryProtocol = linkManager.getConnector().getBinaryProtocol();
|
||||
|
|
Loading…
Reference in New Issue