Files
ECAP_Server/doc/icao解码.txt
T
2026-06-16 11:18:22 +08:00

51 lines
1.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
https://mode-s.org/1090mhz/content/mode-s/1-basics.html
p(x)crc计算结果
符号解释
A:是ICAO地址
P:是后24位置零,crc的计算结果,任何消息都能算这个值
AP=A^P
异或可逆性性
AP = A^P
A = AP^P
P = AP^A
DP = BDS^AAA^P //DP是数据奇偶校验,目前没看到那种24位,存这种东西
df = 11 17 18 消息后24位存放P, A明文存放在消息中,直接获取
df = 0 4 5 16 20 21 消息后24位存放AP, 先计算P,然后根据 A=AP^P 计算出A
// 上面这个df pyModeS-master 项目 源码py_common.py 119
// pyModeS-master项目 作者也是 那个文档的作者
def icao(msg: str) -> Optional[str]:
"""Calculate the ICAO address from an Mode-S message.
Applicable only with DF4, DF5, DF20, DF21 messages.
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
String: ICAO address in 6 bytes hexadecimal string
"""
addr: Optional[str]
DF = df(msg)
if DF in (11, 17, 18):
addr = msg[2:8]
elif DF in (0, 4, 5, 16, 20, 21):
c0 = crc(msg, encode=True)
c1 = int(msg[-6:], 16)
addr = "%06X" % (c0 ^ c1)
else:
addr = None
return addr