fix(crsf_rc): send the flight mode telemetry frame again (#29446)

* fix(crsf_rc): send the flight mode telemetry frame again

The arming check added with the bind command (#26790) reads vehicle_status
through the same subscription as the flight mode telemetry. Its copy()
advances that subscription on every Run(), so the telemetry slot's update()
never sees a new message and the flight mode frame (0x21) is never sent.

Give the arming check its own vehicle_status subscription.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: devteamaegis <devteam.aegis@gmail.com>

* fix(crsf_rc): read vehicle_status once per cycle instead of a second subscription

Per review: update the cached vehicle_status once at the top of Run(), use
it for the arming state, and let the flight mode telemetry slot send from
the cached copy when a new message arrived since its last send.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: devteamaegis <devteam.aegis@gmail.com>

---------

Signed-off-by: devteamaegis <devteam.aegis@gmail.com>
This commit is contained in:
Ishaan Samantray authored and GitHub committed 2026-10-29 11:59:41 -06:00
1 parent 888b0a942d
commit a54e6115d2
2 files changed
+9 -11

No files matched your search

+7 -11
View File
@@ -212,12 +212,9 @@ void CrsfRc::Run()
const hrt_abstime time_now_us = hrt_absolute_time();
perf_count_interval(_cycle_interval_perf, time_now_us);
if (_vehicle_status_sub.updated()) {
vehicle_status_s vehicle_status;
if (_vehicle_status_sub.copy(&vehicle_status)) {
_armed = (vehicle_status.arming_state == vehicle_status_s::ARMING_STATE_ARMED);
}
if (_vehicle_status_sub.update(&_vehicle_status)) {
_armed = (_vehicle_status.arming_state == vehicle_status_s::ARMING_STATE_ARMED);
_vehicle_status_updated = true;
}
vehicle_command_s vcmd{};
@@ -359,12 +356,11 @@ void CrsfRc::Run()
break;
case 3:
vehicle_status_s vehicle_status;
if (_vehicle_status_sub.update(&vehicle_status)) {
if (_vehicle_status_updated) {
_vehicle_status_updated = false;
const char *flight_mode = "(unknown)";
switch (vehicle_status.nav_state) {
switch (_vehicle_status.nav_state) {
case vehicle_status_s::NAVIGATION_STATE_MANUAL:
flight_mode = "Manual";
break;
@@ -382,7 +378,7 @@ void CrsfRc::Run()
break;
case vehicle_status_s::NAVIGATION_STATE_POSCTL:
flight_mode = (vehicle_status.vehicle_type == vehicle_status_s::VEHICLE_TYPE_FIXED_WING) ? "Cruise" : "Position";
flight_mode = (_vehicle_status.vehicle_type == vehicle_status_s::VEHICLE_TYPE_FIXED_WING) ? "Cruise" : "Position";
break;
case vehicle_status_s::NAVIGATION_STATE_AUTO_RTL:
+2
View File
@@ -104,6 +104,8 @@ private:
char _device[20] {}; ///< device / serial port path
bool _is_singlewire{false};
bool _armed{false};
vehicle_status_s _vehicle_status{};
bool _vehicle_status_updated{false};
static constexpr size_t RC_MAX_BUFFER_SIZE{64};
uint8_t _rcs_buf[RC_MAX_BUFFER_SIZE] {};