Repository navigation
OSD: optional disarm hold on the MSP DisplayPort port only (osd_msp_disarm_hold) - #12246
erwinquilloy wants to merge 1 commit into
Conversation
DJI goggles record only while the FC reports ARMED, so the stats screen, drawn at disarm, is never recorded. osd_msp_disarm_hold (0-7 s, default 0 = off) keeps the ARM bit in the status replies on the MSP DisplayPort (MSP_OSD) serial port only, for that long after a disarm. The flight controller disarms at once. Every other MSP user (MSP ports such as mLRS, MSP over CRSF / SmartPort, MSP in MAVLink, the configurator) is answered by mspFcProcessCommand directly and sees the real arm state. MSP_STATUS / MSP_STATUS_EX / MSP2_INAV_STATUS: only mode bit 0 (ARM, and ARMED in INAV_STATUS armingFlags) changes. The new field is appended to osdConfig_t, so saved OSD settings load unchanged.
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
PR Summary by QodoHold the ARM indication briefly on MSP DisplayPort after disarm
AI Description
Merge Risk
|
Code Review by Qodo
1. Extended status replies disagree on arming
|
|
https://www.youtube.com/watch?v=Phk2TsFHvSo - long video with disarm delay in action at the end https://youtu.be/4VapQdlyU4o - bench testing I have tested that in both INAV and Ardupilot custom build crafts. Checked Crossfire, MLRS, ELRS and R9 RC links. In every case there were no issues upon disarming - everything stopped as normal, and OSD got recorded for a set amount of seconds. The long video has the disarm delay at the end visible, the short one is bench testing with forced arming. |
|
Tested this in flight today on a fixed wing. Rc protocol is CRSF (Mlrs using MSP-X). I also used KiteGC Mobile to upload a WP mission via MSP. The flight was flawless, no issues using KiteGC while the Displayport delay active. Video is sped up but the delay did let the recording continue for 5 seconds after disarm. Yesterday I tested this on the bench with forced FC arming, and a normal arming in the backyard. I discovered zero issues in all three test. |
What it does
DJI air units (and other digital VTX systems that start and stop the DVR from the FC's arm state) stop recording the moment they see the disarm. INAV draws the post-flight stats screen after the disarm, so it never makes it into the goggle recording. This has been asked for several times (#10851, #11475).
This PR adds one setting,
osd_msp_disarm_hold(0-7 s, default 0 = off, no change in behaviour). When it is set, the status replies sent on the MSP DisplayPort serial port only keep the ARM bit for that many seconds after a disarm, so the goggles keep recording long enough to capture the stats screen.This is not a global change to the arm state
I've read the earlier discussions. The objections were that the arm state must stay true, that a delay would reach ground stations, Bluetooth/WiFi adapters, companion computers and other MSP devices, and that INAV can't tell which device is asking. I agree with all of that, and this PR is built around it:
ARMING_FLAG(ARMED), the motors, the mixer, failsafe, logging and every other part of the firmware are untouched. Nothing in this PR delays or changes the disarm itself.MSP DisplayPortfunction (FUNCTION_MSP_OSD). INAV does know what is on that port. The user configured it as the DisplayPort OSD for the air unit. The change is a small wrapper around the command handler that onlymspOsdSerialProcess()uses, and it edits the reply bytes after the normal handler has written them.mspFcProcessCommand()directly and never go through the wrapper:MSPserial port, e.g. mLRS, Bluetooth/WiFi adapters, companion computers and the configurator (mspSerialProcess()infc_tasks.c)telemetry/msp_shared.c)fc/fc_mavlink.c)FUNCTION_DJI_HD_OSD,osd_dji_hd.c, its own handler)isSerialConfigValid()only allows MSP to share a port with telemetry, blackbox or log, and the DisplayPort OSD has its ownmspPort, opened withFUNCTION_MSP_OSD. So a GCS, adapter or receiver link cannot receive the held replies.MSP_STATUS/MSP_STATUS_EX: mode flags byte 6, bit 0. This is BOXARM, whichinitActiveBoxIds()always adds first, and it is also the DJI ARM bit in the O4 workaround reply.MSP2_INAV_STATUS:ARMEDinarmingFlags(byte 9) and mode flags byte 13, bit 0.millis()with a wrap-safe compare. It doesn't uselastDisarmTimeUs, because 32-bit micros wrap after about 71 min.The code
The whole runtime change is in
src/main/io/displayport_msp_osd.c:reply->buf.ptris the start of the reply buffer when the handler is called (mspSerialProcessReceivedCommand()inmsp_serial.c), sostart[n]is bytenof the payload. The length checks keep the patch inside what the handler actually wrote.Other files:
src/main/fc/settings.yaml:osd_msp_disarm_hold, uint8, 0-7, default 0,condition: USE_MSP_OSD.src/main/io/osd.h:uint8_t msp_disarm_holdappended at the end ofosdConfig_t. The PG version is unchanged, so existing saved OSD settings load as they are and the new field takes its default of 0.src/main/io/osd.c: reset template default.docs/Settings.md: regenerated withsrc/utils/update_cli_docs.py.5 files, +74 / -2. Flash cost is about 200 bytes.
Usage
Use 0 (default) for off and 1-7 for seconds. CLI only, no configurator change needed.
Testing
SITL (
next-10.1+ this PR), three ports at once:MSP_STATUS,MSP_STATUS_EXandMSP2_INAV_STATUSare polled on UART2 and UART3 after every disarm.osd_msp_disarm_holdWith hold 3, over 6 arm/disarm cycles, the DisplayPort held ARM for 3.00, 2.97, 2.97, 3.00, 2.97 and 2.98 s, measured from the moment the truth port reported the disarm. The plain MSP port showed the disarm on the first sample in 18 of 18 checks (3 messages × 6 cycles). With hold 0, both ports were identical to stock over 3 cycles. The FC's own
armingFlagsalways dropped ARMED at the disarm. While armed, no port ever reported disarmed.Host unit test (the two functions compiled against stubs): boot state, hold timing, re-arm during hold, hold 0 unchanged, clamp to 7,
millis()wrap. All pass.Hardware (built on 9.1.0, where the same commit applies without changes):
osd_msp_disarm_hold = 7. The motor stops at disarm and the goggles keep recording for 7 s, including the stats screen.Builds with
-DWARNINGS_AS_ERRORS=ONonnext-10.1: MATEKH743 (H7), MATEKF405TE (F4), TBS_LUCID_FC (AT32F435), SITL.Not covered
FUNCTION_DJI_HD_OSDport (old DJI FPV system protocol) is not changed. It has its own handler, and the hold could be added there the same way if wanted.