Browse Source

AP_ADSB: create frontend/backend split

c415-sdk
Tom Pittenger 4 years ago committed by Tom Pittenger
parent
commit
f784fc7c5c
  1. 11
      libraries/AP_ADSB/AP_ADSB.cpp
  2. 7
      libraries/AP_ADSB/AP_ADSB.h
  3. 29
      libraries/AP_ADSB/AP_ADSB_Backend.cpp
  4. 36
      libraries/AP_ADSB/AP_ADSB_Backend.h
  5. 27
      libraries/AP_ADSB/AP_ADSB_uAvionix_MAVLink.cpp
  6. 31
      libraries/AP_ADSB/AP_ADSB_uAvionix_MAVLink.h

11
libraries/AP_ADSB/AP_ADSB.cpp

@ -23,6 +23,7 @@ @@ -23,6 +23,7 @@
#include "AP_ADSB.h"
#if HAL_ADSB_ENABLED
#include "AP_ADSB_uAvionix_MAVLink.h"
#include <GCS_MAVLink/GCS_MAVLink.h>
#include <stdio.h> // for sprintf
#include <limits.h>
@ -203,6 +204,16 @@ void AP_ADSB::init(void) @@ -203,6 +204,16 @@ void AP_ADSB::init(void)
}
in_state.list_size_allocated = in_state.list_size_param;
}
if (_backend == nullptr) {
_backend = new AP_ADSB_uAvionix_MAVLink(*this);
if (_backend == nullptr) {
_init_failed = true;
gcs().send_text(MAV_SEVERITY_CRITICAL, "ADSB: Unable to initialize ADSB driver");
return;
}
}
}
/*

7
libraries/AP_ADSB/AP_ADSB.h

@ -34,8 +34,13 @@ @@ -34,8 +34,13 @@
#include <AP_Common/Location.h>
#include <GCS_MAVLink/GCS_MAVLink.h>
class AP_ADSB_Backend;
class AP_ADSB {
public:
friend class AP_ADSB_Backend;
friend class AP_ADSB_uAvionix_MAVLink;
// constructor
AP_ADSB();
@ -235,6 +240,8 @@ private: @@ -235,6 +240,8 @@ private:
void update_uavionix();
// reference to backend
AP_ADSB_Backend *_backend;
};
namespace AP {

29
libraries/AP_ADSB/AP_ADSB_Backend.cpp

@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "AP_ADSB_Backend.h"
#if HAL_ADSB_ENABLED
/*
base class constructor.
*/
AP_ADSB_Backend::AP_ADSB_Backend(AP_ADSB &frontend) :
_frontend(frontend)
{
}
#endif // HAL_ADSB_ENABLED

36
libraries/AP_ADSB/AP_ADSB_Backend.h

@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "AP_ADSB.h"
#if HAL_ADSB_ENABLED
class AP_ADSB_Backend
{
public:
// constructor.
AP_ADSB_Backend(AP_ADSB &frontend);
virtual void update() = 0;
protected:
// references
AP_ADSB &_frontend;
private:
};
#endif // HAL_ADSB_ENABLED

27
libraries/AP_ADSB/AP_ADSB_uAvionix_MAVLink.cpp

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "AP_ADSB_uAvionix_MAVLink.h"
#if HAL_ADSB_ENABLED
extern const AP_HAL::HAL& hal;
void AP_ADSB_uAvionix_MAVLink::update()
{
}
#endif // HAL_ADSB_ENABLED

31
libraries/AP_ADSB/AP_ADSB_uAvionix_MAVLink.h

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
#pragma once
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "AP_ADSB_Backend.h"
#if HAL_ADSB_ENABLED
class AP_ADSB_uAvionix_MAVLink : public AP_ADSB_Backend {
public:
using AP_ADSB_Backend::AP_ADSB_Backend;
void update() override;
private:
};
#endif // HAL_ADSB_ENABLED
Loading…
Cancel
Save