SIL stuff

This commit is contained in:
Oliver Jowett 2017-12-07 13:36:07 -06:00
parent 161d2d8ded
commit 079061df3c
3 changed files with 37 additions and 15 deletions

View file

@ -178,7 +178,7 @@ typedef enum {
} airground_t; } airground_t;
typedef enum { typedef enum {
SIL_INVALID, SIL_PER_SAMPLE, SIL_PER_HOUR SIL_INVALID, SIL_UNKNOWN, SIL_PER_SAMPLE, SIL_PER_HOUR
} sil_type_t; } sil_type_t;
typedef enum { typedef enum {
@ -509,7 +509,6 @@ struct modesMessage {
unsigned nic_baro_valid : 1; unsigned nic_baro_valid : 1;
unsigned nac_p_valid : 1; unsigned nac_p_valid : 1;
unsigned nac_v_valid : 1; unsigned nac_v_valid : 1;
unsigned sil_valid : 1;
unsigned gva_valid : 1; unsigned gva_valid : 1;
unsigned sda_valid : 1; unsigned sda_valid : 1;
@ -521,8 +520,8 @@ struct modesMessage {
unsigned nac_p : 4; // if nac_p_valid unsigned nac_p : 4; // if nac_p_valid
unsigned nac_v : 3; // if nac_v_valid unsigned nac_v : 3; // if nac_v_valid
unsigned sil : 2; // if sil_valid unsigned sil : 2; // if sil_type != SIL_INVALID
sil_type_t sil_type; // if sil_valid sil_type_t sil_type;
unsigned gva : 2; // if gva_valid unsigned gva : 2; // if gva_valid

View file

@ -1103,9 +1103,8 @@ static void decodeESTargetStatus(struct modesMessage *mm, int check_imf)
mm->accuracy.nic_baro = getbit(me, 44); mm->accuracy.nic_baro = getbit(me, 44);
// 45-46: SIL // 45-46: SIL
mm->accuracy.sil_valid = 1;
mm->accuracy.sil = getbits(me, 45, 46); mm->accuracy.sil = getbits(me, 45, 46);
mm->accuracy.sil_type = SIL_INVALID; mm->accuracy.sil_type = SIL_UNKNOWN;
// 47-51: reserved // 47-51: reserved
@ -1170,9 +1169,8 @@ static void decodeESTargetStatus(struct modesMessage *mm, int check_imf)
mm->accuracy.nic_baro = getbit(me, 44); mm->accuracy.nic_baro = getbit(me, 44);
// 45-46: SIL // 45-46: SIL
mm->accuracy.sil_valid = 1;
mm->accuracy.sil = getbits(me, 45, 46); mm->accuracy.sil = getbits(me, 45, 46);
mm->accuracy.sil_type = SIL_INVALID; mm->accuracy.sil_type = SIL_UNKNOWN;
// 47: mode bits validity // 47: mode bits validity
if (getbit(me, 47)) { if (getbit(me, 47)) {
@ -1241,7 +1239,7 @@ static void decodeESOperationalStatus(struct modesMessage *mm, int check_imf)
mm->accuracy.nic_a = getbit(me, 44); mm->accuracy.nic_a = getbit(me, 44);
mm->accuracy.nac_p_valid = 1; mm->accuracy.nac_p_valid = 1;
mm->accuracy.nac_p = getbits(me, 45, 48); mm->accuracy.nac_p = getbits(me, 45, 48);
mm->accuracy.sil_valid = 1; mm->accuracy.sil_type = SIL_UNKNOWN;
mm->accuracy.sil = getbits(me, 51, 52); mm->accuracy.sil = getbits(me, 51, 52);
mm->opstatus.hrd = getbit(me, 54) ? HEADING_MAGNETIC : HEADING_TRUE; mm->opstatus.hrd = getbit(me, 54) ? HEADING_MAGNETIC : HEADING_TRUE;
@ -1291,7 +1289,6 @@ static void decodeESOperationalStatus(struct modesMessage *mm, int check_imf)
mm->accuracy.nic_a = getbit(me, 44); mm->accuracy.nic_a = getbit(me, 44);
mm->accuracy.nac_p_valid = 1; mm->accuracy.nac_p_valid = 1;
mm->accuracy.nac_p = getbits(me, 45, 48); mm->accuracy.nac_p = getbits(me, 45, 48);
mm->accuracy.sil_valid = 1;
mm->accuracy.sil = getbits(me, 51, 52); mm->accuracy.sil = getbits(me, 51, 52);
mm->accuracy.sil_type = getbit(me, 55) ? SIL_PER_SAMPLE : SIL_PER_HOUR; mm->accuracy.sil_type = getbit(me, 55) ? SIL_PER_SAMPLE : SIL_PER_HOUR;
mm->opstatus.hrd = getbit(me, 54) ? HEADING_MAGNETIC : HEADING_TRUE; mm->opstatus.hrd = getbit(me, 54) ? HEADING_MAGNETIC : HEADING_TRUE;
@ -1583,6 +1580,16 @@ static const char *nav_modes_to_string(nav_modes_t flags)
return buf; return buf;
} }
static const char *sil_type_to_string(sil_type_t type)
{
switch (type) {
case SIL_UNKNOWN: return "unknown type";
case SIL_PER_HOUR: return "per flight hour";
case SIL_PER_SAMPLE: return "per sample";
default: return "invalid type";
}
}
static void print_hex_bytes(unsigned char *data, size_t len) { static void print_hex_bytes(unsigned char *data, size_t len) {
size_t i; size_t i;
for (i = 0; i < len; ++i) { for (i = 0; i < len; ++i) {
@ -1959,10 +1966,26 @@ void displayModesMessage(struct modesMessage *mm) {
if (mm->accuracy.gva_valid) { if (mm->accuracy.gva_valid) {
printf(" GVA: %d\n", mm->accuracy.gva); printf(" GVA: %d\n", mm->accuracy.gva);
} }
if (mm->accuracy.sil_valid) { if (mm->accuracy.sil_type != SIL_INVALID) {
printf(" SIL: %d (%s)\n", const char *sil_description;
switch (mm->accuracy.sil) {
case 1:
sil_description = "p <= 0.1%";
break;
case 2:
sil_description = "p <= 0.001%";
break;
case 3:
sil_description = "p <= 0.00001%";
break;
default:
sil_description = "p > 0.1%";
break;
}
printf(" SIL: %d (%s, %s)\n",
mm->accuracy.sil, mm->accuracy.sil,
(mm->accuracy.sil_type == SIL_PER_HOUR ? "per hour" : "per sample")); sil_description,
sil_type_to_string(mm->accuracy.sil_type));
} }
if (mm->accuracy.sda_valid) { if (mm->accuracy.sda_valid) {
printf(" SDA: %d\n", mm->accuracy.sda); printf(" SDA: %d\n", mm->accuracy.sda);

View file

@ -1000,9 +1000,9 @@ struct aircraft *trackUpdateFromMessage(struct modesMessage *mm)
a->nac_v = mm->accuracy.nac_v; a->nac_v = mm->accuracy.nac_v;
} }
if (mm->accuracy.sil_valid && accept_data(&a->sil_valid, mm->source)) { if (mm->accuracy.sil_type != SIL_INVALID && accept_data(&a->sil_valid, mm->source)) {
a->sil = mm->accuracy.sil; a->sil = mm->accuracy.sil;
if (mm->accuracy.sil_type != SIL_INVALID) { if (a->sil_type == SIL_INVALID || mm->accuracy.sil_type != SIL_UNKNOWN) {
a->sil_type = mm->accuracy.sil_type; a->sil_type = mm->accuracy.sil_type;
} }
} }