VK1ET : --Interactive display changes

Based on a submission by VK1ET, but I've tweaked it a bit to use the
bFlags.

Basically, only print out values in --interactive that have been
received from the aircraft. Previous versions would display 0.000 for
lat and long for any positionless aircraft. This version prints blanks
instead for any/all fields that are not yet known.
This commit is contained in:
Malcolm Robb 2013-05-10 18:17:19 +01:00
parent cd86d58898
commit 6427fcc1ee

View file

@ -2768,64 +2768,71 @@ void interactiveShowData(void) {
|| (((flags & (MODEAC_MSG_MODES_HIT | MODEAC_MSG_MODEC_OLD )) == 0 ) && (msgs > 127) )
) {
int altitude = a->altitude, speed = a->speed;
char squawk[5] = " ";
char strSquawk[5] = " ";
char strFl[6] = " ";
char strTt[5] = " ";
char strGs[5] = " ";
// Convert units to metric if --metric was specified
if (Modes.metric) {
altitude = (int) (altitude / 3.2828);
speed = (int) (speed * 1.852);
speed = (int) (speed * 1.852);
}
if (altitude > 99999) {
altitude = 99999;
} else if (altitude == -999900) {
altitude = 0;
} else if (altitude < -9999) {
altitude = -9999;
}
if (a->modeA) {
sprintf(squawk, "%04x", a->modeA);
}
if (a->bFlags & MODES_ACFLAGS_SQUAWK_VALID) {
snprintf(strSquawk,5,"%04x", a->modeA);}
if (a->bFlags & MODES_ACFLAGS_SPEED_VALID) {
snprintf (strGs, 5,"%3d", speed);}
if (a->bFlags & MODES_ACFLAGS_HEADING_VALID) {
snprintf (strTt, 5,"%03d", a->track);}
if (msgs > 99999) {
msgs = 99999;
}
msgs = 99999;}
if (Modes.interactive_rtl1090 != 0) {
char fl[5] = " ";
char tt[5] = " ";
char gs[5] = " ";
if (Modes.interactive_rtl1090) { // RTL1090 display mode
if (altitude > 0) {
sprintf(fl,"F%03d",(altitude/100));
}
if (speed > 0) {
sprintf (gs,"%3d",speed);
}
if (a->track > 0) {
sprintf (tt,"%03d",a->track);
if (a->bFlags & MODES_ACFLAGS_ALTITUDE_VALID) {
snprintf(strFl,6,"F%03d",(altitude/100));
}
printf("%06x %-8s %-4s %-3s %-3s %4s %-6d %-2d\n",
a->addr, a->flight, fl, gs, tt, squawk, msgs, (int)(now - a->seen));
a->addr, a->flight, strFl, strGs, strTt, strSquawk, msgs, (int)(now - a->seen));
} else {
char mode[5] = " \0";
} else { // Dump1090 display mode
char strMode[5] = " ";
char strLat[8] = " ";
char strLon[9] = " ";
unsigned char * pSig = a->signalLevel;
unsigned int signalAverage = (pSig[0] + pSig[1] + pSig[2] + pSig[3] +
pSig[4] + pSig[5] + pSig[6] + pSig[7] + 3) >> 3;
if ((flags & MODEAC_MSG_FLAG) == 0) {
mode[0] = 'S';
strMode[0] = 'S';
} else if (flags & MODEAC_MSG_MODEA_ONLY) {
mode[0] = 'A';
strMode[0] = 'A';
}
if (flags & MODEAC_MSG_MODEA_HIT) {mode[2] = 'a';}
if (flags & MODEAC_MSG_MODEC_HIT) {mode[3] = 'c';}
if (flags & MODEAC_MSG_MODEA_HIT) {strMode[2] = 'a';}
if (flags & MODEAC_MSG_MODEC_HIT) {strMode[3] = 'c';}
printf("%06x %-4s %-4s %-8s %5d %3d %3d %7.03f %8.03f %3d %5d %2d\n",
a->addr, mode, squawk, a->flight, altitude, speed, a->track,
a->lat, a->lon, signalAverage, msgs, (int)(now - a->seen));
if (a->bFlags & MODES_ACFLAGS_LATLON_VALID) {
snprintf(strLat, 8,"%7.03f", a->lat);
snprintf(strLon, 9,"%8.03f", a->lon);
}
if (a->bFlags & MODES_ACFLAGS_AOG) {
snprintf(strFl, 6," grnd");
} else if (a->bFlags & MODES_ACFLAGS_ALTITUDE_VALID) {
snprintf(strFl, 6, "%5d", altitude);
}
// printf("%06x %-4s %-4s %-8s %5d %3d %3d %7.03f %8.03f %3d %5d %2d\n",
// a->addr, strMode, strSquawk, a->flight, altitude, speed, a->track,
// a->lat, a->lon, signalAverage, msgs, (int)(now - a->seen));
printf("%06x %-4s %-4s %-8s %5s %3s %3s %7s %8s %3d %5d %2d\n",
a->addr, strMode, strSquawk, a->flight, strFl, strGs, strTt,
strLat, strLon, signalAverage, msgs, (int)(now - a->seen));
}
count++;
}