removing dead code related to text to binary switch

This commit is contained in:
rusefi 2019-06-15 19:46:42 -04:00
parent e76706332a
commit f1b37bbad1
5 changed files with 1 additions and 66 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -36,7 +36,6 @@ public class BinaryProtocolCmdSandbox {
SerialIoStreamJSSC.setupPort(serialPort, 38400);
logger.info("Binary looks good!");
bp.switchToBinaryProtocol();
bp.readImage(Fields.TOTAL_CONFIG_SIZE);
//