diff --git a/python/cpr.py b/python/cpr.py index a96b24d..e20ba11 100644 --- a/python/cpr.py +++ b/python/cpr.py @@ -189,9 +189,9 @@ def range_bearing(loc_a, loc_b): class cpr_decoder: def __init__(self, my_location): self.my_location = my_location - self.lkplist = [] - self.evenlist = [] - self.oddlist = [] + self.lkplist = {} + self.evenlist = {} + self.oddlist = {} def set_location(new_location): self.my_location = new_location @@ -202,13 +202,13 @@ class cpr_decoder: if time.time() - item[2] > 900: del poslist[key] - def decode(icao24, encoded_lat, encoded_lon, cpr_format, surface): + def decode(self, icao24, encoded_lat, encoded_lon, cpr_format, surface): #def cpr_decode(my_location, icao24, encoded_lat, encoded_lon, cpr_format, evenlist, oddlist, lkplist, surface): #add the info to the position reports list for global decoding if cpr_format==1: - oddlist[icao24] = [encoded_lat, encoded_lon, time.time()] + self.oddlist[icao24] = [encoded_lat, encoded_lon, time.time()] else: - evenlist[icao24] = [encoded_lat, encoded_lon, time.time()] + self.evenlist[icao24] = [encoded_lat, encoded_lon, time.time()] [decoded_lat, decoded_lon] = [None, None] diff --git a/python/modes_kml.py b/python/modes_kml.py index 129bbce..af28bca 100644 --- a/python/modes_kml.py +++ b/python/modes_kml.py @@ -38,12 +38,15 @@ class modes_kml(threading.Thread): def run(self): while self.done is False: - self.output() + self.write() time.sleep(self._timeout) self.done = True - - def output(self): + + def output(self, string): + self._sqlobj.insert(string) + + def write(self): self._db = sqlite3.connect(self._dbname) kmlstr = self.genkml() if kmlstr is not None: diff --git a/python/modes_parse.py b/python/modes_parse.py index 9c0d4a1..ec041e3 100644 --- a/python/modes_parse.py +++ b/python/modes_parse.py @@ -23,13 +23,13 @@ import time, os, sys from string import split, join from altitude import decode_alt -from cpr import cpr_decode +from cpr import cpr_decoder import math class modes_parse: def __init__(self, mypos): self.my_location = mypos - self.cpr_decoder = cpr_decoder(self.my_location) + self.cpr = cpr_decoder(self.my_location) def parse0(self, shortdata, parity, ecc): # shortdata = long(shortdata, 16) @@ -160,12 +160,12 @@ class modes_parse: altitude = decode_alt(enc_alt, False) - [decoded_lat, decoded_lon, rnge, bearing] = cpr_decoder.decode(icao24, encoded_lat, encoded_lon, cpr_format, 0) + [decoded_lat, decoded_lon, rnge, bearing] = self.cpr.decode(icao24, encoded_lat, encoded_lon, cpr_format, 0) return [altitude, decoded_lat, decoded_lon, rnge, bearing] -#welp turns out it looks like there's only 17 bits in the BDS0,6 ground packet after all. fuck. + #welp turns out it looks like there's only 17 bits in the BDS0,6 ground packet after all. def parseBDS06(self, shortdata, longdata, parity, ecc): icao24 = shortdata & 0xFFFFFF @@ -177,7 +177,7 @@ class modes_parse: altitude = 0 - [decoded_lat, decoded_lon, rnge, bearing] = cpr_decoder.decode(icao24, encoded_lat, encoded_lon, cpr_format, 1) + [decoded_lat, decoded_lon, rnge, bearing] = self.cpr.decode(icao24, encoded_lat, encoded_lon, cpr_format, 1) return [altitude, decoded_lat, decoded_lon, rnge, bearing]