de-duplicate; better logging

This commit is contained in:
Jakob Ketterl
2019-07-28 11:40:58 +02:00
parent 7689e31640
commit a15e625692
3 changed files with 20 additions and 37 deletions

View File

@ -16,27 +16,14 @@ class ServiceOutput(output):
def add_output(self, t, read_fn):
logger.debug("got output of type {0}".format(t))
def pump(read, write):
def copy():
run = True
while run:
data = read()
if data is None or (isinstance(data, bytes) and len(data) == 0):
logger.warning("zero read on {0}".format(t))
run = False
else:
write(data)
return copy
if t == "wsjt_demod":
parser = WsjtParser(WsjtHandler())
parser.setDialFrequency(self.frequency)
target = pump(read_fn, parser.parse)
target = self.pump(read_fn, parser.parse)
else:
# dump everything else
# TODO rewrite the output mechanism in a way that avoids producing unnecessary data
target = pump(read_fn, lambda x: None)
target = self.pump(read_fn, lambda x: None)
threading.Thread(target=target).start()

View File

@ -515,20 +515,7 @@ class DspManager(csdr.output):
}
write = writers[t]
def pump(read, write):
def copy():
run = True
while run:
data = read()
if data is None or (isinstance(data, bytes) and len(data) == 0):
logger.warning("zero read on {0}".format(t))
run = False
else:
write(data)
return copy
threading.Thread(target=pump(read_fn, write)).start()
threading.Thread(target=self.pump(read_fn, write)).start()
def stop(self):
self.dsp.stop()