diff --git a/receive.py b/receive.py index fd6302a..3cc7220 100644 --- a/receive.py +++ b/receive.py @@ -158,25 +158,25 @@ class ReceiveApp: elif getmessage[36:38] == "02": k = "AIS通道2信息" self.recv_text.insert(tk.END,"报文类型:" + k + "\n") - elif getmessage[36:38] == "02": + elif getmessage[36:38] == "03": k = "ACARS通道1信息" self.recv_text.insert(tk.END,"报文类型:" + k + "\n") - elif getmessage[36:38] == "02": + elif getmessage[36:38] == "04": k = "ACARS通道2信息" self.recv_text.insert(tk.END,"报文类型:" + k + "\n") - elif getmessage[36:38] == "02": + elif getmessage[36:38] == "05": k = "ACARS通道3信息" self.recv_text.insert(tk.END,"报文类型:" + k + "\n") - elif getmessage[36:38] == "02": + elif getmessage[36:38] == "06": k = "ACARS通道4信息" self.recv_text.insert(tk.END,"报文类型:" + k + "\n") - elif getmessage[36:38] == "02": + elif getmessage[36:38] == "07": k = "ADS-B信息" self.recv_text.insert(tk.END,"报文类型:" + k + "\n") - elif getmessage[36:38] == "02": + elif getmessage[36:38] == "08": k = "IFF信息" self.recv_text.insert(tk.END,"报文类型:" + k + "\n") - elif getmessage[36:38] == "02": + elif getmessage[36:38] == "FF": k = "工况" self.recv_text.insert(tk.END,"报文类型:" + k + "\n") else: @@ -188,7 +188,7 @@ class ReceiveApp: #AIS信息 - if True: #getmessage[36:38]=="01" or getmessage[36:38]=="02" + if getmessage[36:38] == "01" or getmessage[36:38] == "02": if getmessage[42:44] == "01" or getmessage[42:44] == "02" or getmessage[42:44] == "03": k = "A类船位置报告消息" self.recv_text.insert(tk.END, "消息ID:" + k + "\n") @@ -397,6 +397,261 @@ class ReceiveApp: self.recv_text.insert(tk.END, last_type + "\n") return + #ACARS数据 + if getmessage[36:38] == "03" or getmessage[36:38] == "04" or getmessage[36:38] == "05" or getmessage[36:38] == "06": + if getmessage[40:42] == "01": + t = "飞机发往地面" + self.recv_text.insert(tk.END, "消息ID:" + t + "\n") + elif getmessage[42:44] == "01": + t = "A类,广播模式" + self.recv_text.insert(tk.END, "消息ID:" + t + "\n") + elif getmessage[42:44] == "02": + t = "B类,点对点模式" + self.recv_text.insert(tk.END, "消息ID:" + t + "\n") + elif getmessage[44:58] == "FFFFFFFFFFFFFF" or getmessage[70:78] == "FFFFFFFFFFFFFF" or getmessage[78:86] == "FFFFFFFFFFFFFF": + t = "无效信息" + self.recv_text.insert(tk.END, "消息ID:" + t + "\n") + else: + t = "错误" + self.recv_text.insert(tk.END, "消息ID:" + t + "\n") + + self.recv_text.insert(tk.END, "飞机注册码:" + getmessage[44:58] + "\n") + + self.recv_text.insert(tk.END, "航班号:" + getmessage[58:70] + "\n") + + + self.recv_text.insert(tk.END, "起飞机场:" + getmessage[70:78] + "\n") + + self.recv_text.insert(tk.END, "目的机场:" + getmessage[78:86] + "\n") + + month = int(getmessage[86:88], 16) + day = int(getmessage[88:90], 16) + hour = int(getmessage[90:92], 16) + minute = int(getmessage[92:94], 16) + self.recv_text.insert(tk.END, "预计到达时间为: " + str(month) + "月" + str(day) + "日" + str( + hour) + "时" + str(minute) + "分" "\n") + + t = int(getmessage[94:98], 16) / 10 + self.recv_text.insert(tk.END, "空速:" + t + "\n") + + get_longitude = getmessage[98:116] + if get_longitude[0:3] == "FFFF": + longitude = "无效" + else: + byte_string = bytes.fromhex(get_longitude) + longitude = int.from_bytes(byte_string, byteorder='little', signed=True) + if (longitude < 0): + long_tag = "南纬: " + longitude = str((0 - longitude) / 10000) + else: + long_tag = "北纬: " + longitude = str((longitude) / 10000) + get_latitude = getmessage[116:124] + if get_latitude[0:3] == "FFFF": + latitude = "无效" + else: + byte_string = bytes.fromhex(get_latitude) + latitude = int.from_bytes(byte_string, byteorder='little', signed=True) + if (latitude < 0): + lat_tag = " 西经: " + latitude = str((0 - latitude) / 10000) + else: + lat_tag = " 东经:" + latitude = str((latitude) / 10000) + if (longitude == "无效" or latitude == "无效"): + self.recv_text.insert(tk.END, "无效位置\n") + else: + self.recv_text.insert(tk.END, "位置为: " + str(long_tag) + str(longitude) + str(lat_tag) + str( + latitude) + "\n") + + get_height = getmessage[124:132] + t = get_height + self.recv_text.insert(tk.END, "高度:" + t + "\n") + + #ADS-B数据 + if getmessage[36:38]== "07": + t = getmessage[44:50] + self.recv_text.insert(tk.END, "飞机地址码:" + t + "\n") + + if getmessage[50:52] == "00": + t = "无 ADS-B 发射器类型信息" + elif getmessage[50:52] == "01": + t = "轻型(<15500 磅);" + elif getmessage[50:52] == "02": + t = "小型(15500 到 75000 磅);" + elif getmessage[50:52] == "03": + t = "大型(75000 到 300000 磅);" + elif getmessage[50:52] == "04": + t = "高漩涡式大型(如 B-757 飞机)" + elif getmessage[50:52] == "05": + t = "重型(>300000 磅);" + elif getmessage[50:52] == "06": + t = "高性能(>5g 加速度且>400 哩/小时);" + elif getmessage[50:52] == "07": + t = "旋冀飞机;" + self.recv_text.insert(tk.END, "飞机类别:" + t + "\n") + + if getmessage[52:54] == "00": + t = "向上" + elif getmessage[52:54] == "01": + t = "向下" + self.recv_text.insert(tk.END, "飞垂直速度方向:" + t + "\n") + + t = int(getmessage[54:58], 16) / 10 + self.recv_text.insert(tk.END, "垂直速度:" + t + "\n") + + t = int(getmessage[58:62], 16) / 10 + self.recv_text.insert(tk.END, "空速:" + t + "\n") + + t = int(getmessage[62:66], 16) / 100 + self.recv_text.insert(tk.END, "航向:" + t + "\n") + + t = int(getmessage[66:70], 16) / 100 + self.recv_text.insert(tk.END, "目标航向:" + t + "\n") + + get_longitude = getmessage[70:78] + if get_longitude[0:3] == "FFFF": + longitude = "无效" + else: + byte_string = bytes.fromhex(get_longitude) + longitude = int.from_bytes(byte_string, byteorder='little', signed=True) + if (longitude < 0): + long_tag = "南纬: " + longitude = str((0 - longitude) / 10000) + else: + long_tag = "北纬: " + longitude = str((longitude) / 10000) + get_latitude = getmessage[78:86] + if get_latitude[0:3] == "FFFF": + latitude = "无效" + else: + byte_string = bytes.fromhex(get_latitude) + latitude = int.from_bytes(byte_string, byteorder='little', signed=True) + if (latitude < 0): + lat_tag = " 西经: " + latitude = str((0 - latitude) / 10000) + else: + lat_tag = " 东经:" + latitude = str((latitude) / 10000) + if (longitude == "无效" or latitude == "无效"): + self.recv_text.insert(tk.END, "无效位置\n") + else: + self.recv_text.insert(tk.END, "位置为: " + str(long_tag) + str(longitude) + str(lat_tag) + str( + latitude) + "\n") + + get_height = getmessage[86:94] + t = get_height + self.recv_text.insert(tk.END, "高度:" + t + "\n") + + get_height = getmessage[94:102] + t = get_height + self.recv_text.insert(tk.END, "目标高度:" + t + "\n") + + t = getmessage[102:118] + self.recv_text.insert(tk.END, "航班号:" + t + "\n") + + #工况信息 + if getmessage[36:38] == "FF": + get_frequency1 = getmessage[42:50] + byte_string = bytes.fromhex(get_frequency1) + frequency = int.from_bytes(byte_string, byteorder='little') + self.recv_text.insert(tk.END, "通道1中心频率为" + str(frequency) + "KHz\n") + + get_frequency2 = getmessage[58:66] + byte_string = bytes.fromhex(get_frequency2) + frequency = int.from_bytes(byte_string, byteorder='little') + self.recv_text.insert(tk.END, "通道2中心频率为" + str(frequency) + "KHz\n") + + get_frequency3 = getmessage[74:82] + byte_string = bytes.fromhex(get_frequency3) + frequency = int.from_bytes(byte_string, byteorder='little') + self.recv_text.insert(tk.END, "通道3中心频率为" + str(frequency) + "KHz\n") + + get_frequency4 = getmessage[90:98] + byte_string = bytes.fromhex(get_frequency4) + frequency = int.from_bytes(byte_string, byteorder='little') + self.recv_text.insert(tk.END, "通道4中心频率为" + str(frequency) + "KHz\n") + + get_frequency5 = getmessage[106:114] + byte_string = bytes.fromhex(get_frequency5) + frequency = int.from_bytes(byte_string, byteorder='little') + self.recv_text.insert(tk.END, "通道5中心频率为" + str(frequency) + "KHz\n") + + get_frequency6 = getmessage[122:130] + byte_string = bytes.fromhex(get_frequency6) + frequency = int.from_bytes(byte_string, byteorder='little') + self.recv_text.insert(tk.END, "通道6中心频率为" + str(frequency) + "KHz\n") + + get_frequency7 = getmessage[138:146] + byte_string = bytes.fromhex(get_frequency7) + frequency = int.from_bytes(byte_string, byteorder='little') + self.recv_text.insert(tk.END, "通道7中心频率为" + str(frequency) + "KHz\n") + + get_fpga = getmessage[154:162] + byte_string = bytes.fromhex(get_fpga) + fpga = int.from_bytes(byte_string, byteorder='little') + self.recv_text.insert(tk.END, "FPGA版本号为" + str(fpga) + "\n") + + get_arm = getmessage[170:178] + byte_string = bytes.fromhex(get_arm) + arm = int.from_bytes(byte_string, byteorder='little') + self.recv_text.insert(tk.END, "ARM版本号为" + str(arm) + "\n") + + #四个字节,分别对应第一到第四段号码 + address1 = int(getmessage[186:188],16) + address2 = int(getmessage[188:190],16) + address3 = int(getmessage[190:192],16) + address4 = int(getmessage[192:194],16) + ip_address = str(address1)+"."+str(address2)+"."+str(address3)+"."+str(address4) + self.recv_text.insert(tk.END, "接收机地址为" + str(ip_address) + "\n") + + get_port = getmessage[194:198] + byte_string = bytes.fromhex(get_port) + port = int.from_bytes(byte_string, byteorder='little') + self.recv_text.insert(tk.END, "接收机端口号为" + str(port) + "\n") + + #198-202 纬度 + get_longitude = getmessage[198:204] + if get_longitude[0:3] == "FFFF": + longitude = "无效" + else: + byte_string = bytes.fromhex(get_longitude) + longitude = int.from_bytes(byte_string, byteorder='little',signed=True) + if(longitude < 0): + long_tag = "南纬: " + longitude = str((0-longitude)/10000) + else: + long_tag = "北纬: " + longitude = str((longitude)/10000) + get_latitude = getmessage[204:212] + if get_latitude[0:3] == "FFFF": + latitude = "无效" + else: + byte_string = bytes.fromhex(get_latitude) + latitude = int.from_bytes(byte_string, byteorder='little',signed=True) + if(latitude < 0): + lat_tag = " 西经: " + latitude = str((0-latitude)/10000) + else: + lat_tag = " 东经:" + latitude = str((latitude)/10000) + if(longitude == "无效" or latitude == "无效"): + self.recv_text.insert(tk.END, "无效位置\n") + else: + self.recv_text.insert(tk.END, "本机位置为: " + str(long_tag) + str(longitude) + str(lat_tag) + str(latitude) + "\n") + + cpu_temp = getmessage[212:214] + + byte_string = bytes.fromhex(cpu_temp) + cpu_temp = int.from_bytes(byte_string, byteorder='little') + self.recv_text.insert(tk.END, "CPU温度为" + str(cpu_temp) + "℃\n") + + #帧尾 + if getmessage[214:220] != "334441": + last_type = "错误类型:帧尾错误" + self.recv_text.insert(tk.END, last_type + "\n") + return + if __name__ == "__main__": water = 0