fix debugging; synchronize startup

This commit is contained in:
Jakob Ketterl 2020-04-30 22:54:44 +02:00
parent 1764abe65f
commit 56f3f089a1
2 changed files with 8 additions and 5 deletions

View File

@ -229,7 +229,6 @@ class OpenWebRxReceiverClient(Client):
def startDsp(self):
while True:
logger.debug("starting dsp...")
self.getDsp().start()
if self.sdr.getState() == SdrSource.STATE_FAILED:
self.write_log_message('SDR device "{0}" has failed, selecting new device'.format(self.sdr.getName()))
@ -247,7 +246,6 @@ class OpenWebRxReceiverClient(Client):
super().close()
def stopDsp(self):
logger.debug("stopDsp")
if self.dsp is not None:
self.dsp.stop()
self.dsp = None
@ -270,7 +268,6 @@ class OpenWebRxReceiverClient(Client):
def getDsp(self):
if self.dsp is None:
logger.debug("new DSP")
self.dsp = DspManager(self, self.sdr)
return self.dsp

View File

@ -130,14 +130,17 @@ class DspManager(csdr.output):
self.props.wireProperty("secondary_offset_freq", self.dsp.set_secondary_offset_freq),
]
self.startOnAvailable = False
self.sdrSource.addClient(self)
super().__init__()
def start(self):
logger.debug(self.sdrSource)
if self.sdrSource.isAvailable():
self.dsp.start()
else:
self.startOnAvailable = True
def receive_output(self, t, read_fn):
logger.debug("adding new output of type %s", t)
@ -156,6 +159,7 @@ class DspManager(csdr.output):
def stop(self):
self.dsp.stop()
self.startOnAvailable = False
self.sdrSource.removeClient(self)
for sub in self.subscriptions:
sub.cancel()
@ -174,7 +178,9 @@ class DspManager(csdr.output):
def onStateChange(self, state):
if state == SdrSource.STATE_RUNNING:
logger.debug("received STATE_RUNNING, attempting DspSource restart")
self.dsp.start()
if self.startOnAvailable:
self.dsp.start()
self.startOnAvailable = False
elif state == SdrSource.STATE_STOPPING:
logger.debug("received STATE_STOPPING, shutting down DspSource")
self.dsp.stop()