MSP2_INAV_SET_GVAR#11146
Merged
sensei-hacker merged 1 commit intoiNavFlight:maintenance-9.xfrom Dec 6, 2025
Merged
Conversation
Contributor
PR Compliance Guide 🔍All compliance sections have been disabled in the configurations. |
Contributor
There was a problem hiding this comment.
High-level Suggestion
Add a safety check to prevent the MSP2_INAV_SET_GVAR command from executing if the aircraft is armed. This avoids unintended flight behavior changes caused by modifying Global Variables mid-flight. [High-level, importance: 9]
Solution Walkthrough:
Before:
case MSP2_INAV_SET_GVAR:
if (dataSize != 5) {
return MSP_RESULT_ERROR;
}
{
uint8_t gvarIndex;
if (!sbufReadU8Safe(&gvarIndex, src)) {
return MSP_RESULT_ERROR;
}
const int32_t gvarValue = (int32_t)sbufReadU32(src);
if (gvarIndex >= MAX_GLOBAL_VARIABLES) {
return MSP_RESULT_ERROR;
}
gvSet(gvarIndex, gvarValue);
}
break;After:
case MSP2_INAV_SET_GVAR:
if (ARMING_FLAG(ARMED)) {
return MSP_RESULT_ERROR;
}
if (dataSize != 5) {
return MSP_RESULT_ERROR;
}
{
uint8_t gvarIndex;
if (!sbufReadU8Safe(&gvarIndex, src)) {
return MSP_RESULT_ERROR;
}
const int32_t gvarValue = (int32_t)sbufReadU32(src);
if (gvarIndex >= MAX_GLOBAL_VARIABLES) {
return MSP_RESULT_ERROR;
}
gvSet(gvarIndex, gvarValue);
}
break;
Contributor
Author
There was a problem hiding this comment.
That would defeat the point
Member
|
This looks like it could be useful. The commit seems to include unrelated changes to docs/development/msp/inav_enums_ref.md ? |
Contributor
Author
|
Yeah that's from when you run the gen, it scans the source and if there's any change in the enums it will show it |
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
There was no way to set a Global Variable through MSP, which seems like a pretty handy thing to have.
PR Type
Enhancement
Description
Add MSP2_INAV_SET_GVAR command for setting Global Variables
Implement handler with validation for gvar index and data size
Update MSP protocol documentation and enum references
Fix documentation source references for sdcard drivers
Diagram Walkthrough
File Walkthrough
fc_msp.c
Implement MSP2_INAV_SET_GVAR command handlersrc/main/fc/fc_msp.c
MSP2_INAV_SET_GVARcommandgvarIndex(uint8_t) andgvarValue(int32_t) from buffergvarIndexagainstMAX_GLOBAL_VARIABLESlimitgvSet()to set the global variable valuemsp_protocol_v2_inav.h
Define MSP2_INAV_SET_GVAR protocol constantsrc/main/msp/msp_protocol_v2_inav.h
MSP2_INAV_SET_GVARmacro definition with code0x2214MSP2_INAV_SET_GEOZONE_VERTEXin protocol definitionsmsp_messages.checksum
Update message definition checksumdocs/development/msp/msp_messages.checksum
MSP2_INAV_SET_GVARmessage additionmsp_messages.json
Document MSP2_INAV_SET_GVAR message structuredocs/development/msp/msp_messages.json
MSP2_INAV_SET_GVARmessage definition with code 8724gvarIndexandvaluefieldsUSE_PROGRAMMING_FRAMEWORKrequirement and validationmsp_ref.md
Add MSP2_INAV_SET_GVAR to reference documentationdocs/development/msp/msp_ref.md
MSP2_INAV_SET_GVARto message index with code 8724inav_enums_ref.md
Update enum documentation and fix referencesdocs/development/msp/inav_enums_ref.md
DEVHW_W25N01Genum name toDEVHW_W25NLOGIC_CONDITION_OPERAND_FLIGHT_RELATIVE_WIND_OFFSETenum withvalue 49
rev
Bump MSP documentation revisiondocs/development/msp/rev