Skip to content

Commit b9473dd

Browse files
committed
Account for telemetry with spaces after commas
Technically invalid, but we should try and parse them anyway as it's just whitespace.
1 parent fb95db6 commit b9473dd

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

aprslib/parsing/telemetry.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ def parse_telemetry_config(body):
6969
teqns = [0, 1, 0] * 5
7070

7171
for idx, val in enumerate(eqns):
72+
# Strip whitespace from values (some packets have spaces after commas)
73+
val = val.strip()
7274
if not re.match(r"^([-]?\d*\.?\d+|)$", val):
7375
raise ParseError("value at %d is not a number in %s" % (idx+1, form))
7476
else:

tests/test_parse_telemetry_config.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,19 @@ def test_parse_telemetry_config_eqns(self):
108108
self.assertIsInstance(result['tEQNS'], list)
109109
self.assertEqual(len(result['tEQNS']), 5)
110110

111+
def test_parse_telemetry_config_eqns_with_spaces(self):
112+
"""Test EQNS telemetry config with spaces after commas (real-world packet)"""
113+
packet = "IZ6RND>IESPX,TCPIP*,qAC,T2NL::IZ6RND :EQNS.0,0.392,-20, 0,0.235,0, 0,0.1,0, 0,1,0, 0,1,0"
114+
result = parse(packet)
115+
116+
self.assertEqual(result['format'], 'telemetry-message')
117+
self.assertIn('tEQNS', result)
118+
self.assertIsInstance(result['tEQNS'], list)
119+
self.assertEqual(len(result['tEQNS']), 5)
120+
# Verify the values are correctly parsed (spaces should be stripped)
121+
expected = [[0, 0.392, -20], [0, 0.235, 0], [0, 0.1, 0], [0, 1, 0], [0, 1, 0]]
122+
self.assertEqual(result['tEQNS'], expected)
123+
111124
def test_bits_without_binary_bits(self):
112125
"""Test BITS telemetry config without binary bits (malformed packet)"""
113126
packet = "E25HML-13>APRS,TCPIP*,qAC,T2PERTH::E25HML-13:BITS.ESP8266 Test WX DHT22 version"

0 commit comments

Comments
 (0)