Add try/catch around az_map's parsing.

This commit is contained in:
Nick Foster 2013-06-18 11:45:58 -07:00
parent d508b39b31
commit 29f8a2c1b4

View File

@ -26,6 +26,7 @@ from PyQt4 import QtCore, QtGui
import threading import threading
import math import math
import air_modes import air_modes
from air_modes.exceptions import *
# model has max range vs. azimuth in n-degree increments # model has max range vs. azimuth in n-degree increments
@ -174,24 +175,27 @@ class az_map_output(air_modes.parse):
self.model = model self.model = model
def output(self, msg): def output(self, msg):
[data, ecc, reference, timestamp] = msg.split() try:
data = air_modes.modes_reply(long(data, 16)) [data, ecc, reference, timestamp] = msg.split()
ecc = long(ecc, 16) data = air_modes.modes_reply(long(data, 16))
rssi = 10.*math.log10(float(reference)) ecc = long(ecc, 16)
msgtype = data["df"] rssi = 10.*math.log10(float(reference))
now = time.time() msgtype = data["df"]
now = time.time()
if msgtype == 17: if msgtype == 17:
icao = data["aa"] icao = data["aa"]
subtype = data["ftc"] subtype = data["ftc"]
distance, altitude, bearing = [0,0,0] distance, altitude, bearing = [0,0,0]
if 5 <= subtype <= 8: if 5 <= subtype <= 8:
(ground_track, decoded_lat, decoded_lon, distance, bearing) = self.parseBDS06(data) (ground_track, decoded_lat, decoded_lon, distance, bearing) = self.parseBDS06(data)
altitude = 0 altitude = 0
elif 9 <= subtype <= 18: elif 9 <= subtype <= 18:
(altitude, decoded_lat, decoded_lon, distance, bearing) = self.parseBDS05(data) (altitude, decoded_lat, decoded_lon, distance, bearing) = self.parseBDS05(data)
self.model.addRecord(bearing, altitude, distance) self.model.addRecord(bearing, altitude, distance)
except ADSBError:
pass
############################## ##############################