2nd attempt to fix #7613 (#7670)

This commit is contained in:
Bertrand Songis
2020-06-04 15:13:32 +02:00
committed by GitHub
parent f34b5216a7
commit a468005ada
3 changed files with 12 additions and 14 deletions
@@ -1948,16 +1948,9 @@ class SensorField: public TransformedField {
else { else {
sensor.id = _id; sensor.id = _id;
sensor.subid = _subid; sensor.subid = _subid;
if (model.moduleData[0].isPxx1Module() || model.moduleData[1].isPxx1Module()) {
sensor.instance = (_instance & 0x1F) + (version <= 218 ? 0 : 1); // 5 bits instance sensor.instance = (_instance & 0x1F) + (version <= 218 ? 0 : 1); // 5 bits instance
sensor.rxIdx = 0x03; // 2 bits Rx idx
sensor.moduleIdx = 0x01; // 1 bit module idx
}
else {
sensor.instance = (_instance & 0x1F) + 1;
sensor.rxIdx = (_instance >> 5) & 0x03; // 2 bits Rx idx sensor.rxIdx = (_instance >> 5) & 0x03; // 2 bits Rx idx
sensor.moduleIdx = (_instance >> 7) & 0x1; // 1 bit module idx sensor.moduleIdx = (_instance >> 7) & 0x1; // 1 bit module idx
}
sensor.ratio = _ratio; sensor.ratio = _ratio;
sensor.offset = _offset; sensor.offset = _offset;
} }
+7 -2
View File
@@ -387,10 +387,15 @@ PACK(struct TelemetrySensor {
return true; return true;
if (protocol == PROTOCOL_TELEMETRY_FRSKY_SPORT) { if (protocol == PROTOCOL_TELEMETRY_FRSKY_SPORT) {
#if defined(SIMU)
if (((this->instance ^ instance) & 0x1F) == 0)
return true;
#else
if (((this->instance ^ instance) & 0x9F) == 0 && (this->instance >> 5) != TELEMETRY_ENDPOINT_SPORT && (instance >> 5) != TELEMETRY_ENDPOINT_SPORT) { if (((this->instance ^ instance) & 0x9F) == 0 && (this->instance >> 5) != TELEMETRY_ENDPOINT_SPORT && (instance >> 5) != TELEMETRY_ENDPOINT_SPORT) {
this->instance = instance; // update the instance in case we had telemetry switching this->instance = instance; // update the instance in case we had telemetry switching
return true; return true;
} }
#endif
} }
return false; return false;
@@ -471,11 +476,11 @@ PACK(struct ModuleData {
// Helper functions to set both of the rfProto protocol at the same time // Helper functions to set both of the rfProto protocol at the same time
NOBACKUP(inline uint8_t getMultiProtocol() { NOBACKUP(inline uint8_t getMultiProtocol() {
return ((uint8_t) (rfProtocol & 0x0f)) + (multi.rfProtocolExtra << 4); return ((uint8_t) (rfProtocol & 0x0F)) + (multi.rfProtocolExtra << 4);
}) })
NOBACKUP(inline void setMultiProtocol(uint8_t proto) { NOBACKUP(inline void setMultiProtocol(uint8_t proto) {
rfProtocol = (uint8_t) (proto & 0x0f); rfProtocol = (uint8_t) (proto & 0x0F);
multi.rfProtocolExtra = (proto & 0x70) >> 4; multi.rfProtocolExtra = (proto & 0x70) >> 4;
}) })
}); });