Update allcall.py

This commit is contained in:
boringow
2020-11-12 14:46:33 +01:00
committed by GitHub
parent 84c6255567
commit 35c0bfa513
+36 -3
View File
@@ -3,8 +3,8 @@ from pyModeS import common
Decoding all call replies DF=11 Decoding all call replies DF=11
""" """
def ipcode(msg): def ipcode(msg):
if common.df(msg) == 11: # check that the msg is DF11
'''Returns the IP code of the Mode S all-call reply (DF11)''' '''Returns the IP code of the Mode S all-call reply (DF11)'''
binaryraw=common.hex2bin(msg) binaryraw=common.hex2bin(msg)
PI=binaryraw[-24:] PI=binaryraw[-24:]
@@ -25,9 +25,39 @@ def ipcode(msg):
Mx=Mx[1:] Mx=Mx[1:]
Gx=Gx[:-1] Gx=Gx[:-1]
SIcode=(int(Mx,2)^int(PI,2)) #Mx is the parity sequence and PI is the last field of the DF11. SIcode=bin(int(Mx,2)^int(PI,2)).zfill(7) #Mx is the parity sequence and PI is the last field of the DF11.
return SIcode if int(SIcode[0:3],2)>0:
return str("SI" + str(int(SIcode[3:],2)))
else:
return str("II" + str(int(SIcode,2)))
else:
raise RuntimeError("Incorrect or inconsistent message types")
def flight_status(msg):
'''returns the flight status'''
if common.df(msg) == 11: # check that the msg is DF11
binaryraw=common.hex2bin(msg)
CA = (int(binaryraw[5:8],2))
if CA in [0, 1, 2, 3, 6, 7]: #reserved
return None
if CA == 4:#level 2 transponder, ability to set CA to 7 and on ground
return "on ground"
if CA == 5:#level 2 transponder, ability to set CA to 7 and airborn
return "airborne"
else:
raise RuntimeError("Incorrect or inconsistent message types")
def transponder_level(msg):
'''returns the transponder level'''
if common.df(msg) == 11:#check that the msg is DF11
binaryraw=common.hex2bin(msg)
CA = (int(binaryraw[5:8],2))
if CA in [1, 2, 3, 4, 5, 6, 7]: #reserved
return 2
if CA == 0:
return 1
else:
raise RuntimeError("Incorrect or inconsistent message types")
def capability(msg): def capability(msg):
'''return the capability code''' '''return the capability code'''
@@ -51,4 +81,7 @@ def capability(msg):
def AA(msg): def AA(msg):
'''returns the icao code of the aircraft''' '''returns the icao code of the aircraft'''
if common.df(msg) == 11: # check that the msg is DF11
return (msg[2:8]) return (msg[2:8])
else:
raise RuntimeError("Incorrect or inconsistent message types")