LCOV - code coverage report
Current view: top level - AP_RPM - RPM_Backend.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 9 12 75.0 %
Date: 2026-09-09 11:02:08 Functions: 2 2 100.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 "RPM_Backend.h"
      17             : 
      18             : #if AP_RPM_ENABLED
      19             : 
      20             : #include "AP_RPM.h"
      21             : 
      22             : #if HAL_WITH_ESC_TELEM
      23             : #include "AP_ESC_Telem/AP_ESC_Telem.h"
      24             : #endif
      25             : 
      26             : /*
      27             :   base class constructor. 
      28             : */
      29          97 : AP_RPM_Backend::AP_RPM_Backend(AP_RPM &_ap_rpm, uint8_t instance, AP_RPM::RPM_State &_state) :
      30          97 :         ap_rpm(_ap_rpm),
      31          97 :         state(_state) 
      32             : {
      33          97 :     state.instance = instance;
      34          97 : }
      35             : 
      36             : #if AP_RPM_ESC_TELEM_OUTBOUND_ENABLED
      37      484590 : void AP_RPM_Backend::update_esc_telem_outbound()
      38             : {
      39      484590 :     const uint8_t esc_index = ap_rpm._params[state.instance].esc_telem_outbound_index;
      40      484590 :     if (esc_index == 0) {
      41             :         // Disabled if there's no ESC identified to route the data to
      42      484590 :         return;
      43             :     }
      44           0 :     if (!ap_rpm.healthy(state.instance)) {
      45             :         // If we're unhealthy don't update the telemetry. Let it
      46             :         // timeout on it's own instead of showing potentially wrong data
      47           0 :         return;
      48             :     }
      49             : 
      50           0 :     AP::esc_telem().update_rpm(esc_index-1, state.rate_rpm, 0);
      51             : }
      52             : #endif
      53             : 
      54             : #endif  // AP_RPM_ENABLED

Generated by: LCOV version 1.14