mirror of https://github.com/ArduPilot/ardupilot
39 lines
1.2 KiB
C++
39 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include "AP_RangeFinder.h"
|
|
#include "AP_RangeFinder_Backend_Serial.h"
|
|
|
|
class AP_RangeFinder_LightWareSerial : public AP_RangeFinder_Backend_Serial
|
|
{
|
|
|
|
public:
|
|
|
|
using AP_RangeFinder_Backend_Serial::AP_RangeFinder_Backend_Serial;
|
|
|
|
protected:
|
|
|
|
MAV_DISTANCE_SENSOR _get_mav_distance_sensor_type() const override {
|
|
return MAV_DISTANCE_SENSOR_LASER;
|
|
}
|
|
|
|
private:
|
|
// get a reading
|
|
bool get_reading(float &reading_m) override;
|
|
bool is_lost_signal_distance(int16_t distance_cm, int16_t distance_cm_max);
|
|
|
|
char linebuf[10]; // legacy protocol buffer
|
|
uint8_t linebuf_len; // legacy protocol buffer length
|
|
uint32_t last_init_ms; // init time used to switch lw20 to serial mode
|
|
uint8_t high_byte; // binary protocol high byte
|
|
bool high_byte_received; // true if high byte has been received
|
|
|
|
// automatic protocol decision variables
|
|
enum class ProtocolState {
|
|
UNKNOWN, // the protocol used is not yet known
|
|
LEGACY, // legacy protocol, distances are sent as strings
|
|
BINARY // binary protocol, distances are sent using two bytes
|
|
} protocol_state;
|
|
uint8_t legacy_valid_count;
|
|
uint8_t binary_valid_count;
|
|
};
|