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