diff --git a/csdr.py b/csdr.py index a7f1f89..2d0d310 100755 --- a/csdr.py +++ b/csdr.py @@ -374,7 +374,6 @@ class dsp: self.set_squelch_level(self.squelch_level) if self.smeter_pipe != None: self.smeter_pipe_file=open(self.smeter_pipe,"r") - self.set_pipe_nonblocking(self.smeter_pipe_file) self.start_secondary_demodulator() diff --git a/htdocs/openwebrx.js b/htdocs/openwebrx.js index 980a6ae..f5a17b4 100644 --- a/htdocs/openwebrx.js +++ b/htdocs/openwebrx.js @@ -1181,6 +1181,9 @@ function on_ws_recv(evt) waterfall_init(); audio_preinit(); break; + case "smeter": + setSmeterAbsoluteValue(json.value); + break; default: console.warn('received message of unknown type', json); } diff --git a/owrx/controllers.py b/owrx/controllers.py index 90e3405..fe4dac2 100644 --- a/owrx/controllers.py +++ b/owrx/controllers.py @@ -1,7 +1,7 @@ import mimetypes from owrx.websocket import WebSocketConnection from owrx.config import PropertyManager -from owrx.source import SpectrumThread, DspThread +from owrx.source import SpectrumThread, DspManager import json class Controller(object): @@ -53,6 +53,8 @@ class SpectrumForwarder(object): self.conn.send(bytes([0x01]) + data) def write_dsp_data(self, data): self.conn.send(bytes([0x02]) + data) + def write_s_meter_level(self, level): + self.conn.send({"type":"smeter","value":level}) class WebSocketMessageHandler(object): def __init__(self): @@ -77,7 +79,7 @@ class WebSocketMessageHandler(object): self.forwarder = SpectrumForwarder(conn) SpectrumThread.getSharedInstance().add_client(self.forwarder) - self.dsp = DspThread(self.forwarder) + self.dsp = DspManager(self.forwarder) else: try: diff --git a/owrx/source.py b/owrx/source.py index e135cde..e1ab9e2 100644 --- a/owrx/source.py +++ b/owrx/source.py @@ -2,7 +2,6 @@ import subprocess from owrx.config import PropertyManager import threading import csdr -import time class RtlNmuxSource(object): def __init__(self): @@ -88,7 +87,7 @@ class SpectrumThread(threading.Thread): SpectrumThread.sharedInstance = None self.doRun = False -class DspThread(threading.Thread): +class DspManager(object): def __init__(self, handler): self.doRun = True self.handler = handler @@ -138,12 +137,21 @@ class DspThread(threading.Thread): super().__init__() - def run(self): + def start(self): self.dsp.start() + threading.Thread(target = self.readDspOutput).start() + threading.Thread(target = self.readSMeterOutput).start() + + def readDspOutput(self): while (self.doRun): data = self.dsp.read(256) self.handler.write_dsp_data(data) + def readSMeterOutput(self): + while (self.doRun): + level = self.dsp.get_smeter_level() + self.handler.write_s_meter_level(level) + def stop(self): self.doRun = False