Commit Graph

34 Commits

Author SHA1 Message Date
Oliver Jowett 56625449e8
Adaptive gain, first pass (#134)
This PR adds basic adaptive gain support, which adjusts SDR gain on the fly based on the noise & signal levels seen.

There are two control mechanisms:

Dynamic range control is enabled by the --adaptive-range option. This adjusts SDR gain to try to achieve a minimum dynamic range, regardless of the exact hardware in the RF path.

Burst (loud message) control is enabled by the --adaptive-burst option. This decreases SDR gain when undecodable loud messages are heard, allowing for better reception of nearby aircraft at the expense of range.

This is only the basic implementation - see the PR for remaining work to do.
2021-06-29 20:11:13 +08:00
Oliver Jowett c433463392 Reduce CPU further in --no-fix-df mode. Add --enable-df24 option.
This reinstates the fastpath in the 2.4MHz demodulator that
aborts message demodulation early if the DF bits don't match a message
type that we know how to decode, or stops early if the DF bits can
only correspond to a short 56-bit message.

Do this in a more general form where we test against a set of valid
DF values, rather than a switch/case. Then populate the sets based on
the current error-correction settings (e.g. if we are allowed to repair
DF damage with 1 bit error correction, then a DF17 message could appear
with any of DF=17, DF=16, DF=19, DF=21, DF=25, or DF=1 and still be
correctable to a valid DF17 message)

In the default case this produces a small CPU improvement as short
messages might be able to stop earlier and a few DF values can be ignored
early. With --no-fix-df it produces a larger improvement as relatively few
DF values are valid in that mode.

To further reduce CPU, the default behaviour has changed to _not_
decode DF24 messages (Comm-D ELM messages). These are rarely seen in
the wild and dump1090 can't do anything useful with them. Disabling
them allows us to further reduce the set of valid DF values as they
effectively use all DF values from 24..31, 25% of all possible values.
To re-enable DF24 decoding, use the new `--enable-df24` option.

Finally, avoid doing some CRC calculations twice. This was only happening
once per valid decoded message, not per demodulation attempt, so it's not
such a large win.
2021-03-19 17:03:15 +08:00
Oliver Jowett c421c31152 Overhaul of message scoring & error correction.
Major changes:

Try to error-correct all messages that potentially could be DF11/17/18
even if the original DF value is different. This allows messages with
correctable damage in the first 5 bits to be correctable.

Track recently-seen DF18 addresses separately to DF17 addresses.
DF18 does not imply Mode S support, so we don't want to treat it like
a known Mode S emitter, but once we've heard some DF18 for an aircraft
we can be more confident about future DF18 messages for the same
address.

Rework the scoring system so it's just a big enum that lists all the
possible outcomes in the order that we want. This makes the relative
ordering of different messages clearer, and makes it easier to move
messages above/below the accept thresholds as needed.

Don't accept 2-bit-error-corrected messages that are from aircraft we
have not previously seen. This greatly reduces the number of garbage
messages when using 2-bit error correction.

Overall results are:

 * more CPU required for decoding (approx 30% increase in my tests)
   as we're doing a lot more speculative CRC-checking work
 * no significant change to message rates with error correction off
 * about 5% more 1-bit-corrected DF17 decodes, with a
   disproportionate increase in those messages contributing to
   successful position decodes / unique aircraft counts
 * _fewer_ decodes with 2-bit correction (versus old code with 2-bit
   correction), but the message quality is substantially improved,
   the rate of garbage decodes / phantom aircraft is greatly reduced

sample stats:

1-bit correction, old code:
    141158 total usable messages
    137852 accepted with correct CRC
      3306 accepted with 1-bit error repaired
     27446 DF17 messages
        51 unique aircraft tracks

1-bit correction, new code:
    141296 total usable messages
    137854 accepted with correct CRC
      3442 accepted with 1-bit error repaired
     27528 DF17 messages
        55 unique aircraft tracks

2-bit correction, old code:
    142656 total usable messages
    137809 accepted with correct CRC
      3283 accepted with 1-bit error repaired
      1564 accepted with 2-bit error repaired
     28803 DF17 messages
       349 unique aircraft tracks (<- note that most of these are garbage)

2-bit correction, new code:
    142426 total usable messages
    137822 accepted with correct CRC
      3420 accepted with 1-bit error repaired
      1184 accepted with 2-bit error repaired
     28666 DF17 messages
        55 unique aircraft tracks
2021-02-09 20:10:55 +08:00
Oliver Jowett 74607b31ed Factor out FIFO handling; reimplement as a linked list, not a circular buffer.
Update all the SDR implementation to use it.

This was getting pretty ugly with code getting copy&pasted in all the SDR
implementations. Unify it all and give it a simpler API. Linked list works out
much simpler than the circular buffer. Also, simplify copying the overlap region
around by just using a separate buffer (it's only a few hundred bytes long, so
the double copy is not a big deal).
2020-08-05 19:50:38 +08:00
Oliver Jowett 6986b3847f WIP on new faup1090 output, data aging, refactoring 2017-12-02 17:38:33 +00:00
Oliver Jowett 2142d2edf5 Whitespace changes only: cleaning up trailing whitespace at EOL 2017-06-15 18:17:07 +01:00
Oliver Jowett 72e786af35 Tweak reported timestamps so that the relative timing of Mode S and
Mode A/C messages is the same as from a Beast/Radarcape.
2017-01-15 19:29:25 +00:00
Oliver Jowett 5063efe064 Add #ifdef-ed code to display mode A/C signals graphically. 2016-11-12 17:13:36 +00:00
Oliver Jowett 32231cf142 Tweaks to A/C demodulator.
* use a global noise level rather than one computed from a few bits
 * work out level vs power confusion in some thresholds
 * fix the power calculation for working out the phase offset from
   the framing bits
 * require fewer quiet trailing bits
 * relax the bit-threshold tests
2016-11-12 17:10:29 +00:00
Oliver Jowett cc47718a2d Measure mean signal level in the converters.
Rearrange the meaning of the measured power level to be consistent
with the signal level.
2016-11-12 14:07:58 +00:00
Oliver Jowett 54ca2c7fb2 WIP big rewrite of message decoding / aircraft tracking. 2016-08-27 14:34:14 +01:00
Oliver Jowett 36a5c16dd2 Initialize from static "zero" messages rather than using memset. 2016-08-26 21:39:39 +01:00
Oliver Jowett a06b13d42a Relax the A/C quiet threshold; this seems to pick up a lot more A/C messages. 2016-07-24 15:05:52 +01:00
rxseger 75b69452ef Remove unused functions in demod_2400 2016-06-06 22:28:33 -07:00
Oliver Jowett b8dc3973d1 Always measure noise power, silently ignore --measure-noise if given. 2016-05-31 11:54:34 +01:00
Oliver Jowett d419b62a65 Always use phase enhancement; silently ignore --phase-enhance if given. 2016-05-31 11:47:57 +01:00
Oliver Jowett 5781e6ab96 Be a bit more aggressive about rejecting noise in the space periods. 2016-03-20 20:49:30 +00:00
Oliver Jowett f6bdb61b13 Experimental 2.4MHz Mode A/C demodulator. 2016-03-20 19:49:37 +00:00
Oliver Jowett 21bdc45bf0 Tweaks to noise measurements. 2015-06-16 10:13:25 +01:00
Oliver Jowett 03b53c2d29 Factor out the sample -> magnitude conversion code and make everything a little less sample-rate-dependent.
Add optional noise measurement (cheaper than the old version)
Add optional DC filter (expensive, not really needed with rtlsdr input)
2015-06-15 22:14:37 +01:00
Oliver Jowett 15ea5ba3da Rearrangements to the receive thread.
Magnitude conversion now happens immediately when sample data is
received, so there is no risk of newly received data clobbering old
data under CPU overload.
2015-04-09 18:51:31 +01: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 965ac96493 Update bestscore even if decoding fails so we register the number of "unknown ICAO" messages correctly. 2015-02-06 13:11:41 +00:00
Oliver Jowett 4fb607a826 Noise floor measurement is too expensive to be worth it, disable it. 2015-01-22 23:38:21 +00:00
Oliver Jowett dc8891e0ba Reduce the demodulation length properly when we see a 56-bit DF. 2015-01-22 23:34:47 +00:00
Oliver Jowett a59077a370 Stats overhaul. 2015-01-22 19:49:19 +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 20456a83fd Ditch SNR calcs too. 2015-01-21 19:10:07 +00:00
Oliver Jowett 00e232cc4f Try unrolling the inner loop to speed things up. 2015-01-21 19:03:51 +00:00
Oliver Jowett ef098a2461 Import new 2.4MHz demodulator from experimental branch. 2015-01-21 13:32:17 +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 f753c2d9fe Separate 2.4MHz demodulator into its own file. 2015-01-19 23:50:25 +00:00