get the s-meter back

This commit is contained in:
Jakob Ketterl 2019-05-05 16:17:55 +02:00
parent 7481399908
commit 0f86796e75
4 changed files with 18 additions and 6 deletions

View File

@ -374,7 +374,6 @@ class dsp:
self.set_squelch_level(self.squelch_level) self.set_squelch_level(self.squelch_level)
if self.smeter_pipe != None: if self.smeter_pipe != None:
self.smeter_pipe_file=open(self.smeter_pipe,"r") self.smeter_pipe_file=open(self.smeter_pipe,"r")
self.set_pipe_nonblocking(self.smeter_pipe_file)
self.start_secondary_demodulator() self.start_secondary_demodulator()

View File

@ -1181,6 +1181,9 @@ function on_ws_recv(evt)
waterfall_init(); waterfall_init();
audio_preinit(); audio_preinit();
break; break;
case "smeter":
setSmeterAbsoluteValue(json.value);
break;
default: default:
console.warn('received message of unknown type', json); console.warn('received message of unknown type', json);
} }

View File

@ -1,7 +1,7 @@
import mimetypes import mimetypes
from owrx.websocket import WebSocketConnection from owrx.websocket import WebSocketConnection
from owrx.config import PropertyManager from owrx.config import PropertyManager
from owrx.source import SpectrumThread, DspThread from owrx.source import SpectrumThread, DspManager
import json import json
class Controller(object): class Controller(object):
@ -53,6 +53,8 @@ class SpectrumForwarder(object):
self.conn.send(bytes([0x01]) + data) self.conn.send(bytes([0x01]) + data)
def write_dsp_data(self, data): def write_dsp_data(self, data):
self.conn.send(bytes([0x02]) + data) self.conn.send(bytes([0x02]) + data)
def write_s_meter_level(self, level):
self.conn.send({"type":"smeter","value":level})
class WebSocketMessageHandler(object): class WebSocketMessageHandler(object):
def __init__(self): def __init__(self):
@ -77,7 +79,7 @@ class WebSocketMessageHandler(object):
self.forwarder = SpectrumForwarder(conn) self.forwarder = SpectrumForwarder(conn)
SpectrumThread.getSharedInstance().add_client(self.forwarder) SpectrumThread.getSharedInstance().add_client(self.forwarder)
self.dsp = DspThread(self.forwarder) self.dsp = DspManager(self.forwarder)
else: else:
try: try:

View File

@ -2,7 +2,6 @@ import subprocess
from owrx.config import PropertyManager from owrx.config import PropertyManager
import threading import threading
import csdr import csdr
import time
class RtlNmuxSource(object): class RtlNmuxSource(object):
def __init__(self): def __init__(self):
@ -88,7 +87,7 @@ class SpectrumThread(threading.Thread):
SpectrumThread.sharedInstance = None SpectrumThread.sharedInstance = None
self.doRun = False self.doRun = False
class DspThread(threading.Thread): class DspManager(object):
def __init__(self, handler): def __init__(self, handler):
self.doRun = True self.doRun = True
self.handler = handler self.handler = handler
@ -138,12 +137,21 @@ class DspThread(threading.Thread):
super().__init__() super().__init__()
def run(self): def start(self):
self.dsp.start() self.dsp.start()
threading.Thread(target = self.readDspOutput).start()
threading.Thread(target = self.readSMeterOutput).start()
def readDspOutput(self):
while (self.doRun): while (self.doRun):
data = self.dsp.read(256) data = self.dsp.read(256)
self.handler.write_dsp_data(data) 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): def stop(self):
self.doRun = False self.doRun = False