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

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "AP_RangeFinder_config.h"
       4             : 
       5             : #if AP_RANGEFINDER_ENABLED
       6             : 
       7             : #include "AP_RangeFinder_Backend.h"
       8             : 
       9             : class AP_RangeFinder_Backend_Serial : public AP_RangeFinder_Backend
      10             : {
      11             : public:
      12             :     // constructor
      13             :     AP_RangeFinder_Backend_Serial(RangeFinder::RangeFinder_State &_state,
      14             :                                   AP_RangeFinder_Params &_params);
      15             : 
      16             :     void init_serial(uint8_t serial_instance) override;
      17             : 
      18             : protected:
      19             : 
      20             :     // baudrate used during object construction:
      21             :     virtual uint32_t initial_baudrate(uint8_t serial_instance) const;
      22             : 
      23             :     // the value 0 is special to the UARTDriver - it's "use default"
      24          24 :     virtual uint16_t rx_bufsize() const { return 0; }
      25          24 :     virtual uint16_t tx_bufsize() const { return 0; }
      26             : 
      27             :     AP_HAL::UARTDriver *uart = nullptr;
      28             : 
      29             :     // update state; not all backends call this!
      30             :     virtual void update(void) override;
      31             : 
      32             :     // it is essential that anyone relying on the base-class update to
      33             :     // implement this:
      34             :     virtual bool get_reading(float &reading_m) = 0;
      35             : 
      36             :     // returns 0-100 or -1. This virtual method is for
      37             :     // serial drivers and is a companion to the previous method get_reading().
      38             :     // Like get_reading() this method is called in the base-class update() method.
      39        7757 :     virtual int8_t get_signal_quality_pct() const WARN_IF_UNUSED
      40        7757 :     { return RangeFinder::SIGNAL_QUALITY_UNKNOWN; }
      41             : 
      42             :     // maximum time between readings before we change state to NoData:
      43       19482 :     virtual uint16_t read_timeout_ms() const { return 200; }
      44             : };
      45             : 
      46             : #endif  // AP_RANGEFINDER_ENABLED

Generated by: LCOV version 1.14