Skip to content

Commit 74ea61f

Browse files
authored
fix decoder and uncertainty issues (#146)
* 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 <>
1 parent 08218f5 commit 74ea61f

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

pyModeS/decoder/adsb.py

+1
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ def nic_v2(msg: str, NICa: int, NICbc: int) -> tuple[int, int]:
459459

460460
Rc = uncertainty.NICv2[NIC][NICs]["Rc"]
461461
except KeyError:
462+
NIC = None
462463
Rc = uncertainty.NA
463464

464465
return NIC, Rc # type: ignore

pyModeS/streamer/decode.py

+27-6
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,15 @@ def process_raw(self, adsb_ts, adsb_msg, commb_ts, commb_msg, tnow=None):
7373
"VFOMr": None,
7474
"PE_RCu": None,
7575
"PE_VPL": None,
76+
"hum44" : None,
77+
"p44" : None,
78+
"temp44" : None,
79+
"turb44" : None,
80+
"wind44" : None,
7681
}
7782

83+
self.acs[icao]["tc"] = tc
84+
self.acs[icao]["icao"] = icao
7885
self.acs[icao]["t"] = t
7986
self.acs[icao]["live"] = int(t)
8087

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

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

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

169176
if tc == 19:
170-
ac["HVE"], ac["VVE"] = pms.adsb.nuc_v(msg)
177+
ac["NUCv"], ac["HVE"], ac["VVE"] = pms.adsb.nuc_v(msg)
171178
if ac["ver"] in [1, 2]:
172-
ac["HFOMr"], ac["VFOMr"] = pms.adsb.nac_v(msg)
179+
ac["NACv"], ac["HFOMr"], ac["VFOMr"] = pms.adsb.nac_v(msg)
173180

174181
if tc == 29:
175182
ac["PE_RCu"], ac["PE_VPL"], ac["base"] = pms.adsb.sil(msg, ac["ver"])
176-
ac["EPU"], ac["VEPU"] = pms.adsb.nac_p(msg)
183+
ac["NACp"], ac["HEPU"], ac["VEPU"] = pms.adsb.nac_p(msg)
177184

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

204+
self.acs[icao]["icao"] = icao
205+
self.acs[icao]["t"] = t
197206
self.acs[icao]["live"] = int(t)
198207

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

219228
if trk50:
229+
self.acs[icao]["trk50"] = trk50
220230
output_buffer.append([t, icao, "trk50", trk50])
221231
if gs50:
232+
self.acs[icao]["gs50"] = gs50
222233
output_buffer.append([t, icao, "gs50", gs50])
223234

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

243254
if roc60baro:
255+
self.acs[icao]["roc60baro"] = roc60baro
244256
output_buffer.append([t, icao, "roc60baro", roc60baro])
245257
if roc60ins:
258+
self.acs[icao]["roc60ins"] = roc60ins
246259
output_buffer.append([t, icao, "roc60ins", roc60ins])
247260

261+
elif bds == "BDS44":
262+
if(pms.commb.is44(msg)):
263+
self.acs[icao]["hum44"] = pms.commb.hum44(msg)
264+
self.acs[icao]["p44"] = pms.commb.p44(msg)
265+
self.acs[icao]["temp44"] = pms.commb.temp44(msg)
266+
self.acs[icao]["turb44"] = pms.commb.turb44(msg)
267+
self.acs[icao]["wind44"] = pms.commb.wind44(msg)
268+
248269
# clear up old data
249270
for icao in list(self.acs.keys()):
250271
if self.t - self.acs[icao]["live"] > self.cache_timeout:

0 commit comments

Comments
 (0)