mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-10-30 16:56:12 +08:00
currently registering an MSP backend can't fail, so if we fail to register (e.g. out of slots) then we can end up overwriting other's data. Add a probe method which can return nullptr on failure
31 lines
579 B
C++
31 lines
579 B
C++
#pragma once
|
|
|
|
#include "AP_Compass_config.h"
|
|
|
|
#if AP_COMPASS_MSP_ENABLED
|
|
|
|
#include "AP_Compass.h"
|
|
#include "AP_Compass_Backend.h"
|
|
#include <AP_MSP/msp.h>
|
|
|
|
class AP_Compass_MSP : public AP_Compass_Backend
|
|
{
|
|
public:
|
|
|
|
static AP_Compass_Backend *probe(uint8_t _msp_instance);
|
|
|
|
void read(void) override;
|
|
|
|
private:
|
|
AP_Compass_MSP(uint8_t _msp_instance) :
|
|
msp_instance{_msp_instance} { }
|
|
|
|
bool init();
|
|
|
|
void handle_msp(const MSP::msp_compass_data_message_t &pkt) override;
|
|
uint8_t msp_instance;
|
|
uint8_t instance;
|
|
};
|
|
|
|
#endif // AP_COMPASS_MSP_ENABLED
|