display message when sdr unavailable

This commit is contained in:
Jakob Ketterl 2019-10-13 14:17:32 +02:00
parent 5b61f8c7a3
commit ea67340cab
2 changed files with 13 additions and 1 deletions

View File

@ -142,6 +142,11 @@ class OpenWebRxReceiverClient(Client):
def setSdr(self, id=None): def setSdr(self, id=None):
next = SdrService.getSource(id) next = SdrService.getSource(id)
if next is None:
self.handleSdrFailure("sdr device failed")
return
if next == self.sdr: if next == self.sdr:
return return
@ -180,6 +185,9 @@ class OpenWebRxReceiverClient(Client):
self.sdr.addSpectrumClient(self) self.sdr.addSpectrumClient(self)
def handleSdrFailure(self, message):
self.write_sdr_error(message)
def startDsp(self): def startDsp(self):
if self.dsp is None: if self.dsp is None:
self.dsp = DspManager(self, self.sdr) self.dsp = DspManager(self, self.sdr)

View File

@ -76,10 +76,14 @@ class SdrService(object):
def getSource(id=None): def getSource(id=None):
SdrService.loadProps() SdrService.loadProps()
sources = SdrService.getSources() sources = SdrService.getSources()
if not sources:
return None
if id is None: if id is None:
# TODO: configure default sdr in config? right now it will pick the first one off the list. # TODO: configure default sdr in config? right now it will pick the first one off the list.
id = list(sources.keys())[0] id = list(sources.keys())[0]
if not id in sources:
return None
return sources[id] return sources[id]
@staticmethod @staticmethod
@ -654,7 +658,7 @@ class DspManager(csdr.output):
def onSdrFailed(self): def onSdrFailed(self):
logger.debug("received onSdrFailed, shutting down DspSource") logger.debug("received onSdrFailed, shutting down DspSource")
self.dsp.stop() self.dsp.stop()
self.handler.write_sdr_error("sdr failed") self.handler.handleSdrFailure("sdr device failed")
class CpuUsageThread(threading.Thread): class CpuUsageThread(threading.Thread):