rossengeorgiev / aprs-python

📡 Python module for working with APRS
http://aprs-python.readthedocs.io/en/latest/
GNU General Public License v2.0
113 stars 35 forks source link

Error while parsing PHGR #83

Open mprilepok opened 1 year ago

mprilepok commented 1 year ago

I got error during parsing PHG parameter with letter on the end of the value

APRS Packet: b'PA0AGO-11>APRS,TCPIP*,qAC,FOURTH:@072239z5150.54N/00441.71E#PHG1230I/A=000012 RX ONLY! RAZ IGATE' Traceback (most recent call last): File "/home/pi/test.py", line 61, in AIS.consumer(on_message) File "/home/pi/.local/lib/python3.9/site-packages/aprslib/inet.py", line 185, in consumer callback(self._parse(line)) File "/home/pi/.local/lib/python3.9/site-packages/aprslib/parsing/init.py", line 134, in parse _try_toparse_body(packet_type, body, parsed) File "/home/pi/.local/lib/python3.9/site-packages/aprslib/parsing/init.py", line 209, in _try_toparse_body body, result = parse_position(packet_type, body) File "/home/pi/.local/lib/python3.9/site-packages/aprslib/parsing/position.py", line 76, in parse_position parse_comment(body, parsed) File "/home/pi/.local/lib/python3.9/site-packages/aprslib/parsing/common.py", line 118, in parse_comment body, result = parse_data_extentions(body) File "/home/pi/.local/lib/python3.9/site-packages/aprslib/parsing/common.py", line 196, in parse_data_extentions parsed.update({'phg_rate': int(phgr[0], 16)}) # as decimal ValueError: invalid literal for int() with base 16: 'I'

wb2osz commented 6 months ago

This is rather obscure, but it is valid. Usually PHG is followed by exactly 4 digits. There is a new form ( http://www.aprs.org/aprs12/probes.txt ) , that I don't think I ever observed before, where and an additional digit or upper case letter AND a slash can be added. This specific example raises an interesting question. Would the following altitude be recognized? PHG9999X/ would require the / to know that another character should be processed after the usual 4 digits. We would not want the / to appear in the comment presented to the application user. it seems to me that the following A=999999 would not be recognized as an altitude and would be considered part of the comment text.

Unfortunately the tocall field is "APRS" so we have no clue what generated this packet.

73, John WB2OSZ