From c35ae7260badc04012b6b8c7e58b8960c2abeda0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Mi=C5=A1i=C4=87?= Date: Wed, 12 Oct 2022 12:07:10 +0200 Subject: [PATCH] transponder/sagetech_mxs: move the ADS-B related parameters to the lib ADS-B parameters can be reused for other ADS-B devices --- .../transponder/sagetech_mxs/CMakeLists.txt | 1 + .../transponder/sagetech_mxs/parameters.c | 162 --------------- src/lib/CMakeLists.txt | 1 + src/lib/adsb/CMakeLists.txt | 34 +++ src/lib/adsb/adsb.cpp | 32 +++ src/lib/adsb/parameters.c | 194 ++++++++++++++++++ 6 files changed, 262 insertions(+), 162 deletions(-) create mode 100644 src/lib/adsb/CMakeLists.txt create mode 100644 src/lib/adsb/adsb.cpp create mode 100644 src/lib/adsb/parameters.c diff --git a/src/drivers/transponder/sagetech_mxs/CMakeLists.txt b/src/drivers/transponder/sagetech_mxs/CMakeLists.txt index 56d7049218..08d2f2d60a 100644 --- a/src/drivers/transponder/sagetech_mxs/CMakeLists.txt +++ b/src/drivers/transponder/sagetech_mxs/CMakeLists.txt @@ -76,6 +76,7 @@ px4_add_module( SagetechMXS.cpp SagetechMXS.hpp DEPENDS + adsb px4_work_queue MODULE_CONFIG module.yaml diff --git a/src/drivers/transponder/sagetech_mxs/parameters.c b/src/drivers/transponder/sagetech_mxs/parameters.c index 0d31d1a445..4164f8691d 100644 --- a/src/drivers/transponder/sagetech_mxs/parameters.c +++ b/src/drivers/transponder/sagetech_mxs/parameters.c @@ -39,168 +39,6 @@ * @author Check Faber chuck.faber@sagetech.com */ -/** - * ADSB-Out squawk code configuration - * - * This parameter defines the squawk code. Value should be between 0000 and 7777. - * - * @reboot_required false - * @min 0 - * @max 7777 - * @group Transponder - * - */ -PARAM_DEFINE_INT32(ADSB_SQUAWK, 1200); - -/** - * ADSB-Out Ident Configuration - * - * Enable Identification of Position feature - * - * @boolean - * @reboot_required false - * @group Transponder - */ -PARAM_DEFINE_INT32(ADSB_IDENT, 0); - -/** - * ADSB-In Vehicle List Size - * - * Change number of targets to track - * - * @min 0 - * @max 50 - * @reboot_required true - * @group Transponder - */ -PARAM_DEFINE_INT32(ADSB_LIST_MAX, 25); - -/** - * ADSB-Out ICAO configuration - * - * Defines the ICAO ID of the vehicle - * - * @reboot_required true - * @min -1 - * @max 16777215 - * @group Transponder - * - */ -PARAM_DEFINE_INT32(ADSB_ICAO_ID, 1194684); - -/** - * ADSB-Out Vehicle Size Configuration - * - * Report the length and width of the vehicle in meters. In most cases, use '1' for the smallest vehicle size. - * - * @reboot_required true - * @min 0 - * @max 15 - * @group Transponder - * - * @value 0 SizeUnknown - * @value 1 Len15_Wid23 - * @value 2 Len25_Wid28 - * @value 3 Len25_Wid34 - * @value 4 Len35_Wid33 - * @value 5 Len35_Wid38 - * @value 6 Len45_Wid39 - * @value 7 Len45_Wid45 - * @value 8 Len55_Wid45 - * @value 9 Len55_Wid52 - * @value 10 Len65_Wid59 - * @value 11 Len65_Wid67 - * @value 12 Len75_Wid72 - * @value 13 Len75_Wid80 - * @value 14 Len85_Wid80 - * @value 15 Len85_Wid90 - */ -PARAM_DEFINE_INT32(ADSB_LEN_WIDTH, 1); - -/** - * ADSB-Out Vehicle Emitter Type - * - * Configure the emitter type of the vehicle. - * - * @reboot_required true - * @min 0 - * @max 15 - * @group Transponder - * - * @value 0 Unknown - * @value 1 Light - * @value 2 Small - * @value 3 Large - * @value 4 HighVortex - * @value 5 Heavy - * @value 6 Performance - * @value 7 Rotorcraft - * @value 8 RESERVED - * @value 9 Glider - * @value 10 LightAir - * @value 11 Parachute - * @value 12 UltraLight - * @value 13 RESERVED - * @value 14 UAV - * @value 15 Space - * @value 16 RESERVED - * @value 17 EmergencySurf - * @value 18 ServiceSurf - * @value 19 PointObstacle - */ -PARAM_DEFINE_INT32(ADSB_EMIT_TYPE, 14); - -/** - * ADSB-Out Vehicle Max Speed - * - * Informs ADSB vehicles of this vehicle's max speed capability - * - * @reboot_required true - * @min 0 - * @max 6 - * @value 0 UnknownMaxSpeed - * @value 1 75Kts - * @value 2 150Kts - * @value 3 300Kts - * @value 4 600Kts - * @value 5 1200Kts - * @value 6 Over1200Kts - * @group Transponder - */ -PARAM_DEFINE_INT32(ADSB_MAX_SPEED, 0); - -/** - * ADSB-In Special ICAO configuration - * - * This vehicle is always tracked. Use 0 to disable. - * - * @reboot_required false - * @min 0 - * @max 16777215 - * @group Transponder - * - */ -PARAM_DEFINE_INT32(ADSB_ICAO_SPECL, 0); - -/** - * ADSB-Out Emergency State - * - * Sets the vehicle emergency state - * - * @reboot_required false - * @min 0 - * @max 6 - * @value 0 NoEmergency - * @value 1 General - * @value 2 Medical - * @value 3 LowFuel - * @value 4 NoCommunications - * @value 5 Interference - * @value 6 Downed - * @group Transponder - */ -PARAM_DEFINE_INT32(ADSB_EMERGC, 0); - /** * Sagetech MXS mode configuration * diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 14b4dcf9f6..6cbf853886 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -31,6 +31,7 @@ # ############################################################################ +add_subdirectory(adsb) add_subdirectory(airspeed) add_subdirectory(avoidance) add_subdirectory(battery) diff --git a/src/lib/adsb/CMakeLists.txt b/src/lib/adsb/CMakeLists.txt new file mode 100644 index 0000000000..2012ef827d --- /dev/null +++ b/src/lib/adsb/CMakeLists.txt @@ -0,0 +1,34 @@ +############################################################################ +# +# Copyright (c) 2022 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +px4_add_library(adsb adsb.cpp) diff --git a/src/lib/adsb/adsb.cpp b/src/lib/adsb/adsb.cpp new file mode 100644 index 0000000000..36bffcc179 --- /dev/null +++ b/src/lib/adsb/adsb.cpp @@ -0,0 +1,32 @@ +/**************************************************************************** + * + * Copyright (C) 2022 PX4 Development Team. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name PX4 nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ diff --git a/src/lib/adsb/parameters.c b/src/lib/adsb/parameters.c new file mode 100644 index 0000000000..2ac2e97843 --- /dev/null +++ b/src/lib/adsb/parameters.c @@ -0,0 +1,194 @@ +/**************************************************************************** + * + * Copyright (c) 2022 PX4 Development Team. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name PX4 nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/** + * ADSB-Out squawk code configuration + * + * This parameter defines the squawk code. Value should be between 0000 and 7777. + * + * @reboot_required false + * @min 0 + * @max 7777 + * @group ADSB + * + */ +PARAM_DEFINE_INT32(ADSB_SQUAWK, 1200); + +/** + * ADSB-Out Ident Configuration + * + * Enable Identification of Position feature + * + * @boolean + * @reboot_required false + * @group ADSB + */ +PARAM_DEFINE_INT32(ADSB_IDENT, 0); + +/** + * ADSB-In Vehicle List Size + * + * Change number of targets to track + * + * @min 0 + * @max 50 + * @reboot_required true + * @group ADSB + */ +PARAM_DEFINE_INT32(ADSB_LIST_MAX, 25); + +/** + * ADSB-Out ICAO configuration + * + * Defines the ICAO ID of the vehicle + * + * @reboot_required true + * @min -1 + * @max 16777215 + * @group ADSB + * + */ +PARAM_DEFINE_INT32(ADSB_ICAO_ID, 1194684); + +/** + * ADSB-Out Vehicle Size Configuration + * + * Report the length and width of the vehicle in meters. In most cases, use '1' for the smallest vehicle size. + * + * @reboot_required true + * @min 0 + * @max 15 + * @group ADSB + * + * @value 0 SizeUnknown + * @value 1 Len15_Wid23 + * @value 2 Len25_Wid28 + * @value 3 Len25_Wid34 + * @value 4 Len35_Wid33 + * @value 5 Len35_Wid38 + * @value 6 Len45_Wid39 + * @value 7 Len45_Wid45 + * @value 8 Len55_Wid45 + * @value 9 Len55_Wid52 + * @value 10 Len65_Wid59 + * @value 11 Len65_Wid67 + * @value 12 Len75_Wid72 + * @value 13 Len75_Wid80 + * @value 14 Len85_Wid80 + * @value 15 Len85_Wid90 + */ +PARAM_DEFINE_INT32(ADSB_LEN_WIDTH, 1); + +/** + * ADSB-Out Vehicle Emitter Type + * + * Configure the emitter type of the vehicle. + * + * @reboot_required true + * @min 0 + * @max 15 + * @group ADSB + * + * @value 0 Unknown + * @value 1 Light + * @value 2 Small + * @value 3 Large + * @value 4 HighVortex + * @value 5 Heavy + * @value 6 Performance + * @value 7 Rotorcraft + * @value 8 RESERVED + * @value 9 Glider + * @value 10 LightAir + * @value 11 Parachute + * @value 12 UltraLight + * @value 13 RESERVED + * @value 14 UAV + * @value 15 Space + * @value 16 RESERVED + * @value 17 EmergencySurf + * @value 18 ServiceSurf + * @value 19 PointObstacle + */ +PARAM_DEFINE_INT32(ADSB_EMIT_TYPE, 14); + +/** + * ADSB-Out Vehicle Max Speed + * + * Informs ADSB vehicles of this vehicle's max speed capability + * + * @reboot_required true + * @min 0 + * @max 6 + * @value 0 UnknownMaxSpeed + * @value 1 75Kts + * @value 2 150Kts + * @value 3 300Kts + * @value 4 600Kts + * @value 5 1200Kts + * @value 6 Over1200Kts + * @group ADSB + */ +PARAM_DEFINE_INT32(ADSB_MAX_SPEED, 0); + +/** + * ADSB-In Special ICAO configuration + * + * This vehicle is always tracked. Use 0 to disable. + * + * @reboot_required false + * @min 0 + * @max 16777215 + * @group ADSB + * + */ +PARAM_DEFINE_INT32(ADSB_ICAO_SPECL, 0); + +/** + * ADSB-Out Emergency State + * + * Sets the vehicle emergency state + * + * @reboot_required false + * @min 0 + * @max 6 + * @value 0 NoEmergency + * @value 1 General + * @value 2 Medical + * @value 3 LowFuel + * @value 4 NoCommunications + * @value 5 Interference + * @value 6 Downed + * @group ADSB + */ +PARAM_DEFINE_INT32(ADSB_EMERGC, 0);