Commit graph

193 commits

Author SHA1 Message Date
Oliver Jowett 849697f84c Fix integer overflow in stats output. 2015-02-11 00:14:28 +00:00
Oliver Jowett f9ed7e4a97 More time_t -> milliseconds conversions.
This lets us support fractional net flush times among other things, which is handy.
2015-02-10 22:24:22 +00:00
Oliver Jowett 7053ad02da Make aircraft tracking use milliseconds everywhere. 2015-02-10 21:49:37 +00:00
Oliver Jowett a49b5b8830 Add stats for total aircraft tracks and tracks that have only a single message. 2015-02-08 18:47:39 +00:00
Oliver Jowett 4e177c2d64 Store computed reception time in the message struct so we don't rely on
the message being emitted immediately.

Fix computation of reception time so it's more sensible (the block timestamp
is some time after reception of the _end_ of the block, not the start) - this
means that message-emission times are always later than message-reception
times in SBS output, which is a bit more sensible.

Use clock_gettime in preference to ftime.
2015-02-08 17:46:01 +00:00
Oliver Jowett 20407e5378 Don't emit SBS output with non-ICAO addresses (fixes #9) 2015-02-08 14:30:10 +00:00
Oliver Jowett 245bbd8b97 Report total, not latest-minute, message count in aircraft.json so that
the webmap value doesn't jump around over a reset.
2015-01-23 17:40:03 +00:00
Oliver Jowett c5b61a33fd Oops, another compile error, sigh. 2015-01-23 02:11:44 +00:00
Oliver Jowett c07e45a4c8 Report CPU in integer milliseconds, makes it a bit easier to process. 2015-01-23 02:03:57 +00:00
Oliver Jowett 5b40377b98 Measure CPU for demodulator, read thread, and background tasks individually. 2015-01-23 01:22:22 +00:00
Oliver Jowett eb023ff1d9 Don't include latest in 1/5/15 min totals, it's a bit confusing.
This means the 1/5/15 min values may reflect a period that ended
up to 1 minute ago, but the length of the measured period is always
as expected i.e. 1/5/15 mins.
2015-01-22 20:45:53 +00:00
Oliver Jowett c8025700e5 Emit all stats in stats.json. 2015-01-22 20:18:51 +00:00
Oliver Jowett 008ae926e7 Add --net-verbatim, which forwards the original uncorrected message to net clients,
not the corrected version. Then the client can make its own policy decisions about
whether to accept and correct the damaged messages.
2015-01-22 19:56:38 +00:00
Oliver Jowett a59077a370 Stats overhaul. 2015-01-22 19:49:19 +00:00
Oliver Jowett b77d52bd1f Include recent RSSI in aircraft output. 2015-01-22 15:30:34 +00:00
Oliver Jowett 89d6b64747 Treat signal level in network messages as a (RMS) amplitude, since that
is what was previously done and it gives us better range for small signals.

Means a sqrt() call on beast output, but this shouldn't be too bad as
it's only done once per message.
2015-01-22 15:28:35 +00:00
Oliver Jowett 35e0364670 Fix compile errors. 2015-01-22 13:29:13 +00:00
Oliver Jowett 70e8579850 Simple filter for spurious messages that make it past checksum:
don't show aircraft until we have seen 2 messages from them.
2015-01-22 13:22:16 +00:00
Oliver Jowett ada188a1c8 Changed my mind, put the non-ICAO flag bit in the address itself
since we have 8 bits spare, so there's no chance of confusing it
with an ICAO address, and we can safely use the filter table to match
future messages without also matching equivalent ICAO addresses.
2015-01-22 12:30:12 +00:00
Oliver Jowett 35551b4455 Don't emit FATSV output for non-ICAO addresses. 2015-01-22 12:18:46 +00:00
Oliver Jowett 6e1315e3a6 Flag non-ICAO addresses in json output. 2015-01-22 12:18:14 +00:00
Oliver Jowett d0605629b6 Avoid zero signalLevel. 2015-01-22 11:40:52 +00:00
Oliver Jowett 7850848ef7 Export a few stats via JSON. 2015-01-22 01:21:53 +00:00
Oliver Jowett 19082d92ea Measure signal power / noise power (at least in 2.4MHz mode).
Switch signalLevel back to a power measurement, don't put SNR in there.
But make it a 0.0 - 1.0 double so we're not scaling everywhere.

Adjust for the amplitude offset when calculating power.

