Flightgear interface for new parser, minus BDS0,9
This commit is contained in:
parent
f928669094
commit
3d2920b56a
@ -27,40 +27,40 @@ class modes_flightgear(modes_parse.modes_parse):
|
|||||||
self.sock.connect((self.hostname, self.port))
|
self.sock.connect((self.hostname, self.port))
|
||||||
|
|
||||||
def output(self, message):
|
def output(self, message):
|
||||||
[msgtype, shortdata, longdata, parity, ecc, reference, timestamp] = message.split()
|
[data, ecc, reference, timestamp] = message.split()
|
||||||
shortdata = long(shortdata, 16)
|
data = modes_parse.modes_reply(long(data, 16))
|
||||||
longdata = long(longdata, 16)
|
|
||||||
msgtype = int(msgtype)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
msgtype = data["df"]
|
||||||
if msgtype == 17: #ADS-B report
|
if msgtype == 17: #ADS-B report
|
||||||
icao24 = shortdata & 0xFFFFFF
|
icao24 = data["aa"]
|
||||||
subtype = (longdata >> 51) & 0x1F
|
subtype = data["me"]["sub"]
|
||||||
if subtype == 4: #ident packet
|
if subtype == 4: #ident packet
|
||||||
(ident, actype) = self.parseBDS08(shortdata, longdata)
|
(ident, actype) = self.parseBDS08(data)
|
||||||
#select model based on actype
|
#select model based on actype
|
||||||
self.callsigns[icao24] = [ident, actype]
|
self.callsigns[icao24] = [ident, actype]
|
||||||
|
|
||||||
elif 5 <= subtype <= 8: #BDS0,6 pos
|
elif 5 <= subtype <= 8: #BDS0,6 pos
|
||||||
[altitude, decoded_lat, decoded_lon, rnge, bearing] = self.parseBDS06(shortdata, longdata)
|
[altitude, decoded_lat, decoded_lon, rnge, bearing] = self.parseBDS06(data)
|
||||||
self.positions[icao24] = [decoded_lat, decoded_lon, altitude]
|
self.positions[icao24] = [decoded_lat, decoded_lon, altitude]
|
||||||
self.update(icao24)
|
self.update(icao24)
|
||||||
|
|
||||||
elif 9 <= subtype <= 18: #BDS0,5 pos
|
elif 9 <= subtype <= 18: #BDS0,5 pos
|
||||||
[altitude, decoded_lat, decoded_lon, rnge, bearing] = self.parseBDS05(shortdata, longdata)
|
[altitude, decoded_lat, decoded_lon, rnge, bearing] = self.parseBDS05(data)
|
||||||
self.positions[icao24] = [decoded_lat, decoded_lon, altitude]
|
self.positions[icao24] = [decoded_lat, decoded_lon, altitude]
|
||||||
self.update(icao24)
|
self.update(icao24)
|
||||||
|
|
||||||
elif subtype == 19: #velocity
|
elif subtype == 19: #velocity
|
||||||
subsubtype = (longdata >> 48) & 0x07
|
pass #FIXME TODO BDS0,9
|
||||||
if subsubtype == 0:
|
# subsubtype = (longdata >> 48) & 0x07
|
||||||
[velocity, heading, vert_spd, turnrate] = self.parseBDS09_0(shortdata, longdata)
|
# if subsubtype == 0:
|
||||||
elif subsubtype == 1:
|
# [velocity, heading, vert_spd, turnrate] = self.parseBDS09_0(data)
|
||||||
[velocity, heading, vert_spd] = self.parseBDS09_1(shortdata, longdata)
|
# elif subsubtype == 1:
|
||||||
turnrate = 0
|
# [velocity, heading, vert_spd] = self.parseBDS09_1(data)
|
||||||
else:
|
# turnrate = 0
|
||||||
return
|
# else:
|
||||||
self.velocities[icao24] = [velocity, heading, vert_spd, turnrate]
|
# return
|
||||||
|
# self.velocities[icao24] = [velocity, heading, vert_spd, turnrate]
|
||||||
|
|
||||||
except ADSBError:
|
except ADSBError:
|
||||||
pass
|
pass
|
||||||
|
@ -46,12 +46,6 @@ class modes_output_print(modes_parse.modes_parse):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
msgtype = data["df"]
|
msgtype = data["df"]
|
||||||
except NoHandlerError as err:
|
|
||||||
output += "No handler for msgtype %s" % err.msgtype
|
|
||||||
print output
|
|
||||||
return
|
|
||||||
|
|
||||||
try:
|
|
||||||
if msgtype == 0:
|
if msgtype == 0:
|
||||||
output += self.print0(data, ecc)
|
output += self.print0(data, ecc)
|
||||||
elif msgtype == 4:
|
elif msgtype == 4:
|
||||||
@ -63,7 +57,7 @@ class modes_output_print(modes_parse.modes_parse):
|
|||||||
elif msgtype == 17:
|
elif msgtype == 17:
|
||||||
output += self.print17(data)
|
output += self.print17(data)
|
||||||
else:
|
else:
|
||||||
output += "No handler for message type " + str(msgtype) + " (but it's in modes_parse)"
|
output += "No handler for message type " + str(msgtype) + (" from %x" % ecc) + " (but it's in modes_parse)"
|
||||||
print output
|
print output
|
||||||
except NoHandlerError as e:
|
except NoHandlerError as e:
|
||||||
output += "No handler for message type " + str(e.msgtype) + " from %x" % ecc
|
output += "No handler for message type " + str(e.msgtype) + " from %x" % ecc
|
||||||
|
Loading…
Reference in New Issue
Block a user