Don't use DF0/4/16/20 altitudes when DF17/18 altitudes are available.

The DF17/18 values are generally more trustworthy as they have full
CRC coverage. Errors in the CRC bits of a DF0/4/16/20 message can
result in the contained altitude being attributed to the wrong aircraft.
This commit is contained in:
Oliver Jowett 2015-06-26 20:43:46 +01:00
parent 5c2ec7106e
commit 8d1df036ae
4 changed files with 25 additions and 3 deletions

View file

@ -959,6 +959,7 @@ static char * appendStatsJson(char *p,
",\"local_range\":%u" ",\"local_range\":%u"
",\"local_speed\":%u" ",\"local_speed\":%u"
",\"filtered\":%u}" ",\"filtered\":%u}"
",\"altitude_suppressed\":%u"
",\"cpu\":{\"demod\":%llu,\"reader\":%llu,\"background\":%llu}" ",\"cpu\":{\"demod\":%llu,\"reader\":%llu,\"background\":%llu}"
",\"tracks\":{\"all\":%u" ",\"tracks\":{\"all\":%u"
",\"single_message\":%u}" ",\"single_message\":%u}"
@ -977,6 +978,7 @@ static char * appendStatsJson(char *p,
st->cpr_local_range_checks, st->cpr_local_range_checks,
st->cpr_local_speed_checks, st->cpr_local_speed_checks,
st->cpr_filtered, st->cpr_filtered,
st->suppressed_altitude_messages,
(unsigned long long)demod_cpu_millis, (unsigned long long)demod_cpu_millis,
(unsigned long long)reader_cpu_millis, (unsigned long long)reader_cpu_millis,
(unsigned long long)background_cpu_millis, (unsigned long long)background_cpu_millis,

View file

@ -151,6 +151,7 @@ void display_stats(struct stats *st) {
st->cpr_local_speed_checks, st->cpr_local_speed_checks,
st->cpr_filtered); st->cpr_filtered);
printf("%u non-ES altitude messages from ES-equipped aircraft ignored\n", st->suppressed_altitude_messages);
printf("%u unique aircraft tracks\n", st->unique_aircraft); printf("%u unique aircraft tracks\n", st->unique_aircraft);
printf("%u aircraft tracks where only one message was seen\n", st->single_message_aircraft); printf("%u aircraft tracks where only one message was seen\n", st->single_message_aircraft);
@ -325,6 +326,8 @@ void add_stats(const struct stats *st1, const struct stats *st2, struct stats *t
target->cpr_local_speed_checks = st1->cpr_local_speed_checks + st2->cpr_local_speed_checks; target->cpr_local_speed_checks = st1->cpr_local_speed_checks + st2->cpr_local_speed_checks;
target->cpr_filtered = st1->cpr_filtered + st2->cpr_filtered; target->cpr_filtered = st1->cpr_filtered + st2->cpr_filtered;
target->suppressed_altitude_messages = st1->suppressed_altitude_messages + st2->suppressed_altitude_messages;
// aircraft // aircraft
target->unique_aircraft = st1->unique_aircraft + st2->unique_aircraft; target->unique_aircraft = st1->unique_aircraft + st2->unique_aircraft;
target->single_message_aircraft = st1->single_message_aircraft + st2->single_message_aircraft; target->single_message_aircraft = st1->single_message_aircraft + st2->single_message_aircraft;

View file

@ -114,6 +114,10 @@ struct stats {
unsigned int cpr_local_receiver_relative; unsigned int cpr_local_receiver_relative;
unsigned int cpr_filtered; unsigned int cpr_filtered;
// number of altitude messages ignored because
// we had a recent DF17/18 altitude
unsigned int suppressed_altitude_messages;
// aircraft: // aircraft:
// total "new" aircraft (i.e. not seen in the last 30 or 300s) // total "new" aircraft (i.e. not seen in the last 30 or 300s)
unsigned int unique_aircraft; unsigned int unique_aircraft;

19
track.c
View file

@ -483,9 +483,22 @@ struct aircraft *trackUpdateFromMessage(struct modesMessage *mm)
a->modeCcount = 0; //....zero the hit count a->modeCcount = 0; //....zero the hit count
a->modeACflags &= ~MODEAC_MSG_MODEC_HIT; a->modeACflags &= ~MODEAC_MSG_MODEC_HIT;
} }
a->altitude = mm->altitude;
a->modeC = (mm->altitude + 49) / 100; // If we received an altitude in a DF17/18 squitter recently, ignore
a->seenAltitude = now; // DF0/4/16/20 altitudes as single-bit errors can attribute them to the wrong
// aircraft
if ((a->bFlags & MODES_ACFLAGS_ALTITUDE_VALID) &&
(now - a->seenAltitude) < 15000 &&
(a->bFlags & MODES_ACFLAGS_LATLON_VALID) &&
(now - a->seenLatLon) < 15000 &&
mm->msgtype != 17 &&
mm->msgtype != 18) {
Modes.stats_current.suppressed_altitude_messages++;
} else {
a->altitude = mm->altitude;
a->modeC = (mm->altitude + 49) / 100;
a->seenAltitude = now;
}
} }
// If a (new) SQUAWK has been received, copy it to the aircraft structure // If a (new) SQUAWK has been received, copy it to the aircraft structure