Adapt everything else to the new scheme.
2015-01-22 01:01:39 +00:00
Oliver Jowett 2a1a2a0a71 Fix (maybe) JSON escaping.
I've obviously never tested this code!
2015-01-21 11:58:51 +00:00
Oliver Jowett cae20a8060 Escape flight name in JSON in case it has odd characters. 2015-01-21 11:56:27 +00:00
Oliver Jowett ebae590653 Use MODES_NOTUSED for unused args. 2015-01-21 11:54:55 +00:00
Oliver Jowett 5e522fe8db Decoder cleanups from experimental branch. 2015-01-21 00:23:48 +00:00
Oliver Jowett b9b76da02d Stats rearrangement, based on experimental branch changes. 2015-01-20 17:16:35 +00:00
Oliver Jowett e02a2cdd44 GPL. 2015-01-20 16:49:01 +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 c7204ec6ab Support image/gif content type
(cherry picked from commit f4b38a62f69d0df2bb5d3a87979e38d76249b80a)
2015-01-16 20:33:08 +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 63fb121d1c Status messages in HTTP responses.
(cherry picked from commit 820528b4ad7f3963199718205724cdf3ac97b113)
2015-01-16 20:28:36 +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 0976d12b88 Ditch any query strings in HTTP requests before handling them,
to allow AJAX requests to tack on a query string to avoid caching.
2015-01-07 18:40:55 +00:00
Oliver Jowett e8a62293c2 More WIP on the webmap, mostly fixing up track history. 2015-01-06 01:00:44 +00:00
Oliver Jowett 1f06abf67d WIP webmap cleanup 2015-01-05 23:20:03 +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 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 c712543ee5 Only completeWrite() if we didn't run off the end of the buffer.
If we did run off the end, complain about it.
2014-12-08 20:17:48 +00:00
Oliver Jowett 39d905324f Be more paranoid about not overrunning our fatsv output buffer.
Request a buffer of a more reasonable size.
2014-12-08 20:14:53 +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 af957da81c Merge branch 'realpath-memory-leak' 2014-12-07 14:10:17 +00:00
Oliver Jowett d09eefb827 Fix a memory leak from use of realpath() in HTTP request processing.
realpath() returns a heap-allocated buffer if given NULL for the destination buffer.
This must be freed by the caller; dump1090 does not do this.

Instead of worrying about freeing it, take the simpler approach of just providing a
stack-allocated destination buffer.
2014-12-07 14:05:24 +00:00
Oliver Jowett e0bc89e542 Merge branch 'write-json-files' into oversampling 2014-11-23 16:34:18 +00:00
Oliver Jowett ebab2c0e11 Create json files with mode 0644 - umask.
mkstemp defaults to 0600 which is not so useful for serving the file.
2014-11-23 16:32:45 +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 29d1e53f9f Merge remote-tracking branch 'upstream/master' into net-cleanups 2014-10-31 17:58:03 +00:00
Malcolm Robb 5f18f6cbca Fix warnings and Windows compile problems 2014-10-29 19:00:42 +00:00
MalcolmRobb 5699e48855 Merge pull request #54 from l0calguest/bind_address
Ability to assign bind address for services
2014-10-29 17:21:12 +00:00
hhm 027ab92e7a Merge branch 'master' of https://www.github.com/MalcolmRobb/dump1090 into http_server_wk 2014-10-29 10:29:04 -04:00
demonx 5b4d811c7d Ability to assign bind address for services 2014-10-25 21:33:45 +02:00
hhm f71bc6c130 Merge branch 'master' of https://www.github.com/MalcolmRobb/dump1090 into http_server_wk 2014-10-04 21:39:15 -04:00
hhm e20e240130 B"H Merge branch 'master' of https://www.github.com/MalcolmRobb/dump1090 into socket_hang
Conflicts:
	net_io.c
2014-10-04 21:36:51 -04: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
MalcolmRobb 65751ed6e9 Merge pull request #45 from mutability/net-client-eof-handling
Detect client EOF properly. Handle EWOULDBLOCK.
2014-10-02 21:32:40 +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
Malcolm Robb 5a5c52d7a9 Merge remote-tracking branch 'origin/pr/46' 2014-10-02 19:53:43 +01:00
Oliver Jowett 15f3408d8e Always emit a message reception time, as otherwise the FR24 uploader is unhappy.
When we don't have a time available (e.g. remote message) use the system time.
2014-10-02 12:20:37 +01:00
hhm 13fe375437 Merge branch 'master' of https://www.github.com/MalcolmRobb/dump1090 into http_server_wk 2014-10-01 11:10:41 -04:00
hhm 8b4d5b3dca Merge branch 'master' of https://www.github.com/MalcolmRobb/dump1090 into socket_hang 2014-10-01 11:10:19 -04:00
Oliver Jowett 186cac5c25 Use the anet-reported error string when reporting bind errors.
errno may have been modified by the time you see it.
2014-10-01 12:37:29 +01:00
Oliver Jowett a513c3677b Detect client EOF properly. Handle EWOULDBLOCK.
Client disconnection appears as a read of 0 bytes.
Without a test for this, dump1090 continues to poll that client forever.

Also, read() may return EWOULDBLOCK as well as EAGAIN
for "no data right now", so handle that.

I don't know if there is an equivalent Win32 bug here as the Win32
interfaces seem subtly different to vanilla POSIX.

