Commit Graph
51 Commits
Author SHA1 Message Date
Peter Barker 4456a028bf AP_VideoTX: remove VTX_OPTIONS parameter width conversion
This was meant to convert VTX_OPTIONS from int8 to int16, and is present
in the 4.3.0 release, so anybody running 4.3.0 or later has already had
it applied.

It should be noted that it never actually did anything.  0658f06030
widened _options from AP_Int8 to AP_Int16 and added the conversion in
the same commit, but passed the new width rather than the old one:

    _options.convert_parameter_width(AP_PARAM_INT16);

The argument to convert_parameter_width() is the type the value was
stored as *before* the widening, so this should have been
AP_PARAM_INT8.  AP_Param::scan() matches on the type in the parameter
header, so a value written as an int8 is never found by a scan for an
int16 and the conversion always returned false without touching
anything.  A user upgrading across the widening lost their VTX_OPTIONS
regardless.

So this removes dead code, and the migration floor is not really what
makes it safe to do so.
2026-09-01 20:49:36 +10:00
Peter Barker 4b2e59e21b AP_VideoTX: correct parameter conversion comment format
These are now "PARAMETER_CONVERSION - Added: <Mon>-<Year>", so a grep for conversion vintages finds them and can parse the date.  No functional change.

Also names the release the conversion was for, which is the part that
actually matters when deciding whether a conversion can be retired.  The
date alone is ambiguous here: 0658f06030 was authored Dec-2021 but did
not reach master until Sep-2022, and the conversion is absent from
4.2.0 and present in 4.3.0.  Dating it from when it was written would
point at the wrong release.
2026-08-31 08:18:26 +10:00
Peter Barker b42670f281 AP_VideoTX: correct '#endif // COMMENT' comments
these should always match the opening #if
2026-08-04 11:59:14 +10:00
Andy Piper dc09655501 AP_VideoTX: drop redundant AP_MSP_VIDEOTX_ENABLED default
The default now lives in AP_MSP/AP_MSP_config.h, which this header
already includes; keep it in one place.
2026-07-29 17:16:29 +10:00
Andy Piper 0a4b9e2c27 AP_VideoTX: add set_option_enabled and tidy MSP power helpers
set_option_enabled sets or clears a single configured option bit,
replacing the open-coded read-modify-write the MSP VTX pitmode path
used. Use ARRAY_SIZE(_power_levels) for the new power-level loops and
call the levels "active" to match the state they test.
2026-07-29 17:16:29 +10:00
Andy Piper 6fc59ab03d AP_VideoTX: default MSP VTX control to off
It is non-essential and only useful with a digital VTX, so do not build it
into every >1MB board. Boards with the hardware opt in (FPV/OSD boards via
minimize_fpv_osd.inc, others by defining AP_MSP_VIDEOTX_ENABLED).
2026-07-29 17:16:29 +10:00
Andy Piper 0ab5540f2b AP_VideoTX: add MSP VTX provider support
Add MSP as a VTX control transport alongside the existing providers.
VTX_TYPES selects which transport is allowed to drive the VTX so MSP and
SmartAudio/Tramp/CRSF do not fight over it.

The MSP provider is built behind AP_MSP_VIDEOTX_ENABLED, which requires
HAL_MSP_ENABLED and defaults on for boards with more than 1MB of flash.

Power levels from MSP arrive as a one-based index; map it onto the
supported levels so it lines up with the rest of the VTX power handling.
2026-07-29 17:16:29 +10:00
Peter BarkerandClaude Opus 4.8 9a7c74e3fb AP_VideoTX: clamp SmartAudio power level count from the wire
unpack_settings() for the v2.1 extended response frame copied
num_power_levels+1 bytes into the fixed power_levels[8] array, where
num_power_levels comes straight from the wire and is unbounded.  A
malformed frame could request a copy of up to 256 bytes, overrunning
both the source and destination arrays.

Clamp the count to the size of the arrays before copying.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-31 12:33:22 +10:00
Peter BarkerandClaude Opus 4.8 701f11f8b6 AP_VideoTX: validate SmartAudio response length before parsing
parse_response_buffer() cast the received buffer to the response frame
struct selected by the command byte without checking that enough bytes
were actually received.  A short or corrupt frame (for example a
GET_SETTINGS response with a length field of zero) could pass the CRC
check yet cause the parser to read channel/power/frequency fields from
buffer positions that were never written this cycle, pushing stale
values into the VTX settings.

Pass the received byte count into parse_response_buffer() and, in each
command case, reject frames that are too short for the struct being
interpreted.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-31 12:33:22 +10:00
Andy Piper 7f2cec578a AP_VideoTX: surface actual VTX power and bound retries on rejection
The Tramp 'v' reply reports both configured and actual power, but only
the configured value reached AP_VideoTX, hiding VTXes that ignore the
request or have a hardware power floor. Expose the actual value via
set/get_actual_power_mw() (-1 = not reported) and warn once when it
exceeds VTX_MAX_POWER or the request by more than 50%.

update_power() also rejected any mW not in the SmartAudio power table,
silently dropping valid Tramp values like 2500mW. Accept off-table
values when a Tramp provider is active, stashing them in the custom
power slot so later equality checks still work.

A VTX that silently rejects a value drove an infinite retry loop because
update() re-armed retry_count on every mismatch. Re-arm only when the
configured value actually changes, and warn once when retries exhaust on
the same value. Also defines get_current_actual_power() and
get_current_temp(), which were declared but never implemented.
2026-05-27 21:12:24 +01:00
Andy Piper c7b6c02d6b AP_VideoTX: force maximum power output at maximum level 2026-04-14 09:39:00 +10:00
truepasha 7b481f32d9 AP_VideoTX: fix LowRace Band (BUG)
Fixes an issue where setting the VTX_BAND parameter to LowRace would cause the video transmitter to hang or stop responding. Now LowRace band can be selected and used reliably without causing any malfunction.
2025-05-24 15:28:21 +01:00
Peter Barker 6338d10b5f global: create and use HAL_PROGRAM_SIZE_LIMIT_KB
We will reserve BOARD_FLASH_SIZE for the internal flash on stm32 flash processors, use HAL_PROGRAM_SIZE_LIMIT_KB in the general code base.

