Commit graph

161 commits

Author SHA1 Message Date
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