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.
This commit is contained in:
Nick Foster 2010-10-21 23:02:48 -07:00
parent 0edcc29380
commit 0bf5e47749
3 changed files with 14 additions and 9 deletions

View File

@ -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:

View File

@ -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
);"""

View File

@ -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()