Commit graph

296 commits

Author SHA1 Message Date
Oliver Jowett e02a2cdd44 GPL. 2015-01-20 16:49:01 +00:00
Oliver Jowett f753c2d9fe Separate 2.4MHz demodulator into its own file. 2015-01-19 23:50:25 +00:00
Oliver Jowett a6542b505b Separate out 2MHz demodulator + support functions to a separate file. 2015-01-19 23:47:51 +00:00
Oliver Jowett 971e5754ff Try to work around a libusb crash on exit after SIGINT. 2015-01-17 19:23:57 +00:00
Oliver Jowett e68949bdb3 Write an accurate value for the history count, so the progress bar is correct.
(cherry picked from commit 0919700293e34f5a93a4407d33e1e56c0ae0d13c)
2015-01-16 20:33:40 +00:00
Oliver Jowett 1db63ebc65 Add generation of history JSON.
Add support for URL handlers that match a path prefix.

(cherry picked from commit 38faa510cb881cbf9d2a0a85bbde61130b5259e7)
2015-01-16 20:31:59 +00:00
Oliver Jowett b1bfb4d520 Rationalization of JSON output. Pass actual URL path to URL handler.
(cherry picked from commit becce8d69a6e6cee38d4fdb78b5a4e25d570baea)
2015-01-16 20:30:41 +00:00
Oliver Jowett 10c372f528 Display stats on exit in --net-only mode.
(cherry picked from commit ec252d77deb2b345a8561cba13965d5ef8ab0a83)
2015-01-16 20:27:48 +00:00
Oliver Jowett e701f883b3 Do tuner gain setting properly.
(cherry picked from commit c06a537c8143af8e363fde677043053cefff1612)
2015-01-16 20:25:45 +00:00
Oliver Jowett 62ec7796d0 Require that the JSON refresh interval is at least 1, as it is used
to control the webmap refresh rate even if JSON files are not being written.
2015-01-14 01:15:54 +00:00
Oliver Jowett 72bfc31458 Display message rate (30 sec average) on the webmap.
(cherry picked from commit 848af78be685c6e2a26d0b30e9f385696201a2c4)
2015-01-13 22:01:53 +00:00
Oliver Jowett fefce7b4bd Add --max-range parameter. Use it for relative position limits, and to discard bad position results.
(cherry picked from commit 0d725508f78cb2fd7759efbb66b45b867d6f7722)
2015-01-13 21:53:12 +00:00
Oliver Jowett 165f98a567 Fix hanging exit on control-C.
(cherry picked from commit e6f8283946cc3150bcba2d8b3cbab11f5d509308)
2015-01-13 21:37:45 +00:00
Oliver Jowett f72fc3dbee Fix a couple of problems found by valgrind. 2015-01-12 00:56:51 +00:00
Oliver Jowett 43ec58c78e Remove dead tracking code related to the removed PlanePlotter feed. 2015-01-04 20:09:38 +00:00
Oliver Jowett 76474f58ab Fix warnings. Add -Werror so they break the build in future. 2015-01-04 20:08:33 +00:00
Oliver Jowett 85eee61358 Oops, one unsaved file. 2015-01-02 22:34:35 +00:00
Oliver Jowett 07bc762055 Notice if we lose the RTLSDR device and reconnect.
Fix some of the more glaring pthread bugs.
2015-01-02 22:29:29 +00:00
Oliver Jowett 2db9d62c1c Warn if --modeac is used together with --oversample. 2014-12-27 21:25:32 +00:00
Oliver Jowett 727a59e8eb Oversampling is now less scary. 2014-12-27 21:22:43 +00:00
Oliver Jowett 58dfbdcb6b Add support for controlling the accuracy of the receiver location
written in the JSON metadata used by the webmap.
2014-12-27 20:52:56 +00:00
Oliver Jowett fc45eded0b Removing COAA/PlanePlotter stuff (+ binary-only object file) that I can't support or test. 2014-12-27 20:16:56 +00:00
Oliver Jowett 48986c48cc Remove half-implemented --no-decode option. 2014-12-27 20:11:10 +00:00
Oliver Jowett 9fa09e0e92 receiver.json support, internal webserver cleanup.
Add data/receiver.json (generated once) and support for it in script.js.

