From dc90983cb603a05e94b8314a9cf7e3ef701f983f Mon Sep 17 00:00:00 2001 From: TheCranston Date: Tue, 28 Sep 2021 20:18:11 -0400 Subject: [PATCH] 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. --- aprslib/parsing/common.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/aprslib/parsing/common.py b/aprslib/parsing/common.py index dd8d9cd..2328d72 100644 --- a/aprslib/parsing/common.py +++ b/aprslib/parsing/common.py @@ -151,17 +151,23 @@ def parse_data_extentions(body): if nrq.isdigit(): parsed.update({'nrq': int(nrq)}) 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: - ext, phg = match[0] - body = body[len(ext):] - 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 + ext, phg = match[0] + body = body[len(ext):] + parsed.update({'phg': phg}) + else: + match = re.findall(r"^(PHG(\d[\x30-\x7e]\d\d))", body) + if match: + ext, phg = match[0] + body = body[len(ext):] + 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