Skip to content

Commit

Permalink
fix decoder and uncertainty issues (#146)
Browse files Browse the repository at this point in the history
* Created branch mods20230421a

* nic_v2 NIC return is set to None when a KeyError exception is raised

* process_raw receives additional return values from nuc_p, nic_v2, nuc_v, nac_v, nac_p .  hum44, p44, temp44, turb44, wind44, tk50, gs50, roc60baro, roc60ins, tc, and icao added to acs dictionary.

---------

Co-authored-by: Mike M <>
  • Loading branch information
gituser283 authored Aug 25, 2024
1 parent 08218f5 commit 74ea61f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
1 change: 1 addition & 0 deletions pyModeS/decoder/adsb.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ def nic_v2(msg: str, NICa: int, NICbc: int) -> tuple[int, int]:

Rc = uncertainty.NICv2[NIC][NICs]["Rc"]
except KeyError:
NIC = None
Rc = uncertainty.NA

return NIC, Rc # type: ignore
Expand Down
33 changes: 27 additions & 6 deletions pyModeS/streamer/decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,15 @@ def process_raw(self, adsb_ts, adsb_msg, commb_ts, commb_msg, tnow=None):
"VFOMr": None,
"PE_RCu": None,
"PE_VPL": None,
"hum44" : None,
"p44" : None,
"temp44" : None,
"turb44" : None,
"wind44" : None,
}

self.acs[icao]["tc"] = tc
self.acs[icao]["icao"] = icao
self.acs[icao]["t"] = t
self.acs[icao]["live"] = int(t)

Expand Down Expand Up @@ -155,7 +162,7 @@ def process_raw(self, adsb_ts, adsb_msg, commb_ts, commb_msg, tnow=None):
ac["nic_bc"] = pms.adsb.nic_b(msg)

if (5 <= tc <= 8) or (9 <= tc <= 18) or (20 <= tc <= 22):
ac["HPL"], ac["RCu"], ac["RCv"] = pms.adsb.nuc_p(msg)
ac["NUCp"], ac["HPL"], ac["RCu"], ac["RCv"] = pms.adsb.nuc_p(msg)

if (ac["ver"] == 1) and ("nic_s" in ac.keys()):
ac["Rc"], ac["VPL"] = pms.adsb.nic_v1(msg, ac["nic_s"])
Expand All @@ -164,20 +171,20 @@ def process_raw(self, adsb_ts, adsb_msg, commb_ts, commb_msg, tnow=None):
and ("nic_a" in ac.keys())
and ("nic_bc" in ac.keys())
):
ac["Rc"] = pms.adsb.nic_v2(msg, ac["nic_a"], ac["nic_bc"])
ac["NIC"], ac["Rc"] = pms.adsb.nic_v2(msg, ac["nic_a"], ac["nic_bc"])

if tc == 19:
ac["HVE"], ac["VVE"] = pms.adsb.nuc_v(msg)
ac["NUCv"], ac["HVE"], ac["VVE"] = pms.adsb.nuc_v(msg)
if ac["ver"] in [1, 2]:
ac["HFOMr"], ac["VFOMr"] = pms.adsb.nac_v(msg)
ac["NACv"], ac["HFOMr"], ac["VFOMr"] = pms.adsb.nac_v(msg)

if tc == 29:
ac["PE_RCu"], ac["PE_VPL"], ac["base"] = pms.adsb.sil(msg, ac["ver"])
ac["EPU"], ac["VEPU"] = pms.adsb.nac_p(msg)
ac["NACp"], ac["HEPU"], ac["VEPU"] = pms.adsb.nac_p(msg)

if tc == 31:
ac["ver"] = pms.adsb.version(msg)
ac["EPU"], ac["VEPU"] = pms.adsb.nac_p(msg)
ac["NACp"], ac["HEPU"], ac["VEPU"] = pms.adsb.nac_p(msg)
ac["PE_RCu"], ac["PE_VPL"], ac["sil_base"] = pms.adsb.sil(
msg, ac["ver"]
)
Expand All @@ -194,6 +201,8 @@ def process_raw(self, adsb_ts, adsb_msg, commb_ts, commb_msg, tnow=None):
if icao not in self.acs:
continue

self.acs[icao]["icao"] = icao
self.acs[icao]["t"] = t
self.acs[icao]["live"] = int(t)

bds = pms.bds.infer(msg)
Expand All @@ -217,8 +226,10 @@ def process_raw(self, adsb_ts, adsb_msg, commb_ts, commb_msg, tnow=None):
output_buffer.append([t, icao, "rtrk50", rtrk50])

if trk50:
self.acs[icao]["trk50"] = trk50
output_buffer.append([t, icao, "trk50", trk50])
if gs50:
self.acs[icao]["gs50"] = gs50
output_buffer.append([t, icao, "gs50", gs50])

elif bds == "BDS60":
Expand All @@ -241,10 +252,20 @@ def process_raw(self, adsb_ts, adsb_msg, commb_ts, commb_msg, tnow=None):
output_buffer.append([t, icao, "mach60", mach60])

if roc60baro:
self.acs[icao]["roc60baro"] = roc60baro
output_buffer.append([t, icao, "roc60baro", roc60baro])
if roc60ins:
self.acs[icao]["roc60ins"] = roc60ins
output_buffer.append([t, icao, "roc60ins", roc60ins])

elif bds == "BDS44":
if(pms.commb.is44(msg)):
self.acs[icao]["hum44"] = pms.commb.hum44(msg)
self.acs[icao]["p44"] = pms.commb.p44(msg)
self.acs[icao]["temp44"] = pms.commb.temp44(msg)
self.acs[icao]["turb44"] = pms.commb.turb44(msg)
self.acs[icao]["wind44"] = pms.commb.wind44(msg)

# clear up old data
for icao in list(self.acs.keys()):
if self.t - self.acs[icao]["live"] > self.cache_timeout:
Expand Down

0 comments on commit 74ea61f

Please sign in to comment.