some quick nudges to allow reconfiguration of the rtl_sdr command on the fly
This commit is contained in:
parent
fa05249a9d
commit
9fc77c2804
20
csdr.py
20
csdr.py
@ -26,6 +26,7 @@ import os
|
||||
import code
|
||||
import signal
|
||||
import fcntl
|
||||
import threading
|
||||
|
||||
class dsp:
|
||||
|
||||
@ -282,6 +283,8 @@ class dsp:
|
||||
return float(line[:-1])
|
||||
except ValueError:
|
||||
return 0
|
||||
else:
|
||||
time.sleep(1)
|
||||
|
||||
def mkfifo(self,path):
|
||||
try:
|
||||
@ -351,6 +354,15 @@ class dsp:
|
||||
if self.csdr_dynamic_bufsize: my_env["CSDR_DYNAMIC_BUFSIZE_ON"]="1";
|
||||
if self.csdr_print_bufsizes: my_env["CSDR_PRINT_BUFSIZES"]="1";
|
||||
self.process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True, preexec_fn=os.setpgrp, env=my_env)
|
||||
|
||||
def watch_thread():
|
||||
rc = self.process.wait()
|
||||
print("dsp thread ended with rc={0}".format(rc))
|
||||
if (self.running):
|
||||
self.restart()
|
||||
|
||||
threading.Thread(target = watch_thread).start()
|
||||
|
||||
self.running = True
|
||||
|
||||
#open control pipes for csdr and send initialization data
|
||||
@ -372,7 +384,13 @@ class dsp:
|
||||
return self.process.stdout.read(size)
|
||||
|
||||
def stop(self):
|
||||
self.running = False
|
||||
if hasattr(self, "process"):
|
||||
try:
|
||||
os.killpg(os.getpgid(self.process.pid), signal.SIGTERM)
|
||||
except ProcessLookupError:
|
||||
# been killed by something else, ignore
|
||||
pass
|
||||
self.stop_secondary_demodulator()
|
||||
#if(self.process.poll()!=None):return # returns None while subprocess is running
|
||||
#while(self.process.poll()==None):
|
||||
@ -403,8 +421,6 @@ class dsp:
|
||||
# try: os.unlink(self.iqtee2_pipe)
|
||||
# except: print "[openwebrx-dsp-plugin:csdr] stop() :: unlink failed: " + self.iqtee2_pipe
|
||||
|
||||
self.running = False
|
||||
|
||||
def restart(self):
|
||||
self.stop()
|
||||
self.start()
|
||||
|
@ -72,6 +72,7 @@ class WebSocketMessageHandler(object):
|
||||
def __init__(self):
|
||||
self.handshake = None
|
||||
self.client = None
|
||||
self.dsp = None
|
||||
|
||||
def handleTextMessage(self, conn, message):
|
||||
pm = PropertyManager.getSharedInstance()
|
||||
|
@ -126,11 +126,12 @@ class SpectrumThread(threading.Thread):
|
||||
while self.doRun:
|
||||
data=dsp.read(bytes_to_read)
|
||||
if len(data) == 0:
|
||||
self.shutdown()
|
||||
time.sleep(1)
|
||||
else:
|
||||
for c in self.clients:
|
||||
c.write_spectrum_data(data)
|
||||
|
||||
dsp.stop()
|
||||
print("spectrum thread shut down")
|
||||
|
||||
def add_client(self, c):
|
||||
|
Loading…
Reference in New Issue
Block a user