From 2021f647ad7171ef03f02760e547203fcb03d9fd Mon Sep 17 00:00:00 2001 From: nseidle Date: Mon, 12 Jun 2023 14:13:40 -0600 Subject: [PATCH] Write incoming Bluetooth data over I2C to avoid UART2 corruptions See issue 469 --- Firmware/RTK_Surveyor/Tasks.ino | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Firmware/RTK_Surveyor/Tasks.ino b/Firmware/RTK_Surveyor/Tasks.ino index 847a51e27..5228c32a3 100644 --- a/Firmware/RTK_Surveyor/Tasks.ino +++ b/Firmware/RTK_Surveyor/Tasks.ino @@ -39,7 +39,10 @@ void btReadTask(void *e) { // Ignore this escape character, passing along to output if (USE_I2C_GNSS) - serialGNSS.write(incoming); + { + // serialGNSS.write(incoming); + theGNSS.pushRawData(&incoming, 1); + } else theGNSS.pushRawData(&incoming, 1); } @@ -50,7 +53,11 @@ void btReadTask(void *e) while (btEscapeCharsReceived-- > 0) { if (USE_I2C_GNSS) - serialGNSS.write(btEscapeCharacter); + { + // serialGNSS.write(btEscapeCharacter); + uint8_t escChar = btEscapeCharacter; + theGNSS.pushRawData(&escChar, 1); + } else { uint8_t escChar = btEscapeCharacter; @@ -61,7 +68,12 @@ void btReadTask(void *e) // Pass byte to GNSS receiver or to system // TODO - control if this RTCM source should be listened to or not if (USE_I2C_GNSS) - serialGNSS.write(incoming); + { + // UART RX can be corrupted by UART TX + // See issue: https://github.com/sparkfun/SparkFun_RTK_Firmware/issues/469 + // serialGNSS.write(incoming); + theGNSS.pushRawData(&incoming, 1); + } else theGNSS.pushRawData(&incoming, 1);