def ehs_decode_all(n=None): print "===== Decode all Mode-S EHS sample data=====" import csv f = open('ehs.csv', 'rt') for i, r in enumerate(csv.reader(f)): if n and i > n: break ts = r[1] m = r[2] icao = ehs.icao(m) vBDS = ehs.BDS(m) if vBDS: if vBDS == "BDS20": print ts, m, icao, vBDS, ehs.callsign(m) if vBDS == "BDS40": print ts, m, icao, vBDS, ehs.alt_mcp(m), \ ehs.alt_fms(m), ehs.pbaro(m) if vBDS == "BDS50": print ts, m, icao, vBDS, ehs.roll(m), ehs.track(m), \ ehs.gs(m), ehs.rtrack(m), ehs.tas(m) if vBDS == "BDS60": print ts, m, icao, vBDS, ehs.heading(m), ehs.ias(m), \ ehs.mach(m), ehs.baro_vr(m), ehs.ins_vr(m) else: print ts, m, icao, vBDS
def ehs_decode_all(df, n=None): import csv print("===== Decode EHS sample data (DF=%s)=====" % df) f = open('tests/data/sample_data_ehs_df%s.csv' % df, 'rt') for i, r in enumerate(csv.reader(f)): if n and i > n: break ts = r[0] m = r[2] df = util.df(m) icao = ehs.icao(m) BDS = ehs.BDS(m) code = ehs.df20alt(m) if df == 20 else ehs.df21id(m) if not BDS: print(ts, m, icao, df, '%5s' % code, 'UNKNOWN') continue if isinstance(BDS, list): print(ts, m, icao, df, '%5s' % code, end=' ') for i, bds in enumerate(BDS): if i == 0: print(bds, *bds_info(bds, m)) else: print(' ' * 55, bds, *bds_info(bds, m)) else: print(ts, m, icao, df, '%5s' % code, BDS, *bds_info(BDS, m))
def test_ehs_icao(): assert ehs.icao("A0001839CA3800315800007448D9") == '400940' assert ehs.icao("A000139381951536E024D4CCF6B5") == '3C4DD2' assert ehs.icao("A000029CFFBAA11E2004727281F1") == '4243D0'