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_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_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_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_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_LLBOTH_VALID (MODES_ACFLAGS_LLEVEN_VALID | MODES_ACFLAGS_LLODD_VALID)
|
||||||
#define MODES_ACFLAGS_AOG_GROUND (MODES_ACFLAGS_AOG_VALID | MODES_ACFLAGS_AOG)
|
#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_DEMOD (1<<0)
|
||||||
#define MODES_DEBUG_DEMODERR (1<<1)
|
#define MODES_DEBUG_DEMODERR (1<<1)
|
||||||
#define MODES_DEBUG_BADCRC (1<<2)
|
#define MODES_DEBUG_BADCRC (1<<2)
|
||||||
|
|
|
@ -523,10 +523,10 @@ void interactiveShowData(void) {
|
||||||
|
|
||||||
if (Modes.interactive_rtl1090 == 0) {
|
if (Modes.interactive_rtl1090 == 0) {
|
||||||
printf (
|
printf (
|
||||||
"Hex Mode Sqwk Flight Alt Spd Hdg Lat Long RSSI Msgs Ti%c\n", progress);
|
" Hex Mode Sqwk Flight Alt Spd Hdg Lat Long RSSI Msgs Ti%c\n", progress);
|
||||||
} else {
|
} else {
|
||||||
printf (
|
printf (
|
||||||
"Hex Flight Alt V/S GS TT SSR G*456^ Msgs Seen %c\n", progress);
|
" Hex Flight Alt V/S GS TT SSR G*456^ Msgs Seen %c\n", progress);
|
||||||
}
|
}
|
||||||
printf(
|
printf(
|
||||||
"-------------------------------------------------------------------------------\n");
|
"-------------------------------------------------------------------------------\n");
|
||||||
|
@ -601,8 +601,8 @@ void interactiveShowData(void) {
|
||||||
snprintf(strFl, 6, "%5d", altitude);
|
snprintf(strFl, 6, "%5d", altitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%06X%s %-4s %-4s %-8s %5s %3s %3s %7s %8s %5.1f %5d %2d\n",
|
printf("%s%06X %-4s %-4s %-8s %5s %3s %3s %7s %8s %5.1f %5d %2d\n",
|
||||||
a->addr, (a->bFlags & MODES_ACFLAGS_NON_ICAO) ? "~" : " ",
|
(a->addr & MODES_NON_ICAO_ADDRESS) ? "~" : " ", (a->addr & 0xffffff),
|
||||||
strMode, strSquawk, a->flight, strFl, strGs, strTt,
|
strMode, strSquawk, a->flight, strFl, strGs, strTt,
|
||||||
strLat, strLon, 10 * log10(signalAverage), msgs, (int)(now - a->seen));
|
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[0] = (ModeA >> 8);
|
||||||
mm->msg[1] = (ModeA);
|
mm->msg[1] = (ModeA);
|
||||||
|
|
||||||
// Fudge an ICAO address based on Mode A (remove the Ident bit)
|
// Fudge an address based on Mode A (remove the Ident bit)
|
||||||
// Use an upper address byte of FF, since this is ICAO unallocated
|
mm->addr = (ModeA & 0x0000FF7F) | MODES_NON_ICAO_ADDRESS;
|
||||||
mm->addr = 0x00FF0000 | (ModeA & 0x0000FF7F);
|
|
||||||
|
|
||||||
// Set the Identity field to ModeA
|
// Set the Identity field to ModeA
|
||||||
mm->modeA = ModeA & 0x7777;
|
mm->modeA = ModeA & 0x7777;
|
||||||
mm->bFlags |= MODES_ACFLAGS_SQUAWK_VALID;
|
mm->bFlags |= MODES_ACFLAGS_SQUAWK_VALID;
|
||||||
mm->bFlags |= MODES_ACFLAGS_NON_ICAO;
|
|
||||||
|
|
||||||
// Flag ident in flight status
|
// Flag ident in flight status
|
||||||
mm->fs = ModeA & 0x0080;
|
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]);
|
mm->addr = (msg[1] << 16) | (msg[2] << 8) | (msg[3]);
|
||||||
|
|
||||||
if (mm->msgtype == 18 && (mm->cf != 0 && mm->cf != 6))
|
if (mm->msgtype == 18 && (mm->cf != 0 && mm->cf != 6))
|
||||||
mm->bFlags |= MODES_ACFLAGS_NON_ICAO; // DF 18 message not using ICAO addressing
|
mm->addr |= MODES_NON_ICAO_ADDRESS; // don't confuse this with any ICAO address
|
||||||
else if (!mm->correctedbits && (mm->msgtype != 11 || mm->iid == 0)) {
|
|
||||||
|
if (!mm->correctedbits && (mm->msgtype != 11 || mm->iid == 0)) {
|
||||||
// No CRC errors seen, and either it was an DF17/18 extended squitter
|
// 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.
|
// or a DF11 acquisition squitter with II = 0. We probably have the right address.
|
||||||
|
|
||||||
|
|
6
net_io.c
6
net_io.c
|
@ -749,7 +749,7 @@ char *generateAircraftJson(const char *url_path, int *len) {
|
||||||
else
|
else
|
||||||
*p++ = ',';
|
*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)
|
if (a->bFlags & MODES_ACFLAGS_SQUAWK_VALID)
|
||||||
p += snprintf(p, end-p, ",\"squawk\":\"%04x\"", a->modeA);
|
p += snprintf(p, end-p, ",\"squawk\":\"%04x\"", a->modeA);
|
||||||
if (a->bFlags & MODES_ACFLAGS_CALLSIGN_VALID)
|
if (a->bFlags & MODES_ACFLAGS_CALLSIGN_VALID)
|
||||||
|
@ -1311,14 +1311,14 @@ static void writeFATSV() {
|
||||||
char *p, *end;
|
char *p, *end;
|
||||||
|
|
||||||
// skip non-ICAO
|
// skip non-ICAO
|
||||||
if (a->bFlags & MODES_ACFLAGS_NON_ICAO)
|
if (a->addr & MODES_NON_ICAO_ADDRESS)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// don't emit if it hasn't updated since last time
|
// don't emit if it hasn't updated since last time
|
||||||
if (a->seen < a->fatsv_last_emitted) {
|
if (a->seen < a->fatsv_last_emitted) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
emittedSecondsAgo = (int)(now - a->fatsv_last_emitted);
|
emittedSecondsAgo = (int)(now - a->fatsv_last_emitted);
|
||||||
|
|
||||||
// don't emit more than once every five seconds
|
// don't emit more than once every five seconds
|
||||||
|
|
Loading…
Reference in a new issue