diff --git a/src/python/cpr-test.py b/src/python/cpr-test.py index 43782c8..eaf7064 100755 --- a/src/python/cpr-test.py +++ b/src/python/cpr-test.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python # # Copyright 2010 Nick Foster # @@ -19,9 +20,6 @@ # Boston, MA 02110-1301, USA. # - -#!/usr/bin/env python - from modes_parse import * from cpr import * import sys diff --git a/src/python/modes_print.py b/src/python/modes_print.py index 304ce52..284cb3f 100644 --- a/src/python/modes_print.py +++ b/src/python/modes_print.py @@ -29,8 +29,6 @@ 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) @@ -54,7 +52,13 @@ class modes_output_print(modes_parse.modes_parse): else: output = "No handler for message type " + str(msgtype) + " from " + str(ecc) - output = "(%.0f) " % (10.0*math.log10(float(reference))) + output + + if reference == 0: + refdb = 0 + else: + refdb = 10.0*math.log10(reference) + + output = "(%.0f) " % (refdb) + output print output diff --git a/src/python/modes_sql.py b/src/python/modes_sql.py index 89a6cc6..f8f312f 100644 --- a/src/python/modes_sql.py +++ b/src/python/modes_sql.py @@ -25,9 +25,9 @@ import modes_parse import sqlite3 class modes_output_sql(modes_parse.modes_parse): - def __init__(self): + def __init__(self, filename): #create the database - self.db = sqlite3.connect('adsb.db') + self.db = sqlite3.connect(filename) #now execute a schema to create the tables you need c = self.db.cursor() query = """CREATE TABLE IF NOT EXISTS "positions" ( diff --git a/src/python/uhd_modes.py b/src/python/uhd_modes.py index 839701e..12ca79f 100755 --- a/src/python/uhd_modes.py +++ b/src/python/uhd_modes.py @@ -149,7 +149,7 @@ if __name__ == '__main__': updates = [] #registry of plugin update functions if options.kml is not None: - sqlport = modes_output_sql() #create a SQL parser to push stuff into SQLite + sqlport = modes_output_sql('adsb.db') #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('adsb.db', options.kml) #create a KML generating thread which reads the database @@ -178,8 +178,8 @@ if __name__ == '__main__': while queue.empty_p() == 0 : msg = queue.delete_head() #blocking read - for out in outputs: - out(msg.to_string()) + for out in outputs: + out(msg.to_string()) elif runner.done: raise KeyboardInterrupt