diff --git a/owrx/pskreporter.py b/owrx/pskreporter.py index 856d4bb..5ecf599 100644 --- a/owrx/pskreporter.py +++ b/owrx/pskreporter.py @@ -115,6 +115,8 @@ class Uploader(object): def getPackets(self, spots): encoded = [self.encodeSpot(spot) for spot in spots] + # filter out any erroneous encodes + encoded = [e for e in encoded if e is not None] def chunks(l, n): """Yield successive n-sized chunks from l.""" @@ -150,16 +152,20 @@ class Uploader(object): return [len(s)] + list(s.encode("utf-8")) def encodeSpot(self, spot): - return bytes( - self.encodeString(spot["callsign"]) - + list(int(spot["freq"]).to_bytes(4, "big")) - + list(int(spot["db"]).to_bytes(1, "big", signed=True)) - + self.encodeString(spot["mode"]) - + self.encodeString(spot["locator"]) - # informationsource. 1 means "automatically extracted - + [0x01] - + list(int(spot["timestamp"] / 1000).to_bytes(4, "big")) - ) + try: + return bytes( + self.encodeString(spot["callsign"]) + + list(int(spot["freq"]).to_bytes(4, "big")) + + list(int(spot["db"]).to_bytes(1, "big", signed=True)) + + self.encodeString(spot["mode"]) + + self.encodeString(spot["locator"]) + # informationsource. 1 means "automatically extracted + + [0x01] + + list(int(spot["timestamp"] / 1000).to_bytes(4, "big")) + ) + except Exception: + logger.exception("Error while encoding spot for pskreporter") + return None def getReceiverInformationHeader(self): return bytes(