Skip to content

Conversation

@xznhj8129
Copy link
Contributor

@xznhj8129 xznhj8129 commented Dec 17, 2025

User description

Small fix to enum parsing that caused some to be missed, added a "not implemented" flag to MSP2_INAV_LOGIC_CONDITIONS, kept the inav_enums.json file for use in SDK


PR Type

Enhancement, Bug fix


Description

  • Fixed enum parsing regex to handle named enums correctly

  • Added 30+ previously missed enums to documentation

  • Marked MSP2_INAV_LOGIC_CONDITIONS as deprecated due to buffer overflow

  • Generated stable inav_enums.json file with normalized source paths


Diagram Walkthrough

flowchart LR
  A["Enum Parser Regex"] -->|"Handle named enums"| B["Fixed Parsing"]
  C["Source Path Normalization"] -->|"Replace ../../../src"| D["Stable JSON Output"]
  E["Missing Enums"] -->|"30+ enums added"| F["Complete Documentation"]
  G["MSP2_INAV_LOGIC_CONDITIONS"] -->|"Mark deprecated"| H["Buffer Overflow Fix"]
Loading

File Walkthrough

Relevant files
Bug fix
2 files
gen_enum_md.py
Fixed enum parsing and JSON generation                                     
+4/-1     
msp_messages.json
Marked MSP2_INAV_LOGIC_CONDITIONS as not implemented         
+3/-2     
Enhancement
2 files
inav_enums_ref.md
Added 30+ missing enums to reference                                         
+342/-0 
inav_enums.json
Generated stable enum definitions JSON file                           
+4128/-0
Documentation
2 files
msp_ref.md
Updated MSP2_INAV_LOGIC_CONDITIONS deprecation                     
+4/-5     
format.md
Clarified not_implemented field documentation                       
+1/-1     
Miscellaneous
2 files
msp_messages.checksum
Updated checksum for message changes                                         
+1/-1     
rev
Incremented JSON file revision to 4                                           
+1/-1     
Additional files
1 files
original_msp_ref.md +0/-3514

@github-actions
Copy link

Branch Targeting Suggestion

You've targeted the master branch with this PR. Please consider if a version branch might be more appropriate:

  • maintenance-9.x - If your change is backward-compatible and won't create compatibility issues between INAV firmware and Configurator 9.x versions. This will allow your PR to be included in the next 9.x release.

  • maintenance-10.x - If your change introduces compatibility requirements between firmware and configurator that would break 9.x compatibility. This is for PRs which will be included in INAV 10.x

If master is the correct target for this change, no action is needed.


This is an automated suggestion to help route contributions to the appropriate branch.

@xznhj8129 xznhj8129 marked this pull request as ready for review December 17, 2025 16:52
@qodo-code-review
Copy link
Contributor

PR Compliance Guide 🔍

All compliance sections have been disabled in the configurations.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High-level Suggestion

Avoid committing the large, auto-generated inav_enums.json file. Instead, publish it as a build artifact or release asset to prevent bloating the repository. [High-level, importance: 7]

Solution Walkthrough:

Before:

# .github/workflows/docs.yml (or similar)
- name: Generate enum documentation
  run: python docs/development/msp/gen_enum_md.py

# git repository contains:
# - docs/development/msp/gen_enum_md.py
# - docs/development/msp/inav_enums.json (large, generated)

After:

# .github/workflows/docs.yml (or similar)
- name: Generate enum documentation
  run: python docs/development/msp/gen_enum_md.py
- name: Upload artifact
  uses: actions/upload-artifact@v3
  with:
    name: inav-enums-json
    path: docs/development/msp/inav_enums.json

# .gitignore
docs/development/msp/inav_enums.json

# git repository no longer contains inav_enums.json

# ---------- Parsing regexes ----------

RE_ENUM_START = re.compile(r'^\s*typedef\s+enum\s*\{')
RE_ENUM_START = re.compile(r'^\s*typedef\s+enum(?:\s+[A-Za-z_]\w*)?\s*\{')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Update the RE_ENUM_START regex to optionally match __attribute__((packed)) to correctly parse packed enums. [possible issue, importance: 6]

Suggested change
RE_ENUM_START = re.compile(r'^\s*typedef\s+enum(?:\s+[A-Za-z_]\w*)?\s*\{')
RE_ENUM_START = re.compile(r'^\s*typedef\s+enum(?:\s+[A-Za-z_]\w*)?(?:\s+__attribute__\(\([\w\s,\(\)]+\)\))?\s*\{')

Comment on lines +277 to +278
if '_source' in jsonfile[e.name]:
jsonfile[e.name]['_source'] = jsonfile[e.name]['_source'].replace('../../../src', 'inav/src')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Replace the hardcoded path string replacement with a flexible regex using re.sub to normalize source paths with varying depths. [general, importance: 7]

Suggested change
if '_source' in jsonfile[e.name]:
jsonfile[e.name]['_source'] = jsonfile[e.name]['_source'].replace('../../../src', 'inav/src')
if '_source' in jsonfile[e.name]:
jsonfile[e.name]['_source'] = re.sub(r'^(?:\.\./)+src', 'inav/src', jsonfile[e.name]['_source'])

|---|---:|---|
| `MODE_RX` | 1 << 0 | |
| `MODE_TX` | 1 << 1 | |
| `MODE_RXTX` | MODE_RX | MODE_TX | |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Fix the markdown table for MODE_RXTX by merging the MODE_RX and MODE_TX cells into a single "Value" cell, displaying MODE_RX | MODE_TX. [general, importance: 6]

Suggested change
| `MODE_RXTX` | MODE_RX | MODE_TX | |
| `MODE_RXTX` | MODE_RX \| MODE_TX | |

@xznhj8129 xznhj8129 changed the base branch from master to maintenance-9.x December 17, 2025 20:50
@sensei-hacker
Copy link
Member

The deprecation message could mention the replacement MSP2_INAV_LOGIC_CONDITIONS_CONFIGURED pattern.

The Qodo bot sometimes suggests dumb things; sometimes points to a good potential improvement.
Please let me know if you think any of the suggestions it made here are worth doing.

@xznhj8129
Copy link
Contributor Author

xznhj8129 commented Dec 18, 2025

The deprecation message could mention the replacement MSP2_INAV_LOGIC_CONDITIONS_CONFIGURED pattern.

The Qodo bot sometimes suggests dumb things; sometimes points to a good potential improvement. Please let me know if you think any of the suggestions it made here are worth doing.

Not sure what he means by "publish it as a build artifact or release asset", it may be gone soon anyway as i figure out a way to proprely generate C headers and a python library as part of a united SDK; i used to delete it after creation. The regex still is part of that improvement, i noticed some enums were missing so it will be getting some improvements anyway; i'm no good at regex, that is no language of man.

It could be a very good idea to keep a changelog of MSP; i did take note of this page recently which hasn't been updated in years https://github.com/iNavFlight/inav/wiki/INAV-MSP-frames-changelog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants