From 554d17357cf92b48f9ea5901a8fb827f0d250d0d Mon Sep 17 00:00:00 2001 From: blckmn Date: Sat, 19 Nov 2016 21:06:04 +1100 Subject: [PATCH] Removed need to check for serial port, or open it --- src/main/rx/crsf.c | 5 +++++ src/main/rx/crsf.h | 1 + src/main/telemetry/crsf.c | 12 +++--------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/rx/crsf.c b/src/main/rx/crsf.c index 4e200934a2..74e2876c6e 100644 --- a/src/main/rx/crsf.c +++ b/src/main/rx/crsf.c @@ -237,4 +237,9 @@ bool crsfRxInit(const rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig) return serialPort != NULL; } + +bool crsfRxIsActive(void) +{ + return serialPort != NULL; +} #endif diff --git a/src/main/rx/crsf.h b/src/main/rx/crsf.h index 2f69b260f6..5c320c0724 100644 --- a/src/main/rx/crsf.h +++ b/src/main/rx/crsf.h @@ -81,3 +81,4 @@ void crsfRxSendTelemetryData(void); struct rxConfig_s; struct rxRuntimeConfig_s; bool crsfRxInit(const struct rxConfig_s *initialRxConfig, struct rxRuntimeConfig_s *rxRuntimeConfig); +bool crsfRxIsActive(void); \ No newline at end of file diff --git a/src/main/telemetry/crsf.c b/src/main/telemetry/crsf.c index 41280b3008..af61ff11bf 100644 --- a/src/main/telemetry/crsf.c +++ b/src/main/telemetry/crsf.c @@ -23,6 +23,7 @@ #ifdef TELEMETRY +#include "config/feature.h" #include "build/version.h" #if (FC_VERSION_MAJOR == 3) // not a very good way of finding out if this is betaflight or Cleanflight @@ -350,15 +351,8 @@ static void processCrsf(void) void initCrsfTelemetry(void) { // check if there is a serial port open for CRSF telemetry (ie opened by the CRSF RX) - // if so, set CRSF telemetry enabled - crsfTelemetryEnabled = false; - const serialPortConfig_t *serialPortConfig = findSerialPortConfig(FUNCTION_TELEMETRY_CRSF); - if (serialPortConfig) { - const serialPort_t *serialPort = openSerialPort(serialPortConfig->identifier, FUNCTION_TELEMETRY_CRSF, NULL, CRSF_BAUDRATE, CRSF_PORT_MODE, CRSF_PORT_OPTIONS); - if (serialPort) { - crsfTelemetryEnabled = true; - } - } + // and feature is enabled, if so, set CRSF telemetry enabled + crsfTelemetryEnabled = crsfRxIsActive() && feature(FEATURE_TELEMETRY); } bool checkCrsfTelemetryState(void)