inav icon indicating copy to clipboard operation
inav copied to clipboard

Add guard for logic conditions bitmask if max exceeds 64

Open sensei-hacker opened this issue 2 weeks ago • 1 comments

User description

Summary

Adds a guard to the MSP2_INAV_LOGIC_CONDITIONS_CONFIGURED handler to use MIN(MAX_LOGIC_CONDITIONS, 64) instead of hardcoded 64. This prevents potential issues if MAX_LOGIC_CONDITIONS is increased beyond 64 in the future.

Changes

  • Use MIN(MAX_LOGIC_CONDITIONS, 64) in the loop bound

Testing

Code review only.


PR Type

Enhancement


Description

  • Add MSP2_INAV_LOGIC_CONDITIONS_CONFIGURED command for efficient condition status

  • Returns 8-byte bitmask indicating which logic conditions differ from defaults

  • Enables configurator optimization reducing MSP requests from 64 to 1+N

  • Guard loop with MIN(MAX_LOGIC_CONDITIONS, 64) for future-proofing


Diagram Walkthrough

flowchart LR
  A["MSP2_INAV_LOGIC_CONDITIONS_CONFIGURED<br/>request"] --> B["Iterate logic conditions<br/>up to MIN(MAX, 64)"]
  B --> C["Check if condition<br/>is configured"]
  C --> D["Build 64-bit<br/>bitmask"]
  D --> E["Send 8-byte response<br/>lower + upper 32-bits"]

File Walkthrough

Relevant files
Enhancement
fc_msp.c
Implement logic conditions configured bitmask handler       

src/main/fc/fc_msp.c

  • Implement new MSP2_INAV_LOGIC_CONDITIONS_CONFIGURED handler
  • Create 64-bit bitmask by checking each logic condition against default
    values
  • Verify enabled, activatorId, operation, operands, and flags fields
  • Send bitmask as two 32-bit values to support 8-byte response
+23/-0   
Configuration changes
msp_protocol_v2_inav.h
Add MSP protocol definition for configured conditions       

src/main/msp/msp_protocol_v2_inav.h

  • Define new MSP2_INAV_LOGIC_CONDITIONS_CONFIGURED command with ID
    0x203C
  • Add documentation comment explaining 8-byte bitmask return format
+1/-0     

sensei-hacker avatar Dec 10 '25 05:12 sensei-hacker

PR Compliance Guide 🔍

All compliance sections have been disabled in the configurations.

qodo-code-review[bot] avatar Dec 10 '25 05:12 qodo-code-review[bot]