Commit graph

293 commits

Author SHA1 Message Date
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
Malcolm Robb e33591d65d VK1ET : Check Bit Correction against ICAO cache
If we error correct a DF17 frame, check that the ICAOaddr exists in our
recently seen ICAO cache. This reduces the likelyhood of birthday
paradox solutions producing false ICAO addresses
2013-05-21 16:01:54 +01:00
Malcolm Robb 542b94dedb VK1ET : Changes to fixBitErrors()
1) Reduce complexity of fixBitErrors()
2) Inline flipBits()
3) Remove validation checks that can never occur.
2013-05-21 13:40:07 +01:00
Malcolm Robb 0a0ba165db VK1ET : Changes to modesInitError()
Restrict Syndromes to exclude DF bits. Do NOT introduce syndromes for
errors in the first 5 bits (DF field)

Use the --aggressive flag to see if we populate the two-bit error
syndromes. If --aggressive is not specified, then we don't attempt to
fix two bit errors.
2013-05-21 13:25:33 +01:00
Malcolm Robb 640d63a0d1 VK1ET: Shorten CRC calculation
We don't need to include the CRC itself one bit at a time. This shortens
the loop count by 24 iterations, so should be much faster
2013-05-21 12:54:34 +01:00
Malcolm Robb f33a7090b0 VK1ET : Better pthread termination
Close threads, mutex and conditions using pthread functions

Also, correct/update a few comments.
2013-05-21 12:08:35 +01:00
Malcolm Robb 92fd06bcd6 VK1ET : Bugfix in Error correction table
vk1etI believe there is an error in the way the CRC error syndromes are
being created in the two bit case. The inner loop was introducing an
extra error bit each time through rather than moving it. Below is the
modified code fragment for syndrome creation collapsedSun 07:26
19 May 2013 07:26vk1et [notifications@github.com]Actions
To:Mantirez/dump1090 ‎[dump1090@noreply.github.com]‎Cc:MMalcolmRobb
‎[Support@ATTAvionics.com]‎

To help protect your privacy, some content in this message has been
blocked. If you're sure this message is from a trusted sender and you
want to re-enable the blocked features, click here.
Bugfix first noted by VK1ET, and posted here :
https://github.com/antirez/dump1090/pull/23#issuecomment-18113094

I believe there is an error in the way the CRC error syndromes are being
created in the two bit case. The inner loop was introducing an extra
error bit each time through rather than moving it.
2013-05-21 11:28:56 +01:00
Malcolm Robb eac2a90a8a Version update
Version update for terribl and bdavenport's combined changes
2013-05-14 22:26:26 +01:00
terribl 9ea6f3e8e2 Merge remote-tracking branch 'upstream/master' 2013-05-14 12:54:05 +03:00
Malcolm Robb df4a24bf14 Version update for Ulrich
Updated the version number for Ulrich's code

Replaced some Tabs with spaces

