From 059ceee7e31c5401a7c5552fc7f855582e25595c Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Mon, 16 Sep 2019 07:59:08 +0200 Subject: [PATCH] Fix telemetry sensor module/rx source data being lost in some cases (#6792) --- companion/src/firmwares/opentx/opentxeeprom.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 07c38e4a9..f13881149 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -1914,8 +1914,7 @@ class SensorField: public TransformedField { if (sensor.type == SensorData::TELEM_TYPE_CUSTOM) { _id = sensor.id; _subid = sensor.subid; - // keep highest 3 bits from instance (rxIdx & moduleIdx are read-only) - _instance = (sensor.instance & 0x1F) | (_instance & 0xE0); + _instance = (sensor.instance & 0x1F) | (sensor.rxIdx << 5) | (sensor.moduleIdx << 7); _ratio = sensor.ratio; _offset = sensor.offset; } @@ -1941,7 +1940,7 @@ class SensorField: public TransformedField { if (model.moduleData[0].isPxx1Module() || model.moduleData[1].isPxx1Module()) sensor.instance = (_instance & 0x1F) + (version <= 218 ? -1 : 0); // 5 bits instance else - sensor.instance = _instance; + sensor.instance = _instance & 0x1F; sensor.rxIdx = (_instance >> 5) & 0x03; // 2 bits Rx idx sensor.moduleIdx = (_instance >> 7) & 0x1; // 1 bit module idx sensor.ratio = _ratio;