From 6bb5bd998c6136d4418e20af59f4c4820dc4a903 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Sun, 9 Jun 2024 23:07:05 -0700 Subject: [PATCH] process plain command only if no second byte (#440) * process plain command only if no second byte * print in case of not understood single-byte cmd --- firmware/console/binary/tunerstudio.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/firmware/console/binary/tunerstudio.cpp b/firmware/console/binary/tunerstudio.cpp index b7f6ebf5c9..c0782744a6 100644 --- a/firmware/console/binary/tunerstudio.cpp +++ b/firmware/console/binary/tunerstudio.cpp @@ -346,6 +346,7 @@ bool TunerStudio::handlePlainCommand(TsChannelBase* tsChannel, uint8_t command) return true; } else { // This wasn't a valid command + efiPrintf("TS: didn't understand single byte comamnd %d (char '%c')", command, command); return false; } } @@ -381,16 +382,17 @@ static int tsProcessOne(TsChannelBase* tsChannel) { return -1; } - if (tsInstance.handlePlainCommand(tsChannel, firstByte)) { - return -1; - } - uint8_t secondByte; /* second byte should be received within minimal delay */ received = tsChannel->readTimeout(&secondByte, 1, TS_COMMUNICATION_TIMEOUT_SHORT); if (received != 1) { - tunerStudioError(tsChannel, "TS: ERROR: no second byte"); - tsChannel->in_sync = false; + // Second byte timed out: it may be a single-byte "plain" command + if (!tsInstance.handlePlainCommand(tsChannel, firstByte)) { + // This wasn't understood as a plain command, so it's an error + tunerStudioError(tsChannel, "TS: ERROR: no second byte"); + tsChannel->in_sync = false; + } + return -1; }