Forward declaration of the fixBitErrors() function required for M$ VC
6.0 to suppress warning messages.
2013-05-14 10:49:57 +01:00
Ulrich Kuehn feab602088 Call new error correction code. Instead of bit positions record no. of corrected bits. 2013-05-12 17:57:26 +02:00
Ulrich Kuehn 6d5d7a4244 Test code for new bit error correction plus timing. This code is run when debugging. 2013-05-12 17:41:22 +02:00
Ulrich Kuehn 0a4fc6e98f Added code for table based correction of bit errors. Code is not called yet except initialisation. 2013-05-12 17:33:44 +02:00
terribl cac715e40a Upstream merge conflicts resolved 2013-05-12 09:50:20 +03:00
Malcolm Robb f56679a61d VK1ET : Bugfix pTimestamp printf()
Change the type of pTimestamp from char* to unsigned char* to stop sign
extension messing up the printf("%02X,pTimestamp stuff
2013-05-12 01:17:38 +01:00
terribl e65e873c13 Added flags to json for valid position and heading
As MalcolmRobb suggested.

	modified:   dump1090.c
	modified:   public_html/script.js
2013-05-11 23:36:11 +03:00
Malcolm Robb c83d404c4a Update of some comments, Version and release 2013-05-11 16:11:45 +01:00
Malcolm Robb d0469061ff Update ModeA/C to ModeS
Update the ModeA/C to Mode S comparison routine to use bFlags.
2013-05-11 15:02:34 +01:00
Malcolm Robb 6427fcc1ee VK1ET : --Interactive display changes
Based on a submission by VK1ET, but I've tweaked it a bit to use the
bFlags.

Basically, only print out values in --interactive that have been
received from the aircraft. Previous versions would display 0.000 for
lat and long for any positionless aircraft. This version prints blanks
instead for any/all fields that are not yet known.
2013-05-10 18:17:19 +01:00
Malcolm Robb cd86d58898 Major Rewrite of SBS output code
Remove dependency of the SBS output code on the historic (a) aircraft
structure. The only items that were required were the decoded aircraft
Lat/Lon and these are now included in the mm structure.

Rewrite the SBS output code to use mm->bFlags when populating the output
fields. This ensures that all available data is output, and also that no
stale data is sent.

Using the mm->bFlags variable for SBS output means there is no further
requirement for the sbsFlags member in the aircraft structure, so remove
it.

Cross your fingers and hope this hasn't introduced too many bugs !
2013-05-10 17:27:34 +01:00
Malcolm Robb 7df6d656a0 Implement additional Decoding and Tidy
Implement additional bFlags to validate AircraftOnGround, and FS.

Decode Aircraft On Ground from DF0, DF4, DF5, DF16, DF20, and DF21 where
possible.
Flag FS as valid for DF4, DF5, DF20, DF21,

Remove dr and um from the mm structure. They're only used in console
list output mode, so decode them there if required.
2013-05-10 17:17:10 +01:00
Malcolm Robb 60aa63b421 Merge remote-tracking branch 'origin/master' into Debug
Conflicts:
	dump1090.c
2013-05-10 11:02:46 +01:00
Malcolm Robb 914923f8bb Fix terribl's commit for Microsoft C
Microsoft Visual C 6.0 doesn't support inline declaration of variables.

Also, need to update the version number.
2013-05-10 00:12:36 +01:00
terribl c5fdde64e4 Added resetMap()-function to web-view.
+ some small tweaks.

	modified:   dump1090.c
	modified:   public_html/script.js
2013-05-09 21:57:33 +03:00
Malcolm Robb 735429b87a Additional bFlags for Lat/Lon decoding
Additional flags in the bFlags variables for even and odd CPR lat/lon
updates.

Change the interactiveReceiveData function to use the bFlags when
updating the aircraft (a) structure from the newly received (mm) message
structure. This should hopefully be faster than basically re-decoding
the DF, type and subtypes all over again.

If we decode the lat/lon into the aircraft (a) structure, back populate
it into the message (mm) structure. This allows us to print a decoded
Lat/Lon in the decoded message list output.
2013-05-09 18:48:07 +01:00
Malcolm Robb f011f07e9f Tidy up ModeA/C mm and a structure
If --modeac is specified, then the program will be building an aircraft
list. Calculate the altitude when we create the aircraft structure (a) ,
and then back copy it into the mm structure. This avoids us having to do
a second ModeAtoModeC conversion in the list output display.

Also - bug fix in the ns_vel calculation.
2013-05-09 16:40:04 +01:00
terribl 6968bf92a6 Splitted gmap.html to multiple files in new 'public_html'-directory.
Changes to 'dump1090.c'-file made accordingly.

	modified:   .gitignore
	modified:   dump1090.c
	deleted:    gmap.html
	new file:   public_html/gmap.html
	new file:   public_html/script.js
	new file:   public_html/style.css
2013-05-09 17:59:26 +03:00
Malcolm Robb fc7d1e27c9 Complete the bFlags decoding
Update the bFlags structure member to indicate which other structure
members contain decoded values.

Also, trim out mm structure members that are simple bitwise ands from
the raw data, unless the results are used in lots of places whereby
decoding them once is more efficient.
2013-05-09 15:29:25 +01:00
Malcolm Robb a3d62f96b7 VK1ET : More Decoding of DF-17 ground reports
Extend the DF-17 CPR decoding to use User Lat/Lon for ground positions.

Also start implementing a bFlags structure variable to indicate which
fields in the mm and a data structures contain valid values.
2013-05-09 15:06:07 +01:00
Malcolm Robb cc464b0a34 User Lat/Lon setting
Based on initial code supplied by VK1ET

Allow the user to specify their receivers (technically their aerials)
physical location. This is required for decoding ground positions, and
also for uploading aircraft data to various sharer sites.

The position can be hardwired by setting the MODES_USER_LATITUDE_DFLT
and MODES_USER_LONGITUDE_DFLT constants before compilation, or entered
at runtime via the new command line switches --lat and --lon.   Either
way, the values are checked for validity before use.
2013-05-09 11:29:18 +01:00
Malcolm Robb 5f009a3264 VK1ET ; Decode DF-17 ground position reports 2013-05-09 00:40:57 +01:00
Malcolm Robb 6b53c9e73a Move the clearing of mm for modeA/C
Only clear mm after we are sure we have got a Mode A/C. This reduces
processor load.

Also tidy up some Linux compiler warnings that result from the last
change.
2013-05-08 22:38:31 +01:00
Malcolm Robb 8048cbec6b Better decoding of DF-17 Airborne Velocity
Based on a submission by VK1ET. Fully decode DF-17, metype 19. Take care
to only update fields that are valid in the data.

Also, initialise (to zero) the mm structures before use
2013-05-08 22:16:38 +01:00
Malcolm Robb 6af4bb7431 VK1ET : Only Decode valid AC12 and AC13 altitudes
Decode DF17 altitudes only if valid (i.e. must be a non-zero field)
2013-05-08 20:13:11 +01:00
Malcolm Robb 8efe64982a Tidy up some comments and initialisation 2013-05-08 19:48:08 +01:00
Malcolm Robb dd72fc6dd5 VK1ET : Allow stats in --interactive mode 2013-05-08 19:38:10 +01:00
Malcolm Robb fb5ef77cd1 VK1ET : Fix AC12 Altitude decoding 2013-05-08 19:34:47 +01:00
Malcolm Robb 71ace95fd4 Additional Timestamps for Lat Lon
1) Implement additional timestamps to remember when a new Lat/Lon value
is generated.

