diff --git a/src/main/telemetry/hott.c b/src/main/telemetry/hott.c index a8c0b0b56d..0f37c84d02 100644 --- a/src/main/telemetry/hott.c +++ b/src/main/telemetry/hott.c @@ -58,6 +58,8 @@ #include "platform.h" +#include "build_config.h" + #ifdef TELEMETRY #include "common/axis.h" @@ -108,6 +110,8 @@ static telemetryConfig_t *telemetryConfig; static HOTT_GPS_MSG_t hottGPSMessage; static HOTT_EAM_MSG_t hottEAMMessage; +static bool useSoftserialRxFailureWorkaround = false; + static void initialiseEAMMessage(HOTT_EAM_MSG_t *msg, size_t size) { memset(msg, 0, size); @@ -266,6 +270,10 @@ void configureHoTTTelemetryPort(void) // FIXME only need to do this if the port is shared previousPortMode = hottPort->mode; previousBaudRate = hottPort->baudRate; + + if (hottPort->identifier == SERIAL_PORT_SOFTSERIAL1 || hottPort->identifier == SERIAL_PORT_SOFTSERIAL2) { + useSoftserialRxFailureWorkaround = true; + } } } @@ -342,12 +350,24 @@ static void flushHottRxBuffer(void) } } -static void hottCheckSerialData(uint32_t currentMicros) { - +static void hottCheckSerialData(uint32_t currentMicros) +{ static bool lookingForRequest = true; uint8_t bytesWaiting = serialTotalBytesWaiting(hottPort); + if (useSoftserialRxFailureWorkaround) { + // FIXME The 0x80 is being read as 0x00 - softserial timing/syncronisation problem somewhere. + if (!bytesWaiting) { + return; + } + + uint8_t incomingByte = serialRead(hottPort); + processBinaryModeRequest(incomingByte); + + return; + } + if (bytesWaiting <= 1) { return; }