def read_message(self, msg, ts): """ Process ADSB messages """ if len(msg) < 28: return df = decoder.get_df(msg) if df == 17: addr = decoder.get_icao_addr(msg) tc = decoder.get_tc(msg) if tc >= 1 and tc <= 4: # aircraft identification callsign = decoder.get_callsign(msg) self.update_callsign(addr, callsign) if 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) self.update_cprpos(addr, oe, ts, alt, cprlat, cprlon) elif tc == 19: # airbone velocity frame sh = decoder.get_speed_heading(msg) if len(sh) == 2: spd = sh[0] hdg = sh[1] self.update_spd_hdg(addr, spd, hdg) return
def read_message(self, msgtype, data, datalen): ''' Process the message that received from remote TCP server ''' if msgtype == 3: # get time from the Aircraft t_sec_ac = 0 t_sec_ac |= data[0] << 24 t_sec_ac |= data[1] << 16 t_sec_ac |= data[2] << 8 t_sec_ac |= data[3] # get receiver timestamp t_sec_receiver = 0 t_sec_receiver |= data[4] << 24 t_sec_receiver |= data[5] << 16 t_sec_receiver |= data[6] << 8 t_sec_receiver |= data[7] # ignor receiver id, data[8] # ignor data[9], for now mlat = 0 mlat |= data[10] << 24 mlat |= data[11] << 16 mlat |= data[12] << 8 mlat |= data[13] power = 0 power |= data[14] << 8 power |= data[15] power &= 0x3FFF power = power >> 6 # process msg in the data frame msg = '' msglen = 14 # type 3 data length is 14 msgstart = 16 msgend = msgstart + msglen for i in data[msgstart : msgend] : msg += "%02X" % i # print "Type:%d | Len:%d | AcTime:%d | ReceiverTime:%d | Power:%d | MSG: %s" % \ # (msgtype, datalen, t_sec_ac, t_sec_receiver, power, msg) df = adsb_decoder.get_df(msg) tc = adsb_decoder.get_tc(msg) ca = adsb_decoder.get_ca(msg) if df == 17: addr = adsb_decoder.get_icao_addr(msg) if tc>=1 and tc<=4: # aircraft identification callsign = adsb_decoder.get_callsign(msg) self.datafeed.update_callsign_data(addr, callsign) if tc>=9 and tc<=18: # airbone postion frame alt = adsb_decoder.get_alt(msg) oe = adsb_decoder.get_oe_flag(msg) # odd or even frame cprlat = adsb_decoder.get_cprlat(msg) cprlon = adsb_decoder.get_cprlon(msg) dataset = {'addr':addr, 'oe':oe, 'time':t_sec_ac, 'alt':alt, 'cprlat':cprlat, 'cprlon':cprlon} # print dataset self.datafeed.push_cprpos_data(dataset) elif tc==19: # airbone velocity frame sh = adsb_decoder.get_speed_heading(msg) if sh: dataset = {'addr':addr, 'speed':sh[0], 'heading':sh[1]} self.datafeed.push_speed_heading_data(dataset) return