CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_ADSB/AP_ADSB_uAvionix_UCP.h
Views: 1798
1
/*
2
Copyright (C) 2021 Kraus Hamdani Aerospace Inc. All rights reserved.
3
4
This program is free software: you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation, either version 3 of the License, or
7
(at your option) any later version.
8
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
13
14
You should have received a copy of the GNU General Public License
15
along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17
Author: Tom Pittenger
18
*/
19
20
#pragma once
21
#include "AP_ADSB_Backend.h"
22
23
#if HAL_ADSB_UCP_ENABLED
24
25
#define AP_ADSB_UAVIONIX_UCP_CAPTURE_ALL_RX_PACKETS 1
26
27
#include "GDL90_protocol/GDL90_Message_Structs.h"
28
#include "GDL90_protocol/hostGDL90Support.h"
29
30
class AP_ADSB_uAvionix_UCP : public AP_ADSB_Backend {
31
public:
32
using AP_ADSB_Backend::AP_ADSB_Backend;
33
34
// init - performs any required initialisation for this instance
35
bool init() override;
36
37
// update - should be called periodically
38
void update() override;
39
40
// static detection function
41
static bool detect();
42
43
private:
44
45
void handle_msg(const GDL90_RX_MESSAGE &msg);
46
bool request_msg(const GDL90_MESSAGE_ID msg_id);
47
48
void send_GPS_Data();
49
void send_Transponder_Control();
50
const char* get_hardware_name(const uint8_t hwId);
51
52
bool hostTransmit(uint8_t *buffer, uint16_t length);
53
uint16_t gdl90Transmit(GDL90_TX_MESSAGE &message, const uint16_t length);
54
static bool parseByte(const uint8_t data, GDL90_RX_MESSAGE &msg, GDL90_RX_STATUS &status);
55
56
struct {
57
uint32_t last_msg_ms;
58
GDL90_RX_MESSAGE msg;
59
GDL90_RX_STATUS status;
60
61
// cache local copies so we always have the latest info of everything.
62
struct {
63
GDL90_IDENTIFICATION_V3 identification;
64
GDL90_TRANSPONDER_CONFIG_MSG_V4_V5 transponder_config;
65
GDL90_HEARTBEAT heartbeat;
66
GDL90_TRANSPONDER_STATUS_MSG transponder_status;
67
GDL90_TRANSPONDER_STATUS_MSG_V3 transponder_status_v3;
68
#if AP_ADSB_UAVIONIX_UCP_CAPTURE_ALL_RX_PACKETS
69
GDL90_OWNSHIP_REPORT ownship_report;
70
GDL90_OWNSHIP_GEO_ALTITUDE ownship_geometric_altitude;
71
GDL90_SENSOR_BARO_MESSAGE sensor_message;
72
#endif
73
} decoded;
74
} rx;
75
76
struct {
77
uint32_t last_packet_GPS_ms; // out
78
uint32_t last_packet_Transponder_Control_ms; // out
79
uint32_t last_packet_Transponder_Status_ms; // in
80
uint32_t last_packet_Transponder_Heartbeat_ms; // in
81
uint32_t last_packet_Transponder_Ownship_ms; // in
82
uint32_t last_gcs_send_message_Transponder_Status_ms; // out
83
uint32_t last_packet_Request_Transponder_Config_ms; // out
84
uint32_t last_packet_Transponder_Config_ms; // in
85
uint32_t request_Transponder_Config_tries;
86
uint32_t last_packet_Request_Transponder_Id_ms; // out
87
uint32_t last_packet_Transponder_Id_ms; // in
88
uint32_t request_Transponder_Id_tries;
89
90
} run_state;
91
92
};
93
#endif // HAL_ADSB_UCP_ENABLED
94
95
96