From 571ea7ac4118668fdf8fa57e8fc07f655398a99c Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Tue, 9 Jan 2018 14:46:33 +0000 Subject: [PATCH] Emit integrity info, when it changes. --- net_io.c | 28 +++++++++++++++++++++++++++- track.h | 13 ++++++++----- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/net_io.c b/net_io.c index a6be677..1568022 100644 --- a/net_io.c +++ b/net_io.c @@ -1991,6 +1991,16 @@ static const char *emergency_enum_string(emergency_t emergency) } } +static const char *sil_type_enum_string(sil_type_t type) +{ + switch (type) { + case SIL_UNKNOWN: return "unknown"; + case SIL_PER_HOUR: return "perhour"; + case SIL_PER_SAMPLE: return "persample"; + default: return "invalid"; + } +} + static void writeFATSVBanner() { char *p = prepareWrite(&Modes.fatsv_out, TSV_MAX_PACKET_SIZE); @@ -2130,6 +2140,18 @@ static void writeFATSV() if (forceEmit || a->category != a->fatsv_emitted_category) { p = appendFATSV(p, end, "category", "%02X", a->category); } + if (trackDataValid(&a->nac_p_valid) && (forceEmit || a->nac_p != a->fatsv_emitted_nac_p)) { + p = appendFATSVMeta(p, end, "nac_p", a, &a->nac_p_valid, "%u", a->nac_p); + } + if (trackDataValid(&a->nac_v_valid) && (forceEmit || a->nac_v != a->fatsv_emitted_nac_v)) { + p = appendFATSVMeta(p, end, "nac_v", a, &a->nac_v_valid, "%u", a->nac_v); + } + if (trackDataValid(&a->sil_valid) && (forceEmit || a->sil != a->fatsv_emitted_sil || a->sil_type != a->fatsv_emitted_sil_type)) { + p = appendFATSVMeta(p, end, "sil", a, &a->sil_valid, "{%u %s}", a->sil, sil_type_enum_string(a->sil_type)); + } + if (trackDataValid(&a->nic_baro_valid) && (forceEmit || a->nic_baro != a->fatsv_emitted_nic_baro)) { + p = appendFATSVMeta(p, end, "nic_baro", a, &a->nic_baro_valid, "%u", a->nic_baro); + } // only emit alt, speed, latlon, track etc if they have been received since the last time // and are not stale @@ -2147,7 +2169,6 @@ static void writeFATSV() p = appendFATSVMeta(p, end, "alt", a, &a->altitude_baro_valid, "%d", a->altitude_baro); if (positionValid) { p = appendFATSVMeta(p, end, "position", a, &a->position_valid, "{%.5f %.5f %u %u}", a->lat, a->lon, a->pos_nic, a->pos_rc); - p = appendFATSVMeta(p, end, "nac_p", a, &a->nac_p_valid, "%u", a->nac_p); } p = appendFATSVMeta(p, end, "alt_gnss", a, &a->altitude_geom_valid, "%d", a->altitude_geom); @@ -2205,6 +2226,11 @@ static void writeFATSV() a->fatsv_emitted_adsb_version = a->adsb_version; a->fatsv_emitted_category = a->category; a->fatsv_emitted_squawk = a->squawk; + a->fatsv_emitted_nac_p = a->nac_p; + a->fatsv_emitted_nac_v = a->nac_v; + a->fatsv_emitted_sil = a->sil; + a->fatsv_emitted_sil_type = a->sil_type; + a->fatsv_emitted_nic_baro = a->nic_baro; a->fatsv_last_emitted = now; if (forceEmit) { a->fatsv_last_force_emit = now; diff --git a/track.h b/track.h index 40323d4..3d7475c 100644 --- a/track.h +++ b/track.h @@ -197,11 +197,9 @@ struct aircraft { unsigned nic_c : 1; // NIC supplement C from opstatus unsigned nic_baro : 1; // NIC baro supplement from TSS or opstatus unsigned nac_p : 4; // NACp from TSS or opstatus - unsigned nac_v : 3; // NACv from opstatus - unsigned sil : 2; // SIL from TS or opstatus - sil_type_t sil_type; // SIL supplement from TS or opstatus - unsigned gva : 2; // GVA from opstatus - unsigned sda : 2; // SDA from opstatus + unsigned nac_v : 3; // NACv from airborne velocity or opstatus + unsigned sil : 2; // SIL from TSS or opstatus + sil_type_t sil_type; // SIL supplement from TSS or opstatus int modeA_hit; // did our squawk match a possible mode A reply in the last check period? int modeC_hit; // did our altitude match a possible mode C reply in the last check period? @@ -233,6 +231,11 @@ struct aircraft { int fatsv_emitted_adsb_version; // -"- ADS-B version (assumed non-ADS-B initially) unsigned fatsv_emitted_category; // -"- ADS-B emitter category (assumed A0 initially) unsigned fatsv_emitted_squawk; // -"- squawk + unsigned fatsv_emitted_nac_p; // -"- NACp + unsigned fatsv_emitted_nac_v; // -"- NACv + unsigned fatsv_emitted_sil; // -"- SIL + sil_type_t fatsv_emitted_sil_type; // -"- SIL supplement + unsigned fatsv_emitted_nic_baro; // -"- NICbaro uint64_t fatsv_last_emitted; // time (millis) aircraft was last FA emitted uint64_t fatsv_last_force_emit; // time (millis) we last emitted only-on-change data