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"
This commit is contained in:
parent
0306c7edfd
commit
b8fb5e5fe5
12
comm_b.c
12
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue