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

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "AP_RangeFinder_config.h"
       4             : 
       5             : #if AP_RANGEFINDER_LIGHTWARE_SERIAL_ENABLED
       6             : 
       7             : #include "AP_RangeFinder.h"
       8             : #include "AP_RangeFinder_Backend_Serial.h"
       9             : 
      10             : class AP_RangeFinder_LightWareSerial : public AP_RangeFinder_Backend_Serial
      11             : {
      12             : 
      13             : public:
      14             : 
      15           3 :     static AP_RangeFinder_Backend_Serial *create(
      16             :         RangeFinder::RangeFinder_State &_state,
      17             :         AP_RangeFinder_Params &_params) {
      18           3 :         return NEW_NOTHROW AP_RangeFinder_LightWareSerial(_state, _params);
      19             :     }
      20             : 
      21             : protected:
      22             : 
      23             :     using AP_RangeFinder_Backend_Serial::AP_RangeFinder_Backend_Serial;
      24             : 
      25        1392 :     MAV_DISTANCE_SENSOR _get_mav_distance_sensor_type() const override {
      26        1392 :         return MAV_DISTANCE_SENSOR_LASER;
      27             :     }
      28             : 
      29        1395 :     int8_t get_signal_quality_pct() const override {
      30        1395 :         return no_signal ? RangeFinder::SIGNAL_QUALITY_MIN : RangeFinder::SIGNAL_QUALITY_MAX;
      31             :     }
      32             : 
      33             : private:
      34             :     // get a reading
      35             :     bool get_reading(float &reading_m) override;
      36             :     bool is_lost_signal_distance(int16_t distance_cm, int16_t distance_cm_max);
      37             : 
      38             :     char linebuf[10];           // legacy protocol buffer
      39             :     uint8_t linebuf_len;        // legacy protocol buffer length
      40             :     uint32_t last_init_ms;      // init time used to switch lw20 to serial mode
      41             :     uint8_t high_byte;          // binary protocol high byte
      42             :     bool high_byte_received;    // true if high byte has been received
      43             : 
      44             :     // automatic protocol decision variables
      45             :     enum class ProtocolState {
      46             :         UNKNOWN,    // the protocol used is not yet known
      47             :         LEGACY,     // legacy protocol, distances are sent as strings
      48             :         BINARY      // binary protocol, distances are sent using two bytes
      49             :     } protocol_state;
      50             :     uint8_t legacy_valid_count;
      51             :     uint8_t binary_valid_count;
      52             : 
      53             :     bool no_signal = false;
      54             : };
      55             : 
      56             : #endif  // AP_RANGEFINDER_LIGHTWARE_SERIAL_ENABLED

Generated by: LCOV version 1.14