2) Increase callsign[] character array to 16 chars  to make it long word
aligned.

3) Change some more comments from /* to //
2013-05-07 21:52:54 +01:00
Malcolm Robb ed076d0d98 Change initialisation of structures
Use memset to clear entire structures at initial creation to zero, and
then populate values that should not be zero. Do this rather than
individually clear each structure member to zero.

This should be faster, plus it's safer when new structure members are
added because you don't have to remember to initialise them.
2013-05-02 13:05:25 +01:00
Malcolm Robb 8870de2b9a Update --interactive with DF20/21 callsigns 2013-05-01 12:54:37 +01:00
Malcolm Robb 5457c5b177 Tidy DF17 print output routine 2013-04-30 18:25:32 +01:00
Malcolm Robb 36778f1284 Extract callsign from DF20 and DF21 2013-04-30 18:18:37 +01:00
Malcolm Robb 14c54599ac Improve callsign extraction from DF17
Use 32 bit registers to hold multiple characters and shift them. This
removes the need for multiple memory reads.

Also tidy up the DF-17 extraction routine to make it more readable.
2013-04-30 18:12:18 +01:00
Malcolm Robb 539faaaf27 Rename Gillham conversion function
ICAO documents refer to AC13 for altitude encoding and ID13 for squawk
wncoding. Rename decodeGillhamField to decodeID13Field to better
represent this.
2013-04-30 18:07:16 +01:00
Malcolm Robb 9783b4786a Generate an average Signal Strength
Remember the last 8 signal strengths for each aircraft and average them
for --interactive display. This produces a less jittery indication.
2013-04-30 18:03:30 +01:00
Malcolm Robb a296f2783f Make stats gathering conditional on Modes.stats
There is a quite complex if/else construct for gathering statistics
inside the main decodeModeS loop. To speed the loop up when not
gathering statistics, make the whole construct conditional on Modes.stat
being set.

Also tidy up a few comments
2013-04-30 10:46:23 +01:00
Malcolm Robb 2e21367f85 Calculate DF and size in decodeModeMessage
Allow the decodeModeMessage function to re-calculate msgtype and
msgbits. This makes the code a bit more portable by not requiring the
calling function to fill in these fields before the call.
2013-04-30 10:41:48 +01:00
Malcolm Robb c81498a0d0 Improve DF field error correction speed
Use bitmasks to speed up the detection of valid and invalid ICAO DF
field types.
2013-04-30 10:35:52 +01:00
Malcolm Robb 8d65abd317 Sanity Check on msglen after decoding
Add a sanity check to ensure that msglen is consistent with the DF type.
2013-04-30 10:32:23 +01:00
Malcolm Robb 5f7ed42050 VK1ET : Ctrl/C and other cleanup code
Changes supplied by John VK1ET.

This tidies up the thread termination, which then allows for use of [a
trapped] Ctrl/C to cleanly terminate the program and dump stats if flag
set.
2013-04-29 22:14:06 +01:00
Malcolm Robb 50cedd7fe2 Major re-write of decodeModesMessage
Lots of changes to the decodeModesMessages() function, and associated
helper functions, with the aim of speeding the code up by reducing the
number of calls to the CRC functions. Also, only update the mm variables
which are part of the message we're decoding.

Change the way CRC's are generated and checked.
Change the way single and double bit error is implemented.
General tidy up of the function to make it more readable.
2013-04-29 18:53:11 +01:00
Malcolm Robb e9b463d25c Update displayModesMessage()
Update displayModesMessage() to show additional ICAO defined DF types.
2013-04-29 18:39:40 +01:00
Malcolm Robb 19c11509e7 Mode S Gillham altitude changes
Modify all the Mode=S Gillham altitude decoding to use a new function
decodeGillhamField()

Change the Mode-S signal strength so that it rounds to the nearest
integer
2013-04-29 18:33:59 +01:00
Malcolm Robb e161b7662c DF Error detection and Correction
Added additional error detection and correction to the DF field of the
first byte in every ModeS frame.
2013-04-29 01:30:12 +01:00
Malcolm Robb 7cf79580a4 Change the message length decision
Assume that DF0-DF15 are all short 56 bit messages
Assume that DF16-DF31 are all long 112 bit messages

This helps us error detect and error recover for bits in the first byte
2013-04-28 20:53:30 +01:00
Malcolm Robb 748f2f5e91 Adjust --interactive display
Allow 8 character Longitudes to cope with -179.999

Change the type of signalLevel to unsigned chae. Negative signal levels
make no sense.
2013-04-28 16:24:33 +01:00
Malcolm Robb 8ed0574ac8 Implement 100 ft Altitudes
The DF's for altitude include a Q bit to distinguish either 100ft or
25ft altitude encoding. This version implements the 100ft increments
used by older aircraft. These codes are basically ModeC altitudes
transmitted over ModeS.
2013-04-28 02:17:57 +01:00
Malcolm Robb 05187f76e7 Add items to --interactive display
Reformat the --interactive display to show more information

Add a "Mode" column. This displays the The primary message type "S" or
"A" plus any matching modes "a" and/or "c". Requires --modeac switch.

Add a "Sig" column to show the signal strength.
2013-04-27 00:18:14 +01:00
Malcolm Robb 4d370bd247 Change default for error correction to OFF
Add a --fix command line switch to enable error correction using CRC.
Change the default to OFF/Disabled.

Error correction can very occasionally result in an incorrect solution
to the crc equation.  It also takes significant CPU work for very few
corrected results. Therefore, the default has been changed to OFF, but
you can re-enable it if you wish by using the --fix command line switch.
2013-04-26 10:12:47 +01:00
Malcolm Robb f77a85e8b8 VK1ET : Additions to check fflags
Implement changes suggested by John/VK1ET

Changes to cprNFunction to ensure fflag {was 'isodd'} is used as a flag.
Fix to decodeCPRrelative to pass 'surface' flag.
2013-04-26 09:49:53 +01:00
Malcolm Robb 2acb0947f0 Changes to Mode A/C/S matchup code
Try to improve the matching of ModeA/C codes to Known Mode-S
2013-04-26 01:40:52 +01:00
Malcolm Robb 25f92e54ba Change Squawk/ModeA code
The original code stores the squawk as a decimal (base 10) value. Change
this to a hex value to reduce the amount of maths required to convert
the input binary value..

Rename all the variables used to store the squawk to "modeA", rather
than variously identity, squawk and modeA.
2013-04-25 23:22:34 +01:00
Malcolm Robb f9c1dc1da5 Remove duplicate varbles
Several variables within structures contain the same information in
different forms.

The aircraft structure contains addr and hexaddr. Hexaddr is a printable
string version of addr. However, hexaddr is only ever used in printf
statments, so we can use printf(%06x) to print addr. This saves a printf
for every received command.

The modesMessage structure contains addr, and aa1,aa2,aa3 as separate
bytes. aa1,aa2 and aa3 are only ever used to construct addr, and to
print out. Therefore, we can use addr instead of them..
2013-04-25 21:17:00 +01:00
Malcolm Robb 3766492067 Change Mode-A/C to Mode-S detection
The original code made an attempt to reconcile a newly arrived ModeA/C
message with every known Mode-S report at the time of detection.
However, the results of matching up Modes A/C and S are only used in the
interactive display routine, and that is only called periodically from
within the BackgroundTasks loop.

Doing the matching on every ModeA/C arrival incurs quite a large CPU
processing load. Moving the matching up routine to the backgroundTasks
loop means that the task is performed muck less frequently and therefore
uses less CPU time.
2013-04-24 23:47:08 +01:00
Malcolm Robb 3dbc0efffc VK1ET : Decode mode ASCII hex input message types
Modifications entirely base on code supplied by John VK1ET.

Supports additional AVR raw ASCII input message stream types
2013-04-24 20:46:59 +01:00
Malcolm Robb a04e399d7e VK1ET : Implement Relative CPR decoding
Modifications entirely base on code supplied by John VK1ET.

Implements relative CPR Lat/Long decoding for --interactive display
2013-04-24 20:24:46 +01:00
Malcolm Robb b78b60677c Improvements to Mode A/C display
Allow a greater range and negative values for Mode C (down to -1200
feet)

Stop attempting to feed ModeA/C data to SBS Output stream.

Allow Mode A only matches to Mode-S squawks when the Mode A code does
not conflict with any possible (legal) Mode C code.

Allow Mode C matches to track aircraft climbing and descending
relatively slowly. This also helps when trying to match Mode-S altitudes
which are 25 foot increments, with Mode C altitudes which are in 100
foot increments.
2013-04-24 00:13:18 +01:00
Malcolm Robb d63ac81a6a Updated comments, ,no code changes 2013-04-23 22:18:15 +01:00
Malcolm Robb 9fff65ba58 Implement Mode A/C decoding
First attempt at decoding legacy SSR Modes A and C.

If the command line switch --modeac is used, the program will now
attempt to recover Mode A/C signals contained in the raw I/Q data
stream. The current recovery mechanism is quite strict and does not cope
well with overlapping and corrupt SSR replies. I estimate that less than
20% of possible returns are decoded correctly. Hopefully over the next
few iterations this can be improved.

If outputting raw data it is recommended to use the --net-ro-size and
--net-ro-rate command line options to reduce the number of very small
ethernet packets that will be generated by mode A/C replies.
2013-04-22 23:31:59 +01:00
Malcolm Robb 39cb96f24b Fix several bugs in input/output fromat
Thanks to vk1et for these.

1) Correct for additional timestamp langth in raw output buffer when
using mlat mode

2) Don't output a timestamp when the message has been received from a
remote site (the internet). This is to avoid upsetting MLAT because
there is an indeterminate delay between reception at the remote site and
subsequent message arrival in the local dump1090 instance.

3) Allow @ character for raw data input with timestamp, and correctly
calculate the length.
2013-04-20 11:29:27 +01:00
Malcolm Robb 11265089b4 Fix Bug in Beast Mode Output
Original code put the signal strength in before the timestamp. It should
be after.

Also add some code to support MODE A/C output at a future date.
2013-04-19 15:29:39 +01:00
Malcolm Robb e98728108c Bug fix in vertical sign
Incorrect shift amount when detecting vertical rate sign.  Thanks
John-vk1et.
2013-04-19 09:32:34 +01:00
Malcolm Robb 3d25f4bf1a Changes to prevent stale output in SBS-1 format
The original code calculates Lat/Long only if it receives two DF-17
(subtype 9 or 18) within one second of each other. I have no idea why.
It then caches the results in the aircrafts data structure for use in
the --interactive display.

When SBS-1 style ASCII output is selected (port 30003) the code does not
attempt to calculate Lat/Long from the data just received - instead it
picks it up from the cached information in the aircraft's data
structure.

However, if the data isn't being updated this results in stale Lat/Long
being sent out. This is most likely to occur when the aircraft is at the
extreme edge of the receivers range when it may be getting some DF-17s
containing Lat/Long, but not 2 per second. The program will continue
sending the stale data until the aircraft finally times out (default 60
seconds)

I have modified the code to include a sbsflags variable in the aircraft
data structure. When a new Lat/Long is decoded and put into the
structure, a bit is set to indicate SBS_LAT_LONG_FRESH. Then, once the
Lat/Long is output the first time, the bit is cleared. Thereafter the
code will not populate the Lat/Long fields in the output message until
SBS_LAT_LONG_FRESH is set again.
2013-04-17 23:09:01 +01:00
Malcolm Robb bbcf68cf11 Nunojpg Southern Hemisphere bug fix + 1
1) Incorporate nunojpg southern hemisphere bug fix
2) Initialise Modes.stat_DF_Corrected variable
2013-04-17 20:09:49 +01:00
Malcolm Robb a75442d11d Up issue the version and commit
Version 1.01.1503.13
2013-04-15 23:26:12 +01:00
Malcolm Robb 2431dc0c77 Added --net-ro-rate command line switch
The default is 0. This works in conjunction with --net-ro-size.

The program will attempt to gather up "net-ro-size" raw bytes before
sending them out over Ethernet. However, to avoid a long wait if the
traffic density is very low, the program will only wait for
"net-ro-rate" 64mS periods since the last send. before sending any data
added to the output buffer since the last send. This allows the user to
tailor the network load to suit their requirements.
2013-04-15 23:17:08 +01:00
Malcolm Robb 7779ef4d4f Correct CRLF order in SBS-1 ASCII output 2013-04-15 22:37:10 +01:00
Malcolm Robb b15ae2a544 Print DF-11 II/SI 2013-04-15 22:18:45 +01:00
Malcolm Robb 96afd52cb0 Speed up Squawk Decode
Re-write to avoid multiple reads of the same memory variable.
2013-04-15 22:12:40 +01:00
Malcolm Robb 6619d21970 Speed up Error Correction
Move memcopy to outside the main bit loop, and just flip the modified
bit back at the end of each loop if it didn;t work

Pass in a pointer to the mm structure being corrected, and fix-up the
crc with the value inside the function, rather than re-calculate on
return
2013-04-15 22:01:56 +01:00
Malcolm Robb bdf985a792 Don't attempt to error correct DF-11
Don't attempt to error correct DF-11, because we can't be sure that the
checksum/crc is supposed to be 0.

Also a few typo's corrected
2013-04-15 21:55:46 +01:00
Malcolm Robb bb20d0b5b8 SBS-1 ASCII output changes suggested by JungleJet
1) Populate Field 3 witn "111"
2) Populate field 4 with "11111"
3  Populate Field 6 with "111111"
4) End the record with <CRLF>, rather than just <LF>
5) Increase the ctrCommon buffer size to cope with additional field data

Apparently, this makes the output more compatible with Plane Plotter and
RTL1090.
2013-04-15 00:51:04 +01:00
Malcolm Robb 249c11a4c3 Add --net-ro-size command line switch
Allow the user to specify the minimum size of raw data to be sent to the
TCP port. Dump1090 will buffer up raw data until it has at least this
many bytes to send to the TCP socket.

The default is 0, which means every frame is sent to the TCP socket as
it is decoded. The maximum value is limited to 1300 bytes.

Note the buffer will  be flushed every 65 ms regardless of the amount of
data in it so that excessive in transmission do not occur.
2013-04-14 22:51:50 +01:00
Malcolm Robb 0263793928 Add version number to help output screen 2013-04-14 22:03:19 +01:00
Malcolm Robb 444b1cf3a2 Changed the date separator in SBS-1
Changed the separator from \ to /
2013-04-13 02:09:57 +01:00
Malcolm Robb 09d72d2897 Merge JungleJet Updates 2013-04-13 01:37:02 +01:00
Malcolm Robb d96f3a679e Added Raw Output Buffering
The original code wrote every individual received frame to the TCP port.
Some O/S's buffer smaller writes into larger packets. It appears that
some versions of Linux don't. The result is that the (Ethernet) network
gets bombarded with lots of small Ethernet packets.

Therefore, I've added a 1500 byte output buffer to the raw output
functions. Data is written into this buffer by the raw output routines.

Data is flushed out to the TCP port when either.
1) The latest write to the output buffer takes the contents to more than
1300 bytes
2) At the end of every processed block of data supplied by rtl-sdr. This
will be every 56mS or so,

The end result should be that on systems detecting a lot of traffic, you
should see lots of > 1300-byte Ethernet packets. On systems receiving
less traffic, you should see one network packet every 56 mS or so.

The total number of network packets should be much reduced, and their
average size much bigger. The worst case delay in transmission will be
56 mS.
2013-04-12 22:39:33 +01:00
Malcolm Robb 1324e28a38 Add Timestamps to SBS-1 format output
As requested by mlino

Note : I haven't been able to validate that the format is correct. I
think it should be Ok, but it needs someone with an SBS setup to check
it. Any offers?
2013-04-12 22:03:04 +01:00
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 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 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 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 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 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