Update common.py
This comprehends the PHGR custom message that MUST be terminated by "/" and the standard PHG message of 4 chars. The math "Should" be done for the "R" in terms of direction but that has been omitted.
This commit is contained in:
parent
a3e205f001
commit
dc90983cb6
|
|
@ -151,17 +151,23 @@ def parse_data_extentions(body):
|
||||||
if nrq.isdigit():
|
if nrq.isdigit():
|
||||||
parsed.update({'nrq': int(nrq)})
|
parsed.update({'nrq': int(nrq)})
|
||||||
else:
|
else:
|
||||||
match = re.findall(r"^(PHG(\d[\x30-\x7e]\d\d[0-9A-Z]?))", body)
|
match = re.findall(r"^(PHG(\d[\x30-\x7e]\d\d[0-9A-Z]?\/))", body)
|
||||||
if match:
|
if match:
|
||||||
ext, phg = match[0]
|
ext, phg = match[0]
|
||||||
body = body[len(ext):]
|
body = body[len(ext):]
|
||||||
parsed.update({'phg': phg})
|
parsed.update({'phg': phg})
|
||||||
else:
|
else:
|
||||||
match = re.findall(r"^RNG(\d{4})", body)
|
match = re.findall(r"^(PHG(\d[\x30-\x7e]\d\d))", body)
|
||||||
if match:
|
if match:
|
||||||
rng = match[0]
|
ext, phg = match[0]
|
||||||
body = body[7:]
|
body = body[len(ext):]
|
||||||
parsed.update({'rng': int(rng) * 1.609344}) # miles to km
|
parsed.update({'phg': phg})
|
||||||
|
else:
|
||||||
|
match = re.findall(r"^RNG(\d{4})", body)
|
||||||
|
if match:
|
||||||
|
rng = match[0]
|
||||||
|
body = body[7:]
|
||||||
|
parsed.update({'rng': int(rng) * 1.609344}) # miles to km
|
||||||
|
|
||||||
return body, parsed
|
return body, parsed
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue