def pp5(self, shortdata, ecc): [datestr, timestr] = self.current_time() aircraft_id = self.get_aircraft_id(ecc) retstr = "MSG,6,0,%i,%06X,%i,%s,%s,%s,%s,,,,,,,,%04i," % ( aircraft_id, ecc, aircraft_id + 100, datestr, timestr, datestr, timestr, air_modes.decode_id(shortdata["id"])) return retstr + self.decode_fs(shortdata["fs"]) + "\r\n"
def handle5(self, msg): try: retstr = output_print.prefix(msg) retstr += "Type 5 (short surveillance ident reply) from %x with ident %i" % ( msg.ecc, air_modes.decode_id(msg.data["id"])) retstr += output_print.fs_text(msg.data["fs"]) except ADSBError: return self._print(retstr)
def printTCAS(self, msg): msgtype = msg.data["df"] if msgtype == 16: bds1 = msg.data["vds1"] bds2 = msg.data["vds2"] else: bds1 = msg.data["bds1"] bds2 = msg.data["bds2"] retstr = output_print.prefix(msg) if bds2 != 0: retstr += "No handler in type %i for BDS2 == %i from %x" % (msgtype, bds2, msg.ecc) elif bds1 == 0: retstr += "No handler in type %i for BDS1 == 0 from %x" % (msgtype, msg.ecc) elif bds1 == 1: retstr += "Type %i link capability report from %x: ACS: 0x%x, BCS: 0x%x, ECS: 0x%x, continues %i" \ % (msgtype, msg.ecc, msg.data["acs"], msg.data["bcs"], msg.data["ecs"], msg.data["cfs"]) elif bds1 == 2: retstr += "Type %i identification from %x with text %s" % (msgtype, msg.ecc, air_modes.parseMB_id(msg.data)) elif bds1 == 3: retstr += "Type %i TCAS report from %x: " % (msgtype, msg.ecc) tti = msg.data["tti"] if msgtype == 16: (resolutions, complements, rat, mte) = air_modes.parse_TCAS_CRM(msg.data) retstr += "advised: %s complement: %s" % (resolutions, complements) else: if tti == 1: (resolutions, complements, rat, mte, threat_id) = air_modes.parseMB_TCAS_threatid(msg.data) retstr += "threat ID: %x advised: %s complement: %s" % (threat_id, resolutions, complements) elif tti == 2: (resolutions, complements, rat, mte, threat_alt, threat_range, threat_bearing) = air_modes.parseMB_TCAS_threatloc(msg.data) retstr += "range: %i bearing: %i alt: %i advised: %s complement: %s" % (threat_range, threat_bearing, threat_alt, resolutions, complements) else: rat = 0 mte = 0 retstr += " (no handler for TTI=%i)" % tti if mte == 1: retstr += " (multiple threats)" if rat == 1: retstr += " (resolved)" else: retstr += "No handler for type %i, BDS1 == %i from %x" % (msgtype, bds1, msg.ecc) if(msgtype == 20 or msgtype == 16): retstr += " at %ift" % air_modes.decode_alt(msg.data["ac"], True) else: retstr += " ident %x" % air_modes.decode_id(msg.data["id"]) self._print(retstr)
def receive(self, message, cpr_decoder): self.__last_heard_time = time.time( ) # TODO: arguably should be an argument # Unfortunately, gr-air-modes doesn't provide a function to implement this gunk -- imitating its output_flightgear code which data = message.data t = data.get_type() if t == 0: self.__altitude_feet = air_modes.decode_alt(data['ac'], True) # TODO more info available here elif t == 4: self.__altitude_feet = air_modes.decode_alt(data['ac'], True) # TODO more info available here elif t == 5: self.__ident = air_modes.decode_id(data['id']) # TODO more info available here elif t == 17: # ADS-B bdsreg = data['me'].get_type() if bdsreg == 0x05: (self.__altitude_feet, self.__latitude, self.__longitude, _range, _bearing) = air_modes.parseBDS05(data, cpr_decoder) elif bdsreg == 0x06: (_ground_track, self.__latitude, self.__longitude, _range, _bearing) = air_modes.parseBDS06(data, cpr_decoder) elif bdsreg == 0x08: (self.__call, self.__aircraft_type) = air_modes.parseBDS08(data) elif bdsreg == 0x09: subtype = data['bds09'].get_type() if subtype == 0: (self.__velocity, self.__heading, self.__vertical_speed, self.__turn_rate) = air_modes.parseBDS09_0(data) elif subtype == 1: (self.__velocity, self.__heading, self.__vertical_speed) = air_modes.parseBDS09_1(data) self.__turn_rate = 0 # TODO: or should we keep last? else: # TODO report pass else: # TODO report pass else: # TODO report pass
def receive(self, message, cpr_decoder): self.__last_heard_time = time.time() # TODO: arguably should be an argument # Unfortunately, gr-air-modes doesn't provide a function to implement this gunk -- imitating its output_flightgear code which data = message.data t = data.get_type() if t == 0: self.__altitude_feet = air_modes.decode_alt(data['ac'], True) # TODO more info available here elif t == 4: self.__altitude_feet = air_modes.decode_alt(data['ac'], True) # TODO more info available here elif t == 5: self.__ident = air_modes.decode_id(data['id']) # TODO more info available here elif t == 17: # ADS-B bdsreg = data['me'].get_type() if bdsreg == 0x05: (self.__altitude_feet, self.__latitude, self.__longitude, _range, _bearing) = air_modes.parseBDS05(data, cpr_decoder) elif bdsreg == 0x06: (_ground_track, self.__latitude, self.__longitude, _range, _bearing) = air_modes.parseBDS06(data, cpr_decoder) elif bdsreg == 0x08: (self.__call, self.__aircraft_type) = air_modes.parseBDS08(data) elif bdsreg == 0x09: subtype = data['bds09'].get_type() if subtype == 0: (self.__velocity, self.__heading, self.__vertical_speed, self.__turn_rate) = air_modes.parseBDS09_0(data) elif subtype == 1: (self.__velocity, self.__heading, self.__vertical_speed) = air_modes.parseBDS09_1(data) self.__turn_rate = 0 # TODO: or should we keep last? else: # TODO report pass else: # TODO report pass else: # TODO report pass
def pp5(self, shortdata, ecc): [datestr, timestr] = self.current_time() aircraft_id = self.get_aircraft_id(ecc) retstr = "MSG,6,0,%i,%06X,%i,%s,%s,%s,%s,,,,,,,,%04i," % (aircraft_id, ecc, aircraft_id+100, datestr, timestr, datestr, timestr, air_modes.decode_id(shortdata["id"])) return retstr + self.decode_fs(shortdata["fs"]) + "\r\n"
def receive(self, message_wrapper): message = message_wrapper.message cpr_decoder = message_wrapper.cpr_decoder receive_time = message_wrapper.receive_time self.__last_heard_time = receive_time # Unfortunately, gr-air-modes doesn't provide a function to implement this gunk -- imitating its output_flightgear code which data = message.data t = data.get_type() if t == 0: self.__track = self.__track._replace( altitude=TelemetryItem(air_modes.decode_alt(data['ac'], True) * _METERS_PER_FEET, receive_time)) # TODO more info available here elif t == 4: self.__track = self.__track._replace( altitude=TelemetryItem(air_modes.decode_alt(data['ac'], True) * _METERS_PER_FEET, receive_time)) # TODO more info available here elif t == 5: self.__ident = air_modes.decode_id(data['id']) # TODO more info available here elif t == 17: # ADS-B bdsreg = data['me'].get_type() if bdsreg == 0x05: # TODO use unused info (altitude_feet, latitude, longitude, _range, _bearing) = air_modes.parseBDS05(data, cpr_decoder) self.__track = self.__track._replace( altitude=TelemetryItem(altitude_feet * _METERS_PER_FEET, receive_time), latitude=TelemetryItem(latitude, receive_time), longitude=TelemetryItem(longitude, receive_time), ) elif bdsreg == 0x06: # TODO use unused info (_ground_track, latitude, longitude, _range, _bearing) = air_modes.parseBDS06(data, cpr_decoder) self.__track = self.__track._replace( latitude=TelemetryItem(latitude, receive_time), longitude=TelemetryItem(longitude, receive_time), ) elif bdsreg == 0x08: (self.__call, self.__aircraft_type) = air_modes.parseBDS08(data) elif bdsreg == 0x09: subtype = data['bds09'].get_type() if subtype == 0: (velocity, heading, vertical_speed, _turn_rate) = air_modes.parseBDS09_0(data) # TODO: note we're stuffing the heading in as track angle. Is there something better to do? self.__track = self.__track._replace( h_speed=TelemetryItem(velocity * _KNOTS_TO_METERS_PER_SECOND, receive_time), heading=TelemetryItem(heading, receive_time), track_angle=TelemetryItem(heading, receive_time), v_speed=TelemetryItem(vertical_speed, receive_time), # TODO add turn rate ) elif subtype == 1: (velocity, heading, vertical_speed) = air_modes.parseBDS09_1(data) self.__track = self.__track._replace( h_speed=TelemetryItem(velocity * _KNOTS_TO_METERS_PER_SECOND, receive_time), heading=TelemetryItem(heading, receive_time), track_angle=TelemetryItem(heading, receive_time), v_speed=TelemetryItem(vertical_speed, receive_time), # TODO reset turn rate? ) else: # TODO report pass else: # TODO report pass else: # TODO report pass
def receive(self, message_wrapper): message = message_wrapper.message cpr_decoder = message_wrapper.cpr_decoder receive_time = message_wrapper.receive_time self.__last_heard_time = receive_time # Unfortunately, gr-air-modes doesn't provide a function to implement this gunk -- imitating its output_flightgear code which data = message.data t = data.get_type() if t == 0: self.__track = self.__track._replace(altitude=TelemetryItem( air_modes.decode_alt(data['ac'], True) * _METERS_PER_FEET, receive_time)) # TODO more info available here elif t == 4: self.__track = self.__track._replace(altitude=TelemetryItem( air_modes.decode_alt(data['ac'], True) * _METERS_PER_FEET, receive_time)) # TODO more info available here elif t == 5: self.__ident = air_modes.decode_id(data['id']) # TODO more info available here elif t == 17: # ADS-B bdsreg = data['me'].get_type() if bdsreg == 0x05: # TODO use unused info (altitude_feet, latitude, longitude, _range, _bearing) = air_modes.parseBDS05(data, cpr_decoder) self.__track = self.__track._replace( altitude=TelemetryItem(altitude_feet * _METERS_PER_FEET, receive_time), latitude=TelemetryItem(latitude, receive_time), longitude=TelemetryItem(longitude, receive_time), ) elif bdsreg == 0x06: # TODO use unused info (_ground_track, latitude, longitude, _range, _bearing) = air_modes.parseBDS06(data, cpr_decoder) self.__track = self.__track._replace( latitude=TelemetryItem(latitude, receive_time), longitude=TelemetryItem(longitude, receive_time), ) elif bdsreg == 0x08: (self.__call, self.__aircraft_type) = air_modes.parseBDS08(data) elif bdsreg == 0x09: subtype = data['bds09'].get_type() if subtype == 0: (velocity, heading, vertical_speed, _turn_rate) = air_modes.parseBDS09_0(data) # TODO: note we're stuffing the heading in as track angle. Is there something better to do? self.__track = self.__track._replace( h_speed=TelemetryItem( velocity * _KNOTS_TO_METERS_PER_SECOND, receive_time), heading=TelemetryItem(heading, receive_time), track_angle=TelemetryItem(heading, receive_time), v_speed=TelemetryItem(vertical_speed, receive_time), # TODO add turn rate ) elif subtype == 1: (velocity, heading, vertical_speed) = air_modes.parseBDS09_1(data) self.__track = self.__track._replace( h_speed=TelemetryItem( velocity * _KNOTS_TO_METERS_PER_SECOND, receive_time), heading=TelemetryItem(heading, receive_time), track_angle=TelemetryItem(heading, receive_time), v_speed=TelemetryItem(vertical_speed, receive_time), # TODO reset turn rate? ) else: # TODO report pass else: # TODO report pass else: # TODO report pass self.state_changed()
def handle5(self, msg): try: retstr = output_print.prefix(msg) retstr += "Type 5 (short surveillance ident reply) from %x with ident %i" % (msg.ecc, air_modes.decode_id(msg.data["id"])) retstr += output_print.fs_text(msg.data["fs"]) except ADSBError: return self._print(retstr)