fix(PXX2): prevent legacy telemetry polling (S.PORT) if the module driver defines its own method (#2504)

This is to prevent the S.PORT line to interfere with PXX2 telemetry reception, especially with R9M ACCESS.
This commit is contained in:
Raphael Coeffic
2022-10-11 21:36:24 +10:00
committed by GitHub
parent 37002080a1
commit 324c8e9eef
3 changed files with 16 additions and 3 deletions
+11 -3
View File
@@ -223,9 +223,9 @@ inline bool isBadAntennaDetected()
return false;
}
static inline void pollTelemetry(uint8_t module, const etx_module_driver_t* drv, void* ctx)
static inline bool pollTelemetry(uint8_t module, const etx_module_driver_t* drv, void* ctx)
{
if (!drv || !drv->getByte || !drv->processData) return;
if (!drv || !drv->getByte || !drv->processData) return false;
uint8_t* rxBuffer = getTelemetryRxBuffer(module);
uint8_t& rxBufferCount = getTelemetryRxBufferCount(module);
@@ -239,6 +239,8 @@ static inline void pollTelemetry(uint8_t module, const etx_module_driver_t* drv,
LOG_TELEMETRY_WRITE_BYTE(data);
} while (drv->getByte(ctx, &data) > 0);
}
return true;
}
static inline void pollExtTelemetryLegacy()
@@ -265,7 +267,13 @@ void telemetryWakeup()
#if defined(HARDWARE_EXTERNAL_MODULE)
auto ext_drv = getExtModuleDriver();
if (ext_drv) pollTelemetry(EXTERNAL_MODULE, ext_drv, getExtModuleCtx());
if (ext_drv) {
if (pollTelemetry(EXTERNAL_MODULE, ext_drv, getExtModuleCtx())) {
// skip legacy telemetry polling in case external module
// driver defines telemetry methods (getByte & processData)
return;
}
}
#endif
// TODO: needs to be moved to protocol/module init