We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bddaf9a commit cb67c63Copy full SHA for cb67c63
pyModeS/decoder/uplink.py
@@ -0,0 +1,24 @@
1
+from pyModeS.decoder import common
2
+
3
+def uplink_icao(msg):
4
+ """Calculate the ICAO address from a Mode-S interrogation (uplink message)"""
5
+ p_gen = 0xfffa0480 << ((len(msg)-14)*4)
6
+ data = int(msg[:-6],16)
7
+ PA = int(msg[-6:],16)
8
+ ad = 0
9
+ topbit = 0b1 << (len(msg)*4-25)
10
+ for j in range(0,len(msg)*4,1):
11
+ if (data & topbit):
12
+ data^=p_gen
13
+ data = (data << 1) + ((PA >> 23) & 1)
14
+ PA = PA << 1
15
+ if (j>(len(msg)*4-26)):
16
+ ad = ad + ((data >> (len(msg)*4-25)) & 1)
17
+ ad = ad << 1
18
+ return "%06X" % (ad >> 2)
19
20
21
+def uf(msg):
22
+ """Decode Uplink Format value, bits 1 to 5."""
23
+ ufbin = common.hex2bin(msg[:2])
24
+ return min(common.bin2int(ufbin[0:5]), 24)
0 commit comments