From 2d178a399c4551460bf9a4575fc6af902486afc5 Mon Sep 17 00:00:00 2001 From: EmanuelFeru Date: Thu, 6 Feb 2020 21:53:38 +0100 Subject: [PATCH] Improved Serial Timeout - added condition to avoid restarting DMA repeatedly if no data is received - enabled DEBUG_SERIAL_ASCII for all Variants except VARIANT_TRANSPOTTER --- Inc/config.h | 2 +- Src/main.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Inc/config.h b/Inc/config.h index 141ac42..bc8daf8 100644 --- a/Inc/config.h +++ b/Inc/config.h @@ -176,7 +176,7 @@ #ifndef VARIANT_TRANSPOTTER //#define DEBUG_SERIAL_SERVOTERM - //#define DEBUG_SERIAL_ASCII + #define DEBUG_SERIAL_ASCII #endif // ########################### END OF DEBUG SERIAL ############################ diff --git a/Src/main.c b/Src/main.c index de6370e..6f2b4ba 100644 --- a/Src/main.c +++ b/Src/main.c @@ -550,6 +550,7 @@ int main(void) { if (main_loop_counter % 25 == 0 && command.start != IBUS_LENGTH && command.start != 0xFF) { HAL_UART_DMAStop(&huart); HAL_UART_Receive_DMA(&huart, (uint8_t *)&command, sizeof(command)); + command.start = 0xFF; // Change the Start Frame to avoid entering again here if no data is received } } #else @@ -572,6 +573,7 @@ int main(void) { if (main_loop_counter % 25 == 0 && command.start != START_FRAME && command.start != 0xFFFF) { HAL_UART_DMAStop(&huart); HAL_UART_Receive_DMA(&huart, (uint8_t *)&command, sizeof(command)); + command.start = 0xFFFF; // Change the Start Frame to avoid entering again here if no data is received } } #endif