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

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "AP_RangeFinder_config.h"
       4             : 
       5             : #if AP_RANGEFINDER_BACKEND_CAN_ENABLED
       6             : 
       7             : #include "AP_RangeFinder_Backend.h"
       8             : #include <AP_CANManager/AP_CANSensor.h>
       9             : #include <AP_BoardConfig/AP_BoardConfig.h>
      10             : 
      11             : class RangeFinder_MultiCAN;
      12             : 
      13             : class AP_RangeFinder_Backend_CAN : public AP_RangeFinder_Backend
      14             : {
      15             : public:
      16             :     // constructor
      17             :     AP_RangeFinder_Backend_CAN(RangeFinder::RangeFinder_State &_state,
      18             :                                 AP_RangeFinder_Params &_params, AP_CAN::Protocol can_type,
      19             :                                 const char *driver_name);
      20             : 
      21             :     friend class RangeFinder_MultiCAN;
      22             : 
      23             :     static const struct AP_Param::GroupInfo var_info[];
      24             : 
      25             : protected:
      26             : 
      27             :     // update state
      28             :     virtual void update(void) override;
      29             : 
      30             :     // get distance measurement
      31             :     bool get_reading(float &reading_m);
      32             : 
      33             :     // it is essential that anyone relying on the base-class update to implement this
      34             :     virtual bool handle_frame(AP_HAL::CANFrame &frame) = 0;
      35             : 
      36             :     // maximum time between readings before we change state to NoData:
      37           0 :     virtual uint32_t read_timeout_ms() const { return 200; }
      38             : 
      39             :     // return true if the CAN ID is correct
      40             :     bool is_correct_id(uint32_t can_id) const;
      41             : 
      42             :     // set distance and count
      43           0 :     void accumulate_distance_m(float distance_m) {
      44           0 :         _distance_sum += distance_m;
      45           0 :         _distance_count++;
      46           0 :     };
      47             : 
      48             :     // linked list
      49             :     AP_RangeFinder_Backend_CAN *next;
      50             : 
      51             :     AP_Int32 receive_id; // CAN ID to receive for this backend
      52             :     AP_Int32 snr_min; // minimum signal strength to accept packet
      53             : 
      54             :     MultiCAN* multican_rangefinder; // Allows for multiple CAN rangefinders on a single bus
      55             : private:
      56             : 
      57             :     float _distance_sum; // meters
      58             :     uint32_t _distance_count;
      59             : };
      60             : 
      61             : #endif  // AP_RANGEFINDER_BACKEND_CAN_ENABLED

Generated by: LCOV version 1.14