mirror of https://github.com/rusefi/rusefi-1.git
mostly refactoring very little progress
This commit is contained in:
parent
44b251c958
commit
6642fd4312
|
@ -249,7 +249,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
||||||
putShort(packet, 3, swap16(offset));
|
putShort(packet, 3, swap16(offset));
|
||||||
putShort(packet, 5, swap16(requestSize));
|
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) {
|
if (!checkResponseCode(response, RESPONSE_OK) || response.length != requestSize + 1) {
|
||||||
String code = (response == null || response.length == 0) ? "empty" : "code " + response[0];
|
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];
|
byte packet[] = new byte[7];
|
||||||
packet[0] = COMMAND_CRC_CHECK_COMMAND;
|
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) {
|
if (checkResponseCode(response, RESPONSE_OK) && response.length == 5) {
|
||||||
ByteBuffer bb = ByteBuffer.wrap(response, 1, 4);
|
ByteBuffer bb = ByteBuffer.wrap(response, 1, 4);
|
||||||
|
@ -304,6 +304,10 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public byte[] executeCommand(byte[] packet, String msg) {
|
||||||
|
return executeCommand(packet, msg, false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Blocking sending binary packet and waiting for a response
|
* Blocking sending binary packet and waiting for a response
|
||||||
*
|
*
|
||||||
|
@ -351,7 +355,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
||||||
|
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
while (!isClosed && (System.currentTimeMillis() - start < Timeouts.BINARY_IO_TIMEOUT)) {
|
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) {
|
if (!checkResponseCode(response, RESPONSE_OK) || response.length != 1) {
|
||||||
logger.error("writeData: Something is wrong, retrying...");
|
logger.error("writeData: Something is wrong, retrying...");
|
||||||
continue;
|
continue;
|
||||||
|
@ -368,7 +372,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (isClosed)
|
if (isClosed)
|
||||||
return;
|
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) {
|
if (!checkResponseCode(response, RESPONSE_BURN_OK) || response.length != 1) {
|
||||||
continue;
|
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() {
|
public boolean requestOutputChannels() {
|
||||||
if (isClosed)
|
if (isClosed)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -47,7 +47,7 @@ public enum LiveDocsRegistry {
|
||||||
putShort(packet, 1, swap16(liveDocRequestId)); // offset
|
putShort(packet, 1, swap16(liveDocRequestId)); // offset
|
||||||
putShort(packet, 3, swap16(size));
|
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)
|
if (responseWithCode == null || responseWithCode.length != (size + 1) || responseWithCode[0] != RESPONSE_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -58,12 +58,12 @@ public class BenchTestPane {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
BinaryProtocol bp = BinaryProtocolHolder.INSTANCE.getCurrentStreamState();
|
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 {
|
try {
|
||||||
Thread.sleep(500);
|
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)
|
if (!checkResponseCode(packet, RESPONSE_OK) || ((packet.length - 1) % 8) != 0)
|
||||||
throw new IllegalStateException("Unexpected packet");
|
throw new IllegalStateException("Unexpected packet");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue