2015-01-20 16:49:01 +00:00
|
|
|
// Part of dump1090, a Mode S message decoder for RTLSDR devices.
|
2013-08-19 14:55:17 +00:00
|
|
|
//
|
2015-01-20 16:49:01 +00:00
|
|
|
// dump1090.h: main program header
|
2013-08-19 14:55:17 +00:00
|
|
|
//
|
2016-08-27 13:34:14 +00:00
|
|
|
// Copyright (c) 2014-2016 Oliver Jowett <oliver@mutability.co.uk>
|
2013-08-19 14:55:17 +00:00
|
|
|
//
|
2017-06-15 17:16:51 +00:00
|
|
|
// This file is free software: you may copy, redistribute and/or modify it
|
2015-01-20 16:49:01 +00:00
|
|
|
// under the terms of the GNU General Public License as published by the
|
2017-06-15 17:16:51 +00:00
|
|
|
// Free Software Foundation, either version 2 of the License, or (at your
|
|
|
|
|
// option) any later version.
|
2013-08-19 14:55:17 +00:00
|
|
|
//
|
2017-06-15 17:16:51 +00:00
|
|
|
// This file 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
|
2015-01-20 16:49:01 +00:00
|
|
|
// General Public License for more details.
|
2013-08-19 14:55:17 +00:00
|
|
|
//
|
2017-06-15 17:16:51 +00:00
|
|
|
// You should have received a copy of the GNU General Public License
|
2015-01-20 16:49:01 +00:00
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
2017-06-15 17:16:51 +00:00
|
|
|
// This file incorporates work covered by the following copyright and
|
2015-01-20 16:49:01 +00:00
|
|
|
// permission notice:
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com>
|
|
|
|
|
//
|
|
|
|
|
// All rights reserved.
|
2013-08-19 14:55:17 +00:00
|
|
|
//
|
2015-01-20 16:49:01 +00:00
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
|
// modification, are permitted provided that the following conditions are
|
|
|
|
|
// met:
|
2013-08-19 14:55:17 +00:00
|
|
|
//
|
2015-01-20 16:49:01 +00:00
|
|
|
// * Redistributions of source code must retain the above copyright
|
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
|
//
|
|
|
|
|
// * 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.
|
|
|
|
|
//
|
|
|
|
|
// 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
|
|
|
|
|
// HOLDER 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.
|
|
|
|
|
|
2013-05-24 22:32:12 +00:00
|
|
|
#ifndef __DUMP1090_H
|
|
|
|
|
#define __DUMP1090_H
|
|
|
|
|
|
2015-01-22 13:19:15 +00:00
|
|
|
// Default version number, if not overriden by the Makefile
|
2014-12-10 12:25:43 +00:00
|
|
|
#ifndef MODES_DUMP1090_VERSION
|
2020-08-04 12:38:52 +00:00
|
|
|
# define MODES_DUMP1090_VERSION "unknown"
|
2014-12-10 12:44:00 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef MODES_DUMP1090_VARIANT
|
2020-08-04 12:38:52 +00:00
|
|
|
# define MODES_DUMP1090_VARIANT "dump1090-unknown"
|
2014-12-10 12:25:43 +00:00
|
|
|
#endif
|
2013-05-24 22:32:12 +00:00
|
|
|
|
2013-08-19 14:55:17 +00:00
|
|
|
// ============================= Include files ==========================
|
2013-05-24 22:32:12 +00:00
|
|
|
|
2020-08-04 12:39:28 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stdbool.h>
|
2020-08-04 12:40:18 +00:00
|
|
|
#include <stdatomic.h>
|
2020-08-04 12:39:28 +00:00
|
|
|
#include <pthread.h>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
#include <signal.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
#include <time.h>
|
|
|
|
|
#include <limits.h>
|
2013-05-24 22:32:12 +00:00
|
|
|
|
2015-09-07 11:58:49 +00:00
|
|
|
#include "compat/compat.h"
|
Move all converters to starch-based implementations (#97)
* Switch all conversion routines to use starch.
main user-visible changes:
* ensure you check out submodules ('git clone --recurse-submodules")
* --version shows the CPU features and DSP implementations in use
* --wisdom allows overriding of the built-in architecture wisdom
* --dcfilter no longer supported
* "starch-benchmark" binary will benchmark all options on the
current machine and can produce a wisdom file to feed to
the --wisdom option
If you have a usecase for --dcfilter, please get in touch and
let me know - it's an edge case and for now there's no starch/DSP
support for it, but support can be written if needed.
In almost all cases the new conversion routines are slightly or
substantially faster than the old conversion routines. The only case
that is slower is SC16/SC16Q11 on a Pi 0, which is around 10% slower
due to changing from heavily approximated lookup tables to higher
quality results (but SC16 is probably already out of reach of a Pi 0)
* No need to build with SC16Q11_TABLE_BITS any more
* Add oneoff/uc8_capture_stats
(reads a UC8 capture; measures min/max/mean I and Q)
* Switch UC8 conversion to 127.4 center, 128 range.
Looking at actual UC8 captures from a RTL2832, the mean I and Q
are actually at 127.4, so use that as the zero point.
This means that the resulting I/Q maximum values could be as large as
127.6. Switch to 128 for simplicity.
* Switch to the new UC8 zero offset in benchmarks, fix some bugs
* Fix some bugs in SC16/SC16Q11 validation, tighten the max error requirements
* Ditch UC8 approximation path, add a NEON VRQSQRTE path.
* Tweak the SC16 exact path, add a new impl that uses a mix of
u32 & floats.
* SC16Q11 impl tweaks:
* add a u32->float exact path
* ditch the approximation path
* add a NEON VRSQRTE path
* add a 12-bit table path (using the full signed I/Q value, not absolute value)
* Ditch SC16 approximation path, add NEON vrsqrte path
* Add oneoff/dsp_error_measurement
This runs sample input through the DSP functions that are
allowed to be inexact and dumps the results as a TSV suitable for
feeding to gnuplot to look at the actual errors.
* Update make clean, make wisdom targets
* Update wisdom based on benchmarking
* Preserve the raw wisdom benchmark data
* Update to latest starch
* Update .gitignore for new wisdom files
* Update starch generated code
* Build starch-benchmark as part of the 'all' target
* Use wisdom from /etc/dump1090-fa/wisdom.local if present
* Package starch-benchmark and a helper script to generate local wisdom data
* Remove submodules in preparation for importing them directly
* Import cpu_features v0.6.0 from https://github.com/google/cpu_features/releases/tag/v0.6.0
* Import starch at commit a725c8491dc33a321565d451b385131e589d8490
from https://github.com/flightaware/starch
2021-01-21 11:45:00 +00:00
|
|
|
#include "dsp/generated/starch.h"
|
2015-09-07 11:58:49 +00:00
|
|
|
|
2013-08-19 14:55:17 +00:00
|
|
|
// ============================= #defines ===============================
|
2013-05-24 22:32:12 +00:00
|
|
|
|
|
|
|
|
#define MODES_DEFAULT_FREQ 1090000000
|
|
|
|
|
#define MODES_DEFAULT_WIDTH 1000
|
|
|
|
|
#define MODES_DEFAULT_HEIGHT 700
|
2015-04-09 17:51:31 +00:00
|
|
|
#define MODES_RTL_BUFFERS 15 // Number of RTL buffers
|
|
|
|
|
#define MODES_RTL_BUF_SIZE (16*16384) // 256k
|
|
|
|
|
#define MODES_MAG_BUF_SAMPLES (MODES_RTL_BUF_SIZE / 2) // Each sample is 2 bytes
|
|
|
|
|
#define MODES_MAG_BUFFERS 12 // Number of magnitude buffers (should be smaller than RTL_BUFFERS for flowcontrol to work)
|
2021-07-19 09:32:51 +00:00
|
|
|
#define MODES_LEGACY_AUTO_GAIN -10 // old gain value for "use automatic gain"
|
|
|
|
|
#define MODES_DEFAULT_GAIN 999999 // Use default SDR gain
|
2014-09-22 13:53:06 +00:00
|
|
|
#define MODES_MSG_SQUELCH_DB 4.0 // Minimum SNR, in dB
|
2013-05-24 22:32:12 +00:00
|
|
|
#define MODES_MSG_ENCODER_ERRS 3 // Maximum number of encoding errors
|
|
|
|
|
|
|
|
|
|
#define MODEAC_MSG_SAMPLES (25 * 2) // include up to the SPI bit
|
|
|
|
|
#define MODEAC_MSG_BYTES 2
|
|
|
|
|
#define MODEAC_MSG_SQUELCH_LEVEL 0x07FF // Average signal strength limit
|
|
|
|
|
|
|
|
|
|
#define MODES_PREAMBLE_US 8 // microseconds = bits
|
|
|
|
|
#define MODES_PREAMBLE_SAMPLES (MODES_PREAMBLE_US * 2)
|
|
|
|
|
#define MODES_PREAMBLE_SIZE (MODES_PREAMBLE_SAMPLES * sizeof(uint16_t))
|
|
|
|
|
#define MODES_LONG_MSG_BYTES 14
|
|
|
|
|
#define MODES_SHORT_MSG_BYTES 7
|
|
|
|
|
#define MODES_LONG_MSG_BITS (MODES_LONG_MSG_BYTES * 8)
|
|
|
|
|
#define MODES_SHORT_MSG_BITS (MODES_SHORT_MSG_BYTES * 8)
|
|
|
|
|
#define MODES_LONG_MSG_SAMPLES (MODES_LONG_MSG_BITS * 2)
|
|
|
|
|
#define MODES_SHORT_MSG_SAMPLES (MODES_SHORT_MSG_BITS * 2)
|
|
|
|
|
#define MODES_LONG_MSG_SIZE (MODES_LONG_MSG_SAMPLES * sizeof(uint16_t))
|
|
|
|
|
#define MODES_SHORT_MSG_SIZE (MODES_SHORT_MSG_SAMPLES * sizeof(uint16_t))
|
|
|
|
|
|
2014-09-26 21:42:38 +00:00
|
|
|
#define MODES_OS_PREAMBLE_SAMPLES (20)
|
|
|
|
|
#define MODES_OS_PREAMBLE_SIZE (MODES_OS_PREAMBLE_SAMPLES * sizeof(uint16_t))
|
|
|
|
|
#define MODES_OS_LONG_MSG_SAMPLES (268)
|
|
|
|
|
#define MODES_OS_SHORT_MSG_SAMPLES (135)
|
|
|
|
|
#define MODES_OS_LONG_MSG_SIZE (MODES_LONG_MSG_SAMPLES * sizeof(uint16_t))
|
|
|
|
|
#define MODES_OS_SHORT_MSG_SIZE (MODES_SHORT_MSG_SAMPLES * sizeof(uint16_t))
|
|
|
|
|
|
2014-10-03 21:55:21 +00:00
|
|
|
#define MODES_OUT_BUF_SIZE (1500)
|
|
|
|
|
#define MODES_OUT_FLUSH_SIZE (MODES_OUT_BUF_SIZE - 256)
|
2015-02-10 23:43:48 +00:00
|
|
|
#define MODES_OUT_FLUSH_INTERVAL (60000)
|
2013-05-24 22:32:12 +00:00
|
|
|
|
|
|
|
|
#define MODES_USER_LATLON_VALID (1<<0)
|
|
|
|
|
|
2016-08-26 20:38:06 +00:00
|
|
|
#define INVALID_ALTITUDE (-9999)
|
|
|
|
|
|
2016-08-27 13:34:14 +00:00
|
|
|
/* Where did a bit of data arrive from? In order of increasing priority */
|
|
|
|
|
typedef enum {
|
|
|
|
|
SOURCE_INVALID, /* data is not valid */
|
2016-10-11 16:55:02 +00:00
|
|
|
SOURCE_MODE_AC, /* A/C message */
|
2016-08-27 13:34:14 +00:00
|
|
|
SOURCE_MLAT, /* derived from mlat */
|
|
|
|
|
SOURCE_MODE_S, /* data from a Mode S message, no full CRC */
|
|
|
|
|
SOURCE_MODE_S_CHECKED, /* data from a Mode S message with full CRC */
|
|
|
|
|
SOURCE_TISB, /* data from a TIS-B extended squitter message */
|
2019-12-11 18:43:19 +00:00
|
|
|
SOURCE_ADSR, /* data from a ADS-R extended squitter message */
|
2016-08-27 13:34:14 +00:00
|
|
|
SOURCE_ADSB, /* data from a ADS-B extended squitter message */
|
|
|
|
|
} datasource_t;
|
|
|
|
|
|
2016-09-14 15:54:00 +00:00
|
|
|
/* What sort of address is this and who sent it?
|
|
|
|
|
* (Earlier values are higher priority)
|
|
|
|
|
*/
|
2016-09-14 15:37:07 +00:00
|
|
|
typedef enum {
|
2016-09-15 14:30:34 +00:00
|
|
|
ADDR_ADSB_ICAO, /* Mode S or ADS-B, ICAO address, transponder sourced */
|
|
|
|
|
ADDR_ADSB_ICAO_NT, /* ADS-B, ICAO address, non-transponder */
|
|
|
|
|
ADDR_ADSR_ICAO, /* ADS-R, ICAO address */
|
|
|
|
|
ADDR_TISB_ICAO, /* TIS-B, ICAO address */
|
2016-09-14 15:54:00 +00:00
|
|
|
|
2016-09-15 14:30:34 +00:00
|
|
|
ADDR_ADSB_OTHER, /* ADS-B, other address format */
|
|
|
|
|
ADDR_ADSR_OTHER, /* ADS-R, other address format */
|
|
|
|
|
ADDR_TISB_TRACKFILE, /* TIS-B, Mode A code + track file number */
|
|
|
|
|
ADDR_TISB_OTHER, /* TIS-B, other address format */
|
2016-09-14 15:54:00 +00:00
|
|
|
|
2016-10-11 16:55:02 +00:00
|
|
|
ADDR_MODE_A, /* Mode A */
|
|
|
|
|
|
2016-09-15 14:30:34 +00:00
|
|
|
ADDR_UNKNOWN /* unknown address format */
|
2016-09-14 15:37:07 +00:00
|
|
|
} addrtype_t;
|
|
|
|
|
|
2016-08-27 13:34:14 +00:00
|
|
|
typedef enum {
|
|
|
|
|
UNIT_FEET,
|
|
|
|
|
UNIT_METERS
|
|
|
|
|
} altitude_unit_t;
|
|
|
|
|
|
2020-09-21 22:00:44 +00:00
|
|
|
typedef enum {
|
|
|
|
|
UNIT_NAUTICAL_MILES,
|
|
|
|
|
UNIT_STATUTE_MILES,
|
|
|
|
|
UNIT_KILOMETERS,
|
|
|
|
|
} interactive_distance_unit_t;
|
|
|
|
|
|
2016-08-27 13:34:14 +00:00
|
|
|
typedef enum {
|
|
|
|
|
ALTITUDE_BARO,
|
2017-06-15 17:07:40 +00:00
|
|
|
ALTITUDE_GEOM
|
2016-08-27 13:34:14 +00:00
|
|
|
} altitude_source_t;
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
|
AG_INVALID,
|
|
|
|
|
AG_GROUND,
|
|
|
|
|
AG_AIRBORNE,
|
|
|
|
|
AG_UNCERTAIN
|
|
|
|
|
} airground_t;
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
2017-12-07 19:36:07 +00:00
|
|
|
SIL_INVALID, SIL_UNKNOWN, SIL_PER_SAMPLE, SIL_PER_HOUR
|
2016-08-29 10:11:04 +00:00
|
|
|
} sil_type_t;
|
2016-08-27 13:34:14 +00:00
|
|
|
|
|
|
|
|
typedef enum {
|
2016-10-01 23:16:29 +00:00
|
|
|
CPR_SURFACE, CPR_AIRBORNE, CPR_COARSE
|
|
|
|
|
} cpr_type_t;
|
2016-08-27 13:34:14 +00:00
|
|
|
|
2016-08-29 10:11:04 +00:00
|
|
|
typedef enum {
|
2017-12-07 16:34:08 +00:00
|
|
|
HEADING_INVALID, // Not set
|
2017-06-15 20:07:53 +00:00
|
|
|
HEADING_GROUND_TRACK, // Direction of track over ground, degrees clockwise from true north
|
|
|
|
|
HEADING_TRUE, // Heading, degrees clockwise from true north
|
|
|
|
|
HEADING_MAGNETIC, // Heading, degrees clockwise from magnetic north
|
|
|
|
|
HEADING_MAGNETIC_OR_TRUE, // HEADING_MAGNETIC or HEADING_TRUE depending on the HRD bit in opstatus
|
2017-12-07 16:34:08 +00:00
|
|
|
HEADING_TRACK_OR_HEADING // GROUND_TRACK / MAGNETIC / TRUE depending on the TAH bit in opstatus
|
2017-06-15 20:07:53 +00:00
|
|
|
} heading_type_t;
|
2016-08-29 10:11:04 +00:00
|
|
|
|
2016-10-01 23:16:29 +00:00
|
|
|
typedef enum {
|
2017-06-15 17:07:40 +00:00
|
|
|
COMMB_UNKNOWN,
|
2019-05-02 09:29:04 +00:00
|
|
|
COMMB_AMBIGUOUS,
|
2021-07-29 11:04:51 +00:00
|
|
|
COMMB_NOT_DECODED,
|
2017-06-15 17:07:40 +00:00
|
|
|
COMMB_EMPTY_RESPONSE,
|
|
|
|
|
COMMB_DATALINK_CAPS,
|
|
|
|
|
COMMB_GICB_CAPS,
|
|
|
|
|
COMMB_AIRCRAFT_IDENT,
|
|
|
|
|
COMMB_ACAS_RA,
|
|
|
|
|
COMMB_VERTICAL_INTENT,
|
|
|
|
|
COMMB_TRACK_TURN,
|
2021-07-29 11:04:49 +00:00
|
|
|
COMMB_HEADING_SPEED,
|
2021-07-29 11:04:52 +00:00
|
|
|
COMMB_MRAR,
|
|
|
|
|
COMMB_AIRBORNE_POSITION
|
2017-06-15 17:07:40 +00:00
|
|
|
} commb_format_t;
|
|
|
|
|
|
2017-06-16 09:39:01 +00:00
|
|
|
typedef enum {
|
2017-12-07 16:34:08 +00:00
|
|
|
NAV_MODE_AUTOPILOT = 1,
|
|
|
|
|
NAV_MODE_VNAV = 2,
|
|
|
|
|
NAV_MODE_ALT_HOLD = 4,
|
|
|
|
|
NAV_MODE_APPROACH = 8,
|
|
|
|
|
NAV_MODE_LNAV = 16,
|
|
|
|
|
NAV_MODE_TCAS = 32
|
|
|
|
|
} nav_modes_t;
|
2017-06-16 09:39:01 +00:00
|
|
|
|
2018-01-09 14:43:58 +00:00
|
|
|
// Matches encoding of the ES type 28/1 emergency/priority status subfield
|
|
|
|
|
typedef enum {
|
|
|
|
|
EMERGENCY_NONE = 0,
|
|
|
|
|
EMERGENCY_GENERAL = 1,
|
|
|
|
|
EMERGENCY_LIFEGUARD = 2,
|
|
|
|
|
EMERGENCY_MINFUEL = 3,
|
|
|
|
|
EMERGENCY_NORDO = 4,
|
|
|
|
|
EMERGENCY_UNLAWFUL = 5,
|
|
|
|
|
EMERGENCY_DOWNED = 6,
|
|
|
|
|
EMERGENCY_RESERVED = 7
|
|
|
|
|
} emergency_t;
|
2016-10-01 23:16:29 +00:00
|
|
|
|
2019-03-19 18:44:09 +00:00
|
|
|
typedef enum {
|
|
|
|
|
NAV_ALT_INVALID, NAV_ALT_UNKNOWN, NAV_ALT_AIRCRAFT, NAV_ALT_MCP, NAV_ALT_FMS
|
|
|
|
|
} nav_altitude_source_t;
|
|
|
|
|
|
2021-07-29 11:04:49 +00:00
|
|
|
// BDS4,4 MRAR - FOM/Source values
|
|
|
|
|
typedef enum {
|
|
|
|
|
MRAR_SOURCE_INVALID = 0,
|
|
|
|
|
MRAR_SOURCE_INS = 1,
|
|
|
|
|
MRAR_SOURCE_GNSS = 2,
|
|
|
|
|
MRAR_SOURCE_DMEDME = 3,
|
2021-07-29 11:04:50 +00:00
|
|
|
MRAR_SOURCE_VORDME = 4,
|
|
|
|
|
MRAR_SOURCE_RESERVED = 5
|
2021-07-29 11:04:49 +00:00
|
|
|
} mrar_source_t;
|
|
|
|
|
|
|
|
|
|
// BDS4,4 and BDS4,5 hazard reports
|
|
|
|
|
typedef enum {
|
|
|
|
|
HAZARD_NIL = 0,
|
|
|
|
|
HAZARD_LIGHT = 1,
|
|
|
|
|
HAZARD_MODERATE = 2,
|
|
|
|
|
HAZARD_SEVERE = 3
|
|
|
|
|
} hazard_t;
|
|
|
|
|
|
2015-01-22 12:30:12 +00:00
|
|
|
#define MODES_NON_ICAO_ADDRESS (1<<24) // Set on addresses to indicate they are not ICAO addresses
|
|
|
|
|
|
2013-05-24 22:32:12 +00:00
|
|
|
#define MODES_INTERACTIVE_REFRESH_TIME 250 // Milliseconds
|
2015-02-10 21:49:37 +00:00
|
|
|
#define MODES_INTERACTIVE_DISPLAY_TTL 60000 // Delete from display after 60 seconds
|
2013-05-24 22:32:12 +00:00
|
|
|
|
2015-02-10 22:24:22 +00:00
|
|
|
#define MODES_NET_HEARTBEAT_INTERVAL 60000 // milliseconds
|
2014-03-11 01:09:49 +00:00
|
|
|
|
2013-05-24 22:32:12 +00:00
|
|
|
#define MODES_CLIENT_BUF_SIZE 1024
|
|
|
|
|
#define MODES_NET_SNDBUF_SIZE (1024*64)
|
2014-07-10 17:11:13 +00:00
|
|
|
#define MODES_NET_SNDBUF_MAX (7)
|
2013-05-24 22:32:12 +00:00
|
|
|
|
2015-01-20 17:16:35 +00:00
|
|
|
#define HISTORY_SIZE 120
|
2015-02-10 22:24:22 +00:00
|
|
|
#define HISTORY_INTERVAL 30000
|
2015-01-20 17:16:35 +00:00
|
|
|
|
2013-05-24 22:32:12 +00:00
|
|
|
#define MODES_NOTUSED(V) ((void) V)
|
|
|
|
|
|
2015-06-15 21:14:37 +00:00
|
|
|
#define MAX_AMPLITUDE 65535.0
|
|
|
|
|
#define MAX_POWER (MAX_AMPLITUDE * MAX_AMPLITUDE)
|
2015-01-22 01:01:39 +00:00
|
|
|
|
2021-02-09 13:25:51 +00:00
|
|
|
#define FAUP_DEFAULT_RATE_MULTIPLIER 1.0 // FA Upload rate multiplier
|
|
|
|
|
|
|
|
|
|
|
2015-01-20 18:41:44 +00:00
|
|
|
// Include subheaders after all the #defines are in place
|
|
|
|
|
|
2015-02-08 14:27:03 +00:00
|
|
|
#include "util.h"
|
2015-01-20 17:16:35 +00:00
|
|
|
#include "anet.h"
|
2015-06-26 16:50:51 +00:00
|
|
|
#include "net_io.h"
|
2015-01-20 17:16:35 +00:00
|
|
|
#include "crc.h"
|
|
|
|
|
#include "demod_2400.h"
|
|
|
|
|
#include "stats.h"
|
2015-01-20 18:41:44 +00:00
|
|
|
#include "cpr.h"
|
2015-01-20 23:53:26 +00:00
|
|
|
#include "icao_filter.h"
|
2015-06-15 21:14:37 +00:00
|
|
|
#include "convert.h"
|
2017-01-27 17:30:40 +00:00
|
|
|
#include "sdr.h"
|
2020-08-05 08:18:59 +00:00
|
|
|
#include "fifo.h"
|
2021-06-29 12:11:13 +00:00
|
|
|
#include "adaptive.h"
|
2015-01-20 17:16:35 +00:00
|
|
|
|
2013-08-19 14:55:17 +00:00
|
|
|
//======================== structure declarations =========================
|
2013-05-24 22:32:12 +00:00
|
|
|
|
2017-01-27 17:30:40 +00:00
|
|
|
typedef enum {
|
2020-08-03 07:16:32 +00:00
|
|
|
SDR_NONE, SDR_IFILE, SDR_RTLSDR, SDR_BLADERF, SDR_HACKRF, SDR_LIMESDR
|
2017-01-27 17:30:40 +00:00
|
|
|
} sdr_type_t;
|
|
|
|
|
|
2013-05-24 22:32:12 +00:00
|
|
|
// Program global state
|
2020-06-06 13:52:04 +00:00
|
|
|
struct _Modes { // Internal state
|
2013-05-24 22:32:12 +00:00
|
|
|
pthread_t reader_thread;
|
BUGFIX : Missed data causes timestamp slip
The Mutex on the RTL data reader thread does not "force" the data
processing thread to execute. Therefore, if the processor is busy, it is
possible for a second RTL callback to occur before the data from the
first has been processed. This will cause the loss of the first data,
but worse, it will cause a slip in the timestamp. This upsets Beamfinder
and MLAT operation in PlanePlotter.
To solve this, keep a Fifo buffer which is filled by the callback
thread, and emptied by the data processing thread. The fifo is the same
size as the number of buffers requested in the call to
rtlsdr_read_async().
Note - we only put the value of the pointer supplied in the callback
into the fifo. We do not attempt to cache the data in the buffer pointed
to by the pointer. This would require us to memcopy() 2Mbytes per
second, which we don't want to do if we don't have to because it will
only make the processor loading worse. Instead, we assume that the data
in the buffer will remain valid after the callback returns, at least
until it is overwritten by new data.
It is still possible for us to lose data if we can't process it quickly
enough. However, we can now detect this loss of data when the fifo is
almost full, and correct the timestamp for the lost block/blocks.
2014-02-22 23:11:13 +00:00
|
|
|
|
2020-08-05 04:00:50 +00:00
|
|
|
pthread_mutex_t reader_cpu_mutex; // mutex protecting reader_cpu_accumulator
|
|
|
|
|
struct timespec reader_cpu_accumulator; // accumulated CPU time used by the reader thread
|
|
|
|
|
struct timespec reader_cpu_start; // start time for the last reader thread CPU measurement
|
2015-04-09 17:51:31 +00:00
|
|
|
|
|
|
|
|
unsigned trailing_samples; // extra trailing samples in magnitude buffers
|
2015-06-15 21:14:37 +00:00
|
|
|
double sample_rate; // actual sample rate in use (in hz)
|
2015-04-09 17:51:31 +00:00
|
|
|
|
2014-09-22 13:53:06 +00:00
|
|
|
uint16_t *log10lut; // Magnitude -> log10 lookup table
|
2020-08-04 12:40:18 +00:00
|
|
|
atomic_int exit; // Exit from the main loop when true (2 = unclean exit)
|
2013-05-24 22:32:12 +00:00
|
|
|
|
2015-06-15 21:14:37 +00:00
|
|
|
// Sample conversion
|
|
|
|
|
int dc_filter; // should we apply a DC filter?
|
|
|
|
|
|
2021-06-29 12:11:13 +00:00
|
|
|
// RTLSDR and some other SDRs
|
2015-01-02 22:29:29 +00:00
|
|
|
char * dev_name;
|
2021-06-29 12:11:13 +00:00
|
|
|
float gain; // value in dB, or MODES_AUTO_GAIN, or MODES_MAX_GAIN
|
2013-05-24 22:32:12 +00:00
|
|
|
int freq;
|
|
|
|
|
|
|
|
|
|
// Networking
|
|
|
|
|
char aneterr[ANET_ERR_LEN];
|
2015-06-26 16:50:51 +00:00
|
|
|
struct net_service *services; // Active services
|
2014-04-25 13:48:14 +00:00
|
|
|
struct client *clients; // Our clients
|
2014-10-03 21:55:21 +00:00
|
|
|
|
2019-11-27 13:01:46 +00:00
|
|
|
struct net_service *beast_verbatim_service; // Beast-format output service, verbatim mode
|
|
|
|
|
struct net_service *beast_cooked_service; // Beast-format output service, "cooked" mode
|
|
|
|
|
|
|
|
|
|
struct net_writer raw_out; // AVR-format output
|
|
|
|
|
struct net_writer beast_verbatim_out; // Beast-format output, verbatim mode
|
|
|
|
|
struct net_writer beast_cooked_out; // Beast-format output, "cooked" mode
|
|
|
|
|
struct net_writer sbs_out; // SBS-format output
|
2020-03-23 22:53:24 +00:00
|
|
|
struct net_writer stratux_out; // Stratux-format output
|
2019-11-27 13:01:46 +00:00
|
|
|
struct net_writer fatsv_out; // FATSV-format output
|
2014-10-03 21:55:21 +00:00
|
|
|
|
Implement a remote interactive screen
No changes to dump1090, (except the version number)
Include a sample Linux batch start file called dump1090.sh for use when
running dump1090 headless. This file needs to be copied to the
/etc/init.d/ subdirectory on your raspberry pi, and marked as
executable. Then when you re-start your RPi, dump1090 will start-up
auto-magically and run as a sort of server to allow both local and
remote connection to it's various internet ports.
Modified the Makefile to build a new headless helper application called
view1090
Added view1090. This is an executable that allows you to connect to
dump1090 when it is running and 'see' the interactive screen display.
The default is to try and connect to dump1090 on IP address 127.0.0.1
port 30005. This should work if you are running on the same RPi as
dump1090 and using the default dump1090 port settings. However, if
you're running on a different machine you will have to specify the IP
address of the RPi running dump1090 using the --net-bo-ipaddr switch.
Something like "view1090 --net-bo-ipaddr 192.168.2.65" . You may also
have to sudo it, depending on your privilige settings.
I've also compiled view1090 as a Wiin32 exe, so you should be able to
run it under any 32 bit version of Microsoft Windows - i.e. Win95, Win
2K, Win XP, Win 7 etc. It may work on Win 8 and 64 bit Windows, but I
haven't tried it. The Win32 version is compiled from the same source, so
takes all the same command line switches.
2013-09-24 17:37:54 +00:00
|
|
|
#ifdef _WIN32
|
2014-04-25 13:48:14 +00:00
|
|
|
WSADATA wsaData; // Windows socket initialisation
|
Implement a remote interactive screen
No changes to dump1090, (except the version number)
Include a sample Linux batch start file called dump1090.sh for use when
running dump1090 headless. This file needs to be copied to the
/etc/init.d/ subdirectory on your raspberry pi, and marked as
executable. Then when you re-start your RPi, dump1090 will start-up
auto-magically and run as a sort of server to allow both local and
remote connection to it's various internet ports.
Modified the Makefile to build a new headless helper application called
view1090
Added view1090. This is an executable that allows you to connect to
dump1090 when it is running and 'see' the interactive screen display.
The default is to try and connect to dump1090 on IP address 127.0.0.1
port 30005. This should work if you are running on the same RPi as
dump1090 and using the default dump1090 port settings. However, if
you're running on a different machine you will have to specify the IP
address of the RPi running dump1090 using the --net-bo-ipaddr switch.
Something like "view1090 --net-bo-ipaddr 192.168.2.65" . You may also
have to sudo it, depending on your privilige settings.
I've also compiled view1090 as a Wiin32 exe, so you should be able to
run it under any 32 bit version of Microsoft Windows - i.e. Win95, Win
2K, Win XP, Win 7 etc. It may work on Win 8 and 64 bit Windows, but I
haven't tried it. The Win32 version is compiled from the same source, so
takes all the same command line switches.
2013-09-24 17:37:54 +00:00
|
|
|
#endif
|
2013-05-24 22:32:12 +00:00
|
|
|
|
|
|
|
|
// Configuration
|
2017-01-27 17:30:40 +00:00
|
|
|
sdr_type_t sdr_type; // where are we getting data from?
|
2013-05-24 22:32:12 +00:00
|
|
|
int nfix_crc; // Number of crc bit error(s) to correct
|
|
|
|
|
int check_crc; // Only display messages with good CRC
|
2021-03-08 06:23:35 +00:00
|
|
|
int fix_df; // Try to correct damage to the DF field, as well as the main message body
|
Reduce CPU further in --no-fix-df mode. Add --enable-df24 option.
This reinstates the fastpath in the 2.4MHz demodulator that
aborts message demodulation early if the DF bits don't match a message
type that we know how to decode, or stops early if the DF bits can
only correspond to a short 56-bit message.
Do this in a more general form where we test against a set of valid
DF values, rather than a switch/case. Then populate the sets based on
the current error-correction settings (e.g. if we are allowed to repair
DF damage with 1 bit error correction, then a DF17 message could appear
with any of DF=17, DF=16, DF=19, DF=21, DF=25, or DF=1 and still be
correctable to a valid DF17 message)
In the default case this produces a small CPU improvement as short
messages might be able to stop earlier and a few DF values can be ignored
early. With --no-fix-df it produces a larger improvement as relatively few
DF values are valid in that mode.
To further reduce CPU, the default behaviour has changed to _not_
decode DF24 messages (Comm-D ELM messages). These are rarely seen in
the wild and dump1090 can't do anything useful with them. Disabling
them allows us to further reduce the set of valid DF values as they
effectively use all DF values from 24..31, 25% of all possible values.
To re-enable DF24 decoding, use the new `--enable-df24` option.
Finally, avoid doing some CRC calculations twice. This was only happening
once per valid decoded message, not per demodulation attempt, so it's not
such a large win.
2021-03-19 08:52:42 +00:00
|
|
|
int enable_df24; // Enable decoding of DF24..DF31 (Comm-D ELM)
|
2013-05-24 22:32:12 +00:00
|
|
|
int raw; // Raw output format
|
|
|
|
|
int mode_ac; // Enable decoding of SSR Modes A & C
|
2016-12-29 17:56:32 +00:00
|
|
|
int mode_ac_auto; // allow toggling of A/C by Beast commands
|
2013-05-24 22:32:12 +00:00
|
|
|
int net; // Enable networking
|
|
|
|
|
int net_only; // Enable just networking
|
2015-02-10 22:24:22 +00:00
|
|
|
uint64_t net_heartbeat_interval; // TCP heartbeat interval (milliseconds)
|
2014-10-03 21:55:21 +00:00
|
|
|
int net_output_flush_size; // Minimum Size of output data
|
2015-02-10 22:24:22 +00:00
|
|
|
uint64_t net_output_flush_interval; // Maximum interval (in milliseconds) between outputwrites
|
2016-01-24 18:45:35 +00:00
|
|
|
char *net_output_raw_ports; // List of raw output TCP ports
|
|
|
|
|
char *net_input_raw_ports; // List of raw input TCP ports
|
|
|
|
|
char *net_output_sbs_ports; // List of SBS output TCP ports
|
2020-03-23 22:53:24 +00:00
|
|
|
char *net_output_stratux_ports; // List of Stratux output TCP ports
|
2016-01-24 18:45:35 +00:00
|
|
|
char *net_input_beast_ports; // List of Beast input TCP ports
|
|
|
|
|
char *net_output_beast_ports; // List of Beast output TCP ports
|
|
|
|
|
char *net_bind_address; // Bind address
|
2014-05-27 12:16:57 +00:00
|
|
|
int net_sndbuf_size; // TCP output buffer size (64Kb * 2^n)
|
2019-11-27 13:01:46 +00:00
|
|
|
int net_verbatim; // if true, Beast output connections default to verbatim mode
|
2015-07-03 20:56:23 +00:00
|
|
|
int forward_mlat; // allow forwarding of mlat messages to output ports
|
2013-05-24 22:32:12 +00:00
|
|
|
int quiet; // Suppress stdout
|
2015-02-22 23:01:54 +00:00
|
|
|
uint32_t show_only; // Only show messages from this ICAO
|
2013-05-24 22:32:12 +00:00
|
|
|
int interactive; // Interactive mode
|
2015-02-10 21:49:37 +00:00
|
|
|
uint64_t interactive_display_ttl;// Interactive mode: TTL display
|
2021-01-23 06:48:49 +00:00
|
|
|
int interactive_display_size; // Size of TTL display
|
2020-09-21 22:00:44 +00:00
|
|
|
int interactive_show_distance; // Show aircraft distance and bearing instead of lat/lon
|
|
|
|
|
interactive_distance_unit_t interactive_distance_units; // Units for interactive distance display
|
|
|
|
|
char *interactive_callsign_filter; // Filter for interactive display callsigns
|
2015-02-10 22:24:22 +00:00
|
|
|
uint64_t stats; // Interval (millis) between stats dumps,
|
2015-06-19 16:29:14 +00:00
|
|
|
int stats_range_histo; // Collect/show a range histogram?
|
2013-05-24 22:32:12 +00:00
|
|
|
int onlyaddr; // Print only ICAO addresses
|
|
|
|
|
int metric; // Use metric units
|
2016-08-27 13:34:14 +00:00
|
|
|
int use_gnss; // Use GNSS altitudes with H suffix ("HAE", though it isn't always) when available
|
2013-05-24 22:32:12 +00:00
|
|
|
int mlat; // Use Beast ascii format for raw data output, i.e. @...; iso *...;
|
2015-01-15 20:54:22 +00:00
|
|
|
char *json_dir; // Path to json base directory, or NULL not to write json.
|
2015-02-10 22:24:22 +00:00
|
|
|
uint64_t json_interval; // Interval between rewriting the json aircraft file, in milliseconds; also the advertised map refresh interval
|
2021-02-01 07:18:42 +00:00
|
|
|
uint64_t json_stats_interval; // Interval between rewriting the json stats file, in milliseconds
|
2014-12-27 20:52:56 +00:00
|
|
|
int json_location_accuracy; // Accuracy of location metadata: 0=none, 1=approx, 2=exact
|
2021-02-09 13:25:51 +00:00
|
|
|
double faup_rate_multiplier; // Multiplier to adjust rate of faup1090 messages emitted
|
2021-07-29 11:04:53 +00:00
|
|
|
bool faup_upload_unknown_commb; // faup1090: should we upload Comm-B messages that weren't in a recognized format?
|
2013-05-24 22:32:12 +00:00
|
|
|
|
2015-01-15 20:55:55 +00:00
|
|
|
int json_aircraft_history_next;
|
|
|
|
|
struct {
|
|
|
|
|
char *content;
|
|
|
|
|
int clen;
|
|
|
|
|
} json_aircraft_history[HISTORY_SIZE];
|
|
|
|
|
|
2013-05-24 22:32:12 +00:00
|
|
|
// User details
|
|
|
|
|
double fUserLat; // Users receiver/antenna lat/lon needed for initial surface location
|
|
|
|
|
double fUserLon; // Users receiver/antenna lat/lon needed for initial surface location
|
|
|
|
|
int bUserFlags; // Flags relating to the user details
|
2015-01-13 20:03:34 +00:00
|
|
|
double maxRange; // Absolute maximum decoding range, in *metres*
|
2013-05-24 22:32:12 +00:00
|
|
|
|
2015-02-08 14:27:03 +00:00
|
|
|
// State tracking
|
2013-05-24 22:32:12 +00:00
|
|
|
struct aircraft *aircrafts;
|
2015-02-08 14:27:03 +00:00
|
|
|
|
2013-05-24 22:32:12 +00:00
|
|
|
// Statistics
|
2021-02-01 07:18:42 +00:00
|
|
|
struct stats stats_current; // Currently accumulating stats, this is where all stats are initially collected
|
|
|
|
|
struct stats stats_alltime; // Accumulated stats since the start of the process
|
|
|
|
|
struct stats stats_periodic; // Accumulated stats since the last periodic stats display (--stats-every)
|
|
|
|
|
struct stats stats_latest; // Accumulated stats since the end of the last 1-minute period
|
|
|
|
|
struct stats stats_1min[15]; // Accumulated stats for a full 1-minute window; this is a ring buffer maintaining a history of 15 minutes
|
|
|
|
|
int stats_newest_1min; // Index into stats_1min of the most recent 1-minute window
|
|
|
|
|
struct stats stats_5min; // Accumulated stats from the last 5 complete 1-minute windows
|
|
|
|
|
struct stats stats_15min; // Accumulated stats from the last 15 complete 1-minute windows
|
2021-06-29 12:11:13 +00:00
|
|
|
|
|
|
|
|
// Adaptive gain config
|
|
|
|
|
float adaptive_min_gain_db;
|
|
|
|
|
float adaptive_max_gain_db;
|
|
|
|
|
|
2021-07-15 08:44:26 +00:00
|
|
|
float adaptive_duty_cycle;
|
|
|
|
|
|
2021-06-29 12:11:13 +00:00
|
|
|
bool adaptive_burst_control;
|
|
|
|
|
float adaptive_burst_alpha;
|
|
|
|
|
unsigned adaptive_burst_change_delay;
|
|
|
|
|
float adaptive_burst_loud_rate;
|
|
|
|
|
unsigned adaptive_burst_loud_runlength;
|
|
|
|
|
float adaptive_burst_quiet_rate;
|
|
|
|
|
unsigned adaptive_burst_quiet_runlength;
|
|
|
|
|
|
|
|
|
|
bool adaptive_range_control;
|
|
|
|
|
float adaptive_range_alpha;
|
|
|
|
|
unsigned adaptive_range_percentile;
|
|
|
|
|
float adaptive_range_target;
|
2021-07-07 12:57:34 +00:00
|
|
|
unsigned adaptive_range_change_delay;
|
2021-12-07 09:29:50 +00:00
|
|
|
unsigned adaptive_range_scan_delay;
|
2021-06-29 12:11:13 +00:00
|
|
|
unsigned adaptive_range_rescan_delay;
|
2020-06-06 13:52:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern struct _Modes Modes;
|
2013-05-24 22:32:12 +00:00
|
|
|
|
|
|
|
|
// The struct we use to store information about a decoded message.
|
|
|
|
|
struct modesMessage {
|
|
|
|
|
// Generic fields
|
|
|
|
|
unsigned char msg[MODES_LONG_MSG_BYTES]; // Binary message.
|
2015-01-22 19:56:38 +00:00
|
|
|
unsigned char verbatim[MODES_LONG_MSG_BYTES]; // Binary message, as originally received before correction
|
2017-06-15 17:16:51 +00:00
|
|
|
int msgbits; // Number of bits in message
|
2013-05-24 22:32:12 +00:00
|
|
|
int msgtype; // Downlink format #
|
|
|
|
|
uint32_t crc; // Message CRC
|
2017-06-15 17:16:51 +00:00
|
|
|
int correctedbits; // No. of bits corrected
|
2015-01-22 19:49:19 +00:00
|
|
|
uint32_t addr; // Address Announced
|
2016-09-14 15:37:07 +00:00
|
|
|
addrtype_t addrtype; // address format / source
|
2015-02-08 17:46:01 +00:00
|
|
|
uint64_t timestampMsg; // Timestamp of the message (12MHz clock)
|
2017-12-02 17:38:33 +00:00
|
|
|
uint64_t sysTimestampMsg; // Timestamp of the message (system time)
|
2013-05-24 22:32:12 +00:00
|
|
|
int remote; // If set this message is from a remote station
|
2015-01-22 01:01:39 +00:00
|
|
|
double signalLevel; // RSSI, in the range [0..1], as a fraction of full-scale power
|
2015-01-22 19:49:19 +00:00
|
|
|
int score; // Scoring from scoreModesMessage, if used
|
2019-11-27 12:30:41 +00:00
|
|
|
int reliable; // is this a "reliable" message (uncorrected DF11/DF17/DF18)?
|
2013-05-24 22:32:12 +00:00
|
|
|
|
2016-08-27 13:34:14 +00:00
|
|
|
datasource_t source; // Characterizes the overall message source
|
|
|
|
|
|
|
|
|
|
// Raw data, just extracted directly from the message
|
|
|
|
|
// The names reflect the field names in Annex 4
|
|
|
|
|
unsigned IID; // extracted from CRC of DF11s
|
|
|
|
|
unsigned AA;
|
|
|
|
|
unsigned AC;
|
|
|
|
|
unsigned CA;
|
|
|
|
|
unsigned CC;
|
|
|
|
|
unsigned CF;
|
|
|
|
|
unsigned DR;
|
|
|
|
|
unsigned FS;
|
|
|
|
|
unsigned ID;
|
|
|
|
|
unsigned KE;
|
|
|
|
|
unsigned ND;
|
|
|
|
|
unsigned RI;
|
|
|
|
|
unsigned SL;
|
|
|
|
|
unsigned UM;
|
|
|
|
|
unsigned VS;
|
|
|
|
|
unsigned char MB[7];
|
|
|
|
|
unsigned char MD[10];
|
|
|
|
|
unsigned char ME[7];
|
|
|
|
|
unsigned char MV[7];
|
|
|
|
|
|
|
|
|
|
// Decoded data
|
2017-12-07 16:34:08 +00:00
|
|
|
unsigned altitude_baro_valid : 1;
|
|
|
|
|
unsigned altitude_geom_valid : 1;
|
2017-06-15 17:07:40 +00:00
|
|
|
unsigned track_valid : 1;
|
|
|
|
|
unsigned track_rate_valid : 1;
|
2016-08-27 13:34:14 +00:00
|
|
|
unsigned heading_valid : 1;
|
2017-06-15 17:07:40 +00:00
|
|
|
unsigned roll_valid : 1;
|
|
|
|
|
unsigned gs_valid : 1;
|
|
|
|
|
unsigned ias_valid : 1;
|
|
|
|
|
unsigned tas_valid : 1;
|
|
|
|
|
unsigned mach_valid : 1;
|
|
|
|
|
unsigned baro_rate_valid : 1;
|
|
|
|
|
unsigned geom_rate_valid : 1;
|
2016-08-27 13:34:14 +00:00
|
|
|
unsigned squawk_valid : 1;
|
|
|
|
|
unsigned callsign_valid : 1;
|
|
|
|
|
unsigned cpr_valid : 1;
|
|
|
|
|
unsigned cpr_odd : 1;
|
|
|
|
|
unsigned cpr_decoded : 1;
|
|
|
|
|
unsigned cpr_relative : 1;
|
|
|
|
|
unsigned category_valid : 1;
|
2017-06-15 17:07:40 +00:00
|
|
|
unsigned geom_delta_valid : 1;
|
2016-08-27 13:34:14 +00:00
|
|
|
unsigned from_mlat : 1;
|
|
|
|
|
unsigned from_tisb : 1;
|
|
|
|
|
unsigned spi_valid : 1;
|
|
|
|
|
unsigned spi : 1;
|
|
|
|
|
unsigned alert_valid : 1;
|
|
|
|
|
unsigned alert : 1;
|
2018-01-09 14:43:58 +00:00
|
|
|
unsigned emergency_valid : 1;
|
2016-08-27 13:34:14 +00:00
|
|
|
|
|
|
|
|
unsigned metype; // DF17/18 ME type
|
|
|
|
|
unsigned mesub; // DF17/18 ME subtype
|
|
|
|
|
|
2017-06-15 17:07:40 +00:00
|
|
|
commb_format_t commb_format; // Inferred format of a comm-b message
|
|
|
|
|
|
2017-12-07 16:34:08 +00:00
|
|
|
// valid if altitude_baro_valid:
|
|
|
|
|
int altitude_baro; // Altitude in either feet or meters
|
|
|
|
|
altitude_unit_t altitude_baro_unit; // the unit used for altitude
|
|
|
|
|
|
|
|
|
|
// valid if altitude_geom_valid:
|
|
|
|
|
int altitude_geom; // Altitude in either feet or meters
|
|
|
|
|
altitude_unit_t altitude_geom_unit; // the unit used for altitude
|
2017-06-15 17:07:40 +00:00
|
|
|
|
|
|
|
|
// following fields are valid if the corresponding _valid field is set:
|
|
|
|
|
int geom_delta; // Difference between geometric and baro alt
|
2017-06-15 20:07:53 +00:00
|
|
|
float heading; // ground track or heading, degrees (0-359). Reported directly or computed from from EW and NS velocity
|
|
|
|
|
heading_type_t heading_type;// how to interpret 'track_or_heading'
|
2017-06-15 17:07:40 +00:00
|
|
|
float track_rate; // Rate of change of track, degrees/second
|
|
|
|
|
float roll; // Roll, degrees, negative is left roll
|
2017-12-07 16:34:08 +00:00
|
|
|
struct {
|
|
|
|
|
// Groundspeed, kts, reported directly or computed from from EW and NS velocity
|
|
|
|
|
// For surface movement, this has different interpretations for v0 and v2; both
|
|
|
|
|
// fields are populated. The tracking layer will update "gs.selected".
|
|
|
|
|
float v0;
|
|
|
|
|
float v2;
|
|
|
|
|
float selected;
|
|
|
|
|
} gs;
|
2017-06-15 17:07:40 +00:00
|
|
|
unsigned ias; // Indicated airspeed, kts
|
|
|
|
|
unsigned tas; // True airspeed, kts
|
|
|
|
|
double mach; // Mach number
|
|
|
|
|
int baro_rate; // Rate of change of barometric altitude, feet/minute
|
|
|
|
|
int geom_rate; // Rate of change of geometric (GNSS / INS) altitude, feet/minute
|
|
|
|
|
unsigned squawk; // 13 bits identity (Squawk), encoded as 4 hex digits
|
|
|
|
|
char callsign[9]; // 8 chars flight number, NUL-terminated
|
2015-02-22 12:15:26 +00:00
|
|
|
unsigned category; // A0 - D7 encoded as a single hex byte
|
2018-01-09 14:43:58 +00:00
|
|
|
emergency_t emergency; // emergency/priority status
|
2017-06-15 17:16:51 +00:00
|
|
|
|
2016-08-27 13:34:14 +00:00
|
|
|
// valid if cpr_valid
|
2017-06-15 17:16:51 +00:00
|
|
|
cpr_type_t cpr_type; // The encoding type used (surface, airborne, coarse TIS-B)
|
|
|
|
|
unsigned cpr_lat; // Non decoded latitude.
|
|
|
|
|
unsigned cpr_lon; // Non decoded longitude.
|
|
|
|
|
unsigned cpr_nucp; // NUCp/NIC value implied by message type
|
2013-05-24 22:32:12 +00:00
|
|
|
|
2017-06-15 17:16:51 +00:00
|
|
|
airground_t airground; // air/ground state
|
2015-01-21 00:23:48 +00:00
|
|
|
|
2016-08-27 13:34:14 +00:00
|
|
|
// valid if cpr_decoded:
|
|
|
|
|
double decoded_lat;
|
|
|
|
|
double decoded_lon;
|
2017-12-07 16:34:08 +00:00
|
|
|
unsigned decoded_nic;
|
|
|
|
|
unsigned decoded_rc;
|
|
|
|
|
|
|
|
|
|
// various integrity/accuracy things
|
|
|
|
|
struct {
|
|
|
|
|
unsigned nic_a_valid : 1;
|
|
|
|
|
unsigned nic_b_valid : 1;
|
|
|
|
|
unsigned nic_c_valid : 1;
|
|
|
|
|
unsigned nic_baro_valid : 1;
|
|
|
|
|
unsigned nac_p_valid : 1;
|
|
|
|
|
unsigned nac_v_valid : 1;
|
|
|
|
|
unsigned gva_valid : 1;
|
|
|
|
|
unsigned sda_valid : 1;
|
|
|
|
|
|
|
|
|
|
unsigned nic_a : 1; // if nic_a_valid
|
|
|
|
|
unsigned nic_b : 1; // if nic_b_valid
|
|
|
|
|
unsigned nic_c : 1; // if nic_c_valid
|
|
|
|
|
unsigned nic_baro : 1; // if nic_baro_valid
|
|
|
|
|
|
|
|
|
|
unsigned nac_p : 4; // if nac_p_valid
|
|
|
|
|
unsigned nac_v : 3; // if nac_v_valid
|
|
|
|
|
|
2017-12-07 19:36:07 +00:00
|
|
|
unsigned sil : 2; // if sil_type != SIL_INVALID
|
|
|
|
|
sil_type_t sil_type;
|
2017-12-07 16:34:08 +00:00
|
|
|
|
|
|
|
|
unsigned gva : 2; // if gva_valid
|
|
|
|
|
|
|
|
|
|
unsigned sda : 2; // if sda_valid
|
|
|
|
|
} accuracy;
|
2016-08-29 10:11:04 +00:00
|
|
|
|
|
|
|
|
// Operational Status
|
|
|
|
|
struct {
|
|
|
|
|
unsigned valid : 1;
|
|
|
|
|
unsigned version : 3;
|
|
|
|
|
|
|
|
|
|
unsigned om_acas_ra : 1;
|
|
|
|
|
unsigned om_ident : 1;
|
|
|
|
|
unsigned om_atc : 1;
|
|
|
|
|
unsigned om_saf : 1;
|
|
|
|
|
|
|
|
|
|
unsigned cc_acas : 1;
|
|
|
|
|
unsigned cc_cdti : 1;
|
|
|
|
|
unsigned cc_1090_in : 1;
|
|
|
|
|
unsigned cc_arv : 1;
|
|
|
|
|
unsigned cc_ts : 1;
|
|
|
|
|
unsigned cc_tc : 2;
|
|
|
|
|
unsigned cc_uat_in : 1;
|
|
|
|
|
unsigned cc_poa : 1;
|
|
|
|
|
unsigned cc_b2_low : 1;
|
|
|
|
|
unsigned cc_lw_valid : 1;
|
|
|
|
|
|
2017-06-15 20:07:53 +00:00
|
|
|
heading_type_t tah;
|
|
|
|
|
heading_type_t hrd;
|
2016-08-29 10:11:04 +00:00
|
|
|
|
|
|
|
|
unsigned cc_lw;
|
|
|
|
|
unsigned cc_antenna_offset;
|
|
|
|
|
} opstatus;
|
|
|
|
|
|
2017-06-15 17:07:40 +00:00
|
|
|
// combined:
|
|
|
|
|
// Target State & Status (ADS-B V2 only)
|
|
|
|
|
// Comm-B BDS4,0 Vertical Intent
|
2016-08-29 10:11:04 +00:00
|
|
|
struct {
|
|
|
|
|
unsigned heading_valid : 1;
|
2017-06-15 17:07:40 +00:00
|
|
|
unsigned fms_altitude_valid : 1;
|
|
|
|
|
unsigned mcp_altitude_valid : 1;
|
2017-12-07 16:34:08 +00:00
|
|
|
unsigned qnh_valid : 1;
|
2017-06-16 09:39:01 +00:00
|
|
|
unsigned modes_valid : 1;
|
2016-08-29 10:11:04 +00:00
|
|
|
|
2017-06-15 17:07:40 +00:00
|
|
|
float heading; // heading, degrees (0-359) (could be magnetic or true heading; magnetic recommended)
|
2017-12-07 16:34:08 +00:00
|
|
|
heading_type_t heading_type;
|
2017-06-15 17:07:40 +00:00
|
|
|
unsigned fms_altitude; // FMS selected altitude
|
|
|
|
|
unsigned mcp_altitude; // MCP/FCU selected altitude
|
2017-12-07 16:34:08 +00:00
|
|
|
float qnh; // altimeter setting (QFE or QNH/QNE), millibars
|
2017-06-15 17:07:40 +00:00
|
|
|
|
2019-03-19 18:44:09 +00:00
|
|
|
nav_altitude_source_t altitude_source;
|
2017-06-15 17:07:40 +00:00
|
|
|
|
2017-12-07 16:34:08 +00:00
|
|
|
nav_modes_t modes;
|
|
|
|
|
} nav;
|
2021-07-29 11:04:49 +00:00
|
|
|
|
|
|
|
|
// BDS 4,4 MRAR
|
|
|
|
|
unsigned mrar_source_valid : 1;
|
|
|
|
|
unsigned wind_valid : 1;
|
|
|
|
|
unsigned temperature_valid : 1;
|
|
|
|
|
unsigned pressure_valid : 1;
|
|
|
|
|
unsigned turbulence_valid : 1;
|
|
|
|
|
unsigned humidity_valid : 1;
|
|
|
|
|
|
|
|
|
|
mrar_source_t mrar_source;
|
|
|
|
|
float wind_speed; // kts
|
|
|
|
|
float wind_dir; // degrees
|
|
|
|
|
float temperature; // degrees C
|
|
|
|
|
float pressure; // hPa
|
|
|
|
|
hazard_t turbulence; // NIL/LIGHT/MODERATE/SEVERE
|
|
|
|
|
float humidity; // 0-100 %
|
2013-05-24 22:32:12 +00:00
|
|
|
};
|
|
|
|
|
|
If we squelch the first message from an aircraft, emit it when we see a second message.
This is possible now that the SBS output doesn't rely on the global block timestamp;
the output will look like this:
MSG,8,111,11111,4AC954,111111,2015/02/08,17:57:53.917,2015/02/08,17:57:53.936,,,,,,,,,,,,0
MSG,7,111,11111,392AEB,111111,2015/02/08,17:57:53.744,2015/02/08,17:57:53.936,,15375,,,,,,,,,,0
MSG,8,111,11111,392AEB,111111,2015/02/08,17:57:53.917,2015/02/08,17:57:53.936,,,,,,,,,,,,0
MSG,6,111,11111,800387,111111,2015/02/08,17:57:53.919,2015/02/08,17:57:53.936,,,,,,,,4745,0,0,0,0
where the "receive timestamp" (first time column) goes backwards to reflect the original reception
time of the delayed message, but the "forwarded timestamp" (second time column) reflects the actual
forwarding time.
2015-02-08 18:00:18 +00:00
|
|
|
// This one needs modesMessage:
|
|
|
|
|
#include "track.h"
|
2017-06-15 17:07:40 +00:00
|
|
|
#include "mode_s.h"
|
|
|
|
|
#include "comm_b.h"
|
If we squelch the first message from an aircraft, emit it when we see a second message.
This is possible now that the SBS output doesn't rely on the global block timestamp;
the output will look like this:
MSG,8,111,11111,4AC954,111111,2015/02/08,17:57:53.917,2015/02/08,17:57:53.936,,,,,,,,,,,,0
MSG,7,111,11111,392AEB,111111,2015/02/08,17:57:53.744,2015/02/08,17:57:53.936,,15375,,,,,,,,,,0
MSG,8,111,11111,392AEB,111111,2015/02/08,17:57:53.917,2015/02/08,17:57:53.936,,,,,,,,,,,,0
MSG,6,111,11111,800387,111111,2015/02/08,17:57:53.919,2015/02/08,17:57:53.936,,,,,,,,4745,0,0,0,0
where the "receive timestamp" (first time column) goes backwards to reflect the original reception
time of the delayed message, but the "forwarded timestamp" (second time column) reflects the actual
forwarding time.
2015-02-08 18:00:18 +00:00
|
|
|
|
2013-08-19 14:55:17 +00:00
|
|
|
// ======================== function declarations =========================
|
2013-05-24 22:32:12 +00:00
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2013-08-19 14:55:17 +00:00
|
|
|
//
|
|
|
|
|
// Functions exported from mode_ac.c
|
|
|
|
|
//
|
2013-05-24 22:32:12 +00:00
|
|
|
int detectModeA (uint16_t *m, struct modesMessage *mm);
|
|
|
|
|
void decodeModeAMessage(struct modesMessage *mm, int ModeA);
|
2016-10-11 16:57:25 +00:00
|
|
|
void modeACInit();
|
|
|
|
|
int modeAToModeC (unsigned int modeA);
|
|
|
|
|
unsigned modeCToModeA (int modeC);
|
2013-05-24 22:32:12 +00:00
|
|
|
|
2013-08-19 14:55:17 +00:00
|
|
|
//
|
|
|
|
|
// Functions exported from interactive.c
|
|
|
|
|
//
|
2016-10-11 19:37:28 +00:00
|
|
|
void interactiveInit(void);
|
2013-08-19 14:55:17 +00:00
|
|
|
void interactiveShowData(void);
|
2016-10-11 19:37:28 +00:00
|
|
|
void interactiveCleanup(void);
|
2019-12-02 11:51:06 +00:00
|
|
|
void interactiveNoConnection(void);
|
2013-09-20 15:48:15 +00:00
|
|
|
|
2016-12-27 19:07:10 +00:00
|
|
|
// Provided by dump1090.c / view1090.c / faup1090.c
|
|
|
|
|
void receiverPositionChanged(float lat, float lon, float alt);
|
|
|
|
|
|
2013-05-24 22:32:12 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif // __DUMP1090_H
|