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

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "AP_RangeFinder_config.h"
       4             : 
       5             : #if AP_RANGEFINDER_USD1_SERIAL_ENABLED
       6             : 
       7             : #include "AP_RangeFinder.h"
       8             : #include "AP_RangeFinder_Backend_Serial.h"
       9             : 
      10             : class AP_RangeFinder_USD1_Serial : public AP_RangeFinder_Backend_Serial
      11             : {
      12             : 
      13             : public:
      14             : 
      15           2 :     static AP_RangeFinder_Backend_Serial *create(
      16             :         RangeFinder::RangeFinder_State &_state,
      17             :         AP_RangeFinder_Params &_params) {
      18           2 :         return NEW_NOTHROW AP_RangeFinder_USD1_Serial(_state, _params);
      19             :     }
      20             : 
      21             : protected:
      22             : 
      23         677 :     MAV_DISTANCE_SENSOR _get_mav_distance_sensor_type() const override {
      24         677 :         return MAV_DISTANCE_SENSOR_RADAR;
      25             :     }
      26             : 
      27             :     // baudrate used during object construction:
      28           2 :     uint32_t initial_baudrate(uint8_t serial_instance) const override {
      29           2 :         return 115200;
      30             :     }
      31             : 
      32           2 :     uint16_t rx_bufsize() const override { return 128; }
      33           2 :     uint16_t tx_bufsize() const override { return 128; }
      34             : 
      35             : private:
      36             : 
      37             :     using AP_RangeFinder_Backend_Serial::AP_RangeFinder_Backend_Serial;
      38             : 
      39             :     // detect USD1_Serial Firmware Version
      40             :     bool detect_version(void);
      41             : 
      42             :     // get a reading
      43             :     bool get_reading(float &reading_m) override;
      44             : 
      45             :     uint8_t  _linebuf[6];
      46             :     uint8_t  _linebuf_len;
      47             :     bool     _version_known;
      48             :     uint8_t  _header;
      49             :     uint8_t  _version;
      50             : };
      51             : 
      52             : #endif  // AP_RANGEFINDER_USD1_SERIAL_ENABLED

Generated by: LCOV version 1.14