From 6642fd4312cfe3d886f4f64a98e5b4a5cf1f4897 Mon Sep 17 00:00:00 2001 From: rusefi Date: Thu, 28 May 2020 22:06:51 -0400 Subject: [PATCH] mostly refactoring very little progress --- .../rusefi/binaryprotocol/BinaryProtocol.java | 23 +++++++++++++++---- .../rusefi/ui/livedocs/LiveDocsRegistry.java | 2 +- .../ui/src/com/rusefi/BenchTestPane.java | 4 ++-- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java b/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java index b7ba19546f..9b6d027290 100644 --- a/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java +++ b/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java @@ -249,7 +249,7 @@ public class BinaryProtocol implements BinaryProtocolCommands { putShort(packet, 3, swap16(offset)); putShort(packet, 5, swap16(requestSize)); - byte[] response = executeCommand(packet, "load image offset=" + offset, false); + byte[] response = executeCommand(packet, "load image offset=" + offset); if (!checkResponseCode(response, RESPONSE_OK) || response.length != requestSize + 1) { String code = (response == null || response.length == 0) ? "empty" : "code " + response[0]; @@ -288,7 +288,7 @@ public class BinaryProtocol implements BinaryProtocolCommands { byte packet[] = new byte[7]; packet[0] = COMMAND_CRC_CHECK_COMMAND; - byte[] response = executeCommand(packet, "get CRC32", false); + byte[] response = executeCommand(packet, "get CRC32"); if (checkResponseCode(response, RESPONSE_OK) && response.length == 5) { ByteBuffer bb = ByteBuffer.wrap(response, 1, 4); @@ -304,6 +304,10 @@ public class BinaryProtocol implements BinaryProtocolCommands { return null; } + public byte[] executeCommand(byte[] packet, String msg) { + return executeCommand(packet, msg, false); + } + /** * Blocking sending binary packet and waiting for a response * @@ -351,7 +355,7 @@ public class BinaryProtocol implements BinaryProtocolCommands { long start = System.currentTimeMillis(); while (!isClosed && (System.currentTimeMillis() - start < Timeouts.BINARY_IO_TIMEOUT)) { - byte[] response = executeCommand(packet, "writeImage", false); + byte[] response = executeCommand(packet, "writeImage"); if (!checkResponseCode(response, RESPONSE_OK) || response.length != 1) { logger.error("writeData: Something is wrong, retrying..."); continue; @@ -368,7 +372,7 @@ public class BinaryProtocol implements BinaryProtocolCommands { while (true) { if (isClosed) return; - byte[] response = executeCommand(new byte[]{COMMAND_BURN}, "burn", false); + byte[] response = executeCommand(new byte[]{COMMAND_BURN}, "burn"); if (!checkResponseCode(response, RESPONSE_BURN_OK) || response.length != 1) { continue; } @@ -442,6 +446,17 @@ public class BinaryProtocol implements BinaryProtocolCommands { } } + public void getComposite() throws IOException { + if (isClosed) + return; + + byte packet[] = new byte[1]; + packet[0] = Fields.TS_GET_COMPOSITE_BUFFER_DONE_DIFFERENTLY; + +// executeCommand() + + } + public boolean requestOutputChannels() { if (isClosed) return false; diff --git a/java_console/io/src/com/rusefi/ui/livedocs/LiveDocsRegistry.java b/java_console/io/src/com/rusefi/ui/livedocs/LiveDocsRegistry.java index b5d08e2a33..576a395255 100644 --- a/java_console/io/src/com/rusefi/ui/livedocs/LiveDocsRegistry.java +++ b/java_console/io/src/com/rusefi/ui/livedocs/LiveDocsRegistry.java @@ -47,7 +47,7 @@ public enum LiveDocsRegistry { putShort(packet, 1, swap16(liveDocRequestId)); // offset putShort(packet, 3, swap16(size)); - byte[] responseWithCode = binaryProtocol.executeCommand(packet, "get LiveDoc", false); + byte[] responseWithCode = binaryProtocol.executeCommand(packet, "get LiveDoc"); if (responseWithCode == null || responseWithCode.length != (size + 1) || responseWithCode[0] != RESPONSE_OK) return; diff --git a/java_console/ui/src/com/rusefi/BenchTestPane.java b/java_console/ui/src/com/rusefi/BenchTestPane.java index 373ecd2492..11f3827bff 100644 --- a/java_console/ui/src/com/rusefi/BenchTestPane.java +++ b/java_console/ui/src/com/rusefi/BenchTestPane.java @@ -58,12 +58,12 @@ public class BenchTestPane { @Override public void actionPerformed(ActionEvent e) { BinaryProtocol bp = BinaryProtocolHolder.INSTANCE.getCurrentStreamState(); - bp.executeCommand(new byte[]{'r'}, "begin trace", false); + bp.executeCommand(new byte[]{Fields.TS_PERF_TRACE_BEGIN}, "begin trace"); try { Thread.sleep(500); - byte[] packet = bp.executeCommand(new byte[]{'b'}, "get trace", true); + 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");