├── resource.h ├── debian ├── compat ├── source │ └── format ├── dump1090-mutability.logrotate ├── dump1090-mutability.install ├── dump1090-mutability.conffiles ├── cron-template ├── lighttpd │ └── 89-dump1090.conf ├── control ├── rules ├── dump1090-mutability.postrm ├── copyright ├── config-template ├── dump1090-mutability.postinst ├── dump1090-mutability.init └── dump1090-mutability.config ├── inttypes ├── README ├── changelog.txt ├── LICENSE.inttypes ├── stdint.h └── inttypes.h ├── endian ├── README.endian └── endian.h ├── dump1090.rc ├── rtlsdr ├── rtlsdr.dll ├── rtlsdr.lib ├── libusb-1.0.dll ├── rtlsdr_static.lib ├── AUTHORS ├── README ├── README.windows.txt └── rtl-sdr_export.h ├── testfiles └── modes1.bin ├── pthread ├── pthreadVC2.lib ├── sched.h ├── CONTRIBUTORS └── COPYING.pthreads ├── public_html ├── spinny.gif ├── style.css ├── config.js ├── formatter.js └── dbloader.js ├── winposixclock ├── winposixclock.dll ├── winposixclock.exp ├── winposixclock.lib ├── winposixclock.h └── winposixclock_types.h ├── .gitignore ├── demod_2000.h ├── demod_2400.h ├── util.h ├── crc.h ├── README.md ├── icao_filter.h ├── dump1090.sln ├── Makefile ├── cpr.h ├── convert.h ├── LICENSE ├── anet.h ├── tools ├── update-aircraft-database.sh ├── vrs-basicaircraft-to-json.py └── debug.html ├── net_io.h ├── view1090.vcxproj.filters ├── mode_ac.c ├── util.c ├── stats.h ├── dump1090.vcxproj.filters ├── track.h ├── icao_filter.c ├── winstubs.h ├── interactive.c ├── faup1090.c ├── view1090.vcxproj ├── README-json.md └── dump1090.vcxproj /resource.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 8 2 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (native) 2 | -------------------------------------------------------------------------------- /inttypes/README: -------------------------------------------------------------------------------- 1 | from: https://code.google.com/p/msinttypes/ -------------------------------------------------------------------------------- /endian/README.endian: -------------------------------------------------------------------------------- 1 | from: https://gist.github.com/panzi/6856583 -------------------------------------------------------------------------------- /dump1090.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tpainter/dump1090_win/HEAD/dump1090.rc -------------------------------------------------------------------------------- /endian/endian.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tpainter/dump1090_win/HEAD/endian/endian.h -------------------------------------------------------------------------------- /rtlsdr/rtlsdr.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tpainter/dump1090_win/HEAD/rtlsdr/rtlsdr.dll -------------------------------------------------------------------------------- /rtlsdr/rtlsdr.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tpainter/dump1090_win/HEAD/rtlsdr/rtlsdr.lib -------------------------------------------------------------------------------- /testfiles/modes1.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tpainter/dump1090_win/HEAD/testfiles/modes1.bin -------------------------------------------------------------------------------- /inttypes/changelog.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tpainter/dump1090_win/HEAD/inttypes/changelog.txt -------------------------------------------------------------------------------- /pthread/pthreadVC2.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tpainter/dump1090_win/HEAD/pthread/pthreadVC2.lib -------------------------------------------------------------------------------- /public_html/spinny.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tpainter/dump1090_win/HEAD/public_html/spinny.gif -------------------------------------------------------------------------------- /rtlsdr/libusb-1.0.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tpainter/dump1090_win/HEAD/rtlsdr/libusb-1.0.dll -------------------------------------------------------------------------------- /rtlsdr/rtlsdr_static.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tpainter/dump1090_win/HEAD/rtlsdr/rtlsdr_static.lib -------------------------------------------------------------------------------- /winposixclock/winposixclock.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tpainter/dump1090_win/HEAD/winposixclock/winposixclock.dll -------------------------------------------------------------------------------- /winposixclock/winposixclock.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tpainter/dump1090_win/HEAD/winposixclock/winposixclock.exp -------------------------------------------------------------------------------- /winposixclock/winposixclock.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tpainter/dump1090_win/HEAD/winposixclock/winposixclock.lib -------------------------------------------------------------------------------- /debian/dump1090-mutability.logrotate: -------------------------------------------------------------------------------- 1 | /var/log/dump1090-mutability.log { 2 | weekly 3 | rotate 4 4 | copytruncate 5 | } 6 | -------------------------------------------------------------------------------- /rtlsdr/AUTHORS: -------------------------------------------------------------------------------- 1 | Steve Markgraf 2 | Dimitri Stolnikov 3 | Hoernchen 4 | Kyle Keen 5 | -------------------------------------------------------------------------------- /rtlsdr/README: -------------------------------------------------------------------------------- 1 | rtl-sdr 2 | turns your Realtek RTL2832 based DVB dongle into a SDR receiver 3 | ====================================================================== 4 | 5 | For more information see: 6 | http://sdr.osmocom.org/trac/wiki/rtl-sdr 7 | -------------------------------------------------------------------------------- /debian/dump1090-mutability.install: -------------------------------------------------------------------------------- 1 | public_html/* usr/share/dump1090-mutability/html 2 | debian/lighttpd/* etc/lighttpd/conf-available 3 | debian/config-template usr/share/dump1090-mutability 4 | debian/cron-template usr/share/dump1090-mutability 5 | tools/vrs-basicaircraft-to-json.py usr/share/dump1090-mutability 6 | tools/update-aircraft-database.sh usr/share/dump1090-mutability 7 | -------------------------------------------------------------------------------- /debian/dump1090-mutability.conffiles: -------------------------------------------------------------------------------- 1 | /usr/share/dump1090-mutability/html/config.js 2 | /usr/share/dump1090-mutability/html/gmap.html 3 | /usr/share/dump1090-mutability/html/script.js 4 | /usr/share/dump1090-mutability/html/planeObject.js 5 | /usr/share/dump1090-mutability/html/style.css 6 | /usr/share/dump1090-mutability/html/markers.js 7 | /usr/share/dump1090-mutability/html/formatter.js 8 | /usr/share/dump1090-mutability/html/dbloader.js 9 | -------------------------------------------------------------------------------- /rtlsdr/README.windows.txt: -------------------------------------------------------------------------------- 1 | The Windows build is using 2 | https://github.com/libusbx/libusbx 33ba1231a1b07425eaa83935f84b2e4b7f904f35 3 | and 4 | http://sources.redhat.com/pthreads-win32/ cvs 5 | See the corresponding COPYING* files for the license text. 6 | 7 | You might need to grab the runtime from 8 | http://www.microsoft.com/en-us/download/details.aspx?id=8328 9 | or 10 | http://www.microsoft.com/en-us/download/details.aspx?id=13523 -------------------------------------------------------------------------------- /debian/cron-template: -------------------------------------------------------------------------------- 1 | ## TEMPLATE FILE - This is used to create /etc/cron.d/dump1090-mutability ## 2 | ## The first three lines will be discarded ## 3 | 4 | # Checks for updates to the VRS aircraft database once a day at around 5am; 5 | # when an update is available, downloads it and regenerates the JSON data 6 | # used by the webmap. 7 | 8 | # NB: the minute value below is randomly generated on install, to avoid 9 | # all installs hitting the server at the same time. 10 | 11 | # m h dom mon dow user command 12 | @MIN@ 5 * * * @USER@ test -x /usr/share/dump1090-mutability/update-aircraft-database.sh && /usr/share/dump1090-mutability/update-aircraft-database.sh --log-to-file 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | dump1090 3 | testfiles/*.bin 4 | misc 5 | frames.js 6 | .*.swp 7 | *~ 8 | *.rej 9 | *.orig 10 | untrackedDeveloperSettings.js 11 | view1090 12 | faup1090 13 | 14 | #Visual Studio from: https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 15 | ## User-specific files 16 | *.suo 17 | *.user 18 | *.userosscache 19 | *.sln.docstates 20 | 21 | ## User-specific files (MonoDevelop/Xamarin Studio) 22 | *.userprefs 23 | 24 | ## Build results 25 | [Dd]ebug/ 26 | [Dd]ebugPublic/ 27 | [Rr]elease/ 28 | [Rr]eleases/ 29 | x64/ 30 | x86/ 31 | build/ 32 | bld/ 33 | [Bb]in/ 34 | [Oo]bj/ 35 | 36 | ## Visual C++ cache files 37 | ipch/ 38 | *.aps 39 | *.ncb 40 | *.opensdf 41 | *.sdf 42 | *.cachefile 43 | -------------------------------------------------------------------------------- /debian/lighttpd/89-dump1090.conf: -------------------------------------------------------------------------------- 1 | # Allows access to the static files that provide the dump1090 map view, 2 | # and also to the dynamically-generated json parts that contain aircraft 3 | # data and are periodically written by the dump1090 daemon. 4 | 5 | url.redirect += ( 6 | "^/dump1090/$" => "/dump1090/gmap.html", 7 | "^/dump1090$" => "/dump1090/gmap.html" 8 | ) 9 | 10 | alias.url += ( 11 | "/dump1090/data/" => "/run/dump1090-mutability/", 12 | "/dump1090/db/" => "/var/cache/dump1090-mutability/db/", 13 | "/dump1090/" => "/usr/share/dump1090-mutability/html/" 14 | ) 15 | 16 | # The stat cache must be disabled, as aircraft.json changes 17 | # frequently and lighttpd's stat cache often ends up with the 18 | # wrong content length. 19 | server.stat-cache-engine = "disable" 20 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: dump1090-mutability 2 | Section: embedded 3 | Priority: extra 4 | Maintainer: Oliver Jowett 5 | Build-Depends: debhelper(>=8), librtlsdr-dev, libusb-1.0-0-dev, pkg-config 6 | Standards-Version: 3.9.3 7 | Homepage: https://github.com/mutability/dump1090 8 | Vcs-Git: https://github.com/mutability/dump1090.git 9 | 10 | Package: dump1090-mutability 11 | Architecture: any 12 | Depends: ${shlibs:Depends}, ${misc:Depends}, adduser 13 | Recommends: python(>=2.5), cron | cron-daemon 14 | Suggests: lighttpd 15 | Provides: fatsv-data-source 16 | Description: ADS-B Ground Station System for RTL-SDR 17 | Networked Aviation Mode S / ADS-B decoder/translator with RTL-SDR software 18 | defined radio USB device support. 19 | . 20 | This is a packaging of the "mutability" fork of dump1090 that includes 21 | sampling at 2.4MHz and other improvements. 22 | -------------------------------------------------------------------------------- /demod_2000.h: -------------------------------------------------------------------------------- 1 | // Part of dump1090, a Mode S message decoder for RTLSDR devices. 2 | // 3 | // demod_2000.h: 2MHz Mode S demodulator prototypes. 4 | // 5 | // Copyright (c) 2014,2015 Oliver Jowett 6 | // 7 | // This file is free software: you may copy, redistribute and/or modify it 8 | // under the terms of the GNU General Public License as published by the 9 | // Free Software Foundation, either version 2 of the License, or (at your 10 | // option) any later version. 11 | // 12 | // This file is distributed in the hope that it will be useful, but 13 | // WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | // General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program. If not, see . 19 | 20 | #ifndef DUMP1090_DEMOD_2000_H 21 | #define DUMP1090_DEMOD_2000_H 22 | 23 | #include 24 | 25 | struct mag_buf; 26 | 27 | void demodulate2000(struct mag_buf *mag); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /demod_2400.h: -------------------------------------------------------------------------------- 1 | // Part of dump1090, a Mode S message decoder for RTLSDR devices. 2 | // 3 | // demod_2400.h: 2.4MHz Mode S demodulator prototypes. 4 | // 5 | // Copyright (c) 2014,2015 Oliver Jowett 6 | // 7 | // This file is free software: you may copy, redistribute and/or modify it 8 | // under the terms of the GNU General Public License as published by the 9 | // Free Software Foundation, either version 2 of the License, or (at your 10 | // option) any later version. 11 | // 12 | // This file is distributed in the hope that it will be useful, but 13 | // WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | // General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program. If not, see . 19 | 20 | #ifndef DUMP1090_DEMOD_2400_H 21 | #define DUMP1090_DEMOD_2400_H 22 | 23 | #include 24 | 25 | struct mag_buf; 26 | 27 | void demodulate2400(struct mag_buf *mag); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # -*- makefile -*- 3 | # Sample debian/rules that uses debhelper. 4 | # This file was originally written by Joey Hess and Craig Small. 5 | # As a special exception, when this file is copied by dh-make into a 6 | # dh-make output file, you may use that output file without restriction. 7 | # This special exception was added by Craig Small in version 0.37 of dh-make. 8 | 9 | # Uncomment this to turn on verbose mode. 10 | export DH_VERBOSE=1 11 | 12 | export DEB_BUILD_MAINT_OPTIONS = hardening=+all 13 | 14 | DPKG_EXPORT_BUILDFLAGS = 1 15 | include /usr/share/dpkg/buildflags.mk 16 | 17 | export DUMP1090_VERSION=$(shell dpkg-parsechangelog | sed -n 's/^Version: /v/p') 18 | SRCNAME=$(shell dpkg-parsechangelog | sed -n 's/^Source: //p') 19 | 20 | override_dh_auto_build: 21 | dh_auto_build -- 'EXTRACFLAGS=-DHTMLPATH=\"/usr/share/dump1090-mutability/html\" -DMODES_DUMP1090_VARIANT=\"$(SRCNAME)\"' 22 | 23 | override_dh_install: 24 | dh_install 25 | install -d debian/dump1090-mutability/usr/bin 26 | cp -a dump1090 debian/dump1090-mutability/usr/bin/dump1090-mutability 27 | cp -a view1090 debian/dump1090-mutability/usr/bin/view1090-mutability 28 | 29 | %: 30 | dh $@ 31 | -------------------------------------------------------------------------------- /debian/dump1090-mutability.postrm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # postrm script for #PACKAGE# 3 | # 4 | # see: dh_installdeb(1) 5 | 6 | set -e 7 | 8 | # summary of how this script can be called: 9 | # * `remove' 10 | # * `purge' 11 | # * `upgrade' 12 | # * `failed-upgrade' 13 | # * `abort-install' 14 | # * `abort-install' 15 | # * `abort-upgrade' 16 | # * `disappear' 17 | # 18 | # for details, see http://www.debian.org/doc/debian-policy/ or 19 | # the debian-policy package 20 | 21 | 22 | case "$1" in 23 | purge) 24 | rm -f /etc/default/dump1090-mutability 25 | rm -f /etc/cron.d/dump1090-mutability 26 | rm -rf /var/cache/dump1090-mutability 27 | ;; 28 | 29 | remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) 30 | ;; 31 | 32 | *) 33 | echo "postrm called with unknown argument \`$1'" >&2 34 | exit 1 35 | ;; 36 | esac 37 | 38 | # dh_installdeb will replace this with shell code automatically 39 | # generated by other debhelper scripts. 40 | 41 | #DEBHELPER# 42 | 43 | exit 0 44 | -------------------------------------------------------------------------------- /util.h: -------------------------------------------------------------------------------- 1 | // Part of dump1090, a Mode S message decoder for RTLSDR devices. 2 | // 3 | // track.h: aircraft state tracking prototypes 4 | // 5 | // Copyright (c) 2015 Oliver Jowett 6 | // 7 | // This file is free software: you may copy, redistribute and/or modify it 8 | // under the terms of the GNU General Public License as published by the 9 | // Free Software Foundation, either version 2 of the License, or (at your 10 | // option) any later version. 11 | // 12 | // This file is distributed in the hope that it will be useful, but 13 | // WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | // General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program. If not, see . 19 | 20 | #ifndef DUMP1090_UTIL_H 21 | #define DUMP1090_UTIL_H 22 | 23 | #include 24 | 25 | /* Returns system time in milliseconds */ 26 | uint64_t mstime(void); 27 | 28 | /* Returns the time elapsed, in nanoseconds, from t1 to t2, 29 | * where t1 and t2 are 12MHz counters. 30 | */ 31 | int64_t receiveclock_ns_elapsed(uint64_t t1, uint64_t t2); 32 | 33 | /* Normalize the value in ts so that ts->nsec lies in 34 | * [0,999999999] 35 | */ 36 | struct timespec; 37 | void normalize_timespec(struct timespec *ts); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /crc.h: -------------------------------------------------------------------------------- 1 | // Part of dump1090, a Mode S message decoder for RTLSDR devices. 2 | // 3 | // crc.h: Mode S checksum prototypes. 4 | // 5 | // Copyright (c) 2014,2015 Oliver Jowett 6 | // 7 | // This file is free software: you may copy, redistribute and/or modify it 8 | // under the terms of the GNU General Public License as published by the 9 | // Free Software Foundation, either version 2 of the License, or (at your 10 | // option) any later version. 11 | // 12 | // This file is distributed in the hope that it will be useful, but 13 | // WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | // General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program. If not, see . 19 | 20 | #ifndef DUMP1090_CRC_H 21 | #define DUMP1090_CRC_H 22 | 23 | #include 24 | 25 | // Global max for fixable bit erros 26 | #define MODES_MAX_BITERRORS 2 27 | 28 | struct errorinfo { 29 | uint32_t syndrome; // CRC syndrome 30 | int errors; // number of errors 31 | int8_t bit[MODES_MAX_BITERRORS]; // bit positions to fix (-1 = no bit) 32 | }; 33 | 34 | void modesChecksumInit(int fixBits); 35 | uint32_t modesChecksum(uint8_t *msg, int bitlen); 36 | struct errorinfo *modesChecksumDiagnose(uint32_t syndrome, int bitlen); 37 | void modesChecksumFix(uint8_t *msg, struct errorinfo *info); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # dump1090-win Windows package 2 | 3 | This is a fork of Oliver Jowett's version of dump1090 (dump1090-mutability) 4 | and is designed to be built as a Windows package. It does not 5 | add any new functionality. It serves solely as fork to track the developement 6 | of dump1090-mutability and provide similar features for Windows users. 7 | 8 | This version is licensed under the GPL (v3 or later). 9 | See the file COPYING for details. 10 | The source license has been "upgraded" to GPLv3 using the "or later" clause. 11 | This has been done because of the inclusion of required libraries being under 12 | licenses that are not compatible with the GPLv2; namely the Apache License 2.0. 13 | 14 | # Features 15 | 16 | * 2.4MHz "oversampling" support 17 | * supports FlightAware-TSV-format connections directly (same as the FlightAware version - no faup1090 needed) 18 | * map view uses receiver lat/long given to dump1090 automatically 19 | * somewhat cleaned-up network code 20 | * tries to do things "the debian way" when it comes to config, package structure, etc 21 | * probably a bunch of other things I've forgotten.. 22 | 23 | # Install for Windows Users 24 | 25 | **TODO** 26 | 27 | ## Logging 28 | 29 | No logging in Windows is currently configured. 30 | 31 | # Bug reports, feedback etc 32 | 33 | Please use the [github issues page](https://github.com/tpainter/dump1090_win/issues) to report any problems. 34 | 35 | # Building from source 36 | 37 | The programs dump1090.exe and view1090.exe are built from source using Microsoft Visual Studio 2010. Just open 38 | the dump1090.sln file. 39 | -------------------------------------------------------------------------------- /icao_filter.h: -------------------------------------------------------------------------------- 1 | // Part of dump1090, a Mode S message decoder for RTLSDR devices. 2 | // 3 | // icao_filter.c: prototypes for ICAO address hashtable 4 | // 5 | // Copyright (c) 2014,2015 Oliver Jowett 6 | // 7 | // This file is free software: you may copy, redistribute and/or modify it 8 | // under the terms of the GNU General Public License as published by the 9 | // Free Software Foundation, either version 2 of the License, or (at your 10 | // option) any later version. 11 | // 12 | // This file is distributed in the hope that it will be useful, but 13 | // WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | // General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program. If not, see . 19 | 20 | #ifndef DUMP1090_ICAO_FILTER_H 21 | #define DUMP1090_ICAO_FILTER_H 22 | 23 | // Call once: 24 | void icaoFilterInit(); 25 | 26 | // Add an address to the filter 27 | void icaoFilterAdd(uint32_t addr); 28 | 29 | // Test if the given address matches the filter 30 | int icaoFilterTest(uint32_t addr); 31 | 32 | // Test if the top 16 bits match any previously added address. 33 | // If they do, returns an arbitrary one of the matched 34 | // addresses. Returns 0 on failure. 35 | uint32_t icaoFilterTestFuzzy(uint32_t partial); 36 | 37 | // Call this periodically to allow the filter to expire 38 | // old entries. 39 | void icaoFilterExpire(); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /dump1090.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dump1090", "dump1090.vcxproj", "{BE63D02A-C284-8D63-52A2-A5FF5AF292BD}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "view1090", "view1090.vcxproj", "{70065ED2-8338-DFFE-CB59-104662C18E6C}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | Template|Win32 = Template|Win32 13 | EndGlobalSection 14 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 15 | {BE63D02A-C284-8D63-52A2-A5FF5AF292BD}.Debug|Win32.ActiveCfg = Debug|Win32 16 | {BE63D02A-C284-8D63-52A2-A5FF5AF292BD}.Debug|Win32.Build.0 = Debug|Win32 17 | {BE63D02A-C284-8D63-52A2-A5FF5AF292BD}.Release|Win32.ActiveCfg = Release|Win32 18 | {BE63D02A-C284-8D63-52A2-A5FF5AF292BD}.Release|Win32.Build.0 = Release|Win32 19 | {BE63D02A-C284-8D63-52A2-A5FF5AF292BD}.Template|Win32.ActiveCfg = Release|Win32 20 | {BE63D02A-C284-8D63-52A2-A5FF5AF292BD}.Template|Win32.Build.0 = Release|Win32 21 | {70065ED2-8338-DFFE-CB59-104662C18E6C}.Debug|Win32.ActiveCfg = Debug|Win32 22 | {70065ED2-8338-DFFE-CB59-104662C18E6C}.Release|Win32.ActiveCfg = Release|Win32 23 | {70065ED2-8338-DFFE-CB59-104662C18E6C}.Template|Win32.ActiveCfg = Template|Win32 24 | {70065ED2-8338-DFFE-CB59-104662C18E6C}.Template|Win32.Build.0 = Template|Win32 25 | EndGlobalSection 26 | GlobalSection(SolutionProperties) = preSolution 27 | HideSolutionNode = FALSE 28 | EndGlobalSection 29 | EndGlobal 30 | -------------------------------------------------------------------------------- /rtlsdr/rtl-sdr_export.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl-sdr, turns your Realtek RTL2832 based DVB dongle into a SDR receiver 3 | * Copyright (C) 2012 by Hoernchen 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef RTLSDR_EXPORT_H 20 | #define RTLSDR_EXPORT_H 21 | 22 | #if defined __GNUC__ 23 | # if __GNUC__ >= 4 24 | # define __SDR_EXPORT __attribute__((visibility("default"))) 25 | # define __SDR_IMPORT __attribute__((visibility("default"))) 26 | # else 27 | # define __SDR_EXPORT 28 | # define __SDR_IMPORT 29 | # endif 30 | #elif _MSC_VER 31 | # define __SDR_EXPORT __declspec(dllexport) 32 | # define __SDR_IMPORT __declspec(dllimport) 33 | #else 34 | # define __SDR_EXPORT 35 | # define __SDR_IMPORT 36 | #endif 37 | 38 | #ifndef rtlsdr_STATIC 39 | # ifdef rtlsdr_EXPORTS 40 | # define RTLSDR_API __SDR_EXPORT 41 | # else 42 | # define RTLSDR_API __SDR_IMPORT 43 | # endif 44 | #else 45 | #define RTLSDR_API 46 | #endif 47 | #endif /* RTLSDR_EXPORT_H */ 48 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # When building a package or installing otherwise in the system, make 3 | # sure that the variable PREFIX is defined, e.g. make PREFIX=/usr/local 4 | # 5 | PROGNAME=dump1090 6 | 7 | ifndef DUMP1090_VERSION 8 | DUMP1090_VERSION=$(shell git describe --tags) 9 | endif 10 | 11 | ifdef PREFIX 12 | BINDIR=$(PREFIX)/bin 13 | SHAREDIR=$(PREFIX)/share/$(PROGNAME) 14 | EXTRACFLAGS=-DHTMLPATH=\"$(SHAREDIR)\" 15 | endif 16 | 17 | CPPFLAGS+=-DMODES_DUMP1090_VERSION=\"$(DUMP1090_VERSION)\" 18 | CFLAGS+=-O2 -g -Wall -Werror -W 19 | LIBS=-lpthread -lm -lrt 20 | LIBS_RTL=`pkg-config --libs librtlsdr` 21 | CC=gcc 22 | 23 | all: dump1090 view1090 24 | 25 | %.o: %.c *.h 26 | $(CC) $(CPPFLAGS) $(CFLAGS) $(EXTRACFLAGS) -c $< -o $@ 27 | 28 | dump1090.o: CFLAGS += `pkg-config --cflags librtlsdr` 29 | 30 | dump1090: dump1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o crc.o demod_2000.o demod_2400.o stats.o cpr.o icao_filter.o track.o util.o convert.o 31 | $(CC) -g -o $@ $^ $(LIBS) $(LIBS_RTL) $(LDFLAGS) 32 | 33 | view1090: view1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o crc.o stats.o cpr.o icao_filter.o track.o util.o 34 | $(CC) -g -o $@ $^ $(LIBS) $(LDFLAGS) 35 | 36 | faup1090: faup1090.o anet.o mode_ac.o mode_s.o net_io.o crc.o stats.o cpr.o icao_filter.o track.o util.o 37 | $(CC) -g -o $@ $^ $(LIBS) $(LDFLAGS) 38 | 39 | clean: 40 | rm -f *.o dump1090 view1090 faup1090 cprtests crctests 41 | 42 | test: cprtests 43 | ./cprtests 44 | 45 | cprtests: cpr.o cprtests.o 46 | $(CC) $(CPPFLAGS) $(CFLAGS) $(EXTRACFLAGS) -g -o $@ $^ -lm 47 | 48 | crctests: crc.c crc.h 49 | $(CC) $(CPPFLAGS) $(CFLAGS) $(EXTRACFLAGS) -g -DCRCDEBUG -o $@ $< 50 | -------------------------------------------------------------------------------- /cpr.h: -------------------------------------------------------------------------------- 1 | // Part of dump1090, a Mode S message decoder for RTLSDR devices. 2 | // 3 | // cpr.h - Compact Position Reporting prototypes 4 | // 5 | // Copyright (c) 2014,2015 Oliver Jowett 6 | // 7 | // This file is free software: you may copy, redistribute and/or modify it 8 | // under the terms of the GNU General Public License as published by the 9 | // Free Software Foundation, either version 2 of the License, or (at your 10 | // option) any later version. 11 | // 12 | // This file is distributed in the hope that it will be useful, but 13 | // WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | // General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program. If not, see . 19 | 20 | #ifndef DUMP1090_CPR_H 21 | #define DUMP1090_CPR_H 22 | 23 | int decodeCPRairborne(int even_cprlat, int even_cprlon, 24 | int odd_cprlat, int odd_cprlon, 25 | int fflag, 26 | double *out_lat, double *out_lon); 27 | 28 | int decodeCPRsurface(double reflat, double reflon, 29 | int even_cprlat, int even_cprlon, 30 | int odd_cprlat, int odd_cprlon, 31 | int fflag, 32 | double *out_lat, double *out_lon); 33 | 34 | int decodeCPRrelative(double reflat, double reflon, 35 | int cprlat, int cprlon, 36 | int fflag, int surface, 37 | double *out_lat, double *out_lon); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /inttypes/LICENSE.inttypes: -------------------------------------------------------------------------------- 1 | // ISO C9x compliant inttypes.h for Microsoft Visual Studio 2 | // Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 3 | // 4 | // Copyright (c) 2006 Alexander Chemeris 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // 1. Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // 2. Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // 16 | // 3. The name of the author may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 20 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /convert.h: -------------------------------------------------------------------------------- 1 | // Part of dump1090, a Mode S message decoder for RTLSDR devices. 2 | // 3 | // convert.h: support for various IQ -> magnitude conversions 4 | // 5 | // Copyright (c) 2015 Oliver Jowett 6 | // 7 | // This file is free software: you may copy, redistribute and/or modify it 8 | // under the terms of the GNU General Public License as published by the 9 | // Free Software Foundation, either version 2 of the License, or (at your 10 | // option) any later version. 11 | // 12 | // This file is distributed in the hope that it will be useful, but 13 | // WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | // General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program. If not, see . 19 | 20 | #ifndef DUMP1090_CONVERT_H 21 | #define DUMP1090_CONVERT_H 22 | 23 | struct converter_state; 24 | typedef enum { INPUT_UC8=0, INPUT_SC16, INPUT_SC16Q11 } input_format_t; 25 | 26 | typedef void (*iq_convert_fn)(void *iq_data, 27 | uint16_t *mag_data, 28 | unsigned nsamples, 29 | struct converter_state *state, 30 | double *out_power); 31 | 32 | iq_convert_fn init_converter(input_format_t format, 33 | double sample_rate, 34 | int filter_dc, 35 | int compute_power, 36 | struct converter_state **out_state); 37 | 38 | void cleanup_converter(struct converter_state *state); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /public_html/style.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | margin: 0; padding: 0; background-color: #ffffff; font-family: Tahoma, Sans-Serif; 3 | font-size: 10pt; overflow: auto; height: 100%; 4 | } 5 | div#map_container { float: left; width: 100%; height: 100%; } 6 | div#map_canvas { height: 100%; margin-right: 420px; } 7 | 8 | div#sidebar_container { float: left; width: 410px; margin-left: -410px; height: 100%; overflow: auto; } 9 | 10 | div#SpecialSquawkWarning { position: absolute; bottom: 25px; right: 430px; border: 2px solid red; 11 | background-color: #FFFFA3; opacity: 0.75; filter:alpha(opacity=75); padding: 5px; 12 | text-align: center; } 13 | 14 | div#update_error { position: absolute; bottom: 25px; left: 25px; border: 2px solid red; 15 | background-color: #FFFFA3; opacity: 0.75; filter:alpha(opacity=75); padding: 5px; 16 | text-align: center; } 17 | 18 | div#loader { z-index: 99; position: absolute; left: 0; top: 0; bottom: 0; right: 0; background: #000; opacity: 0.8; filter: alpha(opacity=80); } 19 | #spinny { width: 128px; height: 128px; position: absolute; top: 50%; left: 50%; margin: -64px 0 0 -64px; } 20 | #loader_progress { width: 250px; height: 20px; position: absolute; top: 50%; left: 50%; margin: 128px 0 0 -125px; } 21 | 22 | #tableinfo, #sudo_buttons { font-size: x-small; font-family: monospace; } 23 | 24 | .vPosition { font-weight: bold; background-color: #d5ffd5; } 25 | .mlat { font-weight: bold; background-color: #d5d5ff; } 26 | .squawk7500 { font-weight: bold; background-color: #ff5555; } 27 | .squawk7600 { font-weight: bold; background-color: #00ffff; } 28 | .squawk7700 { font-weight: bold; background-color: #ffff00; } 29 | .selected { background-color: #dddddd; } 30 | .plane_table_row { cursor: pointer; } 31 | .hidden { display: none; } 32 | 33 | .infoblock_heading { font-size: larger; } 34 | .infoblock_heading a { text-decoration: none; color: blue; font-size: x-small;} 35 | .infoblock_body { font-size: small; } 36 | 37 | #selected_icao { font-size: x-small; } 38 | #selected_registration { font-size: x-small; } 39 | #selected_icaotype { font-size: x-small; } 40 | 41 | .dim { opacity: 0.3; filter:alpha(opacity=30); /* For IE8 and earlier */ } 42 | 43 | .pointer { cursor: pointer; } 44 | 45 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This version of dump1090 is licensed under the GPL, v3 or later. 2 | 3 | Please see the individual source files and the file COPYING 4 | for full copyright and license details. 5 | 6 | If you need to use dump1090 in a way that is incompatible with 7 | the GPL, please contact the author 8 | to discuss your requirements. 9 | 10 | The source code incorporates worh that was released under the GPL, v2 11 | or later license by Oliver Jowett , please see: 12 | https://github.com/mutability/dump1090 . 13 | The license has been converted to GPL, v3 in order 14 | to include linking to libraries licensed under the Apache License 2.0. 15 | 16 | The source code incorporates work that was released under a 17 | BSD-style license, reproduced below. For unmodified versions 18 | of the original work that may be used under the terms of that 19 | license, please see https://github.com/antirez/dump1090 and 20 | https://github.com/MalcolmRobb/dump1090. 21 | 22 | // Copyright (C) 2012 by Salvatore Sanfilippo 23 | // 24 | // All rights reserved. 25 | // 26 | // Redistribution and use in source and binary forms, with or without 27 | // modification, are permitted provided that the following conditions are 28 | // met: 29 | // 30 | // * Redistributions of source code must retain the above copyright 31 | // notice, this list of conditions and the following disclaimer. 32 | // 33 | // * Redistributions in binary form must reproduce the above copyright 34 | // notice, this list of conditions and the following disclaimer in the 35 | // documentation and/or other materials provided with the distribution. 36 | // 37 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 38 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 39 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 40 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 41 | // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 42 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 43 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 44 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 45 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 46 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 47 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 48 | -------------------------------------------------------------------------------- /anet.h: -------------------------------------------------------------------------------- 1 | /* anet.c -- Basic TCP socket stuff made a bit less boring 2 | * 3 | * Copyright (c) 2006-2012, Salvatore Sanfilippo 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * * Neither the name of Redis nor the names of its contributors may be used 15 | * to endorse or promote products derived from this software without 16 | * specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | * POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef ANET_H 32 | #define ANET_H 33 | 34 | #define ANET_OK 0 35 | #define ANET_ERR -1 36 | #define ANET_ERR_LEN 256 37 | 38 | #if defined(__sun) 39 | #define AF_LOCAL AF_UNIX 40 | #endif 41 | 42 | int anetTcpConnect(char *err, char *addr, int port); 43 | int anetTcpNonBlockConnect(char *err, char *addr, int port); 44 | int anetUnixConnect(char *err, char *path); 45 | int anetUnixNonBlockConnect(char *err, char *path); 46 | int anetRead(int fd, char *buf, int count); 47 | int anetResolve(char *err, char *host, char *ipbuf); 48 | int anetTcpServer(char *err, int port, char *bindaddr); 49 | int anetUnixServer(char *err, char *path, mode_t perm); 50 | int anetTcpAccept(char *err, int serversock, char *ip, int *port); 51 | int anetUnixAccept(char *err, int serversock); 52 | int anetWrite(int fd, char *buf, int count); 53 | int anetNonBlock(char *err, int fd); 54 | int anetTcpNoDelay(char *err, int fd); 55 | int anetTcpKeepAlive(char *err, int fd); 56 | int anetPeerToString(int fd, char *ip, int *port); 57 | int anetSetSendBuffer(char *err, int fd, int buffsize); 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /winposixclock/winposixclock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Travis Painter 3 | * Copyright (c) 2011, Dongsheng Song 4 | * 5 | * Licensed to the Apache Software Foundation (ASF) under one or more 6 | * contributor license agreements. See the NOTICE file distributed with 7 | * this work for additional information regarding copyright ownership. 8 | * The ASF licenses this file to You under the Apache License, Version 2.0 9 | * (the "License"); you may not use this file except in compliance with 10 | * the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | #ifndef _WINPOSIXCLOCK_H_ 22 | #define _WINPOSIXCLOCK_H_ 1 23 | 24 | /** 25 | * @file winposixclock.h 26 | * @brief POSIX Time Routines 27 | */ 28 | 29 | /** 30 | * @defgroup clock POSIX Time Routines 31 | * @{ 32 | */ 33 | 34 | #include 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /* We have POSIX timers. */ 41 | #ifndef _POSIX_TIMERS 42 | #define _POSIX_TIMERS 200809L 43 | #endif 44 | 45 | /* The monotonic clock might be available. */ 46 | #ifndef _POSIX_MONOTONIC_CLOCK 47 | #define _POSIX_MONOTONIC_CLOCK 0 48 | #endif 49 | 50 | /* The CPU-time clocks are available. */ 51 | #ifndef _POSIX_CPUTIME 52 | #define _POSIX_CPUTIME 200809L 53 | #endif 54 | 55 | /* The Clock support in threads are available. */ 56 | #ifndef _POSIX_THREAD_CPUTIME 57 | #define _POSIX_THREAD_CPUTIME 200809L 58 | #endif 59 | 60 | #ifndef TIMER_ABSTIME 61 | #define TIMER_ABSTIME 1 62 | #endif 63 | 64 | #ifndef CLOCK_REALTIME 65 | #define CLOCK_REALTIME 0 66 | #endif 67 | 68 | #ifndef CLOCK_MONOTONIC 69 | #define CLOCK_MONOTONIC 1 70 | #endif 71 | 72 | #ifndef CLOCK_PROCESS_CPUTIME_ID 73 | #define CLOCK_PROCESS_CPUTIME_ID 2 74 | #endif 75 | 76 | #ifndef CLOCK_THREAD_CPUTIME_ID 77 | #define CLOCK_THREAD_CPUTIME_ID 3 78 | #endif 79 | 80 | int nanosleep(const struct timespec *request, struct timespec *remain); 81 | 82 | int clock_getres(clockid_t clock_id, struct timespec *res); 83 | int clock_gettime(clockid_t clock_id, struct timespec *tp); 84 | int clock_settime(clockid_t clock_id, const struct timespec *tp); 85 | int clock_nanosleep(clockid_t clock_id, int flags, 86 | const struct timespec *request, 87 | struct timespec *remain); 88 | 89 | #ifdef __cplusplus 90 | } 91 | #endif 92 | 93 | /** @} */ 94 | 95 | #endif /* _WINPOSIXCLOCK_H_ */ 96 | -------------------------------------------------------------------------------- /tools/update-aircraft-database.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script checks for a new version of BasicAircraftLookup from 4 | # the VRS website and, if one is available, downloads it and updates 5 | # the dump1090 webmap json files. 6 | 7 | set -e 8 | 9 | # defaults that can be overridden: 10 | VRS_URL=${VRS_URL:-http://www.virtualradarserver.co.uk/Files/BasicAircraftLookup.sqb.gz} 11 | CACHEDIR=${CACHEDIR:-/var/cache/dump1090-mutability} 12 | JSONDIR=${JSONDIR:-$CACHEDIR/db} 13 | SQBDIR=${SQBDIR:-$CACHEDIR/sqb} 14 | LOGFILE=${LOGFILE:-/var/log/dump1090-mutability.log} 15 | UPDATESCRIPT=${UPDATESCRIPT:-/usr/share/dump1090-mutability/vrs-basicaircraft-to-json.py} 16 | 17 | if [ -f /etc/default/dump1090-mutability ] 18 | then 19 | . /etc/default/dump1090-mutability 20 | fi 21 | 22 | ETAGFILE=$SQBDIR/BasicAircraftLookup.sqb.etag 23 | SQBFILE=$SQBDIR/BasicAircraftLookup.sqb 24 | 25 | CHECKMODIFIED=true 26 | LOGTOFILE=false 27 | while [ "$#" -gt 0 ] 28 | do 29 | case "$1" in 30 | -f|--force) CHECKMODIFIED=false ;; 31 | -l|--log-to-file) LOGTOFILE=true ;; 32 | *) echo "unrecognized option: $1" >&2; exit 1 ;; 33 | esac 34 | shift 35 | done 36 | 37 | if $LOGTOFILE; then exec >>$LOGFILE 2>&1; fi 38 | 39 | log() { 40 | date "+%c $*" >&2 41 | } 42 | 43 | mkdir -p $CACHEDIR $JSONDIR $SQBDIR 44 | rm -f $ETAGFILE.new $SQBFILE.new 45 | 46 | log "Checking VRS server for an updated database.." 47 | 48 | # get ETag 49 | curl --silent --fail --include --head $VRS_URL | grep ETag >$ETAGFILE.new 50 | 51 | # check for existing file 52 | RETRIEVE=true 53 | ARGS="" 54 | if $CHECKMODIFIED && [ -f $SQBFILE ] 55 | then 56 | if [ -s $ETAGFILE -a -s $ETAGFILE.new ] 57 | then 58 | if cmp -s $ETAGFILE $ETAGFILE.new 59 | then 60 | log "Database not modified." 61 | RETRIEVE=false 62 | else 63 | log "Database modified, will retrieve a new copy." 64 | fi 65 | else 66 | # do an if-modified-since 67 | log "Database possibly modified, will try to retrieve a new copy." 68 | ARGS="-z $SQBFILE" 69 | fi 70 | fi 71 | 72 | if $RETRIEVE 73 | then 74 | log "Retrieving database.." 75 | curl --silent --fail --remote-time --retry 2 $ARGS -o $SQBFILE.new $VRS_URL 76 | mv $ETAGFILE.new $ETAGFILE 77 | if [ -f $SQBFILE.new ] 78 | then 79 | log "Decompressing database.." 80 | zcat $SQBFILE.new >$SQBFILE 81 | touch -r $SQBFILE.new $SQBFILE 82 | rm $SQBFILE.new 83 | else 84 | log "Database not modified." 85 | fi 86 | fi 87 | 88 | UPDATE=true 89 | if $CHECKMODIFIED 90 | then 91 | if test -f $JSONDIR/last_update; then 92 | if ! test $SQBFILE -nt $JSONDIR/last_update; then UPDATE=false; fi 93 | fi 94 | fi 95 | 96 | if $UPDATE 97 | then 98 | log "Updating JSON files from database.." 99 | mkdir -p $JSONDIR/new 100 | $UPDATESCRIPT $SQBFILE $JSONDIR/new 101 | rm -f $JSONDIR/*.json 102 | mv $JSONDIR/new/*.json $JSONDIR/ 103 | touch -r $SQBFILE $JSONDIR/last_update 104 | rmdir $JSONDIR/new 105 | log "Done." 106 | else 107 | log "No update to JSON files needed." 108 | fi 109 | 110 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: dump1090 3 | Upstream-Contact: Oliver Jowett 4 | Source: https://github.com/mutability/dump1090 5 | 6 | Files: * 7 | Copyright: Copyright 2012 Salvatore Sanfilippo 8 | Copyright 2013,2014 Malcolm Robb 9 | Copyright 2014,2015 Oliver Jowett 10 | License: BSD-3-Clause and GPL-2+ 11 | 12 | Files: cprtests.c cpr.h crc.c crc.h demod_2000.h demod_2400.c demod_2000.h icao_filter.c icao_filter.h demod_2400.h demod_2000.h crc.h 13 | Copyright: Copyright 2014,2015 Oliver Jowett 14 | License: GPL-2+ 15 | 16 | Files: debian/* 17 | Copyright: 2014,2015 Oliver Jowett 18 | License: BSD-3-Clause 19 | 20 | License: GPL-2+ 21 | This program is free software; you can redistribute it 22 | and/or modify it under the terms of the GNU General Public 23 | License as published by the Free Software Foundation; either 24 | version 2 of the License, or (at your option) any later 25 | version. 26 | . 27 | This program is distributed in the hope that it will be 28 | useful, but WITHOUT ANY WARRANTY; without even the implied 29 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 30 | PURPOSE. See the GNU General Public License for more 31 | details. 32 | . 33 | You should have received a copy of the GNU General Public 34 | License along with this package; if not, write to the Free 35 | Software Foundation, Inc., 51 Franklin St, Fifth Floor, 36 | Boston, MA 02110-1301 USA 37 | . 38 | On Debian systems, the full text of the GNU General Public 39 | License version 2 can be found in the file 40 | `/usr/share/common-licenses/GPL-2'. 41 | 42 | License: BSD-3-Clause 43 | Redistribution and use in source and binary forms, with or without 44 | modification, are permitted provided that the following conditions 45 | are met: 46 | 1. Redistributions of source code must retain the above copyright 47 | notice, this list of conditions and the following disclaimer. 48 | 2. Redistributions in binary form must reproduce the above copyright 49 | notice, this list of conditions and the following disclaimer in the 50 | documentation and/or other materials provided with the distribution. 51 | 3. Neither the name of the University nor the names of its contributors 52 | may be used to endorse or promote products derived from this software 53 | without specific prior written permission. 54 | . 55 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 56 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 57 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 58 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE HOLDERS OR 59 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 60 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 61 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 62 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 63 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 64 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 65 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 66 | -------------------------------------------------------------------------------- /net_io.h: -------------------------------------------------------------------------------- 1 | // Part of dump1090, a Mode S message decoder for RTLSDR devices. 2 | // 3 | // net_io.h: network handling. 4 | // 5 | // Copyright (c) 2014,2015 Oliver Jowett 6 | // 7 | // This file is free software: you may copy, redistribute and/or modify it 8 | // under the terms of the GNU General Public License as published by the 9 | // Free Software Foundation, either version 2 of the License, or (at your 10 | // option) any later version. 11 | // 12 | // This file is distributed in the hope that it will be useful, but 13 | // WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | // General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program. If not, see . 19 | 20 | #ifndef DUMP1090_NETIO_H 21 | #define DUMP1090_NETIO_H 22 | 23 | // Describes a networking service (group of connections) 24 | 25 | struct modesMessage; 26 | struct client; 27 | struct net_service; 28 | typedef int (*read_fn)(struct client *, char *); 29 | typedef void (*heartbeat_fn)(struct net_service *); 30 | 31 | // Describes one network service (a group of clients with common behaviour) 32 | struct net_service { 33 | struct net_service* next; 34 | const char *descr; 35 | int listen_fd; 36 | 37 | int connections; // number of active clients 38 | 39 | struct net_writer *writer; // shared writer state 40 | 41 | const char *read_sep; // hander details for input data 42 | read_fn read_handler; 43 | }; 44 | 45 | // Structure used to describe a networking client 46 | struct client { 47 | struct client* next; // Pointer to next client 48 | int fd; // File descriptor 49 | struct net_service *service; // Service this client is part of 50 | int buflen; // Amount of data on buffer 51 | char buf[MODES_CLIENT_BUF_SIZE+1]; // Read buffer 52 | }; 53 | 54 | // Common writer state for all output sockets of one type 55 | struct net_writer { 56 | struct net_service *service; // owning service 57 | void *data; // shared write buffer, sized MODES_OUT_BUF_SIZE 58 | int dataUsed; // number of bytes of write buffer currently used 59 | uint64_t lastWrite; // time of last write to clients 60 | heartbeat_fn send_heartbeat; // function that queues a heartbeat if needed 61 | }; 62 | 63 | struct net_service *serviceInit(const char *descr, struct net_writer *writer, heartbeat_fn hb_handler, const char *sep, read_fn read_handler); 64 | struct client *serviceConnect(struct net_service *service, char *addr, int port); 65 | void serviceListen(struct net_service *service, char *bind_addr, int bind_port); 66 | struct client *createSocketClient(struct net_service *service, int fd); 67 | struct client *createGenericClient(struct net_service *service, int fd); 68 | 69 | // view1090 / faup1090 want to create these themselves: 70 | struct net_service *makeBeastInputService(void); 71 | struct net_service *makeFatsvOutputService(void); 72 | 73 | void modesInitNet(void); 74 | void modesQueueOutput(struct modesMessage *mm); 75 | void modesNetPeriodicWork(void); 76 | 77 | // TODO: move these somewhere else 78 | char *generateAircraftJson(const char *url_path, int *len); 79 | char *generateStatsJson(const char *url_path, int *len); 80 | char *generateReceiverJson(const char *url_path, int *len); 81 | char *generateHistoryJson(const char *url_path, int *len); 82 | void writeJsonToFile(const char *file, char * (*generator) (const char *,int*)); 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /tools/vrs-basicaircraft-to-json.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | # 4 | # Converts a Virtual Radar Server BasicAircraftLookup.sqb database 5 | # into a bunch of json files suitable for use by the webmap 6 | # 7 | 8 | import sqlite3, json, sys 9 | from contextlib import closing 10 | 11 | def extract(dbfile, todir, blocklimit, debug): 12 | ac_count = 0 13 | block_count = 0 14 | 15 | blocks = {} 16 | for i in xrange(16): 17 | blocks['%01X' % i] = {} 18 | 19 | print >>sys.stderr, 'Reading', dbfile 20 | with closing(sqlite3.connect(dbfile)) as db: 21 | with closing(db.execute('SELECT a.Icao, a.Registration, m.Icao FROM Aircraft a, Model m WHERE a.ModelID = m.ModelID')) as c: 22 | for icao24, reg, icaotype in c: 23 | bkey = icao24[0:1].upper() 24 | dkey = icao24[1:].upper() 25 | blocks[bkey][dkey] = {} 26 | if reg: blocks[bkey][dkey]['r'] = reg 27 | if icaotype: blocks[bkey][dkey]['t'] = icaotype 28 | ac_count += 1 29 | print >>sys.stderr, 'Read', ac_count, 'aircraft' 30 | 31 | print >>sys.stderr, 'Writing blocks:', 32 | 33 | queue = sorted(blocks.keys()) 34 | while queue: 35 | bkey = queue[0] 36 | del queue[0] 37 | 38 | blockdata = blocks[bkey] 39 | if len(blockdata) > blocklimit: 40 | if debug: print >>sys.stderr, 'Splitting block', bkey, 'with', len(blockdata), 'entries..', 41 | 42 | # split all children out 43 | children = {} 44 | for dkey in blockdata.keys(): 45 | new_bkey = bkey + dkey[0] 46 | new_dkey = dkey[1:] 47 | 48 | if new_bkey not in children: children[new_bkey] = {} 49 | children[new_bkey][new_dkey] = blockdata[dkey] 50 | 51 | # look for small children we can retain in the parent, to 52 | # reduce the total number of files needed. This reduces the 53 | # number of blocks needed from 150 to 61 54 | blockdata = {} 55 | children = sorted(children.items(), key=lambda x: len(x[1])) 56 | retained = 1 57 | 58 | while len(children[0][1]) + retained < blocklimit: 59 | # move this child back to the parent 60 | c_bkey, c_entries = children[0] 61 | for c_dkey, entry in c_entries.items(): 62 | blockdata[c_bkey[-1] + c_dkey] = entry 63 | retained += 1 64 | del children[0] 65 | 66 | if debug: print >>sys.stderr, len(children), 'children created,', len(blockdata), 'entries retained in parent' 67 | children = sorted(children, key=lambda x: x[0]) 68 | blockdata['children'] = [x[0] for x in children] 69 | blocks[bkey] = blockdata 70 | for c_bkey, c_entries in children: 71 | blocks[c_bkey] = c_entries 72 | queue.append(c_bkey) 73 | 74 | path = todir + '/' + bkey + '.json' 75 | if debug: print >>sys.stderr, 'Writing', len(blockdata), 'entries to', path 76 | else: print >>sys.stderr, bkey, 77 | block_count += 1 78 | with closing(open(path, 'w')) as f: 79 | json.dump(obj=blockdata, fp=f, check_circular=False, separators=(',',':'), sort_keys=True) 80 | 81 | print >>sys.stderr, 'done.' 82 | print >>sys.stderr, 'Wrote', block_count, 'blocks' 83 | 84 | if __name__ == '__main__': 85 | if len(sys.argv) < 3: 86 | print >>sys.stderr, 'Syntax: %s ' % sys.argv[0] 87 | sys.exit(1) 88 | else: 89 | extract(sys.argv[1], sys.argv[2], 1000, False) 90 | sys.exit(0) 91 | -------------------------------------------------------------------------------- /debian/config-template: -------------------------------------------------------------------------------- 1 | ## TEMPLATE FILE - This is used to create /etc/default/dump1090-mutability ## 2 | ## The first three lines will be discarded ## 3 | 4 | # dump1090-mutability configuration file 5 | # This is a POSIX shell fragment. 6 | # You can edit this file directly, or use 7 | # "dpkg-reconfigure dump1090-mutability" 8 | 9 | # Set to "yes" to start dump1090 on boot. 10 | START_DUMP1090= 11 | 12 | # User to run dump1090 as. 13 | DUMP1090_USER= 14 | 15 | # Logfile to log to 16 | LOGFILE= 17 | 18 | # 19 | # Receiver options 20 | # 21 | 22 | # RTLSDR device index or serial number to use 23 | # If set to "none", dump1090 will be started in --net-only mode 24 | DEVICE= 25 | 26 | # RTLSDR gain in dB. 27 | # If set to "max" (the default) the maximum supported gain is used. 28 | # If set to "agc", the tuner AGC is used to set the gain. 29 | GAIN= 30 | 31 | # RTLSDR frequency correction in PPM 32 | PPM= 33 | 34 | # If yes, enable sampling at 2.4MHz. Otherwise, 2.0MHz is used. 35 | OVERSAMPLE= 36 | 37 | # If yes, enables phase-enhancement of messages 38 | PHASE_ENHANCE= 39 | 40 | # 41 | # Decoding options 42 | # 43 | 44 | # If yes, fixes messages with correctable CRC errors. 45 | FIX_CRC= 46 | 47 | # If yes, enables aggressive fixes to damaged messages. 48 | # Use with caution - it can increase the rate of undetected errors. 49 | AGGRESSIVE= 50 | 51 | # If set, supplies a reference location for local position decoding. 52 | LAT= 53 | LON= 54 | 55 | # If set, provides the absolute maximum receiver range used to 56 | # filter bad position reports, and to determine when local position 57 | # decoding is safe to use. Specify this in nautical miles (NM). 58 | MAX_RANGE= 59 | 60 | # 61 | # Networking options 62 | # 63 | 64 | # Port to listen on for HTTP connections. 0 disables. 65 | # HTTP defaults to being disabled unless you specify something here. I 66 | # that you do not enable this, and instead serve the contents of 67 | # /usr/share/dump1090-mutability and JSON_DIR (below) using a proper 68 | # webserver. See /etc/lighttpd/conf-available/90-dump1090.conf 69 | # for an example configuration ("sudo lighty-enable-mod dump1090" to enable) 70 | HTTP_PORT= 71 | 72 | # Port to listen on for raw (AVR-format) input connections. 0 disables. 73 | RAW_INPUT_PORT= 74 | 75 | # Port to listen on for raw (AVR-format) output connections. 0 disables. 76 | RAW_OUTPUT_PORT= 77 | 78 | # Port to listen on for SBS-format output connections. 0 disables. 79 | SBS_OUTPUT_PORT= 80 | 81 | # Port to listen on for Beast-format input connections. 0 disables. 82 | BEAST_INPUT_PORT= 83 | 84 | # Port to listen on for Beast-format output connections. 0 disables. 85 | BEAST_OUTPUT_PORT= 86 | 87 | # Port to listen on for FATSV-format output connections. 0 disables. 88 | FATSV_OUTPUT_PORT= 89 | 90 | # TCP heartbeat interval in seconds. 0 disables. 91 | NET_HEARTBEAT= 92 | 93 | # Minimum output buffer size per write, in bytes. 94 | NET_OUTPUT_SIZE= 95 | 96 | # Maximum buffering time before writing, in seconds. 97 | NET_OUTPUT_INTERVAL= 98 | 99 | # TCP buffer size, in bytes 100 | NET_BUFFER= 101 | 102 | # Bind ports on a particular address. If unset, binds to all interfaces. 103 | # This defaults to binding to localhost. If you need to allow remote 104 | # connections, change this. 105 | NET_BIND_ADDRESS= 106 | 107 | # 108 | # Misc options 109 | # 110 | 111 | # Interval (in seconds) between logging stats to the logfile. 0 disables. 112 | STATS_INTERVAL= 113 | 114 | # Path to write json state to (for use with an external webserver). Blank disables. 115 | JSON_DIR= 116 | 117 | # Interval between writing json state (in seconds). 0 disables. 118 | JSON_INTERVAL= 119 | 120 | # Accuracy of receiver location to write to json state, one of "exact" / "approximate" / "none" 121 | JSON_LOCATION_ACCURACY= 122 | 123 | # Set to yes to log all decoded messages 124 | # This can get large fast! 125 | LOG_DECODED_MESSAGES= 126 | 127 | # Additional options that are passed to the Daemon. 128 | EXTRA_ARGS= 129 | -------------------------------------------------------------------------------- /view1090.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {43954c28-05c5-41c5-b280-97b15026b343} 6 | cpp;c;cxx;rc;def;r;odl;idl;hpj;bat 7 | 8 | 9 | {074f09a7-d535-4c92-a34a-b9a3b79b7c60} 10 | h;hpp;hxx;hm;inl 11 | 12 | 13 | {ec3f3c0f-f2da-4a9f-b057-e627176b4902} 14 | 15 | 16 | {7ba00c0a-2177-4d22-b8f3-574ca94a637d} 17 | ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe 18 | 19 | 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | Source Files 53 | 54 | 55 | Source Files 56 | 57 | 58 | 59 | 60 | Header Files 61 | 62 | 63 | Header Files 64 | 65 | 66 | Header Files 67 | 68 | 69 | Header Files 70 | 71 | 72 | Header Files 73 | 74 | 75 | Header Files 76 | 77 | 78 | Header Files 79 | 80 | 81 | Header Files 82 | 83 | 84 | Header Files 85 | 86 | 87 | Header Files 88 | 89 | 90 | Header Files 91 | 92 | 93 | Header Files 94 | 95 | 96 | Header Files 97 | 98 | 99 | Header Files 100 | 101 | 102 | 103 | 104 | Library Files 105 | 106 | 107 | Library Files 108 | 109 | 110 | Library Files 111 | 112 | 113 | -------------------------------------------------------------------------------- /public_html/config.js: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------- 2 | // 3 | // This file is to configure the configurable settings. 4 | // Load this file before script.js file at gmap.html. 5 | // 6 | // -------------------------------------------------------- 7 | 8 | // -- Title Settings -------------------------------------- 9 | // Show number of aircraft and/or messages per second in the page title 10 | PlaneCountInTitle = true; 11 | MessageRateInTitle = false; 12 | 13 | // -- Output Settings ------------------------------------- 14 | // Show metric values 15 | // The Metric setting controls whether metric (m, km, km/h) or 16 | // imperial (ft, NM, knots) units are used in the plane table 17 | // and in the detailed plane info. If ShowOtherUnits is true, 18 | // then the other unit will also be shown in the detailed plane 19 | // info. 20 | Metric = false; 21 | ShowOtherUnits = true; 22 | 23 | // -- Map settings ---------------------------------------- 24 | // These settings are overridden by any position information 25 | // provided by dump1090 itself. All positions are in decimal 26 | // degrees. 27 | 28 | // Default center of the map. 29 | DefaultCenterLat = 45.0; 30 | DefaultCenterLon = 9.0; 31 | // The google maps zoom level, 0 - 16, lower is further out 32 | DefaultZoomLvl = 7; 33 | 34 | // Center marker. If dump1090 provides a receiver location, 35 | // that location is used and these settings are ignored. 36 | 37 | SiteShow = false; // true to show a center marker 38 | SiteLat = 45.0; // position of the marker 39 | SiteLon = 9.0; 40 | SiteName = "My Radar Site"; // tooltip of the marker 41 | 42 | 43 | // -- Marker settings ------------------------------------- 44 | 45 | // These settings control the coloring of aircraft by altitude. 46 | // All color values are given as Hue (0-359) / Saturation (0-100) / Lightness (0-100) 47 | ColorByAlt = { 48 | // HSL for planes with unknown altitude: 49 | unknown : { h: 0, s: 0, l: 40 }, 50 | 51 | // HSL for planes that are on the ground: 52 | ground : { h: 120, s: 100, l: 30 }, 53 | 54 | air : { 55 | // These define altitude-to-hue mappings 56 | // at particular altitudes; the hue 57 | // for intermediate altitudes that lie 58 | // between the provided altitudes is linearly 59 | // interpolated. 60 | // 61 | // Mappings must be provided in increasing 62 | // order of altitude. 63 | // 64 | // Altitudes below the first entry use the 65 | // hue of the first entry; altitudes above 66 | // the last entry use the hue of the last 67 | // entry. 68 | h: [ { alt: 2000, val: 20 }, // orange 69 | { alt: 10000, val: 140 }, // light green 70 | { alt: 40000, val: 300 } ], // magenta 71 | s: 85, 72 | l: 50, 73 | }, 74 | 75 | // Changes added to the color of the currently selected plane 76 | selected : { h: 0, s: -10, l: +20 }, 77 | 78 | // Changes added to the color of planes that have stale position info 79 | stale : { h: 0, s: -10, l: +30 } 80 | }; 81 | 82 | // For a monochrome display try this: 83 | // ColorByAlt = { 84 | // unknown : { h: 0, s: 0, l: 40 }, 85 | // ground : { h: 0, s: 0, l: 30 }, 86 | // air : { h: [ { alt: 0, val: 0 } ], s: 0, l: 50 }, 87 | // selected : { h: 0, s: 0, l: +30 }, 88 | // stale : { h: 0, s: 0, l: +30 } 89 | // }; 90 | 91 | 92 | SiteCircles = true; // true to show circles (only shown if the center marker is shown) 93 | // In nautical miles or km (depending settings value 'Metric') 94 | SiteCirclesDistances = new Array(100,150,200); 95 | 96 | // Show the clocks at the top of the righthand pane? You can disable the clocks if you want here 97 | ShowClocks = true; 98 | 99 | // Controls page title, righthand pane when nothing is selected 100 | PageName = "DUMP1090"; 101 | -------------------------------------------------------------------------------- /mode_ac.c: -------------------------------------------------------------------------------- 1 | // dump1090, a Mode S messages decoder for RTLSDR devices. 2 | // 3 | // Copyright (C) 2012 by Salvatore Sanfilippo 4 | // 5 | // All rights reserved. 6 | // 7 | // Redistribution and use in source and binary forms, with or without 8 | // modification, are permitted provided that the following conditions are 9 | // met: 10 | // 11 | // * Redistributions of source code must retain the above copyright 12 | // notice, this list of conditions and the following disclaimer. 13 | // 14 | // * Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #include "dump1090.h" 32 | // 33 | //========================================================================= 34 | // 35 | // Input format is : 00:A4:A2:A1:00:B4:B2:B1:00:C4:C2:C1:00:D4:D2:D1 36 | // 37 | int ModeAToModeC(unsigned int ModeA) 38 | { 39 | unsigned int FiveHundreds = 0; 40 | unsigned int OneHundreds = 0; 41 | 42 | if ( (ModeA & 0xFFFF888B) // D1 set is illegal. D2 set is > 62700ft which is unlikely 43 | || ((ModeA & 0x000000F0) == 0) ) // C1,,C4 cannot be Zero 44 | {return -9999;} 45 | 46 | if (ModeA & 0x0010) {OneHundreds ^= 0x007;} // C1 47 | if (ModeA & 0x0020) {OneHundreds ^= 0x003;} // C2 48 | if (ModeA & 0x0040) {OneHundreds ^= 0x001;} // C4 49 | 50 | // Remove 7s from OneHundreds (Make 7->5, snd 5->7). 51 | if ((OneHundreds & 5) == 5) {OneHundreds ^= 2;} 52 | 53 | // Check for invalid codes, only 1 to 5 are valid 54 | if (OneHundreds > 5) 55 | {return -9999;} 56 | 57 | //if (ModeA & 0x0001) {FiveHundreds ^= 0x1FF;} // D1 never used for altitude 58 | if (ModeA & 0x0002) {FiveHundreds ^= 0x0FF;} // D2 59 | if (ModeA & 0x0004) {FiveHundreds ^= 0x07F;} // D4 60 | 61 | if (ModeA & 0x1000) {FiveHundreds ^= 0x03F;} // A1 62 | if (ModeA & 0x2000) {FiveHundreds ^= 0x01F;} // A2 63 | if (ModeA & 0x4000) {FiveHundreds ^= 0x00F;} // A4 64 | 65 | if (ModeA & 0x0100) {FiveHundreds ^= 0x007;} // B1 66 | if (ModeA & 0x0200) {FiveHundreds ^= 0x003;} // B2 67 | if (ModeA & 0x0400) {FiveHundreds ^= 0x001;} // B4 68 | 69 | // Correct order of OneHundreds. 70 | if (FiveHundreds & 1) {OneHundreds = 6 - OneHundreds;} 71 | 72 | return ((FiveHundreds * 5) + OneHundreds - 13); 73 | } 74 | // 75 | //========================================================================= 76 | // 77 | void decodeModeAMessage(struct modesMessage *mm, int ModeA) 78 | { 79 | mm->msgtype = 32; // Valid Mode S DF's are DF-00 to DF-31. 80 | // so use 32 to indicate Mode A/C 81 | 82 | mm->msgbits = 16; // Fudge up a Mode S style data stream 83 | mm->msg[0] = (ModeA >> 8); 84 | mm->msg[1] = (ModeA); 85 | 86 | // Fudge an address based on Mode A (remove the Ident bit) 87 | mm->addr = (ModeA & 0x0000FF7F) | MODES_NON_ICAO_ADDRESS; 88 | 89 | // Set the Identity field to ModeA 90 | mm->modeA = ModeA & 0x7777; 91 | mm->bFlags |= MODES_ACFLAGS_SQUAWK_VALID; 92 | 93 | // Flag ident in flight status 94 | mm->fs = ModeA & 0x0080; 95 | 96 | // Not much else we can tell from a Mode A/C reply. 97 | // Just fudge up a few bits to keep other code happy 98 | mm->correctedbits = 0; 99 | } 100 | // 101 | // ===================== Mode A/C detection and decoding =================== 102 | // 103 | -------------------------------------------------------------------------------- /public_html/formatter.js: -------------------------------------------------------------------------------- 1 | // -*- mode: javascript; indent-tabs-mode: t; c-basic-offset: 8 -*- 2 | "use strict"; 3 | 4 | var NBSP='\u00a0'; 5 | var DEGREES='\u00b0' 6 | var UP_TRIANGLE='\u25b2'; // U+25B2 BLACK UP-POINTING TRIANGLE 7 | var DOWN_TRIANGLE='\u25bc'; // U+25BC BLACK DOWN-POINTING TRIANGLE 8 | 9 | var TrackDirections = ["North","Northeast","East","Southeast","South","Southwest","West","Northwest"]; 10 | 11 | // formatting helpers 12 | 13 | // track in degrees (0..359) 14 | function format_track_brief(track) { 15 | if (track === null){ 16 | return ""; 17 | } 18 | 19 | return Math.round(track); 20 | } 21 | 22 | // track in degrees (0..359) 23 | function format_track_long(track) { 24 | if (track === null){ 25 | return "n/a"; 26 | } 27 | 28 | var trackDir = Math.floor((360 + track % 360 + 22.5) / 45) % 8; 29 | return Math.round(track) + DEGREES + NBSP + "(" + TrackDirections[trackDir] + ")"; 30 | } 31 | 32 | // altitude (input: alt in feet) 33 | // brief will always show either Metric or Imperial 34 | function format_altitude_brief(alt, vr) { 35 | var alt_text; 36 | 37 | if (alt === null){ 38 | return ""; 39 | } else if (alt === "ground"){ 40 | return "ground"; 41 | } 42 | 43 | if (Metric) { 44 | alt_text = Math.round(alt / 3.2828) + NBSP; // Altitude to meters 45 | } else { 46 | alt_text = Math.round(alt) + NBSP; 47 | } 48 | 49 | // Vertical Rate Triangle 50 | if (vr > 128){ 51 | return alt_text + UP_TRIANGLE; 52 | } else if (vr < -128){ 53 | return alt_text + DOWN_TRIANGLE; 54 | } else { 55 | return alt_text + NBSP; 56 | } 57 | } 58 | 59 | // alt in ft 60 | function _alt_to_unit(alt, m) { 61 | if (m) 62 | return Math.round(alt / 3.2828) + NBSP + "m"; 63 | else 64 | return Math.round(alt) + NBSP + "ft"; 65 | } 66 | 67 | function format_altitude_long(alt, vr) { 68 | var alt_text = ""; 69 | 70 | if (alt === null) { 71 | return "n/a"; 72 | } else if (alt === "ground") { 73 | return "on ground"; 74 | } 75 | 76 | // Primary unit 77 | alt_text = _alt_to_unit(alt, Metric); 78 | 79 | // Secondary unit 80 | if (ShowOtherUnits) { 81 | alt_text = alt_text + ' | ' + _alt_to_unit(alt, !Metric); 82 | } 83 | 84 | if (vr > 128) { 85 | return UP_TRIANGLE + NBSP + alt_text; 86 | } else if (vr < -128) { 87 | return DOWN_TRIANGLE + NBSP + alt_text; 88 | } else { 89 | return alt_text; 90 | } 91 | } 92 | 93 | //input: speed in kts 94 | function format_speed_brief(speed) { 95 | if (speed === null) { 96 | return ""; 97 | } 98 | 99 | if (Metric) { 100 | return Math.round(speed * 1.852); // knots to kilometers per hour 101 | } else { 102 | return Math.round(speed); // knots 103 | } 104 | } 105 | 106 | // speed in kts 107 | 108 | function _speed_to_unit(speed, m) { 109 | if (m) 110 | return Math.round(speed * 1.852) + NBSP + "km/h"; 111 | else 112 | return Math.round(speed) + NBSP + "kt"; 113 | } 114 | 115 | function format_speed_long(speed) { 116 | if (speed === null) { 117 | return "n/a"; 118 | } 119 | 120 | // Primary unit 121 | var speed_text = _speed_to_unit(speed, Metric); 122 | 123 | // Secondary unit 124 | if (ShowOtherUnits) { 125 | speed_text = speed_text + ' | ' + _speed_to_unit(speed, !Metric); 126 | } 127 | 128 | return speed_text; 129 | } 130 | 131 | // dist in meters 132 | function format_distance_brief(dist) { 133 | if (dist === null) { 134 | return ""; 135 | } 136 | 137 | if (Metric) { 138 | return (dist/1000).toFixed(1); // meters to kilometers 139 | } else { 140 | return (dist/1852).toFixed(1); // meters to nautocal miles 141 | } 142 | } 143 | 144 | // dist in metres 145 | 146 | function _dist_to_unit(dist, m) { 147 | if (m) 148 | return (dist/1000).toFixed(1) + NBSP + "km"; 149 | else 150 | return (dist/1852).toFixed(1) + NBSP + "NM"; 151 | } 152 | 153 | function format_distance_long(dist) { 154 | if (dist === null) { 155 | return "n/a"; 156 | } 157 | 158 | // Primary unit 159 | var dist_text = _dist_to_unit(dist, Metric); 160 | 161 | // Secondary unit 162 | if (ShowOtherUnits) { 163 | dist_text = dist_text + ' | ' + _dist_to_unit(dist, !Metric); 164 | } 165 | 166 | return dist_text; 167 | } 168 | 169 | // p as a LatLng 170 | function format_latlng(p) { 171 | return p.lat().toFixed(3) + DEGREES + "," + NBSP + p.lng().toFixed(3) + DEGREES; 172 | } 173 | -------------------------------------------------------------------------------- /winposixclock/winposixclock_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Travis Painter 3 | * Copyright (c) 2011, Dongsheng Song 4 | * 5 | * Licensed to the Apache Software Foundation (ASF) under one or more 6 | * contributor license agreements. See the NOTICE file distributed with 7 | * this work for additional information regarding copyright ownership. 8 | * The ASF licenses this file to You under the Apache License, Version 2.0 9 | * (the "License"); you may not use this file except in compliance with 10 | * the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | #ifndef _WINPOSIXCLOCK_TYPES_H_ 22 | #define _WINPOSIXCLOCK_H_ 1 23 | 24 | /** 25 | * @file winposixclock_types.h 26 | * @brief POSIX Thread Support Definitions 27 | */ 28 | 29 | /** 30 | * @defgroup thread_def POSIX Thread Support Definitions 31 | * @ingroup libpthread 32 | * @{ 33 | */ 34 | 35 | #include /* Adding definition of EINVAL, ETIMEDOUT, ..., etc. */ 36 | #include /* Adding O_CREAT definition. */ 37 | #include /* Adding INT_MAX, UINT_MAX definition.*/ 38 | #include /* Adding intptr_t, uintptr_t definition.*/ 39 | #include /* Adding time_t definition. */ 40 | #include /* Adding pid_t, mode_t definition. */ 41 | 42 | #ifndef _MSC_VER 43 | #include 44 | #include 45 | #else 46 | #if _MSC_VER >= 1600 47 | #include 48 | #else 49 | /* stdint.h */ 50 | typedef signed char int8_t; 51 | typedef short int16_t; 52 | typedef int int32_t; 53 | 54 | typedef unsigned char uint8_t; 55 | typedef unsigned short uint16_t; 56 | typedef unsigned int uint32_t; 57 | 58 | #define INT8_MAX 0x7f 59 | #define UINT8_MAX 0xff 60 | #define INT16_MAX 0x7fff 61 | #define UINT16_MAX 0xffff 62 | #define INT32_MAX 0x7fffffff 63 | #define UINT32_MAX 0xffffffff 64 | #define INT64_MAX 0x7fffffffffffffff 65 | #define UINT64_MAX 0xffffffffffffffffU 66 | /* 67 | #define INT64_C(c) c ## I64 68 | #define UINT64_C(c) c ## UI64 69 | */ 70 | #define INT64_C(x) ((x) + (INT64_MAX - INT64_MAX)) 71 | #define UINT64_C(x) ((x) + (UINT64_MAX - UINT64_MAX)) 72 | #endif /* _MSC_VER >= 1600 */ 73 | 74 | /* inttypes.h */ 75 | #define PRId64 "I64d" 76 | #define PRIu64 "I64u" 77 | #define PRIx64 "I64x" 78 | #define PRIX64 "I64X" 79 | #endif /* _MSC_VER */ 80 | 81 | #ifndef _PID_T_ 82 | typedef intptr_t pid_t; 83 | #define _PID_T_ 1 84 | #endif 85 | 86 | #ifndef _MODE_T_ 87 | typedef unsigned short _mode_t; 88 | #define _MODE_T_ 1 89 | 90 | #ifndef NO_OLDNAMES 91 | typedef _mode_t mode_t; 92 | #endif 93 | #endif /* _MODE_T_ */ 94 | 95 | #ifndef ENOTSUP 96 | #define ENOTSUP 129 /* This is the value in VC 2010. */ 97 | #endif 98 | 99 | #ifndef ETIMEDOUT 100 | #define ETIMEDOUT 138 /* This is the value in VC 2010. */ 101 | #endif 102 | 103 | /** @} */ 104 | 105 | /** 106 | * @defgroup clock POSIX Time Routines 107 | * @{ 108 | */ 109 | 110 | #ifndef __clockid_t_defined 111 | typedef int clockid_t; 112 | #define __clockid_t_defined 1 113 | #endif /* __clockid_t_defined */ 114 | 115 | #ifndef _TIMESPEC_DEFINED 116 | struct timespec { 117 | time_t tv_sec; /* Seconds */ 118 | long tv_nsec; /* Nanoseconds */ 119 | }; 120 | 121 | struct itimerspec { 122 | struct timespec it_interval; /* Timer period */ 123 | struct timespec it_value; /* Timer expiration */ 124 | }; 125 | #define _TIMESPEC_DEFINED 1 126 | #endif /* _TIMESPEC_DEFINED */ 127 | 128 | /** @} */ 129 | 130 | #endif /* _WINPOSIXCLOCK_H_ */ 131 | -------------------------------------------------------------------------------- /public_html/dbloader.js: -------------------------------------------------------------------------------- 1 | // -*- mode: javascript; indent-tabs-mode: nil; c-basic-offset: 8 -*- 2 | 3 | // Part of dump1090, a Mode S message decoder for RTLSDR devices. 4 | // 5 | // dbloader.js: load aircraft metadata from static json files 6 | // 7 | // Copyright (c) 2014,2015 Oliver Jowett 8 | // 9 | // This file is free software: you may copy, redistribute and/or modify it 10 | // under the terms of the GNU General Public License as published by the 11 | // Free Software Foundation, either version 2 of the License, or (at your 12 | // option) any later version. 13 | // 14 | // This file is distributed in the hope that it will be useful, but 15 | // WITHOUT ANY WARRANTY; without even the implied warranty of 16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | // General Public License for more details. 18 | // 19 | // You should have received a copy of the GNU General Public License 20 | // along with this program. If not, see . 21 | 22 | "use strict"; 23 | 24 | var _aircraft_cache = {}; 25 | 26 | function getAircraftData(icao) { 27 | var defer; 28 | 29 | icao = icao.toUpperCase(); 30 | 31 | if (icao in _aircraft_cache) { 32 | defer = _aircraft_cache[icao]; 33 | } else { 34 | // load from blocks: 35 | defer = _aircraft_cache[icao] = $.Deferred(); 36 | request_from_db(icao, 1, defer); 37 | } 38 | 39 | return defer; 40 | } 41 | 42 | function request_from_db(icao, level, defer) { 43 | var bkey = icao.substring(0, level); 44 | var dkey = icao.substring(level); 45 | var req = db_ajax(bkey); 46 | 47 | req.done(function(data) { 48 | var subkey; 49 | 50 | if (dkey in data) { 51 | defer.resolve(data[dkey]); 52 | return; 53 | } 54 | 55 | if ("children" in data) { 56 | subkey = bkey + dkey.substring(0,1); 57 | if (data.children.indexOf(subkey) != -1) { 58 | request_from_db(icao, level+1, defer); 59 | return; 60 | } 61 | } 62 | defer.reject(); 63 | }); 64 | 65 | req.fail(function(jqXHR,textStatus,errorThrown) { 66 | defer.reject(); 67 | }); 68 | } 69 | 70 | var _request_count = 0; 71 | var _request_queue = []; 72 | var _request_cache = {}; 73 | 74 | var MAX_REQUESTS = 2; 75 | 76 | function db_ajax(bkey) { 77 | var defer; 78 | 79 | if (bkey in _request_cache) { 80 | return _request_cache[bkey]; 81 | } 82 | 83 | if (_request_count < MAX_REQUESTS) { 84 | // just do ajax directly 85 | ++_request_count; 86 | defer = _request_cache[bkey] = $.ajax({ url: 'db/' + bkey + '.json', 87 | cache: true, 88 | timeout: 5000, 89 | dataType : 'json' }); 90 | defer.always(db_ajax_request_complete); 91 | } else { 92 | // put it in the queue 93 | defer = _request_cache[bkey] = $.Deferred(); 94 | defer.bkey = bkey; 95 | _request_queue.push(defer); 96 | } 97 | 98 | return defer; 99 | } 100 | 101 | function db_ajax_request_complete() { 102 | var req; 103 | var ajaxreq; 104 | 105 | if (_request_queue.length == 0) { 106 | --_request_count; 107 | } else { 108 | req = _request_queue.shift(); 109 | ajaxreq = $.ajax({ url: 'db/' + req.bkey + '.json', 110 | cache: true, 111 | timeout: 5000, 112 | dataType : 'json' }); 113 | ajaxreq.done(function(data) { req.resolve(data); }); 114 | ajaxreq.fail(function(jqxhr, status, error) { req.reject(jqxhr, status, error); }); 115 | ajaxreq.always(db_ajax_request_complete); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /util.c: -------------------------------------------------------------------------------- 1 | // Part of dump1090, a Mode S message decoder for RTLSDR devices. 2 | // 3 | // util.c: misc utilities 4 | // 5 | // Copyright (C) 2015 Travis Painter 6 | // 7 | // This program is free software: you can redistribute it and/or modify 8 | // it under the terms of the GNU General Public License as published by 9 | // the Free Software Foundation, either version 3 of the License, or 10 | // (at your option) any later version. 11 | // 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program. If not, see . 19 | // 20 | // This file incorporates work covered by the following copyright and 21 | // permission notices: 22 | // 23 | // Copyright (c) 2015 Oliver Jowett 24 | // 25 | // This file is free software: you may copy, redistribute and/or modify it 26 | // under the terms of the GNU General Public License as published by the 27 | // Free Software Foundation, either version 2 of the License, or (at your 28 | // option) any later version. 29 | // 30 | // This file is distributed in the hope that it will be useful, but 31 | // WITHOUT ANY WARRANTY; without even the implied warranty of 32 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 33 | // General Public License for more details. 34 | // 35 | // You should have received a copy of the GNU General Public License 36 | // along with this program. If not, see . 37 | 38 | // This file incorporates work covered by the following copyright and 39 | // permission notice: 40 | // 41 | // Copyright (C) 2012 by Salvatore Sanfilippo 42 | // 43 | // All rights reserved. 44 | // 45 | // Redistribution and use in source and binary forms, with or without 46 | // modification, are permitted provided that the following conditions are 47 | // met: 48 | // 49 | // * Redistributions of source code must retain the above copyright 50 | // notice, this list of conditions and the following disclaimer. 51 | // 52 | // * Redistributions in binary form must reproduce the above copyright 53 | // notice, this list of conditions and the following disclaimer in the 54 | // documentation and/or other materials provided with the distribution. 55 | // 56 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 57 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 58 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 59 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 60 | // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 61 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 62 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 63 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 64 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 65 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 66 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 67 | 68 | #include "util.h" 69 | 70 | #include 71 | #include "dump1090.h" 72 | #ifndef _WIN32 73 | #include 74 | #endif 75 | 76 | uint64_t mstime(void) 77 | { 78 | struct timeval tv; 79 | uint64_t mst; 80 | 81 | gettimeofday(&tv, NULL); 82 | mst = ((uint64_t)tv.tv_sec)*1000; 83 | mst += tv.tv_usec/1000; 84 | return mst; 85 | } 86 | 87 | int64_t receiveclock_ns_elapsed(uint64_t t1, uint64_t t2) 88 | { 89 | return (t2 - t1) * 1000U / 12U; 90 | } 91 | 92 | void normalize_timespec(struct timespec *ts) 93 | { 94 | if (ts->tv_nsec > 1000000000) { 95 | ts->tv_sec += ts->tv_nsec / 1000000000; 96 | ts->tv_nsec = ts->tv_nsec % 1000000000; 97 | } else if (ts->tv_nsec < 0) { 98 | long adjust = ts->tv_nsec / 1000000000 + 1; 99 | ts->tv_sec -= adjust; 100 | ts->tv_nsec = (ts->tv_nsec + 1000000000 * adjust) % 1000000000; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /stats.h: -------------------------------------------------------------------------------- 1 | // Part of dump1090, a Mode S message decoder for RTLSDR devices. 2 | // 3 | // stats.c: statistics structures and prototypes. 4 | // 5 | // Copyright (c) 2015 Oliver Jowett 6 | // 7 | // This file is free software: you may copy, redistribute and/or modify it 8 | // under the terms of the GNU General Public License as published by the 9 | // Free Software Foundation, either version 2 of the License, or (at your 10 | // option) any later version. 11 | // 12 | // This file is distributed in the hope that it will be useful, but 13 | // WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | // General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program. If not, see . 19 | 20 | // This file incorporates work covered by the following copyright and 21 | // permission notice: 22 | // 23 | // Copyright (C) 2012 by Salvatore Sanfilippo 24 | // 25 | // All rights reserved. 26 | // 27 | // Redistribution and use in source and binary forms, with or without 28 | // modification, are permitted provided that the following conditions are 29 | // met: 30 | // 31 | // * Redistributions of source code must retain the above copyright 32 | // notice, this list of conditions and the following disclaimer. 33 | // 34 | // * Redistributions in binary form must reproduce the above copyright 35 | // notice, this list of conditions and the following disclaimer in the 36 | // documentation and/or other materials provided with the distribution. 37 | // 38 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 39 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 40 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 41 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 42 | // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 43 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 44 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 45 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 46 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 47 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 48 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 49 | 50 | #ifndef DUMP1090_STATS_H 51 | #define DUMP1090_STATS_H 52 | 53 | struct stats { 54 | uint64_t start; 55 | uint64_t end; 56 | 57 | // Mode S demodulator counts: 58 | uint32_t demod_preambles; 59 | uint32_t demod_rejected_bad; 60 | uint32_t demod_rejected_unknown_icao; 61 | uint32_t demod_accepted[MODES_MAX_BITERRORS+1]; 62 | 63 | // Mode A/C demodulator counts: 64 | uint32_t demod_modeac; 65 | 66 | uint64_t samples_processed; 67 | uint64_t samples_dropped; 68 | 69 | // timing: 70 | struct timespec demod_cpu; 71 | struct timespec reader_cpu; 72 | struct timespec background_cpu; 73 | 74 | // noise floor: 75 | double noise_power_sum; 76 | uint64_t noise_power_count; 77 | 78 | // mean signal power: 79 | double signal_power_sum; 80 | uint64_t signal_power_count; 81 | 82 | // peak signal power seen 83 | double peak_signal_power; 84 | 85 | // number of signals with power > -3dBFS 86 | uint32_t strong_signal_count; 87 | 88 | // remote messages: 89 | uint32_t remote_received_modeac; 90 | uint32_t remote_received_modes; 91 | uint32_t remote_rejected_bad; 92 | uint32_t remote_rejected_unknown_icao; 93 | uint32_t remote_accepted[MODES_MAX_BITERRORS+1]; 94 | 95 | // total messages: 96 | uint32_t messages_total; 97 | 98 | // network: 99 | uint32_t http_requests; 100 | 101 | // CPR decoding: 102 | unsigned int cpr_surface; 103 | unsigned int cpr_airborne; 104 | unsigned int cpr_global_ok; 105 | unsigned int cpr_global_bad; 106 | unsigned int cpr_global_skipped; 107 | unsigned int cpr_global_range_checks; 108 | unsigned int cpr_global_speed_checks; 109 | unsigned int cpr_local_ok; 110 | unsigned int cpr_local_skipped; 111 | unsigned int cpr_local_range_checks; 112 | unsigned int cpr_local_speed_checks; 113 | unsigned int cpr_local_aircraft_relative; 114 | unsigned int cpr_local_receiver_relative; 115 | unsigned int cpr_filtered; 116 | 117 | // number of altitude messages ignored because 118 | // we had a recent DF17/18 altitude 119 | unsigned int suppressed_altitude_messages; 120 | 121 | // aircraft: 122 | // total "new" aircraft (i.e. not seen in the last 30 or 300s) 123 | unsigned int unique_aircraft; 124 | // we saw only a single message 125 | unsigned int single_message_aircraft; 126 | 127 | // range histogram 128 | #define RANGE_BUCKET_COUNT 76 129 | uint32_t range_histogram[RANGE_BUCKET_COUNT]; 130 | }; 131 | 132 | void add_stats(const struct stats *st1, const struct stats *st2, struct stats *target); 133 | void display_stats(struct stats *st); 134 | void reset_stats(struct stats *st); 135 | 136 | void add_timespecs(const struct timespec *x, const struct timespec *y, struct timespec *z); 137 | 138 | #endif 139 | -------------------------------------------------------------------------------- /debian/dump1090-mutability.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # postinst script for dump1090 3 | # 4 | # see: dh_installdeb(1) 5 | 6 | set -e 7 | 8 | # summary of how this script can be called: 9 | # * `configure' 10 | # * `abort-upgrade' 11 | # * `abort-remove' `in-favour' 12 | # 13 | # * `abort-remove' 14 | # * `abort-deconfigure' `in-favour' 15 | # `removing' 16 | # 17 | # for details, see http://www.debian.org/doc/debian-policy/ or 18 | # the debian-policy package 19 | 20 | NAME=dump1090-mutability 21 | CONFIGFILE=/etc/default/$NAME 22 | TEMPLATECONFIG=/usr/share/$NAME/config-template 23 | CRONFILE=/etc/cron.d/$NAME 24 | TEMPLATECRON=/usr/share/$NAME/cron-template 25 | SEDSCRIPT=$CONFIGFILE.sed.tmp 26 | 27 | subvar_raw() { 28 | # $1 = db var value 29 | # $2 = config var name 30 | 31 | # if not present in the config file, add it 32 | test -z "$1" || grep -Eq "^ *$2=" $CONFIGFILE || echo "$2=" >> $CONFIGFILE 33 | # add to the sedscript 34 | echo "s@^ *$2=.*@$2=\"$1\"@" >>$SEDSCRIPT 35 | } 36 | 37 | subvar() { 38 | # $1 = db var name 39 | # $2 = config var name 40 | db_get $NAME/$1 41 | subvar_raw "$RET" "$2" 42 | } 43 | 44 | subvar_yn() { 45 | # $1 = db var name 46 | # $2 = config var name 47 | db_get $NAME/$1 48 | if [ "$RET" = "true" ]; then subvar_raw "yes" "$2"; else subvar_raw "no" "$2"; fi 49 | } 50 | 51 | case "$1" in 52 | configure) 53 | . /usr/share/debconf/confmodule 54 | 55 | # Generate config file, if it doesn't exist. 56 | if [ ! -e $CONFIGFILE ]; then 57 | tail -n +4 $TEMPLATECONFIG >$CONFIGFILE 58 | fi 59 | 60 | rm -f $SEDSCRIPT 61 | 62 | subvar_yn auto-start START_DUMP1090 63 | subvar run-as-user DUMP1090_USER 64 | subvar log-file LOGFILE 65 | subvar rtlsdr-device DEVICE 66 | subvar rtlsdr-gain GAIN 67 | subvar rtlsdr-ppm PPM 68 | subvar_yn rtlsdr-oversample OVERSAMPLE 69 | subvar_yn decode-fixcrc FIX_CRC 70 | subvar_yn decode-phase-enhance PHASE_ENHANCE 71 | subvar_yn decode-aggressive AGGRESSIVE 72 | subvar decode-lat LAT 73 | subvar decode-lon LON 74 | subvar decode-max-range MAX_RANGE 75 | subvar net-http-port HTTP_PORT 76 | subvar net-ri-port RAW_INPUT_PORT 77 | subvar net-ro-port RAW_OUTPUT_PORT 78 | subvar net-bi-port BEAST_INPUT_PORT 79 | subvar net-bo-port BEAST_OUTPUT_PORT 80 | subvar net-sbs-port SBS_OUTPUT_PORT 81 | subvar net-fatsv-port FATSV_OUTPUT_PORT 82 | subvar net-heartbeat NET_HEARTBEAT 83 | subvar net-out-size NET_OUTPUT_SIZE 84 | subvar net-out-interval NET_OUTPUT_INTERVAL 85 | subvar net-buffer NET_BUFFER 86 | subvar net-bind-address NET_BIND_ADDRESS 87 | subvar stats-interval STATS_INTERVAL 88 | subvar json-dir JSON_DIR 89 | subvar json-interval JSON_INTERVAL 90 | subvar json-location-accuracy JSON_LOCATION_ACCURACY 91 | subvar_yn log-decoded-messages LOG_DECODED_MESSAGES 92 | subvar extra-args EXTRA_ARGS 93 | 94 | cp -a -f $CONFIGFILE $CONFIGFILE.tmp 95 | sed -f $SEDSCRIPT < $CONFIGFILE > $CONFIGFILE.tmp 96 | mv -f $CONFIGFILE.tmp $CONFIGFILE 97 | rm $SEDSCRIPT 98 | 99 | db_get $NAME/run-as-user 100 | RUNAS="$RET" 101 | if ! getent passwd "$RUNAS" >/dev/null 102 | then 103 | adduser --system --home /usr/share/$NAME --no-create-home --quiet "$RUNAS" 104 | fi 105 | 106 | # create log if missing; change ownership if needed so the cronjob works 107 | db_get $NAME/log-file 108 | touch $RET 109 | chown $RUNAS $RET 110 | 111 | # create cronjob 112 | if ! test -e $CRONFILE; then 113 | echo "Creating cronjob in $CRONFILE to periodically update the aircraft database.." >&2 114 | MIN=$(($RANDOM % 60)) 115 | tail -n +4 $TEMPLATECRON | sed -e "s/@USER@/$RUNAS/g" -e "s/@MIN@/$MIN/g" >$CRONFILE 116 | fi 117 | 118 | # update the DB 119 | echo "Updating aircraft database now.." 120 | mkdir -m 0755 -p /var/cache/$NAME 121 | chown $RUNAS /var/cache/$NAME 122 | su $RUNAS -s /bin/bash -c /usr/share/$NAME/update-aircraft-database.sh || \ 123 | echo "Aircraft database update failed. It will be retried periodically from cron." >&2 124 | 125 | # config file changed between 1.14 and 1.15 126 | if [ -e /etc/lighttpd/conf-enabled/89-dump1090.conf ]; then 127 | if dpkg --compare-versions "$2" le "1.14"; then 128 | echo "Restarting lighttpd.." >&2 129 | service lighttpd restart || echo "Warning: lighttpd failed to restart." >&2 130 | fi 131 | fi 132 | ;; 133 | 134 | abort-upgrade|abort-remove|abort-deconfigure) 135 | ;; 136 | 137 | *) 138 | echo "postinst called with unknown argument \`$1'" >&2 139 | exit 1 140 | ;; 141 | esac 142 | 143 | # dh_installdeb will replace this with shell code automatically 144 | # generated by other debhelper scripts. 145 | 146 | #DEBHELPER# 147 | 148 | if [ "$1" = "configure" ]; then db_stop; fi 149 | exit 0 150 | -------------------------------------------------------------------------------- /dump1090.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {f1dd9786-e82c-48b5-9328-bbd595057e9f} 6 | cpp;c;cxx;rc;def;r;odl;idl;hpj;bat 7 | 8 | 9 | {dc0285b2-b848-4684-bb82-b11a7cac75c9} 10 | h;hpp;hxx;hm;inl 11 | 12 | 13 | {4f62f1d8-d950-4e2e-990f-437ff1c970a8} 14 | ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe 15 | 16 | 17 | {b1ef7848-7ea8-454e-8a90-d65a89aa2717} 18 | 19 | 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | Source Files 53 | 54 | 55 | Source Files 56 | 57 | 58 | Source Files 59 | 60 | 61 | Source Files 62 | 63 | 64 | Source Files 65 | 66 | 67 | 68 | 69 | Header Files 70 | 71 | 72 | Header Files 73 | 74 | 75 | Header Files 76 | 77 | 78 | Header Files 79 | 80 | 81 | Header Files 82 | 83 | 84 | Header Files 85 | 86 | 87 | Header Files 88 | 89 | 90 | Header Files 91 | 92 | 93 | Header Files 94 | 95 | 96 | Header Files 97 | 98 | 99 | Header Files 100 | 101 | 102 | Header Files 103 | 104 | 105 | Header Files 106 | 107 | 108 | Header Files 109 | 110 | 111 | Header Files 112 | 113 | 114 | Header Files 115 | 116 | 117 | Header Files 118 | 119 | 120 | Header Files 121 | 122 | 123 | Header Files 124 | 125 | 126 | Header Files 127 | 128 | 129 | Header Files 130 | 131 | 132 | Header Files 133 | 134 | 135 | 136 | 137 | Resource Files 138 | 139 | 140 | 141 | 142 | Library Files 143 | 144 | 145 | Library Files 146 | 147 | 148 | Library Files 149 | 150 | 151 | Library Files 152 | 153 | 154 | 155 | 156 | Library Files 157 | 158 | 159 | -------------------------------------------------------------------------------- /pthread/sched.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Module: sched.h 3 | * 4 | * Purpose: 5 | * Provides an implementation of POSIX realtime extensions 6 | * as defined in 7 | * 8 | * POSIX 1003.1b-1993 (POSIX.1b) 9 | * 10 | * -------------------------------------------------------------------------- 11 | * 12 | * Pthreads-win32 - POSIX Threads Library for Win32 13 | * Copyright(C) 1998 John E. Bossom 14 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 15 | * 16 | * Contact Email: rpj@callisto.canberra.edu.au 17 | * 18 | * The current list of contributors is contained 19 | * in the file CONTRIBUTORS included with the source 20 | * code distribution. The list can also be seen at the 21 | * following World Wide Web location: 22 | * http://sources.redhat.com/pthreads-win32/contributors.html 23 | * 24 | * This library is free software; you can redistribute it and/or 25 | * modify it under the terms of the GNU Lesser General Public 26 | * License as published by the Free Software Foundation; either 27 | * version 2 of the License, or (at your option) any later version. 28 | * 29 | * This library is distributed in the hope that it will be useful, 30 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 31 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 32 | * Lesser General Public License for more details. 33 | * 34 | * You should have received a copy of the GNU Lesser General Public 35 | * License along with this library in the file COPYING.LIB; 36 | * if not, write to the Free Software Foundation, Inc., 37 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 38 | */ 39 | #if !defined(_SCHED_H) 40 | #define _SCHED_H 41 | 42 | #undef PTW32_SCHED_LEVEL 43 | 44 | #if defined(_POSIX_SOURCE) 45 | #define PTW32_SCHED_LEVEL 0 46 | /* Early POSIX */ 47 | #endif 48 | 49 | #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309 50 | #undef PTW32_SCHED_LEVEL 51 | #define PTW32_SCHED_LEVEL 1 52 | /* Include 1b, 1c and 1d */ 53 | #endif 54 | 55 | #if defined(INCLUDE_NP) 56 | #undef PTW32_SCHED_LEVEL 57 | #define PTW32_SCHED_LEVEL 2 58 | /* Include Non-Portable extensions */ 59 | #endif 60 | 61 | #define PTW32_SCHED_LEVEL_MAX 3 62 | 63 | #if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 ) || !defined(PTW32_SCHED_LEVEL) 64 | #define PTW32_SCHED_LEVEL PTW32_SCHED_LEVEL_MAX 65 | /* Include everything */ 66 | #endif 67 | 68 | 69 | #if defined(__GNUC__) && !defined(__declspec) 70 | # error Please upgrade your GNU compiler to one that supports __declspec. 71 | #endif 72 | 73 | /* 74 | * When building the library, you should define PTW32_BUILD so that 75 | * the variables/functions are exported correctly. When using the library, 76 | * do NOT define PTW32_BUILD, and then the variables/functions will 77 | * be imported correctly. 78 | */ 79 | #if !defined(PTW32_STATIC_LIB) 80 | # if defined(PTW32_BUILD) 81 | # define PTW32_DLLPORT __declspec (dllexport) 82 | # else 83 | # define PTW32_DLLPORT __declspec (dllimport) 84 | # endif 85 | #else 86 | # define PTW32_DLLPORT 87 | #endif 88 | 89 | /* 90 | * This is a duplicate of what is in the autoconf config.h, 91 | * which is only used when building the pthread-win32 libraries. 92 | */ 93 | 94 | #if !defined(PTW32_CONFIG_H) 95 | # if defined(WINCE) 96 | # define NEED_ERRNO 97 | # define NEED_SEM 98 | # endif 99 | # if defined(__MINGW64__) 100 | # define HAVE_STRUCT_TIMESPEC 101 | # define HAVE_MODE_T 102 | # elif defined(_UWIN) || defined(__MINGW32__) 103 | # define HAVE_MODE_T 104 | # endif 105 | #endif 106 | 107 | /* 108 | * 109 | */ 110 | 111 | #if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX 112 | #if defined(NEED_ERRNO) 113 | #include "need_errno.h" 114 | #else 115 | #include 116 | #endif 117 | #endif /* PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX */ 118 | 119 | #if (defined(__MINGW64__) || defined(__MINGW32__)) || defined(_UWIN) 120 | # if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX 121 | /* For pid_t */ 122 | # include 123 | /* Required by Unix 98 */ 124 | # include 125 | # else 126 | typedef int pid_t; 127 | # endif 128 | #else 129 | typedef int pid_t; 130 | #endif 131 | 132 | /* Thread scheduling policies */ 133 | 134 | enum { 135 | SCHED_OTHER = 0, 136 | SCHED_FIFO, 137 | SCHED_RR, 138 | SCHED_MIN = SCHED_OTHER, 139 | SCHED_MAX = SCHED_RR 140 | }; 141 | 142 | struct sched_param { 143 | int sched_priority; 144 | }; 145 | 146 | #if defined(__cplusplus) 147 | extern "C" 148 | { 149 | #endif /* __cplusplus */ 150 | 151 | PTW32_DLLPORT int __cdecl sched_yield (void); 152 | 153 | PTW32_DLLPORT int __cdecl sched_get_priority_min (int policy); 154 | 155 | PTW32_DLLPORT int __cdecl sched_get_priority_max (int policy); 156 | 157 | PTW32_DLLPORT int __cdecl sched_setscheduler (pid_t pid, int policy); 158 | 159 | PTW32_DLLPORT int __cdecl sched_getscheduler (pid_t pid); 160 | 161 | /* 162 | * Note that this macro returns ENOTSUP rather than 163 | * ENOSYS as might be expected. However, returning ENOSYS 164 | * should mean that sched_get_priority_{min,max} are 165 | * not implemented as well as sched_rr_get_interval. 166 | * This is not the case, since we just don't support 167 | * round-robin scheduling. Therefore I have chosen to 168 | * return the same value as sched_setscheduler when 169 | * SCHED_RR is passed to it. 170 | */ 171 | #define sched_rr_get_interval(_pid, _interval) \ 172 | ( errno = ENOTSUP, (int) -1 ) 173 | 174 | 175 | #if defined(__cplusplus) 176 | } /* End of extern "C" */ 177 | #endif /* __cplusplus */ 178 | 179 | #undef PTW32_SCHED_LEVEL 180 | #undef PTW32_SCHED_LEVEL_MAX 181 | 182 | #endif /* !_SCHED_H */ 183 | 184 | -------------------------------------------------------------------------------- /track.h: -------------------------------------------------------------------------------- 1 | // Part of dump1090, a Mode S message decoder for RTLSDR devices. 2 | // 3 | // track.h: aircraft state tracking prototypes 4 | // 5 | // Copyright (c) 2014,2015 Oliver Jowett 6 | // 7 | // This file is free software: you may copy, redistribute and/or modify it 8 | // under the terms of the GNU General Public License as published by the 9 | // Free Software Foundation, either version 2 of the License, or (at your 10 | // option) any later version. 11 | // 12 | // This file is distributed in the hope that it will be useful, but 13 | // WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | // General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program. If not, see . 19 | 20 | // This file incorporates work covered by the following copyright and 21 | // permission notice: 22 | // 23 | // Copyright (C) 2012 by Salvatore Sanfilippo 24 | // 25 | // All rights reserved. 26 | // 27 | // Redistribution and use in source and binary forms, with or without 28 | // modification, are permitted provided that the following conditions are 29 | // met: 30 | // 31 | // * Redistributions of source code must retain the above copyright 32 | // notice, this list of conditions and the following disclaimer. 33 | // 34 | // * Redistributions in binary form must reproduce the above copyright 35 | // notice, this list of conditions and the following disclaimer in the 36 | // documentation and/or other materials provided with the distribution. 37 | // 38 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 39 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 40 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 41 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 42 | // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 43 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 44 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 45 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 46 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 47 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 48 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 49 | 50 | #ifndef DUMP1090_TRACK_H 51 | #define DUMP1090_TRACK_H 52 | 53 | /* Maximum age of tracked aircraft in milliseconds */ 54 | #define TRACK_AIRCRAFT_TTL 300000 55 | 56 | /* Maximum age of a tracked aircraft with only 1 message received, in milliseconds */ 57 | #define TRACK_AIRCRAFT_ONEHIT_TTL 60000 58 | 59 | /* Maximum validity of an aircraft position */ 60 | #define TRACK_AIRCRAFT_POSITION_TTL 60000 61 | 62 | /* Structure used to describe the state of one tracked aircraft */ 63 | struct aircraft { 64 | uint32_t addr; // ICAO address 65 | char flight[16]; // Flight number 66 | double signalLevel[8]; // Last 8 Signal Amplitudes 67 | int altitude; // Altitude 68 | int speed; // Velocity 69 | int track; // Angle of flight 70 | int vert_rate; // Vertical rate. 71 | 72 | uint64_t seen; // Time (millis) at which the last packet was received 73 | uint64_t seenLatLon; // Time (millis) at which lat, lon was measured 74 | uint64_t seenAltitude; // Time (millis) at which altitude was measured 75 | uint64_t seenSpeed; // Time (millis) at which speed was measured 76 | uint64_t seenTrack; // Time (millis) at which track was measured 77 | 78 | int mlatFlags; // Data derived from mlat messages 79 | 80 | long messages; // Number of Mode S messages received 81 | int modeA; // Squawk 82 | int modeC; // Altitude 83 | long modeAcount; // Mode A Squawk hit Count 84 | long modeCcount; // Mode C Altitude hit Count 85 | int modeACflags; // Flags for mode A/C recognition 86 | 87 | int fatsv_emitted_altitude; // last FA emitted altitude 88 | int fatsv_emitted_track; // last FA emitted track 89 | int fatsv_emitted_speed; // last FA emitted speed 90 | uint64_t fatsv_last_emitted; // time (millis) aircraft was last FA emitted 91 | 92 | // Encoded latitude and longitude as extracted by odd and even CPR encoded messages 93 | uint64_t odd_cprtime; 94 | int odd_cprlat; 95 | int odd_cprlon; 96 | unsigned odd_cprnuc; 97 | 98 | uint64_t even_cprtime; 99 | int even_cprlat; 100 | int even_cprlon; 101 | unsigned even_cprnuc; 102 | 103 | double lat, lon; // Coordinated obtained from CPR encoded data 104 | unsigned pos_nuc; // NUCp of last computed position 105 | 106 | unsigned category; // Aircraft category A0 - D7 encoded as a single hex byte 107 | 108 | int bFlags; // Flags related to valid fields in this structure 109 | struct aircraft *next; // Next aircraft in our linked list 110 | 111 | struct modesMessage first_message; // A copy of the first message we received for this aircraft. 112 | }; 113 | 114 | 115 | 116 | /* Update aircraft state from data in the provided mesage. 117 | * Return the tracked aircraft. 118 | */ 119 | struct modesMessage; 120 | struct aircraft *trackUpdateFromMessage(struct modesMessage *mm); 121 | 122 | /* Call periodically */ 123 | void trackPeriodicUpdate(); 124 | 125 | #endif 126 | -------------------------------------------------------------------------------- /pthread/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | Contributors (in approximate order of appearance) 2 | 3 | [See also the ChangeLog file where individuals are 4 | attributed in log entries. Likewise in the FAQ file.] 5 | 6 | Ben Elliston bje at cygnus dot com 7 | Initiated the project; 8 | setup the project infrastructure (CVS, web page, etc.); 9 | early prototype routines. 10 | Ross Johnson Ross dot Johnson at dot homemail dot com dot au 11 | early prototype routines; 12 | ongoing project coordination/maintenance; 13 | implementation of spin locks and barriers; 14 | various enhancements; 15 | bug fixes; 16 | documentation; 17 | testsuite. 18 | Robert Colquhoun rjc at trump dot net dot au 19 | Early bug fixes. 20 | John E. Bossom John dot Bossom at cognos dot com 21 | Contributed substantial original working implementation; 22 | bug fixes; 23 | ongoing guidance and standards interpretation. 24 | Anders Norlander anorland at hem2 dot passagen dot se 25 | Early enhancements and runtime checking for supported 26 | Win32 routines. 27 | Tor Lillqvist tml at iki dot fi 28 | General enhancements; 29 | early bug fixes to condition variables. 30 | Scott Lightner scott at curriculum dot com 31 | Bug fix. 32 | Kevin Ruland Kevin dot Ruland at anheuser-busch dot com 33 | Various bug fixes. 34 | Mike Russo miker at eai dot com 35 | Bug fix. 36 | Mark E. Armstrong avail at pacbell dot net 37 | Bug fixes. 38 | Lorin Hochstein lmh at xiphos dot ca 39 | general bug fixes; bug fixes to condition variables. 40 | Peter Slacik Peter dot Slacik at tatramed dot sk 41 | Bug fixes. 42 | Mumit Khan khan at xraylith dot wisc dot edu 43 | Fixes to work with Mingw32. 44 | Milan Gardian mg at tatramed dot sk 45 | Bug fixes and reports/analyses of obscure problems. 46 | Aurelio Medina aureliom at crt dot com 47 | First implementation of read-write locks. 48 | Graham Dumpleton Graham dot Dumpleton at ra dot pad dot otc dot telstra dot com dot au 49 | Bug fix in condition variables. 50 | Tristan Savatier tristan at mpegtv dot com 51 | WinCE port. 52 | Erik Hensema erik at hensema dot xs4all dot nl 53 | Bug fixes. 54 | Rich Peters rpeters at micro-magic dot com 55 | Todd Owen towen at lucidcalm dot dropbear dot id dot au 56 | Bug fixes to dll loading. 57 | Jason Nye jnye at nbnet dot nb dot ca 58 | Implementation of async cancelation. 59 | Fred Forester fforest at eticomm dot net 60 | Kevin D. Clark kclark at cabletron dot com 61 | David Baggett dmb at itasoftware dot com 62 | Bug fixes. 63 | Paul Redondo paul at matchvision dot com 64 | Scott McCaskill scott at 3dfx dot com 65 | Bug fixes. 66 | Jef Gearhart jgearhart at tpssys dot com 67 | Bug fix. 68 | Arthur Kantor akantor at bexusa dot com 69 | Mutex enhancements. 70 | Steven Reddie smr at essemer dot com dot au 71 | Bug fix. 72 | Alexander Terekhov TEREKHOV at de dot ibm dot com 73 | Re-implemented and improved read-write locks; 74 | (with Louis Thomas) re-implemented and improved 75 | condition variables; 76 | enhancements to semaphores; 77 | enhancements to mutexes; 78 | new mutex implementation in 'futex' style; 79 | suggested a robust implementation of pthread_once 80 | similar to that implemented by V.Kliathcko; 81 | system clock change handling re CV timeouts; 82 | bug fixes. 83 | Thomas Pfaff tpfaff at gmx dot net 84 | Changes to make C version usable with C++ applications; 85 | re-implemented mutex routines to avoid Win32 mutexes 86 | and TryEnterCriticalSection; 87 | procedure to fix Mingw32 thread-safety issues. 88 | Franco Bez franco dot bez at gmx dot de 89 | procedure to fix Mingw32 thread-safety issues. 90 | Louis Thomas lthomas at arbitrade dot com 91 | (with Alexander Terekhov) re-implemented and improved 92 | condition variables. 93 | David Korn dgk at research dot att dot com 94 | Ported to UWIN. 95 | Phil Frisbie, Jr. phil at hawksoft dot com 96 | Bug fix. 97 | Ralf Brese Ralf dot Brese at pdb4 dot siemens dot de 98 | Bug fix. 99 | prionx at juno dot com prionx at juno dot com 100 | Bug fixes. 101 | Max Woodbury mtew at cds dot duke dot edu 102 | POSIX versioning conditionals; 103 | reduced namespace pollution; 104 | idea to separate routines to reduce statically 105 | linked image sizes. 106 | Rob Fanner rfanner at stonethree dot com 107 | Bug fix. 108 | Michael Johnson michaelj at maine dot rr dot com 109 | Bug fix. 110 | Nicolas Barry boozai at yahoo dot com 111 | Bug fixes. 112 | Piet van Bruggen pietvb at newbridges dot nl 113 | Bug fix. 114 | Makoto Kato raven at oldskool dot jp 115 | AMD64 port. 116 | Panagiotis E. Hadjidoukas peh at hpclab dot ceid dot upatras dot gr 117 | phadjido at cs dot uoi dot gr 118 | Contributed the QueueUserAPCEx package which 119 | makes preemptive async cancelation possible. 120 | Will Bryant will dot bryant at ecosm dot com 121 | Borland compiler patch and makefile. 122 | Anuj Goyal anuj dot goyal at gmail dot com 123 | Port to Digital Mars compiler. 124 | Gottlob Frege gottlobfrege at gmail dot com 125 | re-implemented pthread_once (version 2) 126 | (pthread_once cancellation added by rpj). 127 | Vladimir Kliatchko vladimir at kliatchko dot com 128 | reimplemented pthread_once with the same form 129 | as described by A.Terekhov (later version 2); 130 | implementation of MCS (Mellor-Crummey/Scott) locks. 131 | Ramiro Polla ramiro.polla at gmail dot com 132 | static library auto init/cleanup on application 133 | start/exit via RT hooks (MSC and GCC compilers only). 134 | Daniel Richard G. skunk at iSKUNK dot org 135 | Patches and cleanups for x86 and x64, particularly 136 | across a range of MS build environments. 137 | John Kamp john dot kamp at globalgraphics dot com 138 | Patches to fix various problems on x64; brutal testing 139 | particularly using high memory run environments. 140 | 141 | -------------------------------------------------------------------------------- /icao_filter.c: -------------------------------------------------------------------------------- 1 | // Part of dump1090, a Mode S message decoder for RTLSDR devices. 2 | // 3 | // Copyright (C) 2015 Travis Painter 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program. If not, see . 17 | // 18 | // This file incorporates work covered by the following copyright and 19 | // permission notices: 20 | // 21 | // icao_filter.c: hashtable for ICAO addresses 22 | // 23 | // Copyright (c) 2014,2015 Oliver Jowett 24 | // 25 | // This file is free software: you may copy, redistribute and/or modify it 26 | // under the terms of the GNU General Public License as published by the 27 | // Free Software Foundation, either version 2 of the License, or (at your 28 | // option) any later version. 29 | // 30 | // This file is distributed in the hope that it will be useful, but 31 | // WITHOUT ANY WARRANTY; without even the implied warranty of 32 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 33 | // General Public License for more details. 34 | // 35 | // You should have received a copy of the GNU General Public License 36 | // along with this program. If not, see . 37 | 38 | #include "dump1090.h" 39 | 40 | // hash table size, must be a power of two: 41 | #define ICAO_FILTER_SIZE 4096 42 | 43 | // Millis between filter expiry flips: 44 | #define MODES_ICAO_FILTER_TTL 60000 45 | 46 | // Open-addressed hash table with linear probing. 47 | // We store each address twice to handle Data/Parity 48 | // which need to match on a partial address (top 16 bits only). 49 | 50 | // Maintain two tables and switch between them to age out entries. 51 | 52 | static uint32_t icao_filter_a[ICAO_FILTER_SIZE]; 53 | static uint32_t icao_filter_b[ICAO_FILTER_SIZE]; 54 | static uint32_t *icao_filter_active; 55 | 56 | static uint32_t icaoHash(uint32_t a) 57 | { 58 | // Jenkins one-at-a-time hash, unrolled for 3 bytes 59 | uint32_t hash = 0; 60 | 61 | hash += a & 0xff; 62 | hash += hash << 10; 63 | hash ^= hash >> 6; 64 | 65 | hash += (a >> 8) & 0xff; 66 | hash += (hash << 10); 67 | hash ^= (hash >> 6); 68 | 69 | hash += (a >> 16) & 0xff; 70 | hash += (hash << 10); 71 | hash ^= (hash >> 6); 72 | 73 | hash += (hash << 3); 74 | hash ^= (hash >> 11); 75 | hash += (hash << 15); 76 | 77 | return hash & (ICAO_FILTER_SIZE-1); 78 | } 79 | 80 | void icaoFilterInit() 81 | { 82 | memset(icao_filter_a, 0, sizeof(icao_filter_a)); 83 | memset(icao_filter_b, 0, sizeof(icao_filter_b)); 84 | icao_filter_active = icao_filter_a; 85 | } 86 | 87 | void icaoFilterAdd(uint32_t addr) 88 | { 89 | uint32_t h, h0; 90 | h0 = h = icaoHash(addr); 91 | while (icao_filter_active[h] && icao_filter_active[h] != addr) { 92 | h = (h+1) & (ICAO_FILTER_SIZE-1); 93 | if (h == h0) { 94 | fprintf(stderr, "ICAO hash table full, increase ICAO_FILTER_SIZE\n"); 95 | return; 96 | } 97 | } 98 | if (!icao_filter_active[h]) 99 | icao_filter_active[h] = addr; 100 | 101 | // also add with a zeroed top byte, for handling DF20/21 with Data Parity 102 | h0 = h = icaoHash(addr & 0x00ffff); 103 | while (icao_filter_active[h] && (icao_filter_active[h] & 0x00ffff) != (addr & 0x00ffff)) { 104 | h = (h+1) & (ICAO_FILTER_SIZE-1); 105 | if (h == h0) { 106 | fprintf(stderr, "ICAO hash table full, increase ICAO_FILTER_SIZE\n"); 107 | return; 108 | } 109 | } 110 | if (!icao_filter_active[h]) 111 | icao_filter_active[h] = addr; 112 | } 113 | 114 | int icaoFilterTest(uint32_t addr) 115 | { 116 | uint32_t h, h0; 117 | 118 | h0 = h = icaoHash(addr); 119 | while (icao_filter_a[h] && icao_filter_a[h] != addr) { 120 | h = (h+1) & (ICAO_FILTER_SIZE-1); 121 | if (h == h0) 122 | break; 123 | } 124 | if (icao_filter_a[h] == addr) 125 | return 1; 126 | 127 | h = h0; 128 | while (icao_filter_b[h] && icao_filter_b[h] != addr) { 129 | h = (h+1) & (ICAO_FILTER_SIZE-1); 130 | if (h == h0) 131 | break; 132 | } 133 | if (icao_filter_b[h] == addr) 134 | return 1; 135 | 136 | return 0; 137 | } 138 | 139 | uint32_t icaoFilterTestFuzzy(uint32_t partial) 140 | { 141 | uint32_t h, h0; 142 | 143 | partial &= 0x00ffff; 144 | h0 = h = icaoHash(partial); 145 | while (icao_filter_a[h] && (icao_filter_a[h] & 0x00ffff) != partial) { 146 | h = (h+1) & (ICAO_FILTER_SIZE-1); 147 | if (h == h0) 148 | break; 149 | } 150 | if ((icao_filter_a[h] & 0x00ffff) == partial) 151 | return icao_filter_a[h]; 152 | 153 | h = h0; 154 | while (icao_filter_b[h] && (icao_filter_b[h] & 0x00ffff) != partial) { 155 | h = (h+1) & (ICAO_FILTER_SIZE-1); 156 | if (h == h0) 157 | break; 158 | } 159 | if ((icao_filter_b[h] & 0x00ffff) == partial) 160 | return icao_filter_b[h]; 161 | 162 | return 0; 163 | } 164 | 165 | void icaoFilterExpire() 166 | { 167 | static uint64_t next_flip = 0; 168 | uint64_t now = mstime(); 169 | if (now >= next_flip) { 170 | if (icao_filter_active == icao_filter_a) { 171 | memset(icao_filter_b, 0, sizeof(icao_filter_b)); 172 | icao_filter_active = icao_filter_b; 173 | } else { 174 | memset(icao_filter_a, 0, sizeof(icao_filter_a)); 175 | icao_filter_active = icao_filter_a; 176 | } 177 | next_flip = now + MODES_ICAO_FILTER_TTL; 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /pthread/COPYING.pthreads: -------------------------------------------------------------------------------- 1 | pthreads-win32 - a POSIX threads library for Microsoft Windows 2 | 3 | 4 | This file is Copyrighted 5 | ------------------------ 6 | 7 | This file is covered under the following Copyright: 8 | 9 | Copyright (C) 2001,2006 Ross P. Johnson 10 | All rights reserved. 11 | 12 | Everyone is permitted to copy and distribute verbatim copies 13 | of this license document, but changing it is not allowed. 14 | 15 | Pthreads-win32 is covered by the GNU Lesser General Public License 16 | ------------------------------------------------------------------ 17 | 18 | Pthreads-win32 is open software; you can redistribute it and/or 19 | modify it under the terms of the GNU Lesser General Public License 20 | as published by the Free Software Foundation version 2.1 of the 21 | License. 22 | 23 | Pthreads-win32 is several binary link libraries, several modules, 24 | associated interface definition files and scripts used to control 25 | its compilation and installation. 26 | 27 | Pthreads-win32 is distributed in the hope that it will be useful, 28 | but WITHOUT ANY WARRANTY; without even the implied warranty of 29 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 30 | GNU Lesser General Public License for more details. 31 | 32 | A copy of the GNU Lesser General Public License is distributed with 33 | pthreads-win32 under the filename: 34 | 35 | COPYING.LIB 36 | 37 | You should have received a copy of the version 2.1 GNU Lesser General 38 | Public License with pthreads-win32; if not, write to: 39 | 40 | Free Software Foundation, Inc. 41 | 59 Temple Place 42 | Suite 330 43 | Boston, MA 02111-1307 44 | USA 45 | 46 | The contact addresses for pthreads-win32 is as follows: 47 | 48 | Web: http://sources.redhat.com/pthreads-win32 49 | Email: Ross Johnson 50 | Please use: Firstname.Lastname@homemail.com.au 51 | 52 | 53 | 54 | Pthreads-win32 copyrights and exception files 55 | --------------------------------------------- 56 | 57 | With the exception of the files listed below, Pthreads-win32 58 | is covered under the following GNU Lesser General Public License 59 | Copyrights: 60 | 61 | Pthreads-win32 - POSIX Threads Library for Win32 62 | Copyright(C) 1998 John E. Bossom 63 | Copyright(C) 1999,2006 Pthreads-win32 contributors 64 | 65 | The current list of contributors is contained 66 | in the file CONTRIBUTORS included with the source 67 | code distribution. The current list of CONTRIBUTORS 68 | can also be seen at the following WWW location: 69 | http://sources.redhat.com/pthreads-win32/contributors.html 70 | 71 | Contact Email: Ross Johnson 72 | Please use: Firstname.Lastname@homemail.com.au 73 | 74 | These files are not covered under one of the Copyrights listed above: 75 | 76 | COPYING 77 | COPYING.LIB 78 | tests/rwlock7.c 79 | 80 | This file, COPYING, is distributed under the Copyright found at the 81 | top of this file. It is important to note that you may distribute 82 | verbatim copies of this file but you may not modify this file. 83 | 84 | The file COPYING.LIB, which contains a copy of the version 2.1 85 | GNU Lesser General Public License, is itself copyrighted by the 86 | Free Software Foundation, Inc. Please note that the Free Software 87 | Foundation, Inc. does NOT have a copyright over Pthreads-win32, 88 | only the COPYING.LIB that is supplied with pthreads-win32. 89 | 90 | The file tests/rwlock7.c is derived from code written by 91 | Dave Butenhof for his book 'Programming With POSIX(R) Threads'. 92 | The original code was obtained by free download from his website 93 | http://home.earthlink.net/~anneart/family/Threads/source.html 94 | and did not contain a copyright or author notice. It is assumed to 95 | be freely distributable. 96 | 97 | In all cases one may use and distribute these exception files freely. 98 | And because one may freely distribute the LGPL covered files, the 99 | entire pthreads-win32 source may be freely used and distributed. 100 | 101 | 102 | 103 | General Copyleft and License info 104 | --------------------------------- 105 | 106 | For general information on Copylefts, see: 107 | 108 | http://www.gnu.org/copyleft/ 109 | 110 | For information on GNU Lesser General Public Licenses, see: 111 | 112 | http://www.gnu.org/copyleft/lesser.html 113 | http://www.gnu.org/copyleft/lesser.txt 114 | 115 | 116 | Why pthreads-win32 did not use the GNU General Public License 117 | ------------------------------------------------------------- 118 | 119 | The goal of the pthreads-win32 project has been to 120 | provide a quality and complete implementation of the POSIX 121 | threads API for Microsoft Windows within the limits imposed 122 | by virtue of it being a stand-alone library and not 123 | linked directly to other POSIX compliant libraries. For 124 | example, some functions and features, such as those based 125 | on POSIX signals, are missing. 126 | 127 | Pthreads-win32 is a library, available in several different 128 | versions depending on supported compilers, and may be used 129 | as a dynamically linked module or a statically linked set of 130 | binary modules. It is not an application on it's own. 131 | 132 | It was fully intended that pthreads-win32 be usable with 133 | commercial software not covered by either the GPL or the LGPL 134 | licenses. Pthreads-win32 has many contributors to it's 135 | code base, many of whom have done so because they have 136 | used the library in commercial or proprietry software 137 | projects. 138 | 139 | Releasing pthreads-win32 under the LGPL ensures that the 140 | library can be used widely, while at the same time ensures 141 | that bug fixes and improvements to the pthreads-win32 code 142 | itself is returned to benefit all current and future users 143 | of the library. 144 | 145 | Although pthreads-win32 makes it possible for applications 146 | that use POSIX threads to be ported to Win32 platforms, the 147 | broader goal of the project is to encourage the use of open 148 | standards, and in particular, to make it just a little easier 149 | for developers writing Win32 applications to consider 150 | widening the potential market for their products. 151 | -------------------------------------------------------------------------------- /tools/debug.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 150 | 151 | 184 | 185 |
186 |
187 |
188 | 
189 | 190 | 191 | 192 | 193 | 194 | -------------------------------------------------------------------------------- /winstubs.h: -------------------------------------------------------------------------------- 1 | // dump1090, a Mode S messages decoder for RTLSDR devices. 2 | // 3 | // Copyright (C) 2015 Travis Painter 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program. If not, see . 17 | // 18 | // This file incorporates work covered by the following copyright and 19 | // permission notice: 20 | // 21 | // Copyright (C) 2014 by Malcolm Robb 22 | // 23 | // All rights reserved. 24 | // 25 | // Redistribution and use in source and binary forms, with or without 26 | // modification, are permitted provided that the following conditions are 27 | // met: 28 | // 29 | // * Redistributions of source code must retain the above copyright 30 | // notice, this list of conditions and the following disclaimer. 31 | // 32 | // * Redistributions in binary form must reproduce the above copyright 33 | // notice, this list of conditions and the following disclaimer in the 34 | // documentation and/or other materials provided with the distribution. 35 | // 36 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 37 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 38 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 39 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 40 | // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 41 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 42 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 43 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 44 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 45 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 46 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 47 | // 48 | // This file provides basic Windows implementation of Linux specific functions 49 | // used in the dump1090 project. This allows dump1090 to be compiled and debugged 50 | // using Microsoft Visual C++ 6.0 51 | // 52 | // Note that not all functions actually provide equivalent functionality to their 53 | // Linux equivalents. They are simply stubs to allow the project to compile. 54 | // 55 | #ifndef __WINSTUBS_H 56 | #define __WINSTUBS_H 57 | 58 | #include 59 | #include 60 | #include 61 | 62 | typedef UCHAR uint8_t; 63 | typedef USHORT uint16_t; 64 | typedef UINT32 uint32_t; 65 | typedef UINT64 uint64_t; 66 | //typedef UINT32 mode_t; 67 | typedef long ssize_t; 68 | typedef int socklen_t; 69 | 70 | #include 71 | #include 72 | #include 73 | #include 74 | #include 75 | #include 76 | #include 77 | 78 | #define M_PI 3.14159265358979323846 79 | #include 80 | #include 81 | #include 82 | #include 83 | 84 | #ifdef __cplusplus 85 | extern "C" { 86 | #endif 87 | 88 | //Remove gcc specific __atribute__ 89 | #define __attribute__(A) 90 | 91 | //Functions not included in the MSVC maths library. This will do for our use. 92 | _inline double round(double d) {return floor(d + 0.5);} 93 | _inline double trunc(double d) {return (d>0) ? floor(d):ceil(d) ;} 94 | 95 | //usleep works in microseconds, and isn't supported in Windows. This will do for our use. 96 | _inline void usleep(UINT32 ulSleep) {Sleep(ulSleep/1000);} 97 | _inline uint64_t strtoll(const char *p, void *e, UINT32 base) {return _atoi64(p);} 98 | _inline int inet_aton(const char * cp, DWORD * ulAddr) { *ulAddr = inet_addr(cp); return (INADDR_NONE != *ulAddr);} 99 | #define snprintf _snprintf 100 | #define vsnprintf _vsnprintf 101 | #define strcasecmp _stricmp 102 | #define realpath(N,R) _fullpath((R),(N),_MAX_PATH) 103 | 104 | enum { 105 | PATH_MAX = MAX_PATH 106 | }; 107 | 108 | //Windows doesn't have localtime_r 109 | _inline struct tm *localtime_r(time_t *_clock, struct tm *_result) 110 | { 111 | _localtime64_s(_result, _clock); 112 | return _result; 113 | } 114 | 115 | _inline void cls() { 116 | HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); 117 | COORD coord = {0, 0}; 118 | DWORD count; 119 | 120 | CONSOLE_SCREEN_BUFFER_INFO csbi; 121 | GetConsoleScreenBufferInfo(hStdOut, &csbi); 122 | 123 | FillConsoleOutputCharacter(hStdOut, ' ', csbi.dwSize.X * csbi.dwSize.Y, coord, &count); 124 | 125 | SetConsoleCursorPosition(hStdOut, coord); 126 | } 127 | 128 | //PostgreSQL function: 129 | /* 130 | * gettimeofday.c 131 | * Win32 gettimeofday() replacement 132 | * 133 | * src/port/gettimeofday.c 134 | * 135 | * Copyright (c) 2003 SRA, Inc. 136 | * Copyright (c) 2003 SKC, Inc. 137 | * 138 | * Permission to use, copy, modify, and distribute this software and 139 | * its documentation for any purpose, without fee, and without a 140 | * written agreement is hereby granted, provided that the above 141 | * copyright notice and this paragraph and the following two 142 | * paragraphs appear in all copies. 143 | * 144 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, 145 | * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING 146 | * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS 147 | * DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED 148 | * OF THE POSSIBILITY OF SUCH DAMAGE. 149 | * 150 | * THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT 151 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 152 | * A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS 153 | * IS" BASIS, AND THE AUTHOR HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, 154 | * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 155 | */ 156 | 157 | /* FILETIME of Jan 1 1970 00:00:00. */ 158 | static const unsigned __int64 epoch = ((unsigned __int64) 116444736000000000ULL); 159 | 160 | /* 161 | * timezone information is stored outside the kernel so tzp isn't used anymore. 162 | * 163 | * Note: this function is not for Win32 high precision timing purpose. See 164 | * elapsed_time(). 165 | */ 166 | _inline int gettimeofday(struct timeval * tp, struct timezone * tzp) 167 | { 168 | FILETIME file_time; 169 | SYSTEMTIME system_time; 170 | ULARGE_INTEGER ularge; 171 | 172 | GetSystemTime(&system_time); 173 | SystemTimeToFileTime(&system_time, &file_time); 174 | ularge.LowPart = file_time.dwLowDateTime; 175 | ularge.HighPart = file_time.dwHighDateTime; 176 | 177 | tp->tv_sec = (long) ((ularge.QuadPart - epoch) / 10000000L); 178 | tp->tv_usec = (long) (system_time.wMilliseconds * 1000); 179 | 180 | return 0; 181 | } 182 | 183 | 184 | #define STDIN_FILENO 0 185 | #define EINPROGRESS WSAEINPROGRESS 186 | #define EWOULDBLOCK WSAEWOULDBLOCK 187 | 188 | #ifdef __cplusplus 189 | } 190 | #endif 191 | 192 | #endif // __WINSTUBS_H 193 | -------------------------------------------------------------------------------- /debian/dump1090-mutability.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ### BEGIN INIT INFO 3 | # Provides: dump1090-mutability 4 | # Required-Start: $remote_fs 5 | # Required-Stop: $remote_fs 6 | # Default-Start: 2 3 4 5 7 | # Default-Stop: 0 1 6 8 | # Short-Description: dump1090 daemon (mutability variant) 9 | # Description: Receives ADS-B messages from a RTLSDR dongle 10 | # and makes them available to other applications via 11 | # a variety of network protocols. 12 | ### END INIT INFO 13 | 14 | # Do NOT "set -e" 15 | 16 | # PATH should only include /usr/* if it runs after the mountnfs.sh script 17 | PATH=/sbin:/usr/sbin:/bin:/usr/bin 18 | DESC="dump1090-mutability daemon" 19 | NAME=dump1090-mutability 20 | DAEMON=/usr/bin/$NAME 21 | ARGS="" 22 | PIDFILE=/var/run/$NAME.pid 23 | SCRIPTNAME=/etc/init.d/$NAME 24 | 25 | # Exit if the package is not installed 26 | [ -x "$DAEMON" ] || exit 0 27 | 28 | # Read configuration variable file if it is present 29 | [ -r /etc/default/$NAME ] && . /etc/default/$NAME 30 | 31 | # work out daemon args 32 | 33 | # sanitize missing settings 34 | [ -z "$START_DUMP1090" ] && START_DUMP1090=no 35 | [ -z "$DUMP1090_USER" ] && DUMP1090_USER="missing-DUMP1090_USER-setting-in-config" 36 | [ -z "$HTTP_PORT" ] && HTTP_PORT=0 37 | [ -z "$RAW_INPUT_PORT" ] && RAW_INPUT_PORT=0 38 | [ -z "$RAW_OUTPUT_PORT" ] && RAW_OUTPUT_PORT=0 39 | [ -z "$SBS_OUTPUT_PORT" ] && SBS_OUTPUT_PORT=0 40 | [ -z "$BEAST_INPUT_PORT" ] && BEAST_INPUT_PORT=0 41 | [ -z "$BEAST_OUTPUT_PORT" ] && BEAST_OUTPUT_PORT=0 42 | [ -z "$FATSV_OUTPUT_PORT" ] && FATSV_OUTPUT_PORT=0 43 | [ -z "$NET_BUFFER" ] && NET_BUFFER=0 44 | [ -z "$JSON_INTERVAL" ] && JSON_INTERVAL=0 45 | [ -z "$MAX_RANGE" ] && MAX_RANGE=300 46 | 47 | # receiver: 48 | NICELEVEL="--nicelevel -5" 49 | case "x$DEVICE" in 50 | x|x0) ARGS="$ARGS --net" ;; 51 | xnone) ARGS="$ARGS --net-only"; NICELEVEL="" ;; 52 | *) ARGS="$ARGS --net --device-index $DEVICE" ;; 53 | esac 54 | case "x$GAIN" in 55 | x|xmax) ;; 56 | xagc) ARGS="$ARGS --gain -10" ;; 57 | *) ARGS="$ARGS --gain $GAIN" ;; 58 | esac 59 | if [ -n "$PPM" ]; then ARGS="$ARGS --ppm $PPM"; fi 60 | if [ "x$OVERSAMPLE" = "xyes" ]; then ARGS="$ARGS --oversample"; fi 61 | 62 | # decoder: 63 | if [ "x$FIX_CRC" = "xyes" ]; then ARGS="$ARGS --fix"; fi 64 | if [ "x$PHASE_ENHANCE" = "xyes" ]; then ARGS="$ARGS --phase-enhance"; fi 65 | if [ "x$AGGRESSIVE" = "xyes" ]; then ARGS="$ARGS --aggressive"; fi 66 | if [ -n "$LAT" ]; then ARGS="$ARGS --lat $LAT"; fi 67 | if [ -n "$LON" ]; then ARGS="$ARGS --lon $LON"; fi 68 | ARGS="$ARGS --max-range $MAX_RANGE"; fi 69 | 70 | # net: 71 | 72 | ARGS="$ARGS --net-http-port $HTTP_PORT \ 73 | --net-ri-port $RAW_INPUT_PORT --net-ro-port $RAW_OUTPUT_PORT \ 74 | --net-bi-port $BEAST_INPUT_PORT --net-bo-port $BEAST_OUTPUT_PORT \ 75 | --net-sbs-port $SBS_OUTPUT_PORT --net-fatsv-port $FATSV_OUTPUT_PORT" 76 | if [ -n "$NET_HEARTBEAT" ]; then ARGS="$ARGS --net-heartbeat $NET_HEARTBEAT"; fi 77 | if [ -n "$NET_OUTPUT_SIZE" ]; then ARGS="$ARGS --net-ro-size $NET_OUTPUT_SIZE"; fi 78 | if [ -n "$NET_OUTPUT_INTERVAL" ]; then ARGS="$ARGS --net-ro-interval $NET_OUTPUT_INTERVAL"; fi 79 | if [ "$NET_BUFFER" -le "65536" ]; then ARGS="$ARGS --net-buffer 0" 80 | elif [ "$NET_BUFFER" -le "131072" ]; then ARGS="$ARGS --net-buffer 1" 81 | elif [ "$NET_BUFFER" -le "262144" ]; then ARGS="$ARGS --net-buffer 2" 82 | else ARGS="$ARGS --net-buffer 3"; fi 83 | if [ -n "$NET_BIND_ADDRESS" ]; then ARGS="$ARGS --net-bind-address $NET_BIND_ADDRESS"; fi 84 | 85 | # misc: 86 | if [ -n "$STATS_INTERVAL" ]; then ARGS="$ARGS --stats-every $STATS_INTERVAL"; fi 87 | if [ -n "$JSON_DIR" ]; then ARGS="$ARGS --write-json $JSON_DIR"; fi 88 | if [ -n "$JSON_INTERVAL" ]; then ARGS="$ARGS --write-json-every $JSON_INTERVAL"; fi 89 | case "x$JSON_LOCATION_ACCURACY" in 90 | xexact) ARGS="$ARGS --json-location-accuracy 2" ;; 91 | xapproximate) ARGS="$ARGS --json-location-accuracy 1" ;; 92 | *) ARGS="$ARGS --json-location-accuracy 0" ;; 93 | esac 94 | 95 | if [ "x$LOG_DECODED_MESSAGES" != "xyes" ]; then ARGS="$ARGS --quiet"; fi 96 | 97 | if [ -n "$EXTRA_ARGS" ]; then ARGS="$ARGS $EXTRA_ARGS"; fi 98 | 99 | # Load the VERBOSE setting and other rcS variables 100 | . /lib/init/vars.sh 101 | 102 | # Define LSB log_* functions. 103 | # Depend on lsb-base (>= 3.2-14) to ensure that this file is present 104 | # and status_of_proc is working. 105 | . /lib/lsb/init-functions 106 | 107 | # 108 | # Function that starts the daemon/service 109 | # 110 | do_start() 111 | { 112 | # Return 113 | # 0 if daemon has been started 114 | # 1 if daemon was already running 115 | # 2 if daemon could not be started 116 | 117 | if [ "x$START_DUMP1090" != "xyes" ]; then 118 | log_warning_msg "Not starting $NAME daemon, disabled via /etc/default/$NAME" 119 | return 2 120 | fi 121 | 122 | start-stop-daemon --start --quiet --pidfile $PIDFILE --user "$DUMP1090_USER" --exec $DAEMON --test > /dev/null \ 123 | || return 1 124 | 125 | # create JSON_DIR with the appropriate permissions 126 | # (it is on /run by default, so will be lost on reboot) 127 | if [ "x$JSON_DIR" != "x" ]; then 128 | if [ ! -e $JSON_DIR ]; then 129 | (mkdir $JSON_DIR && chmod 0755 $JSON_DIR && chown $DUMP1090_USER $JSON_DIR) || log_warning_msg "Failed to create $JSON_DIR" 130 | fi 131 | fi 132 | 133 | # create logfile with the appropriate permissions if not already there 134 | # (the cronjob running as DUMP1090_USER wants to append to it) 135 | touch $LOGFILE 136 | chown "$DUMP1090_USER":root $LOGFILE 137 | 138 | start-stop-daemon --start $NICELEVEL --quiet --pidfile $PIDFILE --user "$DUMP1090_USER" --chuid "$DUMP1090_USER" --make-pidfile --background --no-close --exec $DAEMON -- \ 139 | $ARGS >>$LOGFILE 2>&1 \ 140 | || return 2 141 | sleep 1 142 | } 143 | 144 | # 145 | # Function that stops the daemon/service 146 | # 147 | do_stop() 148 | { 149 | # Return 150 | # 0 if daemon has been stopped 151 | # 1 if daemon was already stopped 152 | # 2 if daemon could not be stopped 153 | # other if a failure occurred 154 | start-stop-daemon --stop --retry=TERM/30/KILL/5 --pidfile $PIDFILE --user "$DUMP1090_USER" --exec $DAEMON 155 | RETVAL="$?" 156 | [ "$RETVAL" = 2 ] && return 2 157 | sleep 1 158 | # Many daemons don't delete their pidfiles when they exit. 159 | rm -f $PIDFILE 160 | return "$RETVAL" 161 | } 162 | 163 | case "$1" in 164 | start) 165 | [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" 166 | do_start 167 | case "$?" in 168 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 169 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 170 | esac 171 | ;; 172 | stop) 173 | [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" 174 | do_stop 175 | case "$?" in 176 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 177 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 178 | esac 179 | ;; 180 | status) 181 | status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? 182 | ;; 183 | restart|force-reload) 184 | log_daemon_msg "Restarting $DESC" "$NAME" 185 | do_stop 186 | case "$?" in 187 | 0|1) 188 | do_start 189 | case "$?" in 190 | 0) log_end_msg 0 ;; 191 | 1) log_end_msg 1 ;; # Old process is still running 192 | *) log_end_msg 1 ;; # Failed to start 193 | esac 194 | ;; 195 | *) 196 | # Failed to stop 197 | log_end_msg 1 198 | ;; 199 | esac 200 | ;; 201 | *) 202 | echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 203 | exit 3 204 | ;; 205 | esac 206 | 207 | : 208 | -------------------------------------------------------------------------------- /interactive.c: -------------------------------------------------------------------------------- 1 | // Part of dump1090, a Mode S message decoder for RTLSDR devices. 2 | // 3 | // interactive.c: aircraft tracking and interactive display 4 | // 5 | // Copyright (c) 2014,2015 Oliver Jowett 6 | // 7 | // This file is free software: you may copy, redistribute and/or modify it 8 | // under the terms of the GNU General Public License as published by the 9 | // Free Software Foundation, either version 2 of the License, or (at your 10 | // option) any later version. 11 | // 12 | // This file is distributed in the hope that it will be useful, but 13 | // WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | // General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program. If not, see . 19 | 20 | // This file incorporates work covered by the following copyright and 21 | // permission notice: 22 | // 23 | // Copyright (C) 2012 by Salvatore Sanfilippo 24 | // 25 | // All rights reserved. 26 | // 27 | // Redistribution and use in source and binary forms, with or without 28 | // modification, are permitted provided that the following conditions are 29 | // met: 30 | // 31 | // * Redistributions of source code must retain the above copyright 32 | // notice, this list of conditions and the following disclaimer. 33 | // 34 | // * Redistributions in binary form must reproduce the above copyright 35 | // notice, this list of conditions and the following disclaimer in the 36 | // documentation and/or other materials provided with the distribution. 37 | // 38 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 39 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 40 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 41 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 42 | // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 43 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 44 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 45 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 46 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 47 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 48 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 49 | 50 | #include "dump1090.h" 51 | 52 | // 53 | //========================= Interactive mode =============================== 54 | 55 | 56 | // 57 | //========================================================================= 58 | // 59 | // Show the currently captured interactive data on screen. 60 | // 61 | void interactiveShowData(void) { 62 | struct aircraft *a = Modes.aircrafts; 63 | static uint64_t next_update; 64 | uint64_t now = mstime(); 65 | int count = 0; 66 | char progress; 67 | char spinner[4] = "|/-\\"; 68 | 69 | // Refresh screen every (MODES_INTERACTIVE_REFRESH_TIME) miliseconde 70 | if (now < next_update) 71 | return; 72 | 73 | next_update = now + MODES_INTERACTIVE_REFRESH_TIME; 74 | 75 | progress = spinner[(now/1000)%4]; 76 | 77 | #ifndef _WIN32 78 | printf("\x1b[H\x1b[2J"); // Clear the screen 79 | #else 80 | cls(); 81 | #endif 82 | 83 | if (Modes.interactive_rtl1090 == 0) { 84 | printf ( 85 | " Hex Mode Sqwk Flight Alt Spd Hdg Lat Long RSSI Msgs Ti%c\n", progress); 86 | } else { 87 | printf ( 88 | " Hex Flight Alt V/S GS TT SSR G*456^ Msgs Seen %c\n", progress); 89 | } 90 | printf( 91 | "-------------------------------------------------------------------------------\n"); 92 | 93 | while(a && (count < Modes.interactive_rows)) { 94 | 95 | if ((now - a->seen) < Modes.interactive_display_ttl) 96 | { 97 | int msgs = a->messages; 98 | int flags = a->modeACflags; 99 | 100 | if ( (((flags & (MODEAC_MSG_FLAG )) == 0 ) && (msgs > 1 ) ) 101 | || (((flags & (MODEAC_MSG_MODES_HIT | MODEAC_MSG_MODEA_ONLY)) == MODEAC_MSG_MODEA_ONLY) && (msgs > 4 ) ) 102 | || (((flags & (MODEAC_MSG_MODES_HIT | MODEAC_MSG_MODEC_OLD )) == 0 ) && (msgs > 127) ) 103 | ) { 104 | int altitude = a->altitude, speed = a->speed; 105 | char strSquawk[5] = " "; 106 | char strFl[6] = " "; 107 | char strTt[5] = " "; 108 | char strGs[5] = " "; 109 | 110 | // Convert units to metric if --metric was specified 111 | if (Modes.metric) { 112 | altitude = (int) (altitude / 3.2828); 113 | speed = (int) (speed * 1.852); 114 | } 115 | 116 | if (a->bFlags & MODES_ACFLAGS_SQUAWK_VALID) { 117 | snprintf(strSquawk,5,"%04x", a->modeA);} 118 | 119 | if (a->bFlags & MODES_ACFLAGS_SPEED_VALID) { 120 | snprintf (strGs, 5,"%3d", speed);} 121 | 122 | if (a->bFlags & MODES_ACFLAGS_HEADING_VALID) { 123 | snprintf (strTt, 5,"%03d", a->track);} 124 | 125 | if (msgs > 99999) { 126 | msgs = 99999;} 127 | 128 | if (Modes.interactive_rtl1090) { // RTL1090 display mode 129 | 130 | if (a->bFlags & MODES_ACFLAGS_ALTITUDE_VALID) { 131 | snprintf(strFl,6,"F%03d",(altitude/100)); 132 | } 133 | printf("%06x %-8s %-4s %-3s %-3s %4s %-6d %-2.0f\n", 134 | a->addr, a->flight, strFl, strGs, strTt, strSquawk, msgs, (now - a->seen)/1000.0); 135 | 136 | } else { // Dump1090 display mode 137 | char strMode[5] = " "; 138 | char strLat[8] = " "; 139 | char strLon[9] = " "; 140 | double * pSig = a->signalLevel; 141 | double signalAverage = (pSig[0] + pSig[1] + pSig[2] + pSig[3] + 142 | pSig[4] + pSig[5] + pSig[6] + pSig[7]) / 8.0; 143 | 144 | if ((flags & MODEAC_MSG_FLAG) == 0) { 145 | strMode[0] = 'S'; 146 | } else if (flags & MODEAC_MSG_MODEA_ONLY) { 147 | strMode[0] = 'A'; 148 | } 149 | if (flags & MODEAC_MSG_MODEA_HIT) {strMode[2] = 'a';} 150 | if (flags & MODEAC_MSG_MODEC_HIT) {strMode[3] = 'c';} 151 | 152 | if (a->bFlags & MODES_ACFLAGS_LATLON_VALID) { 153 | snprintf(strLat, 8,"%7.03f", a->lat); 154 | snprintf(strLon, 9,"%8.03f", a->lon); 155 | } 156 | 157 | if (a->bFlags & MODES_ACFLAGS_AOG) { 158 | snprintf(strFl, 6," grnd"); 159 | } else if (a->bFlags & MODES_ACFLAGS_ALTITUDE_VALID) { 160 | snprintf(strFl, 6, "%5d", altitude); 161 | } 162 | 163 | printf("%s%06X %-4s %-4s %-8s %5s %3s %3s %7s %8s %5.1f %5d %2.0f\n", 164 | (a->addr & MODES_NON_ICAO_ADDRESS) ? "~" : " ", (a->addr & 0xffffff), 165 | strMode, strSquawk, a->flight, strFl, strGs, strTt, 166 | strLat, strLon, 10 * log10(signalAverage), msgs, (now - a->seen)/1000.0); 167 | } 168 | count++; 169 | } 170 | } 171 | a = a->next; 172 | } 173 | } 174 | 175 | // 176 | //========================================================================= 177 | // 178 | -------------------------------------------------------------------------------- /debian/dump1090-mutability.config: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | NAME=dump1090-mutability 4 | CONFIGFILE=/etc/default/$NAME 5 | set -e 6 | . /usr/share/debconf/confmodule 7 | 8 | db_set_yn() { 9 | if [ "x$2" = "xyes" ]; then db_set $1 true; else db_set $1 false; fi 10 | } 11 | 12 | # Load config file, if it exists. 13 | if [ -e $CONFIGFILE ]; then 14 | . $CONFIGFILE || true 15 | 16 | # Store values from config file into 17 | # debconf db. 18 | 19 | db_set_yn $NAME/auto-start "$START_DUMP1090" 20 | db_set $NAME/run-as-user "$DUMP1090_USER" 21 | db_set $NAME/log-file "$LOGFILE" 22 | 23 | db_set $NAME/rtlsdr-device "$DEVICE" 24 | db_set $NAME/rtlsdr-gain "$GAIN" 25 | db_set $NAME/rtlsdr-ppm "$PPM" 26 | db_set_yn $NAME/rtlsdr-oversample "$OVERSAMPLE" 27 | 28 | db_set_yn $NAME/decode-fixcrc "$FIX_CRC" 29 | db_set_yn $NAME/decode-phase-enhance "$PHASE_ENHANCE" 30 | db_set_yn $NAME/decode-aggressive "$AGGRESSIVE" 31 | db_set $NAME/decode-lat "$LAT" 32 | db_set $NAME/decode-lon "$LON" 33 | db_set $NAME/decode-max-range "$MAX_RANGE" 34 | 35 | db_set $NAME/net-http-port "$HTTP_PORT" 36 | db_set $NAME/net-ri-port "$RAW_INPUT_PORT" 37 | db_set $NAME/net-ro-port "$RAW_OUTPUT_PORT" 38 | db_set $NAME/net-bi-port "$BEAST_INPUT_PORT" 39 | db_set $NAME/net-bo-port "$BEAST_OUTPUT_PORT" 40 | db_set $NAME/net-sbs-port "$SBS_OUTPUT_PORT" 41 | db_set $NAME/net-fatsv-port "$FATSV_OUTPUT_PORT" 42 | db_set $NAME/net-heartbeat "$NET_HEARTBEAT" 43 | db_set $NAME/net-out-size "$NET_OUTPUT_SIZE" 44 | db_set $NAME/net-out-interval "$NET_OUTPUT_INTERVAL" 45 | db_set $NAME/net-buffer "$NET_BUFFER" 46 | db_set $NAME/net-bind-address "$NET_BIND_ADDRESS" 47 | 48 | db_set $NAME/stats-interval "$STATS_INTERVAL" 49 | db_set $NAME/json-dir "$JSON_DIR" 50 | db_set $NAME/json-interval "$JSON_INTERVAL" 51 | db_set $NAME/json-location-accuracy "$JSON_LOCATION_ACCURACY" 52 | db_set_yn $NAME/log-decoded-messages "$LOG_DECODED_MESSAGES" 53 | db_set $NAME/extra-args "$EXTRA_ARGS" 54 | fi 55 | 56 | # Ask questions. 57 | 58 | db_input_verify() { 59 | # $1 = priority 60 | # $2 = db key 61 | # $3 = verification function, should return 0 if OK 62 | PRI=$1; KEY=$2; VERIFY=$3 63 | 64 | set +e 65 | db_input $PRI $KEY; RESULT=$? 66 | db_go 67 | set -e 68 | ASKED=0 69 | while : 70 | do 71 | db_get $KEY 72 | if $VERIFY "$RET"; then return 0; fi 73 | if [ $RESULT -ne 0 ]; then 74 | # db_input failed, and the existing value does not validate 75 | if [ $RESULT = 30 ] && [ $ASKED = 0 ] 76 | then 77 | # question was skipped, but existing value is invalid 78 | # bump priority and try again (once) 79 | PRI=high 80 | ASKED=1 81 | else 82 | # give up, use the default value 83 | db_reset $KEY 84 | return 0 85 | fi 86 | else 87 | # db_input was OK, but the value did not verify. 88 | # show an error message 89 | db_input high dump1090-mutability/invalid-$VERIFY || true 90 | fi 91 | 92 | # try again 93 | set +e 94 | db_fset $KEY seen false 95 | db_input high $KEY; RESULT=$? 96 | db_go 97 | set -e 98 | done 99 | } 100 | 101 | is_unsigned_int() { 102 | if echo "$1" | grep -Eq '^(0|+?[1-9][0-9]*)$'; then return 0; else return 1; fi 103 | } 104 | 105 | is_unsigned_int_or_empty() { 106 | if [ -z "$1" ]; then return 0 107 | elif is_unsigned_int "$1"; then return 0 108 | else return 1; fi 109 | } 110 | 111 | is_positive_int() { 112 | if echo "$1" | grep -Eq '^(+?[1-9][0-9]*)$'; then return 0; else return 1; fi 113 | } 114 | 115 | is_signed_int() { 116 | if echo "$1" | grep -Eq '^(0|[+-]?[1-9][0-9]*)$'; then return 0; else return 1; fi 117 | } 118 | 119 | is_signed_int_or_empty() { 120 | if [ -z "$1" ]; then return 0 121 | elif is_signed_int "$1"; then return 0 122 | else return 1; fi 123 | } 124 | 125 | is_ipaddrish() { 126 | if echo "$1" | grep -Eq '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$'; then return 0; else return 1; fi 127 | } 128 | 129 | is_ipaddrish_or_empty() { 130 | if [ -z "$1" ]; then return 0 131 | elif is_ipaddrish "$1"; then return 0 132 | else return 1; fi 133 | } 134 | 135 | is_number() { 136 | if echo "$1" | grep -Eq '^([+-]?[0-9][0-9]*)(\.[0-9]+)?$'; then return 0; else return 1; fi 137 | } 138 | 139 | is_unsigned_number() { 140 | if echo "$1" | grep -Eq '^([+]?[0-9][0-9]*)(\.[0-9]+)?$'; then return 0; else return 1; fi 141 | } 142 | 143 | is_positive_number() { 144 | if echo "$1" | grep -Eq '^(([+]?0\.[0-9]*[1-9]+[0-9]*)|([+]?[1-9][0-9]*)(\.[0-9]+)?)$'; then return 0; else return 1; fi 145 | } 146 | 147 | is_number_or_empty() { 148 | if [ -z "$1" ]; then return 0 149 | elif is_number "$1"; then return 0; 150 | else return 1; fi 151 | } 152 | 153 | is_valid_gain() { 154 | if is_number "$1"; then return 0; 155 | elif [ "$1" = "max" ]; then return 0; 156 | elif [ "$1" = "agc" ]; then return 0; 157 | else return 1; fi 158 | } 159 | 160 | is_not_empty() { 161 | if [ -z "$1" ]; then return 1; else return 0; fi 162 | } 163 | 164 | # "adduser: To avoid problems, the username should consist only of 165 | # letters, digits, underscores, full stops, at signs and dashes, and not start with 166 | # a dash (as defined by IEEE Std 1003.1-2001). For compatibility with Samba 167 | # machine accounts $ is also supported at the end of the username" 168 | is_non_root_user() { 169 | if [ -z "$1" ]; then return 1; 170 | elif [ "$1" = "root" ]; then return 1; 171 | elif echo "$1" | grep -Eq '^[a-zA-Z0-9_.@-]+\$?$'; then return 0; 172 | else return 1; fi 173 | } 174 | 175 | is_port_number() { 176 | if is_unsigned_int "$1"; then 177 | if [ "$1" -eq 0 ]; then return 0; fi 178 | if [ "$1" -lt 1024 ]; then return 1; fi 179 | if [ "$1" -gt 65535 ]; then return 1; fi 180 | return 0 181 | else 182 | return 1 183 | fi 184 | } 185 | 186 | db_input high $NAME/auto-start || true 187 | db_input_verify low $NAME/run-as-user is_non_root_user || true 188 | db_input_verify low $NAME/log-file is_not_empty || true 189 | 190 | db_go || true; db_get $NAME/auto-start; if [ "$RET" = "true" ]; then 191 | # all of these are only relevant if the init script is enabled 192 | db_input medium $NAME/rtlsdr-device || true 193 | 194 | db_go || true; db_get $NAME/rtlsdr-device; if [ "x$RET" != "xnone" ]; then 195 | # only if a real device was chosen: 196 | db_input_verify medium $NAME/rtlsdr-gain is_valid_gain || true 197 | db_input_verify medium $NAME/rtlsdr-ppm is_signed_int || true 198 | db_input low $NAME/rtlsdr-oversample || true 199 | fi 200 | 201 | db_input low $NAME/decode-fix-crc || true 202 | db_input low $NAME/decode-aggressive || true 203 | db_input_verify medium $NAME/decode-max-range is_number || true 204 | db_input_verify medium $NAME/decode-lat is_number_or_empty || true 205 | 206 | db_go || true; db_get $NAME/decode-lat; if [ -n "$RET" ]; then 207 | # only if latitude was given: 208 | db_input_verify medium $NAME/decode-lon is_number_or_empty || true 209 | fi 210 | 211 | db_input_verify medium $NAME/net-http-port is_port_number || true 212 | db_input_verify low $NAME/net-ri-port is_port_number || true 213 | db_input_verify low $NAME/net-ro-port is_port_number || true 214 | db_input_verify low $NAME/net-bi-port is_port_number || true 215 | db_input_verify low $NAME/net-bo-port is_port_number || true 216 | db_input_verify low $NAME/net-sbs-port is_port_number || true 217 | db_input_verify low $NAME/net-fatsv-port is_port_number || true 218 | db_input_verify low $NAME/net-heartbeat is_unsigned_number || true 219 | db_input_verify low $NAME/net-out-size is_unsigned_int || true 220 | db_input_verify low $NAME/net-out-interval is_unsigned_number || true 221 | db_input_verify low $NAME/net-buffer is_unsigned_int || true 222 | db_input_verify medium $NAME/net-bind-address is_ipaddrish_or_empty || true 223 | 224 | db_input_verify low $NAME/stats-interval is_unsigned_int || true 225 | 226 | db_input_verify low $NAME/json-interval is_positive_number || true 227 | db_input low $NAME/json-location-accuracy || true 228 | db_input low $NAME/json-dir || true 229 | 230 | db_input low $NAME/log-decoded-messages || true 231 | db_input low $NAME/extra-args || true 232 | 233 | db_go || True 234 | fi 235 | 236 | # Done. 237 | db_stop 238 | -------------------------------------------------------------------------------- /inttypes/stdint.h: -------------------------------------------------------------------------------- 1 | // ISO C9x compliant stdint.h for Microsoft Visual Studio 2 | // Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 3 | // 4 | // Copyright (c) 2006-2008 Alexander Chemeris 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // 1. Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // 2. Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // 16 | // 3. The name of the author may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 20 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | /////////////////////////////////////////////////////////////////////////////// 31 | 32 | #ifndef _MSC_VER // [ 33 | #error "Use this header only with Microsoft Visual C++ compilers!" 34 | #endif // _MSC_VER ] 35 | 36 | #ifndef _MSC_STDINT_H_ // [ 37 | #define _MSC_STDINT_H_ 38 | 39 | #if _MSC_VER > 1000 40 | #pragma once 41 | #endif 42 | 43 | #include 44 | 45 | // For Visual Studio 6 in C++ mode and for many Visual Studio versions when 46 | // compiling for ARM we should wrap include with 'extern "C++" {}' 47 | // or compiler give many errors like this: 48 | // error C2733: second C linkage of overloaded function 'wmemchr' not allowed 49 | #ifdef __cplusplus 50 | extern "C" { 51 | #endif 52 | # include 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | 57 | // Define _W64 macros to mark types changing their size, like intptr_t. 58 | #ifndef _W64 59 | # if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 60 | # define _W64 __w64 61 | # else 62 | # define _W64 63 | # endif 64 | #endif 65 | 66 | 67 | // 7.18.1 Integer types 68 | 69 | // 7.18.1.1 Exact-width integer types 70 | 71 | // Visual Studio 6 and Embedded Visual C++ 4 doesn't 72 | // realize that, e.g. char has the same size as __int8 73 | // so we give up on __intX for them. 74 | #if (_MSC_VER < 1300) 75 | typedef signed char int8_t; 76 | typedef signed short int16_t; 77 | typedef signed int int32_t; 78 | typedef unsigned char uint8_t; 79 | typedef unsigned short uint16_t; 80 | typedef unsigned int uint32_t; 81 | #else 82 | typedef signed __int8 int8_t; 83 | typedef signed __int16 int16_t; 84 | typedef signed __int32 int32_t; 85 | typedef unsigned __int8 uint8_t; 86 | typedef unsigned __int16 uint16_t; 87 | typedef unsigned __int32 uint32_t; 88 | #endif 89 | typedef signed __int64 int64_t; 90 | typedef unsigned __int64 uint64_t; 91 | 92 | 93 | // 7.18.1.2 Minimum-width integer types 94 | typedef int8_t int_least8_t; 95 | typedef int16_t int_least16_t; 96 | typedef int32_t int_least32_t; 97 | typedef int64_t int_least64_t; 98 | typedef uint8_t uint_least8_t; 99 | typedef uint16_t uint_least16_t; 100 | typedef uint32_t uint_least32_t; 101 | typedef uint64_t uint_least64_t; 102 | 103 | // 7.18.1.3 Fastest minimum-width integer types 104 | typedef int8_t int_fast8_t; 105 | typedef int16_t int_fast16_t; 106 | typedef int32_t int_fast32_t; 107 | typedef int64_t int_fast64_t; 108 | typedef uint8_t uint_fast8_t; 109 | typedef uint16_t uint_fast16_t; 110 | typedef uint32_t uint_fast32_t; 111 | typedef uint64_t uint_fast64_t; 112 | 113 | // 7.18.1.4 Integer types capable of holding object pointers 114 | #ifdef _WIN64 // [ 115 | typedef signed __int64 intptr_t; 116 | typedef unsigned __int64 uintptr_t; 117 | #else // _WIN64 ][ 118 | typedef _W64 signed int intptr_t; 119 | typedef _W64 unsigned int uintptr_t; 120 | #endif // _WIN64 ] 121 | 122 | // 7.18.1.5 Greatest-width integer types 123 | typedef int64_t intmax_t; 124 | typedef uint64_t uintmax_t; 125 | 126 | 127 | // 7.18.2 Limits of specified-width integer types 128 | 129 | #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 130 | 131 | // 7.18.2.1 Limits of exact-width integer types 132 | #define INT8_MIN ((int8_t)_I8_MIN) 133 | #define INT8_MAX _I8_MAX 134 | #define INT16_MIN ((int16_t)_I16_MIN) 135 | #define INT16_MAX _I16_MAX 136 | #define INT32_MIN ((int32_t)_I32_MIN) 137 | #define INT32_MAX _I32_MAX 138 | #define INT64_MIN ((int64_t)_I64_MIN) 139 | #define INT64_MAX _I64_MAX 140 | #define UINT8_MAX _UI8_MAX 141 | #define UINT16_MAX _UI16_MAX 142 | #define UINT32_MAX _UI32_MAX 143 | #define UINT64_MAX _UI64_MAX 144 | 145 | // 7.18.2.2 Limits of minimum-width integer types 146 | #define INT_LEAST8_MIN INT8_MIN 147 | #define INT_LEAST8_MAX INT8_MAX 148 | #define INT_LEAST16_MIN INT16_MIN 149 | #define INT_LEAST16_MAX INT16_MAX 150 | #define INT_LEAST32_MIN INT32_MIN 151 | #define INT_LEAST32_MAX INT32_MAX 152 | #define INT_LEAST64_MIN INT64_MIN 153 | #define INT_LEAST64_MAX INT64_MAX 154 | #define UINT_LEAST8_MAX UINT8_MAX 155 | #define UINT_LEAST16_MAX UINT16_MAX 156 | #define UINT_LEAST32_MAX UINT32_MAX 157 | #define UINT_LEAST64_MAX UINT64_MAX 158 | 159 | // 7.18.2.3 Limits of fastest minimum-width integer types 160 | #define INT_FAST8_MIN INT8_MIN 161 | #define INT_FAST8_MAX INT8_MAX 162 | #define INT_FAST16_MIN INT16_MIN 163 | #define INT_FAST16_MAX INT16_MAX 164 | #define INT_FAST32_MIN INT32_MIN 165 | #define INT_FAST32_MAX INT32_MAX 166 | #define INT_FAST64_MIN INT64_MIN 167 | #define INT_FAST64_MAX INT64_MAX 168 | #define UINT_FAST8_MAX UINT8_MAX 169 | #define UINT_FAST16_MAX UINT16_MAX 170 | #define UINT_FAST32_MAX UINT32_MAX 171 | #define UINT_FAST64_MAX UINT64_MAX 172 | 173 | // 7.18.2.4 Limits of integer types capable of holding object pointers 174 | #ifdef _WIN64 // [ 175 | # define INTPTR_MIN INT64_MIN 176 | # define INTPTR_MAX INT64_MAX 177 | # define UINTPTR_MAX UINT64_MAX 178 | #else // _WIN64 ][ 179 | # define INTPTR_MIN INT32_MIN 180 | # define INTPTR_MAX INT32_MAX 181 | # define UINTPTR_MAX UINT32_MAX 182 | #endif // _WIN64 ] 183 | 184 | // 7.18.2.5 Limits of greatest-width integer types 185 | #define INTMAX_MIN INT64_MIN 186 | #define INTMAX_MAX INT64_MAX 187 | #define UINTMAX_MAX UINT64_MAX 188 | 189 | // 7.18.3 Limits of other integer types 190 | 191 | #ifdef _WIN64 // [ 192 | # define PTRDIFF_MIN _I64_MIN 193 | # define PTRDIFF_MAX _I64_MAX 194 | #else // _WIN64 ][ 195 | # define PTRDIFF_MIN _I32_MIN 196 | # define PTRDIFF_MAX _I32_MAX 197 | #endif // _WIN64 ] 198 | 199 | #define SIG_ATOMIC_MIN INT_MIN 200 | #define SIG_ATOMIC_MAX INT_MAX 201 | 202 | #ifndef SIZE_MAX // [ 203 | # ifdef _WIN64 // [ 204 | # define SIZE_MAX _UI64_MAX 205 | # else // _WIN64 ][ 206 | # define SIZE_MAX _UI32_MAX 207 | # endif // _WIN64 ] 208 | #endif // SIZE_MAX ] 209 | 210 | // WCHAR_MIN and WCHAR_MAX are also defined in 211 | #ifndef WCHAR_MIN // [ 212 | # define WCHAR_MIN 0 213 | #endif // WCHAR_MIN ] 214 | #ifndef WCHAR_MAX // [ 215 | # define WCHAR_MAX _UI16_MAX 216 | #endif // WCHAR_MAX ] 217 | 218 | #define WINT_MIN 0 219 | #define WINT_MAX _UI16_MAX 220 | 221 | #endif // __STDC_LIMIT_MACROS ] 222 | 223 | 224 | // 7.18.4 Limits of other integer types 225 | 226 | #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 227 | 228 | // 7.18.4.1 Macros for minimum-width integer constants 229 | 230 | #define INT8_C(val) val##i8 231 | #define INT16_C(val) val##i16 232 | #define INT32_C(val) val##i32 233 | #define INT64_C(val) val##i64 234 | 235 | #define UINT8_C(val) val##ui8 236 | #define UINT16_C(val) val##ui16 237 | #define UINT32_C(val) val##ui32 238 | #define UINT64_C(val) val##ui64 239 | 240 | // 7.18.4.2 Macros for greatest-width integer constants 241 | #define INTMAX_C INT64_C 242 | #define UINTMAX_C UINT64_C 243 | 244 | #endif // __STDC_CONSTANT_MACROS ] 245 | 246 | 247 | #endif // _MSC_STDINT_H_ ] 248 | -------------------------------------------------------------------------------- /faup1090.c: -------------------------------------------------------------------------------- 1 | // Part of dump1090, a Mode S message decoder for RTLSDR devices. 2 | // 3 | // faup1090.c: cut down version that just does 30005 -> 10001 forwarding 4 | // 5 | // Copyright (c) 2014,2015 Oliver Jowett 6 | // 7 | // This file is free software: you may copy, redistribute and/or modify it 8 | // under the terms of the GNU General Public License as published by the 9 | // Free Software Foundation, either version 2 of the License, or (at your 10 | // option) any later version. 11 | // 12 | // This file is distributed in the hope that it will be useful, but 13 | // WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | // General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program. If not, see . 19 | 20 | // This file incorporates work covered by the following copyright and 21 | // permission notice: 22 | // 23 | // Copyright (C) 2012 by Salvatore Sanfilippo 24 | // 25 | // All rights reserved. 26 | // 27 | // Redistribution and use in source and binary forms, with or without 28 | // modification, are permitted provided that the following conditions are 29 | // met: 30 | // 31 | // * Redistributions of source code must retain the above copyright 32 | // notice, this list of conditions and the following disclaimer. 33 | // 34 | // * Redistributions in binary form must reproduce the above copyright 35 | // notice, this list of conditions and the following disclaimer in the 36 | // documentation and/or other materials provided with the distribution. 37 | // 38 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 39 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 40 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 41 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 42 | // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 43 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 44 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 45 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 46 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 47 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 48 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 49 | 50 | #include "dump1090.h" 51 | 52 | #include 53 | #include 54 | 55 | // 56 | // =============================== Initialization =========================== 57 | // 58 | static void faupInitConfig(void) { 59 | // Default everything to zero/NULL 60 | memset(&Modes, 0, sizeof(Modes)); 61 | 62 | // Now initialise things that should not be 0/NULL to their defaults 63 | Modes.nfix_crc = 1; 64 | Modes.check_crc = 1; 65 | Modes.net = 1; 66 | Modes.net_heartbeat_interval = MODES_NET_HEARTBEAT_INTERVAL; 67 | Modes.maxRange = 1852 * 300; // 300NM default max range 68 | Modes.quiet = 1; 69 | Modes.net_output_flush_size = MODES_OUT_FLUSH_SIZE; 70 | Modes.net_output_flush_interval = 200; // milliseconds 71 | } 72 | 73 | // 74 | //========================================================================= 75 | // 76 | static void faupInit(void) { 77 | // Validate the users Lat/Lon home location inputs 78 | if ( (Modes.fUserLat > 90.0) // Latitude must be -90 to +90 79 | || (Modes.fUserLat < -90.0) // and 80 | || (Modes.fUserLon > 360.0) // Longitude must be -180 to +360 81 | || (Modes.fUserLon < -180.0) ) { 82 | Modes.fUserLat = Modes.fUserLon = 0.0; 83 | } else if (Modes.fUserLon > 180.0) { // If Longitude is +180 to +360, make it -180 to 0 84 | Modes.fUserLon -= 360.0; 85 | } 86 | // If both Lat and Lon are 0.0 then the users location is either invalid/not-set, or (s)he's in the 87 | // Atlantic ocean off the west coast of Africa. This is unlikely to be correct. 88 | // Set the user LatLon valid flag only if either Lat or Lon are non zero. Note the Greenwich meridian 89 | // is at 0.0 Lon,so we must check for either fLat or fLon being non zero not both. 90 | // Testing the flag at runtime will be much quicker than ((fLon != 0.0) || (fLat != 0.0)) 91 | Modes.bUserFlags &= ~MODES_USER_LATLON_VALID; 92 | if ((Modes.fUserLat != 0.0) || (Modes.fUserLon != 0.0)) { 93 | Modes.bUserFlags |= MODES_USER_LATLON_VALID; 94 | } 95 | 96 | // Prepare error correction tables 97 | modesChecksumInit(1); 98 | icaoFilterInit(); 99 | } 100 | 101 | // 102 | // ================================ Main ==================================== 103 | // 104 | static void showHelp(void) { 105 | printf( 106 | "-----------------------------------------------------------------------------\n" 107 | "| faup1090 ModeS conversion %45s |\n" 108 | "-----------------------------------------------------------------------------\n" 109 | "--net-bind-address IP address to bind to (default: Any; Use 127.0.0.1 for private)\n" 110 | "--net-bo-ipaddr IP address to connect to for Beast data (default: 127.0.0.1)\n" 111 | "--net-bo-port Port to connect for Beast data (default: 30005)\n" 112 | "--net-fatsv-port FlightAware TSV output port (default: 10001)\n" 113 | "--lat Reference/receiver latitude for surface posn (opt)\n" 114 | "--lon Reference/receiver longitude for surface posn (opt)\n" 115 | "--max-range Absolute maximum range for position decoding (in nm, default: 300)\n" 116 | "--help Show this help\n" 117 | "\n", 118 | MODES_DUMP1090_VARIANT " " MODES_DUMP1090_VERSION 119 | ); 120 | } 121 | 122 | // 123 | //========================================================================= 124 | // 125 | // This function is called a few times every second by main in order to 126 | // perform tasks we need to do continuously, like accepting new clients 127 | // from the net, refreshing the screen in interactive mode, and so forth 128 | // 129 | static void backgroundTasks(void) { 130 | icaoFilterExpire(); 131 | trackPeriodicUpdate(); 132 | modesNetPeriodicWork(); 133 | } 134 | 135 | // 136 | //========================================================================= 137 | // 138 | int main(int argc, char **argv) { 139 | int j; 140 | char *bo_connect_ipaddr = "127.0.0.1"; 141 | int bo_connect_port = MODES_NET_OUTPUT_BEAST_PORT; 142 | struct client *c; 143 | struct net_service *beast_input, *fatsv_output; 144 | 145 | // Set sane defaults 146 | faupInitConfig(); 147 | 148 | // Parse the command line options 149 | for (j = 1; j < argc; j++) { 150 | int more = j+1 < argc; // There are more arguments 151 | 152 | if (!strcmp(argv[j],"--net-bo-port") && more) { 153 | bo_connect_port = atoi(argv[++j]); 154 | } else if (!strcmp(argv[j],"--net-bo-ipaddr") && more) { 155 | bo_connect_ipaddr = argv[++j]; 156 | } else if (!strcmp(argv[j],"--lat") && more) { 157 | Modes.fUserLat = atof(argv[++j]); 158 | } else if (!strcmp(argv[j],"--lon") && more) { 159 | Modes.fUserLon = atof(argv[++j]); 160 | } else if (!strcmp(argv[j],"--max-range") && more) { 161 | Modes.maxRange = atof(argv[++j]) * 1852.0; // convert to metres 162 | } else if (!strcmp(argv[j],"--help")) { 163 | showHelp(); 164 | exit(0); 165 | } else { 166 | fprintf(stderr, 167 | "Unknown or not enough arguments for option '%s'.\n\n", 168 | argv[j]); 169 | showHelp(); 170 | exit(1); 171 | } 172 | } 173 | 174 | // Initialization 175 | faupInit(); 176 | modesInitNet(); 177 | 178 | // Set up input connection 179 | beast_input = makeBeastInputService(); 180 | c = serviceConnect(beast_input, bo_connect_ipaddr, bo_connect_port); 181 | if (!c) { 182 | fprintf (stderr, 183 | "faup1090: failed to connect to %s:%d (is dump1090 running?): %s\n", 184 | bo_connect_ipaddr, bo_connect_port, Modes.aneterr); 185 | exit (1); 186 | } 187 | 188 | // Set up output connection on stdout 189 | fatsv_output = makeFatsvOutputService(); 190 | createGenericClient(fatsv_output, STDOUT_FILENO); 191 | 192 | // Run it until we've lost either connection 193 | while (!Modes.exit && beast_input->connections && fatsv_output->connections) { 194 | backgroundTasks(); 195 | usleep(100000); 196 | } 197 | 198 | return 0; 199 | } 200 | // 201 | //========================================================================= 202 | // 203 | -------------------------------------------------------------------------------- /view1090.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Template 14 | Win32 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | Application 24 | 25 | 26 | Application 27 | false 28 | MultiByte 29 | 30 | 31 | Application 32 | false 33 | MultiByte 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | .\Release\ 52 | .\Release\ 53 | false 54 | 55 | 56 | .\Debug\ 57 | .\Debug\ 58 | true 59 | 60 | 61 | 62 | MultiThreaded 63 | OnlyExplicitInline 64 | true 65 | true 66 | MaxSpeed 67 | true 68 | Level3 69 | .\inttypes\.;.\endian\.;.\pthread\.;.\rtlsdr\.;.\winposixclock\.;%(AdditionalIncludeDirectories) 70 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 71 | .\Release\ 72 | true 73 | .\Release\view1090.pch 74 | 75 | 76 | .\Release\ 77 | .\Release\ 78 | 4996;4005;4244 79 | 80 | 81 | .\Release\view1090.tlb 82 | 83 | 84 | 0x0809 85 | NDEBUG;%(PreprocessorDefinitions) 86 | 87 | 88 | true 89 | .\Release\view1090.bsc 90 | 91 | 92 | true 93 | Console 94 | .\Release\view1090.exe 95 | odbc32.lib;odbccp32.lib;ws2_32.lib;.\winposixclock\winposixclock.lib;%(AdditionalDependencies) 96 | 97 | 98 | 99 | 100 | MultiThreadedDebug 101 | Default 102 | false 103 | Disabled 104 | true 105 | Level3 106 | true 107 | EditAndContinue 108 | .\inttypes\.;.\endian\.;.\pthread\.;.\winposixclock\.;.\rtlsdr\.;%(AdditionalIncludeDirectories) 109 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 110 | .\Debug\ 111 | true 112 | .\Debug\view1090.pch 113 | 114 | 115 | .\Debug\ 116 | .\Debug\ 117 | EnableFastChecks 118 | 119 | 120 | .\Debug\view1090.tlb 121 | 122 | 123 | 0x0809 124 | _DEBUG;%(PreprocessorDefinitions) 125 | 126 | 127 | true 128 | .\Debug\view1090.bsc 129 | 130 | 131 | true 132 | true 133 | Console 134 | .\Debug\view1090.exe 135 | odbc32.lib;odbccp32.lib;ws2_32.lib;.\winposixclock\winposixclock.lib;%(AdditionalDependencies) 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | -------------------------------------------------------------------------------- /README-json.md: -------------------------------------------------------------------------------- 1 | # JSON output formats 2 | 3 | dump1090 generates several json files with informaton about the receiver itself, currently known aircraft, 4 | and general statistics. These are used by the webmap, but could also be used by other things 5 | e.g. [this collectd plugin](https://github.com/mutability/dump1090-tools/tree/master/collectd) feeds stats 6 | about dump1090's operation to collectd for later graphing. 7 | 8 | ## Reading the json files 9 | 10 | There are two ways to obtain the json files: 11 | 12 | * By HTTP from dump1090's internal webserver, which defaults to running on port 8080. The json is served from the data/ path, e.g. http://somehost:8080/data/aircraft.json 13 | * As a file in the directory specified by --write-json on dump1090's command line. These can be exposed via a 14 | separate webserver. 15 | 16 | The HTTP versions are always up to date. 17 | The file versions are written periodically; for aircraft, typically once a second, for stats, once a minute. 18 | The file versions are updated to a temporary file, then atomically renamed to the right path, so you should never see partial copies. 19 | 20 | Each file contains a single JSON object. The file formats are: 21 | 22 | ## receiver.json 23 | 24 | This file has general metadata about dump1090. It does not change often and you probably just want to read it once at startup. 25 | The keys are: 26 | 27 | * version: the version of dump1090 in use 28 | * refresh: how often aircraft.json is updated (for the file version), in milliseconds. the webmap uses this to control its refresh interval. 29 | * history: the current number of valid history files (see below) 30 | * lat: the latitude of the receiver in decimal degrees. Optional, may not be present. 31 | * lon: the longitude of the receiver in decimal degrees. Optional, may not be present. 32 | 33 | ## aircraft.json 34 | 35 | This file contains dump1090's list of recently seen aircraft. The keys are: 36 | 37 | * now: the time this file was generated, in seconds since Jan 1 1970 00:00:00 GMT (the Unix epoch). 38 | * messages: the total number of Mode S messages processed since dump1090 started. 39 | * aircraft: an array of JSON objects, one per known aircraft. Each aircraft has the following keys. Keys will be omitted if data is not available. 40 | * hex: the 24-bit ICAO identifier of the aircraft, as 6 hex digits. The identifier may start with '~', this means that the address is a non-ICAO address (e.g. from TIS-B). 41 | * squawk: the 4-digit squawk (octal representation) 42 | * flight: the flight name / callsign 43 | * lat, lon: the aircraft position in decimal degrees 44 | * nucp: the NUCp (navigational uncertainty category) reported for the position 45 | * seen_pos: how long ago (in seconds before "now") the position was last updated 46 | * altitude: the aircraft altitude in feet, or "ground" if it is reporting it is on the ground 47 | * vert_rate: vertical rate in feet/minute 48 | * track: true track over ground in degrees (0-359) 49 | * speed: reported speed in kt. This is usually speed over ground, but might be IAS - you can't tell the difference here, sorry! 50 | * messages: total number of Mode S messages received from this aircraft 51 | * seen: how long ago (in seconds before "now") a message was last received from this aircraft 52 | * rssi: recent average RSSI (signal power), in dbFS; this will always be negative. 53 | 54 | ## history_0.json, history_1.json, ..., history_119.json 55 | 56 | These files are historical copies of aircraft.json at (by default) 30 second intervals. They follow exactly the 57 | same format as aircraft.json. To know how many are valid, see receiver.json ("history" value). They are written in 58 | a cycle, with history_0 being overwritten after history_119 is generated, so history_0.json is not necessarily the 59 | oldest history entry. To load history, you should: 60 | 61 | * read "history" from receiver.json. 62 | * load that many history_N.json files 63 | * sort the resulting files by their "now" values 64 | * process the files in order 65 | 66 | ## stats.json 67 | 68 | This file contains statistics about dump1090's operations. 69 | 70 | There are 5 top level keys: "latest", "last1min", "last5min", "last15min", "total". Each key has statistics for a different period, defined by the "start" and "end" subkeys: 71 | 72 | * "total" covers the entire period from when dump1090 was started up to the current time 73 | * "last1min" covers a recent 1-minute period. This may be up to 1 minute out of date (i.e. "end" may be up to 1 minute old). 74 | * "last5min" covers a recent 5-minute period. As above, this may be up to 1 minute out of date. 75 | * "last15min" covers a recent 15-minute period. As above, this may be up to 1 minute out of date. 76 | * "latest" covers the time between the end of the "last1min" period and the current time. 77 | 78 | Internally, live stats are collected into "latest". Once a minute, "latest" is copied to "last1min" and "latest" is reset. Then "last5min" and "last15min" are recalculated from a history of the last 5 or 15 1-minute periods. 79 | 80 | Each period has the following subkeys: 81 | 82 | * start: the start time (in seconds-since-1-Jan-1970) of this statistics collection period. 83 | * end: the end time (in seconds-since-1-Jan-1970) of this statistics collection period. 84 | * local: statistics about messages received from a local SDR dongle. Not present in --net-only mode. Has subkeys: 85 | * blocks_processed: number of sample blocks processed 86 | * blocks_dropped: number of sample blocks dropped before processing. A nonzero value means CPU overload. 87 | * modeac: number of Mode A / C messages decoded 88 | * modes: number of Mode S preambles received. This is *not* the number of valid messages! 89 | * bad: number of Mode S preambles that didn't result in a valid message 90 | * unknown_icao: number of Mode S preambles which looked like they might be valid but we didn't recognize the ICAO address and it was one of the message types where we can't be sure it's valid in this case. 91 | * accepted: array. Index N has the number of valid Mode S messages accepted with N-bit errors corrected. 92 | * signal: mean signal power of successfully received messages, in dbFS; always negative. 93 | * peak_signal: peak signal power of a successfully received message, in dbFS; always negative. 94 | * strong_signals: number of messages received that had a signal power above -3dBFS. 95 | * remote: statistics about messages received from remote clients. Only present in --net or --net-only mode. Has subkeys: 96 | * modeac: number of Mode A / C messages received. 97 | * modes: number of Mode S messages received. 98 | * bad: number of Mode S messages that had bad CRC or were otherwise invalid. 99 | * unknown_icao: number of Mode S messages which looked like they might be valid but we didn't recognize the ICAO address and it was one of the message types where we can't be sure it's valid in this case. 100 | * accepted: array. Index N has the number of valid Mode S messages accepted with N-bit errors corrected. 101 | * http_requests: number of HTTP requests handled. 102 | * cpu: statistics about CPU use. Has subkeys: 103 | * demod: milliseconds spent doing demodulation and decoding in response to data from a SDR dongle 104 | * reader: milliseconds spent reading sample data over USB from a SDR dongle 105 | * background: milliseconds spent doing network I/O, processing received network messages, and periodic tasks. 106 | * cpr: statistics about Compact Position Report message decoding. Has subkeys: 107 | * surface: total number of surface CPR messages received 108 | * airborne: total number of airborne CPR messages received 109 | * global_ok: global positions successfuly derived 110 | * global_bad: global positions that were rejected because they were inconsistent 111 | * global_range: global positions that were rejected because they exceeded the receiver max range 112 | * global_speed: global positions that were rejected because they failed the inter-position speed check 113 | * global_skipped: global position attempts skipped because we did not have the right data (e.g. even/odd messages crossed a zone boundary) 114 | * local_ok: local (relative) positions successfully found 115 | * local_aircraft_relative: local positions found relative to a previous aircraft position 116 | * local_receiver_relative: local positions found relative to the receiver position 117 | * local_skipped: local (relative) positions not used because we did not have the right data 118 | * local_range: local positions not used because they exceeded the receiver max range or fell into the ambiguous part of the receiver range 119 | * local_speed: local positions not used because they failed the inter-position speed check 120 | * filtered: number of CPR messages ignored because they matched one of the heuristics for faulty transponder output 121 | * tracks: statistics on aircraft tracks. Each track represents a unique aircraft and persists for up to 5 minutes after the last message 122 | from the aircraft is heard. If messages from the same aircraft are subsequently heard after the 5 minute period, this will be counted 123 | as a new track. 124 | * all: total tracks created 125 | * single_message: tracks consisting of only a single message. These are usually due to message decoding errors that produce a bad aircraft address. 126 | * messages: total number of messages accepted by dump1090 from any source 127 | -------------------------------------------------------------------------------- /dump1090.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | Application 20 | false 21 | MultiByte 22 | 23 | 24 | Application 25 | false 26 | MultiByte 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | .\Release\ 42 | .\Release\ 43 | false 44 | 45 | 46 | .\Debug\ 47 | .\Debug\ 48 | true 49 | 50 | 51 | 52 | MultiThreaded 53 | Default 54 | true 55 | true 56 | Full 57 | true 58 | Level3 59 | .\winposixclock\.;.\endian\.;.\inttypes\.;.\rtlsdr\.;.\pthread\.;%(AdditionalIncludeDirectories) 60 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 61 | .\Release\ 62 | true 63 | .\Release\dump1090.pch 64 | 65 | 66 | .\Release\ 67 | .\Release\ 68 | 4996;4005;4244 69 | 70 | 71 | .\Release\dump1090.tlb 72 | 73 | 74 | 0x0809 75 | NDEBUG;%(PreprocessorDefinitions) 76 | 77 | 78 | true 79 | .\Release\dump1090.bsc 80 | 81 | 82 | true 83 | Console 84 | ./release/dump1090.exe 85 | ws2_32.lib;.\winposixclock\winposixclock.lib;.\pthread\pthreadVC2.lib;.\rtlsdr\rtlsdr_static.lib;%(AdditionalDependencies) 86 | false 87 | 88 | 89 | 90 | 91 | MultiThreadedDebug 92 | Default 93 | false 94 | Disabled 95 | true 96 | Level3 97 | true 98 | EditAndContinue 99 | .\winposixclock\.;.\endian\.;.\inttypes\.;.\rtlsdr\.;.\pthread\.;%(AdditionalIncludeDirectories) 100 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 101 | .\Debug\ 102 | true 103 | .\Debug\dump1090.pch 104 | 105 | 106 | .\Debug\ 107 | .\Debug\ 108 | EnableFastChecks 109 | 4996;4005;4244 110 | 111 | 112 | .\Debug\dump1090.tlb 113 | 114 | 115 | 0x0809 116 | _DEBUG;%(PreprocessorDefinitions) 117 | 118 | 119 | true 120 | .\Debug\dump1090.bsc 121 | 122 | 123 | true 124 | true 125 | Console 126 | .\Debug\dump1090.exe 127 | ws2_32.lib;.\winposixclock\winposixclock.lib;.\pthread\pthreadVC2.lib;.\rtlsdr\rtlsdr_static.lib;%(AdditionalDependencies) 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | -------------------------------------------------------------------------------- /inttypes/inttypes.h: -------------------------------------------------------------------------------- 1 | // ISO C9x compliant inttypes.h for Microsoft Visual Studio 2 | // Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 3 | // 4 | // Copyright (c) 2006 Alexander Chemeris 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // 1. Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // 2. Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // 16 | // 3. The name of the author may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 20 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | /////////////////////////////////////////////////////////////////////////////// 31 | 32 | #ifndef _MSC_VER // [ 33 | #error "Use this header only with Microsoft Visual C++ compilers!" 34 | #endif // _MSC_VER ] 35 | 36 | #ifndef _MSC_INTTYPES_H_ // [ 37 | #define _MSC_INTTYPES_H_ 38 | 39 | #if _MSC_VER > 1000 40 | #pragma once 41 | #endif 42 | 43 | #include "stdint.h" 44 | 45 | // 7.8 Format conversion of integer types 46 | 47 | typedef struct { 48 | intmax_t quot; 49 | intmax_t rem; 50 | } imaxdiv_t; 51 | 52 | // 7.8.1 Macros for format specifiers 53 | 54 | #if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198 55 | 56 | // The fprintf macros for signed integers are: 57 | #define PRId8 "d" 58 | #define PRIi8 "i" 59 | #define PRIdLEAST8 "d" 60 | #define PRIiLEAST8 "i" 61 | #define PRIdFAST8 "d" 62 | #define PRIiFAST8 "i" 63 | 64 | #define PRId16 "hd" 65 | #define PRIi16 "hi" 66 | #define PRIdLEAST16 "hd" 67 | #define PRIiLEAST16 "hi" 68 | #define PRIdFAST16 "hd" 69 | #define PRIiFAST16 "hi" 70 | 71 | #define PRId32 "I32d" 72 | #define PRIi32 "I32i" 73 | #define PRIdLEAST32 "I32d" 74 | #define PRIiLEAST32 "I32i" 75 | #define PRIdFAST32 "I32d" 76 | #define PRIiFAST32 "I32i" 77 | 78 | #define PRId64 "I64d" 79 | #define PRIi64 "I64i" 80 | #define PRIdLEAST64 "I64d" 81 | #define PRIiLEAST64 "I64i" 82 | #define PRIdFAST64 "I64d" 83 | #define PRIiFAST64 "I64i" 84 | 85 | #define PRIdMAX "I64d" 86 | #define PRIiMAX "I64i" 87 | 88 | #define PRIdPTR "Id" 89 | #define PRIiPTR "Ii" 90 | 91 | // The fprintf macros for unsigned integers are: 92 | #define PRIo8 "o" 93 | #define PRIu8 "u" 94 | #define PRIx8 "x" 95 | #define PRIX8 "X" 96 | #define PRIoLEAST8 "o" 97 | #define PRIuLEAST8 "u" 98 | #define PRIxLEAST8 "x" 99 | #define PRIXLEAST8 "X" 100 | #define PRIoFAST8 "o" 101 | #define PRIuFAST8 "u" 102 | #define PRIxFAST8 "x" 103 | #define PRIXFAST8 "X" 104 | 105 | #define PRIo16 "ho" 106 | #define PRIu16 "hu" 107 | #define PRIx16 "hx" 108 | #define PRIX16 "hX" 109 | #define PRIoLEAST16 "ho" 110 | #define PRIuLEAST16 "hu" 111 | #define PRIxLEAST16 "hx" 112 | #define PRIXLEAST16 "hX" 113 | #define PRIoFAST16 "ho" 114 | #define PRIuFAST16 "hu" 115 | #define PRIxFAST16 "hx" 116 | #define PRIXFAST16 "hX" 117 | 118 | #define PRIo32 "I32o" 119 | #define PRIu32 "I32u" 120 | #define PRIx32 "I32x" 121 | #define PRIX32 "I32X" 122 | #define PRIoLEAST32 "I32o" 123 | #define PRIuLEAST32 "I32u" 124 | #define PRIxLEAST32 "I32x" 125 | #define PRIXLEAST32 "I32X" 126 | #define PRIoFAST32 "I32o" 127 | #define PRIuFAST32 "I32u" 128 | #define PRIxFAST32 "I32x" 129 | #define PRIXFAST32 "I32X" 130 | 131 | #define PRIo64 "I64o" 132 | #define PRIu64 "I64u" 133 | #define PRIx64 "I64x" 134 | #define PRIX64 "I64X" 135 | #define PRIoLEAST64 "I64o" 136 | #define PRIuLEAST64 "I64u" 137 | #define PRIxLEAST64 "I64x" 138 | #define PRIXLEAST64 "I64X" 139 | #define PRIoFAST64 "I64o" 140 | #define PRIuFAST64 "I64u" 141 | #define PRIxFAST64 "I64x" 142 | #define PRIXFAST64 "I64X" 143 | 144 | #define PRIoMAX "I64o" 145 | #define PRIuMAX "I64u" 146 | #define PRIxMAX "I64x" 147 | #define PRIXMAX "I64X" 148 | 149 | #define PRIoPTR "Io" 150 | #define PRIuPTR "Iu" 151 | #define PRIxPTR "Ix" 152 | #define PRIXPTR "IX" 153 | 154 | // The fscanf macros for signed integers are: 155 | #define SCNd8 "d" 156 | #define SCNi8 "i" 157 | #define SCNdLEAST8 "d" 158 | #define SCNiLEAST8 "i" 159 | #define SCNdFAST8 "d" 160 | #define SCNiFAST8 "i" 161 | 162 | #define SCNd16 "hd" 163 | #define SCNi16 "hi" 164 | #define SCNdLEAST16 "hd" 165 | #define SCNiLEAST16 "hi" 166 | #define SCNdFAST16 "hd" 167 | #define SCNiFAST16 "hi" 168 | 169 | #define SCNd32 "ld" 170 | #define SCNi32 "li" 171 | #define SCNdLEAST32 "ld" 172 | #define SCNiLEAST32 "li" 173 | #define SCNdFAST32 "ld" 174 | #define SCNiFAST32 "li" 175 | 176 | #define SCNd64 "I64d" 177 | #define SCNi64 "I64i" 178 | #define SCNdLEAST64 "I64d" 179 | #define SCNiLEAST64 "I64i" 180 | #define SCNdFAST64 "I64d" 181 | #define SCNiFAST64 "I64i" 182 | 183 | #define SCNdMAX "I64d" 184 | #define SCNiMAX "I64i" 185 | 186 | #ifdef _WIN64 // [ 187 | # define SCNdPTR "I64d" 188 | # define SCNiPTR "I64i" 189 | #else // _WIN64 ][ 190 | # define SCNdPTR "ld" 191 | # define SCNiPTR "li" 192 | #endif // _WIN64 ] 193 | 194 | // The fscanf macros for unsigned integers are: 195 | #define SCNo8 "o" 196 | #define SCNu8 "u" 197 | #define SCNx8 "x" 198 | #define SCNX8 "X" 199 | #define SCNoLEAST8 "o" 200 | #define SCNuLEAST8 "u" 201 | #define SCNxLEAST8 "x" 202 | #define SCNXLEAST8 "X" 203 | #define SCNoFAST8 "o" 204 | #define SCNuFAST8 "u" 205 | #define SCNxFAST8 "x" 206 | #define SCNXFAST8 "X" 207 | 208 | #define SCNo16 "ho" 209 | #define SCNu16 "hu" 210 | #define SCNx16 "hx" 211 | #define SCNX16 "hX" 212 | #define SCNoLEAST16 "ho" 213 | #define SCNuLEAST16 "hu" 214 | #define SCNxLEAST16 "hx" 215 | #define SCNXLEAST16 "hX" 216 | #define SCNoFAST16 "ho" 217 | #define SCNuFAST16 "hu" 218 | #define SCNxFAST16 "hx" 219 | #define SCNXFAST16 "hX" 220 | 221 | #define SCNo32 "lo" 222 | #define SCNu32 "lu" 223 | #define SCNx32 "lx" 224 | #define SCNX32 "lX" 225 | #define SCNoLEAST32 "lo" 226 | #define SCNuLEAST32 "lu" 227 | #define SCNxLEAST32 "lx" 228 | #define SCNXLEAST32 "lX" 229 | #define SCNoFAST32 "lo" 230 | #define SCNuFAST32 "lu" 231 | #define SCNxFAST32 "lx" 232 | #define SCNXFAST32 "lX" 233 | 234 | #define SCNo64 "I64o" 235 | #define SCNu64 "I64u" 236 | #define SCNx64 "I64x" 237 | #define SCNX64 "I64X" 238 | #define SCNoLEAST64 "I64o" 239 | #define SCNuLEAST64 "I64u" 240 | #define SCNxLEAST64 "I64x" 241 | #define SCNXLEAST64 "I64X" 242 | #define SCNoFAST64 "I64o" 243 | #define SCNuFAST64 "I64u" 244 | #define SCNxFAST64 "I64x" 245 | #define SCNXFAST64 "I64X" 246 | 247 | #define SCNoMAX "I64o" 248 | #define SCNuMAX "I64u" 249 | #define SCNxMAX "I64x" 250 | #define SCNXMAX "I64X" 251 | 252 | #ifdef _WIN64 // [ 253 | # define SCNoPTR "I64o" 254 | # define SCNuPTR "I64u" 255 | # define SCNxPTR "I64x" 256 | # define SCNXPTR "I64X" 257 | #else // _WIN64 ][ 258 | # define SCNoPTR "lo" 259 | # define SCNuPTR "lu" 260 | # define SCNxPTR "lx" 261 | # define SCNXPTR "lX" 262 | #endif // _WIN64 ] 263 | 264 | #endif // __STDC_FORMAT_MACROS ] 265 | 266 | // 7.8.2 Functions for greatest-width integer types 267 | 268 | // 7.8.2.1 The imaxabs function 269 | #define imaxabs _abs64 270 | 271 | // 7.8.2.2 The imaxdiv function 272 | 273 | // This is modified version of div() function from Microsoft's div.c found 274 | // in %MSVC.NET%\crt\src\div.c 275 | #ifdef STATIC_IMAXDIV // [ 276 | static 277 | #else // STATIC_IMAXDIV ][ 278 | _inline 279 | #endif // STATIC_IMAXDIV ] 280 | imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom) 281 | { 282 | imaxdiv_t result; 283 | 284 | result.quot = numer / denom; 285 | result.rem = numer % denom; 286 | 287 | if (numer < 0 && result.rem > 0) { 288 | // did division wrong; must fix up 289 | ++result.quot; 290 | result.rem -= denom; 291 | } 292 | 293 | return result; 294 | } 295 | 296 | // 7.8.2.3 The strtoimax and strtoumax functions 297 | #define strtoimax _strtoi64 298 | #define strtoumax _strtoui64 299 | 300 | // 7.8.2.4 The wcstoimax and wcstoumax functions 301 | #define wcstoimax _wcstoi64 302 | #define wcstoumax _wcstoui64 303 | 304 | 305 | #endif // _MSC_INTTYPES_H_ ] 306 | --------------------------------------------------------------------------------