AP_ADSB: added Ping200X driver /w UCP protocol

This commit is contained in:
Tom Pittenger authored and Andrew Tridgell committed 2021-08-19 17:49:27 +10:00
1 parent 896dd49c96
commit b9918cd0d5
7 files changed
+1270 -5

No files matched your search

+22 -2
View File
@@ -24,6 +24,7 @@
#if HAL_ADSB_ENABLED
#include "AP_ADSB_uAvionix_MAVLink.h"
#include "AP_ADSB_uAvionix_UCP.h"
#include "AP_ADSB_Sagetech.h"
#include <AP_Vehicle/AP_Vehicle.h>
#include <GCS_MAVLink/GCS.h>
@@ -54,7 +55,7 @@ const AP_Param::GroupInfo AP_ADSB::var_info[] = {
// @Param: TYPE
// @DisplayName: ADSB Type
// @Description: Type of ADS-B hardware for ADSB-in and ADSB-out configuration and operation. If any type is selected then MAVLink based ADSB-in messages will always be enabled
// @Values: 0:Disabled,1:uAvionix-MAVLink,2:Sagetech
// @Values: 0:Disabled,1:uAvionix-MAVLink,2:Sagetech,3:uAvionix-UCP
// @User: Standard
// @RebootRequired: True
AP_GROUPINFO_FLAGS("TYPE", 0, AP_ADSB, _type[0], 0, AP_PARAM_FLAG_ENABLE),
@@ -80,7 +81,7 @@ const AP_Param::GroupInfo AP_ADSB::var_info[] = {
// @Param: ICAO_ID
// @DisplayName: ICAO_ID vehicle identification number
// @Description: ICAO_ID unique vehicle identification number of this aircraft. This is a integer limited to 24bits. If set to 0 then one will be randomly generated. If set to -1 then static information is not sent, transceiver is assumed pre-programmed.
// @Description: ICAO_ID unique vehicle identification number of this aircraft. This is an integer limited to 24bits. If set to 0 then one will be randomly generated. If set to -1 then static information is not sent, transceiver is assumed pre-programmed.
// @Range: -1 16777215
// @User: Advanced
AP_GROUPINFO("ICAO_ID", 4, AP_ADSB, out_state.cfg.ICAO_id_param, 0),
@@ -156,6 +157,12 @@ const AP_Param::GroupInfo AP_ADSB::var_info[] = {
// @User: Advanced
AP_GROUPINFO("LOG", 14, AP_ADSB, _log, 1),
// @Param: OPTIONS
// @DisplayName: ADS-B Options
// @Bitmask: 0:Ping200X Send GPS,1:Squawk 7400 on RC failsafe,2:Squawk 7400 on GCS failsafe
// @User: Advanced
AP_GROUPINFO("OPTIONS", 15, AP_ADSB, _options, 0),
AP_GROUPEND
};
@@ -250,17 +257,30 @@ void AP_ADSB::detect_instance(uint8_t instance)
return;
case Type::uAvionix_MAVLink:
#if HAL_ADSB_UAVIONIX_MAVLINK_ENABLED
if (AP_ADSB_uAvionix_MAVLink::detect()) {
_backend[instance] = new AP_ADSB_uAvionix_MAVLink(*this, instance);
return;
}
#endif
break;
case Type::uAvionix_UCP:
#if HAL_ADSB_UCP_ENABLED
if (AP_ADSB_uAvionix_UCP::detect()) {
_backend[instance] = new AP_ADSB_uAvionix_UCP(*this, instance);
return;
}
#endif
break;
case Type::Sagetech:
#if HAL_ADSB_SAGETECH_ENABLED
if (AP_ADSB_Sagetech::detect()) {
_backend[instance] = new AP_ADSB_Sagetech(*this, instance);
return;
}
#endif
break;
}
}
+34
View File
@@ -36,12 +36,16 @@
#define ADSB_MAX_INSTANCES 1 // Maximum number of ADSB sensor instances available on this platform
#define ADSB_BITBASK_RF_CAPABILITIES_UAT_IN (1 << 0)
#define ADSB_BITBASK_RF_CAPABILITIES_1090ES_IN (1 << 1)
class AP_ADSB_Backend;
class AP_ADSB {
public:
friend class AP_ADSB_Backend;
friend class AP_ADSB_uAvionix_MAVLink;
friend class AP_ADSB_uAvionix_UCP;
friend class AP_ADSB_Sagetech;
// constructor
@@ -61,6 +65,7 @@ public:
None = 0,
uAvionix_MAVLink = 1,
Sagetech = 2,
uAvionix_UCP = 3,
};
struct adsb_vehicle_t {
@@ -68,6 +73,13 @@ public:
uint32_t last_update_ms; // last time this was refreshed, allows timeouts
};
// enum for adsb optional features
enum class AdsbOption {
Ping200X_Send_GPS = (1<<0),
Squawk_7400_FS_RC = (1<<1),
Squawk_7400_FS_GCS = (1<<2),
};
// for holding parameters
static const struct AP_Param::GroupInfo var_info[];
@@ -138,6 +150,21 @@ public:
// confirm a value is a valid callsign
static bool is_valid_callsign(uint16_t octal) WARN_IF_UNUSED;
// Mode-S IDENT is active. While true, we are currently a large "HEY LOOK AT ME" symbol on the Air Traffic Controllers' radar screen.
bool ident_is_active() const {
return out_state.ident_is_active;
}
// Trigger a Mode 3/A transponder IDENT. This should only be done when requested to do so by an Air Traffic Controller.
// See wikipedia for IDENT explaination https://en.wikipedia.org/wiki/Transponder_(aeronautics)
bool ident_start() {
if (ident_is_active() || !healthy() || ((out_state.cfg.rfSelect & UAVIONIX_ADSB_OUT_RF_SELECT_TX_ENABLED) == 0)) {
return false;
}
out_state.ident_pending = true;
return true;
}
AP_ADSB::Type get_type(uint8_t instance) const;
private:
@@ -209,6 +236,11 @@ private:
bool is_flying;
bool is_in_auto_mode;
// Mode 3/A transponder IDENT. This triggers, or shows status of, an active IDENT status should only be done when requested to do so by an Air Traffic Controller.
// See wikipedia for IDENT explaination https://en.wikipedia.org/wiki/Transponder_(aeronautics)
bool ident_pending;
bool ident_is_active;
// ADSB-OUT configuration
struct {
int32_t ICAO_id;
@@ -235,6 +267,8 @@ private:
// special ICAO of interest that ignored filters when != 0
AP_Int32 _special_ICAO_target;
AP_Int32 _options;
static const uint8_t _max_samples = 30;
ObjectBuffer<adsb_vehicle_t> _samples{_max_samples};
@@ -25,9 +25,6 @@
#define ADSB_CHAN_TIMEOUT_MS 15000
#define ADSB_BITBASK_RF_CAPABILITIES_UAT_IN (1 << 0)
#define ADSB_BITBASK_RF_CAPABILITIES_1090ES_IN (1 << 1)
extern const AP_HAL::HAL& hal;
File diff suppressed because it is too large. Load diff
+91
View File
@@ -0,0 +1,91 @@
/*
Copyright (C) 2021 Kraus Hamdani Aerospace Inc. All rights reserved.
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/>.
Author: Tom Pittenger
*/
#pragma once
#include "AP_ADSB_Backend.h"
#ifndef HAL_ADSB_UCP_ENABLED
#define HAL_ADSB_UCP_ENABLED HAL_ADSB_ENABLED
#endif
#if HAL_ADSB_UCP_ENABLED
#define AP_ADSB_UAVIONIX_UCP_CAPTURE_ALL_RX_PACKETS 1
#include <AP_GPS/AP_GPS.h>
#include <AP_Baro/AP_Baro.h>
#include <AP_AHRS/AP_AHRS.h>
#include "GDL90_protocol/GDL90_Message_Structs.h"
#include "GDL90_protocol/hostGDL90Support.h"
class AP_ADSB_uAvionix_UCP : public AP_ADSB_Backend {
public:
using AP_ADSB_Backend::AP_ADSB_Backend;
// init - performs any required initialisation for this instance
bool init() override;
// update - should be called periodically
void update() override;
// static detection function
static bool detect();
private:
void handle_msg(const GDL90_RX_MESSAGE &msg);
bool request_msg(const GDL90_MESSAGE_ID msg_id);
void send_GPS_Data();
void send_Transponder_Control();
const char* get_hardware_name(const uint8_t hwId);
bool hostTransmit(uint8_t *buffer, uint16_t length);
uint16_t gdl90Transmit(GDL90_TX_MESSAGE &message, const uint16_t length);
static bool parseByte(const uint8_t data, GDL90_RX_MESSAGE &msg, GDL90_RX_STATUS &status);
struct {
uint32_t last_msg_ms;
GDL90_RX_MESSAGE msg;
GDL90_RX_STATUS status;
// cache local copies so we always have the latest info of everything.
struct {
GDL90_IDENTIFICATION_V3 identification;
GDL90_TRANSPONDER_CONFIG_MSG_V4_V5 transponder_config;
GDL90_HEARTBEAT heartbeat;
#if AP_ADSB_UAVIONIX_UCP_CAPTURE_ALL_RX_PACKETS
GDL90_OWNSHIP_REPORT ownship_report;
GDL90_OWNSHIP_GEO_ALTITUDE ownship_geometric_altitude;
GDL90_SENSOR_BARO_MESSAGE sensor_message;
GDL90_TRANSPONDER_STATUS_MSG transponder_status;
#endif
} decoded;
} rx;
struct {
uint32_t last_packet_GPS_ms;
uint32_t last_packet_Transponder_Control_ms;
} run_state;
};
#endif // HAL_ADSB_UCP_ENABLED
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,83 @@
/*
Copyright (C) 2021 Kraus Hamdani Aerospace Inc. All rights reserved.
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/>.
Author: GDL90/UCP protocol by uAvionix, 2021.
Implemented by: Tom Pittenger
*/
#ifndef _GDL90_H_
#define _GDL90_H_
#include <stdint.h>
#define GDL90_QUEUE_LENGTH (2)
#define GDL90_FLAG_BYTE (0x7E)
#define GDL90_CONTROL_ESCAPE_BYTE (0x7D)
#define GDL90_STUFF_BYTE (0x20)
#define GDL90_OVERHEAD_LENGTH (3) // Not counting framing bytes
// Transmit message sizes
#define GDL90_TX_MAX_PAYLOAD_LENGTH (552)
#define GDL90_TX_MAX_PACKET_LENGTH (GDL90_TX_MAX_PAYLOAD_LENGTH + GDL90_OVERHEAD_LENGTH)
#define GDL90_TX_MAX_FRAME_LENGTH (2 + ((15 * GDL90_TX_MAX_PACKET_LENGTH) / 10)) // IF every other byte was stuffed
// Receive message sizes
#define GDL90_RX_MAX_PAYLOAD_LENGTH (128)
#define GDL90_RX_MAX_PACKET_LENGTH (GDL90_RX_MAX_PAYLOAD_LENGTH + GDL90_OVERHEAD_LENGTH)
typedef union __attribute__((__packed__))
{
struct __attribute__((__packed__))
{
GDL90_MESSAGE_ID messageId;
uint8_t payload[GDL90_TX_MAX_PAYLOAD_LENGTH];
uint16_t crc; // Actually CRC location varies. This is a placeholder
};
uint8_t raw[GDL90_TX_MAX_PACKET_LENGTH];
} GDL90_TX_MESSAGE;
typedef union __attribute__((__packed__))
{
struct __attribute__((__packed__))
{
GDL90_MESSAGE_ID messageId;
uint8_t payload[GDL90_RX_MAX_PAYLOAD_LENGTH];
uint16_t crc; // Actually CRC location varies. This is a placeholder
};
uint8_t raw[GDL90_RX_MAX_PACKET_LENGTH];
} GDL90_RX_MESSAGE;
typedef enum
{
GDL90_RX_IDLE,
GDL90_RX_IN_PACKET,
GDL90_RX_UNSTUFF,
//GDL90_RX_END,
} GDL90_RX_STATE;
typedef struct
{
GDL90_RX_STATE state;
uint16_t length;
//uint32_t overflow;
//uint32_t complete;
uint8_t prev_data;
} GDL90_RX_STATUS;
#endif