Collected all the local position stuff so it's specified once in uhd_modes.py.
Should probably add in a command-line parameter to specify this.
This commit is contained in:
@@ -157,7 +157,7 @@ def cpr_resolve_global(evenpos, oddpos, mostrecent, surface): #ok this is consid
|
||||
return [rlat, rlon]
|
||||
|
||||
|
||||
def cpr_decode(icao24, encoded_lat, encoded_lon, cpr_format, evenlist, oddlist, lkplist, surface, longdata):
|
||||
def cpr_decode(my_location, icao24, encoded_lat, encoded_lon, cpr_format, evenlist, oddlist, lkplist, surface, longdata):
|
||||
#this is a stopgap measure to catch those packets which aren't really position packets. what gives?
|
||||
# if encoded_lat == 0 or encoded_lon == 0:
|
||||
#print "debug: lat or lon zero for longdata %x" % (longdata,)
|
||||
@@ -208,7 +208,7 @@ def cpr_decode(icao24, encoded_lat, encoded_lon, cpr_format, evenlist, oddlist,
|
||||
|
||||
else: #no LKP available
|
||||
#print "debug: icao %x not found. attempting local decode." % icao24
|
||||
[local_lat, local_lon] = cpr_resolve_local([my_lat, my_lon], [encoded_lat, encoded_lon], cpr_format, surface) #try local decoding
|
||||
[local_lat, local_lon] = cpr_resolve_local(my_location, [encoded_lat, encoded_lon], cpr_format, surface) #try local decoding
|
||||
# print "debug: local resolve gives %.6f, %.6f" % (local_lat, local_lon)
|
||||
[rnge, bearing] = range_bearing([my_lat, my_lon], [local_lat, local_lon])
|
||||
if rnge < validrange: #if the local decoding can be guaranteed valid
|
||||
|
||||
@@ -23,11 +23,11 @@ import sqlite3
|
||||
import string, math, threading, time
|
||||
|
||||
class modes_kml(threading.Thread):
|
||||
def __init__(self, dbfile, filename, timeout=5):
|
||||
def __init__(self, dbfile, filename, localpos, timeout=5):
|
||||
threading.Thread.__init__(self)
|
||||
self._filename = filename
|
||||
self._dbfile = dbfile
|
||||
self.my_coords = [37.76225, -122.44254] #there has got to be a better way of getting your coords in here
|
||||
self.my_coords = localpos
|
||||
self._timeout = timeout
|
||||
self.done = False
|
||||
self.setDaemon(1)
|
||||
|
||||
@@ -27,6 +27,9 @@ from cpr import cpr_decode
|
||||
import math
|
||||
|
||||
class modes_parse:
|
||||
def __init__(self, mypos):
|
||||
self.my_location = mypos
|
||||
|
||||
def parse0(self, shortdata, parity, ecc):
|
||||
# shortdata = long(shortdata, 16)
|
||||
#parity = long(parity)
|
||||
@@ -166,7 +169,7 @@ class modes_parse:
|
||||
|
||||
altitude = decode_alt(enc_alt, False)
|
||||
|
||||
[decoded_lat, decoded_lon, rnge, bearing] = cpr_decode(icao24, encoded_lat, encoded_lon, cpr_format, self._evenlist, self._oddlist, self._lkplist, 0, longdata)
|
||||
[decoded_lat, decoded_lon, rnge, bearing] = cpr_decode(self.my_location, icao24, encoded_lat, encoded_lon, cpr_format, self._evenlist, self._oddlist, self._lkplist, 0, longdata)
|
||||
|
||||
return [altitude, decoded_lat, decoded_lon, rnge, bearing]
|
||||
|
||||
|
||||
@@ -26,6 +26,9 @@ import modes_parse
|
||||
import math
|
||||
|
||||
class modes_output_print(modes_parse.modes_parse):
|
||||
def __init__(self, mypos):
|
||||
modes_parse.modes_parse.__init__(self, mypos)
|
||||
|
||||
def parse(self, message):
|
||||
[msgtype, shortdata, longdata, parity, ecc, reference] = message.split()
|
||||
|
||||
|
||||
@@ -26,7 +26,8 @@ import modes_parse
|
||||
from datetime import *
|
||||
|
||||
class modes_output_sbs1(modes_parse.modes_parse):
|
||||
def __init__(self):
|
||||
def __init__(self, mypos):
|
||||
modes_parse.modes_parse.__init__(self, mypos)
|
||||
self._s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
self._s.bind(('', 30003))
|
||||
self._s.listen(1)
|
||||
|
||||
@@ -25,7 +25,8 @@ import modes_parse
|
||||
import sqlite3
|
||||
|
||||
class modes_output_sql(modes_parse.modes_parse):
|
||||
def __init__(self, filename):
|
||||
def __init__(self, mypos, filename):
|
||||
modes_parse.modes_parse.__init__(self, mypos)
|
||||
#create the database
|
||||
self.db = sqlite3.connect(filename)
|
||||
#now execute a schema to create the tables you need
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
my_position = [37.76225, -122.44254]
|
||||
|
||||
from gnuradio import gr, gru, optfir, eng_notation, blks2, air
|
||||
from gnuradio import uhd
|
||||
from gnuradio.eng_option import eng_option
|
||||
@@ -149,18 +151,18 @@ if __name__ == '__main__':
|
||||
updates = [] #registry of plugin update functions
|
||||
|
||||
if options.kml is not None:
|
||||
sqlport = modes_output_sql('adsb.db') #create a SQL parser to push stuff into SQLite
|
||||
sqlport = modes_output_sql(my_position, '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
|
||||
kmlgen = modes_kml('adsb.db', options.kml, my_position) #create a KML generating thread which reads the database
|
||||
|
||||
if options.sbs1 is True:
|
||||
sbs1port = modes_output_sbs1()
|
||||
sbs1port = modes_output_sbs1(my_position)
|
||||
outputs.append(sbs1port.output)
|
||||
updates.append(sbs1port.add_pending_conns)
|
||||
|
||||
if options.no_print is not True:
|
||||
outputs.append(modes_output_print().parse)
|
||||
outputs.append(modes_output_print(my_position).parse)
|
||||
|
||||
fg = adsb_rx_block(options, args, queue)
|
||||
runner = top_block_runner(fg)
|
||||
|
||||
Reference in New Issue
Block a user