From 817ec3892554c5302c6647e0eb7cb2d46fbbfb32 Mon Sep 17 00:00:00 2001 From: Bill Mitchell Date: Wed, 7 Feb 2018 10:59:45 -0600 Subject: [PATCH 1/3] When packet type is unsupported, give error message which specifies the packet type. --- aprslib/parsing/__init__.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/aprslib/parsing/__init__.py b/aprslib/parsing/__init__.py index 43e9766..858f955 100644 --- a/aprslib/parsing/__init__.py +++ b/aprslib/parsing/__init__.py @@ -138,6 +138,26 @@ def parse(packet): def _try_toparse_body(packet_type, body, parsed): result = {} + unsupported_formats = { + '#':'raw weather report', + '$':'raw gps', + '%':'agrelo', + '&':'reserved', + '(':'unused', + ')':'item report', + '*':'complete weather report', + '+':'reserved', + '-':'unused', + '.':'reserved', + '<':'station capabilities', + '?':'general query format', + 'T':'telemetry report', + '[':'maidenhead locator beacon', + '\\':'unused', + ']':'unused', + '^':'unused', + '}':'3rd party traffic' + } # NOT SUPPORTED FORMATS # # # - raw weather report @@ -159,7 +179,7 @@ def _try_toparse_body(packet_type, body, parsed): # ^ - unused # } - 3rd party traffic if packet_type in '#$%)* Date: Wed, 7 Feb 2018 12:52:01 -0600 Subject: [PATCH 2/3] If parsing fails on body after succeeding on head, return the partially-parsed packet as part of the error. --- aprslib/parsing/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/aprslib/parsing/__init__.py b/aprslib/parsing/__init__.py index 858f955..376cd0b 100644 --- a/aprslib/parsing/__init__.py +++ b/aprslib/parsing/__init__.py @@ -116,6 +116,7 @@ def parse(packet): # capture ParseErrors and attach the packet except (UnknownFormat, ParseError) as exp: exp.packet = packet + exp.parsed = parsed raise # if we fail all attempts to parse, try beacon packet From abe71698d45adea4b91d1e371bc3dc0b833f062b Mon Sep 17 00:00:00 2001 From: Bill Mitchell Date: Wed, 7 Feb 2018 13:56:28 -0600 Subject: [PATCH 3/3] Added support for third-party packets --- aprslib/parsing/__init__.py | 11 ++++++++--- aprslib/parsing/thirdparty.py | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 aprslib/parsing/thirdparty.py diff --git a/aprslib/parsing/__init__.py b/aprslib/parsing/__init__.py index 376cd0b..b579d8b 100644 --- a/aprslib/parsing/__init__.py +++ b/aprslib/parsing/__init__.py @@ -42,6 +42,7 @@ from aprslib.parsing.mice import * from aprslib.parsing.message import * from aprslib.parsing.telemetry import * from aprslib.parsing.weather import * +from aprslib.parsing.thirdparty import * def _unicode_packet(packet): @@ -157,7 +158,6 @@ def _try_toparse_body(packet_type, body, parsed): '\\':'unused', ']':'unused', '^':'unused', - '}':'3rd party traffic' } # NOT SUPPORTED FORMATS # @@ -178,10 +178,15 @@ def _try_toparse_body(packet_type, body, parsed): # \ - unused # ] - unused # ^ - unused - # } - 3rd party traffic - if packet_type in '#$%)*