Compare commits

...

13 commits

Author SHA1 Message Date
Arnold Dechamps 39cd6cb64e
Making it compile. Fixing Issue #165 in fork root 2024-09-01 21:00:31 +02:00
MalcolmRobb bff92c4ad7 Merge pull request #36 from mutability/improve-phase-enhancement
Rearrange phase enhancement so that it handles phase errors in both directions
2014-10-31 13:01:59 +00:00
Malcolm Robb 960ebfccea Publish version 1.10.3010.14 2014-10-30 17:50:56 +00:00
MalcolmRobb b8ea7540c7 Merge pull request #13 from bovine/faurl
link to FlightAware for flight details
2014-10-30 12:11:28 +00:00
Malcolm Robb a9cd75ded1 More Updates to Pull #54
Pull #54 breaks the Windows version of dump1090 due to a bug in the
inet_aton() windows function.

1) Fix the bug in the windows inet_aton()
2) Modify the command line code to strdup() the command line string.
3) Leave the Modes.net_bind_address pointer NULL if no command line
specified
2014-10-30 12:06:03 +00:00
Jeff Lawson cd09210cb9 Merge branch 'master' into faurl 2014-10-29 23:00:38 -05:00
Malcolm Robb 6d55cf6f71 Publish version 1.10.2910.14 2014-10-29 19:05:01 +00:00
Malcolm Robb 68f1220ab8 Change default binding to 0.0.0.0
Pull #54 permits changing the default bind address. The default was
127.0.0.1. This prevents external access unless a command line switch is
used. Since many users of dump1090 are using dump1090 as remote receiver
heads for programs such as plane plotter, this is undesirable. If you
want to lock down your RPi for local use only then use the command line
switch. If not, retain legacy open mode by binding to 0.0.0.0 by
default.
2014-10-29 19:04:25 +00:00
Malcolm Robb 5f18f6cbca Fix warnings and Windows compile problems 2014-10-29 19:00:42 +00:00
Malcolm Robb 3447f7ec83 Add Windows resource file for version numbering 2014-10-29 19:00:03 +00:00
Jeff Lawson 87a88c9798 Merge branch 'master' into faurl 2014-10-12 16:31:35 -05:00
Oliver Jowett 31b28b3878 Rearrange phase enhancement so that it handles phase errors in both directions.
This almost doubles the number of messages recovered by phase enhancement.
2014-09-15 01:43:14 +01:00
Jeff Lawson cc27ff6234 link to FlightAware for flight details 2014-02-27 14:40:14 -06:00
11 changed files with 201 additions and 52 deletions

Binary file not shown.

View file

@ -29,6 +29,7 @@
//
#include "coaa.h"
#include "dump1090.h"
struct stModes Modes; struct stDF tDF;
//
// ============================= Utility functions ==========================
//
@ -76,7 +77,6 @@ void modesInitConfig(void) {
Modes.net_input_raw_port = MODES_NET_INPUT_RAW_PORT;
Modes.net_output_beast_port = MODES_NET_OUTPUT_BEAST_PORT;
Modes.net_input_beast_port = MODES_NET_INPUT_BEAST_PORT;
Modes.net_bind_address = MODES_NET_BIND_ADDRESS;
Modes.net_http_port = MODES_NET_HTTP_PORT;
Modes.interactive_rows = getTermRows();
Modes.interactive_delete_ttl = MODES_INTERACTIVE_DELETE_TTL;
@ -410,7 +410,7 @@ void showHelp(void) {
"--modeac Enable decoding of SSR Modes 3/A & 3/C\n"
"--net-beast TCP raw output in Beast binary format\n"
"--net-only Enable just networking, no RTL device or file used\n"
"--net-bind-address <ip> IP address to bind to (default: 127.0.0.1; 0.0.0.0 for public)\n"
"--net-bind-address <ip> IP address to bind to (default: Any; Use 127.0.0.1 for private)\n"
"--net-http-port <port> HTTP server port (default: 8080)\n"
"--net-ri-port <port> TCP raw input listen port (default: 30001)\n"
"--net-ro-port <port> TCP raw output listen port (default: 30002)\n"
@ -719,7 +719,7 @@ int main(int argc, char **argv) {
} else if (!strcmp(argv[j],"--net-bi-port") && more) {
Modes.net_input_beast_port = atoi(argv[++j]);
} else if (!strcmp(argv[j],"--net-bind-address") && more) {
Modes.net_bind_address = argv[++j];
Modes.net_bind_address = strdup(argv[++j]);
} else if (!strcmp(argv[j],"--net-http-port") && more) {
Modes.net_http_port = atoi(argv[++j]);
} else if (!strcmp(argv[j],"--net-sbs-port") && more) {

View file

@ -131,6 +131,10 @@ SOURCE=.\winstubs.h
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\Dump1090.rc
# End Source File
# End Group
# Begin Group "Library Files"

View file

@ -37,7 +37,7 @@
// 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
//
#define MODES_DUMP1090_VERSION "1.09.0608.14"
#define MODES_DUMP1090_VERSION "1.10.3010.14"
// ============================= Include files ==========================
@ -173,7 +173,6 @@
#define MODES_NET_OUTPUT_SBS_PORT 30003
#define MODES_NET_INPUT_BEAST_PORT 30004
#define MODES_NET_OUTPUT_BEAST_PORT 30005
#define MODES_NET_BIND_ADDRESS "127.0.0.1"
#define MODES_NET_HTTP_PORT 8080
#define MODES_CLIENT_BUF_SIZE 1024
#define MODES_NET_SNDBUF_SIZE (1024*64)
@ -236,10 +235,10 @@ struct stDF {
uint64_t llTimestamp; // Timestamp at which the this packet was received
uint32_t addr; // Timestamp at which the this packet was received
unsigned char msg[MODES_LONG_MSG_BYTES]; // the binary
} tDF;
};
// Program global state
struct { // Internal state
struct stModes { // Internal state
pthread_t reader_thread;
pthread_mutex_t data_mutex; // Mutex to synchronize buffer access
@ -371,7 +370,8 @@ struct { // Internal state
unsigned int stat_blocks_processed;
unsigned int stat_blocks_dropped;
} Modes;
};
extern struct stModes Modes; extern struct stDF tDF;
// The struct we use to store information about a decoded message.
struct modesMessage {

115
dump1090.rc Normal file
View file

@ -0,0 +1,115 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS
#include "ntverp.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,10,2910,14
PRODUCTVERSION 1,10,2910,14
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x3L
FILESUBTYPE 0x7L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", "Dump1090 for Win32 \0"
VALUE "CompanyName", "\0"
VALUE "FileDescription", "Mode A/C/S decoder for RTL Dongles\0"
VALUE "FileVersion", "1, 10, 2910, 14\0"
VALUE "InternalName", "DUMP1090.EXE\0"
VALUE "LegalCopyright", "Copyright © 2012 by Salvatore Sanfilippo <antirez@gmail.com>\r\nCopyright © 2014 by Malcolm Robb <support@attavionics.com>\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "DUMP1090.EXE\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "DUMP1090\0"
VALUE "ProductVersion", "1, 10, 2910, 14\0"
VALUE "SpecialBuild", "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#endif // !_MAC
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""windows.h""\r\n"
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""ntverp.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

107
mode_s.c
View file

@ -1456,46 +1456,75 @@ int detectOutOfPhase(uint16_t *pPreamble) {
if (pPreamble[-1] > pPreamble[1]/3) return -1;
return 0;
}
uint16_t clamped_scale(uint16_t v, uint16_t scale) {
uint32_t scaled = (uint32_t)v * scale / 16384;
if (scaled > 65535) return 65535;
return (uint16_t) scaled;
}
// This function decides whether we are sampling early or late,
// and by approximately how much, by looking at the energy in
// preamble bits before and after the expected pulse locations.
//
//=========================================================================
//
// This function does not really correct the phase of the message, it just
// applies a transformation to the first sample representing a given bit:
//
// If the previous bit was one, we amplify it a bit.
// If the previous bit was zero, we decrease it a bit.
//
// This simple transformation makes the message a bit more likely to be
// correctly decoded for out of phase messages:
//
// When messages are out of phase there is more uncertainty in
// sequences of the same bit multiple times, since 11111 will be
// transmitted as continuously altering magnitude (high, low, high, low...)
//
// However because the message is out of phase some part of the high
// is mixed in the low part, so that it is hard to distinguish if it is
// a zero or a one.
//
// However when the message is out of phase passing from 0 to 1 or from
// 1 to 0 happens in a very recognizable way, for instance in the 0 -> 1
// transition, magnitude goes low, high, high, low, and one of of the
// two middle samples the high will be *very* high as part of the previous
// or next high signal will be mixed there.
//
// Applying our simple transformation we make more likely if the current
// bit is a zero, to detect another zero. Symmetrically if it is a one
// it will be more likely to detect a one because of the transformation.
// In this way similar levels will be interpreted more likely in the
// correct way.
// It then deals with one sample pair at a time, comparing samples
// to make a decision about the bit value. Based on this decision it
// modifies the sample value of the *adjacent* sample which will
// contain some of the energy from the bit we just inspected.
//
// pPayload[0] should be the start of the preamble,
// pPayload[-1 .. MODES_PREAMBLE_SAMPLES + MODES_LONG_MSG_SAMPLES - 1] should be accessible.
// pPayload[MODES_PREAMBLE_SAMPLES .. MODES_PREAMBLE_SAMPLES + MODES_LONG_MSG_SAMPLES - 1] will be updated.
void applyPhaseCorrection(uint16_t *pPayload) {
int j;
for (j = 0; j < MODES_LONG_MSG_SAMPLES; j += 2, pPayload += 2) {
if (pPayload[0] > pPayload[1]) { // One
pPayload[2] = (pPayload[2] * 5) / 4;
} else { // Zero
pPayload[2] = (pPayload[2] * 4) / 5;
// we expect 1 bits at 0, 2, 7, 9
// and 0 bits at -1, 1, 3, 4, 5, 6, 8, 10, 11, 12, 13, 14
// use bits -1,6 for early detection (bit 0/7 arrived a little early, our sample period starts after the bit phase so we include some of the next bit)
// use bits 3,10 for late detection (bit 2/9 arrived a little late, our sample period starts before the bit phase so we include some of the last bit)
uint32_t onTime = (pPayload[0] + pPayload[2] + pPayload[7] + pPayload[9]);
uint32_t early = (pPayload[-1] + pPayload[6]) << 1;
uint32_t late = (pPayload[3] + pPayload[10]) << 1;
if (early > late) {
// Our sample period starts late and so includes some of the next bit.
uint16_t scaleUp = 16384 + 16384 * early / (early + onTime); // 1 + early / (early+onTime)
uint16_t scaleDown = 16384 - 16384 * early / (early + onTime); // 1 - early / (early+onTime)
// trailing bits are 0; final data sample will be a bit low.
pPayload[MODES_PREAMBLE_SAMPLES + MODES_LONG_MSG_SAMPLES - 1] =
clamped_scale(pPayload[MODES_PREAMBLE_SAMPLES + MODES_LONG_MSG_SAMPLES - 1], scaleUp);
for (j = MODES_PREAMBLE_SAMPLES + MODES_LONG_MSG_SAMPLES - 2; j > MODES_PREAMBLE_SAMPLES; j -= 2) {
if (pPayload[j] > pPayload[j+1]) {
// x [1 0] y
// x overlapped with the "1" bit and is slightly high
pPayload[j-1] = clamped_scale(pPayload[j-1], scaleDown);
} else {
// x [0 1] y
// x overlapped with the "0" bit and is slightly low
pPayload[j-1] = clamped_scale(pPayload[j-1], scaleUp);
}
}
} else {
// Our sample period starts early and so includes some of the previous bit.
uint16_t scaleUp = 16384 + 16384 * late / (late + onTime); // 1 + late / (late+onTime)
uint16_t scaleDown = 16384 - 16384 * late / (late + onTime); // 1 - late / (late+onTime)
// leading bits are 0; first data sample will be a bit low.
pPayload[MODES_PREAMBLE_SAMPLES] = clamped_scale(pPayload[MODES_PREAMBLE_SAMPLES], scaleUp);
for (j = MODES_PREAMBLE_SAMPLES; j < MODES_PREAMBLE_SAMPLES + MODES_LONG_MSG_SAMPLES - 2; j += 2) {
if (pPayload[j] > pPayload[j+1]) {
// x [1 0] y
// y overlapped with the "0" bit and is slightly low
pPayload[j+2] = clamped_scale(pPayload[j+2], scaleUp);
} else {
// x [0 1] y
// y overlapped with the "1" bit and is slightly high
pPayload[j+2] = clamped_scale(pPayload[j+2], scaleDown);
}
}
}
}
@ -1509,7 +1538,7 @@ void applyPhaseCorrection(uint16_t *pPayload) {
void detectModeS(uint16_t *m, uint32_t mlen) {
struct modesMessage mm;
unsigned char msg[MODES_LONG_MSG_BYTES], *pMsg;
uint16_t aux[MODES_LONG_MSG_SAMPLES];
uint16_t aux[MODES_PREAMBLE_SAMPLES+MODES_LONG_MSG_SAMPLES+1];
uint32_t j;
int use_correction = 0;
@ -1631,10 +1660,10 @@ void detectModeS(uint16_t *m, uint32_t mlen) {
// If the previous attempt with this message failed, retry using
// magnitude correction
// Make a copy of the Payload, and phase correct the copy
memcpy(aux, pPayload, sizeof(aux));
applyPhaseCorrection(aux);
memcpy(aux, &pPreamble[-1], sizeof(aux));
applyPhaseCorrection(&aux[1]);
Modes.stat_out_of_phase++;
pPayload = aux;
pPayload = &aux[1 + MODES_PREAMBLE_SAMPLES];
// TODO ... apply other kind of corrections
}

View file

@ -782,9 +782,8 @@ int handleHTTPRequest(struct client *c, char *p) {
}
if (clen < 0) {
char buf[128];
content = realloc(content, sizeof(buf));
clen = snprintf(content,sizeof(buf),"Error opening HTML file: %s", strerror(errno));
content = realloc(content, 128);
clen = snprintf(content, 128,"Error opening HTML file: %s", strerror(errno));
statuscode = 404;
}

View file

@ -270,6 +270,7 @@ function refreshSelected() {
html += '&nbsp;<a href="http://fr24.com/'+selected.flight+'" target="_blank">[FR24]</a>';
html += '&nbsp;<a href="http://www.flightstats.com/go/FlightStatus/flightStatusByFlight.do?';
html += 'flightNumber='+selected.flight+'" target="_blank">[FlightStats]</a>';
html += '&nbsp;<a href="http://flightaware.com/live/flight/'+selected.flight+'" target="_blank">[FlightAware]</a>';
}
html += '<td></tr>';

View file

@ -29,6 +29,7 @@
//
#include "coaa.h"
#include "view1090.h"
struct stModes Modes; struct stDF tDF;
//
// ============================= Utility functions ==========================
//

View file

@ -72,10 +72,10 @@ _inline double trunc(double d) {return (d>0) ? floor(d):ceil(d) ;}
//usleep works in microseconds, and isn't supported in Windows. This will do for our use.
_inline void usleep(UINT32 ulSleep) {Sleep(ulSleep/1000);}
_inline uint64_t strtoll(const char *p, void *e, UINT32 base) {return _atoi64(p);}
_inline int inet_aton(const char * cp, DWORD * ulAddr) { *ulAddr = inet_addr(cp); return 0;}
_inline int inet_aton(const char * cp, DWORD * ulAddr) { *ulAddr = inet_addr(cp); return (INADDR_NONE != *ulAddr);}
#define snprintf _snprintf
#define vsnprintf _vsnprintf
#define realpath(A, B) _fullpath(B, A, _MAX_PATH)
#define realpath(N,R) _fullpath((R),(N),_MAX_PATH)
_inline void cls() {
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);