LCOV - code coverage report
Current view: top level - AP_MSP - AP_MSP_Telem_DisplayPort.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 12 23 52.2 %
Date: 2026-09-09 11:02:08 Functions: 3 4 75.0 %

          Line data    Source code
       1             : /*
       2             :    This program is free software: you can redistribute it and/or modify
       3             :    it under the terms of the GNU General Public License as published by
       4             :    the Free Software Foundation, either version 3 of the License, or
       5             :    (at your option) any later version.
       6             : 
       7             :    This program is distributed in the hope that it will be useful,
       8             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
       9             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      10             :    GNU General Public License for more details.
      11             : 
      12             :    You should have received a copy of the GNU General Public License
      13             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      14             : */
      15             : 
      16             : #include <AP_Common/AP_FWVersion.h>
      17             : #include <AP_Vehicle/AP_Vehicle_Type.h>
      18             : 
      19             : #include "AP_MSP.h"
      20             : #include "AP_MSP_Telem_DisplayPort.h"
      21             : 
      22             : #if HAL_WITH_MSP_DISPLAYPORT
      23             : 
      24             : extern const AP_HAL::HAL& hal;
      25             : 
      26             : using namespace MSP;
      27             : 
      28           0 : MSPCommandResult AP_MSP_Telem_DisplayPort::msp_process_out_fc_variant(sbuf_t *dst)
      29             : {
      30           0 :     const AP_MSP *msp = AP::msp();
      31           0 :     if (msp == nullptr) {
      32           0 :         return MSP_RESULT_ERROR;
      33             :     }
      34             :     // report the flight controller identifier matching the selected OSD symbol
      35             :     // table. A betaflight-style MSP VTX (e.g. HDZero) only runs its config
      36             :     // handshake against a "BTFL" FC, so selecting BTFL symbols also enables
      37             :     // MSP VTX control.
      38           0 :     if (msp->is_option_enabled(AP_MSP::Option::DISPLAYPORT_INAV_SYMBOLS)) {
      39           0 :         sbuf_write_data(dst, INAV_IDENTIFIER, FLIGHT_CONTROLLER_IDENTIFIER_LENGTH);
      40           0 :     } else if (msp->is_option_enabled(AP_MSP::Option::DISPLAYPORT_BTFL_SYMBOLS)) {
      41           0 :         sbuf_write_data(dst, BETAFLIGHT_IDENTIFIER, FLIGHT_CONTROLLER_IDENTIFIER_LENGTH);
      42             :     } else {
      43           0 :         sbuf_write_data(dst, ARDUPILOT_IDENTIFIER, FLIGHT_CONTROLLER_IDENTIFIER_LENGTH);
      44             :     }
      45             : 
      46           0 :     return MSP_RESULT_ACK;
      47             : }
      48             : 
      49         548 : bool AP_MSP_Telem_DisplayPort::is_scheduler_enabled() const
      50             : {
      51             : #if AP_MSP_VIDEOTX_ENABLED
      52         548 :     return AP::vtx().get_enabled();
      53             : #else
      54             :     return false;
      55             : #endif
      56             : }
      57             : 
      58        6409 : bool AP_MSP_Telem_DisplayPort::is_packet_ready(uint8_t idx, bool queue_empty)
      59             : {
      60        6409 :     switch (idx) {
      61             : #if AP_MSP_VIDEOTX_ENABLED
      62          53 :     case VTX_PARAMETERS:    // VTX control
      63          53 :         return AP::vtx().get_enabled();
      64             : #endif
      65        6356 :     default:
      66        6356 :         return false;
      67             :     }
      68             : }
      69             : 
      70           4 : bool AP_MSP_Telem_DisplayPort::init_uart()
      71             : {
      72           4 :     if (_msp_port.uart != nullptr)  {
      73             :         // re-init port here for use in this thread
      74             :         // displayport needs a bigger tx buffer
      75             :         // rx buffer can be small for we mostly write
      76           4 :         _msp_port.uart->begin(0, 256, 768);
      77           4 :         return true;
      78             :     }
      79           0 :     return false;
      80             : }
      81             : 
      82             : #endif //HAL_WITH_MSP_DISPLAYPORT

Generated by: LCOV version 1.14