From 35b46d0e92a1ad738409f2aec136d0d4029918d6 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Mon, 3 Jun 2024 14:45:14 -0700 Subject: [PATCH] TS helper for no-payload responses --- firmware/console/binary/tunerstudio.cpp | 12 +++--------- firmware/console/binary/tunerstudio_io.h | 5 +++++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/firmware/console/binary/tunerstudio.cpp b/firmware/console/binary/tunerstudio.cpp index f36544162c..e1cdfe768d 100644 --- a/firmware/console/binary/tunerstudio.cpp +++ b/firmware/console/binary/tunerstudio.cpp @@ -125,7 +125,7 @@ static void sendOkResponse(TsChannelBase *tsChannel) { } void sendErrorCode(TsChannelBase *tsChannel, uint8_t code) { - tsChannel->writeCrcPacket(code, nullptr, 0); + tsChannel->writeCrcResponse(code); } void TunerStudio::sendErrorCode(TsChannelBase* tsChannel, uint8_t code) { @@ -256,12 +256,6 @@ void requestBurn(void) { #endif // !EFI_UNIT_TEST } -static void sendResponseCode(ts_response_format_e mode, TsChannelBase *tsChannel, const uint8_t responseCode) { - if (mode == TS_CRC) { - tsChannel->writeCrcPacket(responseCode, nullptr, 0); - } -} - /** * 'Burn' command is a command to commit the changes */ @@ -278,7 +272,7 @@ static void handleBurnCommand(TsChannelBase* tsChannel) { requestBurn(); } - sendResponseCode(TS_CRC, tsChannel, TS_RESPONSE_BURN_OK); + tsChannel->writeCrcResponse(TS_RESPONSE_BURN_OK); efiPrintf("BURN in %dms", (int)(t.getElapsedSeconds() * 1e3)); } @@ -581,7 +575,7 @@ void TunerStudio::handleExecuteCommand(TsChannelBase* tsChannel, char *data, int #endif (console_line_callback)(trimmed); - tsChannel->writeCrcPacket(TS_RESPONSE_COMMAND_OK, nullptr, 0); + tsChannel->writeCrcResponse(TS_RESPONSE_COMMAND_OK); } int TunerStudio::handleCrcCommand(TsChannelBase* tsChannel, char *data, int incomingPacketSize) { diff --git a/firmware/console/binary/tunerstudio_io.h b/firmware/console/binary/tunerstudio_io.h index 606a64fe12..0d495d8c29 100644 --- a/firmware/console/binary/tunerstudio_io.h +++ b/firmware/console/binary/tunerstudio_io.h @@ -56,6 +56,11 @@ public: void crcAndWriteBuffer(const uint8_t responseCode, const size_t size); void copyAndWriteSmallCrcPacket(uint8_t responseCode, const uint8_t* buf, size_t size); + // Write a response code with no data + void writeCrcResponse(uint8_t responseCode) { + writeCrcPacketLarge(responseCode, nullptr, 0); + } + /* When TsChannel is in "not in sync" state tsProcessOne will silently try to find * begining of packet. * As soon as tsProcessOne was able to receive valid packet with valid size and crc