diff --git a/mode_s.c b/mode_s.c index 4093cc3..5c35962 100644 --- a/mode_s.c +++ b/mode_s.c @@ -716,10 +716,18 @@ static void decodeESIdentAndCategory(struct modesMessage *mm) mm->callsign[6] = ais_charset[getbits(me, 45, 50)]; mm->callsign[7] = ais_charset[getbits(me, 51, 56)]; mm->callsign[8] = 0; + mm->callsign_valid = 1; - // A common failure mode seems to be to intermittently send - // all zeros. Catch that here. - mm->callsign_valid = (strcmp(mm->callsign, "@@@@@@@@") != 0); + // actually valid? + for (unsigned i = 0; i < 8; ++i) { + if (!(mm->callsign[i] >= 'A' && mm->callsign[i] <= 'Z') && + !(mm->callsign[i] >= '0' && mm->callsign[i] <= '9') && + mm->callsign[i] != ' ') { + // Bad callsign, ignore it + mm->callsign_valid = 0; + break; + } + } mm->category = ((0x0E - mm->metype) << 4) | mm->mesub; mm->category_valid = 1;