From ffd537a28b627e8aa8d318041a18db5790c311b5 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sun, 14 Nov 2021 17:27:12 +0100 Subject: [PATCH] Fixed compiling with DEBUG=ON --- radio/src/cli.cpp | 18 ++++++++++++++---- radio/src/cli_traces.h | 27 +++++++++++++++++++++++++++ radio/src/debug.h | 1 + 3 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 radio/src/cli_traces.h diff --git a/radio/src/cli.cpp b/radio/src/cli.cpp index efb3c3472..6d28787e2 100644 --- a/radio/src/cli.cpp +++ b/radio/src/cli.cpp @@ -25,6 +25,8 @@ #include #include +#include "cli_traces.h" + #define CLI_COMMAND_MAX_ARGS 8 #define CLI_COMMAND_MAX_LEN 256 @@ -837,10 +839,13 @@ int cliSet(const char **argv) return -1; } - if (level) + if (level) { GPIO_SetBits(INTMODULE_BOOTCMD_GPIO, INTMODULE_BOOTCMD_GPIO_PIN); - else + serialPrint("%s: bootpin set", argv[0]); + } else { GPIO_ResetBits(INTMODULE_BOOTCMD_GPIO, INTMODULE_BOOTCMD_GPIO_PIN); + serialPrint("%s: bootpin reset", argv[0]); + } } #endif @@ -1187,9 +1192,11 @@ int cliDisplay(const char ** argv) printDebugTimers(); } #endif +#if defined(DEBUG_AUDIO) else if (!strcmp(argv[1], "audio")) { printAudioVars(); } +#endif #if defined(DISK_CACHE) else if (!strcmp(argv[1], "dc")) { DiskCacheStats stats = diskCache.getStats(); @@ -1234,9 +1241,12 @@ int cliRepeat(const char ** argv) if (toInt(argv, 1, &interval) > 0 && argv[2]) { interval *= 50; counter = interval; + uint8_t c; - while (!cliRxFifo.pop(c) || !(c == '\r' || c == '\n' || c == ' ')) { - RTOS_WAIT_MS(20); // 20ms + const TickType_t xTimeout = 20 / RTOS_MS_PER_TICK; + while (!xStreamBufferReceive(cliRxBuffer, &c, 1, xTimeout) + || !(c == '\r' || c == '\n' || c == ' ')) { + if (++counter >= interval) { cliExecCommand(&argv[2]); counter = 0; diff --git a/radio/src/cli_traces.h b/radio/src/cli_traces.h new file mode 100644 index 000000000..62fd7f8ee --- /dev/null +++ b/radio/src/cli_traces.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) EdgeTX + * + * Based on code named + * opentx - https://github.com/opentx/opentx + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#pragma once + +#include + +// Allows for switchable debug prints via CLI +extern uint8_t cliTracesEnabled; diff --git a/radio/src/debug.h b/radio/src/debug.h index 4fb3baf26..cd3bd06b6 100644 --- a/radio/src/debug.h +++ b/radio/src/debug.h @@ -44,6 +44,7 @@ uint8_t aux2SerialTracesEnabled(); #include #define debugPrintf(...) printf(__VA_ARGS__) #elif defined(DEBUG) && defined(CLI) + #include "cli_traces.h" #define debugPrintf(...) do { if (cliTracesEnabled) serialPrintf(__VA_ARGS__); } while(0) #elif defined(DEBUG) #define debugPrintf(...) do { serialPrintf(__VA_ARGS__); } while(0)