Commit graph

133 commits

Author SHA1 Message Date
Malcolm Robb 1175a03f4b Another attempt to remove UNIX compiler warnings
M$ VC 6.0 does not like long long
UNIX compilers don't like printing int64_t or uint64_t as %lld
Raspberry Pi Linux doesn;t like PRId64

So I give up.

I've changed the affected variables to bog standard unsigned ints.
Assuming these compile as 32 bit unsigned's, its unlikely youll have the
program running long enough for these to overflow.
2013-04-12 21:06:19 +01:00
Malcolm Robb 8c024d1736 Try to correct single bit errors in the DF field
If noist/sampling/Nyquist errors cause bit detection errors in the DF
pare of the frame, then we may not be able to work out the correct
length of the message. We have to guess whether the bit should be a 0 or
a 1.

In such circumstances we assume the message length is long(112 bits)
However, if we start to get encoding errors after bit 56 the we attempt
to change our original guess at the bit, and invert it. If this change
of guess would have resulted in a short message, and if the short
message would have been error free then we can recover.
2013-04-12 20:45:12 +01:00
junglejet 0c91c5f61f Merge pull request #1 from junglejet/Debug
Debug
2013-04-12 03:44:05 -07:00
junglejet 44ca030d3f committ repeated
committ repeated
2013-04-12 12:30:18 +02:00
junglejet c4956704e7 --mlat option and --interactive-rtl1090 option added
--mlat option introduced: to display raw data in Beast ascii format with
counter (@...;), does not affect Beast binary format ;
--interactive-rtl1090 option introduced: order of flight table Iin
interactive mode) and some formats adopted to RTL1090 format, so
comparison is easier
2013-04-12 12:15:52 +02:00
Malcolm Robb 63622355e3 Change the message bit decoder
Change (and hopefully improve) the Message bit decoder.

When decoding bits, a "0" is encoded as (m[j]<m[j+1]), and a "1" is
(m[j]>m[j+1]) . However, there is a problem if mpj[ == m[j+1] because we
can't decide what it's supposed to be.

Antirez's original code defaults to a '1', and then lets the bit error
detection code sort it out. I *think* it's better to default to '0'
because it's more likely that noise added to the signal will produce a
spurious '1' rathar than anything subtracting from the signal to produce
a spurious '0'

Also, Antirez''s code only looks for errors in the first bit of the
message. I don't know why  this is.

There is a potential problem in deciding the message length if there are
any errors in the first 5 bits decoded, because this defines the message
type (the DF-??), and it's the DF that determines how many bits the
message shall contain.

If there is an error in the first 5 bits, then we could ignore the DF,
and continue decoding a long format (112 bits). However, for weak
signals, if the message is a short one (56 bits) this results in the
sigStrength decaying to the point where it's level drops below squelch,
so we discard a possibly decodeable 56bit

However, if we assume it's a short message, and only decode 56 bits, and
it's really a long message we won't have decoded all the bits.

Not sure what to do about this
2013-04-12 10:53:46 +01:00
Malcolm Robb ff697dbb51 Improve the decoding for DF-11
Three changes in this one

1) Change the checksum testing for DF-11
2) Recode the Checksum generation routine to use pointers.
3) Tidy up the appearance of some print debug statments
2013-04-11 19:01:03 +01:00
Malcolm Robb dc7e2b6a22 Change the type of the stats variables from uint64_t to int64_t
Some compilers complain about the printf %llx format being used with a
uint64_t
2013-04-11 18:53:09 +01:00
Malcolm Robb 22c329849a Change the I/Q lookup table values for better detection
Change the I/Q lookup table for better detection. Changes fully
described in the source dump1090.c at line 347 onwards. This change
results in about 30% more frames being detected at weak signal input
levels.

Also a bug fix from the last commit - C doesn't support the min()
function.
2013-04-10 20:57:09 +01:00
Malcolm Robb f806f1899e Basic tidy up of the modesInit() function 2013-04-10 12:16:25 +01:00
Malcolm Robb f1935b280c Get rid of that hideous goto
I'm not overly keen on the continues either :-)
2013-04-10 11:43:55 +01:00
Malcolm Robb e59142b9dc Merge the data bit detection and data byte assembly into the same loop
Original code loops through the analogue array m[] detecting data bits
and putting them into the bits[] array. It then loops through all the
bits[] creating the msg[] byte array. It then loops through the analogue
array m[] again calculating the signal strength.

Change this so that everything is done in one loop so we can go straight
from analogue samples to bytes, calculating the signal strength on the
fly.

Also use the results of the signal strength calculation to populate the
message records mm.signalLevel variable.
2013-04-10 11:33:18 +01:00
Malcolm Robb d85939c4f5 Create a payload pointer in message detector loop
Create a pointer, pPayload, which points to the start of the data bits
in the analogue sample buffer m[]. So pPayload =
&m[j+MODES_PREAMBLE_SAMPLES] Then use this
pointer to perform the data bit detection tests.  It should save a few
cpu cycles per test because accessing pPayload[2] should be quicker than
m[2+j+MODES_PREAMBLE_SAMPLES].

