Track HAE altitude separately to baro altitude where possible.
This commit is contained in:
parent
c4a2a5c9fb
commit
efd6b94310
|
@ -163,6 +163,8 @@ typedef struct rtlsdr_dev rtlsdr_dev_t;
|
||||||
#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_CATEGORY_VALID (1<<17) // Aircraft category is known
|
#define MODES_ACFLAGS_CATEGORY_VALID (1<<17) // Aircraft category is known
|
||||||
#define MODES_ACFLAGS_FROM_MLAT (1<<18) // Data was derived from multilateration
|
#define MODES_ACFLAGS_FROM_MLAT (1<<18) // Data was derived from multilateration
|
||||||
|
#define MODES_ACFLAGS_ALTITUDE_HAE_VALID (1<<19) // altitude_hae is valid
|
||||||
|
#define MODES_ACFLAGS_HAE_DELTA_VALID (1<<20) // hae_delta is valid
|
||||||
|
|
||||||
#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)
|
||||||
|
@ -389,6 +391,8 @@ struct modesMessage {
|
||||||
int vert_rate; // Vertical rate.
|
int vert_rate; // Vertical rate.
|
||||||
int velocity; // Reported by aircraft, or computed from from EW and NS velocity
|
int velocity; // Reported by aircraft, or computed from from EW and NS velocity
|
||||||
unsigned category; // A0 - D7 encoded as a single hex byte
|
unsigned category; // A0 - D7 encoded as a single hex byte
|
||||||
|
int altitude_hae; // altitude reported as GNSS HAE
|
||||||
|
int hae_delta; // difference between HAE and baro alt
|
||||||
|
|
||||||
// DF 18
|
// DF 18
|
||||||
int cf; // Control Field
|
int cf; // Control Field
|
||||||
|
|
27
mode_s.c
27
mode_s.c
|
@ -846,6 +846,11 @@ static void decodeExtendedSquitter(struct modesMessage *mm)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (msg[10] != 0) {
|
||||||
|
mm->bFlags |= MODES_ACFLAGS_HAE_DELTA_VALID;
|
||||||
|
mm->hae_delta = ((msg[10] & 0x80) ? -25 : 25) * ((msg[10] & 0x7f) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -910,10 +915,19 @@ static void decodeExtendedSquitter(struct modesMessage *mm)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AC12Field) {// Only attempt to decode if a valid (non zero) altitude is present
|
if (AC12Field) {// Only attempt to decode if a valid (non zero) altitude is present
|
||||||
|
if (metype == 20 || metype == 21 || metype == 22) {
|
||||||
|
// Position reported as HAE
|
||||||
|
mm->altitude_hae = decodeAC12Field(AC12Field, &mm->unit);
|
||||||
|
if (mm->altitude_hae != INVALID_ALTITUDE) {
|
||||||
|
mm->bFlags |= MODES_ACFLAGS_ALTITUDE_HAE_VALID;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
mm->altitude = decodeAC12Field(AC12Field, &mm->unit);
|
mm->altitude = decodeAC12Field(AC12Field, &mm->unit);
|
||||||
if (mm->altitude != INVALID_ALTITUDE)
|
if (mm->altitude != INVALID_ALTITUDE) {
|
||||||
mm->bFlags |= MODES_ACFLAGS_ALTITUDE_VALID;
|
mm->bFlags |= MODES_ACFLAGS_ALTITUDE_VALID;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (metype == 0 || metype == 18 || metype == 22)
|
if (metype == 0 || metype == 18 || metype == 22)
|
||||||
mm->nuc_p = 0;
|
mm->nuc_p = 0;
|
||||||
|
@ -1011,15 +1025,22 @@ static void displayExtendedSquitter(struct modesMessage *mm) {
|
||||||
printf(" Vertical status : %s\n", (mm->bFlags & MODES_ACFLAGS_VERTRATE_VALID) ? "Valid" : "Unavailable");
|
printf(" Vertical status : %s\n", (mm->bFlags & MODES_ACFLAGS_VERTRATE_VALID) ? "Valid" : "Unavailable");
|
||||||
printf(" Vertical rate src : %d\n", ((mm->msg[8] >> 4) & 1));
|
printf(" Vertical rate src : %d\n", ((mm->msg[8] >> 4) & 1));
|
||||||
printf(" Vertical rate : %d\n", mm->vert_rate);
|
printf(" Vertical rate : %d\n", mm->vert_rate);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
printf(" Unrecognized ME subtype: %d subtype: %d\n", mm->metype, mm->mesub);
|
printf(" Unrecognized ME subtype: %d subtype: %d\n", mm->metype, mm->mesub);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mm->bFlags & MODES_ACFLAGS_HAE_DELTA_VALID) {
|
||||||
|
printf(" HAE - Barometric : %d ft\n", mm->hae_delta);
|
||||||
|
} else {
|
||||||
|
printf(" HAE - Barometric : not valid\n");
|
||||||
|
}
|
||||||
} else if (mm->metype >= 5 && mm->metype <= 22) { // Airborne position Baro
|
} else if (mm->metype >= 5 && mm->metype <= 22) { // Airborne position Baro
|
||||||
printf(" F flag : %s\n", (mm->msg[6] & 0x04) ? "odd" : "even");
|
printf(" F flag : %s\n", (mm->msg[6] & 0x04) ? "odd" : "even");
|
||||||
printf(" T flag : %s\n", (mm->msg[6] & 0x08) ? "UTC" : "non-UTC");
|
printf(" T flag : %s\n", (mm->msg[6] & 0x08) ? "UTC" : "non-UTC");
|
||||||
if (mm->bFlags & MODES_ACFLAGS_ALTITUDE_VALID)
|
if (mm->bFlags & MODES_ACFLAGS_ALTITUDE_VALID)
|
||||||
printf(" Altitude : %d feet\n", mm->altitude);
|
printf(" Altitude : %d feet barometric\n", mm->altitude);
|
||||||
|
else if (mm->bFlags & MODES_ACFLAGS_ALTITUDE_HAE_VALID)
|
||||||
|
printf(" Altitude : %d feet HAE\n", mm->altitude_hae);
|
||||||
else
|
else
|
||||||
printf(" Altitude : not valid\n");
|
printf(" Altitude : not valid\n");
|
||||||
if (mm->bFlags & MODES_ACFLAGS_LATLON_VALID) {
|
if (mm->bFlags & MODES_ACFLAGS_LATLON_VALID) {
|
||||||
|
|
31
track.c
31
track.c
|
@ -522,9 +522,34 @@ struct aircraft *trackUpdateFromMessage(struct modesMessage *mm)
|
||||||
a->altitude = mm->altitude;
|
a->altitude = mm->altitude;
|
||||||
a->modeC = (mm->altitude + 49) / 100;
|
a->modeC = (mm->altitude + 49) / 100;
|
||||||
a->seenAltitude = now;
|
a->seenAltitude = now;
|
||||||
|
|
||||||
|
// reporting of HAE and baro altitudes is mutually exclusive
|
||||||
|
// so if we see a baro altitude, assume the HAE altitude is invalid
|
||||||
|
// we will recalculate it from baro + HAE delta below, where possible
|
||||||
|
a->bFlags &= ~MODES_ACFLAGS_ALTITUDE_HAE_VALID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If a (new) HAE altitude has been received, copy it to the aircraft structure
|
||||||
|
if (mm->bFlags & MODES_ACFLAGS_ALTITUDE_HAE_VALID) {
|
||||||
|
a->altitude_hae = mm->altitude_hae;
|
||||||
|
|
||||||
|
// reporting of HAE and baro altitudes is mutually exclusive
|
||||||
|
// if you have both, you're meant to report baro and a HAE delta,
|
||||||
|
// so if we see explicit HAE then assume the delta is invalid too
|
||||||
|
a->bFlags &= ~(MODES_ACFLAGS_ALTITUDE_VALID | MODES_ACFLAGS_HAE_DELTA_VALID);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If a (new) HAE/barometric difference has been received, copy it to the aircraft structure
|
||||||
|
if (mm->bFlags & MODES_ACFLAGS_HAE_DELTA_VALID) {
|
||||||
|
a->hae_delta = mm->hae_delta;
|
||||||
|
|
||||||
|
// reporting of HAE and baro altitudes is mutually exclusive
|
||||||
|
// if you have both, you're meant to report baro and a HAE delta,
|
||||||
|
// so if we see a HAE delta then assume the HAE altitude is invalid
|
||||||
|
a->bFlags &= ~MODES_ACFLAGS_ALTITUDE_HAE_VALID;
|
||||||
|
}
|
||||||
|
|
||||||
// If a (new) SQUAWK has been received, copy it to the aircraft structure
|
// If a (new) SQUAWK has been received, copy it to the aircraft structure
|
||||||
if (mm->bFlags & MODES_ACFLAGS_SQUAWK_VALID) {
|
if (mm->bFlags & MODES_ACFLAGS_SQUAWK_VALID) {
|
||||||
if (a->modeA != mm->modeA) {
|
if (a->modeA != mm->modeA) {
|
||||||
|
@ -559,6 +584,12 @@ struct aircraft *trackUpdateFromMessage(struct modesMessage *mm)
|
||||||
// Update the aircrafts a->bFlags to reflect the newly received mm->bFlags;
|
// Update the aircrafts a->bFlags to reflect the newly received mm->bFlags;
|
||||||
a->bFlags |= mm->bFlags;
|
a->bFlags |= mm->bFlags;
|
||||||
|
|
||||||
|
// If we have a baro altitude and a HAE delta from baro, calculate the HAE altitude
|
||||||
|
if ((a->bFlags & MODES_ACFLAGS_ALTITUDE_VALID) && (a->bFlags & MODES_ACFLAGS_HAE_DELTA_VALID)) {
|
||||||
|
a->altitude_hae = a->altitude + a->hae_delta;
|
||||||
|
a->bFlags |= MODES_ACFLAGS_ALTITUDE_HAE_VALID;
|
||||||
|
}
|
||||||
|
|
||||||
// Update mlat flags. The mlat flags indicate which bits in bFlags
|
// Update mlat flags. The mlat flags indicate which bits in bFlags
|
||||||
// were last set based on a mlat-derived message.
|
// were last set based on a mlat-derived message.
|
||||||
if (mm->bFlags & MODES_ACFLAGS_FROM_MLAT)
|
if (mm->bFlags & MODES_ACFLAGS_FROM_MLAT)
|
||||||
|
|
4
track.h
4
track.h
|
@ -64,7 +64,9 @@ struct aircraft {
|
||||||
uint32_t addr; // ICAO address
|
uint32_t addr; // ICAO address
|
||||||
char flight[16]; // Flight number
|
char flight[16]; // Flight number
|
||||||
double signalLevel[8]; // Last 8 Signal Amplitudes
|
double signalLevel[8]; // Last 8 Signal Amplitudes
|
||||||
int altitude; // Altitude
|
int altitude; // Altitude (Baro)
|
||||||
|
int altitude_hae; // Altitude (HAE)
|
||||||
|
int hae_delta; // Difference between HAE and Baro altitudes
|
||||||
int speed; // Velocity
|
int speed; // Velocity
|
||||||
int track; // Angle of flight
|
int track; // Angle of flight
|
||||||
int vert_rate; // Vertical rate.
|
int vert_rate; // Vertical rate.
|
||||||
|
|
Loading…
Reference in a new issue