Add * to the end of flight mode string in CRSF

This commit is contained in:
Mingchen Zhang 2021-10-10 00:07:42 -07:00 committed by Andrew Tridgell
parent d85992613b
commit ad6355c029
1 changed files with 7 additions and 1 deletions

View File

@ -916,7 +916,13 @@ void AP_CRSF_Telem::calc_flight_mode()
AP_Notify * notify = AP_Notify::get_singleton(); AP_Notify * notify = AP_Notify::get_singleton();
if (notify) { if (notify) {
// Note: snprintf() always terminates the string // Note: snprintf() always terminates the string
hal.util->snprintf(_telem.bcast.flightmode.flight_mode, sizeof(AP_CRSF_Telem::FlightModeFrame), "%s", notify->get_flight_mode_str()); hal.util->snprintf(
_telem.bcast.flightmode.flight_mode,
sizeof(AP_CRSF_Telem::FlightModeFrame),
"%s%s",
notify->get_flight_mode_str(),
hal.util->get_soft_armed() ? "" : "*"
);
// Note: strlen(_telem.bcast.flightmode.flight_mode) is safe because called on a guaranteed null terminated string // Note: strlen(_telem.bcast.flightmode.flight_mode) is safe because called on a guaranteed null terminated string
_telem_size = strlen(_telem.bcast.flightmode.flight_mode) + 1; //send the terminator as well _telem_size = strlen(_telem.bcast.flightmode.flight_mode) + 1; //send the terminator as well
_telem_type = AP_RCProtocol_CRSF::CRSF_FRAMETYPE_FLIGHT_MODE; _telem_type = AP_RCProtocol_CRSF::CRSF_FRAMETYPE_FLIGHT_MODE;