Internal webserver rearrangement to support multiple json files.
2014-12-10 17:05:22 +00:00
Oliver Jowett f707f2cdce More version reporting tweaks. 2014-12-10 12:44:00 +00:00
Oliver Jowett c6077b1e6c Use the package version as the version number compiled into the binary. 2014-12-10 12:25:43 +00:00
Oliver Jowett 2dcc8e3524 Add direct support for FATSV-format output.
This is adapted from the FlightAware fork, with some cleanup and
modifications needed to work with the net-cleanup changes.

Inclusion of "verbatim" TSV data read from an AVR-format input
connection is not supported.
2014-12-08 19:56:45 +00:00
Oliver Jowett 9e72eb64be Merge branch 'write-json-files' into oversampling 2014-11-23 17:22:58 +00:00
Oliver Jowett 2abc386895 Off-by-one error in the json interval calculation. 2014-11-23 17:22:34 +00:00
Oliver Jowett e0bc89e542 Merge branch 'write-json-files' into oversampling 2014-11-23 16:34:18 +00:00
Oliver Jowett d0174994cb Fix path buffer size 2014-11-23 16:32:22 +00:00
Oliver Jowett 7bd2ee5510 Merge branch 'write-json-files' into oversampling
Conflicts:
	dump1090.c
	dump1090.h
2014-11-23 16:03:35 +00:00
Oliver Jowett 6910a4bf4d Experimental json changes 2014-11-23 16:02:11 +00:00
Oliver Jowett 8246df8b2d Merge branch 'master' into oversampling 2014-10-31 19:42:15 +00:00
Oliver Jowett bbd5a13030 Merge branch 'net-cleanups' 2014-10-31 19:38:06 +00:00
Oliver Jowett 29d1e53f9f Merge remote-tracking branch 'upstream/master' into net-cleanups 2014-10-31 17:58:03 +00:00
Malcolm Robb a9cd75ded1 More Updates to Pull #54
Pull #54 breaks the Windows version of dump1090 due to a bug in the
inet_aton() windows function.

1) Fix the bug in the windows inet_aton()
2) Modify the command line code to strdup() the command line string.
3) Leave the Modes.net_bind_address pointer NULL if no command line
specified
2014-10-30 12:06:03 +00:00
demonx 5b4d811c7d Ability to assign bind address for services 2014-10-25 21:33:45 +02:00
Oliver Jowett cd3efe2d63 Merge branch 'net-cleanups'
Conflicts:
	dump1090.c
2014-10-03 23:15:06 +01:00
Oliver Jowett 22f2a8db37 Merge branch 'net-cleanups' into oversampling
Conflicts:
	dump1090.c
	dump1090.h
2014-10-03 23:04:09 +01:00
Oliver Jowett 1769ac9006 Restructuring of network output side.
Mostly refactoring the common code that was duplicated
between the different output types so that there aren't
many copies floating around.

This introduces "struct net_writer" to store the state of a
particular type of output service - buffers, time of last write,
connection count etc. prepareWrite() / completeWrite() give access
to the buffer and handle the actual writes and flushing when needed.

Heartbeat and time-based flushing move into a generic periodic-work
function.

Update the SBS output code to use the new infrastructure. This makes
a big different to CPU use when under load.
2014-10-03 22:55:21 +01:00
Oliver Jowett 8d4f1a396c Merge branch 'fix-net-list-corruption' into net-cleanups 2014-10-03 20:58:52 +01:00
Oliver Jowett 4a4fed2b37 Merge branch 'fix-net-list-corruption' into oversampling 2014-10-02 21:18:50 +01:00
Oliver Jowett 1cf0097dac Merge branch 'fix-net-list-corruption' 2014-10-02 21:18:35 +01:00
Oliver Jowett a2f49f2bb8 Fix a crash when an outbound client is closed in response to reading a remote message.
When we read from some client A, we may end up forwarding a message to other
clients. If we forward to some client B and there is a write error, then
we close B and remove it from the client list. However, if before this happened
A->next == B, then the read loop will still be holding on to a pointer to B,
and we crash.

