Whitespace changes only: cleaning up trailing whitespace at EOL

This commit is contained in:
Oliver Jowett 2017-06-15 18:16:51 +01:00
parent 98d64483d6
commit 2142d2edf5
35 changed files with 350 additions and 349 deletions

View file

@ -4,17 +4,17 @@
// //
// Copyright (c) 2015 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2015 Oliver Jowett <oliver@mutability.co.uk>
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "dump1090.h" #include "dump1090.h"

View file

@ -4,17 +4,17 @@
// //
// Copyright (c) 2015 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2015 Oliver Jowett <oliver@mutability.co.uk>
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef DUMP1090_CONVERT_H #ifndef DUMP1090_CONVERT_H

View file

@ -5,17 +5,17 @@
// Copyright (c) 2016-2017 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2016-2017 Oliver Jowett <oliver@mutability.co.uk>
// Copyright (c) 2017 FlightAware LLC // Copyright (c) 2017 FlightAware LLC
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "dump1090.h" #include "dump1090.h"

20
cpr.c
View file

@ -4,20 +4,20 @@
// //
// Copyright (c) 2014,2015 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2014,2015 Oliver Jowett <oliver@mutability.co.uk>
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file incorporates work covered by the following copyright and // This file incorporates work covered by the following copyright and
// permission notice: // permission notice:
// //
// Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com> // Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com>
@ -345,9 +345,9 @@ int decodeCPRrelative(double reflat, double reflon,
return (-1); // Time to give up - Latitude error return (-1); // Time to give up - Latitude error
} }
// Check to see that answer is reasonable - ie no more than 1/2 cell away // Check to see that answer is reasonable - ie no more than 1/2 cell away
if (fabs(rlat - reflat) > (AirDlat/2)) { if (fabs(rlat - reflat) > (AirDlat/2)) {
return (-1); // Time to give up - Latitude error return (-1); // Time to give up - Latitude error
} }
// Compute the Longitude Index "m" // Compute the Longitude Index "m"

14
cpr.h
View file

@ -4,17 +4,17 @@
// //
// Copyright (c) 2014,2015 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2014,2015 Oliver Jowett <oliver@mutability.co.uk>
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef DUMP1090_CPR_H #ifndef DUMP1090_CPR_H

View file

@ -4,17 +4,17 @@
// //
// Copyright (c) 2014,2015 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2014,2015 Oliver Jowett <oliver@mutability.co.uk>
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.

40
crc.c
View file

@ -4,17 +4,17 @@
// //
// Copyright (c) 2014,2015 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2014,2015 Oliver Jowett <oliver@mutability.co.uk>
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "dump1090.h" #include "dump1090.h"
@ -40,7 +40,7 @@ static void initLookupTables()
{ {
int i; int i;
uint8_t msg[112/8]; uint8_t msg[112/8];
for (i = 0; i < 256; ++i) { for (i = 0; i < 256; ++i) {
uint32_t c = i << 16; uint32_t c = i << 16;
int j; int j;
@ -141,7 +141,7 @@ static int prepareSubtable(struct errorinfo *table, int n, int maxsize, int offs
table[n].syndrome ^= single_bit_syndrome[i + offset]; table[n].syndrome ^= single_bit_syndrome[i + offset];
table[n].errors = error_bit+1; table[n].errors = error_bit+1;
table[n].bit[error_bit] = i; table[n].bit[error_bit] = i;
++n; ++n;
n = prepareSubtable(table, n, maxsize, offset, i + 1, endbit, &table[n-1], error_bit + 1, max_errors); n = prepareSubtable(table, n, maxsize, offset, i + 1, endbit, &table[n-1], error_bit + 1, max_errors);
} }
@ -200,7 +200,7 @@ static struct errorinfo *prepareErrorTable(int bits, int max_correct, int max_de
maxsize += combinations(bits - 5, i); // space needed for all i-bit errors maxsize += combinations(bits - 5, i); // space needed for all i-bit errors
} }
#ifdef CRCDEBUG #ifdef CRCDEBUG
fprintf(stderr, "Preparing syndrome table to correct up to %d-bit errors (detecting %d-bit errors) in a %d-bit message (max %d entries)\n", max_correct, max_detect, bits, maxsize); fprintf(stderr, "Preparing syndrome table to correct up to %d-bit errors (detecting %d-bit errors) in a %d-bit message (max %d entries)\n", max_correct, max_detect, bits, maxsize);
#endif #endif
@ -212,7 +212,7 @@ static struct errorinfo *prepareErrorTable(int bits, int max_correct, int max_de
// ignore the first 5 bits (DF type) // ignore the first 5 bits (DF type)
usedsize = prepareSubtable(table, 0, maxsize, 112 - bits, 5, bits, &base_entry, 0, max_correct); usedsize = prepareSubtable(table, 0, maxsize, 112 - bits, 5, bits, &base_entry, 0, max_correct);
#ifdef CRCDEBUG #ifdef CRCDEBUG
fprintf(stderr, "%d syndromes (expected %d).\n", usedsize, maxsize); fprintf(stderr, "%d syndromes (expected %d).\n", usedsize, maxsize);
fprintf(stderr, "Sorting syndromes..\n"); fprintf(stderr, "Sorting syndromes..\n");
@ -220,15 +220,15 @@ static struct errorinfo *prepareErrorTable(int bits, int max_correct, int max_de
qsort(table, usedsize, sizeof(struct errorinfo), syndrome_compare); qsort(table, usedsize, sizeof(struct errorinfo), syndrome_compare);
#ifdef CRCDEBUG #ifdef CRCDEBUG
{ {
// Show the table stats // Show the table stats
fprintf(stderr, "Undetectable errors:\n"); fprintf(stderr, "Undetectable errors:\n");
for (i = 1; i <= max_correct; ++i) { for (i = 1; i <= max_correct; ++i) {
int j, count; int j, count;
count = 0; count = 0;
for (j = 0; j < usedsize; ++j) for (j = 0; j < usedsize; ++j)
if (table[j].errors == i && table[j].syndrome == 0) if (table[j].errors == i && table[j].syndrome == 0)
++count; ++count;
@ -240,7 +240,7 @@ static struct errorinfo *prepareErrorTable(int bits, int max_correct, int max_de
// Handle ambiguous cases, where there is more than one possible error pattern // Handle ambiguous cases, where there is more than one possible error pattern
// that produces a given syndrome (this happens with >2 bit errors). // that produces a given syndrome (this happens with >2 bit errors).
#ifdef CRCDEBUG #ifdef CRCDEBUG
fprintf(stderr, "Finding collisions..\n"); fprintf(stderr, "Finding collisions..\n");
#endif #endif
for (i = 0, j = 0; i < usedsize; ++i) { for (i = 0, j = 0; i < usedsize; ++i) {
@ -264,7 +264,7 @@ static struct errorinfo *prepareErrorTable(int bits, int max_correct, int max_de
#endif #endif
usedsize = j; usedsize = j;
} }
// Flag collisions we want to detect but not correct // Flag collisions we want to detect but not correct
if (max_detect > max_correct) { if (max_detect > max_correct) {
int flagged; int flagged;
@ -302,9 +302,9 @@ static struct errorinfo *prepareErrorTable(int bits, int max_correct, int max_de
table = realloc(table, usedsize * sizeof(struct errorinfo)); table = realloc(table, usedsize * sizeof(struct errorinfo));
#endif #endif
} }
*size_out = usedsize; *size_out = usedsize;
#ifdef CRCDEBUG #ifdef CRCDEBUG
{ {
// Check the table. // Check the table.
@ -335,9 +335,9 @@ static struct errorinfo *prepareErrorTable(int bits, int max_correct, int max_de
fprintf(stderr, "Syndrome table summary:\n"); fprintf(stderr, "Syndrome table summary:\n");
for (i = 1; i <= max_correct; ++i) { for (i = 1; i <= max_correct; ++i) {
int j, count, possible; int j, count, possible;
count = 0; count = 0;
for (j = 0; j < usedsize; ++j) for (j = 0; j < usedsize; ++j)
if (table[j].errors == i) if (table[j].errors == i)
++count; ++count;

14
crc.h
View file

@ -4,17 +4,17 @@
// //
// Copyright (c) 2014,2015 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2014,2015 Oliver Jowett <oliver@mutability.co.uk>
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef DUMP1090_CRC_H #ifndef DUMP1090_CRC_H

View file

@ -4,17 +4,17 @@
// //
// Copyright (c) 2014,2015 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2014,2015 Oliver Jowett <oliver@mutability.co.uk>
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "dump1090.h" #include "dump1090.h"
@ -98,7 +98,7 @@ void demodulate2400(struct mag_buf *mag)
// phase 6: 0/4\2 2/4\0 0 0 0 2/4\0/5\1 0 0 0 0 0 0 X2 // phase 6: 0/4\2 2/4\0 0 0 0 2/4\0/5\1 0 0 0 0 0 0 X2
// phase 7: 0/3 3\1/5\0 0 0 0 1/5\0/4\2 0 0 0 0 0 0 X3 // phase 7: 0/3 3\1/5\0 0 0 0 1/5\0/4\2 0 0 0 0 0 0 X3
// //
// quick check: we must have a rising edge 0->1 and a falling edge 12->13 // quick check: we must have a rising edge 0->1 and a falling edge 12->13
if (! (preamble[0] < preamble[1] && preamble[12] > preamble[13]) ) if (! (preamble[0] < preamble[1] && preamble[12] > preamble[13]) )
continue; continue;
@ -174,7 +174,7 @@ void demodulate2400(struct mag_buf *mag)
// Decode all the next 112 bits, regardless of the actual message // Decode all the next 112 bits, regardless of the actual message
// size. We'll check the actual message type later // size. We'll check the actual message type later
pPtr = &m[j+19] + (try_phase/5); pPtr = &m[j+19] + (try_phase/5);
phase = try_phase % 5; phase = try_phase % 5;
@ -184,7 +184,7 @@ void demodulate2400(struct mag_buf *mag)
switch (phase) { switch (phase) {
case 0: case 0:
theByte = theByte =
(slice_phase0(pPtr) > 0 ? 0x80 : 0) | (slice_phase0(pPtr) > 0 ? 0x80 : 0) |
(slice_phase2(pPtr+2) > 0 ? 0x40 : 0) | (slice_phase2(pPtr+2) > 0 ? 0x40 : 0) |
(slice_phase4(pPtr+4) > 0 ? 0x20 : 0) | (slice_phase4(pPtr+4) > 0 ? 0x20 : 0) |
@ -198,7 +198,7 @@ void demodulate2400(struct mag_buf *mag)
phase = 1; phase = 1;
pPtr += 19; pPtr += 19;
break; break;
case 1: case 1:
theByte = theByte =
(slice_phase1(pPtr) > 0 ? 0x80 : 0) | (slice_phase1(pPtr) > 0 ? 0x80 : 0) |
@ -213,7 +213,7 @@ void demodulate2400(struct mag_buf *mag)
phase = 2; phase = 2;
pPtr += 19; pPtr += 19;
break; break;
case 2: case 2:
theByte = theByte =
(slice_phase2(pPtr) > 0 ? 0x80 : 0) | (slice_phase2(pPtr) > 0 ? 0x80 : 0) |
@ -228,9 +228,9 @@ void demodulate2400(struct mag_buf *mag)
phase = 3; phase = 3;
pPtr += 19; pPtr += 19;
break; break;
case 3: case 3:
theByte = theByte =
(slice_phase3(pPtr) > 0 ? 0x80 : 0) | (slice_phase3(pPtr) > 0 ? 0x80 : 0) |
(slice_phase0(pPtr+3) > 0 ? 0x40 : 0) | (slice_phase0(pPtr+3) > 0 ? 0x40 : 0) |
(slice_phase2(pPtr+5) > 0 ? 0x20 : 0) | (slice_phase2(pPtr+5) > 0 ? 0x20 : 0) |
@ -243,9 +243,9 @@ void demodulate2400(struct mag_buf *mag)
phase = 4; phase = 4;
pPtr += 19; pPtr += 19;
break; break;
case 4: case 4:
theByte = theByte =
(slice_phase4(pPtr) > 0 ? 0x80 : 0) | (slice_phase4(pPtr) > 0 ? 0x80 : 0) |
(slice_phase1(pPtr+3) > 0 ? 0x40 : 0) | (slice_phase1(pPtr+3) > 0 ? 0x40 : 0) |
(slice_phase3(pPtr+5) > 0 ? 0x20 : 0) | (slice_phase3(pPtr+5) > 0 ? 0x20 : 0) |
@ -265,7 +265,7 @@ void demodulate2400(struct mag_buf *mag)
switch (msg[0] >> 3) { switch (msg[0] >> 3) {
case 0: case 4: case 5: case 11: case 0: case 4: case 5: case 11:
bytelen = MODES_SHORT_MSG_BYTES; break; bytelen = MODES_SHORT_MSG_BYTES; break;
case 16: case 17: case 18: case 20: case 21: case 24: case 16: case 17: case 18: case 20: case 21: case 24:
break; break;
@ -283,7 +283,7 @@ void demodulate2400(struct mag_buf *mag)
bestmsg = msg; bestmsg = msg;
bestscore = score; bestscore = score;
bestphase = try_phase; bestphase = try_phase;
// swap to using the other buffer so we don't clobber our demodulated data // swap to using the other buffer so we don't clobber our demodulated data
// (if we find a better result then we'll swap back, but that's OK because // (if we find a better result then we'll swap back, but that's OK because
// we no longer need this copy if we found a better one) // we no longer need this copy if we found a better one)
@ -362,7 +362,7 @@ void demodulate2400(struct mag_buf *mag)
// few bits of the first message, but the message bits didn't // few bits of the first message, but the message bits didn't
// overlap) // overlap)
j += msglen*12/5; j += msglen*12/5;
// Pass data to the next layer // Pass data to the next layer
useModesMessage(&mm); useModesMessage(&mm);
} }

View file

@ -4,17 +4,17 @@
// //
// Copyright (c) 2014,2015 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2014,2015 Oliver Jowett <oliver@mutability.co.uk>
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef DUMP1090_DEMOD_2400_H #ifndef DUMP1090_DEMOD_2400_H

View file

@ -4,20 +4,20 @@
// //
// Copyright (c) 2014-2016 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2014-2016 Oliver Jowett <oliver@mutability.co.uk>
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file incorporates work covered by the following copyright and // This file incorporates work covered by the following copyright and
// permission notice: // permission notice:
// //
// Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com> // Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com>
@ -158,24 +158,24 @@ void modesInit(void) {
// Validate the users Lat/Lon home location inputs // Validate the users Lat/Lon home location inputs
if ( (Modes.fUserLat > 90.0) // Latitude must be -90 to +90 if ( (Modes.fUserLat > 90.0) // Latitude must be -90 to +90
|| (Modes.fUserLat < -90.0) // and || (Modes.fUserLat < -90.0) // and
|| (Modes.fUserLon > 360.0) // Longitude must be -180 to +360 || (Modes.fUserLon > 360.0) // Longitude must be -180 to +360
|| (Modes.fUserLon < -180.0) ) { || (Modes.fUserLon < -180.0) ) {
Modes.fUserLat = Modes.fUserLon = 0.0; Modes.fUserLat = Modes.fUserLon = 0.0;
} else if (Modes.fUserLon > 180.0) { // If Longitude is +180 to +360, make it -180 to 0 } else if (Modes.fUserLon > 180.0) { // If Longitude is +180 to +360, make it -180 to 0
Modes.fUserLon -= 360.0; Modes.fUserLon -= 360.0;
} }
// If both Lat and Lon are 0.0 then the users location is either invalid/not-set, or (s)he's in the // If both Lat and Lon are 0.0 then the users location is either invalid/not-set, or (s)he's in the
// Atlantic ocean off the west coast of Africa. This is unlikely to be correct. // Atlantic ocean off the west coast of Africa. This is unlikely to be correct.
// Set the user LatLon valid flag only if either Lat or Lon are non zero. Note the Greenwich meridian // Set the user LatLon valid flag only if either Lat or Lon are non zero. Note the Greenwich meridian
// is at 0.0 Lon,so we must check for either fLat or fLon being non zero not both. // is at 0.0 Lon,so we must check for either fLat or fLon being non zero not both.
// Testing the flag at runtime will be much quicker than ((fLon != 0.0) || (fLat != 0.0)) // Testing the flag at runtime will be much quicker than ((fLon != 0.0) || (fLat != 0.0))
Modes.bUserFlags &= ~MODES_USER_LATLON_VALID; Modes.bUserFlags &= ~MODES_USER_LATLON_VALID;
if ((Modes.fUserLat != 0.0) || (Modes.fUserLon != 0.0)) { if ((Modes.fUserLat != 0.0) || (Modes.fUserLon != 0.0)) {
Modes.bUserFlags |= MODES_USER_LATLON_VALID; Modes.bUserFlags |= MODES_USER_LATLON_VALID;
} }
// Limit the maximum requested raw output size to less than one Ethernet Block // Limit the maximum requested raw output size to less than one Ethernet Block
if (Modes.net_output_flush_size > (MODES_OUT_FLUSH_SIZE)) if (Modes.net_output_flush_size > (MODES_OUT_FLUSH_SIZE))
{Modes.net_output_flush_size = MODES_OUT_FLUSH_SIZE;} {Modes.net_output_flush_size = MODES_OUT_FLUSH_SIZE;}
if (Modes.net_output_flush_interval > (MODES_OUT_FLUSH_INTERVAL)) if (Modes.net_output_flush_interval > (MODES_OUT_FLUSH_INTERVAL))
@ -372,7 +372,7 @@ void backgroundTasks(void) {
if (Modes.net) { if (Modes.net) {
modesNetPeriodicWork(); modesNetPeriodicWork();
} }
// Refresh screen when in interactive mode // Refresh screen when in interactive mode
@ -391,21 +391,21 @@ void backgroundTasks(void) {
} else { } else {
Modes.stats_latest_1min = (Modes.stats_latest_1min + 1) % 15; Modes.stats_latest_1min = (Modes.stats_latest_1min + 1) % 15;
Modes.stats_1min[Modes.stats_latest_1min] = Modes.stats_current; Modes.stats_1min[Modes.stats_latest_1min] = Modes.stats_current;
add_stats(&Modes.stats_current, &Modes.stats_alltime, &Modes.stats_alltime); add_stats(&Modes.stats_current, &Modes.stats_alltime, &Modes.stats_alltime);
add_stats(&Modes.stats_current, &Modes.stats_periodic, &Modes.stats_periodic); add_stats(&Modes.stats_current, &Modes.stats_periodic, &Modes.stats_periodic);
reset_stats(&Modes.stats_5min); reset_stats(&Modes.stats_5min);
for (i = 0; i < 5; ++i) for (i = 0; i < 5; ++i)
add_stats(&Modes.stats_1min[(Modes.stats_latest_1min - i + 15) % 15], &Modes.stats_5min, &Modes.stats_5min); add_stats(&Modes.stats_1min[(Modes.stats_latest_1min - i + 15) % 15], &Modes.stats_5min, &Modes.stats_5min);
reset_stats(&Modes.stats_15min); reset_stats(&Modes.stats_15min);
for (i = 0; i < 15; ++i) for (i = 0; i < 15; ++i)
add_stats(&Modes.stats_1min[i], &Modes.stats_15min, &Modes.stats_15min); add_stats(&Modes.stats_1min[i], &Modes.stats_15min, &Modes.stats_15min);
reset_stats(&Modes.stats_current); reset_stats(&Modes.stats_current);
Modes.stats_current.start = Modes.stats_current.end = now; Modes.stats_current.start = Modes.stats_current.end = now;
if (Modes.json_dir) if (Modes.json_dir)
writeJsonToFile("stats.json", generateStatsJson); writeJsonToFile("stats.json", generateStatsJson);

View file

@ -4,20 +4,20 @@
// //
// Copyright (c) 2014-2016 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2014-2016 Oliver Jowett <oliver@mutability.co.uk>
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file incorporates work covered by the following copyright and // This file incorporates work covered by the following copyright and
// permission notice: // permission notice:
// //
// Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com> // Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com>
@ -374,10 +374,10 @@ struct modesMessage {
// Generic fields // Generic fields
unsigned char msg[MODES_LONG_MSG_BYTES]; // Binary message. unsigned char msg[MODES_LONG_MSG_BYTES]; // Binary message.
unsigned char verbatim[MODES_LONG_MSG_BYTES]; // Binary message, as originally received before correction unsigned char verbatim[MODES_LONG_MSG_BYTES]; // Binary message, as originally received before correction
int msgbits; // Number of bits in message int msgbits; // Number of bits in message
int msgtype; // Downlink format # int msgtype; // Downlink format #
uint32_t crc; // Message CRC uint32_t crc; // Message CRC
int correctedbits; // No. of bits corrected int correctedbits; // No. of bits corrected
uint32_t addr; // Address Announced uint32_t addr; // Address Announced
addrtype_t addrtype; // address format / source addrtype_t addrtype; // address format / source
uint64_t timestampMsg; // Timestamp of the message (12MHz clock) uint64_t timestampMsg; // Timestamp of the message (12MHz clock)
@ -462,13 +462,14 @@ struct modesMessage {
unsigned squawk; // 13 bits identity (Squawk), encoded as 4 hex digits unsigned squawk; // 13 bits identity (Squawk), encoded as 4 hex digits
char callsign[9]; // 8 chars flight number, NUL-terminated char callsign[9]; // 8 chars flight number, NUL-terminated
unsigned category; // A0 - D7 encoded as a single hex byte unsigned category; // A0 - D7 encoded as a single hex byte
// valid if cpr_valid
cpr_type_t cpr_type; // The encoding type used (surface, airborne, coarse TIS-B)
unsigned cpr_lat; // Non decoded latitude.
unsigned cpr_lon; // Non decoded longitude.
unsigned cpr_nucp; // NUCp/NIC value implied by message type
airground_t airground; // air/ground state // valid if cpr_valid
cpr_type_t cpr_type; // The encoding type used (surface, airborne, coarse TIS-B)
unsigned cpr_lat; // Non decoded latitude.
unsigned cpr_lon; // Non decoded longitude.
unsigned cpr_nucp; // NUCp/NIC value implied by message type
airground_t airground; // air/ground state
// valid if cpr_decoded: // valid if cpr_decoded:
double decoded_lat; double decoded_lat;

View file

@ -4,20 +4,20 @@
// //
// Copyright (c) 2014,2015 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2014,2015 Oliver Jowett <oliver@mutability.co.uk>
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file incorporates work covered by the following copyright and // This file incorporates work covered by the following copyright and
// permission notice: // permission notice:
// //
// Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com> // Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com>
@ -83,17 +83,17 @@ static void faupInitConfig(void) {
static void faupInit(void) { static void faupInit(void) {
// Validate the users Lat/Lon home location inputs // Validate the users Lat/Lon home location inputs
if ( (Modes.fUserLat > 90.0) // Latitude must be -90 to +90 if ( (Modes.fUserLat > 90.0) // Latitude must be -90 to +90
|| (Modes.fUserLat < -90.0) // and || (Modes.fUserLat < -90.0) // and
|| (Modes.fUserLon > 360.0) // Longitude must be -180 to +360 || (Modes.fUserLon > 360.0) // Longitude must be -180 to +360
|| (Modes.fUserLon < -180.0) ) { || (Modes.fUserLon < -180.0) ) {
Modes.fUserLat = Modes.fUserLon = 0.0; Modes.fUserLat = Modes.fUserLon = 0.0;
} else if (Modes.fUserLon > 180.0) { // If Longitude is +180 to +360, make it -180 to 0 } else if (Modes.fUserLon > 180.0) { // If Longitude is +180 to +360, make it -180 to 0
Modes.fUserLon -= 360.0; Modes.fUserLon -= 360.0;
} }
// If both Lat and Lon are 0.0 then the users location is either invalid/not-set, or (s)he's in the // If both Lat and Lon are 0.0 then the users location is either invalid/not-set, or (s)he's in the
// Atlantic ocean off the west coast of Africa. This is unlikely to be correct. // Atlantic ocean off the west coast of Africa. This is unlikely to be correct.
// Set the user LatLon valid flag only if either Lat or Lon are non zero. Note the Greenwich meridian // Set the user LatLon valid flag only if either Lat or Lon are non zero. Note the Greenwich meridian
// is at 0.0 Lon,so we must check for either fLat or fLon being non zero not both. // is at 0.0 Lon,so we must check for either fLat or fLon being non zero not both.
// Testing the flag at runtime will be much quicker than ((fLon != 0.0) || (fLat != 0.0)) // Testing the flag at runtime will be much quicker than ((fLon != 0.0) || (fLat != 0.0))
Modes.bUserFlags &= ~MODES_USER_LATLON_VALID; Modes.bUserFlags &= ~MODES_USER_LATLON_VALID;
if ((Modes.fUserLat != 0.0) || (Modes.fUserLon != 0.0)) { if ((Modes.fUserLat != 0.0) || (Modes.fUserLon != 0.0)) {

View file

@ -4,17 +4,17 @@
// //
// Copyright (c) 2014,2015 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2014,2015 Oliver Jowett <oliver@mutability.co.uk>
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "dump1090.h" #include "dump1090.h"
@ -51,7 +51,7 @@ static uint32_t icaoHash(uint32_t a)
hash += (a >> 16) & 0xff; hash += (a >> 16) & 0xff;
hash += (hash << 10); hash += (hash << 10);
hash ^= (hash >> 6); hash ^= (hash >> 6);
hash += (hash << 3); hash += (hash << 3);
hash ^= (hash >> 11); hash ^= (hash >> 11);
hash += (hash << 15); hash += (hash << 15);

View file

@ -4,17 +4,17 @@
// //
// Copyright (c) 2014,2015 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2014,2015 Oliver Jowett <oliver@mutability.co.uk>
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef DUMP1090_ICAO_FILTER_H #ifndef DUMP1090_ICAO_FILTER_H

View file

@ -4,20 +4,20 @@
// //
// Copyright (c) 2014,2015 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2014,2015 Oliver Jowett <oliver@mutability.co.uk>
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file incorporates work covered by the following copyright and // This file incorporates work covered by the following copyright and
// permission notice: // permission notice:
// //
// Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com> // Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com>

View file

@ -92,10 +92,10 @@ static int internalModeAToModeC(unsigned int ModeA)
if (ModeA & 0x0020) {OneHundreds ^= 0x003;} // C2 if (ModeA & 0x0020) {OneHundreds ^= 0x003;} // C2
if (ModeA & 0x0040) {OneHundreds ^= 0x001;} // C4 if (ModeA & 0x0040) {OneHundreds ^= 0x001;} // C4
// Remove 7s from OneHundreds (Make 7->5, snd 5->7). // Remove 7s from OneHundreds (Make 7->5, snd 5->7).
if ((OneHundreds & 5) == 5) {OneHundreds ^= 2;} if ((OneHundreds & 5) == 5) {OneHundreds ^= 2;}
// Check for invalid codes, only 1 to 5 are valid // Check for invalid codes, only 1 to 5 are valid
if (OneHundreds > 5) { if (OneHundreds > 5) {
return INVALID_ALTITUDE; return INVALID_ALTITUDE;
} }
@ -108,14 +108,14 @@ static int internalModeAToModeC(unsigned int ModeA)
if (ModeA & 0x2000) {FiveHundreds ^= 0x01F;} // A2 if (ModeA & 0x2000) {FiveHundreds ^= 0x01F;} // A2
if (ModeA & 0x4000) {FiveHundreds ^= 0x00F;} // A4 if (ModeA & 0x4000) {FiveHundreds ^= 0x00F;} // A4
if (ModeA & 0x0100) {FiveHundreds ^= 0x007;} // B1 if (ModeA & 0x0100) {FiveHundreds ^= 0x007;} // B1
if (ModeA & 0x0200) {FiveHundreds ^= 0x003;} // B2 if (ModeA & 0x0200) {FiveHundreds ^= 0x003;} // B2
if (ModeA & 0x0400) {FiveHundreds ^= 0x001;} // B4 if (ModeA & 0x0400) {FiveHundreds ^= 0x001;} // B4
// Correct order of OneHundreds.
if (FiveHundreds & 1) {OneHundreds = 6 - OneHundreds;}
return ((FiveHundreds * 5) + OneHundreds - 13); // Correct order of OneHundreds.
if (FiveHundreds & 1) {OneHundreds = 6 - OneHundreds;}
return ((FiveHundreds * 5) + OneHundreds - 13);
} }
// //
//========================================================================= //=========================================================================

View file

@ -4,20 +4,20 @@
// //
// Copyright (c) 2014-2016 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2014-2016 Oliver Jowett <oliver@mutability.co.uk>
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file incorporates work covered by the following copyright and // This file incorporates work covered by the following copyright and
// permission notice: // permission notice:
// //
// Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com> // Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com>
@ -68,8 +68,8 @@
// //
// Given the Downlink Format (DF) of the message, return the message length in bits. // Given the Downlink Format (DF) of the message, return the message length in bits.
// //
// All known DF's 16 or greater are long. All known DF's 15 or less are short. // All known DF's 16 or greater are long. All known DF's 15 or less are short.
// There are lots of unused codes in both category, so we can assume ICAO will stick to // There are lots of unused codes in both category, so we can assume ICAO will stick to
// these rules, meaning that the most significant bit of the DF indicates the length. // these rules, meaning that the most significant bit of the DF indicates the length.
// //
int modesMessageLenByType(int type) { int modesMessageLenByType(int type) {
@ -86,7 +86,7 @@ int modesMessageLenByType(int type) {
// //
// So every group of three bits A, B, C, D represent an integer from 0 to 7. // So every group of three bits A, B, C, D represent an integer from 0 to 7.
// //
// The actual meaning is just 4 octal numbers, but we convert it into a hex // The actual meaning is just 4 octal numbers, but we convert it into a hex
// number tha happens to represent the four octal numbers. // number tha happens to represent the four octal numbers.
// //
// For more info: http://en.wikipedia.org/wiki/Gillham_code // For more info: http://en.wikipedia.org/wiki/Gillham_code
@ -100,8 +100,8 @@ static int decodeID13Field(int ID13Field) {
if (ID13Field & 0x0200) {hexGillham |= 0x2000;} // Bit 9 = A2 if (ID13Field & 0x0200) {hexGillham |= 0x2000;} // Bit 9 = A2
if (ID13Field & 0x0100) {hexGillham |= 0x0040;} // Bit 8 = C4 if (ID13Field & 0x0100) {hexGillham |= 0x0040;} // Bit 8 = C4
if (ID13Field & 0x0080) {hexGillham |= 0x4000;} // Bit 7 = A4 if (ID13Field & 0x0080) {hexGillham |= 0x4000;} // Bit 7 = A4
//if (ID13Field & 0x0040) {hexGillham |= 0x0800;} // Bit 6 = X or M //if (ID13Field & 0x0040) {hexGillham |= 0x0800;} // Bit 6 = X or M
if (ID13Field & 0x0020) {hexGillham |= 0x0100;} // Bit 5 = B1 if (ID13Field & 0x0020) {hexGillham |= 0x0100;} // Bit 5 = B1
if (ID13Field & 0x0010) {hexGillham |= 0x0001;} // Bit 4 = D1 or Q if (ID13Field & 0x0010) {hexGillham |= 0x0001;} // Bit 4 = D1 or Q
if (ID13Field & 0x0008) {hexGillham |= 0x0200;} // Bit 3 = B2 if (ID13Field & 0x0008) {hexGillham |= 0x0200;} // Bit 3 = B2
if (ID13Field & 0x0004) {hexGillham |= 0x0002;} // Bit 2 = D2 if (ID13Field & 0x0004) {hexGillham |= 0x0002;} // Bit 2 = D2
@ -157,13 +157,13 @@ static int decodeAC12Field(int AC12Field, altitude_unit_t *unit) {
*unit = UNIT_FEET; *unit = UNIT_FEET;
if (q_bit) { if (q_bit) {
/// N is the 11 bit integer resulting from the removal of bit Q at bit 4 /// N is the 11 bit integer resulting from the removal of bit Q at bit 4
int n = ((AC12Field & 0x0FE0) >> 1) | int n = ((AC12Field & 0x0FE0) >> 1) |
(AC12Field & 0x000F); (AC12Field & 0x000F);
// The final altitude is the resulting number multiplied by 25, minus 1000. // The final altitude is the resulting number multiplied by 25, minus 1000.
return ((n * 25) - 1000); return ((n * 25) - 1000);
} else { } else {
// Make N a 13 bit Gillham coded altitude by inserting M=0 at bit 6 // Make N a 13 bit Gillham coded altitude by inserting M=0 at bit 6
int n = ((AC12Field & 0x0FC0) << 1) | int n = ((AC12Field & 0x0FC0) << 1) |
(AC12Field & 0x003F); (AC12Field & 0x003F);
n = modeAToModeC(decodeID13Field(n)); n = modeAToModeC(decodeID13Field(n));
if (n < -12) { if (n < -12) {
@ -182,7 +182,7 @@ static int decodeAC12Field(int AC12Field, altitude_unit_t *unit) {
static unsigned decodeMovementField(unsigned movement) { static unsigned decodeMovementField(unsigned movement) {
int gspeed; int gspeed;
// Note : movement codes 0,125,126,127 are all invalid, but they are // Note : movement codes 0,125,126,127 are all invalid, but they are
// trapped for before this function is called. // trapped for before this function is called.
if (movement > 123) gspeed = 199; // > 175kt if (movement > 123) gspeed = 199; // > 175kt
@ -200,7 +200,7 @@ static unsigned decodeMovementField(unsigned movement) {
// (from bits 8-31) if it is affected by the given error // (from bits 8-31) if it is affected by the given error
// syndrome. Updates *addr and returns >0 if changed, 0 if // syndrome. Updates *addr and returns >0 if changed, 0 if
// it was unaffected. // it was unaffected.
static int correct_aa_field(uint32_t *addr, struct errorinfo *ei) static int correct_aa_field(uint32_t *addr, struct errorinfo *ei)
{ {
int i; int i;
int addr_errors = 0; int addr_errors = 0;
@ -310,7 +310,7 @@ int scoreModesMessage(unsigned char *msg, int validbits)
else else
return -1; return -1;
} }
case 17: // Extended squitter case 17: // Extended squitter
case 18: // Extended squitter/non-transponder case 18: // Extended squitter/non-transponder
ei = modesChecksumDiagnose(crc, msgbits); ei = modesChecksumDiagnose(crc, msgbits);
@ -319,7 +319,7 @@ int scoreModesMessage(unsigned char *msg, int validbits)
// fix any errors in the address field // fix any errors in the address field
addr = getbits(msg, 9, 32); addr = getbits(msg, 9, 32);
correct_aa_field(&addr, ei); correct_aa_field(&addr, ei);
if (icaoFilterTest(addr)) if (icaoFilterTest(addr))
return 1800 / (ei->errors+1); return 1800 / (ei->errors+1);
@ -349,7 +349,7 @@ int scoreModesMessage(unsigned char *msg, int validbits)
// //
//========================================================================= //=========================================================================
// //
// Decode a raw Mode S message demodulated as a stream of bytes by detectModeS(), // Decode a raw Mode S message demodulated as a stream of bytes by detectModeS(),
// and split it into fields populating a modesMessage structure. // and split it into fields populating a modesMessage structure.
// //
@ -458,7 +458,7 @@ int decodeModesMessage(struct modesMessage *mm, unsigned char *msg)
mm->correctedbits = ei->errors; mm->correctedbits = ei->errors;
modesChecksumFix(msg, ei); modesChecksumFix(msg, ei);
addr2 = getbits(msg, 9, 32); addr2 = getbits(msg, 9, 32);
// we are conservative here: only accept corrected messages that // we are conservative here: only accept corrected messages that
// match an existing aircraft. // match an existing aircraft.
if (addr1 != addr2 && !icaoFilterTest(addr2)) { if (addr1 != addr2 && !icaoFilterTest(addr2)) {
@ -492,7 +492,7 @@ int decodeModesMessage(struct modesMessage *mm, unsigned char *msg)
default: default:
// All other message types, we don't know how to handle their CRCs, give up // All other message types, we don't know how to handle their CRCs, give up
return -2; return -2;
} }
// decode the bulk of the message // decode the bulk of the message
@ -1175,7 +1175,7 @@ static void decodeExtendedSquitter(struct modesMessage *mm)
decodeESOperationalStatus(mm, check_imf); decodeESOperationalStatus(mm, check_imf);
break; break;
default: default:
break; break;
} }
} }
@ -1755,8 +1755,8 @@ void displayModesMessage(struct modesMessage *mm) {
// //
//========================================================================= //=========================================================================
// //
// When a new message is available, because it was decoded from the RTL device, // When a new message is available, because it was decoded from the RTL device,
// file, or received in the TCP input port, or any other way we can receive a // file, or received in the TCP input port, or any other way we can receive a
// decoded message, we call this function in order to use the message. // decoded message, we call this function in order to use the message.
// //
// Basically this function passes a raw message to the upper layers for further // Basically this function passes a raw message to the upper layers for further

View file

@ -4,20 +4,20 @@
// //
// Copyright (c) 2014-2016 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2014-2016 Oliver Jowett <oliver@mutability.co.uk>
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file incorporates work covered by the following copyright and // This file incorporates work covered by the following copyright and
// permission notice: // permission notice:
// //
// Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com> // Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com>
@ -606,7 +606,7 @@ static void modesSendSBSOutput(struct modesMessage *mm, struct aircraft *a) {
if (mm->gs_valid) { if (mm->gs_valid) {
p += sprintf(p, ",%d", mm->gs); p += sprintf(p, ",%d", mm->gs);
} else { } else {
p += sprintf(p, ","); p += sprintf(p, ",");
} }
// Field 14 is the ground Heading (if we have it) // Field 14 is the ground Heading (if we have it)
@ -972,13 +972,13 @@ static int hexDigitVal(int c) {
// //
// This function decodes a string representing message in raw hex format // This function decodes a string representing message in raw hex format
// like: *8D4B969699155600E87406F5B69F; The string is null-terminated. // like: *8D4B969699155600E87406F5B69F; The string is null-terminated.
// //
// The message is passed to the higher level layers, so it feeds // The message is passed to the higher level layers, so it feeds
// the selected screen output, the network output and so forth. // the selected screen output, the network output and so forth.
// //
// If the message looks invalid it is silently discarded. // If the message looks invalid it is silently discarded.
// //
// The function always returns 0 (success) to the caller as there is no // The function always returns 0 (success) to the caller as there is no
// case where we want broken messages here to close the client connection. // case where we want broken messages here to close the client connection.
// //
static int decodeHexMessage(struct client *c, char *hex) { static int decodeHexMessage(struct client *c, char *hex) {
@ -1030,13 +1030,13 @@ static int decodeHexMessage(struct client *c, char *hex) {
break;} break;}
} }
if ( (l != (MODEAC_MSG_BYTES * 2)) if ( (l != (MODEAC_MSG_BYTES * 2))
&& (l != (MODES_SHORT_MSG_BYTES * 2)) && (l != (MODES_SHORT_MSG_BYTES * 2))
&& (l != (MODES_LONG_MSG_BYTES * 2)) ) && (l != (MODES_LONG_MSG_BYTES * 2)) )
{return (0);} // Too short or long message... broken {return (0);} // Too short or long message... broken
if ( (0 == Modes.mode_ac) if ( (0 == Modes.mode_ac)
&& (l == (MODEAC_MSG_BYTES * 2)) ) && (l == (MODEAC_MSG_BYTES * 2)) )
{return (0);} // Right length for ModeA/C, but not enabled {return (0);} // Right length for ModeA/C, but not enabled
for (j = 0; j < l; j += 2) { for (j = 0; j < l; j += 2) {
@ -1171,11 +1171,11 @@ char *generateAircraftJson(const char *url_path, int *len) {
continue; continue;
} }
if (first) if (first)
first = 0; first = 0;
else else
*p++ = ','; *p++ = ',';
p += snprintf(p, end-p, "\n {\"hex\":\"%s%06x\"", (a->addr & MODES_NON_ICAO_ADDRESS) ? "~" : "", a->addr & 0xFFFFFF); p += snprintf(p, end-p, "\n {\"hex\":\"%s%06x\"", (a->addr & MODES_NON_ICAO_ADDRESS) ? "~" : "", a->addr & 0xFFFFFF);
if (a->addrtype != ADDR_ADSB_ICAO) if (a->addrtype != ADDR_ADSB_ICAO)
p += snprintf(p, end-p, ",\"type\":\"%s\"", addrtype_short_string(a->addrtype)); p += snprintf(p, end-p, ",\"type\":\"%s\"", addrtype_short_string(a->addrtype));
@ -1223,7 +1223,7 @@ char *generateAircraftJson(const char *url_path, int *len) {
a->messages, (now - a->seen)/1000.0, a->messages, (now - a->seen)/1000.0,
10 * log10((a->signalLevel[0] + a->signalLevel[1] + a->signalLevel[2] + a->signalLevel[3] + 10 * log10((a->signalLevel[0] + a->signalLevel[1] + a->signalLevel[2] + a->signalLevel[3] +
a->signalLevel[4] + a->signalLevel[5] + a->signalLevel[6] + a->signalLevel[7] + 1e-5) / 8)); a->signalLevel[4] + a->signalLevel[5] + a->signalLevel[6] + a->signalLevel[7] + 1e-5) / 8));
// If we're getting near the end of the buffer, expand it. // If we're getting near the end of the buffer, expand it.
if ((end - p) < 512) { if ((end - p) < 512) {
int used = p - buf; int used = p - buf;
@ -1353,7 +1353,7 @@ static char * appendStatsJson(char *p,
return p; return p;
} }
char *generateStatsJson(const char *url_path, int *len) { char *generateStatsJson(const char *url_path, int *len) {
struct stats add; struct stats add;
char *buf = (char *) malloc(4096), *p = buf, *end = buf + 4096; char *buf = (char *) malloc(4096), *p = buf, *end = buf + 4096;
@ -1375,7 +1375,7 @@ char *generateStatsJson(const char *url_path, int *len) {
add_stats(&Modes.stats_alltime, &Modes.stats_current, &add); add_stats(&Modes.stats_alltime, &Modes.stats_current, &add);
p = appendStatsJson(p, end, &add, "total"); p = appendStatsJson(p, end, &add, "total");
p += snprintf(p, end-p, "\n}\n"); p += snprintf(p, end-p, "\n}\n");
assert(p <= end); assert(p <= end);
@ -1461,7 +1461,7 @@ void writeJsonToFile(const char *file, char * (*generator) (const char *,int*))
fd = mkstemp(tmppath); fd = mkstemp(tmppath);
if (fd < 0) if (fd < 0)
return; return;
mask = umask(0); mask = umask(0);
umask(mask); umask(mask);
fchmod(fd, 0644 & ~mask); fchmod(fd, 0644 & ~mask);

View file

@ -4,17 +4,17 @@
// //
// Copyright (c) 2014,2015 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2014,2015 Oliver Jowett <oliver@mutability.co.uk>
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef DUMP1090_NETIO_H #ifndef DUMP1090_NETIO_H

14
sdr.c
View file

@ -5,17 +5,17 @@
// Copyright (c) 2016-2017 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2016-2017 Oliver Jowett <oliver@mutability.co.uk>
// Copyright (c) 2017 FlightAware LLC // Copyright (c) 2017 FlightAware LLC
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "dump1090.h" #include "dump1090.h"

14
sdr.h
View file

@ -5,17 +5,17 @@
// Copyright (c) 2016-2017 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2016-2017 Oliver Jowett <oliver@mutability.co.uk>
// Copyright (c) 2017 FlightAware LLC // Copyright (c) 2017 FlightAware LLC
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef SDR_H #ifndef SDR_H

View file

@ -4,17 +4,17 @@
// //
// Copyright (c) 2017 FlightAware LLC // Copyright (c) 2017 FlightAware LLC
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "dump1090.h" #include "dump1090.h"

View file

@ -4,17 +4,17 @@
// //
// Copyright (c) 2017 FlightAware LLC // Copyright (c) 2017 FlightAware LLC
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef BLADERF_H #ifndef BLADERF_H

View file

@ -5,20 +5,20 @@
// Copyright (c) 2014-2017 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2014-2017 Oliver Jowett <oliver@mutability.co.uk>
// Copyright (c) 2017 FlightAware LLC // Copyright (c) 2017 FlightAware LLC
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file incorporates work covered by the following copyright and // This file incorporates work covered by the following copyright and
// permission notice: // permission notice:
// //
// Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com> // Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com>

View file

@ -5,17 +5,17 @@
// Copyright (c) 2016-2017 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2016-2017 Oliver Jowett <oliver@mutability.co.uk>
// Copyright (c) 2017 FlightAware LLC // Copyright (c) 2017 FlightAware LLC
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef SDR_IFILE_H #ifndef SDR_IFILE_H

View file

@ -5,20 +5,20 @@
// Copyright (c) 2014-2017 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2014-2017 Oliver Jowett <oliver@mutability.co.uk>
// Copyright (c) 2017 FlightAware LLC // Copyright (c) 2017 FlightAware LLC
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file incorporates work covered by the following copyright and // This file incorporates work covered by the following copyright and
// permission notice: // permission notice:
// //
// Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com> // Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com>
@ -223,7 +223,7 @@ bool rtlsdrOpen(void) {
if (closest == -1 || abs(gains[i] - target) < abs(gains[closest] - target)) if (closest == -1 || abs(gains[i] - target) < abs(gains[closest] - target))
closest = i; closest = i;
} }
rtlsdr_set_tuner_gain(RTLSDR.dev, gains[closest]); rtlsdr_set_tuner_gain(RTLSDR.dev, gains[closest]);
free(gains); free(gains);

View file

@ -5,17 +5,17 @@
// Copyright (c) 2016-2017 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2016-2017 Oliver Jowett <oliver@mutability.co.uk>
// Copyright (c) 2017 FlightAware LLC // Copyright (c) 2017 FlightAware LLC
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef SDR_RTLSDR_H #ifndef SDR_RTLSDR_H

20
stats.c
View file

@ -4,20 +4,20 @@
// //
// Copyright (c) 2015 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2015 Oliver Jowett <oliver@mutability.co.uk>
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file incorporates work covered by the following copyright and // This file incorporates work covered by the following copyright and
// permission notice: // permission notice:
// //
// Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com> // Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com>
@ -261,7 +261,7 @@ void add_stats(const struct stats *st1, const struct stats *st2, struct stats *t
target->start = st2->start; target->start = st2->start;
target->end = st1->end > st2->end ? st1->end : st2->end; target->end = st1->end > st2->end ? st1->end : st2->end;
target->demod_preambles = st1->demod_preambles + st2->demod_preambles; target->demod_preambles = st1->demod_preambles + st2->demod_preambles;
target->demod_rejected_bad = st1->demod_rejected_bad + st2->demod_rejected_bad; target->demod_rejected_bad = st1->demod_rejected_bad + st2->demod_rejected_bad;
target->demod_rejected_unknown_icao = st1->demod_rejected_unknown_icao + st2->demod_rejected_unknown_icao; target->demod_rejected_unknown_icao = st1->demod_rejected_unknown_icao + st2->demod_rejected_unknown_icao;
@ -275,7 +275,7 @@ void add_stats(const struct stats *st1, const struct stats *st2, struct stats *t
add_timespecs(&st1->demod_cpu, &st2->demod_cpu, &target->demod_cpu); add_timespecs(&st1->demod_cpu, &st2->demod_cpu, &target->demod_cpu);
add_timespecs(&st1->reader_cpu, &st2->reader_cpu, &target->reader_cpu); add_timespecs(&st1->reader_cpu, &st2->reader_cpu, &target->reader_cpu);
add_timespecs(&st1->background_cpu, &st2->background_cpu, &target->background_cpu); add_timespecs(&st1->background_cpu, &st2->background_cpu, &target->background_cpu);
// noise power: // noise power:
target->noise_power_sum = st1->noise_power_sum + st2->noise_power_sum; target->noise_power_sum = st1->noise_power_sum + st2->noise_power_sum;
target->noise_power_count = st1->noise_power_count + st2->noise_power_count; target->noise_power_count = st1->noise_power_count + st2->noise_power_count;

18
stats.h
View file

@ -4,20 +4,20 @@
// //
// Copyright (c) 2015 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2015 Oliver Jowett <oliver@mutability.co.uk>
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file incorporates work covered by the following copyright and // This file incorporates work covered by the following copyright and
// permission notice: // permission notice:
// //
// Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com> // Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com>
@ -124,7 +124,7 @@ struct stats {
// range histogram // range histogram
#define RANGE_BUCKET_COUNT 76 #define RANGE_BUCKET_COUNT 76
uint32_t range_histogram[RANGE_BUCKET_COUNT]; uint32_t range_histogram[RANGE_BUCKET_COUNT];
}; };
void add_stats(const struct stats *st1, const struct stats *st2, struct stats *target); void add_stats(const struct stats *st1, const struct stats *st2, struct stats *target);
void display_stats(struct stats *st); void display_stats(struct stats *st);

20
track.c
View file

@ -4,20 +4,20 @@
// //
// Copyright (c) 2014-2016 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2014-2016 Oliver Jowett <oliver@mutability.co.uk>
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file incorporates work covered by the following copyright and // This file incorporates work covered by the following copyright and
// permission notice: // permission notice:
// //
// Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com> // Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com>
@ -351,7 +351,7 @@ static int doLocalCPR(struct aircraft *a, struct modesMessage *mm, uint64_t now,
} else if (!surface && (Modes.bUserFlags & MODES_USER_LATLON_VALID)) { } else if (!surface && (Modes.bUserFlags & MODES_USER_LATLON_VALID)) {
reflat = Modes.fUserLat; reflat = Modes.fUserLat;
reflon = Modes.fUserLon; reflon = Modes.fUserLon;
// The cell size is at least 360NM, giving a nominal // The cell size is at least 360NM, giving a nominal
// max range of 180NM (half a cell). // max range of 180NM (half a cell).
// //
@ -762,7 +762,7 @@ static void trackRemoveStaleAircraft(uint64_t now)
{ {
struct aircraft *a = Modes.aircrafts; struct aircraft *a = Modes.aircrafts;
struct aircraft *prev = NULL; struct aircraft *prev = NULL;
while(a) { while(a) {
if ((now - a->seen) > TRACK_AIRCRAFT_TTL || if ((now - a->seen) > TRACK_AIRCRAFT_TTL ||
(a->messages == 1 && (now - a->seen) > TRACK_AIRCRAFT_ONEHIT_TTL)) { (a->messages == 1 && (now - a->seen) > TRACK_AIRCRAFT_ONEHIT_TTL)) {

16
track.h
View file

@ -4,20 +4,20 @@
// //
// Copyright (c) 2014-2016 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2014-2016 Oliver Jowett <oliver@mutability.co.uk>
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file incorporates work covered by the following copyright and // This file incorporates work covered by the following copyright and
// permission notice: // permission notice:
// //
// Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com> // Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com>

16
util.c
View file

@ -4,20 +4,20 @@
// //
// Copyright (c) 2015 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2015 Oliver Jowett <oliver@mutability.co.uk>
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file incorporates work covered by the following copyright and // This file incorporates work covered by the following copyright and
// permission notice: // permission notice:
// //
// Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com> // Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com>

14
util.h
View file

@ -4,17 +4,17 @@
// //
// Copyright (c) 2015 Oliver Jowett <oliver@mutability.co.uk> // Copyright (c) 2015 Oliver Jowett <oliver@mutability.co.uk>
// //
// This file is free software: you may copy, redistribute and/or modify it // This file is free software: you may copy, redistribute and/or modify it
// under the terms of the GNU General Public License as published by the // under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your // Free Software Foundation, either version 2 of the License, or (at your
// option) any later version. // option) any later version.
// //
// This file is distributed in the hope that it will be useful, but // This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of // WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details. // General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef DUMP1090_UTIL_H #ifndef DUMP1090_UTIL_H

View file

@ -67,10 +67,10 @@ void view1090Init(void) {
pthread_cond_init(&Modes.data_cond,NULL); pthread_cond_init(&Modes.data_cond,NULL);
#ifdef _WIN32 #ifdef _WIN32
if ( (!Modes.wsaData.wVersion) if ( (!Modes.wsaData.wVersion)
&& (!Modes.wsaData.wHighVersion) ) { && (!Modes.wsaData.wHighVersion) ) {
// Try to start the windows socket support // Try to start the windows socket support
if (WSAStartup(MAKEWORD(2,1),&Modes.wsaData) != 0) if (WSAStartup(MAKEWORD(2,1),&Modes.wsaData) != 0)
{ {
fprintf(stderr, "WSAStartup returned Error\n"); fprintf(stderr, "WSAStartup returned Error\n");
} }
@ -79,17 +79,17 @@ void view1090Init(void) {
// Validate the users Lat/Lon home location inputs // Validate the users Lat/Lon home location inputs
if ( (Modes.fUserLat > 90.0) // Latitude must be -90 to +90 if ( (Modes.fUserLat > 90.0) // Latitude must be -90 to +90
|| (Modes.fUserLat < -90.0) // and || (Modes.fUserLat < -90.0) // and
|| (Modes.fUserLon > 360.0) // Longitude must be -180 to +360 || (Modes.fUserLon > 360.0) // Longitude must be -180 to +360
|| (Modes.fUserLon < -180.0) ) { || (Modes.fUserLon < -180.0) ) {
Modes.fUserLat = Modes.fUserLon = 0.0; Modes.fUserLat = Modes.fUserLon = 0.0;
} else if (Modes.fUserLon > 180.0) { // If Longitude is +180 to +360, make it -180 to 0 } else if (Modes.fUserLon > 180.0) { // If Longitude is +180 to +360, make it -180 to 0
Modes.fUserLon -= 360.0; Modes.fUserLon -= 360.0;
} }
// If both Lat and Lon are 0.0 then the users location is either invalid/not-set, or (s)he's in the // If both Lat and Lon are 0.0 then the users location is either invalid/not-set, or (s)he's in the
// Atlantic ocean off the west coast of Africa. This is unlikely to be correct. // Atlantic ocean off the west coast of Africa. This is unlikely to be correct.
// Set the user LatLon valid flag only if either Lat or Lon are non zero. Note the Greenwich meridian // Set the user LatLon valid flag only if either Lat or Lon are non zero. Note the Greenwich meridian
// is at 0.0 Lon,so we must check for either fLat or fLon being non zero not both. // is at 0.0 Lon,so we must check for either fLat or fLon being non zero not both.
// Testing the flag at runtime will be much quicker than ((fLon != 0.0) || (fLat != 0.0)) // Testing the flag at runtime will be much quicker than ((fLon != 0.0) || (fLat != 0.0))
Modes.bUserFlags &= ~MODES_USER_LATLON_VALID; Modes.bUserFlags &= ~MODES_USER_LATLON_VALID;
if ((Modes.fUserLat != 0.0) || (Modes.fUserLon != 0.0)) { if ((Modes.fUserLat != 0.0) || (Modes.fUserLon != 0.0)) {