Notable change here is that boards with external flash will start to get features only available with more than 2MB of program storage
2025-02-26 10:06:39 +11:00
muramura 8dc7fdb771 AP_VideoTX: Change division to multiplication 2025-01-02 23:22:42 +11:00
Patrick Menschel 9f29606d1c AP_Tramp: Fix _configuration_finished indication
The flag _configuration_finished in AP_VideoTX
is not set by AP_Tramp.
Therefore OSD item VTX_PWR blinks forever.
2024-11-13 07:50:05 +11:00
root c854830702 AP_VideoTX:add additional freq bands(RushFPV 3.3GHz) 2024-08-13 21:32:56 +10:00
Peter Barker 92dd71203e AP_VideoTX: correct include to use config.h
need to avoid random headers in these config files!
2024-08-12 17:52:04 +10:00
Andy Piper 607249d73d AP_VideoTX: add autobauding to Tramp
Record enabled backends
2024-05-29 17:49:08 +10:00
root 0c2e9a061b AP_VideoTX:add additional freq bands(Band X) 2024-03-19 07:30:49 +11:00
Brad Bosch 0a5407a1a7 AP_VideoTX: Restore use of the VTX_MAX_POWER parameter
This functionality was lost when a significant rewrite of this code was done in commit 0658f06030
2024-01-02 12:00:22 +11:00
zvldz 8e08a9bdf6 AP_VideoTX:add additional freq bands 2023-09-13 18:05:24 +10:00
Andy Piper e1db6e38e2 AP_VideoTX: protect vtx from pitmode changes when not enabled or not armed 2023-02-15 19:30:28 +11:00
Andy Piper 29d5d5a300 AP_VideoTX: learn all the power levels when using SmartAudio 2.0 2023-01-31 11:23:59 +11:00
Peter Barker 08e42d2699 AP_VideoTX: use minimize.inc for Tramp and SmartAudio
... and rename HAL_SMARTAUDIO_ENABLED
2023-01-24 11:03:27 +11:00
Peter Barker 20f504d337 AP_VideoTX: add and use AP_VIDEOTX_ENABLED 2023-01-24 11:03:27 +11:00
Peter Barker 96900ea627 AP_VideoTX: tidy AP_SerialManager.h includes 2022-11-08 09:49:19 +11:00
jackhong12 4a4f361a17 all: use CLASS_NO_COPY() macro 2022-10-04 11:23:04 +11:00
Andy Piper f651a4b6ce AP_VideoTX: ensure that Tramp changes are broadcast to the GCS 2022-09-22 10:48:04 +10:00
Andy Piper d20fd16a14 AP_VideoTX: fix potential buffer overrun bug 2022-09-22 10:48:04 +10:00
Andy Piper 0658f06030 AP_VideoTX: add lookup tables for VTX power settings
correct settings when power set is received
add support for capturing all supported power levels
learn power levels in SmartAudio 2.1
add better support for VTX power levels
don't set power to 0 if in pitmode
add option for iNav compatibility
support non-conforming SmartAudio implementations
re-enable pitmode on SmartAudio 2.0
add support for "blind" VTX setting
2022-09-22 10:48:04 +10:00
Iampete1 0ef78c2f8b AP_VideoTX: params always use set method 2022-08-03 13:43:48 +01:00
Andy Piper 6ab6aa1ef4 AP_VideoTX: Tramp VTX support
Tramp enabled on 2Mb boards with OSD via AP_TRAMP_ENABLED
2022-07-13 18:22:34 +10:00
Andrew Tridgell be33f77725 AP_VideoTX: fixed use of configured() vs configured_in_storage() 2022-06-06 13:11:50 +10:00
Peter Barker 2ffc16d1c5 AP_VideoTX: tidy includes 2022-05-03 09:14:58 +10:00
murata 5d2c49e202 AP_VideoTX: Change from division to multiplication 2022-03-16 18:41:52 +11:00
VMsunghwan a49bab158f AP_VideoTX : fixed typo
line 610 : to to -> to
2022-01-13 09:45:39 +11:00
Mingchen Zhang 61e0c5b6e7 AP_SmartAudio: fix a bug that would starve the lower priority thread, such as scripting. 2021-12-21 16:03:44 +09:00
giacomo892 9056cd35ea AP_SmartAudio: Add pull down VTX option 2021-06-16 18:49:13 +10:00
giacomo892 49536ceecb AP_VideoTX: Add pull down VTX option 2021-06-16 18:49:13 +10:00
giacomo892 f12fffbb08 AP_SmartAudio: Remove useless variable and comment 2021-06-16 18:49:13 +10:00
giacomo892 2198893092 AP_VideoTX: Add band names to GCS 2021-06-16 18:49:13 +10:00
giacomo892 0af5a7787a AP_VideoTX: Add configuration_finished functions 2021-06-16 18:49:13 +10:00
giacomo892 4dac9baa09 AP_SmartAudio: Add configuration_finished and configuration_pending functions 2021-06-16 18:49:13 +10:00
Andy Piper db06de5c9c AP_VideoTX: correctly deal with unresolvable options requests
move power changes to middle of RC range
2021-05-12 18:03:28 +10:00
Andy Piper 21e95a62d5 AP_VideoTX: increase stack for smart audio thread 2021-04-20 10:39:16 +10:00
Andy Piper 4fd88e8ad0 AP_VideoTX: don't try to change pitmode on anything other than SA2.1 2021-04-12 16:22:36 +10:00
Andy Piper bfcefa3f34 AP_VideoTX: prioritize pitmode changes over power changes 2021-04-12 16:22:36 +10:00
Andy Piper 961c517274 AP_VideoTX: only mark updates when the VTX is enabled 2021-03-17 18:27:11 +11:00
Andy Piper f7e23566ac AP_VideoTX: with SmartAudio v2 set the power level rather than power in dBm 2021-03-17 18:27:11 +11:00
Andy Piper 7039d67474 AP_VideoTX: move AP_VideoTX to AP_VideoTX 2021-02-23 11:43:32 +11:00