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

19
track.c
View file

@ -483,9 +483,22 @@ struct aircraft *trackUpdateFromMessage(struct modesMessage *mm)
a->modeCcount = 0; //....zero the hit count
a->modeACflags &= ~MODEAC_MSG_MODEC_HIT;
}
a->altitude = mm->altitude;
a->modeC = (mm->altitude + 49) / 100;
a->seenAltitude = now;
// If we received an altitude in a DF17/18 squitter recently, ignore
// 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