2019-11-01 03:11:59 -03:00
|
|
|
#pragma once
|
|
|
|
|
2019-11-10 22:47:38 -04:00
|
|
|
#include "AP_RangeFinder_Backend.h"
|
2019-11-01 03:11:59 -03:00
|
|
|
|
|
|
|
class AP_RangeFinder_Backend_Serial : public AP_RangeFinder_Backend
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// constructor
|
|
|
|
AP_RangeFinder_Backend_Serial(RangeFinder::RangeFinder_State &_state,
|
|
|
|
AP_RangeFinder_Params &_params,
|
|
|
|
uint8_t serial_instance);
|
|
|
|
|
|
|
|
// static detection function
|
|
|
|
static bool detect(uint8_t serial_instance);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2019-11-01 07:10:57 -03:00
|
|
|
// baudrate used during object construction:
|
|
|
|
virtual uint32_t initial_baudrate(uint8_t serial_instance) const;
|
|
|
|
|
2019-11-01 07:35:23 -03:00
|
|
|
// the value 0 is special to the UARTDriver - it's "use default"
|
|
|
|
virtual uint16_t rx_bufsize() const { return 0; }
|
|
|
|
virtual uint16_t tx_bufsize() const { return 0; }
|
|
|
|
|
2019-11-01 03:11:59 -03:00
|
|
|
AP_HAL::UARTDriver *uart = nullptr;
|
2019-11-01 07:59:50 -03:00
|
|
|
|
|
|
|
// update state; not all backends call this!
|
|
|
|
virtual void update(void) override;
|
|
|
|
|
|
|
|
// it is essential that anyone relying on the base-class update to
|
|
|
|
// implement this:
|
|
|
|
virtual bool get_reading(uint16_t &reading_cm) { return 0; }
|
2019-11-01 08:00:04 -03:00
|
|
|
|
|
|
|
// maximum time between readings before we change state to NoData:
|
|
|
|
virtual uint16_t read_timeout_ms() const { return 200; }
|
2019-11-01 03:11:59 -03:00
|
|
|
};
|