[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:
Raphael Coeffic
2021-09-18 11:57:23 +10:00
committed by Peter Feerick
parent 514796fa51
commit f401cd4a12
4 changed files with 15 additions and 6 deletions
+3 -3
View File
@@ -211,8 +211,8 @@ bool MultiRfProtocols::triggerScan()
proto2idx.clear();
protoList.clear();
scanState = ScanBegin;
currentProto = MULTI_INVALID_PROTO;
moduleState[moduleIdx].mode = MODULE_MODE_GET_HARDWARE_INFO;
moduleState[moduleIdx].counter = MULTI_INVALID_PROTO;
scanStart = lastScan = RTOS_GET_MS();
return true;
}
@@ -232,7 +232,7 @@ bool MultiRfProtocols::scanReply(const uint8_t* packet, uint8_t len)
// new status received
if (replyProtoId != MULTI_INVALID_PROTO) {
if (moduleState[moduleIdx].counter == MULTI_INVALID_PROTO) {
if (currentProto == MULTI_INVALID_PROTO) {
//TRACE("# of protos: %d", totalProtos);
totalProtos = replyProtoId;
scanState = Scanning;
@@ -271,7 +271,7 @@ bool MultiRfProtocols::scanReply(const uint8_t* packet, uint8_t len)
}
}
moduleState[moduleIdx].counter++;
currentProto++;
lastScan = RTOS_GET_MS();
return true;
+2
View File
@@ -39,6 +39,7 @@ class MultiRfProtocols
uint32_t scanStart = 0;
uint32_t lastScan = 0;
uint8_t currentProto = 0;
uint8_t totalProtos = 0;
MultiRfProtocols(unsigned int moduleIdx) : moduleIdx(moduleIdx) {}
@@ -78,6 +79,7 @@ class MultiRfProtocols
std::string getLastProtoLabel() const;
bool triggerScan();
uint8_t getScanProto() { return currentProto; }
bool scanReply(const uint8_t * packet = nullptr, uint8_t len = 0);
void fillList(std::function<void(const RfProto&)> addProto) const;