update testing code

This commit is contained in:
Junzi Sun 2015-09-18 18:10:04 +02:00
parent 4e1d91cc35
commit 27cac0efde
3 changed files with 30 additions and 4555 deletions

4516
data.txt

File diff suppressed because it is too large Load Diff

39
run.py
View File

@ -1,39 +0,0 @@
import decoder
import re
with open('data.txt', 'r') as f:
lines = f.readlines()
for line in lines:
m = re.search('^(\d+\-\d+\-\d+T\d+\:\d+\:\d+\.\d+)\s*(\S*).*$', line)
time = m.group(1)
msg = m.group(2)
df = decoder.get_df(msg)
tc = decoder.get_tc(msg)
ca = decoder.get_ca(msg)
if df==17:
addr = decoder.get_icao_addr(msg)
if tc>=1 and tc<=4:
# aircraft identification
callsign = decoder.get_callsign(msg)
print msg, '->', 'ID:', callsign
elif tc>=9 and tc<=18:
# airbone postion frame
alt = decoder.get_alt(msg)
oe = decoder.get_oe_flag(msg) # odd or even frame
# cprlat = decoder.get_cprlat(msg)
# cprlon = decoder.get_cprlon(msg)
print msg, '->', 'CPR odd frame' if oe else 'CPR even frame'
elif tc==19:
# airbone velocity frame
sh = decoder.get_speed_heading(msg)
print msg, '->', 'Speed:', sh[0], 'Heading:', sh[1]
else:
print df
pass

30
run_test.py Normal file
View File

@ -0,0 +1,30 @@
import decoder
print 'Testing the ADS-B decoder'
print '---------------------------'
print
# decode call sign test
msg = '8D51004E20092578DB782072C825'
cs = decoder.get_callsign(msg)
print 'Message:', msg
print 'Call sign:', cs
print
# decode position
msg0 = '8D51004E901DF3041D06127582A1'
msg1 = '8D51004E901DF66EB4FEE010C7A9'
t0 = 1442566675
t1 = 1442566674
pos = decoder.get_position(msg0, msg1, t0, t1)
print 'Message E:', msg0
print 'Message O:', msg1
print 'Position:', pos
print
# decode velocity
msg = '8D51004E99850702685C00E582E4'
sh = decoder.get_speed_heading(msg)
print 'Message:', msg
print 'Speed and heading:', sh
print