As it's unpredictable what clients could be closed at what point, the simplest
approach is to retain closed clients in the list until we are at a point where
we know there are no stray pointers on stack, and only then modify the list.
This also simplifies anything that has to loop over clients, as it doesn't need
to worry about the current client being freed under it.
2014-10-02 21:06:10 +01:00
MalcolmRobb bc496fbcad Merge pull request #43 from mutability/more-stats
Add --stats-every option, add sample block counters
2014-10-02 20:51:13 +01:00
Oliver Jowett e008f0fc3f Resync with master. 2014-10-01 12:44:07 +01:00
Oliver Jowett 622b158367 Merge branches 'fix-obinary', 'net-client-eof-handling' and 'report-bind-errors' 2014-10-01 12:41:28 +01:00
Oliver Jowett 98c7c73d06 Only use O_BINARY on Win32 2014-10-01 12:17:51 +01:00
Oliver Jowett 9691e7bf79 Merge upstream. 2014-10-01 12:05:04 +01:00
Oliver Jowett 864660bf27 Use uint64_t in load stats to avoid overflow with large intervals. 2014-10-01 01:43:37 +01:00
Oliver Jowett c11eca44bb Try all phases if --oversample --phase-enhance is on.
If we demodulate a message in 2.4MHz mode and it has a bad, uncorrectable CRC,
and --phase-enhance is on, then retry with the other possible phases until
we get a good CRC or run out of phases to try.

This is very expensive in AGC mode (lots of candidates that are not real
messages) but relatively cheap otherwise. It yields another 10% messages.

Also factor out some common stats code to avoid lots more copy/paste.
2014-09-30 17:02:22 +01:00
Malcolm Robb e3bbf7b266 Read Files are binary
When replaying recordings, the read files are binary, so the file open
needs to reflect this so that spurious end of file characters aren't
misinterpreted.
2014-09-30 16:36:56 +01:00
Oliver Jowett dcae71faa8 Move CPU instrumentation up into the main loop. 2014-09-29 23:11:36 +01:00
Oliver Jowett 7a0ca85a90 Measure CPU used by the sample processing thread. 2014-09-29 23:04:58 +01:00
Oliver Jowett c3409302ce Fix mlat inter-block timestamp accounting in oversampling mode.
Add calculated phase into the per-message timestamp (it is already exactly a 12MHz offset)
2014-09-27 16:44:26 +01:00
Oliver Jowett 69a30535d4 Oversampling, round two.
This now seems to be at the point where it will decode more messages
than when using 2MHz with --phase-enhance.
2014-09-27 13:07:23 +01:00
Oliver Jowett 5c8e6198b7 First cut for sampling at 2.4MHz + phase detection. 2014-09-26 22:42:38 +01:00
Oliver Jowett 9fad408f57 Merge branch 'more-stats' 2014-09-25 22:03:57 +01:00
Oliver Jowett b98c6856b3 Move the stats reset strictly after stats display, so the total message count is shown correctly. 2014-09-25 22:02:52 +01:00
Oliver Jowett b58ae5a17e Merge branch 'more-stats' 2014-09-25 20:36:42 +01:00
Oliver Jowett 4fc2697555 Add stats for number of sample blocks processed and dropped. 2014-09-25 20:35:54 +01:00
Oliver Jowett 10061675de Add --stats-every <secs> option.
Periodically displays and resets stats.
Useful for unattended operation.
2014-09-25 20:33:50 +01:00
Oliver Jowett 3f9c859800 Merge branch 'fractional-gain' 2014-09-24 20:02:00 +01:00
Oliver Jowett 95ccb90c76 Fix --gain with fractional gain values. 2014-09-24 20:01:06 +01:00
Oliver Jowett 5bcc7e1b9a Merge branch 'report-snr' 2014-09-23 14:07:53 +01:00
Oliver Jowett 83d256e984 Fix a thinko in computing the log10 table.
(This shouldn't actually affect the resulting SNR since it's just a constant offset, and the errors in signal and noise will cancel out)
2014-09-23 14:05:25 +01:00
Oliver Jowett e6e92b1e8e Merge branch 'no-decode'
Conflicts:
	mode_s.c
