From 4cd23cf44572af7f2c07d03f2e5d5b16f1a86def Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Tue, 7 May 2019 20:06:06 +0200 Subject: [PATCH] more work to allow seamless config switching --- config_webrx.py | 4 +++- csdr.py | 13 +++++++++---- htdocs/openwebrx.js | 4 ++-- owrx/controllers.py | 2 +- owrx/source.py | 10 +++++----- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/config_webrx.py b/config_webrx.py index a9c25d1..ca91905 100644 --- a/config_webrx.py +++ b/config_webrx.py @@ -159,7 +159,9 @@ To use a HackRF, compile the HackRF host tools from its "stdout" branch: # ==== 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 #increasing client_audio_buffer_size will: diff --git a/csdr.py b/csdr.py index 1807fe0..2a27228 100755 --- a/csdr.py +++ b/csdr.py @@ -211,8 +211,11 @@ class dsp: if self.fft_compression=="adpcm": return (self.secondary_fft_size/2)+(10/2) def set_samp_rate(self,samp_rate): - #to change this, restart is required self.samp_rate=samp_rate + self.calculate_decimation() + if self.running: self.restart() + + def calculate_decimation(self): self.decimation=1 while self.samp_rate/(self.decimation+1)>self.output_rate: self.decimation+=1 @@ -229,7 +232,7 @@ class dsp: def set_output_rate(self,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): #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) def start(self): + if (self.running): return + self.running = True + command_base=self.chain(self.demodulator) #create control pipes for csdr @@ -363,8 +369,6 @@ class dsp: threading.Thread(target = watch_thread).start() - self.running = True - #open control pipes for csdr and send initialization data if self.bpf_pipe != None: 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 def restart(self): + if not self.running: return self.stop() self.start() diff --git a/htdocs/openwebrx.js b/htdocs/openwebrx.js index 230d1e4..a5c6ee5 100644 --- a/htdocs/openwebrx.js +++ b/htdocs/openwebrx.js @@ -1172,7 +1172,7 @@ function on_ws_recv(evt) window.starting_offset_frequency = config.start_offset_frequency; window.audio_buffering_fill_to = config.client_audio_buffer_size; bandwidth = config.samp_rate; - center_freq = config.shown_center_freq; + center_freq = config.center_freq + config.lfo_offset; fft_size = config.fft_size; fft_fps = config.fft_fps; audio_compression = config.audio_compression; @@ -1183,7 +1183,7 @@ function on_ws_recv(evt) waterfall_init(); audio_preinit(); - if (audio_allowed) audio_init(); + if (audio_allowed && !audio_initialized) audio_init(); waterfall_clear(); break; case "secondary_config": diff --git a/owrx/controllers.py b/owrx/controllers.py index 67868a2..10bda5c 100644 --- a/owrx/controllers.py +++ b/owrx/controllers.py @@ -85,7 +85,7 @@ class WebSocketMessageHandler(object): self.client = OpenWebRxClient(conn) 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", "client_audio_buffer_size", "start_freq", "center_freq"] diff --git a/owrx/source.py b/owrx/source.py index 832cd1e..d889700 100644 --- a/owrx/source.py +++ b/owrx/source.py @@ -34,17 +34,17 @@ class RtlNmuxSource(object): self.start() 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() def start(self): 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"]] start_sdr_command = params["command"].format(