If --hae is passed, report altitudes as HAE where available, with a H suffix.

This affects interactive mode and SBS output.
This commit is contained in:
Oliver Jowett 2016-01-01 15:15:28 +00:00
parent c99e4d9aed
commit 9479a5c9be
6 changed files with 25 additions and 12 deletions

View file

@ -709,6 +709,7 @@ void showHelp(void) {
"--stats-every <seconds> Show and reset stats every <seconds> seconds\n"
"--onlyaddr Show only ICAO addresses (testing purposes)\n"
"--metric Use metric units (meters, km/h, ...)\n"
"--hae Show altitudes as HAE (with H suffix) when available\n"
"--snip <level> Strip IQ file removing samples < level\n"
"--debug <flags> Debug mode (verbose), see README for details\n"
"--quiet Disable output to stdout. Use for daemon applications\n"
@ -1006,6 +1007,8 @@ int main(int argc, char **argv) {
Modes.onlyaddr = 1;
} else if (!strcmp(argv[j],"--metric")) {
Modes.metric = 1;
} else if (!strcmp(argv[j],"--hae")) {
Modes.use_hae = 1;
} else if (!strcmp(argv[j],"--aggressive")) {
Modes.nfix_crc = MODES_MAX_BITERRORS;
} else if (!strcmp(argv[j],"--interactive")) {

View file

@ -323,6 +323,7 @@ struct { // Internal state
int stats_range_histo; // Collect/show a range histogram?
int onlyaddr; // Print only ICAO addresses
int metric; // Use metric units
int use_hae; // Use HAE altitudes with H suffix when available
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
char *json_dir; // Path to json base directory, or NULL not to write json.

View file

@ -118,7 +118,7 @@ void interactiveShowData(void) {
|| (((flags & (MODEAC_MSG_MODES_HIT | MODEAC_MSG_MODEC_OLD )) == 0 ) && (msgs > 127) )
) {
char strSquawk[5] = " ";
char strFl[6] = " ";
char strFl[7] = " ";
char strTt[5] = " ";
char strGs[5] = " ";
@ -164,12 +164,14 @@ void interactiveShowData(void) {
}
if (a->bFlags & MODES_ACFLAGS_AOG) {
snprintf(strFl, 6," grnd");
snprintf(strFl, 7," grnd");
} else if (Modes.use_hae && (a->bFlags & MODES_ACFLAGS_ALTITUDE_HAE_VALID)) {
snprintf(strFl, 7, "%5dH", convert_altitude(a->altitude_hae));
} else if (a->bFlags & MODES_ACFLAGS_ALTITUDE_VALID) {
snprintf(strFl, 6, "%5d", convert_altitude(a->altitude));
snprintf(strFl, 7, "%5d ", convert_altitude(a->altitude));
}
printf("%s%06X %-4s %-4s %-8s %5s %3s %3s %7s %8s %5.1f %5d %2.0f\n",
printf("%s%06X %-4s %-4s %-8s %6s %3s %3s %7s %8s %5.1f %5d %2.0f\n",
(a->addr & MODES_NON_ICAO_ADDRESS) ? "~" : " ", (a->addr & 0xffffff),
strMode, strSquawk, a->flight, strFl, strGs, strTt,
strLat, strLon, 10 * log10(signalAverage), msgs, (now - a->seen)/1000.0);

View file

@ -1261,15 +1261,15 @@ void useModesMessage(struct modesMessage *mm) {
if (Modes.net) {
if (Modes.net_verbatim || mm->msgtype == 32) {
// Unconditionally send
modesQueueOutput(mm);
modesQueueOutput(mm, a);
} else if (a->messages > 1) {
// If this is the second message, and we
// squelched the first message, then re-emit the
// first message now.
if (!Modes.net_verbatim && a->messages == 2) {
modesQueueOutput(&a->first_message);
modesQueueOutput(&a->first_message, a);
}
modesQueueOutput(mm);
modesQueueOutput(mm, a);
}
}
}

View file

@ -460,7 +460,7 @@ static void send_raw_heartbeat(struct net_service *service)
// Write SBS output to TCP clients
// The message structure mm->bFlags tells us what has been updated by this message
//
static void modesSendSBSOutput(struct modesMessage *mm) {
static void modesSendSBSOutput(struct modesMessage *mm, struct aircraft *a) {
char *p;
struct timespec now;
struct tm stTime_receive, stTime_now;
@ -535,8 +535,14 @@ static void modesSendSBSOutput(struct modesMessage *mm) {
// Field 12 is the altitude (if we have it) - force to zero if we're on the ground
if ((mm->bFlags & MODES_ACFLAGS_AOG_GROUND) == MODES_ACFLAGS_AOG_GROUND) {
p += sprintf(p, ",0");
} else if (Modes.use_hae && (mm->bFlags & MODES_ACFLAGS_ALTITUDE_HAE_VALID)) {
p += sprintf(p, ",%dH", mm->altitude_hae);
} else if (mm->bFlags & MODES_ACFLAGS_ALTITUDE_VALID) {
p += sprintf(p, ",%d", mm->altitude);
if (Modes.use_hae && (a->bFlags & MODES_ACFLAGS_HAE_DELTA_VALID)) {
p += sprintf(p, ",%dH", mm->altitude + a->hae_delta);
} else {
p += sprintf(p, ",%d", mm->altitude);
}
} else {
p += sprintf(p, ",");
}
@ -636,11 +642,11 @@ static void send_sbs_heartbeat(struct net_service *service)
//
//=========================================================================
//
void modesQueueOutput(struct modesMessage *mm) {
void modesQueueOutput(struct modesMessage *mm, struct aircraft *a) {
if ((mm->bFlags & MODES_ACFLAGS_FROM_MLAT) && !Modes.forward_mlat)
return;
modesSendSBSOutput(mm);
modesSendSBSOutput(mm, a);
modesSendBeastOutput(mm);
modesSendRawOutput(mm);
}

View file

@ -22,6 +22,7 @@
// Describes a networking service (group of connections)
struct aircraft;
struct modesMessage;
struct client;
struct net_service;
@ -71,7 +72,7 @@ struct net_service *makeBeastInputService(void);
struct net_service *makeFatsvOutputService(void);
void modesInitNet(void);
void modesQueueOutput(struct modesMessage *mm);
void modesQueueOutput(struct modesMessage *mm, struct aircraft *a);
void modesNetPeriodicWork(void);
// TODO: move these somewhere else