From ea67340cabbf2316b6e99dfd0c91d1ebf4bbdc3a Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sun, 13 Oct 2019 14:17:32 +0200 Subject: [PATCH] display message when sdr unavailable --- owrx/connection.py | 8 ++++++++ owrx/source.py | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/owrx/connection.py b/owrx/connection.py index da6365d..ab0cabb 100644 --- a/owrx/connection.py +++ b/owrx/connection.py @@ -142,6 +142,11 @@ class OpenWebRxReceiverClient(Client): def setSdr(self, id=None): next = SdrService.getSource(id) + + if next is None: + self.handleSdrFailure("sdr device failed") + return + if next == self.sdr: return @@ -180,6 +185,9 @@ class OpenWebRxReceiverClient(Client): self.sdr.addSpectrumClient(self) + def handleSdrFailure(self, message): + self.write_sdr_error(message) + def startDsp(self): if self.dsp is None: self.dsp = DspManager(self, self.sdr) diff --git a/owrx/source.py b/owrx/source.py index 80e125c..2d576ce 100644 --- a/owrx/source.py +++ b/owrx/source.py @@ -76,10 +76,14 @@ class SdrService(object): def getSource(id=None): SdrService.loadProps() sources = SdrService.getSources() + if not sources: + return None if id is None: # TODO: configure default sdr in config? right now it will pick the first one off the list. id = list(sources.keys())[0] + if not id in sources: + return None return sources[id] @staticmethod @@ -654,7 +658,7 @@ class DspManager(csdr.output): def onSdrFailed(self): logger.debug("received onSdrFailed, shutting down DspSource") self.dsp.stop() - self.handler.write_sdr_error("sdr failed") + self.handler.handleSdrFailure("sdr device failed") class CpuUsageThread(threading.Thread):