Workaround for HoTT and softserial.

This commit is contained in:
Dominic Clifton 2014-10-20 23:14:30 +01:00
parent 2d8f65448d
commit cbd1817f6c
1 changed files with 22 additions and 2 deletions

View File

@ -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;
}