[color] use own protocol counter
Overloading the frame counter causes aa race condition with the UI thread (see SEND_FAILSAFE_1S()).
This commit is contained in:
committed by
Peter Feerick
parent
514796fa51
commit
f401cd4a12
@@ -211,8 +211,8 @@ bool MultiRfProtocols::triggerScan()
|
|||||||
proto2idx.clear();
|
proto2idx.clear();
|
||||||
protoList.clear();
|
protoList.clear();
|
||||||
scanState = ScanBegin;
|
scanState = ScanBegin;
|
||||||
|
currentProto = MULTI_INVALID_PROTO;
|
||||||
moduleState[moduleIdx].mode = MODULE_MODE_GET_HARDWARE_INFO;
|
moduleState[moduleIdx].mode = MODULE_MODE_GET_HARDWARE_INFO;
|
||||||
moduleState[moduleIdx].counter = MULTI_INVALID_PROTO;
|
|
||||||
scanStart = lastScan = RTOS_GET_MS();
|
scanStart = lastScan = RTOS_GET_MS();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -232,7 +232,7 @@ bool MultiRfProtocols::scanReply(const uint8_t* packet, uint8_t len)
|
|||||||
|
|
||||||
// new status received
|
// new status received
|
||||||
if (replyProtoId != MULTI_INVALID_PROTO) {
|
if (replyProtoId != MULTI_INVALID_PROTO) {
|
||||||
if (moduleState[moduleIdx].counter == MULTI_INVALID_PROTO) {
|
if (currentProto == MULTI_INVALID_PROTO) {
|
||||||
//TRACE("# of protos: %d", totalProtos);
|
//TRACE("# of protos: %d", totalProtos);
|
||||||
totalProtos = replyProtoId;
|
totalProtos = replyProtoId;
|
||||||
scanState = Scanning;
|
scanState = Scanning;
|
||||||
@@ -271,7 +271,7 @@ bool MultiRfProtocols::scanReply(const uint8_t* packet, uint8_t len)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
moduleState[moduleIdx].counter++;
|
currentProto++;
|
||||||
lastScan = RTOS_GET_MS();
|
lastScan = RTOS_GET_MS();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class MultiRfProtocols
|
|||||||
|
|
||||||
uint32_t scanStart = 0;
|
uint32_t scanStart = 0;
|
||||||
uint32_t lastScan = 0;
|
uint32_t lastScan = 0;
|
||||||
|
uint8_t currentProto = 0;
|
||||||
uint8_t totalProtos = 0;
|
uint8_t totalProtos = 0;
|
||||||
|
|
||||||
MultiRfProtocols(unsigned int moduleIdx) : moduleIdx(moduleIdx) {}
|
MultiRfProtocols(unsigned int moduleIdx) : moduleIdx(moduleIdx) {}
|
||||||
@@ -78,6 +79,7 @@ class MultiRfProtocols
|
|||||||
|
|
||||||
std::string getLastProtoLabel() const;
|
std::string getLastProtoLabel() const;
|
||||||
bool triggerScan();
|
bool triggerScan();
|
||||||
|
uint8_t getScanProto() { return currentProto; }
|
||||||
|
|
||||||
bool scanReply(const uint8_t * packet = nullptr, uint8_t len = 0);
|
bool scanReply(const uint8_t * packet = nullptr, uint8_t len = 0);
|
||||||
void fillList(std::function<void(const RfProto&)> addProto) const;
|
void fillList(std::function<void(const RfProto&)> addProto) const;
|
||||||
|
|||||||
@@ -177,8 +177,11 @@ void setupPulsesMulti(uint8_t moduleIdx)
|
|||||||
sendChannels(moduleIdx);
|
sendChannels(moduleIdx);
|
||||||
|
|
||||||
// Multi V1.3.X.X -> Send byte 26, Protocol (bits 7 & 6), RX_Num (bits 5 & 4), invert, not used, disable telemetry, disable mapping
|
// Multi V1.3.X.X -> Send byte 26, Protocol (bits 7 & 6), RX_Num (bits 5 & 4), invert, not used, disable telemetry, disable mapping
|
||||||
if ((moduleState[moduleIdx].mode == MODULE_MODE_SPECTRUM_ANALYSER) ||
|
if ((moduleState[moduleIdx].mode == MODULE_MODE_SPECTRUM_ANALYSER)
|
||||||
(moduleState[moduleIdx].mode == MODULE_MODE_GET_HARDWARE_INFO)) {
|
#if defined(MULTI_PROTOLIST)
|
||||||
|
|| (moduleState[moduleIdx].mode == MODULE_MODE_GET_HARDWARE_INFO)
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
sendMulti(moduleIdx, invert[moduleIdx] & 0x08);
|
sendMulti(moduleIdx, invert[moduleIdx] & 0x08);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -371,17 +374,19 @@ void sendFrameProtocolHeader(uint8_t moduleIdx, bool failsafe)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(MULTI_PROTOLIST)
|
||||||
if (moduleMode == MODULE_MODE_GET_HARDWARE_INFO) {
|
if (moduleMode == MODULE_MODE_GET_HARDWARE_INFO) {
|
||||||
sendMulti(moduleIdx, (uint8_t) 0x55); // Header byte
|
sendMulti(moduleIdx, (uint8_t) 0x55); // Header byte
|
||||||
sendMulti(moduleIdx, (uint8_t) 0); // PROTOLIST custom protocol
|
sendMulti(moduleIdx, (uint8_t) 0); // PROTOLIST custom protocol
|
||||||
sendMulti(moduleIdx, (uint8_t) 0);
|
sendMulti(moduleIdx, (uint8_t) 0);
|
||||||
|
|
||||||
// proto array item
|
// proto array item
|
||||||
uint8_t protoIdx = moduleState[moduleIdx].counter;
|
uint8_t protoIdx = MultiRfProtocols::instance(moduleIdx)->getScanProto();
|
||||||
TRACE("scan [%d]", protoIdx);
|
TRACE("scan [%d]", protoIdx);
|
||||||
sendMulti(moduleIdx, protoIdx);
|
sendMulti(moduleIdx, protoIdx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (moduleMode == MODULE_MODE_BIND)
|
if (moduleMode == MODULE_MODE_BIND)
|
||||||
protoByte |= MULTI_SEND_BIND;
|
protoByte |= MULTI_SEND_BIND;
|
||||||
|
|||||||
@@ -473,7 +473,9 @@ static void enablePulsesInternalModule(uint8_t protocol)
|
|||||||
getMultiModuleStatus(INTERNAL_MODULE).failsafeChecked = false;
|
getMultiModuleStatus(INTERNAL_MODULE).failsafeChecked = false;
|
||||||
getMultiModuleStatus(INTERNAL_MODULE).flags = 0;
|
getMultiModuleStatus(INTERNAL_MODULE).flags = 0;
|
||||||
#if defined(MULTI_PROTOLIST)
|
#if defined(MULTI_PROTOLIST)
|
||||||
|
TRACE("enablePulsesInternalModule(): trigger scan");
|
||||||
MultiRfProtocols::instance(INTERNAL_MODULE)->triggerScan();
|
MultiRfProtocols::instance(INTERNAL_MODULE)->triggerScan();
|
||||||
|
TRACE("counter = %d", moduleState[INTERNAL_MODULE].counter);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user