more work to allow seamless config switching

This commit is contained in:
Jakob Ketterl 2019-05-07 20:06:06 +02:00
parent 35930f79f1
commit 4cd23cf445
5 changed files with 20 additions and 13 deletions

View File

@ -159,7 +159,9 @@ To use a HackRF, compile the HackRF host tools from its "stdout" branch:
# ==== Misc settings ==== # ==== Misc settings ====
shown_center_freq = center_freq #you can change this if you use an upconverter # you can change this if you use an upconverter. formula is:
# shown_center_freq = center_freq + lfo_offset
lfo_offset = 0
client_audio_buffer_size = 5 client_audio_buffer_size = 5
#increasing client_audio_buffer_size will: #increasing client_audio_buffer_size will:

13
csdr.py
View File

@ -211,8 +211,11 @@ class dsp:
if self.fft_compression=="adpcm": return (self.secondary_fft_size/2)+(10/2) if self.fft_compression=="adpcm": return (self.secondary_fft_size/2)+(10/2)
def set_samp_rate(self,samp_rate): def set_samp_rate(self,samp_rate):
#to change this, restart is required
self.samp_rate=samp_rate self.samp_rate=samp_rate
self.calculate_decimation()
if self.running: self.restart()
def calculate_decimation(self):
self.decimation=1 self.decimation=1
while self.samp_rate/(self.decimation+1)>self.output_rate: while self.samp_rate/(self.decimation+1)>self.output_rate:
self.decimation+=1 self.decimation+=1
@ -229,7 +232,7 @@ class dsp:
def set_output_rate(self,output_rate): def set_output_rate(self,output_rate):
self.output_rate=output_rate self.output_rate=output_rate
self.set_samp_rate(self.samp_rate) #as it depends on output_rate self.calculate_decimation()
def set_demodulator(self,demodulator): def set_demodulator(self,demodulator):
#to change this, restart is required #to change this, restart is required
@ -314,6 +317,9 @@ class dsp:
except Exception as e: print("[openwebrx-dsp-plugin:csdr] try_delete_pipes() ::", e) except Exception as e: print("[openwebrx-dsp-plugin:csdr] try_delete_pipes() ::", e)
def start(self): def start(self):
if (self.running): return
self.running = True
command_base=self.chain(self.demodulator) command_base=self.chain(self.demodulator)
#create control pipes for csdr #create control pipes for csdr
@ -363,8 +369,6 @@ class dsp:
threading.Thread(target = watch_thread).start() threading.Thread(target = watch_thread).start()
self.running = True
#open control pipes for csdr and send initialization data #open control pipes for csdr and send initialization data
if self.bpf_pipe != None: if self.bpf_pipe != None:
self.bpf_pipe_file=open(self.bpf_pipe,"w") self.bpf_pipe_file=open(self.bpf_pipe,"w")
@ -422,6 +426,7 @@ class dsp:
# except: print "[openwebrx-dsp-plugin:csdr] stop() :: unlink failed: " + self.iqtee2_pipe # except: print "[openwebrx-dsp-plugin:csdr] stop() :: unlink failed: " + self.iqtee2_pipe
def restart(self): def restart(self):
if not self.running: return
self.stop() self.stop()
self.start() self.start()

View File

@ -1172,7 +1172,7 @@ function on_ws_recv(evt)
window.starting_offset_frequency = config.start_offset_frequency; window.starting_offset_frequency = config.start_offset_frequency;
window.audio_buffering_fill_to = config.client_audio_buffer_size; window.audio_buffering_fill_to = config.client_audio_buffer_size;
bandwidth = config.samp_rate; bandwidth = config.samp_rate;
center_freq = config.shown_center_freq; center_freq = config.center_freq + config.lfo_offset;
fft_size = config.fft_size; fft_size = config.fft_size;
fft_fps = config.fft_fps; fft_fps = config.fft_fps;
audio_compression = config.audio_compression; audio_compression = config.audio_compression;
@ -1183,7 +1183,7 @@ function on_ws_recv(evt)
waterfall_init(); waterfall_init();
audio_preinit(); audio_preinit();
if (audio_allowed) audio_init(); if (audio_allowed && !audio_initialized) audio_init();
waterfall_clear(); waterfall_clear();
break; break;
case "secondary_config": case "secondary_config":

View File

@ -85,7 +85,7 @@ class WebSocketMessageHandler(object):
self.client = OpenWebRxClient(conn) self.client = OpenWebRxClient(conn)
config_keys = ["waterfall_colors", "waterfall_min_level", "waterfall_max_level", config_keys = ["waterfall_colors", "waterfall_min_level", "waterfall_max_level",
"waterfall_auto_level_margin", "shown_center_freq", "samp_rate", "fft_size", "fft_fps", "waterfall_auto_level_margin", "lfo_offset", "samp_rate", "fft_size", "fft_fps",
"audio_compression", "fft_compression", "max_clients", "start_mod", "audio_compression", "fft_compression", "max_clients", "start_mod",
"client_audio_buffer_size", "start_freq", "center_freq"] "client_audio_buffer_size", "start_freq", "center_freq"]

View File

@ -34,17 +34,17 @@ class RtlNmuxSource(object):
self.start() self.start()
props.wire(restart) props.wire(restart)
featureDetector = FeatureDetector()
if not featureDetector.is_available(props["rtl_type"]):
print("The RTL source type {0} is not available. please check requirements.".format(props["rtl_type"]))
return
self.start() self.start()
def start(self): def start(self):
props = self.props props = self.props
featureDetector = FeatureDetector()
if not featureDetector.is_available(props["rtl_type"]):
print("The RTL source type {0} is not available. please check requirements.".format(props["rtl_type"]))
return
params = RtlNmuxSource.types[props["rtl_type"]] params = RtlNmuxSource.types[props["rtl_type"]]
start_sdr_command = params["command"].format( start_sdr_command = params["command"].format(