The following test/break can probably be removed if Win32 needs
the same fix.
2014-10-01 12:29:16 +01:00
Oliver Jowett 3eb39ab788 Don't output message reception time in SBS format for remote messages.
For remotely received messages that have a mlat timestamp, we have no
useful way of turning that timestamp into a wallclock timestamp, so
don't try, or we'll just produce wildly wrong results (_days_ in error)
2014-09-25 21:45:46 +01:00
hhm c265ea1d55 B"H net_io.c http server: hopefully mem code is OK now
Still learning the ropes memory-wise :-)
2014-09-17 07:58:19 -04:00
hhm 32fc5fddd0 B"H net_io.c: http server: content should be dynamically allocated 2014-09-17 07:32:34 -04:00
hhm df19d51bc6 B"H net_io.c: use %d like local code 2014-09-17 06:58:53 -04:00
hhm 8d307cd0eb B"H net_io.c: http serve: return HTTP response codes 2014-09-17 06:32:03 -04:00
hhm 04f4abda70 B"H net_io.c: add missing else statement 2014-09-15 09:08:49 -04:00
hhm eb41be3884 B"H net_io: http: check if file can be sent 2014-09-14 06:28:03 -04:00
hhm 84fa09c228 B"H net_io.c: revert previous change and advertise HTTP 1.1
It seems server code should be compatible with HTTP 1.1; the features
unique to 1.1 mostly are upon the client to support, and some headers
used (for example Cache-Control) may need 1.1.
2014-08-18 03:06:43 -04:00
hhm 0317c48aac B"H make sure to close sockets when finished 2014-08-15 04:39:35 -04:00
Malcolm Robb 90fa1dac81 net_io port 30003 bug
Thanks to "Harrie" for this one.
Fix the SBS port 30003 stream to always include speed and/or heading
when available.
2014-08-06 15:29:07 +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
hhm 59984ac8af B"H allow disable ports, doc disable net heartbeat 2014-06-24 23:58:46 -04: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 a55b9a76b5 BUGFIX : Windows version HTML Web browser support
Allow connection of a web browser to the Windows version via
http://127.0.0.1:8080
2014-05-09 23:44:11 +01:00
Malcolm Robb d200099244 BUGFIX : Possible linked list bug 2014-04-25 17:00:58 +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 97c7f69c83 Publish V1.08.2302.14
Final tidy up and publish
2014-02-24 10:28:35 +00:00
Malcolm Robb 260b955f47 BUGFIX : Beast Binary Escape characters
Thanks to Blort on the PP list.

The Beast binary message stream uses the 0x1a character a and escape to
mark the beginning of a new message. However, the 0x1a character could
occur in the body of a message since the message is binary. Therefore,
the 0x1a is repeated  -as Blort put it :

This 56-bit Mode S Frame (containing a 1a) is supposed to look like
this:

1a  32 00 00 48 7b a6 1a 1a 0c  20 28 17 b0 c0 c3 b0

What is actually looks (looked) like (from wireshark) is this:

1a  32 00 00 48 7b a6 1a 0c  20 28 17 b0 c0 c3 b0

There are supposed to be two 1A’s (Gunter’s Escape Character) in a row
(1A 1A) whenever a data byte contains 1A, after the initial two 1A 3x
characters.
2014-02-23 01:55:34 +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 24080a22b1 antirez
Free the client on best effort write(2) short write
2014-02-22 22:35:42 +00:00
Malcolm Robb b9a1a3e650 antirez
modesFreeClient() optimized to find new maxfd faster
2014-02-22 22:28:20 +00:00
Malcolm Robb f331887b7f antirez
Constant replaced with macro MODES_NET_SERVICES_NUM.
2014-02-22 22:20:25 +00:00
Malcolm Robb 2e43a9eb63 IE 8/9 Web Interface moving planes
Many thanks to 0xFACE for this fix. Hopefully those using Windows and
IE8/9 should now see some moving action.
2013-09-27 10:05:05 +01:00
termigrator c2962a00e5 Update net_io.c
Added vertical rate (a->vert_rate) to json output
2013-09-22 23:25:12 +02:00
Malcolm Robb 7ea2e8fdef Bug Fix in modesReadFromClient()
The modesReadFromClient() funtion is called from modesReadFromClients(),
which in turn is called from backgroundTasks(). backgroundTasks() is
called from within the main processing loop.

However, modesReadFromClient() can and does block. It attempts to read
characters from the input stream, and loops whilst there was no error.
This stalls the main RTL processing loop until an error occurs. In order
to support simultaneous local reception (via our RTL dongle) and remote
forwarding (data received from the interweb) we cannot allow this
internet read to stall.

To fix this, in modesReadFromClient() attempt to read a buffer of data
(currently 0x400 bytes). If we get a full buffer of bytes, then process
them, and attempt to read another full buffer. Keep doing thios untill
we read only a partial buffer (less than 0x400 bytes). Process the
partial buffer bytes and return.

This allows us to occasionally process data that is arriving from the
internet (which is buffered anyway in the TCP stack), without blocking
local RTL dongle decoding.
2013-09-20 16:48:15 +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