From 0bf5e47749ce532bc8f126969d57bd128909ed93 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Thu, 21 Oct 2010 23:02:48 -0700 Subject: [PATCH] Various fixes for various exceptions. You are seeing a couple of impossible altitudes and a couple of impossible longitudes. Looks like they're coming from the same aircraft. Possibly a nonstandard squitter? They pass checksum, but they don't contain the data you think they do. --- src/python/modes_print.py | 8 ++++++-- src/python/modes_sql.py | 8 ++++---- src/python/uhd_modes.py | 7 ++++--- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/python/modes_print.py b/src/python/modes_print.py index 47e1afc..304ce52 100644 --- a/src/python/modes_print.py +++ b/src/python/modes_print.py @@ -29,6 +29,8 @@ class modes_output_print(modes_parse.modes_parse): def parse(self, message): [msgtype, shortdata, longdata, parity, ecc, reference] = message.split() + if reference is None: reference = 0 + shortdata = long(shortdata, 16) longdata = long(longdata, 16) parity = long(parity, 16) @@ -117,6 +119,8 @@ class modes_output_print(modes_parse.modes_parse): def print17(self, shortdata, longdata, parity, ecc): icao24 = shortdata & 0xFFFFFF subtype = (longdata >> 51) & 0x1F; + + retstr = None if subtype == 4: msg = self.parseBDS08(shortdata, longdata, parity, ecc) @@ -131,8 +135,8 @@ class modes_output_print(modes_parse.modes_parse): elif subtype >= 9 and subtype <= 18: [altitude, decoded_lat, decoded_lon, rnge, bearing] = self.parseBDS05(shortdata, longdata, parity, ecc) - - retstr = "Type 17 subtype 05 (position report) from " + "%x" % icao24 + " at (" + "%.6f" % decoded_lat + ", " + "%.6f" % decoded_lon + ") (" + "%.2f" % rnge + " @ " + "%.0f" % bearing + ") at " + str(altitude) + "ft" + if decoded_lat is not None: + retstr = "Type 17 subtype 05 (position report) from " + "%x" % icao24 + " at (" + "%.6f" % decoded_lat + ", " + "%.6f" % decoded_lon + ") (" + "%.2f" % rnge + " @ " + "%.0f" % bearing + ") at " + str(altitude) + "ft" # this is a trigger to capture the bizarre BDS0,5 squitters you keep seeing on the map with latitudes all over the place # if icao24 == 0xa1ede9: diff --git a/src/python/modes_sql.py b/src/python/modes_sql.py index 5687752..89a6cc6 100644 --- a/src/python/modes_sql.py +++ b/src/python/modes_sql.py @@ -27,10 +27,10 @@ import sqlite3 class modes_output_sql(modes_parse.modes_parse): def __init__(self): #create the database - self.db = sqlite3.connect('wat.db') #RAM-based database, no persistence + self.db = sqlite3.connect('adsb.db') #now execute a schema to create the tables you need c = self.db.cursor() - query = """CREATE TABLE "positions" ( + query = """CREATE TABLE IF NOT EXISTS "positions" ( "icao" INTEGER KEY NOT NULL, "seen" TEXT NOT NULL, "alt" INTEGER, @@ -38,7 +38,7 @@ class modes_output_sql(modes_parse.modes_parse): "lon" REAL );""" c.execute(query) - query = """CREATE TABLE "vectors" ( + query = """CREATE TABLE IF NOT EXISTS "vectors" ( "icao" INTEGER KEY NOT NULL, "seen" TEXT NOT NULL, "speed" REAL, @@ -46,7 +46,7 @@ class modes_output_sql(modes_parse.modes_parse): "vertical" REAL );""" c.execute(query) - query = """CREATE TABLE "ident" ( + query = """CREATE TABLE IF NOT EXISTS "ident" ( "icao" INTEGER PRIMARY KEY NOT NULL, "ident" TEXT NOT NULL );""" diff --git a/src/python/uhd_modes.py b/src/python/uhd_modes.py index 0c42bed..cab0dc0 100755 --- a/src/python/uhd_modes.py +++ b/src/python/uhd_modes.py @@ -84,6 +84,9 @@ class adsb_rx_block (gr.top_block): self.demod = gr.complex_to_mag() self.avg = gr.moving_average_ff(100, 1.0/100, 400); +# self.filtcoeffs = gr.firdes.band_reject(1, rate, -691e3, -646e3, 10e3, WIN_HANN) +# self.filter = gr.fir_filter_ccc(1, self.filtcoeffs) + self.preamble = air.modes_preamble(rate, options.threshold) self.framer = air.modes_framer(rate) self.slicer = air.modes_slicer(rate, queue) @@ -116,8 +119,6 @@ if __name__ == '__main__': help="set pulse detection threshold above noise in dB [default=%default]") parser.add_option("-a","--output-all", action="store_true", default=False, help="output all frames") - parser.add_option("-b","--bandwidth", type="eng_float", default=5e6, - help="set DBSRX baseband bandwidth in Hz [default=%default]") parser.add_option("-F","--filename", type="string", default=None, help="read data from file instead of USRP") parser.add_option("-K","--kml", type="string", default=None, @@ -138,7 +139,7 @@ if __name__ == '__main__': sqlport = modes_output_sql() #create a SQL parser to push stuff into SQLite outputs.append(sqlport.insert) #also we spawn a thread to run every 30 seconds (or whatever) to generate KML - kmlgen = modes_kml(sqlport.db, options.kml) #create a KML generating thread which reads the database + kmlgen = modes_kml('adsb.db', options.kml) #create a KML generating thread which reads the database if options.sbs1 is True: sbs1port = modes_output_sbs1()