From 98a55c8dec884fccad0b0143a5388c1b70873f23 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Mon, 29 Jun 2015 12:43:58 +0100 Subject: [PATCH] Tweak CPR rules for mlat messages, add some debug. --- track.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/track.c b/track.c index b7b11d5..d1bdffb 100644 --- a/track.c +++ b/track.c @@ -239,7 +239,21 @@ static int doGlobalCPR(struct aircraft *a, struct modesMessage *mm, uint64_t now lat, lon); } - if (result < 0) + if (result < 0) { +#ifdef DEBUG_CPR_CHECKS + if (mm->bFlags & MODES_ACFLAGS_FROM_MLAT) { + fprintf(stderr, "CPR: decode failure from MLAT (%06X) (%d).\n", a->addr, result); + fprintf(stderr, " even: %d %d odd: %d %d fflag: %s\n", + a->even_cprlat, a->even_cprlon, + a->odd_cprlat, a->odd_cprlon, + fflag ? "odd" : "even"); + } +#endif + return result; + } + + // for mlat results, accept it unquestioningly + if (mm->bFlags & MODES_ACFLAGS_FROM_MLAT) return result; // check max range @@ -375,6 +389,11 @@ static void updatePosition(struct aircraft *a, struct modesMessage *mm, uint64_t location_result = doGlobalCPR(a, mm, now, &new_lat, &new_lon, &new_nuc); if (location_result == -2) { +#ifdef DEBUG_CPR_CHECKS + if (mm->bFlags & MODES_ACFLAGS_FROM_MLAT) { + fprintf(stderr, "CPR failure from MLAT (%06X).\n", a->addr); + } +#endif // Global CPR failed because the position produced implausible results. // This is bad data. Discard both odd and even messages and wait for a fresh pair. // Also disable aircraft-relative positions until we have a new good position (but don't discard the @@ -394,6 +413,11 @@ static void updatePosition(struct aircraft *a, struct modesMessage *mm, uint64_t MODES_ACFLAGS_AOG); return; } else if (location_result == -1) { +#ifdef DEBUG_CPR_CHECKS + if (mm->bFlags & MODES_ACFLAGS_FROM_MLAT) { + fprintf(stderr, "CPR skipped from MLAT (%06X).\n", a->addr); + } +#endif // No local reference for surface position available, or the two messages crossed a zone. // Nonfatal, try again later. Modes.stats_current.cpr_global_skipped++;