Changed my mind, put the non-ICAO flag bit in the address itself
since we have 8 bits spare, so there's no chance of confusing it with an ICAO address, and we can safely use the filter table to match future messages without also matching equivalent ICAO addresses.
This commit is contained in:
parent
35551b4455
commit
ada188a1c8
|
@ -164,12 +164,13 @@
|
|||
#define MODES_ACFLAGS_NSEWSPD_VALID (1<<14) // Aircraft EW and NS Speed is known
|
||||
#define MODES_ACFLAGS_LATLON_REL_OK (1<<15) // Indicates it's OK to do a relative CPR
|
||||
#define MODES_ACFLAGS_REL_CPR_USED (1<<16) // Lat/lon derived from relative CPR
|
||||
#define MODES_ACFLAGS_NON_ICAO (1<<17) // Address is not ICAO-format
|
||||
|
||||
#define MODES_ACFLAGS_LLEITHER_VALID (MODES_ACFLAGS_LLEVEN_VALID | MODES_ACFLAGS_LLODD_VALID)
|
||||
#define MODES_ACFLAGS_LLBOTH_VALID (MODES_ACFLAGS_LLEVEN_VALID | MODES_ACFLAGS_LLODD_VALID)
|
||||
#define MODES_ACFLAGS_AOG_GROUND (MODES_ACFLAGS_AOG_VALID | MODES_ACFLAGS_AOG)
|
||||
|
||||
#define MODES_NON_ICAO_ADDRESS (1<<24) // Set on addresses to indicate they are not ICAO addresses
|
||||
|
||||
#define MODES_DEBUG_DEMOD (1<<0)
|
||||
#define MODES_DEBUG_DEMODERR (1<<1)
|
||||
#define MODES_DEBUG_BADCRC (1<<2)
|
||||
|
|
|
@ -601,8 +601,8 @@ void interactiveShowData(void) {
|
|||
snprintf(strFl, 6, "%5d", altitude);
|
||||
}
|
||||
|
||||
printf("%06X%s %-4s %-4s %-8s %5s %3s %3s %7s %8s %5.1f %5d %2d\n",
|
||||
a->addr, (a->bFlags & MODES_ACFLAGS_NON_ICAO) ? "~" : " ",
|
||||
printf("%s%06X %-4s %-4s %-8s %5s %3s %3s %7s %8s %5.1f %5d %2d\n",
|
||||
(a->addr & MODES_NON_ICAO_ADDRESS) ? "~" : " ", (a->addr & 0xffffff),
|
||||
strMode, strSquawk, a->flight, strFl, strGs, strTt,
|
||||
strLat, strLon, 10 * log10(signalAverage), msgs, (int)(now - a->seen));
|
||||
}
|
||||
|
|
|
@ -364,14 +364,12 @@ void decodeModeAMessage(struct modesMessage *mm, int ModeA)
|
|||
mm->msg[0] = (ModeA >> 8);
|
||||
mm->msg[1] = (ModeA);
|
||||
|
||||
// Fudge an ICAO address based on Mode A (remove the Ident bit)
|
||||
// Use an upper address byte of FF, since this is ICAO unallocated
|
||||
mm->addr = 0x00FF0000 | (ModeA & 0x0000FF7F);
|
||||
// Fudge an address based on Mode A (remove the Ident bit)
|
||||
mm->addr = (ModeA & 0x0000FF7F) | MODES_NON_ICAO_ADDRESS;
|
||||
|
||||
// Set the Identity field to ModeA
|
||||
mm->modeA = ModeA & 0x7777;
|
||||
mm->bFlags |= MODES_ACFLAGS_SQUAWK_VALID;
|
||||
mm->bFlags |= MODES_ACFLAGS_NON_ICAO;
|
||||
|
||||
// Flag ident in flight status
|
||||
mm->fs = ModeA & 0x0080;
|
||||
|
|
5
mode_s.c
5
mode_s.c
|
@ -545,8 +545,9 @@ int decodeModesMessage(struct modesMessage *mm, unsigned char *msg)
|
|||
mm->addr = (msg[1] << 16) | (msg[2] << 8) | (msg[3]);
|
||||
|
||||
if (mm->msgtype == 18 && (mm->cf != 0 && mm->cf != 6))
|
||||
mm->bFlags |= MODES_ACFLAGS_NON_ICAO; // DF 18 message not using ICAO addressing
|
||||
else if (!mm->correctedbits && (mm->msgtype != 11 || mm->iid == 0)) {
|
||||
mm->addr |= MODES_NON_ICAO_ADDRESS; // don't confuse this with any ICAO address
|
||||
|
||||
if (!mm->correctedbits && (mm->msgtype != 11 || mm->iid == 0)) {
|
||||
// No CRC errors seen, and either it was an DF17/18 extended squitter
|
||||
// or a DF11 acquisition squitter with II = 0. We probably have the right address.
|
||||
|
||||
|
|
4
net_io.c
4
net_io.c
|
@ -749,7 +749,7 @@ char *generateAircraftJson(const char *url_path, int *len) {
|
|||
else
|
||||
*p++ = ',';
|
||||
|
||||
p += snprintf(p, end-p, "\n {\"hex\":\"%06x%s\"", a->addr, (a->bFlags & MODES_ACFLAGS_NON_ICAO) ? "~" : "");
|
||||
p += snprintf(p, end-p, "\n {\"hex\":\"%s%06x\"", (a->addr & MODES_NON_ICAO_ADDRESS) ? "~" : "", a->addr & 0xFFFFFF);
|
||||
if (a->bFlags & MODES_ACFLAGS_SQUAWK_VALID)
|
||||
p += snprintf(p, end-p, ",\"squawk\":\"%04x\"", a->modeA);
|
||||
if (a->bFlags & MODES_ACFLAGS_CALLSIGN_VALID)
|
||||
|
@ -1311,7 +1311,7 @@ static void writeFATSV() {
|
|||
char *p, *end;
|
||||
|
||||
// skip non-ICAO
|
||||
if (a->bFlags & MODES_ACFLAGS_NON_ICAO)
|
||||
if (a->addr & MODES_NON_ICAO_ADDRESS)
|
||||
continue;
|
||||
|
||||
// don't emit if it hasn't updated since last time
|
||||
|
|
Loading…
Reference in a new issue