mostly refactoring very little progress

This commit is contained in:
rusefi 2020-05-28 22:06:51 -04:00
parent 44b251c958
commit 6642fd4312
3 changed files with 22 additions and 7 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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");