From bc7539c295f96870f15ef130629d3d9dabf89617 Mon Sep 17 00:00:00 2001 From: rusefi Date: Thu, 1 Oct 2020 00:24:49 -0400 Subject: [PATCH] readable codes --- .../rusefi/binaryprotocol/BinaryProtocol.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/java_console/io/src/main/java/com/rusefi/binaryprotocol/BinaryProtocol.java b/java_console/io/src/main/java/com/rusefi/binaryprotocol/BinaryProtocol.java index 16eff53cb0..2cff9968c8 100644 --- a/java_console/io/src/main/java/com/rusefi/binaryprotocol/BinaryProtocol.java +++ b/java_console/io/src/main/java/com/rusefi/binaryprotocol/BinaryProtocol.java @@ -37,6 +37,7 @@ import java.util.concurrent.*; import static com.devexperts.logging.Logging.getLogging; import static com.rusefi.binaryprotocol.IoHelper.*; +import static com.rusefi.config.generated.Fields.*; /** * This object represents logical state of physical connection. @@ -370,7 +371,7 @@ public class BinaryProtocol implements BinaryProtocolCommands { 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]; + String code = (response == null || response.length == 0) ? "empty" : "code " + getCode(response); String info = response == null ? "NO RESPONSE" : (code + " size " + response.length); log.info("readImage: ERROR UNEXPECTED Something is wrong, retrying... " + info); continue; @@ -392,6 +393,21 @@ public class BinaryProtocol implements BinaryProtocolCommands { return image; } + private static String getCode(byte[] response) { + int b = response[0]; + switch (b) { + case TS_RESPONSE_CRC_FAILURE: + return "CRC_FAILURE"; + case TS_RESPONSE_UNRECOGNIZED_COMMAND: + return "UNRECOGNIZED_COMMAND"; + case TS_RESPONSE_OUT_OF_RANGE: + return "OUT_OF_RANGE"; + case TS_RESPONSE_FRAMING_ERROR: + return "FRAMING_ERROR"; + } + return Integer.toString(b); + } + private ConfigurationImage getAndValidateLocallyCached() { if (DISABLE_LOCAL_CACHE) return null;