2014-09-23 00:01:54 +01:00
Oliver Jowett 5683001164 Add --no-decode option.
This disables most decoding of the contents of Mode S messages, aircraft tracking, and some output modes that depend on them.
It's intended for edge receivers that just forward to a central hub rather than processing data locally.
2014-09-22 23:56:49 +01:00
Oliver Jowett 76c958b03e Use a lookup table for SNR calculation. 2014-09-22 14:53:06 +01:00
Malcolm Robb 8b05286a24 Version 1.09.1007.14
Updates to support COAA Planeplotter Ground Station on an RPi
2014-08-06 15:29:05 +01:00
matthewbrandes 6f14ecf7dd Update dump1090.c 2014-07-08 17:34:43 -05:00
matthewbrandes 652af93b88 Update dump1090.c 2014-07-08 16:58:23 -05:00
matthewbrandes d0207569b6 Update dump1090.c 2014-07-08 16:56:03 -05:00
matthewbrandes 8110549fee Update dump1090.c 2014-07-08 15:12:46 -05:00
hhm 59984ac8af B"H allow disable ports, doc disable net heartbeat 2014-06-24 23:58:46 -04:00
papasven e6c43382b9 Incorrect value for auto-gain
Incorrect value for auto-gain option the Modes.gain is multiplied by 10.
2014-06-01 02:14:40 +02:00
Malcolm Robb 903f93f530 Publish Version 1.08.2705.14
A few minor additions and bug fixes as detailed below

1) Additional command line option "--net-buffer <n>" to specify the TCP
output buffer size. Default is n=0, which is 64Kb. Specify a value of n
to increase the buffer size according to  Size  = 64Kb * 2^n, so an n of
1 = 128Kb, n=2 is 256Kb etc. n is limited to 7, so the max size is 8Mb.
This option may assist if you have a high number of aircraft being
received, and an unreliable network connection, or if the receiving end
can be busy for an extended time.

2) Bug fix in ppup1090 which prevented the uploading of valid
ModeA/Squawk codes

3) Bug fix per Markus Grab's commit.
2014-05-27 13:16:57 +01:00
Malcolm Robb 30ae45ec2b Windows Version of dump1090
Make the modifications necessary to compile dump1090 for WinXP, Win7 and
hopefully Win8.

The files can be compiled using M$ Visual Studio/C++ 6.0. Due to various
licensing issues, I haven't included the libraries or DLLs. You will
need to locate pthreadVC2.lib and rtlsdr.lib to link the file, install
the zadig drivers to support the dongle, and locate libusb-1.0.dll,
msvcr100.dll, pthreadVC2.dll and rtlsdr.dll.

dump1090.exe will not run on any Windows version prior to XP SP2,
because msvcr100.dll imports several functions from the Windows kernel
that are not available on earlier versions. This means dump1090 won't
work on Win2K.

The major change to the code relates to file handles. The original code
assumes Linux behaviour in that handles are allocated from 0
sequentially upwards. However Windows handles are allocated pseudo
randomly, and handle numbers greater than 1024 would break the code. The
code has therefore been modified to use a linked list of connection
structures, rather than a static array limited to 1024 entries.
2014-04-25 14:48:14 +01:00
Malcolm Robb f7843c1691 Implement TCP Heartbeat
Some users have reported issues where the TCP link to dump1090 can be
lost at times of low traffic density - typically in the middle of the
night. One possible reason for this is that some routers drop the link
if there is no traffic for a predetermined period.

To try and resolve this, dump1090 now sends a 'null' packet consisting
of 7 "0x00" bytes approximately once a  minute if there is no real
received traffic during this time. This packet should be discarded by
the application receiving the dump1090 because it will have an invalid
checksum, and ICAO address 0x000000 is also invalid. However, this null
packet should be enough to keep routers alive.
2014-03-11 01:09:49 +00:00
Malcolm Robb 97c7f69c83 Publish V1.08.2302.14
Final tidy up and publish
2014-02-24 10:28:35 +00:00
Malcolm Robb 75a4c6ee21 BUGFIX : Missed data causes timestamp slip
The Mutex on the RTL data reader thread does not "force" the data
processing thread to execute. Therefore, if the processor is busy, it is
possible for a second RTL callback to occur before the data from the
first has been processed. This will cause the loss of the first data,
but worse, it will cause a slip in the timestamp. This upsets Beamfinder
and MLAT operation in PlanePlotter.

