fixes to parsing telemetry messages
This commit is contained in:
parent
34b4cd6ded
commit
f2a7993b52
17
aprs.py
17
aprs.py
|
|
@ -572,16 +572,19 @@ def parse(raw_sentence):
|
||||||
# check if it's a telemetry configuration message
|
# check if it's a telemetry configuration message
|
||||||
match = re.findall(r"^([a-zA-Z0-9 ]{9}):(PARM|UNIT|EQNS|BITS)\.(.*)$", body)
|
match = re.findall(r"^([a-zA-Z0-9 ]{9}):(PARM|UNIT|EQNS|BITS)\.(.*)$", body)
|
||||||
if match:
|
if match:
|
||||||
logger.debug("Attempting to parse message packet with telemetry setup")
|
logger.debug("Attempting to parse telemetry message packet")
|
||||||
addresse,form,body = match[0]
|
addresse,form,body = match[0]
|
||||||
|
|
||||||
parsed.update({'format': 'telemetry-message', 'addresse': addresse.rstrip(' ')})
|
parsed.update({'format': 'telemetry-message', 'addresse': addresse.rstrip(' ')})
|
||||||
|
|
||||||
if form in ["PARM", "UNIT"]:
|
if form in ["PARM", "UNIT"]:
|
||||||
if not re.match(r"^([ -~]{1,7}){5,13}$", body):
|
vals = body.split(',')
|
||||||
raise ParseError("incorrect format of %s" % form)
|
|
||||||
|
|
||||||
parsed.update({ 't%s' % form : body.split(',') })
|
for val in vals:
|
||||||
|
if not re.match(r"^([ -~]{1,7}|)$", val):
|
||||||
|
raise ParseError("incorrect format of %s" % form)
|
||||||
|
|
||||||
|
parsed.update({ 't%s' % form : vals })
|
||||||
elif form == "EQNS":
|
elif form == "EQNS":
|
||||||
eqns = body.split(',')
|
eqns = body.split(',')
|
||||||
teqns = [[] for i in range(5)]
|
teqns = [[] for i in range(5)]
|
||||||
|
|
@ -591,13 +594,13 @@ def parse(raw_sentence):
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
for val in eqns:
|
for val in eqns:
|
||||||
if not re.match("^[-]?\d*\.?\d+$", val):
|
if not re.match("^([-]?\d*\.?\d+|)$", val):
|
||||||
raise ParseError("value at %d is not a number in %s" % form)
|
raise ParseError("value at %d is not a number in %s" % (count,form))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
val = int(val)
|
val = int(val)
|
||||||
except:
|
except:
|
||||||
val = float(val)
|
val = float(val) if val != "" else ""
|
||||||
|
|
||||||
teqns[int(math.floor(count / 3))].append(val)
|
teqns[int(math.floor(count / 3))].append(val)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue