Version 1.09.1007.14

Updates to support COAA Planeplotter Ground Station on an RPi
This commit is contained in:
Malcolm Robb 2014-07-10 18:11:13 +01:00
parent a17e5b0f98
commit 8b05286a24
16 changed files with 245 additions and 94 deletions

View file

@ -1 +0,0 @@
dump1090.exe --interactive --net --net-ro-size 500 --net-ro-rate 5

Binary file not shown.

Binary file not shown.

1
anet.c
View file

@ -165,6 +165,7 @@ static int anetTcpGenericConnect(char *err, char *addr, int port, int flags)
if ((s = anetCreateSocket(err,AF_INET)) == ANET_ERR) if ((s = anetCreateSocket(err,AF_INET)) == ANET_ERR)
return ANET_ERR; return ANET_ERR;
memset(&sa,0,sizeof(sa));
sa.sin_family = AF_INET; sa.sin_family = AF_INET;
sa.sin_port = htons((uint16_t)port); sa.sin_port = htons((uint16_t)port);
if (inet_aton(addr, (void*)&sa.sin_addr) == 0) { if (inet_aton(addr, (void*)&sa.sin_addr) == 0) {

Binary file not shown.

View file

@ -1 +0,0 @@
dump1090.exe --interactive --net --net-ro-port 30002 --net-beast --mlat

View file

@ -68,6 +68,7 @@ void modesInitConfig(void) {
// Now initialise things that should not be 0/NULL to their defaults // Now initialise things that should not be 0/NULL to their defaults
Modes.gain = MODES_MAX_GAIN; Modes.gain = MODES_MAX_GAIN;
Modes.freq = MODES_DEFAULT_FREQ; Modes.freq = MODES_DEFAULT_FREQ;
Modes.ppm_error = MODES_DEFAULT_PPM;
Modes.check_crc = 1; Modes.check_crc = 1;
Modes.net_heartbeat_rate = MODES_NET_HEARTBEAT_RATE; Modes.net_heartbeat_rate = MODES_NET_HEARTBEAT_RATE;
Modes.net_output_sbs_port = MODES_NET_OUTPUT_SBS_PORT; Modes.net_output_sbs_port = MODES_NET_OUTPUT_SBS_PORT;
@ -88,6 +89,7 @@ void modesInitConfig(void) {
void modesInit(void) { void modesInit(void) {
int i, q; int i, q;
pthread_mutex_init(&Modes.pDF_mutex,NULL);
pthread_mutex_init(&Modes.data_mutex,NULL); pthread_mutex_init(&Modes.data_mutex,NULL);
pthread_cond_init(&Modes.data_cond,NULL); pthread_cond_init(&Modes.data_cond,NULL);

Binary file not shown.

View file

@ -37,7 +37,7 @@
// MinorVer changes when additional features are added, but not for bug fixes (range 00-99) // 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 // DayDate & Year changes for all changes, including for bug fixes. It represent the release date of the update
// //
#define MODES_DUMP1090_VERSION "1.08.2705.14" #define MODES_DUMP1090_VERSION "1.09.1007.14"
// ============================= Include files ========================== // ============================= Include files ==========================
@ -78,6 +78,7 @@
#define MODES_USER_LONGITUDE_DFLT (0.0) #define MODES_USER_LONGITUDE_DFLT (0.0)
#endif #endif
#define MODES_DEFAULT_PPM 52
#define MODES_DEFAULT_RATE 2000000 #define MODES_DEFAULT_RATE 2000000
#define MODES_DEFAULT_FREQ 1090000000 #define MODES_DEFAULT_FREQ 1090000000
#define MODES_DEFAULT_WIDTH 1000 #define MODES_DEFAULT_WIDTH 1000
@ -226,6 +227,15 @@ struct aircraft {
struct aircraft *next; // Next aircraft in our linked list struct aircraft *next; // Next aircraft in our linked list
}; };
struct stDF {
struct stDF *pNext; // Pointer to next item in the linked list
struct aircraft *pAircraft; // Pointer to the Aircraft structure for this DF
time_t seen; // Dos/UNIX Time at which the this packet was received
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 // Program global state
struct { // Internal state struct { // Internal state
pthread_t reader_thread; pthread_t reader_thread;
@ -316,6 +326,11 @@ struct { // Internal state
struct aircraft *aircrafts; struct aircraft *aircrafts;
uint64_t interactive_last_update; // Last screen update in milliseconds uint64_t interactive_last_update; // Last screen update in milliseconds
// DF List mode
int bEnableDFLogging; // Set to enable DF Logging
pthread_mutex_t pDF_mutex; // Mutex to synchronize pDF access
struct stDF *pDF; // Pointer to DF list
// Statistics // Statistics
unsigned int stat_valid_preamble; unsigned int stat_valid_preamble;
unsigned int stat_demodulated0; unsigned int stat_demodulated0;
@ -426,6 +441,8 @@ struct aircraft* interactiveReceiveData(struct modesMessage *mm);
void interactiveShowData(void); void interactiveShowData(void);
void interactiveRemoveStaleAircrafts(void); void interactiveRemoveStaleAircrafts(void);
int decodeBinMessage (struct client *c, char *p); int decodeBinMessage (struct client *c, char *p);
struct aircraft *interactiveFindAircraft(uint32_t addr);
struct stDF *interactiveFindDF (uint32_t addr);
// //
// Functions exported from net_io.c // Functions exported from net_io.c

View file

@ -42,6 +42,86 @@ static uint64_t mstime(void) {
return mst; return mst;
} }
// //
//=========================================================================
//
// Add a new DF structure to the interactive mode linked list
//
void interactiveCreateDF(struct aircraft *a, struct modesMessage *mm) {
struct stDF *pDF = (struct stDF *) malloc(sizeof(*pDF));
if (pDF) {
// Default everything to zero/NULL
memset(pDF, 0, sizeof(*pDF));
// Now initialise things
pDF->seen = a->seen;
pDF->llTimestamp = mm->timestampMsg;
pDF->addr = mm->addr;
pDF->pAircraft = a;
memcpy(pDF->msg, mm->msg, MODES_LONG_MSG_BYTES);
if (!pthread_mutex_lock(&Modes.pDF_mutex)) {
pDF->pNext = Modes.pDF;
Modes.pDF = pDF;
pthread_mutex_unlock(&Modes.pDF_mutex);
} else {
free(pDF);
}
}
}
//
// Remove stale DF's from the interactive mode linked list
//
void interactiveRemoveStaleDF(time_t now) {
struct stDF *pDF = NULL;
struct stDF *prev = NULL;
// Only fiddle with the DF list if we gain possession of the mutex
// If we fail to get the mutex we'll get another chance to tidy the
// DF list in a second or so.
if (!pthread_mutex_trylock(&Modes.pDF_mutex)) {
pDF = Modes.pDF;
while(pDF) {
if ((now - pDF->seen) > Modes.interactive_delete_ttl) {
if (!prev) {
Modes.pDF = NULL;
} else {
prev->pNext = NULL;
}
// All DF's in the list from here onwards will be time
// expired, so delete them all
while ((prev = pDF)) {
pDF = pDF->pNext;
free(prev);
}
} else {
prev = pDF;
pDF = pDF->pNext;
}
}
pthread_mutex_unlock (&Modes.pDF_mutex);
}
}
struct stDF *interactiveFindDF(uint32_t addr) {
struct stDF *pDF = NULL;
if (!pthread_mutex_lock(&Modes.pDF_mutex)) {
pDF = Modes.pDF;
while(pDF) {
if (pDF->addr == addr) {
pthread_mutex_unlock (&Modes.pDF_mutex);
return (pDF);
}
pDF = pDF->pNext;
}
pthread_mutex_unlock (&Modes.pDF_mutex);
}
return (NULL);
}
//
//========================= Interactive mode =============================== //========================= Interactive mode ===============================
// //
// Return a new aircraft structure for the interactive mode linked list // Return a new aircraft structure for the interactive mode linked list
@ -314,6 +394,11 @@ struct aircraft *interactiveReceiveData(struct modesMessage *mm) {
} }
} }
// If we are Logging DF's, and it's not a Mode A/C
if ((Modes.bEnableDFLogging) && (mm->msgtype < 32)) {
interactiveCreateDF(a,mm);
}
return (a); return (a);
} }
// //
@ -427,7 +512,7 @@ void interactiveShowData(void) {
snprintf(strFl, 6, "%5d", altitude); snprintf(strFl, 6, "%5d", altitude);
} }
printf("%06x %-4s %-4s %-8s %5s %3s %3s %7s %8s %3d %5d %2d\n", printf("%06X %-4s %-4s %-8s %5s %3s %3s %7s %8s %3d %5d %2d\n",
a->addr, strMode, strSquawk, a->flight, strFl, strGs, strTt, a->addr, strMode, strSquawk, a->flight, strFl, strGs, strTt,
strLat, strLon, signalAverage, msgs, (int)(now - a->seen)); strLat, strLon, signalAverage, msgs, (int)(now - a->seen));
} }
@ -448,16 +533,19 @@ void interactiveRemoveStaleAircrafts(void) {
struct aircraft *prev = NULL; struct aircraft *prev = NULL;
time_t now = time(NULL); time_t now = time(NULL);
interactiveRemoveStaleDF(now);
while(a) { while(a) {
if ((now - a->seen) > Modes.interactive_delete_ttl) { if ((now - a->seen) > Modes.interactive_delete_ttl) {
struct aircraft *next = a->next; struct aircraft *next = a->next;
// Remove the element from the linked list, with care // Remove the element from the linked list, with care
// if we are removing the first element // if we are removing the first element
if (!prev) if (!prev) {
Modes.aircrafts = next; Modes.aircrafts = next;
else } else {
prev->next = next; prev->next = next;
}
free(a); free(a);
a = next; a = next;

129
mode_s.c
View file

@ -907,6 +907,10 @@ void decodeModesMessage(struct modesMessage *mm, unsigned char *msg) {
mm->crcok = ICAOAddressWasRecentlySeen(mm->addr = mm->crc); mm->crcok = ICAOAddressWasRecentlySeen(mm->addr = mm->crc);
} }
// If we're checking CRC and the CRC is invalid, then we can't trust any
// of the data contents, so save time and give up now.
if ((Modes.check_crc) && (!mm->crcok)) { return;}
// Fields for DF0, DF16 // Fields for DF0, DF16
if (mm->msgtype == 0 || mm->msgtype == 16) { if (mm->msgtype == 0 || mm->msgtype == 16) {
if (msg[0] & 0x04) { // VS Bit if (msg[0] & 0x04) { // VS Bit
@ -982,32 +986,6 @@ void decodeModesMessage(struct modesMessage *mm, unsigned char *msg) {
mm->flight[8] = '\0'; mm->flight[8] = '\0';
} else if (metype >= 5 && metype <= 18) { // Position Message
mm->raw_latitude = ((msg[6] & 3) << 15) | (msg[7] << 7) | (msg[8] >> 1);
mm->raw_longitude = ((msg[8] & 1) << 16) | (msg[9] << 8) | (msg[10]);
mm->bFlags |= (mm->msg[6] & 0x04) ? MODES_ACFLAGS_LLODD_VALID
: MODES_ACFLAGS_LLEVEN_VALID;
if (metype >= 9) { // Airborne
int AC12Field = ((msg[5] << 4) | (msg[6] >> 4)) & 0x0FFF;
mm->bFlags |= MODES_ACFLAGS_AOG_VALID;
if (AC12Field) {// Only attempt to decode if a valid (non zero) altitude is present
mm->bFlags |= MODES_ACFLAGS_ALTITUDE_VALID;
mm->altitude = decodeAC12Field(AC12Field, &mm->unit);
}
} else { // Ground
int movement = ((msg[4] << 4) | (msg[5] >> 4)) & 0x007F;
mm->bFlags |= MODES_ACFLAGS_AOG_VALID | MODES_ACFLAGS_AOG;
if ((movement) && (movement < 125)) {
mm->bFlags |= MODES_ACFLAGS_SPEED_VALID;
mm->velocity = decodeMovementField(movement);
}
if (msg[5] & 0x08) {
mm->bFlags |= MODES_ACFLAGS_HEADING_VALID;
mm->heading = ((((msg[5] << 4) | (msg[6] >> 4)) & 0x007F) * 45) >> 4;
}
}
} else if (metype == 19) { // Airborne Velocity Message } else if (metype == 19) { // Airborne Velocity Message
// Presumably airborne if we get an Airborne Velocity Message // Presumably airborne if we get an Airborne Velocity Message
@ -1076,22 +1054,61 @@ void decodeModesMessage(struct modesMessage *mm, unsigned char *msg) {
mm->heading = ((((msg[5] & 0x03) << 8) | msg[6]) * 45) >> 7; mm->heading = ((((msg[5] & 0x03) << 8) | msg[6]) * 45) >> 7;
} }
} }
} else if (mm->metype == 23) { // Test metype squawk field
if (mm->mesub == 7) { // (see 1090-WP-15-20) } else if (metype >= 5 && metype <= 22) { // Position Message
mm->raw_latitude = ((msg[6] & 3) << 15) | (msg[7] << 7) | (msg[8] >> 1);
mm->raw_longitude = ((msg[8] & 1) << 16) | (msg[9] << 8) | (msg[10]);
mm->bFlags |= (mm->msg[6] & 0x04) ? MODES_ACFLAGS_LLODD_VALID
: MODES_ACFLAGS_LLEVEN_VALID;
if (metype >= 9) { // Airborne
int AC12Field = ((msg[5] << 4) | (msg[6] >> 4)) & 0x0FFF;
mm->bFlags |= MODES_ACFLAGS_AOG_VALID;
if (AC12Field) {// Only attempt to decode if a valid (non zero) altitude is present
mm->bFlags |= MODES_ACFLAGS_ALTITUDE_VALID;
mm->altitude = decodeAC12Field(AC12Field, &mm->unit);
}
} else { // Ground
int movement = ((msg[4] << 4) | (msg[5] >> 4)) & 0x007F;
mm->bFlags |= MODES_ACFLAGS_AOG_VALID | MODES_ACFLAGS_AOG;
if ((movement) && (movement < 125)) {
mm->bFlags |= MODES_ACFLAGS_SPEED_VALID;
mm->velocity = decodeMovementField(movement);
}
if (msg[5] & 0x08) {
mm->bFlags |= MODES_ACFLAGS_HEADING_VALID;
mm->heading = ((((msg[5] << 4) | (msg[6] >> 4)) & 0x007F) * 45) >> 4;
}
}
} else if (metype == 23) { // Test metype squawk field
if (mesub == 7) { // (see 1090-WP-15-20)
int ID13Field = (((msg[5] << 8) | msg[6]) & 0xFFF1)>>3; int ID13Field = (((msg[5] << 8) | msg[6]) & 0xFFF1)>>3;
if (ID13Field) { if (ID13Field) {
mm->bFlags |= MODES_ACFLAGS_SQUAWK_VALID; mm->bFlags |= MODES_ACFLAGS_SQUAWK_VALID;
mm->modeA = decodeID13Field(ID13Field); mm->modeA = decodeID13Field(ID13Field);
} }
} }
} else if (mm->metype == 28) { // Emergency status squawk field
if (mm->mesub == 1) { } else if (metype == 24) { // Reserved for Surface System Status
} else if (metype == 28) { // Extended Squitter Aircraft Status
if (mesub == 1) { // Emergency status squawk field
int ID13Field = (((msg[5] << 8) | msg[6]) & 0x1FFF); int ID13Field = (((msg[5] << 8) | msg[6]) & 0x1FFF);
if (ID13Field) { if (ID13Field) {
mm->bFlags |= MODES_ACFLAGS_SQUAWK_VALID; mm->bFlags |= MODES_ACFLAGS_SQUAWK_VALID;
mm->modeA = decodeID13Field(ID13Field); mm->modeA = decodeID13Field(ID13Field);
} }
} }
} else if (metype == 29) { // Aircraft Trajectory Intent
} else if (metype == 30) { // Aircraft Operational Coordination
} else if (metype == 31) { // Aircraft Operational Status
} else { // Other metypes
} }
} }
@ -1268,20 +1285,6 @@ void displayModesMessage(struct modesMessage *mm) {
printf(" Aircraft Type : %c%d\n", ('A' + 4 - mm->metype), mm->mesub); printf(" Aircraft Type : %c%d\n", ('A' + 4 - mm->metype), mm->mesub);
printf(" Identification : %s\n", mm->flight); printf(" Identification : %s\n", mm->flight);
//} else if (mm->metype >= 5 && mm->metype <= 8) { // Surface position
} else if (mm->metype >= 9 && mm->metype <= 18) { // Airborne position Baro
printf(" F flag : %s\n", (mm->msg[6] & 0x04) ? "odd" : "even");
printf(" T flag : %s\n", (mm->msg[6] & 0x08) ? "UTC" : "non-UTC");
printf(" Altitude : %d feet\n", mm->altitude);
if (mm->bFlags & MODES_ACFLAGS_LATLON_VALID) {
printf(" Latitude : %f\n", mm->fLat);
printf(" Longitude: %f\n", mm->fLon);
} else {
printf(" Latitude : %d (not decoded)\n", mm->raw_latitude);
printf(" Longitude: %d (not decoded)\n", mm->raw_longitude);
}
} else if (mm->metype == 19) { // Airborne Velocity } else if (mm->metype == 19) { // Airborne Velocity
if (mm->mesub == 1 || mm->mesub == 2) { if (mm->mesub == 1 || mm->mesub == 2) {
printf(" EW status : %s\n", (mm->bFlags & MODES_ACFLAGS_EWSPEED_VALID) ? "Valid" : "Unavailable"); printf(" EW status : %s\n", (mm->bFlags & MODES_ACFLAGS_EWSPEED_VALID) ? "Valid" : "Unavailable");
@ -1305,7 +1308,17 @@ void displayModesMessage(struct modesMessage *mm) {
printf(" Unrecognized ME subtype: %d subtype: %d\n", mm->metype, mm->mesub); printf(" Unrecognized ME subtype: %d subtype: %d\n", mm->metype, mm->mesub);
} }
//} else if (mm->metype >= 20 && mm->metype <= 22) { // Airborne position GNSS } else if (mm->metype >= 5 && mm->metype <= 22) { // Airborne position Baro
printf(" F flag : %s\n", (mm->msg[6] & 0x04) ? "odd" : "even");
printf(" T flag : %s\n", (mm->msg[6] & 0x08) ? "UTC" : "non-UTC");
printf(" Altitude : %d feet\n", mm->altitude);
if (mm->bFlags & MODES_ACFLAGS_LATLON_VALID) {
printf(" Latitude : %f\n", mm->fLat);
printf(" Longitude: %f\n", mm->fLon);
} else {
printf(" Latitude : %d (not decoded)\n", mm->raw_latitude);
printf(" Longitude: %d (not decoded)\n", mm->raw_longitude);
}
} else if (mm->metype == 28) { // Extended Squitter Aircraft Status } else if (mm->metype == 28) { // Extended Squitter Aircraft Status
if (mm->mesub == 1) { if (mm->mesub == 1) {
@ -1343,20 +1356,6 @@ void displayModesMessage(struct modesMessage *mm) {
printf(" Aircraft Type : %c%d\n", ('A' + 4 - mm->metype), mm->mesub); printf(" Aircraft Type : %c%d\n", ('A' + 4 - mm->metype), mm->mesub);
printf(" Identification : %s\n", mm->flight); printf(" Identification : %s\n", mm->flight);
//} else if (mm->metype >= 5 && mm->metype <= 8) { // Surface position
} else if (mm->metype >= 9 && mm->metype <= 18) { // Airborne position Baro
printf(" F flag : %s\n", (mm->msg[6] & 0x04) ? "odd" : "even");
printf(" T flag : %s\n", (mm->msg[6] & 0x08) ? "UTC" : "non-UTC");
printf(" Altitude : %d feet\n", mm->altitude);
if (mm->bFlags & MODES_ACFLAGS_LATLON_VALID) {
printf(" Latitude : %f\n", mm->fLat);
printf(" Longitude: %f\n", mm->fLon);
} else {
printf(" Latitude : %d (not decoded)\n", mm->raw_latitude);
printf(" Longitude: %d (not decoded)\n", mm->raw_longitude);
}
} else if (mm->metype == 19) { // Airborne Velocity } else if (mm->metype == 19) { // Airborne Velocity
if (mm->mesub == 1 || mm->mesub == 2) { if (mm->mesub == 1 || mm->mesub == 2) {
printf(" EW status : %s\n", (mm->bFlags & MODES_ACFLAGS_EWSPEED_VALID) ? "Valid" : "Unavailable"); printf(" EW status : %s\n", (mm->bFlags & MODES_ACFLAGS_EWSPEED_VALID) ? "Valid" : "Unavailable");
@ -1380,7 +1379,17 @@ void displayModesMessage(struct modesMessage *mm) {
printf(" Unrecognized ME subtype: %d subtype: %d\n", mm->metype, mm->mesub); printf(" Unrecognized ME subtype: %d subtype: %d\n", mm->metype, mm->mesub);
} }
//} else if (mm->metype >= 20 && mm->metype <= 22) { // Airborne position GNSS } else if (mm->metype >= 5 && mm->metype <= 22) { // Ground or Airborne position, Baro or GNSS
printf(" F flag : %s\n", (mm->msg[6] & 0x04) ? "odd" : "even");
printf(" T flag : %s\n", (mm->msg[6] & 0x08) ? "UTC" : "non-UTC");
printf(" Altitude : %d feet\n", mm->altitude);
if (mm->bFlags & MODES_ACFLAGS_LATLON_VALID) {
printf(" Latitude : %f\n", mm->fLat);
printf(" Longitude: %f\n", mm->fLon);
} else {
printf(" Latitude : %d (not decoded)\n", mm->raw_latitude);
printf(" Longitude: %d (not decoded)\n", mm->raw_longitude);
}
} else { } else {
printf(" Unrecognized ME type: %d subtype: %d\n", mm->metype, mm->mesub); printf(" Unrecognized ME type: %d subtype: %d\n", mm->metype, mm->mesub);

View file

@ -458,16 +458,20 @@ int decodeBinMessage(struct client *c, char *p) {
int msgLen = 0; int msgLen = 0;
int j; int j;
char ch; char ch;
char * ptr;
unsigned char msg[MODES_LONG_MSG_BYTES]; unsigned char msg[MODES_LONG_MSG_BYTES];
struct modesMessage mm; struct modesMessage mm;
MODES_NOTUSED(c); MODES_NOTUSED(c);
memset(&mm, 0, sizeof(mm)); memset(&mm, 0, sizeof(mm));
if ((*p == '1') && (Modes.mode_ac)) { // skip ModeA/C unless user enables --modes-ac ch = *p++; /// Get the message type
if (0x1A == ch) {p++;}
if ((ch == '1') && (Modes.mode_ac)) { // skip ModeA/C unless user enables --modes-ac
msgLen = MODEAC_MSG_BYTES; msgLen = MODEAC_MSG_BYTES;
} else if (*p == '2') { } else if (ch == '2') {
msgLen = MODES_SHORT_MSG_BYTES; msgLen = MODES_SHORT_MSG_BYTES;
} else if (*p == '3') { } else if (ch == '3') {
msgLen = MODES_LONG_MSG_BYTES; msgLen = MODES_LONG_MSG_BYTES;
} }
@ -475,8 +479,10 @@ int decodeBinMessage(struct client *c, char *p) {
// Mark messages received over the internet as remote so that we don't try to // Mark messages received over the internet as remote so that we don't try to
// pass them off as being received by this instance when forwarding them // pass them off as being received by this instance when forwarding them
mm.remote = 1; mm.remote = 1;
for (j = 0; j < 7; j++) { // Skip the message type and timestamp
ch = *p++; ptr = (char*) &mm.timestampMsg;
for (j = 0; j < 6; j++) { // Grab the timestamp (big endian format)
ptr[5-j] = ch = *p++;
if (0x1A == ch) {p++;} if (0x1A == ch) {p++;}
} }

View file

@ -51,6 +51,7 @@ void ppup1090InitConfig(void) {
// Now initialise things that should not be 0/NULL to their defaults // Now initialise things that should not be 0/NULL to their defaults
Modes.check_crc = 1; Modes.check_crc = 1;
Modes.quiet = 1; Modes.quiet = 1;
Modes.bEnableDFLogging = 1;
strcpy(ppup1090.net_input_beast_ipaddr,PPUP1090_NET_OUTPUT_IP_ADDRESS); strcpy(ppup1090.net_input_beast_ipaddr,PPUP1090_NET_OUTPUT_IP_ADDRESS);
Modes.net_input_beast_port = MODES_NET_OUTPUT_BEAST_PORT; Modes.net_input_beast_port = MODES_NET_OUTPUT_BEAST_PORT;
Modes.interactive_delete_ttl = MODES_INTERACTIVE_DELETE_TTL; Modes.interactive_delete_ttl = MODES_INTERACTIVE_DELETE_TTL;
@ -71,6 +72,10 @@ void ppup1090Init(void) {
int iErr; int iErr;
pthread_mutex_init(&Modes.pDF_mutex,NULL);
pthread_mutex_init(&Modes.data_mutex,NULL);
pthread_cond_init(&Modes.data_cond,NULL);
// Allocate the various buffers used by Modes // Allocate the various buffers used by Modes
if ( NULL == (Modes.icao_cache = (uint32_t *) malloc(sizeof(uint32_t) * MODES_ICAO_CACHE_LEN * 2))) if ( NULL == (Modes.icao_cache = (uint32_t *) malloc(sizeof(uint32_t) * MODES_ICAO_CACHE_LEN * 2)))
{ {
@ -104,6 +109,7 @@ void ppup1090Init(void) {
modesInitErrorInfo(); modesInitErrorInfo();
// Setup the uploader - read the user paramaters from the coaa.h header file // Setup the uploader - read the user paramaters from the coaa.h header file
coaa1090.ppIPAddr = ppup1090.net_pp_ipaddr;
coaa1090.fUserLat = MODES_USER_LATITUDE_DFLT; coaa1090.fUserLat = MODES_USER_LATITUDE_DFLT;
coaa1090.fUserLon = MODES_USER_LONGITUDE_DFLT; coaa1090.fUserLon = MODES_USER_LONGITUDE_DFLT;
strcpy(coaa1090.strAuthCode,STR(USER_AUTHCODE)); strcpy(coaa1090.strAuthCode,STR(USER_AUTHCODE));
@ -126,6 +132,7 @@ void showHelp(void) {
"-----------------------------------------------------------------------------\n" "-----------------------------------------------------------------------------\n"
"--net-bo-ipaddr <IPv4> TCP Beast output listen IPv4 (default: 127.0.0.1)\n" "--net-bo-ipaddr <IPv4> TCP Beast output listen IPv4 (default: 127.0.0.1)\n"
"--net-bo-port <port> TCP Beast output listen port (default: 30005)\n" "--net-bo-port <port> TCP Beast output listen port (default: 30005)\n"
"--net-pp-ipaddr <IPv4> Plane Plotter LAN IPv4 Address (default: 0.0.0.0)\n"
"--quiet Disable output to stdout. Use for daemon applications\n" "--quiet Disable output to stdout. Use for daemon applications\n"
"--help Show this help\n" "--help Show this help\n"
); );
@ -185,6 +192,8 @@ int main(int argc, char **argv) {
Modes.net_input_beast_port = atoi(argv[++j]); Modes.net_input_beast_port = atoi(argv[++j]);
} else if (!strcmp(argv[j],"--net-bo-ipaddr") && more) { } else if (!strcmp(argv[j],"--net-bo-ipaddr") && more) {
strcpy(ppup1090.net_input_beast_ipaddr, argv[++j]); strcpy(ppup1090.net_input_beast_ipaddr, argv[++j]);
} else if (!strcmp(argv[j],"--net-pp-ipaddr") && more) {
inet_aton(argv[++j], (void *)&ppup1090.net_pp_ipaddr);
} else if (!strcmp(argv[j],"--quiet")) { } else if (!strcmp(argv[j],"--quiet")) {
ppup1090.quiet = 1; ppup1090.quiet = 1;
} else if (!strcmp(argv[j],"--help")) { } else if (!strcmp(argv[j],"--help")) {

View file

@ -45,6 +45,9 @@
#include <math.h> #include <math.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/timeb.h> #include <sys/timeb.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <signal.h> #include <signal.h>
#include <fcntl.h> #include <fcntl.h>
#include <ctype.h> #include <ctype.h>
@ -71,12 +74,14 @@
struct { // Internal state struct { // Internal state
int quiet; int quiet;
// Networking // Networking
uint32_t net_pp_ipaddr; // IPv4 address of PP instance
char net_input_beast_ipaddr[32]; // IPv4 address or network name of server/RPi char net_input_beast_ipaddr[32]; // IPv4 address or network name of server/RPi
} ppup1090; } ppup1090;
// COAA Initialisation structure // COAA Initialisation structure
struct _coaa1090 { struct _coaa1090 {
uint32_t ppIPAddr;
double fUserLat; double fUserLat;
double fUserLon; double fUserLon;
char strAuthCode[16]; char strAuthCode[16];

View file

@ -83,6 +83,21 @@ void view1090InitConfig(void) {
// //
void view1090Init(void) { void view1090Init(void) {
pthread_mutex_init(&Modes.pDF_mutex,NULL);
pthread_mutex_init(&Modes.data_mutex,NULL);
pthread_cond_init(&Modes.data_cond,NULL);
#ifdef _WIN32
if ( (!Modes.wsaData.wVersion)
&& (!Modes.wsaData.wHighVersion) ) {
// Try to start the windows socket support
if (WSAStartup(MAKEWORD(2,1),&Modes.wsaData) != 0)
{
fprintf(stderr, "WSAStartup returned Error\n");
}
}
#endif
// Allocate the various buffers used by Modes // Allocate the various buffers used by Modes
if ( NULL == (Modes.icao_cache = (uint32_t *) malloc(sizeof(uint32_t) * MODES_ICAO_CACHE_LEN * 2))) if ( NULL == (Modes.icao_cache = (uint32_t *) malloc(sizeof(uint32_t) * MODES_ICAO_CACHE_LEN * 2)))
{ {
@ -262,6 +277,7 @@ int main(int argc, char **argv) {
#ifdef _WIN32 #ifdef _WIN32
// Try to comply with the Copyright license conditions for binary distribution // Try to comply with the Copyright license conditions for binary distribution
if (!Modes.quiet) {showCopyright();} if (!Modes.quiet) {showCopyright();}
#define MSG_DONTWAIT 0
#endif #endif
#ifndef _WIN32 #ifndef _WIN32