To solve this, keep a Fifo buffer which is filled by the callback
thread, and emptied by the data processing thread. The fifo is the same
size as the number of buffers requested in the call to
rtlsdr_read_async().

Note - we only put the value of the pointer supplied in the callback
into the fifo. We do not attempt to cache the data in the buffer pointed
to by the pointer.  This would require us to memcopy() 2Mbytes per
second, which we don't want to do if we don't have to because it will
only make the processor loading worse. Instead, we assume that the data
in the buffer will remain valid after the callback returns, at least
until it is overwritten by new data.

It is still possible for us to lose data if we can't process it quickly
enough. However, we can now detect this loss of data when the fifo is
almost full, and correct the timestamp for the lost block/blocks.
2014-02-22 23:11:13 +00:00
Malcolm Robb 86093ea95e WIZARDISHUNGRY
Dynamically size terminal using SIGWINCH

f18180fef4
2014-02-22 22:11:11 +00:00
Adam Cécile (Le_Vert) b921d80e7f Typo fixes 2013-10-10 00:44:58 +02:00
Malcolm Robb f50744b11b Better Incorporate coaa.h 2013-09-30 11:46:36 +01:00
Malcolm Robb 6997715fed Split into separate module files
Ok - this is likely to upset some people. Up until now, the vast
majority of the code has been in just one file - dump1090.c. This file
has grown so that it was approaching of 5000 lines long, and it was
becoming unmanagable. So I've split the file into several modules,
hopefully along fairly logical boundaries. The files are :

1) dump1090.c : Basically just the main() entry function, the help
function, the RTL dongle hardware interface, and a few orphan functions
that  don't really fit anywhere else.

2) mode_s.c : This contains all the mode S / ADSB decoding functions.

3) mode_ac.c : This contains all the mode A & C decoding functions

4) interactive.c : This contains all the functions to maintain an
internal list of aircraft seen over the last period, and functions to
print them out to the local console.

5) net_io.c : This contains all the network input/output functions
allowing data to be passed in/out to/from other receivers, in formats
such as SBS-1/3, Beast, AVR and JavaScript.

Hopefully this should provide an easier way forward if/when more
functions are added.
2013-08-19 18:57:03 +01:00
Malcolm Robb 1ebdd6d7a7 Interactive list aircraft display and delete changes
Create two different Time-To-Live parameters for the interactive display
list.

1) Modes.interactive_display_ttl defines for how long the display of an
aircraft persists after the last received message. The default is
MODES_INTERACTIVE_DISPLAY_TTL, which is set to 60 seconds. This replaces
the previous Modes.interactive_ttl/MODES_INTERACTIVE_TTL settings (which
were also 60 seconds)

2) Add an additional Modes.interactive_delete_ttl  parameter, and
default it to  MODES_INTERACTIVE_DELETE_TTL, shich is set to 300
seconds/5 minutes. This defines for how long an aircraft persists in the
list structure after the last received message before being deleted.

Also tidy up a few comments.
2013-08-19 15:55:17 +01:00
terribl 3000baf184 Added metric-option to web-view
Added option to show values in metric system.
Metric = false; // true|false

Removed unused conversion from aircraftsToJson() at dump1090.c-file.
Tweaked distance calculation to use google map api.

	modified:   dump1090.c
	modified:   public_html/config.js
	modified:   public_html/gmap.html
	modified:   public_html/script.js
2013-05-28 12:15:18 +03:00
Malcolm Robb 228b770be8 Move declarations into a headed file
This is the start of breaking the main dump109.c file into smaller
modules to make it a bit more maintainable.

Move all the #define and structure declarations into dump1090.h
2013-05-24 23:32:12 +01:00
Malcolm Robb e86eb3921e VK1ET : Numerous changes to Port handling
Changes based on ideas from John VK1ET. His commit notes are as follows
:

1. Change input socket handling to avoid unnecessary memmove (use
pointers instead)

2. Add ability to read and decode binary beast format TCP.

3. Change output socket handling same as sbs_output - only call output
handler if there is a current client connected use separate ports for
beast in and out - no need for --net-beast flag. Will input/output
format defined by socket connected to. avr raw, beast binary and sbs can
be handled simultaneously.

