LCOV - code coverage report
Current view: top level - AP_Baro - AP_Baro_ExternalAHRS.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 20 21 95.2 %
Date: 2026-09-09 11:02:08 Functions: 3 3 100.0 %

          Line data    Source code
       1             : #include "AP_Baro_ExternalAHRS.h"
       2             : 
       3             : #if AP_BARO_EXTERNALAHRS_ENABLED
       4             : 
       5          62 : AP_Baro_ExternalAHRS::AP_Baro_ExternalAHRS(AP_Baro &baro, uint8_t port) :
       6          62 :     AP_Baro_Backend(baro)
       7             : {
       8          62 :     instance = _frontend.register_sensor();
       9          62 :     set_bus_id(instance, AP_HAL::Device::make_bus_id(AP_HAL::Device::BUS_TYPE_SERIAL,port,0,0));
      10          62 : }
      11             : 
      12             : // Read the sensor
      13       13022 : void AP_Baro_ExternalAHRS::update(void)
      14             : {
      15       13022 :     if (count) {
      16       13007 :         WITH_SEMAPHORE(_sem);
      17       13007 :         _copy_to_frontend(instance, sum_pressure/count, sum_temp/count);
      18       13007 :         sum_pressure = sum_temp = 0;
      19       13007 :         count = 0;
      20       13007 :     }
      21       13022 : }
      22             : 
      23      128559 : void AP_Baro_ExternalAHRS::handle_external(const AP_ExternalAHRS::baro_data_message_t &pkt)
      24             : {
      25      128559 :     if (pkt.instance != 0) {
      26             :         // not for us
      27           0 :         return;
      28             :     }
      29      128559 :     WITH_SEMAPHORE(_sem);
      30      128559 :     sum_pressure += pkt.pressure_pa;
      31      128559 :     sum_temp += pkt.temperature;
      32      128559 :     count++;
      33      128559 : }
      34             : 
      35             : #endif // AP_BARO_EXTERNALAHRS_ENABLED

Generated by: LCOV version 1.14