From 4e61ed364582ff10dc790a261119d5898468d8ce Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Fri, 9 Jul 2021 13:52:33 +0200 Subject: [PATCH 1/2] handle errors while parsing dprs data --- owrx/meta.py | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/owrx/meta.py b/owrx/meta.py index aa6fd8d..66994d4 100644 --- a/owrx/meta.py +++ b/owrx/meta.py @@ -122,22 +122,25 @@ class DStarEnricher(Enricher): loc = LatLngLocation(meta["lat"], meta["lon"]) Map.getSharedInstance().updateLocation(meta["ourcall"], loc, "D-Star", self.parser.getBand()) if "dprs" in meta: - # we can send the DPRS stuff through our APRS parser to extract the information - # TODO: only third-party parsing accepts this format right now - # TODO: we also need to pass a handler, which is not needed - parser = AprsParser(None) - dprsData = parser.parseThirdpartyAprsData(meta["dprs"]) - if "data" in dprsData: - data = dprsData["data"] - if "lat" in data and "lon" in data: - # TODO: we could actually get the symbols from the parsed APRS data and show that on the meta panel - meta["lat"] = data["lat"] - meta["lon"] = data["lon"] + try: + # we can send the DPRS stuff through our APRS parser to extract the information + # TODO: only third-party parsing accepts this format right now + # TODO: we also need to pass a handler, which is not needed + parser = AprsParser(None) + dprsData = parser.parseThirdpartyAprsData(meta["dprs"]) + if "data" in dprsData: + data = dprsData["data"] + if "lat" in data and "lon" in data: + # TODO: we could actually get the symbols from the parsed APRS data and show that on the meta panel + meta["lat"] = data["lat"] + meta["lon"] = data["lon"] - if "ourcall" in meta: - # send location info to map as well (it will show up with the correct symbol there!) - loc = AprsLocation(data) - Map.getSharedInstance().updateLocation(meta["ourcall"], loc, "DPRS", self.parser.getBand()) + if "ourcall" in meta: + # send location info to map as well (it will show up with the correct symbol there!) + loc = AprsLocation(data) + Map.getSharedInstance().updateLocation(meta["ourcall"], loc, "DPRS", self.parser.getBand()) + except Exception: + logger.exception("Error while parsing DPRS data") return meta From 12c032112bd909ed9bfd7e8b69c2722011b525ef Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Fri, 9 Jul 2021 13:52:59 +0200 Subject: [PATCH 2/2] handle errors caused by values that don't fit into json --- owrx/connection.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/owrx/connection.py b/owrx/connection.py index d36379a..a991eb8 100644 --- a/owrx/connection.py +++ b/owrx/connection.py @@ -376,7 +376,10 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient): self.send(bytes([0x04]) + data) def write_s_meter_level(self, level): - self.send({"type": "smeter", "value": level}) + try: + self.send({"type": "smeter", "value": level}) + except ValueError: + logger.warning("unable to send smeter value: %s", str(level)) def write_cpu_usage(self, usage): self.mp_send({"type": "cpuusage", "value": usage})