4. Some comments changes, filtering of ModeAC to json,.
2013-05-24 22:29:00 +01:00
Malcolm Robb f64a65b5a2 Tidy up of UKUEHN's improvements
Resolves some merge conflicts that I couldn't find a way to fix during
the previous merge.

Remove a few Tabs that escaped in the edit/merge

Rename the fix_errors flag variable to nFix_crc since it now represents
the number of crc errors to attempt to fix.

Remove the aggressive variable since it's now part of nFix_crc

Only print phase correction statistics when phase correction is enabled.

Add an additional Modes.stat_ph_bit_fix[] to count the bits fixed during
phase correction
2013-05-24 21:51:44 +01:00
Malcolm Robb 9edba9332a UKUEHN : Various Improvements
Sorry Ulrich - I can't get Github to resolve the merge errors and
preserve your commit notes, so I'll add them here.
Improvements on bit error correction, doc update, preparation for
program installation/package build

Hi,
I committed some further improvements on the bit error correction code,
updated the readme, and implemented a way to install the program in the
linux file system hierarchy (allows for package building).

Regards,
Ulrich
2013-05-24 21:24:16 +01:00
Malcolm Robb ee742cf8db SBS Output Format changes
Bug fixes in the SBS output code as a result of an EMAIL from Liviu

Some software gets upset if null fields are output where the software is
expecting a valid value. This was being caused by DF0's outputting and
SBS MSG5. MSG5 needs Atert and SPI flags, which are derived from the FS
field. DF0 doesn't have an FS field, so cannot output a MSG5. Change so
that DF0 results in an SBS MSG7.

Also DF17/DF18 metypes 5 to 18 contain raw Lat/Lon data. However they
cannot be decoded into real Lat/Lon values unless both even and odd
parts are available Therefore, when we receive a DF17/DF18 we need to
check that we have successfully decoded the Lat/Lon before we attempt to
send an SBS MSG2 or MSG3. If we don't have a decoded Lat/Lon, send a
MSG7 instead.
2013-05-24 12:26:06 +01:00
Malcolm Robb 4c0ed6d5f1 Set AOG_VALID for DF-17/18 metype 19 2013-05-24 11:10:16 +01:00
Malcolm Robb 77bd1f40dc Include Vertical rate in aircraft structure 2013-05-24 11:07:49 +01:00
Malcolm Robb e50c2a5a54 Phase Enhancement changes
Phase enhancement is used to try and increase the signal amplitude when
Nyquist sample aliasing is suspected. In previous versions, this was
enabled by default. In this version, the default is off. There is now an
additional command line switch --phase-enhance to turn it on.

There are also additional debug statistics which count the number of
phase demodulation failures in for both uncorrected and phase corrected
passes.
2013-05-22 13:23:54 +01:00
Malcolm Robb b481c76909 mm structure initialisation
Ideally we should clear down the mm structure every loop of our
ModeA/C/S bit detector. However, we're getting 2Mbits of data per
second, and the structure is several tens of bytes long. Clearing down
every loop would require us to zero up to 100Mb per second. The memset
function may be fast, but it's still going to take up valuable processor
time.

So instead of clearing the whole structure every loop, just clear the
important parts.
2013-05-22 11:49:03 +01:00
Malcolm Robb 4a3113f65a Decode DF-18 2013-05-22 00:05:03 +01:00
Malcolm Robb 08ffc3f541 Change mm.crc checks to mm.correctedbits
Instead of force clearing mm.crc to zero if we successfully correct bit
errors, just use the mm.correctedbits variable. This allows us to print
out the crc value containing the errors during list output modes.
2013-05-21 23:16:49 +01:00
Malcolm Robb be6cb6eaf0 VK1ET : Use error corrected DF17
Actually use the (DF17) messages where we do bit correction.

Other changes to AVR message I/O.
1) treat mlat timestamp of zero as invalid (easier to work with than
(-1) and equally unlikely).
2) If we don't have a valid timestamp send a without timestamp
'*.......' message rather than '@.......' with invalid time.
3) Drop interpretation of obsolete AVR ' #' & '$' formats - they
wouldn't have worked anyway (wrong length).
2013-05-21 16:43:07 +01:00