From 48c88021533c860ed017aadff6b400d6f6815557 Mon Sep 17 00:00:00 2001 From: Pierre-A Date: Tue, 20 Oct 2015 14:48:57 +0200 Subject: [PATCH 1/2] Fix Hott telemetry timing issue --- src/main/telemetry/hott.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/telemetry/hott.c b/src/main/telemetry/hott.c index eb9b7f58e..1580e80da 100644 --- a/src/main/telemetry/hott.c +++ b/src/main/telemetry/hott.c @@ -427,9 +427,12 @@ static void hottSendTelemetryData(void) { if (!hottIsSending) { hottIsSending = true; // FIXME temorary workaround for HoTT not working on Hardware serial ports due to hardware/softserial serial port initialisation differences - //serialSetMode(hottPort, MODE_TX); - closeSerialPort(hottPort); - hottPort = openSerialPort(portConfig->identifier, FUNCTION_TELEMETRY_HOTT, NULL, HOTT_BAUDRATE, MODE_TX, SERIAL_NOT_INVERTED); + if ((portConfig->identifier == SERIAL_PORT_SOFTSERIAL1) || (portConfig->identifier == SERIAL_PORT_SOFTSERIAL2)) + serialSetMode(hottPort, MODE_TX); + else { + closeSerialPort(hottPort); + hottPort = openSerialPort(portConfig->identifier, FUNCTION_TELEMETRY_HOTT, NULL, HOTT_BAUDRATE, MODE_TX, SERIAL_NOT_INVERTED); + } hottMsgCrc = 0; return; } @@ -439,9 +442,12 @@ static void hottSendTelemetryData(void) { hottIsSending = false; // FIXME temorary workaround for HoTT not working on Hardware serial ports due to hardware/softserial serial port initialisation differences - //serialSetMode(hottPort, MODE_RX); - closeSerialPort(hottPort); - hottPort = openSerialPort(portConfig->identifier, FUNCTION_TELEMETRY_HOTT, NULL, HOTT_BAUDRATE, MODE_RX, SERIAL_NOT_INVERTED); + if ((portConfig->identifier == SERIAL_PORT_SOFTSERIAL1) || (portConfig->identifier == SERIAL_PORT_SOFTSERIAL2)) + serialSetMode(hottPort, MODE_RX); + else { + closeSerialPort(hottPort); + hottPort = openSerialPort(portConfig->identifier, FUNCTION_TELEMETRY_HOTT, NULL, HOTT_BAUDRATE, MODE_RX, SERIAL_NOT_INVERTED); + } flushHottRxBuffer(); return; } From 5376dc4ce3a50120ad87d02d0ec30e74b83b30a4 Mon Sep 17 00:00:00 2001 From: Pierre-A Date: Thu, 22 Oct 2015 17:02:44 +0200 Subject: [PATCH 2/2] Fix Hott telemetry timing issue --- src/main/telemetry/hott.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/telemetry/hott.c b/src/main/telemetry/hott.c index 1580e80da..0142e3b53 100644 --- a/src/main/telemetry/hott.c +++ b/src/main/telemetry/hott.c @@ -423,16 +423,19 @@ static void hottCheckSerialData(uint32_t currentMicros) } } +static void workAroundForHottTelemetryOnUsart(serialPort_t *instance, portMode_t mode) { + closeSerialPort(hottPort); + hottPort = openSerialPort(instance->identifier, FUNCTION_TELEMETRY_HOTT, NULL, HOTT_BAUDRATE, mode, SERIAL_NOT_INVERTED); +} + static void hottSendTelemetryData(void) { if (!hottIsSending) { hottIsSending = true; // FIXME temorary workaround for HoTT not working on Hardware serial ports due to hardware/softserial serial port initialisation differences - if ((portConfig->identifier == SERIAL_PORT_SOFTSERIAL1) || (portConfig->identifier == SERIAL_PORT_SOFTSERIAL2)) - serialSetMode(hottPort, MODE_TX); - else { - closeSerialPort(hottPort); - hottPort = openSerialPort(portConfig->identifier, FUNCTION_TELEMETRY_HOTT, NULL, HOTT_BAUDRATE, MODE_TX, SERIAL_NOT_INVERTED); - } + if ((portConfig->identifier == SERIAL_PORT_USART1) || (portConfig->identifier == SERIAL_PORT_USART2) || (portConfig->identifier == SERIAL_PORT_USART3)) + workAroundForHottTelemetryOnUsart(hottPort, MODE_TX); + else + serialSetMode(hottPort, MODE_TX); hottMsgCrc = 0; return; } @@ -440,14 +443,11 @@ static void hottSendTelemetryData(void) { if (hottMsgRemainingBytesToSendCount == 0) { hottMsg = NULL; hottIsSending = false; - // FIXME temorary workaround for HoTT not working on Hardware serial ports due to hardware/softserial serial port initialisation differences - if ((portConfig->identifier == SERIAL_PORT_SOFTSERIAL1) || (portConfig->identifier == SERIAL_PORT_SOFTSERIAL2)) - serialSetMode(hottPort, MODE_RX); - else { - closeSerialPort(hottPort); - hottPort = openSerialPort(portConfig->identifier, FUNCTION_TELEMETRY_HOTT, NULL, HOTT_BAUDRATE, MODE_RX, SERIAL_NOT_INVERTED); - } + if ((portConfig->identifier == SERIAL_PORT_USART1) || (portConfig->identifier == SERIAL_PORT_USART2) || (portConfig->identifier == SERIAL_PORT_USART3)) + workAroundForHottTelemetryOnUsart(hottPort, MODE_RX); + else + serialSetMode(hottPort, MODE_RX); flushHottRxBuffer(); return; }