From dd908c09172208bf4080886202c4f74ddaeb552d Mon Sep 17 00:00:00 2001 From: Marat Fayzullin Date: Fri, 17 Mar 2023 23:41:34 -0400 Subject: [PATCH] Picking latest changes from the main OWRX repo. --- owrx/dsp.py | 25 +++++++++++++------------ owrx/service/__init__.py | 10 ++++++++-- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/owrx/dsp.py b/owrx/dsp.py index 2eef9db6..fb174186 100644 --- a/owrx/dsp.py +++ b/owrx/dsp.py @@ -679,19 +679,20 @@ class DspManager(SdrSourceEventClient, ClientDemodulatorSecondaryDspEventClient) def unpickler(data): b = data.tobytes() # If we know it's not pickled, let us not unpickle - if len(b)<2 or b[0]!=0x80 or b[1]<0x03: + if len(b) < 2 or b[0] != 0x80 or not 3 <= b[1] <= pickle.HIGHEST_PROTOCOL: callback(b.decode("ascii")) - else: - io = BytesIO(b) - try: - while True: - callback(pickle.load(io)) - except EOFError: - pass - except pickle.UnpicklingError: - callback(b.decode("ascii")) - except ValueError: - pass + return + + io = BytesIO(b) + try: + while True: + callback(pickle.load(io)) + except EOFError: + pass + except pickle.UnpicklingError: + callback(b.decode("ascii")) + except ValueError: + pass return unpickler diff --git a/owrx/service/__init__.py b/owrx/service/__init__.py index 6857ae03..0ffe6d0c 100644 --- a/owrx/service/__init__.py +++ b/owrx/service/__init__.py @@ -174,11 +174,17 @@ class ServiceHandler(SdrSourceEventClient): addService(dial, self.source) def get_min_max(self, group): + def find_bandpass(dial): + mode = Modes.findByModulation(dial["mode"]) + if "underlying" in dial: + mode = mode.for_underlying(dial["underlying"]) + return mode.get_bandpass() + frequencies = sorted(group, key=lambda f: f["frequency"]) lowest = frequencies[0] - min = lowest["frequency"] + Modes.findByModulation(lowest["mode"]).get_bandpass().low_cut + min = lowest["frequency"] + find_bandpass(lowest).low_cut highest = frequencies[-1] - max = highest["frequency"] + Modes.findByModulation(highest["mode"]).get_bandpass().high_cut + max = highest["frequency"] + find_bandpass(highest).high_cut return min, max def get_center_frequency(self, group):