-
Notifications
You must be signed in to change notification settings - Fork 373
Ipf trig #2478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
xznhj8129
wants to merge
35
commits into
iNavFlight:maintenance-10.x
Choose a base branch
from
xznhj8129:ipf_trig
base: maintenance-10.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Ipf trig #2478
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
4618245
Add GitHub Action to suggest maintenance branches for PRs targeting m…
sensei-hacker 5209d96
Fix import of HTML in JS Programming tab
Lemontree-Softworks 01cdcbd
search.js: Update fetch to ESM import syntax
sensei-hacker a536572
search: Add error handling
sensei-hacker 2ab4cae
magnetometer.js error logging
sensei-hacker ef74611
magnetometer.js error logging
sensei-hacker 1ea34bf
Fix transpiler API definitions to match firmware implementation
sensei-hacker ef4b1c4
Fix page loading in packed app
Lemontree-Softworks 447769e
Address PR review feedback: update test documentation
sensei-hacker e3924bd
Merge pull request #2450 from sensei-hacker/transpiler-api-fixes
sensei-hacker 7bb72e0
Merge pull request #2446 from sensei-hacker/search_update_fetch_to_esm
sensei-hacker 689378c
Merge pull request #2447 from sensei-hacker/mag_not_load_win64
sensei-hacker 2ed9320
Remove unused API definition files
sensei-hacker dca306d
Fix build error: Remove missing override.js import
sensei-hacker 1745979
Merge pull request #2445 from Scavanger/Fix-JS-Programming-Tab
sensei-hacker 2a72ab8
Merge pull request #2451 from sensei-hacker/remove-unused-api-definit…
sensei-hacker 8dfa61a
Fix JavaScript Programming: Clear unused logic conditions on save
sensei-hacker 3c36172
Fix three bugs breaking JavaScript Programming examples
sensei-hacker 5b8bc76
Fix bug: Ensure logic conditions are sent to correct FC slots
sensei-hacker d983fbd
Fix duplicate condition bug in transpiler >= synthesis
sensei-hacker 47a0fd7
Fix missing override reference and editorWorker import
sensei-hacker 0c7c067
Merge pull request #2452 from sensei-hacker/fix-javascript-clear-unus…
sensei-hacker 7a9bf65
Merge pull request #2455 from sensei-hacker/fix-transpiler-examples-bugs
sensei-hacker c23ffd1
Merge pull request #2456 from sensei-hacker/fix-transpiler-not-operat…
sensei-hacker 6681f4e
Fix JavaScript Programming tab issues (#2453)
sensei-hacker f0b47a3
Merge pull request #2460 from sensei-hacker/fix-javascript-programmin…
sensei-hacker 4326ea1
Add flight axis override support to JavaScript Programming
sensei-hacker 0e4fdb3
Merge branch 'maintenance-9.x' into flight-axis-override-implementation
sensei-hacker eb00d67
ests/test_flight_axis_override.js stray whitespace
sensei-hacker 3909f8e
Remove CHANGELOG_FLIGHT_AXIS.md from PR
sensei-hacker 52e3389
Move internal docs to project directory
sensei-hacker 9dbd346
Merge pull request #2461 from sensei-hacker/flight-axis-override-impl…
sensei-hacker 9bcf765
Update SITL binaries for 9.0.0-RC3
sensei-hacker c288607
Merge pull request #2464 from sensei-hacker/sitl-update-9.0.0-RC3
sensei-hacker 400fb45
change for ipf trig
xznhj8129 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| name: PR Branch Suggestion | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| types: [opened] | ||
| branches: | ||
| - master | ||
|
|
||
| jobs: | ||
| suggest-branch: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| pull-requests: write | ||
| steps: | ||
| - name: Suggest maintenance branch | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const comment = `### 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.*`; | ||
|
|
||
| github.rest.issues.createComment({ | ||
| issue_number: context.issue.number, | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| body: comment | ||
| }); |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,187 @@ | ||
| # Transpiler API Definition Bugs Found | ||
|
|
||
| **Date:** 2025-12-02 | ||
| **Investigator:** Developer | ||
| **Context:** Systematic verification of transpiler API definitions against INAV firmware | ||
|
|
||
| --- | ||
|
|
||
| ## Summary | ||
|
|
||
| Found **3 critical bugs** in the transpiler API definitions where the configurator did not match the actual firmware implementation. | ||
|
|
||
| --- | ||
|
|
||
| ## Bug #1: waypoint.js - CRITICAL - Wrong Type and Fabricated Properties | ||
|
|
||
| **File:** `js/transpiler/api/definitions/waypoint.js` | ||
|
|
||
| ### Issues Found: | ||
|
|
||
| 1. **Wrong Operand Type** | ||
| - **Bug:** Used `type: 5` (GVAR type) | ||
| - **Correct:** Should be `type: 7` (WAYPOINTS type) | ||
| - **Impact:** Waypoint properties would read global variables instead of waypoint data! | ||
|
|
||
| 2. **Fabricated Properties - Data Not Exposed by Firmware** | ||
| - The following properties were **completely fabricated** and do NOT exist in the firmware's logic condition operand system: | ||
| - ❌ `latitude` (claimed value: 2) - **DOES NOT EXIST** | ||
| - ❌ `longitude` (claimed value: 3) - **DOES NOT EXIST** | ||
| - ❌ `altitude` (claimed value: 4) - **DOES NOT EXIST** | ||
| - ❌ `bearing` (claimed value: 6) - **DOES NOT EXIST** | ||
| - ❌ `missionReached` (claimed value: 7) - **DOES NOT EXIST** | ||
| - ❌ `missionValid` (claimed value: 8) - **DOES NOT EXIST** | ||
|
|
||
| 3. **Missing Actual Properties** | ||
| - The file was missing these REAL properties that ARE exposed: | ||
| - Missing: `isWaypointMission` (value: 0) | ||
| - Missing: `nextAction` (value: 3) | ||
| - Missing: `distanceFromPrevious` (value: 5) | ||
| - Missing: ALL user action flags (values: 6-13) | ||
|
|
||
| ### Root Cause: | ||
| - Incorrect source documentation cited: `navigation_pos_estimator.c` | ||
| - **Actual source:** `src/main/programming/logic_condition.h` (logicWaypointOperands_e) | ||
| - **Actual implementation:** `src/main/programming/logic_condition.c` (lines 575-669) | ||
|
|
||
| ### Firmware Reality: | ||
| Waypoints have lat/lon/alt/bearing **internally**, but these are **NOT exposed** through the logic condition operand system (for security/simplicity). | ||
|
|
||
| ### Status: ✅ **FIXED** | ||
| - Updated waypoint.js with correct type (7) and actual properties (0-13) | ||
| - Added proper source documentation | ||
| - Added comment explaining why lat/lon/alt/bearing aren't available | ||
|
|
||
| --- | ||
|
|
||
| ## Bug #2: codegen.js - RC Channel .value Syntax Not Supported | ||
|
|
||
| **File:** `js/transpiler/transpiler/codegen.js` (line 614) | ||
|
|
||
| ### Issue: | ||
| - **Bug:** Regex `/^rc\[(\d+)\]$/` only matched `rc[N]`, not `rc[N].value` | ||
| - **Impact:** Users couldn't use `rc[N].value` syntax (explicit form) | ||
| - **Note:** rc.js defines `.value` property, but transpiler rejected it | ||
|
|
||
| ### Status: ✅ **FIXED** | ||
| - Updated regex to `/^rc\[(\d+)\](?:\.value)?$/` | ||
| - Both `rc[N]` and `rc[N].value` now work as equivalent | ||
| - Error message updated to reflect both syntaxes | ||
|
|
||
| ### Verification: | ||
| Created comprehensive test (`test_rc_channels.js`) that confirms: | ||
| - ✅ RC reads use operand type 1 (RC_CHANNEL) - Correct! | ||
| - ✅ RC writes use operation 38 (RC_CHANNEL_OVERRIDE) - Correct! | ||
| - ✅ Both `rc[N]` and `rc[N].value` syntax work | ||
|
|
||
| --- | ||
|
|
||
| ## Bug #3: inav_constants.js - Missing Flight Parameters 46-49 | ||
|
|
||
| **File:** `js/transpiler/transpiler/inav_constants.js` | ||
|
|
||
| ### Issue: | ||
| - **Bug:** FLIGHT_PARAM stops at index 45 (CRSF_RSSI_DBM) | ||
| - **Missing:** Firmware has parameters 46-49 | ||
|
|
||
| ### Missing Parameters: | ||
| From `inav/src/main/programming/logic_condition.h` (lines 151-154): | ||
|
|
||
| ```c | ||
| LOGIC_CONDITION_OPERAND_FLIGHT_MIN_GROUND_SPEED, // 46 - m/s | ||
| LOGIC_CONDITION_OPERAND_FLIGHT_HORIZONTAL_WIND_SPEED, // 47 - cm/s | ||
| LOGIC_CONDITION_OPERAND_FLIGHT_WIND_DIRECTION, // 48 - deg | ||
| LOGIC_CONDITION_OPERAND_FLIGHT_RELATIVE_WIND_OFFSET, // 49 - deg | ||
| ``` | ||
|
|
||
| ### Impact: | ||
| - Wind-related flight parameters cannot be accessed in transpiler | ||
| - flight.js may also be missing these properties | ||
|
|
||
| ### Status: ⚠️ **NEEDS FIX** | ||
| - Requires updating inav_constants.js FLIGHT_PARAM | ||
| - Requires updating flight.js with wind properties | ||
| - Requires re-running generate-constants.js script | ||
|
|
||
| --- | ||
|
|
||
| ## Additional Findings | ||
|
|
||
| ###rc.js - Type 4 Bug (FALSE ALARM) | ||
|
|
||
| **File:** `js/transpiler/api/definitions/rc.js` | ||
|
|
||
| **Initial concern:** Uses `type: 4` instead of `type: 1` (RC_CHANNEL) | ||
|
|
||
| **Resolution:** ✅ **NO FIX NEEDED** | ||
| - codegen.js handles RC channels **directly** and hardcodes correct type | ||
| - Line 625 in codegen.js: `return { type: OPERAND_TYPE.RC_CHANNEL, value: index }` | ||
| - rc.js definitions are not actually used for operand type mapping | ||
| - Test confirms RC channels use correct type 1 | ||
|
|
||
| --- | ||
|
|
||
| ## Files Modified | ||
|
|
||
| 1. ✅ `js/transpiler/api/definitions/waypoint.js` - Complete rewrite | ||
| 2. ✅ `js/transpiler/transpiler/codegen.js` - Regex fix for rc[N].value | ||
| 3. ✅ `js/transpiler/transpiler/tests/test_rc_channels.js` - New comprehensive test | ||
|
|
||
| ## Files Still Need Review | ||
|
|
||
| 4. ⚠️ `js/transpiler/transpiler/inav_constants.js` - Add FLIGHT_PARAM 46-49 | ||
| 5. ⚠️ `js/transpiler/api/definitions/flight.js` - Add wind parameters | ||
| 6. ⏳ `js/transpiler/api/definitions/gvar.js` - Verify against firmware | ||
| 7. ⏳ `js/transpiler/api/definitions/pid.js` - Verify against firmware | ||
| 8. ⏳ `js/transpiler/api/definitions/override.js` - Verify operations | ||
|
|
||
| --- | ||
|
|
||
| ## Testing Performed | ||
|
|
||
| ### RC Channel Test (`test_rc_channels.js`) | ||
| - Tests both reading (`rc[N]`, `rc[N].value`) and writing (`rc[N] = value`) | ||
| - Verifies correct operand type (1) for reads | ||
| - Verifies correct operation (38) for writes | ||
| - Tests `low`, `mid`, `high` boolean properties | ||
| - ✅ All tests pass (after fixes) | ||
|
|
||
| ### Waypoint Verification | ||
| - Cross-referenced firmware source (`logic_condition.h`, `logic_condition.c`) | ||
| - Confirmed actual exposed operands (0-13) | ||
| - Documented why lat/lon/alt/bearing are not available | ||
|
|
||
| --- | ||
|
|
||
| ## Recommendations | ||
|
|
||
| 1. **Immediate:** Fix inav_constants.js and flight.js to add wind parameters 46-49 | ||
| 2. **Process:** Re-run `generate-constants.js` script to ensure sync with firmware | ||
| 3. **Testing:** Add tests for waypoint operations to prevent regression | ||
| 4. **Documentation:** Update transpiler docs to clarify RC channel syntax options | ||
| 5. **Audit:** Complete verification of remaining API definition files (gvar, pid, override) | ||
|
|
||
| --- | ||
|
|
||
| ## Impact Assessment | ||
|
|
||
| ### Critical (Bug #1 - waypoint.js): | ||
| - **Severity:** HIGH - Complete functional breakage | ||
| - **User Impact:** Any code using waypoint.latitude/longitude/bearing would fail or return wrong data | ||
| - **Likelihood:** MEDIUM - Users writing waypoint-based logic would encounter this | ||
|
|
||
| ### Moderate (Bug #2 - rc syntax): | ||
| - **Severity:** MEDIUM - Syntax limitation | ||
| - **User Impact:** Users forced to use shorthand, couldn't use explicit .value | ||
| - **Likelihood:** LOW - Shorthand works, so users might not notice | ||
|
|
||
| ### Low (Bug #3 - missing wind params): | ||
| - **Severity:** LOW - Missing features | ||
| - **User Impact:** Wind-related conditions unavailable | ||
| - **Likelihood:** LOW - Advanced feature, specific use case | ||
|
|
||
| --- | ||
|
|
||
| **Total Issues:** 3 bugs found, 2 fixed, 1 pending | ||
| **New Tests:** 1 comprehensive RC channel test added | ||
| **Lines Changed:** ~150 lines across 3 files |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Update the
hasOperandproperty forACOSandASINinjs/logicConditionOperators.jsfrom[true, true]to[true, false]to correctly reflect that they are single-argument functions. [general, importance: 6]