Skip to content

Update vtx_tramp.c - #11772

Open
shenderiukv-droid wants to merge 1 commit into
iNavFlight:masterfrom
shenderiukv-droid:patch-1
Open

Update vtx_tramp.c#11772
shenderiukv-droid wants to merge 1 commit into
iNavFlight:masterfrom
shenderiukv-droid:patch-1

Conversation

@shenderiukv-droid

Copy link
Copy Markdown

vtx 2500

@qodo-code-review

Copy link
Copy Markdown
Contributor

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown

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.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Add 2.5W power table selection for Tramp 5.8GHz VTX

✨ Enhancement 🕐 10-20 Minutes

Grey Divider

AI Description

• Add a 5.8GHz 2500mW Tramp power table and display names.
• Select the 2500mW table when reported max power is >= 2500.
• Update VTX capability metadata to expose the new power levels.
Diagram

graph TD
  A["vtx_tramp.c"] --> B["vtxProtoUpdatePowerMetadata"] --> C{Max power?} --> D["Select 2500mW table"] --> E["VTX capability metadata"]
  C --> F["Select 600mW table"] --> E
  D --> G["Power tables/names"]
  F --> G

  subgraph Legend
    direction LR
    _file["File"] ~~~ _fn["Function"] ~~~ _dec{"Decision"} ~~~ _data["Data tables"]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Derive counts from constants/array sizes (avoid magic number 4)
  • ➕ Reduces risk of mismatched powerTableCount/powerCount vs actual table length
  • ➕ Makes future power-level additions less error-prone
  • ➖ May require minor refactor or helper macro to compute array length safely in C
2. Represent 2.5W as an extension of existing 800mW/600mW tables via scaling
  • ➕ Keeps a single canonical 5.8GHz power list and simplifies branching
  • ➕ Potentially reduces code duplication across power tiers
  • ➖ May not match how Tramp devices report discrete power steps (risk of incorrect UI/options)

Recommendation: The overall approach (adding a dedicated 2.5W table and selecting it by maxPower) fits the existing pattern and is straightforward. However, the new branch hard-codes count=4 while the table is declared with VTX_TRAMP_5G8_MAX_POWER_COUNT entries; consider deriving counts from the table/name definitions (or using the existing MAX_POWER_COUNT constant consistently) to avoid off-by-one/overread issues and keep metadata internally consistent.

Files changed (1) +8 / -9

Enhancement (1) +8 / -9
vtx_tramp.cAdd 5.8GHz 2500mW power table and selection logic +8/-9

Add 5.8GHz 2500mW power table and selection logic

• Replaces the previous 5.8GHz 800mW power table/name set with a new 2500mW (2.5W) table and display names. Updates vtxProtoUpdatePowerMetadata to select the new table when maxPower >= 2500 and to publish the corresponding power name/count metadata.

src/main/io/vtx_tramp.c

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. 800mW power capped 🐞 Bug ≡ Correctness
Description
vtxProtoUpdatePowerMetadata() now only selects the new 2500mW table when maxPower>=2500; a TRAMP VTX
reporting maxPower=800 will fall through to the 600mW table and can never request 800mW. This causes
incorrect capability metadata and prevents users from using the device’s supported max power.
Code

src/main/io/vtx_tramp.c[R605-608]

+            if (maxPower >= 2500) {
+                vtxState.metadata.powerTablePtr  = trampPowerTable_5G8_2500;
+                vtxState.metadata.powerTableCount = 4;
                
-                impl_vtxDevice.capability.powerNames = (char **)trampPowerNames_5G8_800;
-                impl_vtxDevice.capability.powerCount = VTX_TRAMP_5G8_MAX_POWER_COUNT;
-            }
Evidence
The driver uses the VTX-reported powerMax to select a power table; with the new logic, an 800mW
device selects the 600mW table whose highest entry is 600, and impl_SetPowerByIndex can only
request values from that table (capping cannot increase it).

src/main/io/vtx_tramp.c[222-242]
src/main/io/vtx_tramp.c[569-573]
src/main/io/vtx_tramp.c[581-619]
src/main/io/vtx_tramp.c[428-443]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The TRAMP 5.8GHz power metadata selection no longer handles devices whose reported `maxPower` is >=800mW but <2500mW, so those devices use the 600mW table and cannot select 800mW.

## Issue Context
`vtxProtoProcessResponse()` reads `capabilities.powerMax` from the VTX and calls `vtxProtoUpdatePowerMetadata(powerMax)`. Power selection (`impl_SetPowerByIndex`) uses `vtxState.metadata.powerTablePtr` values; if the selected table does not include 800, the firmware cannot ever request 800mW (even though it caps requested power to `powerMax`).

## Fix Focus Areas
- src/main/io/vtx_tramp.c[563-574]
- src/main/io/vtx_tramp.c[581-645]
- src/main/io/vtx_tramp.c[428-443]

## Proposed fix
1. Reintroduce the 5.8GHz 800mW power table + names (the prior 25/100/200/500/800 mapping).
2. Add an `else if (maxPower >= 800)` branch between the 2500 and 600 branches to select that table and set matching `powerTableCount`/`capability.powerCount`.
3. Keep the 2500mW handling as the top branch for `maxPower >= 2500`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can ask Qodo to dismiss a finding you disagree with, with your reason on record

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread src/main/io/vtx_tramp.c
Comment on lines +605 to 608
if (maxPower >= 2500) {
vtxState.metadata.powerTablePtr = trampPowerTable_5G8_2500;
vtxState.metadata.powerTableCount = 4;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. 800mw power capped 🐞 Bug ≡ Correctness

vtxProtoUpdatePowerMetadata() now only selects the new 2500mW table when maxPower>=2500; a TRAMP VTX
reporting maxPower=800 will fall through to the 600mW table and can never request 800mW. This causes
incorrect capability metadata and prevents users from using the device’s supported max power.
Agent Prompt
## Issue description
The TRAMP 5.8GHz power metadata selection no longer handles devices whose reported `maxPower` is >=800mW but <2500mW, so those devices use the 600mW table and cannot select 800mW.

## Issue Context
`vtxProtoProcessResponse()` reads `capabilities.powerMax` from the VTX and calls `vtxProtoUpdatePowerMetadata(powerMax)`. Power selection (`impl_SetPowerByIndex`) uses `vtxState.metadata.powerTablePtr` values; if the selected table does not include 800, the firmware cannot ever request 800mW (even though it caps requested power to `powerMax`).

## Fix Focus Areas
- src/main/io/vtx_tramp.c[563-574]
- src/main/io/vtx_tramp.c[581-645]
- src/main/io/vtx_tramp.c[428-443]

## Proposed fix
1. Reintroduce the 5.8GHz 800mW power table + names (the prior 25/100/200/500/800 mapping).
2. Add an `else if (maxPower >= 800)` branch between the 2500 and 600 branches to select that table and set matching `powerTableCount`/`capability.powerCount`.
3. Keep the 2500mW handling as the top branch for `maxPower >= 2500`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant