2013-08-19 16:55:17 +02:00
|
|
|
// dump1090, a Mode S messages decoder for RTLSDR devices.
|
|
|
|
//
|
|
|
|
// Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com>
|
|
|
|
//
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are
|
|
|
|
// met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
//
|
|
|
|
// * Redistributions in binary form must reproduce the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer in the
|
|
|
|
// documentation and/or other materials provided with the distribution.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
//
|
2013-05-25 00:32:12 +02:00
|
|
|
#ifndef __DUMP1090_H
|
|
|
|
#define __DUMP1090_H
|
|
|
|
|
2014-07-10 19:11:13 +02:00
|
|
|
// File Version number
|
2013-05-25 00:32:12 +02:00
|
|
|
// ====================
|
|
|
|
// Format is : MajorVer.MinorVer.DayMonth.Year"
|
|
|
|
// MajorVer changes only with significant changes
|
|
|
|
// MinorVer changes when additional features are added, but not for bug fixes (range 00-99)
|
|
|
|
// DayDate & Year changes for all changes, including for bug fixes. It represent the release date of the update
|
|
|
|
//
|
2014-12-10 13:25:43 +01:00
|
|
|
#ifndef MODES_DUMP1090_VERSION
|
2014-12-10 13:44:00 +01:00
|
|
|
# define MODES_DUMP1090_VERSION "1.10.3010.14+mu"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef MODES_DUMP1090_VARIANT
|
|
|
|
# define MODES_DUMP1090_VARIANT "dump1090-mutability"
|
2014-12-10 13:25:43 +01:00
|
|
|
#endif
|
2013-05-25 00:32:12 +02:00
|
|
|
|
2013-08-19 16:55:17 +02:00
|
|
|
// ============================= Include files ==========================
|
2013-05-25 00:32:12 +02:00
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/timeb.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <sys/stat.h>
|
2014-02-22 23:11:11 +01:00
|
|
|
#include <sys/ioctl.h>
|
2014-09-30 00:04:58 +02:00
|
|
|
#include <time.h>
|
2014-11-23 17:02:11 +01:00
|
|
|
#include <limits.h>
|
2013-05-25 00:32:12 +02:00
|
|
|
#include "rtl-sdr.h"
|
|
|
|
#include "anet.h"
|
|
|
|
#else
|
|
|
|
#include "winstubs.h" //Put everything Windows specific in here
|
|
|
|
#include "rtl-sdr.h"
|
2014-04-25 15:48:14 +02:00
|
|
|
#include "anet.h"
|
2013-05-25 00:32:12 +02:00
|
|
|
#endif
|
|
|
|
|
2013-08-19 16:55:17 +02:00
|
|
|
// ============================= #defines ===============================
|
2013-09-30 12:46:36 +02:00
|
|
|
//
|
2014-07-10 19:11:13 +02:00
|
|
|
// If you have a valid coaa.h, these values will come from it. If not,
|
2013-09-30 12:46:36 +02:00
|
|
|
// then you can enter your own values in the #else section here
|
|
|
|
//
|
2013-05-25 00:32:12 +02:00
|
|
|
#ifdef USER_LATITUDE
|
|
|
|
#define MODES_USER_LATITUDE_DFLT (USER_LATITUDE)
|
|
|
|
#define MODES_USER_LONGITUDE_DFLT (USER_LONGITUDE)
|
|
|
|
#else
|
|
|
|
#define MODES_USER_LATITUDE_DFLT (0.0)
|
|
|
|
#define MODES_USER_LONGITUDE_DFLT (0.0)
|
2014-07-10 19:11:13 +02:00
|
|
|
#endif
|
2013-05-25 00:32:12 +02:00
|
|
|
|
2014-07-10 19:11:13 +02:00
|
|
|
#define MODES_DEFAULT_PPM 52
|
2013-05-25 00:32:12 +02:00
|
|
|
#define MODES_DEFAULT_RATE 2000000
|
2014-09-26 23:42:38 +02:00
|
|
|
#define MODES_OVERSAMPLE_RATE 2400000
|
2013-05-25 00:32:12 +02:00
|
|
|
#define MODES_DEFAULT_FREQ 1090000000
|
|
|
|
#define MODES_DEFAULT_WIDTH 1000
|
|
|
|
#define MODES_DEFAULT_HEIGHT 700
|
BUGFIX : Missed data causes timestamp slip
The Mutex on the RTL data reader thread does not "force" the data
processing thread to execute. Therefore, if the processor is busy, it is
possible for a second RTL callback to occur before the data from the
first has been processed. This will cause the loss of the first data,
but worse, it will cause a slip in the timestamp. This upsets Beamfinder
and MLAT operation in PlanePlotter.
To solve this, keep a Fifo buffer which is filled by the callback
thread, and emptied by the data processing thread. The fifo is the same
size as the number of buffers requested in the call to
rtlsdr_read_async().
Note - we only put the value of the pointer supplied in the callback
into the fifo. We do not attempt to cache the data in the buffer pointed
to by the pointer. This would require us to memcopy() 2Mbytes per
second, which we don't want to do if we don't have to because it will
only make the processor loading worse. Instead, we assume that the data
in the buffer will remain valid after the callback returns, at least
until it is overwritten by new data.
It is still possible for us to lose data if we can't process it quickly
enough. However, we can now detect this loss of data when the fifo is
almost full, and correct the timestamp for the lost block/blocks.
2014-02-23 00:11:13 +01:00
|
|
|
#define MODES_ASYNC_BUF_NUMBER 16
|
2013-05-25 00:32:12 +02:00
|
|
|
#define MODES_ASYNC_BUF_SIZE (16*16384) // 256k
|
|
|
|
#define MODES_ASYNC_BUF_SAMPLES (MODES_ASYNC_BUF_SIZE / 2) // Each sample is 2 bytes
|
|
|
|
#define MODES_AUTO_GAIN -100 // Use automatic gain
|
|
|
|
#define MODES_MAX_GAIN 999999 // Use max available gain
|
2014-09-22 15:53:06 +02:00
|
|
|
#define MODES_MSG_SQUELCH_DB 4.0 // Minimum SNR, in dB
|
2013-05-25 00:32:12 +02:00
|
|
|
#define MODES_MSG_ENCODER_ERRS 3 // Maximum number of encoding errors
|
|
|
|
|
|
|
|
// When changing, change also fixBitErrors() and modesInitErrorTable() !!
|
|
|
|
#define MODES_MAX_BITERRORS 2 // Global max for fixable bit erros
|
|
|
|
|
2014-09-30 18:02:22 +02:00
|
|
|
#define MODES_MAX_PHASE_STATS 10
|
|
|
|
|
2013-05-25 00:32:12 +02:00
|
|
|
#define MODEAC_MSG_SAMPLES (25 * 2) // include up to the SPI bit
|
|
|
|
#define MODEAC_MSG_BYTES 2
|
|
|
|
#define MODEAC_MSG_SQUELCH_LEVEL 0x07FF // Average signal strength limit
|
|
|
|
#define MODEAC_MSG_FLAG (1<<0)
|
|
|
|
#define MODEAC_MSG_MODES_HIT (1<<1)
|
|
|
|
#define MODEAC_MSG_MODEA_HIT (1<<2)
|
|
|
|
#define MODEAC_MSG_MODEC_HIT (1<<3)
|
|
|
|
#define MODEAC_MSG_MODEA_ONLY (1<<4)
|
|
|
|
#define MODEAC_MSG_MODEC_OLD (1<<5)
|
|
|
|
|
|
|
|
#define MODES_PREAMBLE_US 8 // microseconds = bits
|
|
|
|
#define MODES_PREAMBLE_SAMPLES (MODES_PREAMBLE_US * 2)
|
|
|
|
#define MODES_PREAMBLE_SIZE (MODES_PREAMBLE_SAMPLES * sizeof(uint16_t))
|
|
|
|
#define MODES_LONG_MSG_BYTES 14
|
|
|
|
#define MODES_SHORT_MSG_BYTES 7
|
|
|
|
#define MODES_LONG_MSG_BITS (MODES_LONG_MSG_BYTES * 8)
|
|
|
|
#define MODES_SHORT_MSG_BITS (MODES_SHORT_MSG_BYTES * 8)
|
|
|
|
#define MODES_LONG_MSG_SAMPLES (MODES_LONG_MSG_BITS * 2)
|
|
|
|
#define MODES_SHORT_MSG_SAMPLES (MODES_SHORT_MSG_BITS * 2)
|
|
|
|
#define MODES_LONG_MSG_SIZE (MODES_LONG_MSG_SAMPLES * sizeof(uint16_t))
|
|
|
|
#define MODES_SHORT_MSG_SIZE (MODES_SHORT_MSG_SAMPLES * sizeof(uint16_t))
|
|
|
|
|
2014-09-26 23:42:38 +02:00
|
|
|
#define MODES_OS_PREAMBLE_SAMPLES (20)
|
|
|
|
#define MODES_OS_PREAMBLE_SIZE (MODES_OS_PREAMBLE_SAMPLES * sizeof(uint16_t))
|
|
|
|
#define MODES_OS_LONG_MSG_SAMPLES (268)
|
|
|
|
#define MODES_OS_SHORT_MSG_SAMPLES (135)
|
|
|
|
#define MODES_OS_LONG_MSG_SIZE (MODES_LONG_MSG_SAMPLES * sizeof(uint16_t))
|
|
|
|
#define MODES_OS_SHORT_MSG_SIZE (MODES_SHORT_MSG_SAMPLES * sizeof(uint16_t))
|
|
|
|
|
2014-10-03 23:55:21 +02:00
|
|
|
#define MODES_OUT_BUF_SIZE (1500)
|
|
|
|
#define MODES_OUT_FLUSH_SIZE (MODES_OUT_BUF_SIZE - 256)
|
|
|
|
#define MODES_OUT_FLUSH_INTERVAL (60)
|
2013-05-25 00:32:12 +02:00
|
|
|
|
|
|
|
#define MODES_ICAO_CACHE_LEN 1024 // Power of two required
|
|
|
|
#define MODES_ICAO_CACHE_TTL 60 // Time to live of cached addresses
|
|
|
|
#define MODES_UNIT_FEET 0
|
|
|
|
#define MODES_UNIT_METERS 1
|
|
|
|
|
|
|
|
#define MODES_USER_LATLON_VALID (1<<0)
|
|
|
|
|
|
|
|
#define MODES_ACFLAGS_LATLON_VALID (1<<0) // Aircraft Lat/Lon is decoded
|
|
|
|
#define MODES_ACFLAGS_ALTITUDE_VALID (1<<1) // Aircraft altitude is known
|
|
|
|
#define MODES_ACFLAGS_HEADING_VALID (1<<2) // Aircraft heading is known
|
|
|
|
#define MODES_ACFLAGS_SPEED_VALID (1<<3) // Aircraft speed is known
|
|
|
|
#define MODES_ACFLAGS_VERTRATE_VALID (1<<4) // Aircraft vertical rate is known
|
|
|
|
#define MODES_ACFLAGS_SQUAWK_VALID (1<<5) // Aircraft Mode A Squawk is known
|
|
|
|
#define MODES_ACFLAGS_CALLSIGN_VALID (1<<6) // Aircraft Callsign Identity
|
|
|
|
#define MODES_ACFLAGS_EWSPEED_VALID (1<<7) // Aircraft East West Speed is known
|
|
|
|
#define MODES_ACFLAGS_NSSPEED_VALID (1<<8) // Aircraft North South Speed is known
|
|
|
|
#define MODES_ACFLAGS_AOG (1<<9) // Aircraft is On the Ground
|
|
|
|
#define MODES_ACFLAGS_LLEVEN_VALID (1<<10) // Aircraft Even Lot/Lon is known
|
|
|
|
#define MODES_ACFLAGS_LLODD_VALID (1<<11) // Aircraft Odd Lot/Lon is known
|
2014-07-10 19:11:13 +02:00
|
|
|
#define MODES_ACFLAGS_AOG_VALID (1<<12) // MODES_ACFLAGS_AOG is valid
|
|
|
|
#define MODES_ACFLAGS_FS_VALID (1<<13) // Aircraft Flight Status is known
|
2013-05-25 00:32:12 +02:00
|
|
|
#define MODES_ACFLAGS_NSEWSPD_VALID (1<<14) // Aircraft EW and NS Speed is known
|
|
|
|
#define MODES_ACFLAGS_LATLON_REL_OK (1<<15) // Indicates it's OK to do a relative CPR
|
|
|
|
|
2014-07-10 19:11:13 +02:00
|
|
|
#define MODES_ACFLAGS_LLEITHER_VALID (MODES_ACFLAGS_LLEVEN_VALID | MODES_ACFLAGS_LLODD_VALID)
|
2013-05-25 00:32:12 +02:00
|
|
|
#define MODES_ACFLAGS_LLBOTH_VALID (MODES_ACFLAGS_LLEVEN_VALID | MODES_ACFLAGS_LLODD_VALID)
|
|
|
|
#define MODES_ACFLAGS_AOG_GROUND (MODES_ACFLAGS_AOG_VALID | MODES_ACFLAGS_AOG)
|
|
|
|
|
|
|
|
#define MODES_DEBUG_DEMOD (1<<0)
|
|
|
|
#define MODES_DEBUG_DEMODERR (1<<1)
|
|
|
|
#define MODES_DEBUG_BADCRC (1<<2)
|
|
|
|
#define MODES_DEBUG_GOODCRC (1<<3)
|
|
|
|
#define MODES_DEBUG_NOPREAMBLE (1<<4)
|
|
|
|
#define MODES_DEBUG_NET (1<<5)
|
|
|
|
#define MODES_DEBUG_JS (1<<6)
|
|
|
|
|
|
|
|
// When debug is set to MODES_DEBUG_NOPREAMBLE, the first sample must be
|
|
|
|
// at least greater than a given level for us to dump the signal.
|
|
|
|
#define MODES_DEBUG_NOPREAMBLE_LEVEL 25
|
|
|
|
|
|
|
|
#define MODES_INTERACTIVE_REFRESH_TIME 250 // Milliseconds
|
2013-08-19 16:55:17 +02:00
|
|
|
#define MODES_INTERACTIVE_ROWS 22 // Rows on screen
|
|
|
|
#define MODES_INTERACTIVE_DELETE_TTL 300 // Delete from the list after 300 seconds
|
|
|
|
#define MODES_INTERACTIVE_DISPLAY_TTL 60 // Delete from display after 60 seconds
|
2013-05-25 00:32:12 +02:00
|
|
|
|
2014-10-03 23:55:21 +02:00
|
|
|
#define MODES_NET_HEARTBEAT_INTERVAL 60 // seconds
|
2014-03-11 02:09:49 +01:00
|
|
|
|
2014-12-08 20:56:45 +01:00
|
|
|
#define MODES_NET_SERVICES_NUM 7
|
2013-05-25 00:32:12 +02:00
|
|
|
#define MODES_NET_INPUT_RAW_PORT 30001
|
|
|
|
#define MODES_NET_OUTPUT_RAW_PORT 30002
|
|
|
|
#define MODES_NET_OUTPUT_SBS_PORT 30003
|
|
|
|
#define MODES_NET_INPUT_BEAST_PORT 30004
|
|
|
|
#define MODES_NET_OUTPUT_BEAST_PORT 30005
|
|
|
|
#define MODES_NET_HTTP_PORT 8080
|
2014-12-08 20:56:45 +01:00
|
|
|
#define MODES_NET_OUTPUT_FA_TSV_PORT 10001
|
2013-05-25 00:32:12 +02:00
|
|
|
#define MODES_CLIENT_BUF_SIZE 1024
|
|
|
|
#define MODES_NET_SNDBUF_SIZE (1024*64)
|
2014-07-10 19:11:13 +02:00
|
|
|
#define MODES_NET_SNDBUF_MAX (7)
|
2013-05-25 00:32:12 +02:00
|
|
|
|
|
|
|
#ifndef HTMLPATH
|
|
|
|
#define HTMLPATH "./public_html" // default path for gmap.html etc
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define MODES_NOTUSED(V) ((void) V)
|
|
|
|
|
2013-08-19 16:55:17 +02:00
|
|
|
//======================== structure declarations =========================
|
2013-05-25 00:32:12 +02:00
|
|
|
|
|
|
|
// Structure used to describe a networking client
|
|
|
|
struct client {
|
2014-04-25 15:48:14 +02:00
|
|
|
struct client* next; // Pointer to next client
|
|
|
|
int fd; // File descriptor
|
|
|
|
int service; // TCP port the client is connected to
|
|
|
|
int buflen; // Amount of data on buffer
|
|
|
|
char buf[MODES_CLIENT_BUF_SIZE+1]; // Read buffer
|
2013-05-25 00:32:12 +02:00
|
|
|
};
|
|
|
|
|
2015-01-15 23:22:22 +01:00
|
|
|
#define HISTORY_SIZE 120
|
|
|
|
#define HISTORY_INTERVAL 30
|
2015-01-15 21:55:55 +01:00
|
|
|
|
2013-05-25 00:32:12 +02:00
|
|
|
// Structure used to describe an aircraft in iteractive mode
|
|
|
|
struct aircraft {
|
|
|
|
uint32_t addr; // ICAO address
|
|
|
|
char flight[16]; // Flight number
|
|
|
|
unsigned char signalLevel[8]; // Last 8 Signal Amplitudes
|
|
|
|
int altitude; // Altitude
|
|
|
|
int speed; // Velocity
|
|
|
|
int track; // Angle of flight
|
|
|
|
int vert_rate; // Vertical rate.
|
|
|
|
time_t seen; // Time at which the last packet was received
|
|
|
|
time_t seenLatLon; // Time at which the last lat long was calculated
|
|
|
|
uint64_t timestamp; // Timestamp at which the last packet was received
|
|
|
|
uint64_t timestampLatLon;// Timestamp at which the last lat long was calculated
|
|
|
|
long messages; // Number of Mode S messages received
|
|
|
|
int modeA; // Squawk
|
|
|
|
int modeC; // Altitude
|
|
|
|
long modeAcount; // Mode A Squawk hit Count
|
|
|
|
long modeCcount; // Mode C Altitude hit Count
|
|
|
|
int modeACflags; // Flags for mode A/C recognition
|
|
|
|
|
2014-12-08 20:56:45 +01:00
|
|
|
int fatsv_emitted_altitude; // last FA emitted altitude
|
|
|
|
int fatsv_emitted_track; // last FA emitted angle of flight
|
|
|
|
time_t fatsv_last_emitted; // time aircraft was last FA emitted
|
|
|
|
|
2013-05-25 00:32:12 +02:00
|
|
|
// Encoded latitude and longitude as extracted by odd and even CPR encoded messages
|
|
|
|
int odd_cprlat;
|
|
|
|
int odd_cprlon;
|
|
|
|
int even_cprlat;
|
|
|
|
int even_cprlon;
|
|
|
|
uint64_t odd_cprtime;
|
|
|
|
uint64_t even_cprtime;
|
|
|
|
double lat, lon; // Coordinated obtained from CPR encoded data
|
|
|
|
int bFlags; // Flags related to valid fields in this structure
|
|
|
|
struct aircraft *next; // Next aircraft in our linked list
|
|
|
|
};
|
|
|
|
|
2014-09-30 18:02:22 +02:00
|
|
|
// Common stats for non-phase-corrected vs phase-corrected cases
|
|
|
|
struct demod_stats {
|
|
|
|
unsigned int demodulated0;
|
|
|
|
unsigned int demodulated1;
|
|
|
|
unsigned int demodulated2;
|
|
|
|
unsigned int demodulated3;
|
|
|
|
unsigned int goodcrc;
|
|
|
|
unsigned int goodcrc_byphase[MODES_MAX_PHASE_STATS];
|
|
|
|
unsigned int badcrc;
|
|
|
|
unsigned int fixed;
|
|
|
|
|
|
|
|
// Histogram of fixed bit errors: index 0 for single bit erros,
|
|
|
|
// index 1 for double bit errors etc.
|
|
|
|
unsigned int bit_fix[MODES_MAX_BITERRORS];
|
|
|
|
};
|
|
|
|
|
2014-10-03 23:55:21 +02:00
|
|
|
// Common writer state for all output sockets of one type
|
|
|
|
struct net_writer {
|
|
|
|
int socket; // listening socket FD, used to identify the owning service
|
|
|
|
int connections; // number of active clients
|
|
|
|
void *data; // shared write buffer, sized MODES_OUT_BUF_SIZE
|
|
|
|
int dataUsed; // number of bytes of write buffer currently used
|
|
|
|
time_t lastWrite; // time of last write to clients
|
|
|
|
};
|
|
|
|
|
2013-05-25 00:32:12 +02:00
|
|
|
// Program global state
|
|
|
|
struct { // Internal state
|
|
|
|
pthread_t reader_thread;
|
BUGFIX : Missed data causes timestamp slip
The Mutex on the RTL data reader thread does not "force" the data
processing thread to execute. Therefore, if the processor is busy, it is
possible for a second RTL callback to occur before the data from the
first has been processed. This will cause the loss of the first data,
but worse, it will cause a slip in the timestamp. This upsets Beamfinder
and MLAT operation in PlanePlotter.
To solve this, keep a Fifo buffer which is filled by the callback
thread, and emptied by the data processing thread. The fifo is the same
size as the number of buffers requested in the call to
rtlsdr_read_async().
Note - we only put the value of the pointer supplied in the callback
into the fifo. We do not attempt to cache the data in the buffer pointed
to by the pointer. This would require us to memcopy() 2Mbytes per
second, which we don't want to do if we don't have to because it will
only make the processor loading worse. Instead, we assume that the data
in the buffer will remain valid after the callback returns, at least
until it is overwritten by new data.
It is still possible for us to lose data if we can't process it quickly
enough. However, we can now detect this loss of data when the fifo is
almost full, and correct the timestamp for the lost block/blocks.
2014-02-23 00:11:13 +01:00
|
|
|
|
2013-05-25 00:32:12 +02:00
|
|
|
pthread_mutex_t data_mutex; // Mutex to synchronize buffer access
|
|
|
|
pthread_cond_t data_cond; // Conditional variable associated
|
BUGFIX : Missed data causes timestamp slip
The Mutex on the RTL data reader thread does not "force" the data
processing thread to execute. Therefore, if the processor is busy, it is
possible for a second RTL callback to occur before the data from the
first has been processed. This will cause the loss of the first data,
but worse, it will cause a slip in the timestamp. This upsets Beamfinder
and MLAT operation in PlanePlotter.
To solve this, keep a Fifo buffer which is filled by the callback
thread, and emptied by the data processing thread. The fifo is the same
size as the number of buffers requested in the call to
rtlsdr_read_async().
Note - we only put the value of the pointer supplied in the callback
into the fifo. We do not attempt to cache the data in the buffer pointed
to by the pointer. This would require us to memcopy() 2Mbytes per
second, which we don't want to do if we don't have to because it will
only make the processor loading worse. Instead, we assume that the data
in the buffer will remain valid after the callback returns, at least
until it is overwritten by new data.
It is still possible for us to lose data if we can't process it quickly
enough. However, we can now detect this loss of data when the fifo is
almost full, and correct the timestamp for the lost block/blocks.
2014-02-23 00:11:13 +01:00
|
|
|
uint16_t *pData [MODES_ASYNC_BUF_NUMBER]; // Raw IQ sample buffers from RTL
|
|
|
|
struct timeb stSystemTimeRTL[MODES_ASYNC_BUF_NUMBER]; // System time when RTL passed us this block
|
2014-02-24 11:28:35 +01:00
|
|
|
int iDataIn; // Fifo input pointer
|
|
|
|
int iDataOut; // Fifo output pointer
|
2014-07-10 19:11:13 +02:00
|
|
|
int iDataReady; // Fifo content count
|
2014-02-24 11:28:35 +01:00
|
|
|
int iDataLost; // Count of missed buffers
|
BUGFIX : Missed data causes timestamp slip
The Mutex on the RTL data reader thread does not "force" the data
processing thread to execute. Therefore, if the processor is busy, it is
possible for a second RTL callback to occur before the data from the
first has been processed. This will cause the loss of the first data,
but worse, it will cause a slip in the timestamp. This upsets Beamfinder
and MLAT operation in PlanePlotter.
To solve this, keep a Fifo buffer which is filled by the callback
thread, and emptied by the data processing thread. The fifo is the same
size as the number of buffers requested in the call to
rtlsdr_read_async().
Note - we only put the value of the pointer supplied in the callback
into the fifo. We do not attempt to cache the data in the buffer pointed
to by the pointer. This would require us to memcopy() 2Mbytes per
second, which we don't want to do if we don't have to because it will
only make the processor loading worse. Instead, we assume that the data
in the buffer will remain valid after the callback returns, at least
until it is overwritten by new data.
It is still possible for us to lose data if we can't process it quickly
enough. However, we can now detect this loss of data when the fifo is
almost full, and correct the timestamp for the lost block/blocks.
2014-02-23 00:11:13 +01:00
|
|
|
|
2015-01-12 01:22:54 +01:00
|
|
|
int trailing_samples;// extra trailing samples in magnitude buffer
|
2014-09-26 23:42:38 +02:00
|
|
|
|
BUGFIX : Missed data causes timestamp slip
The Mutex on the RTL data reader thread does not "force" the data
processing thread to execute. Therefore, if the processor is busy, it is
possible for a second RTL callback to occur before the data from the
first has been processed. This will cause the loss of the first data,
but worse, it will cause a slip in the timestamp. This upsets Beamfinder
and MLAT operation in PlanePlotter.
To solve this, keep a Fifo buffer which is filled by the callback
thread, and emptied by the data processing thread. The fifo is the same
size as the number of buffers requested in the call to
rtlsdr_read_async().
Note - we only put the value of the pointer supplied in the callback
into the fifo. We do not attempt to cache the data in the buffer pointed
to by the pointer. This would require us to memcopy() 2Mbytes per
second, which we don't want to do if we don't have to because it will
only make the processor loading worse. Instead, we assume that the data
in the buffer will remain valid after the callback returns, at least
until it is overwritten by new data.
It is still possible for us to lose data if we can't process it quickly
enough. However, we can now detect this loss of data when the fifo is
almost full, and correct the timestamp for the lost block/blocks.
2014-02-23 00:11:13 +01:00
|
|
|
uint16_t *pFileData; // Raw IQ samples buffer (from a File)
|
2013-05-25 00:32:12 +02:00
|
|
|
uint16_t *magnitude; // Magnitude vector
|
|
|
|
uint64_t timestampBlk; // Timestamp of the start of the current block
|
|
|
|
struct timeb stSystemTimeBlk; // System time when RTL passed us currently processing this block
|
|
|
|
int fd; // --ifile option file descriptor
|
|
|
|
uint32_t *icao_cache; // Recently seen ICAO addresses cache
|
|
|
|
uint16_t *maglut; // I/Q -> Magnitude lookup table
|
2014-09-22 15:53:06 +02:00
|
|
|
uint16_t *log10lut; // Magnitude -> log10 lookup table
|
2013-05-25 00:32:12 +02:00
|
|
|
int exit; // Exit from the main loop when true
|
|
|
|
|
|
|
|
// RTLSDR
|
2015-01-02 23:29:29 +01:00
|
|
|
char * dev_name;
|
2013-05-25 00:32:12 +02:00
|
|
|
int gain;
|
|
|
|
int enable_agc;
|
|
|
|
rtlsdr_dev_t *dev;
|
|
|
|
int freq;
|
|
|
|
int ppm_error;
|
|
|
|
|
|
|
|
// Networking
|
|
|
|
char aneterr[ANET_ERR_LEN];
|
2014-04-25 15:48:14 +02:00
|
|
|
struct client *clients; // Our clients
|
|
|
|
int ris; // Raw input listening socket
|
|
|
|
int bis; // Beast input listening socket
|
|
|
|
int https; // HTTP listening socket
|
2014-10-03 23:55:21 +02:00
|
|
|
|
|
|
|
struct net_writer raw_out; // Raw output
|
|
|
|
struct net_writer beast_out; // Beast-format output
|
|
|
|
struct net_writer sbs_out; // SBS-format output
|
2014-12-08 20:56:45 +01:00
|
|
|
struct net_writer fatsv_out; // FATSV-format output
|
2014-10-03 23:55:21 +02:00
|
|
|
|
Implement a remote interactive screen
No changes to dump1090, (except the version number)
Include a sample Linux batch start file called dump1090.sh for use when
running dump1090 headless. This file needs to be copied to the
/etc/init.d/ subdirectory on your raspberry pi, and marked as
executable. Then when you re-start your RPi, dump1090 will start-up
auto-magically and run as a sort of server to allow both local and
remote connection to it's various internet ports.
Modified the Makefile to build a new headless helper application called
view1090
Added view1090. This is an executable that allows you to connect to
dump1090 when it is running and 'see' the interactive screen display.
The default is to try and connect to dump1090 on IP address 127.0.0.1
port 30005. This should work if you are running on the same RPi as
dump1090 and using the default dump1090 port settings. However, if
you're running on a different machine you will have to specify the IP
address of the RPi running dump1090 using the --net-bo-ipaddr switch.
Something like "view1090 --net-bo-ipaddr 192.168.2.65" . You may also
have to sudo it, depending on your privilige settings.
I've also compiled view1090 as a Wiin32 exe, so you should be able to
run it under any 32 bit version of Microsoft Windows - i.e. Win95, Win
2K, Win XP, Win 7 etc. It may work on Win 8 and 64 bit Windows, but I
haven't tried it. The Win32 version is compiled from the same source, so
takes all the same command line switches.
2013-09-24 19:37:54 +02:00
|
|
|
#ifdef _WIN32
|
2014-04-25 15:48:14 +02:00
|
|
|
WSADATA wsaData; // Windows socket initialisation
|
Implement a remote interactive screen
No changes to dump1090, (except the version number)
Include a sample Linux batch start file called dump1090.sh for use when
running dump1090 headless. This file needs to be copied to the
/etc/init.d/ subdirectory on your raspberry pi, and marked as
executable. Then when you re-start your RPi, dump1090 will start-up
auto-magically and run as a sort of server to allow both local and
remote connection to it's various internet ports.
Modified the Makefile to build a new headless helper application called
view1090
Added view1090. This is an executable that allows you to connect to
dump1090 when it is running and 'see' the interactive screen display.
The default is to try and connect to dump1090 on IP address 127.0.0.1
port 30005. This should work if you are running on the same RPi as
dump1090 and using the default dump1090 port settings. However, if
you're running on a different machine you will have to specify the IP
address of the RPi running dump1090 using the --net-bo-ipaddr switch.
Something like "view1090 --net-bo-ipaddr 192.168.2.65" . You may also
have to sudo it, depending on your privilige settings.
I've also compiled view1090 as a Wiin32 exe, so you should be able to
run it under any 32 bit version of Microsoft Windows - i.e. Win95, Win
2K, Win XP, Win 7 etc. It may work on Win 8 and 64 bit Windows, but I
haven't tried it. The Win32 version is compiled from the same source, so
takes all the same command line switches.
2013-09-24 19:37:54 +02:00
|
|
|
#endif
|
2013-05-25 00:32:12 +02:00
|
|
|
|
|
|
|
// Configuration
|
|
|
|
char *filename; // Input form file, --ifile option
|
2014-09-26 23:42:38 +02:00
|
|
|
int oversample;
|
2013-05-25 00:32:12 +02:00
|
|
|
int phase_enhance; // Enable phase enhancement if true
|
|
|
|
int nfix_crc; // Number of crc bit error(s) to correct
|
|
|
|
int check_crc; // Only display messages with good CRC
|
|
|
|
int raw; // Raw output format
|
|
|
|
int beast; // Beast binary format output
|
|
|
|
int mode_ac; // Enable decoding of SSR Modes A & C
|
|
|
|
int debug; // Debugging mode
|
|
|
|
int net; // Enable networking
|
|
|
|
int net_only; // Enable just networking
|
2014-10-03 23:55:21 +02:00
|
|
|
int net_heartbeat_interval; // TCP heartbeat interval (seconds)
|
2013-05-25 00:32:12 +02:00
|
|
|
int net_output_sbs_port; // SBS output TCP port
|
2014-10-03 23:55:21 +02:00
|
|
|
int net_output_flush_size; // Minimum Size of output data
|
|
|
|
int net_output_flush_interval; // Maximum interval (in seconds) between outputwrites
|
2013-05-25 00:32:12 +02:00
|
|
|
int net_output_raw_port; // Raw output TCP port
|
|
|
|
int net_input_raw_port; // Raw input TCP port
|
|
|
|
int net_output_beast_port; // Beast output TCP port
|
|
|
|
int net_input_beast_port; // Beast input TCP port
|
2014-10-25 21:33:45 +02:00
|
|
|
char *net_bind_address; // Bind address
|
2013-05-25 00:32:12 +02:00
|
|
|
int net_http_port; // HTTP port
|
2014-12-08 20:56:45 +01:00
|
|
|
int net_fatsv_port; // FlightAware TSV port
|
2014-05-27 14:16:57 +02:00
|
|
|
int net_sndbuf_size; // TCP output buffer size (64Kb * 2^n)
|
2013-05-25 00:32:12 +02:00
|
|
|
int quiet; // Suppress stdout
|
|
|
|
int interactive; // Interactive mode
|
|
|
|
int interactive_rows; // Interactive mode: max number of rows
|
2013-08-19 16:55:17 +02:00
|
|
|
int interactive_display_ttl; // Interactive mode: TTL display
|
|
|
|
int interactive_delete_ttl; // Interactive mode: TTL before deletion
|
2013-05-25 00:32:12 +02:00
|
|
|
int stats; // Print stats at exit in --ifile mode
|
|
|
|
int onlyaddr; // Print only ICAO addresses
|
|
|
|
int metric; // Use metric units
|
|
|
|
int mlat; // Use Beast ascii format for raw data output, i.e. @...; iso *...;
|
|
|
|
int interactive_rtl1090; // flight table in interactive mode is formatted like RTL1090
|
2015-01-15 21:54:22 +01:00
|
|
|
char *json_dir; // Path to json base directory, or NULL not to write json.
|
2014-12-10 18:05:22 +01:00
|
|
|
int json_interval; // Interval between rewriting the json aircraft file
|
2014-12-27 21:52:56 +01:00
|
|
|
int json_location_accuracy; // Accuracy of location metadata: 0=none, 1=approx, 2=exact
|
2013-05-25 00:32:12 +02:00
|
|
|
|
2015-01-15 21:55:55 +01:00
|
|
|
int json_aircraft_history_next;
|
|
|
|
struct {
|
|
|
|
char *content;
|
|
|
|
int clen;
|
|
|
|
} json_aircraft_history[HISTORY_SIZE];
|
|
|
|
|
2013-05-25 00:32:12 +02:00
|
|
|
// User details
|
|
|
|
double fUserLat; // Users receiver/antenna lat/lon needed for initial surface location
|
|
|
|
double fUserLon; // Users receiver/antenna lat/lon needed for initial surface location
|
|
|
|
int bUserFlags; // Flags relating to the user details
|
2015-01-13 21:03:34 +01:00
|
|
|
double maxRange; // Absolute maximum decoding range, in *metres*
|
2013-05-25 00:32:12 +02:00
|
|
|
|
|
|
|
// Interactive mode
|
|
|
|
struct aircraft *aircrafts;
|
|
|
|
uint64_t interactive_last_update; // Last screen update in milliseconds
|
2014-07-16 17:34:42 +02:00
|
|
|
time_t last_cleanup_time; // Last cleanup time in seconds
|
2013-05-25 00:32:12 +02:00
|
|
|
|
|
|
|
// Statistics
|
2014-09-27 14:07:23 +02:00
|
|
|
unsigned int stat_preamble_no_correlation;
|
|
|
|
unsigned int stat_preamble_not_quiet;
|
2013-05-25 00:32:12 +02:00
|
|
|
unsigned int stat_valid_preamble;
|
2014-09-27 14:07:23 +02:00
|
|
|
unsigned int stat_preamble_phase[MODES_MAX_PHASE_STATS];
|
2013-05-25 00:32:12 +02:00
|
|
|
|
2014-09-30 18:02:22 +02:00
|
|
|
struct demod_stats stat_demod;
|
|
|
|
struct demod_stats stat_demod_phasecorrected;
|
2014-08-06 16:26:05 +02:00
|
|
|
|
2013-05-25 00:32:12 +02:00
|
|
|
unsigned int stat_http_requests;
|
|
|
|
unsigned int stat_out_of_phase;
|
2014-08-06 16:26:05 +02:00
|
|
|
|
2013-05-25 00:32:12 +02:00
|
|
|
unsigned int stat_DF_Len_Corrected;
|
|
|
|
unsigned int stat_DF_Type_Corrected;
|
|
|
|
unsigned int stat_ModeAC;
|
2014-09-25 21:35:54 +02:00
|
|
|
|
|
|
|
unsigned int stat_blocks_processed;
|
|
|
|
unsigned int stat_blocks_dropped;
|
2014-09-30 00:04:58 +02:00
|
|
|
|
|
|
|
struct timespec stat_cputime;
|
2015-01-13 20:10:55 +01:00
|
|
|
|
|
|
|
// total messages:
|
|
|
|
unsigned int stat_messages_total;
|
2013-05-25 00:32:12 +02:00
|
|
|
} Modes;
|
|
|
|
|
|
|
|
// The struct we use to store information about a decoded message.
|
|
|
|
struct modesMessage {
|
|
|
|
// Generic fields
|
|
|
|
unsigned char msg[MODES_LONG_MSG_BYTES]; // Binary message.
|
|
|
|
int msgbits; // Number of bits in message
|
|
|
|
int msgtype; // Downlink format #
|
|
|
|
int crcok; // True if CRC was valid
|
|
|
|
uint32_t crc; // Message CRC
|
|
|
|
int correctedbits; // No. of bits corrected
|
|
|
|
char corrected[MODES_MAX_BITERRORS]; // corrected bit positions
|
|
|
|
uint32_t addr; // ICAO Address from bytes 1 2 and 3
|
|
|
|
int phase_corrected; // True if phase correction was applied
|
|
|
|
uint64_t timestampMsg; // Timestamp of the message
|
|
|
|
int remote; // If set this message is from a remote station
|
|
|
|
unsigned char signalLevel; // Signal Amplitude
|
|
|
|
|
|
|
|
// DF 11
|
|
|
|
int ca; // Responder capabilities
|
|
|
|
int iid;
|
|
|
|
|
|
|
|
// DF 17, DF 18
|
|
|
|
int metype; // Extended squitter message type.
|
|
|
|
int mesub; // Extended squitter message subtype.
|
|
|
|
int heading; // Reported by aircraft, or computed from from EW and NS velocity
|
|
|
|
int raw_latitude; // Non decoded latitude.
|
|
|
|
int raw_longitude; // Non decoded longitude.
|
|
|
|
double fLat; // Coordinates obtained from CPR encoded data if/when decoded
|
|
|
|
double fLon; // Coordinates obtained from CPR encoded data if/when decoded
|
|
|
|
char flight[16]; // 8 chars flight number.
|
|
|
|
int ew_velocity; // E/W velocity.
|
|
|
|
int ns_velocity; // N/S velocity.
|
|
|
|
int vert_rate; // Vertical rate.
|
|
|
|
int velocity; // Reported by aircraft, or computed from from EW and NS velocity
|
|
|
|
|
|
|
|
// DF4, DF5, DF20, DF21
|
|
|
|
int fs; // Flight status for DF4,5,20,21
|
|
|
|
int modeA; // 13 bits identity (Squawk).
|
|
|
|
|
|
|
|
// Fields used by multiple message types.
|
|
|
|
int altitude;
|
|
|
|
int unit;
|
|
|
|
int bFlags; // Flags related to fields in this structure
|
|
|
|
};
|
|
|
|
|
2013-08-19 16:55:17 +02:00
|
|
|
// ======================== function declarations =========================
|
2013-05-25 00:32:12 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-08-19 16:55:17 +02:00
|
|
|
//
|
|
|
|
// Functions exported from mode_ac.c
|
|
|
|
//
|
2013-05-25 00:32:12 +02:00
|
|
|
int detectModeA (uint16_t *m, struct modesMessage *mm);
|
|
|
|
void decodeModeAMessage(struct modesMessage *mm, int ModeA);
|
|
|
|
int ModeAToModeC (unsigned int ModeA);
|
|
|
|
|
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 19:57:03 +02:00
|
|
|
//
|
|
|
|
// Functions exported from mode_s.c
|
|
|
|
//
|
|
|
|
void detectModeS (uint16_t *m, uint32_t mlen);
|
2014-09-26 23:42:38 +02:00
|
|
|
void detectModeS_oversample (uint16_t *m, uint32_t mlen);
|
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 19:57:03 +02:00
|
|
|
void decodeModesMessage (struct modesMessage *mm, unsigned char *msg);
|
|
|
|
void displayModesMessage(struct modesMessage *mm);
|
|
|
|
void useModesMessage (struct modesMessage *mm);
|
BUGFIX : Missed data causes timestamp slip
The Mutex on the RTL data reader thread does not "force" the data
processing thread to execute. Therefore, if the processor is busy, it is
possible for a second RTL callback to occur before the data from the
first has been processed. This will cause the loss of the first data,
but worse, it will cause a slip in the timestamp. This upsets Beamfinder
and MLAT operation in PlanePlotter.
To solve this, keep a Fifo buffer which is filled by the callback
thread, and emptied by the data processing thread. The fifo is the same
size as the number of buffers requested in the call to
rtlsdr_read_async().
Note - we only put the value of the pointer supplied in the callback
into the fifo. We do not attempt to cache the data in the buffer pointed
to by the pointer. This would require us to memcopy() 2Mbytes per
second, which we don't want to do if we don't have to because it will
only make the processor loading worse. Instead, we assume that the data
in the buffer will remain valid after the callback returns, at least
until it is overwritten by new data.
It is still possible for us to lose data if we can't process it quickly
enough. However, we can now detect this loss of data when the fifo is
almost full, and correct the timestamp for the lost block/blocks.
2014-02-23 00:11:13 +01:00
|
|
|
void computeMagnitudeVector(uint16_t *pData);
|
2014-09-25 18:10:55 +02:00
|
|
|
int decodeCPR (struct aircraft *a, int fflag, int surface);
|
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 19:57:03 +02:00
|
|
|
int decodeCPRrelative (struct aircraft *a, int fflag, int surface);
|
|
|
|
void modesInitErrorInfo ();
|
2013-08-19 16:55:17 +02:00
|
|
|
//
|
|
|
|
// Functions exported from interactive.c
|
|
|
|
//
|
2013-05-25 00:32:12 +02:00
|
|
|
struct aircraft* interactiveReceiveData(struct modesMessage *mm);
|
2013-08-19 16:55:17 +02:00
|
|
|
void interactiveShowData(void);
|
|
|
|
void interactiveRemoveStaleAircrafts(void);
|
2013-09-20 17:48:15 +02:00
|
|
|
int decodeBinMessage (struct client *c, char *p);
|
2014-07-10 19:11:13 +02:00
|
|
|
struct aircraft *interactiveFindAircraft(uint32_t addr);
|
2013-09-20 17:48:15 +02:00
|
|
|
|
2013-08-19 16:55:17 +02:00
|
|
|
//
|
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 19:57:03 +02:00
|
|
|
// Functions exported from net_io.c
|
2013-08-19 16:55:17 +02:00
|
|
|
//
|
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 19:57:03 +02:00
|
|
|
void modesInitNet (void);
|
|
|
|
void modesQueueOutput (struct modesMessage *mm);
|
2013-09-20 17:48:15 +02:00
|
|
|
void modesReadFromClient(struct client *c, char *sep, int(*handler)(struct client *, char *));
|
2014-10-03 23:55:21 +02:00
|
|
|
void modesNetPeriodicWork (void);
|
2014-12-10 18:05:22 +01:00
|
|
|
|
2015-01-15 21:54:22 +01:00
|
|
|
void writeJsonToFile(const char *file, char * (*generator) (const char*,int*));
|
|
|
|
char *generateAircraftJson(const char *url_path, int *len);
|
|
|
|
char *generateReceiverJson(const char *url_path, int *len);
|
2015-01-15 21:55:55 +01:00
|
|
|
char *generateHistoryJson(const char *url_path, int *len);
|
2013-05-25 00:32:12 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // __DUMP1090_H
|