Allow comm-b aircraft-ident messages containing @, but don't actually use the callsign.

before:
  62905 UNKNOWN
  76091 AIRCRAFT_IDENT

after:
  62527 UNKNOWN
  76469 AIRCRAFT_IDENT
This commit is contained in:
Oliver Jowett 2019-05-02 17:51:46 +08:00
parent b8fb5e5fe5
commit 27f41c178f

View file

@ -221,13 +221,15 @@ static int decodeBDS20(struct modesMessage *mm, bool store)
callsign[7] = ais_charset[getbits(msg, 51, 56)]; callsign[7] = ais_charset[getbits(msg, 51, 56)];
callsign[8] = 0; callsign[8] = 0;
// score based on number of valid non-space characters // score based on number of valid characters
int score = 8; int score = 8;
int valid = 1;
for (unsigned i = 0; i < 8; ++i) { for (unsigned i = 0; i < 8; ++i) {
if ((callsign[i] >= 'A' && callsign[i] <= 'Z') || (callsign[i] >= '0' && callsign[i] <= '9')) { if ((callsign[i] >= 'A' && callsign[i] <= 'Z') || (callsign[i] >= '0' && callsign[i] <= '9') || callsign[i] == ' ') {
score += 6; score += 6;
} else if (callsign[i] == ' ') { } else if (callsign[i] == '@') {
// Valid, but not informative // Padding (sometimes we get @@@@@@@@, i.e. BDS2,0 with all zeros - we do want to accept this as a BDS2,0 but not actually use the callsign)
valid = 0;
} else { } else {
// Invalid // Invalid
return 0; return 0;
@ -236,9 +238,11 @@ static int decodeBDS20(struct modesMessage *mm, bool store)
if (store) { if (store) {
mm->commb_format = COMMB_AIRCRAFT_IDENT; mm->commb_format = COMMB_AIRCRAFT_IDENT;
if (valid) {
memcpy(mm->callsign, callsign, sizeof(mm->callsign)); memcpy(mm->callsign, callsign, sizeof(mm->callsign));
mm->callsign_valid = 1; mm->callsign_valid = 1;
} }
}
return score; return score;
} }