LCOV - code coverage report
Current view: top level - AP_RangeFinder - AP_RangeFinder_MAVLink.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 3 3 100.0 %
Date: 2026-09-09 11:02:08 Functions: 2 2 100.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "AP_RangeFinder_config.h"
       4             : 
       5             : #if AP_RANGEFINDER_MAVLINK_ENABLED
       6             : 
       7             : #include "AP_RangeFinder.h"
       8             : #include "AP_RangeFinder_Backend.h"
       9             : 
      10             : // Data timeout
      11             : #define AP_RANGEFINDER_MAVLINK_TIMEOUT_MS 500
      12             : 
      13             : class AP_RangeFinder_MAVLink : public AP_RangeFinder_Backend
      14             : {
      15             : 
      16             : public:
      17             : 
      18             :     // constructor
      19             :     using AP_RangeFinder_Backend::AP_RangeFinder_Backend;
      20             : 
      21             :     // Assume that if the user set the RANGEFINDER_TYPE parameter to MAVLink,
      22             :     // there is an attached MAVLink rangefinder
      23           4 :     static bool detect() { return true; }
      24             : 
      25             :     // update state
      26             :     void update(void) override;
      27             : 
      28             :     // Get update from mavlink
      29             :     void handle_msg(const mavlink_message_t &msg) override;
      30             : 
      31             :     float max_distance() const override;
      32             :     float min_distance() const override;
      33             : 
      34             : protected:
      35             : 
      36         466 :     MAV_DISTANCE_SENSOR _get_mav_distance_sensor_type() const override {
      37         466 :         return sensor_type;
      38             :     }
      39             : 
      40             : private:
      41             : 
      42             :     // stored data from packet:
      43             :     float distance;
      44             :     float _max_distance;
      45             :     float _min_distance;
      46             :     int8_t signal_quality;
      47             : 
      48             :     // start a reading
      49             :     static bool start_reading(void);
      50             :     static bool get_reading(uint16_t &reading_cm);
      51             : 
      52             :     MAV_DISTANCE_SENSOR sensor_type = MAV_DISTANCE_SENSOR_UNKNOWN;
      53             : };
      54             : 
      55             : #endif

Generated by: LCOV version 1.14