Add MSP2_INAV_LOGIC_CONDITIONS_CONFIGURED command#11171
Merged
sensei-hacker merged 1 commit intoiNavFlight:maintenance-9.xfrom Dec 8, 2025
Merged
Conversation
Returns 8-byte bitmask indicating which logic conditions differ from defaults. Enables configurator optimization to reduce MSP requests from 64 to 1+N.
Contributor
PR Compliance Guide 🔍All compliance sections have been disabled in the configurations. |
Contributor
There was a problem hiding this comment.
High-level Suggestion
To improve maintainability, centralize the logic for checking if a logic condition is in its default state into a dedicated function, such as isLogicConditionDefault(). This avoids hardcoding the default values in the MSP handler, which could lead to inconsistencies if the defaults change. [High-level, importance: 7]
Solution Walkthrough:
Before:
// src/main/fc/fc_msp.c
case MSP2_INAV_LOGIC_CONDITIONS_CONFIGURED:
{
uint64_t mask = 0;
for (int i = 0; i < MAX_LOGIC_CONDITIONS; i++) {
const logicCondition_t *lc = logicConditions(i);
// Check if any field differs from default reset values
bool isConfigured = (lc->enabled != 0) ||
(lc->activatorId != -1) ||
(lc->operation != 0) ||
(lc->operandA.type != LOGIC_CONDITION_OPERAND_TYPE_VALUE) ||
(lc->operandA.value != 0) ||
...;
if (isConfigured) {
mask |= ((uint64_t)1 << i);
}
}
...
}
break;After:
// In a relevant file like logic_conditions.c/h
bool isLogicConditionDefault(const logicCondition_t *lc) {
logicCondition_t defaultLc;
resetLogicCondition(&defaultLc); // Assuming a reset function exists
return memcmp(lc, &defaultLc, sizeof(logicCondition_t)) == 0;
}
// src/main/fc/fc_msp.c
case MSP2_INAV_LOGIC_CONDITIONS_CONFIGURED:
{
uint64_t mask = 0;
for (int i = 0; i < MAX_LOGIC_CONDITIONS; i++) {
const logicCondition_t *lc = logicConditions(i);
if (!isLogicConditionDefault(lc)) {
mask |= ((uint64_t)1 << i);
}
}
...
}
break;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
Adds new MSP command (0x203C) that returns an 8-byte bitmask indicating which of the 64 logic conditions are configured (differ from default values).
This enables the configurator to optimize loading by fetching only configured conditions instead of all 64.
Companion PR: iNavFlight/inav-configurator (pending)
PR Type
Enhancement
Description
Adds MSP2_INAV_LOGIC_CONDITIONS_CONFIGURED command (0x203C)
Returns 8-byte bitmask indicating configured logic conditions
Optimizes configurator by reducing MSP requests from 64 to 1+N
Checks if logic condition differs from default reset values
Diagram Walkthrough
File Walkthrough
msp_protocol_v2_inav.h
Define new MSP2 logic conditions configured commandsrc/main/msp/msp_protocol_v2_inav.h
MSP2_INAV_LOGIC_CONDITIONS_CONFIGUREDwith value0x203Cnon-default logic conditions
fc_msp.c
Implement logic conditions configured bitmask handlersrc/main/fc/fc_msp.c
MSP2_INAV_LOGIC_CONDITIONS_CONFIGUREDcommandfrom default values
configured