From f1b37bbad1af4054106b4d7fe51a69640bb31874 Mon Sep 17 00:00:00 2001 From: rusefi Date: Sat, 15 Jun 2019 19:46:42 -0400 Subject: [PATCH] removing dead code related to text to binary switch --- firmware/console/binary/tunerstudio.cpp | 8 ---- firmware/console/binary/tunerstudio_io.h | 3 -- .../rusefi/binaryprotocol/BinaryProtocol.java | 47 +------------------ .../BinaryProtocolCommands.java | 8 ---- .../BinaryProtocolCmdSandbox.java | 1 - 5 files changed, 1 insertion(+), 66 deletions(-) diff --git a/firmware/console/binary/tunerstudio.cpp b/firmware/console/binary/tunerstudio.cpp index ddf2588824..88e9f6b5e5 100644 --- a/firmware/console/binary/tunerstudio.cpp +++ b/firmware/console/binary/tunerstudio.cpp @@ -114,8 +114,6 @@ static efitimems_t previousWriteReportMs = 0; static ts_channel_s tsChannel; -static uint16_t BINARY_RESPONSE = (uint16_t) SWAP_UINT16(BINARY_SWITCH_TAG); - // this thread wants a bit extra stack static THD_WORKING_AREA(tsThreadStack, 3 * UTILITY_THREAD_STACK_SIZE); @@ -510,12 +508,6 @@ void runBinaryProtocolLoop(ts_channel_s *tsChannel) { uint16_t incomingPacketSize = firstByte << 8 | secondByte; - if (incomingPacketSize == BINARY_SWITCH_TAG) { - // we are here if we get a binary switch request while already in binary mode. We will just ignore it. - sr5WriteData(tsChannel, (const uint8_t *) &BINARY_RESPONSE, 2); - continue; - } - if (incomingPacketSize == 0 || incomingPacketSize > (sizeof(tsChannel->crcReadBuffer) - CRC_WRAPPING_SIZE)) { scheduleMsg(&tsLogger, "TunerStudio: invalid size: %d", incomingPacketSize); tunerStudioError("ERROR: CRC header size"); diff --git a/firmware/console/binary/tunerstudio_io.h b/firmware/console/binary/tunerstudio_io.h index 958fb053fa..7a39badc7c 100644 --- a/firmware/console/binary/tunerstudio_io.h +++ b/firmware/console/binary/tunerstudio_io.h @@ -14,9 +14,6 @@ #include "pin_repository.h" #endif -// that's hex for "~\n", see -#define BINARY_SWITCH_TAG 0x7e0a - #define PROTOCOL "001" #define TS_RESPONSE_OK 0x00 diff --git a/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java b/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java index 3673a7cad2..c7926b4f75 100644 --- a/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java +++ b/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java @@ -159,52 +159,7 @@ public class BinaryProtocol implements BinaryProtocolCommands { return logger; } - /** - * the whole dynamic 'switch to binary protocol' still does not work great - */ - public void switchToBinaryProtocol() { - // we do not have reliable implementation yet :( - for (int i = 0; i < 15; i++) - doSwitchToBinary(); - } - - private void doSwitchToBinary() { - long start = System.currentTimeMillis(); - - while (true) { - try { - if (stream.isClosed()) - return; - dropPending(); - - stream.write((SWITCH_TO_BINARY_COMMAND + "\n").getBytes()); - // todo: document why is ioLock needed here? - synchronized (ioLock) { - boolean isTimeout = incomingData.waitForBytes("switch to binary", start, 2); - if (isTimeout) { - logger.info(new Date() + ": Timeout waiting for switch response"); - close(); - return; - } - int response = incomingData.getShort(); - if (response != swap16(SWITCH_TO_BINARY_RESPONSE)) { - logger.error(String.format("Unexpected response [%x], re-trying", response)); - continue; - } - logger.info(String.format("Got %x - switched to binary protocol", response)); - } - } catch (IOException e) { - close(); - FileLog.MAIN.logLine("exception: " + e); - return; - } catch (InterruptedException e) { - throw new IllegalStateException(e); - } - break; - } - } - - private void dropPending() throws IOException { + private void dropPending() { synchronized (ioLock) { if (isClosed) return; diff --git a/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocolCommands.java b/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocolCommands.java index 374cea4638..9b3cfdc6fb 100644 --- a/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocolCommands.java +++ b/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocolCommands.java @@ -12,14 +12,6 @@ public interface BinaryProtocolCommands { byte RESPONSE_OK = 0; byte RESPONSE_BURN_OK = 0x04; byte RESPONSE_COMMAND_OK = 0x07; - /** - * that's hex for "~\n", see BINARY_SWITCH_TAG in firmware source code - */ - int SWITCH_TO_BINARY_RESPONSE = 0x7e0a; - /** - * See SWITCH_TO_BINARY_COMMAND in firmware source code - */ - String SWITCH_TO_BINARY_COMMAND = "~"; char COMMAND_OUTPUTS = 'O'; // ochGetCommand char COMMAND_HELLO = 'S'; // queryCommand char COMMAND_PROTOCOL = 'F'; diff --git a/java_console/ui/src/com/rusefi/binaryprotocol/BinaryProtocolCmdSandbox.java b/java_console/ui/src/com/rusefi/binaryprotocol/BinaryProtocolCmdSandbox.java index ae3caf3645..f841cf05d6 100644 --- a/java_console/ui/src/com/rusefi/binaryprotocol/BinaryProtocolCmdSandbox.java +++ b/java_console/ui/src/com/rusefi/binaryprotocol/BinaryProtocolCmdSandbox.java @@ -36,7 +36,6 @@ public class BinaryProtocolCmdSandbox { SerialIoStreamJSSC.setupPort(serialPort, 38400); logger.info("Binary looks good!"); - bp.switchToBinaryProtocol(); bp.readImage(Fields.TOTAL_CONFIG_SIZE); //