Also change the way phase correction works. the original code saves the
original data (from m[pPayload] to aux[], and then phase corrects m[],
and then restores aux[] back to m[] afterwards. Change this so that m[]
is copied to aux[] and then phase correction is carried out in aux[],
and the pPayload pointer points to aux[]. This then avoids the
requirement to copy aux[] back to m[] afterwards, which saves a fair few
CPU cycles.
2013-04-10 11:08:19 +01:00
Malcolm Robb 09af545933 Create a preamble pointer in the message detector loop
Create a preamble pointer in the message detector loop

Create a pointer, pPreamble, which points to the start of the preamble
in the analogue sample buffer m[]. So pPreamble = &m[p] Then use this
pointer to perform the preamble detection tests.  It should save a few
cpu cycles per test because accessing pPointer[2] should be quicker than
m[p+2].

Also move the decision on whether to try OutOfPhase correction to the
end of the first pass, rather than automatically going into phase
correction if the first pass fails. This saves two memcpy's if the
decision in the second pass is to not do phase correction.
2013-04-10 01:12:50 +01:00
Malcolm Robb 70031e1234 Create a preamble pointer in the message detector loop
Create a pointer, pPreamble, which points to the start of the preamble
in the analogue sample buffer m[]. So pPreamble = &m[p] Then use this
pointer to perform the preamble detection tests.  It should save a few
cpu cycles per test because accessing pPointer[2] should be quicker than
m[p+2].

Also move the decision on whether to try OutOfPhase correction to the
end of the first pass, rather than automatically going into phase
correction if the first pass fails. This saves two memcpy's if the
decision in the second pass is to not do phase correction.
2013-04-10 00:48:29 +01:00
Malcolm Robb 316b456835 Make Things more Windows friendly
Change the following so that M$ compilers and debuggers complain less

1) change all long long data types to uint64_t.
2) Typecast all malloc function returns to the correct pointer types.
3) Explicitly typecast all float to int conversions.
4) Remove inline variable declaration. Allowed in C++, but not in C.
2013-04-09 23:58:03 +01:00
Malcolm Robb ff34693d1e Make Things more Windows friendly
Change the following so that M$ compilers and debuggers complain less

1) change all long long data types to uint64_t.
2) Typecast all malloc function returns to the correct pointer types.
3) Explicitly typecast all float to int conversions.
4) Remove inline variable declaration. Allowed in C++, but not in C.
2013-04-09 23:56:20 +01:00
Malcolm Robb d02a4043fe Merge remote-tracking branch 'origin/master' into Debug 2013-04-09 21:56:08 +01:00
Malcolm Robb 4f7b51a93f Change timer granularity & incorporate terribl's latest changes
Apparently, the Beast output timestamp has a frequency of 12 Mhz.
Therefore, I've updated the timestamp counter to simulate a 12 Mhz
frequency.

Also incorporate terribls latest updates
2013-04-09 21:50:58 +01:00
Malcolm Robb 408c8468e5 Merge remote-tracking branch 'origin/master' into Debug 2013-04-09 01:00:11 +01:00
Malcolm Robb ed80552ca1 Speed up the I/Q to magnitude calculation
Increase the speed of the I/Q to magnitude calculation lookup by
expanding the table to 65536 entries (256*256*2 bytes). At runtime, this
allows us to pick up raw I/Q bytes as a 16 bit value and index into the
magnitude table to get a 16 bit result. This removes the need for
subtracting 127, and then correcting for -ve numbers, so should be
faster, at the expense of a larger data table.

Change the maglut lookup table from 129*129 to 256*256
Initialise the maglut buffer accordingly
Change the data->maglut lookup to use the new maglut buffer
Change the I/Q data buffer pointet to a uint16_t *
2013-04-09 00:58:32 +01:00
Malcolm Robb bbe96b6afd Merge remote-tracking branch 'origin/master' into Debug 2013-04-08 23:53:08 +01:00
Malcolm Robb 3113223029 One bug fix, and some changes to the --interactive output format
I messed up merging the Squawk display in interactive mode into my
master.

However, the original source posted by terribl causes a print line
length greater than 80 characters. This in turn causes the lines to
spill over on a terminal display. I have therefore re-formatted some of
the output so that it fits within 80 characters.
2013-04-08 23:19:48 +01:00
Malcolm Robb 8ba18ebcdb Type Conversion required when using --file 2013-04-08 18:25:11 +01:00
Malcolm Robb 192cb80c08 Speed up the I/Q to magnitude calculation
Increase the speed of the I/Q to magnitude calculation lookup by
expanding the table to 65536 entries (256*256*2 bytes). At runtime, this
allows us to pick up raw I/Q bytes as a 16 bit value and index into the
magnitude table to get a 16 bit result. This removes the need for
subtracting 127, and then correcting for -ve numbers, so should be
faster, at the expense of a larger data table.

