From b8fb5e5fe521dc0a8c702967b314eb1a96d7ab6f Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Thu, 2 May 2019 17:44:37 +0800 Subject: [PATCH] If there is no single best-scoring comm-b format, mark the message as ambiguous. This mostly affects TRACK_TURN messages on my test set. before: 127603 ACAS_RA 19173 EMPTY_RESPONSE 210286 HEADING_SPEED 223068 DATALINK_CAPS 243445 TRACK_TURN 271644 VERTICAL_INTENT 62905 UNKNOWN 7090 GICB_CAPS 76091 AIRCRAFT_IDENT 15973 "suspicious" after: 10667 AMBIGUOUS 127603 ACAS_RA 19173 EMPTY_RESPONSE 210286 HEADING_SPEED 223068 DATALINK_CAPS 232824 TRACK_TURN 271598 VERTICAL_INTENT 62905 UNKNOWN 7090 GICB_CAPS 76091 AIRCRAFT_IDENT 2258 "suspicious" --- comm_b.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/comm_b.c b/comm_b.c index 0820eff..a51e1e9 100644 --- a/comm_b.c +++ b/comm_b.c @@ -57,18 +57,26 @@ void decodeCommB(struct modesMessage *mm) // This is a bit hairy as we don't know what the requested register was int bestScore = 0; CommBDecoderFn bestDecoder = NULL; + int ambiguous = 0; for (unsigned i = 0; i < (sizeof(comm_b_decoders) / sizeof(comm_b_decoders[0])); ++i) { int score = comm_b_decoders[i](mm, false); if (score > bestScore) { bestScore = score; bestDecoder = comm_b_decoders[i]; + ambiguous = 0; + } else if (score == bestScore) { + ambiguous = 1; } } if (bestDecoder) { - // decode it - bestDecoder(mm, true); + if (ambiguous) { + mm->commb_format = COMMB_AMBIGUOUS; + } else { + // decode it + bestDecoder(mm, true); + } } }