potentially a bugfix - two binary protocol thread should not share static variables

This commit is contained in:
rusefi 2017-03-15 21:20:53 -05:00
parent efeda30e91
commit 46f9cf252c
1 changed files with 11 additions and 2 deletions

View File

@ -434,11 +434,12 @@ static bool isKnownCommand(char command) {
|| command == TS_GET_FIRMWARE_VERSION; || command == TS_GET_FIRMWARE_VERSION;
} }
static uint8_t firstByte;
static uint8_t secondByte;
void runBinaryProtocolLoop(ts_channel_s *tsChannel, bool isConsoleRedirect) { void runBinaryProtocolLoop(ts_channel_s *tsChannel, bool isConsoleRedirect) {
int wasReady = false; int wasReady = false;
bool isFirstByte = true;
while (true) { while (true) {
int isReady = ts_serial_ready(isConsoleRedirect); int isReady = ts_serial_ready(isConsoleRedirect);
if (!isReady) { if (!isReady) {
@ -454,6 +455,7 @@ void runBinaryProtocolLoop(ts_channel_s *tsChannel, bool isConsoleRedirect) {
tsState.tsCounter++; tsState.tsCounter++;
uint8_t firstByte;
int recieved = chnReadTimeout(tsChannel->channel, &firstByte, 1, TS_READ_TIMEOUT); int recieved = chnReadTimeout(tsChannel->channel, &firstByte, 1, TS_READ_TIMEOUT);
#if EFI_SIMULATOR || defined(__DOXYGEN__) #if EFI_SIMULATOR || defined(__DOXYGEN__)
logMsg("recieved %d\r\n", recieved); logMsg("recieved %d\r\n", recieved);
@ -465,10 +467,17 @@ void runBinaryProtocolLoop(ts_channel_s *tsChannel, bool isConsoleRedirect) {
continue; continue;
} }
onDataArrived(); onDataArrived();
if (isFirstByte) {
}
isFirstByte = false;
// scheduleMsg(logger, "Got first=%x=[%c]", firstByte, firstByte); // scheduleMsg(logger, "Got first=%x=[%c]", firstByte, firstByte);
if (handlePlainCommand(tsChannel, firstByte)) if (handlePlainCommand(tsChannel, firstByte))
continue; continue;
uint8_t secondByte;
recieved = chnReadTimeout(tsChannel->channel, &secondByte, 1, TS_READ_TIMEOUT); recieved = chnReadTimeout(tsChannel->channel, &secondByte, 1, TS_READ_TIMEOUT);
if (recieved != 1) { if (recieved != 1) {
tunerStudioError("TS: ERROR: no second byte"); tunerStudioError("TS: ERROR: no second byte");