Merge branch 'upstream'

This commit is contained in:
Oliver Jowett 2016-01-21 21:48:15 +00:00
commit d02893fe3c
8 changed files with 78 additions and 31 deletions

View file

@ -4,9 +4,11 @@ os:
- linux - linux
- osx - osx
sudo: required
dist: trusty
before_install: before_install:
- if [ `uname` = "Linux" ]; then - if [ `uname` = "Linux" ]; then
sudo add-apt-repository ppa:gqrx/releases -y;
sudo apt-get update -qq; sudo apt-get update -qq;
sudo apt-get install -y build-essential debhelper librtlsdr-dev libusb-1.0-0-dev pkg-config; sudo apt-get install -y build-essential debhelper librtlsdr-dev libusb-1.0-0-dev pkg-config;
elif [ `uname` = "Darwin" ]; then elif [ `uname` = "Darwin" ]; then
@ -20,4 +22,4 @@ script:
elif [ `uname` = "Darwin" ]; then elif [ `uname` = "Darwin" ]; then
make; make;
make test; make test;
fi fi

View file

@ -2,7 +2,7 @@
// //
// dump1090.c: main program & miscellany // dump1090.c: main program & miscellany
// //
// Copyright (c) 2014,2015 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2014-2016 Oliver Jowett <oliver@mutability.co.uk>
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
@ -702,7 +702,9 @@ void showHelp(void) {
"--no-fix Disable single-bits error correction using CRC\n" "--no-fix Disable single-bits error correction using CRC\n"
"--no-crc-check Disable messages with broken CRC (discouraged)\n" "--no-crc-check Disable messages with broken CRC (discouraged)\n"
"--phase-enhance Enable phase enhancement\n" "--phase-enhance Enable phase enhancement\n"
#ifdef ALLOW_AGGRESSIVE
"--aggressive More CPU for more messages (two bits fixes, ...)\n" "--aggressive More CPU for more messages (two bits fixes, ...)\n"
#endif
"--mlat display raw messages in Beast ascii mode\n" "--mlat display raw messages in Beast ascii mode\n"
"--stats With --ifile print stats at exit. No other output\n" "--stats With --ifile print stats at exit. No other output\n"
"--stats-range Collect/show range histogram\n" "--stats-range Collect/show range histogram\n"
@ -1010,7 +1012,11 @@ int main(int argc, char **argv) {
} else if (!strcmp(argv[j],"--hae")) { } else if (!strcmp(argv[j],"--hae")) {
Modes.use_hae = 1; Modes.use_hae = 1;
} else if (!strcmp(argv[j],"--aggressive")) { } else if (!strcmp(argv[j],"--aggressive")) {
#ifdef ALLOW_AGGRESSIVE
Modes.nfix_crc = MODES_MAX_BITERRORS; Modes.nfix_crc = MODES_MAX_BITERRORS;
#else
fprintf(stderr, "warning: --aggressive not supported in this build, option ignored.\n");
#endif
} else if (!strcmp(argv[j],"--interactive")) { } else if (!strcmp(argv[j],"--interactive")) {
Modes.interactive = Modes.throttle = 1; Modes.interactive = Modes.throttle = 1;
} else if (!strcmp(argv[j],"--throttle")) { } else if (!strcmp(argv[j],"--throttle")) {

View file

@ -165,6 +165,7 @@ typedef struct rtlsdr_dev rtlsdr_dev_t;
#define MODES_ACFLAGS_FROM_MLAT (1<<18) // Data was derived from multilateration #define MODES_ACFLAGS_FROM_MLAT (1<<18) // Data was derived from multilateration
#define MODES_ACFLAGS_ALTITUDE_HAE_VALID (1<<19) // altitude_hae is valid #define MODES_ACFLAGS_ALTITUDE_HAE_VALID (1<<19) // altitude_hae is valid
#define MODES_ACFLAGS_HAE_DELTA_VALID (1<<20) // hae_delta is valid #define MODES_ACFLAGS_HAE_DELTA_VALID (1<<20) // hae_delta is valid
#define MODES_ACFLAGS_FROM_TISB (1<<21) // Data was derived from TIS-B messages
#define MODES_ACFLAGS_LLEITHER_VALID (MODES_ACFLAGS_LLEVEN_VALID | MODES_ACFLAGS_LLODD_VALID) #define MODES_ACFLAGS_LLEITHER_VALID (MODES_ACFLAGS_LLEVEN_VALID | MODES_ACFLAGS_LLODD_VALID)
#define MODES_ACFLAGS_LLBOTH_VALID (MODES_ACFLAGS_LLEVEN_VALID | MODES_ACFLAGS_LLODD_VALID) #define MODES_ACFLAGS_LLBOTH_VALID (MODES_ACFLAGS_LLEVEN_VALID | MODES_ACFLAGS_LLODD_VALID)

View file

@ -63,7 +63,7 @@ static void faupInitConfig(void) {
Modes.check_crc = 1; Modes.check_crc = 1;
Modes.net = 1; Modes.net = 1;
Modes.net_heartbeat_interval = MODES_NET_HEARTBEAT_INTERVAL; Modes.net_heartbeat_interval = MODES_NET_HEARTBEAT_INTERVAL;
Modes.maxRange = 1852 * 300; // 300NM default max range Modes.maxRange = 1852 * 360; // 360NM default max range; this also disables receiver-relative positions
Modes.quiet = 1; Modes.quiet = 1;
Modes.net_output_flush_size = MODES_OUT_FLUSH_SIZE; Modes.net_output_flush_size = MODES_OUT_FLUSH_SIZE;
Modes.net_output_flush_interval = 200; // milliseconds Modes.net_output_flush_interval = 200; // milliseconds
@ -111,7 +111,7 @@ static void showHelp(void) {
"--net-fatsv-port <port> FlightAware TSV output port (default: 10001)\n" "--net-fatsv-port <port> FlightAware TSV output port (default: 10001)\n"
"--lat <latitude> Reference/receiver latitude for surface posn (opt)\n" "--lat <latitude> Reference/receiver latitude for surface posn (opt)\n"
"--lon <longitude> Reference/receiver longitude for surface posn (opt)\n" "--lon <longitude> Reference/receiver longitude for surface posn (opt)\n"
"--max-range <distance> Absolute maximum range for position decoding (in nm, default: 300)\n" "--max-range <distance> Absolute maximum range for position decoding (in nm, default: 360)\n"
"--stdout REQUIRED. Write results to stdout.\n" "--stdout REQUIRED. Write results to stdout.\n"
"--help Show this help\n" "--help Show this help\n"
"\n", "\n",

View file

@ -714,6 +714,11 @@ static void decodeExtendedSquitter(struct modesMessage *mm)
// Check CF on DF18 to work out the format of the ES and whether we need to look for an IMF bit // Check CF on DF18 to work out the format of the ES and whether we need to look for an IMF bit
if (mm->msgtype == 18) { if (mm->msgtype == 18) {
/* we just globally tag any DF18 as TIS-B,
* which is not strictly true but close enough
*/
mm->bFlags |= MODES_ACFLAGS_FROM_TISB;
switch (mm->cf) { switch (mm->cf) {
case 0: // ADS-B ES/NT devices that report the ICAO 24-bit address in the AA field case 0: // ADS-B ES/NT devices that report the ICAO 24-bit address in the AA field
break; break;

View file

@ -643,12 +643,16 @@ static void send_sbs_heartbeat(struct net_service *service)
//========================================================================= //=========================================================================
// //
void modesQueueOutput(struct modesMessage *mm, struct aircraft *a) { void modesQueueOutput(struct modesMessage *mm, struct aircraft *a) {
if ((mm->bFlags & MODES_ACFLAGS_FROM_MLAT) && !Modes.forward_mlat) int is_mlat = ((mm->bFlags & MODES_ACFLAGS_FROM_MLAT) != 0);
return;
modesSendSBSOutput(mm, a); if (!is_mlat) {
modesSendBeastOutput(mm); modesSendSBSOutput(mm, a);
modesSendRawOutput(mm); modesSendRawOutput(mm);
}
if (!is_mlat || Modes.forward_mlat) {
modesSendBeastOutput(mm);
}
} }
// //
//========================================================================= //=========================================================================
@ -875,6 +879,31 @@ static const char *jsonEscapeString(const char *str) {
return buf; return buf;
} }
static char *append_flags(char *p, char *end, int flags)
{
p += snprintf(p, end-p, "[");
if (flags & MODES_ACFLAGS_SQUAWK_VALID)
p += snprintf(p, end-p, "\"squawk\",");
if (flags & MODES_ACFLAGS_CALLSIGN_VALID)
p += snprintf(p, end-p, "\"callsign\",");
if (flags & MODES_ACFLAGS_LATLON_VALID)
p += snprintf(p, end-p, "\"lat\",\"lon\",");
if (flags & MODES_ACFLAGS_ALTITUDE_VALID)
p += snprintf(p, end-p, "\"altitude\",");
if (flags & MODES_ACFLAGS_HEADING_VALID)
p += snprintf(p, end-p, "\"track\",");
if (flags & MODES_ACFLAGS_SPEED_VALID)
p += snprintf(p, end-p, "\"speed\",");
if (flags & MODES_ACFLAGS_VERTRATE_VALID)
p += snprintf(p, end-p, "\"vert_rate\",");
if (flags & MODES_ACFLAGS_CATEGORY_VALID)
p += snprintf(p, end-p, "\"category\",");
if (p[-1] != '[')
--p;
p += snprintf(p, end-p, "]");
return p;
}
char *generateAircraftJson(const char *url_path, int *len) { char *generateAircraftJson(const char *url_path, int *len) {
uint64_t now = mstime(); uint64_t now = mstime();
struct aircraft *a; struct aircraft *a;
@ -925,26 +954,12 @@ char *generateAircraftJson(const char *url_path, int *len) {
if (a->bFlags & MODES_ACFLAGS_CATEGORY_VALID) if (a->bFlags & MODES_ACFLAGS_CATEGORY_VALID)
p += snprintf(p, end-p, ",\"category\":\"%02X\"", a->category); p += snprintf(p, end-p, ",\"category\":\"%02X\"", a->category);
if (a->mlatFlags) { if (a->mlatFlags) {
p += snprintf(p, end-p, ",\"mlat\":["); p += snprintf(p, end-p, ",\"mlat\":");
if (a->mlatFlags & MODES_ACFLAGS_SQUAWK_VALID) p = append_flags(p, end, a->mlatFlags);
p += snprintf(p, end-p, "\"squawk\","); }
if (a->mlatFlags & MODES_ACFLAGS_CALLSIGN_VALID) if (a->tisbFlags) {
p += snprintf(p, end-p, "\"callsign\","); p += snprintf(p, end-p, ",\"tisb\":");
if (a->mlatFlags & MODES_ACFLAGS_LATLON_VALID) p = append_flags(p, end, a->tisbFlags);
p += snprintf(p, end-p, "\"lat\",\"lon\",");
if (a->mlatFlags & MODES_ACFLAGS_ALTITUDE_VALID)
p += snprintf(p, end-p, "\"altitude\",");
if (a->mlatFlags & MODES_ACFLAGS_HEADING_VALID)
p += snprintf(p, end-p, "\"track\",");
if (a->mlatFlags & MODES_ACFLAGS_SPEED_VALID)
p += snprintf(p, end-p, "\"speed\",");
if (a->mlatFlags & MODES_ACFLAGS_VERTRATE_VALID)
p += snprintf(p, end-p, "\"vert_rate\",");
if (a->mlatFlags & MODES_ACFLAGS_CATEGORY_VALID)
p += snprintf(p, end-p, "\"category\",");
if (p[-1] != '[')
--p;
p += snprintf(p, end-p, "]");
} }
p += snprintf(p, end-p, ",\"messages\":%ld,\"seen\":%.1f,\"rssi\":%.1f}", p += snprintf(p, end-p, ",\"messages\":%ld,\"seen\":%.1f,\"rssi\":%.1f}",
@ -1550,7 +1565,7 @@ static void modesReadFromClient(struct client *c) {
} }
} }
#define TSV_MAX_PACKET_SIZE 160 #define TSV_MAX_PACKET_SIZE 180
static void writeFATSV() static void writeFATSV()
{ {
@ -1595,6 +1610,7 @@ static void writeFATSV()
char *p, *end; char *p, *end;
int flags; int flags;
int used_tisb = 0;
// skip non-ICAO // skip non-ICAO
if (a->addr & MODES_NON_ICAO_ADDRESS) if (a->addr & MODES_NON_ICAO_ADDRESS)
@ -1617,6 +1633,7 @@ static void writeFATSV()
alt = a->altitude; alt = a->altitude;
altAge = now - a->seenAltitude; altAge = now - a->seenAltitude;
altValid = (altAge <= 30000); altValid = (altAge <= 30000);
used_tisb |= (a->tisbFlags & MODES_ACFLAGS_ALTITUDE_VALID);
} }
if (flags & MODES_ACFLAGS_AOG_VALID) { if (flags & MODES_ACFLAGS_AOG_VALID) {
@ -1629,21 +1646,26 @@ static void writeFATSV()
altAge = 0; altAge = 0;
ground = 1; ground = 1;
} }
used_tisb |= (a->tisbFlags & MODES_ACFLAGS_AOG_VALID);
} }
if (flags & MODES_ACFLAGS_LATLON_VALID) { if (flags & MODES_ACFLAGS_LATLON_VALID) {
latlonAge = now - a->seenLatLon; latlonAge = now - a->seenLatLon;
latlonValid = (latlonAge <= 30000); latlonValid = (latlonAge <= 30000);
used_tisb |= (a->tisbFlags & MODES_ACFLAGS_LATLON_VALID);
} }
if (flags & MODES_ACFLAGS_HEADING_VALID) { if (flags & MODES_ACFLAGS_HEADING_VALID) {
trackAge = now - a->seenTrack; trackAge = now - a->seenTrack;
trackValid = (trackAge <= 30000); trackValid = (trackAge <= 30000);
used_tisb |= (a->tisbFlags & MODES_ACFLAGS_HEADING_VALID);
} }
if (flags & MODES_ACFLAGS_SPEED_VALID) { if (flags & MODES_ACFLAGS_SPEED_VALID) {
speedAge = now - a->seenSpeed; speedAge = now - a->seenSpeed;
speedValid = (speedAge <= 30000); speedValid = (speedAge <= 30000);
used_tisb |= (a->tisbFlags & MODES_ACFLAGS_SPEED_VALID);
} }
// don't send mode S very often // don't send mode S very often
@ -1725,6 +1747,10 @@ static void writeFATSV()
useful = 1; useful = 1;
} }
if (used_tisb) {
p += snprintf(p, bufsize(p,end), "\ttisb\t1");
}
// if we didn't get at least an alt or a speed or a latlon or // if we didn't get at least an alt or a speed or a latlon or
// a heading, bail out. We don't need to do anything special // a heading, bail out. We don't need to do anything special
// to unwind prepareWrite(). // to unwind prepareWrite().

View file

@ -597,6 +597,12 @@ struct aircraft *trackUpdateFromMessage(struct modesMessage *mm)
else else
a->mlatFlags = (a->mlatFlags & a->bFlags) & ~mm->bFlags; a->mlatFlags = (a->mlatFlags & a->bFlags) & ~mm->bFlags;
// Same for TIS-B
if (mm->bFlags & MODES_ACFLAGS_FROM_TISB)
a->tisbFlags = (a->tisbFlags & a->bFlags) | mm->bFlags;
else
a->tisbFlags = (a->tisbFlags & a->bFlags) & ~mm->bFlags;
if (mm->msgtype == 32) { if (mm->msgtype == 32) {
int flags = a->modeACflags; int flags = a->modeACflags;
if ((flags & (MODEAC_MSG_MODEC_HIT | MODEAC_MSG_MODEC_OLD)) == MODEAC_MSG_MODEC_OLD) { if ((flags & (MODEAC_MSG_MODEC_HIT | MODEAC_MSG_MODEC_OLD)) == MODEAC_MSG_MODEC_OLD) {

View file

@ -78,6 +78,7 @@ struct aircraft {
uint64_t seenTrack; // Time (millis) at which track was measured uint64_t seenTrack; // Time (millis) at which track was measured
int mlatFlags; // Data derived from mlat messages int mlatFlags; // Data derived from mlat messages
int tisbFlags; // Data derived from TIS-B messages
long messages; // Number of Mode S messages received long messages; // Number of Mode S messages received
int modeA; // Squawk int modeA; // Squawk