2017-04-02 11:56:26 -03:00
|
|
|
/*
|
|
|
|
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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
//
|
|
|
|
// UAVCAN GPS driver
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AP_Common/AP_Common.h>
|
|
|
|
#include <AP_HAL/AP_HAL.h>
|
|
|
|
#include "AP_GPS.h"
|
|
|
|
#include "GPS_Backend.h"
|
|
|
|
|
2018-07-18 06:27:15 -03:00
|
|
|
#include <AP_UAVCAN/AP_UAVCAN.h>
|
|
|
|
|
|
|
|
class FixCb;
|
|
|
|
class AuxCb;
|
|
|
|
|
2017-04-02 11:56:26 -03:00
|
|
|
class AP_GPS_UAVCAN : public AP_GPS_Backend {
|
|
|
|
public:
|
2018-07-18 06:27:15 -03:00
|
|
|
AP_GPS_UAVCAN(AP_GPS &_gps, AP_GPS::GPS_State &_state);
|
|
|
|
~AP_GPS_UAVCAN();
|
2017-04-02 11:56:26 -03:00
|
|
|
|
|
|
|
bool read() override;
|
2016-08-01 08:58:23 -03:00
|
|
|
|
|
|
|
const char *name() const override { return "UAVCAN"; }
|
|
|
|
|
2018-07-18 06:27:15 -03:00
|
|
|
static void subscribe_msgs(AP_UAVCAN* ap_uavcan);
|
|
|
|
static AP_GPS_Backend* probe(AP_GPS &_gps, AP_GPS::GPS_State &_state);
|
|
|
|
|
|
|
|
static void handle_fix_msg_trampoline(AP_UAVCAN* ap_uavcan, uint8_t node_id, const FixCb &cb);
|
|
|
|
static void handle_aux_msg_trampoline(AP_UAVCAN* ap_uavcan, uint8_t node_id, const AuxCb &cb);
|
|
|
|
|
2019-10-21 08:11:26 -03:00
|
|
|
void inject_data(const uint8_t *data, uint16_t len) override;
|
|
|
|
|
2017-04-02 11:56:26 -03:00
|
|
|
private:
|
2018-07-18 06:27:15 -03:00
|
|
|
void handle_fix_msg(const FixCb &cb);
|
|
|
|
void handle_aux_msg(const AuxCb &cb);
|
|
|
|
|
|
|
|
static bool take_registry();
|
|
|
|
static void give_registry();
|
|
|
|
static AP_GPS_UAVCAN* get_uavcan_backend(AP_UAVCAN* ap_uavcan, uint8_t node_id);
|
|
|
|
|
2017-04-02 11:56:26 -03:00
|
|
|
bool _new_data;
|
2018-07-18 06:27:15 -03:00
|
|
|
AP_GPS::GPS_State interim_state;
|
|
|
|
|
|
|
|
HAL_Semaphore sem;
|
|
|
|
|
|
|
|
uint8_t _detected_module;
|
|
|
|
|
|
|
|
// Module Detection Registry
|
|
|
|
static struct DetectedModules {
|
|
|
|
AP_UAVCAN* ap_uavcan;
|
|
|
|
uint8_t node_id;
|
|
|
|
AP_GPS_UAVCAN* driver;
|
|
|
|
} _detected_modules[GPS_MAX_RECEIVERS];
|
2017-04-02 11:56:26 -03:00
|
|
|
|
2018-10-11 20:35:03 -03:00
|
|
|
static HAL_Semaphore _sem_registry;
|
2017-04-02 11:56:26 -03:00
|
|
|
};
|