now able to parse object report format
This commit is contained in:
parent
e0a71de244
commit
703704a005
|
|
@ -8,6 +8,7 @@ Parsing of packets is also possible, but the entire spec is not fully implemenet
|
|||
The following is supported:
|
||||
|
||||
- normal/compressed position reports
|
||||
- objects
|
||||
- mic-e position report
|
||||
- messages (inc. telemetry, bulletins, etc)
|
||||
- base91 comment telemetry extention
|
||||
|
|
|
|||
|
|
@ -119,7 +119,6 @@ def parse(packet):
|
|||
# , - invalid/test format
|
||||
# - - unused
|
||||
# . - reserved
|
||||
# ; - object report
|
||||
# < - station capabilities
|
||||
# ? - general query format
|
||||
# T - telemetry report
|
||||
|
|
@ -130,7 +129,7 @@ def parse(packet):
|
|||
# _ - positionless weather report
|
||||
# { - user defined
|
||||
# } - 3rd party traffic
|
||||
if packet_type in '#$%)*,;<?T[_{}':
|
||||
if packet_type in '#$%)*,<?T[_{}':
|
||||
raise UnknownFormat("format is not supported", packet)
|
||||
|
||||
# STATUS PACKET
|
||||
|
|
@ -163,17 +162,31 @@ def parse(packet):
|
|||
parsed.update(result)
|
||||
|
||||
# postion report (regular or compressed)
|
||||
elif (packet_type in '!=/@' or
|
||||
elif (packet_type in '!=/@;' or
|
||||
0 <= body.find('!') < 40): # page 28 of spec (PDF)
|
||||
|
||||
if packet_type not in '!=/@':
|
||||
if packet_type not in '!=/@;':
|
||||
prefix, body = body.split('!', 1)
|
||||
packet_type = '!'
|
||||
|
||||
parsed.update({"messagecapable": packet_type in '@='})
|
||||
if packet_type == ';':
|
||||
logger.debug("Attempting to parse object report format")
|
||||
match = re.findall(r"^([ -~]{9})(\*|_)", body)
|
||||
if match:
|
||||
name, flag = match[0]
|
||||
parsed.update({
|
||||
'object_name': name,
|
||||
'alive': flag == '*',
|
||||
})
|
||||
|
||||
body = body[10:]
|
||||
else:
|
||||
raise ParseError("invalid format")
|
||||
else:
|
||||
parsed.update({"messagecapable": packet_type in '@='})
|
||||
|
||||
# decode timestamp
|
||||
if packet_type in "/@":
|
||||
if packet_type in "/@;":
|
||||
body, result = _parse_timestamp(body, packet_type)
|
||||
parsed.update(result)
|
||||
|
||||
|
|
@ -197,6 +210,12 @@ def parse(packet):
|
|||
body, result = _parse_comment(body)
|
||||
parsed.update(result)
|
||||
|
||||
if packet_type == ';':
|
||||
parsed.update({
|
||||
'object_format': parsed['format'],
|
||||
'format': 'object',
|
||||
})
|
||||
|
||||
# capture ParseErrors and attach the packet
|
||||
except ParseError as exp:
|
||||
exp.packet = packet
|
||||
|
|
|
|||
Loading…
Reference in New Issue