Change the maglut lookup table from 129*129 to 256*256
Initialise the maglut buffer accordingly
Change the data->maglut lookup to use the new maglut buffer
2013-04-08 17:55:17 +01:00
Malcolm Robb 43c648448f Added some other peoples commit modificatons
Added dtiller's --quiet and --ppm modifications
Added terribl's squawk on interactive modifications

Removed up some unused or un-needed variables
2013-04-08 16:42:27 +01:00
Malcolm Robb d3662bba80 Implemented Beast Binary output 2013-04-07 16:22:02 +01:00
antirez ff0fe38722 Two typos fixed in gmap.html. 2013-02-04 23:09:21 +01:00
antirez c991d658c6 gmap.html: update plane flight field when new data is received. 2013-02-03 23:20:29 +01:00
antirez acc702d9ac Fake version info removed from gmap.html. 2013-02-02 16:32:42 +01:00
antirez 9d55d5edd7 gmap.html: no rotation jumps when selecting / deselecting planes. 2013-02-02 16:32:00 +01:00
antirez 3307261546 CPR decoding: southern hemisphere coords are now handled correctly. 2013-02-02 14:40:58 +01:00
antirez 13596ba3dd A few bugs fixed in debug.html. 2013-01-27 21:42:40 +01:00
antirez e9e07e0778 Improved Google map interace: select planes and see details. 2013-01-27 01:37:05 +01:00
antirez 27e3743d87 Remove stale aircrafts when --interactive is not enabled. 2013-01-27 01:25:22 +01:00
antirez 977493cf63 Strong preamble detection even with --aggressive.
To try to decode messages with a fundamentally flawed preamble is mostly
a useless waste of CPU time.

The new aggressive mode still detects a sensible percentage of
additional messages because of the error tolerance and two-bits fixes
but does not waste your CPU time.
2013-01-26 13:03:24 +01:00
antirez 184953ff92 Phase correction fixed, code reshaped to apply more corrections.
The phase correction was applied only to a subset of bits! Because of an
offset error.

The detection code layout was modified a bit to make it simpler to
implement more corrections in the future. However only phase correction
is performed currently. Slope correction, or to compensate for the cycloid
effect are two possible improvements.
2013-01-26 12:58:08 +01:00
antirez 11d8db0d38 Properly initialize ICAO cached addresses hash table. 2013-01-26 01:15:24 +01:00
antirez c2e79d4555 Many small improvements (see full commit message).
* Better preamble detection to skip most of the messages we'll likely
  not be able to decode.

* A Phase correction algorithm that improves the recognition compared
  to the previous algorithm used.

* Javascript output in debug mode, and a debug.html file that can be
  used in order to see graphically undecoded samples.

* Ability to detect cross-read messages, that are, messages that happen
  to start and end across two different reads from the device or file.

* A few bugx fixed.

* README improved.
2013-01-26 01:08:13 +01:00
antirez 9086290b03 SBS-1: Code style adapted to code base. 2013-01-20 00:17:58 +01:00
Kemal Hadimli 071a021f20 New feature: Output in SBS format 2013-01-19 22:44:11 +01:00
antirez 2fe188286e Do not modify the packet when AP gets decoded. 2013-01-19 18:45:00 +01:00
antirez c9bb48675c Squawk extraction fixed. 2013-01-19 18:44:54 +01:00
antirez b4805ea7d4 Two important fixes to CPR decoding: wrong cast and more precise timing.
This commit address two issues with the implementation of CPR decoding:

Fix #1: The two functions N() and DLon() used to have the latitude
parameter as an integer (!), basically truncating the fractional part
before calling the NL() function to perform the lookup.

This resulted into random strange movements of aircrafts, especially
jumps or shifted positions.

Fix #2: Use milliseconds for CPR odd/even timestamps. Dump1090 already
tried to use the most recent packet received among the odd and even
packets currently available, however to do this correctly millisecond
resolution should be used, otherwise many times the odd and even packet
appear to have the same time in seconds and we don't always use the
latest received.
2013-01-18 23:05:08 +01:00
antirez 03759a3eb0 Google map view enhanced: color by altitude and more. 2013-01-16 20:25:28 +01:00
antirez 21fc9de47a HTTP keep-alive fixed. Network debugging capabilities. 2013-01-16 20:07:35 +01:00
antirez e40e55bfe0 Less buggy network requests parser. 2013-01-16 00:40:47 +01:00
antirez dc91712741 Aggressive mode implemented. 2013-01-15 22:37:47 +01:00
antirez 0bf65d8646 Better error handling for network clients. 2013-01-15 00:35:21 +01:00
antirez e1d3724271 Regression fixed: set client socket non-blocking. 2013-01-15 00:24:19 +01:00