def spectrum_thread_function(): global clients dsp=getattr(plugins.dsp,cfg.dsp_plugin).plugin.dsp_plugin() dsp.set_demodulator("fft") dsp.set_samp_rate(cfg.samp_rate) dsp.set_fft_size(cfg.fft_size) dsp.set_fft_fps(cfg.fft_fps) dsp.set_fft_compression(cfg.fft_compression) dsp.set_format_conversion(cfg.format_conversion) sleep_sec=0.87/cfg.fft_fps print "[openwebrx-spectrum] Spectrum thread initialized successfully." dsp.start() print "[openwebrx-spectrum] Spectrum thread started." bytes_to_read=int(dsp.get_fft_bytes_to_read()) while True: data=dsp.read(bytes_to_read) #print "gotcha",len(data),"bytes of spectrum data via spectrum_thread_function()" cma("spectrum_thread") correction=0 for i in range(0,len(clients)): i-=correction if (clients[i].ws_started): if clients[i].spectrum_queue.full(): print "[openwebrx-spectrum] client spectrum queue full, closing it." close_client(i, False) correction+=1 else: clients[i].spectrum_queue.put([data]) # add new string by "reference" to all clients cmr()
def spectrum_thread_function(): global clients dsp = getattr(plugins.dsp, cfg.dsp_plugin).plugin.dsp_plugin() dsp.set_demodulator("fft") dsp.set_samp_rate(cfg.samp_rate) dsp.set_fft_size(cfg.fft_size) dsp.set_fft_fps(cfg.fft_fps) dsp.set_fft_compression(cfg.fft_compression) dsp.set_format_conversion(cfg.format_conversion) sleep_sec = 0.87 / cfg.fft_fps print "[openwebrx-spectrum] Spectrum thread initialized successfully." dsp.start() print "[openwebrx-spectrum] Spectrum thread started." bytes_to_read = int(dsp.get_fft_bytes_to_read()) while True: data = dsp.read(bytes_to_read) #print "gotcha",len(data),"bytes of spectrum data via spectrum_thread_function()" cma("spectrum_thread") correction = 0 for i in range(0, len(clients)): i -= correction if (clients[i].ws_started): if clients[i].spectrum_queue.full(): print "[openwebrx-spectrum] client spectrum queue full, closing it." close_client(i, False) correction += 1 else: clients[i].spectrum_queue.put( [data]) # add new string by "reference" to all clients cmr()
def spectrum_thread_function(): global clients, spectrum_dsp, spectrum_thread_watchdog_last_tick spectrum_dsp=dsp=getattr(plugins.dsp,cfg.dsp_plugin).plugin.dsp_plugin() dsp.nc_port=cfg.iq_server_port dsp.set_demodulator("fft") dsp.set_samp_rate(cfg.samp_rate) dsp.set_fft_size(cfg.fft_size) dsp.set_fft_fps(cfg.fft_fps) if cfg.fft_enable_average: # number of input samples for fft_fc is fft_size*2, make overlap fraction and fft_fps work correctly in that case: fft_in_size = (cfg.fft_size*2) if cfg.real_input else cfg.fft_size fft_averages = int(round(1.0 * cfg.samp_rate / fft_in_size / cfg.fft_fps / (1.0 - cfg.fft_voverlap_factor))) if fft_averages <= 1: # averaging not needed, disable it fft_averages = 0 else: fft_averages = 0 dsp.set_fft_averages(fft_averages) dsp.set_fft_compression(cfg.fft_compression) dsp.set_format_conversion(cfg.format_conversion) dsp.set_real_input(cfg.real_input) apply_csdr_cfg_to_dsp(dsp) sleep_sec=0.87/cfg.fft_fps print "[openwebrx-spectrum] Spectrum thread initialized successfully." dsp.start() if cfg.csdr_dynamic_bufsize: dsp.read(8) #dummy read to skip bufsize & preamble print "[openwebrx-spectrum] Note: CSDR_DYNAMIC_BUFSIZE_ON = 1" print "[openwebrx-spectrum] Spectrum thread started." bytes_to_read=int(dsp.get_fft_bytes_to_read()) spectrum_thread_counter=0 while True: data=dsp.read(bytes_to_read) #print "gotcha",len(data),"bytes of spectrum data via spectrum_thread_function()" if spectrum_thread_counter >= cfg.fft_fps: spectrum_thread_counter=0 spectrum_thread_watchdog_last_tick = time.time() #once every second else: spectrum_thread_counter+=1 cma("spectrum_thread") correction=0 for i in range(0,len(clients)): i-=correction if (clients[i].ws_started): if clients[i].spectrum_queue.full(): print "[openwebrx-spectrum] client spectrum queue full, closing it." close_client(i, False) correction+=1 else: clients[i].spectrum_queue.put([data]) # add new string by "reference" to all clients cmr()
def spectrum_thread_function(): global clients, spectrum_dsp, spectrum_thread_watchdog_last_tick spectrum_dsp = dsp = getattr(plugins.dsp, cfg.dsp_plugin).plugin.dsp_plugin() dsp.nc_port = cfg.iq_server_port dsp.set_demodulator("fft") dsp.set_samp_rate(cfg.samp_rate) dsp.set_fft_size(cfg.fft_size) dsp.set_fft_fps(cfg.fft_fps) dsp.set_fft_compression(cfg.fft_compression) dsp.set_format_conversion(cfg.format_conversion) apply_csdr_cfg_to_dsp(dsp) sleep_sec = 0.87 / cfg.fft_fps print "[openwebrx-spectrum] Spectrum thread initialized successfully." dsp.start() if cfg.csdr_dynamic_bufsize: dsp.read(8) #dummy read to skip bufsize & preamble print "[openwebrx-spectrum] Note: CSDR_DYNAMIC_BUFSIZE_ON = 1" print "[openwebrx-spectrum] Spectrum thread started." bytes_to_read = int(dsp.get_fft_bytes_to_read()) spectrum_thread_counter = 0 while True: data = dsp.read(bytes_to_read) #print "gotcha",len(data),"bytes of spectrum data via spectrum_thread_function()" if spectrum_thread_counter >= cfg.fft_fps: spectrum_thread_counter = 0 spectrum_thread_watchdog_last_tick = time.time( ) #once every second else: spectrum_thread_counter += 1 cma("spectrum_thread") correction = 0 for i in range(0, len(clients)): i -= correction if (clients[i].ws_started): if clients[i].spectrum_queue.full(): print "[openwebrx-spectrum] client spectrum queue full, closing it." close_client(i, False) correction += 1 else: clients[i].spectrum_queue.put( [data]) # add new string by "reference" to all clients cmr()
def spectrum_thread_function(): global clients, spectrum_dsp, spectrum_thread_watchdog_last_tick spectrum_dsp = dsp = getattr(plugins.dsp, cfg.dsp_plugin).plugin.dsp_plugin() dsp.nc_port = cfg.iq_server_port dsp.set_demodulator("fft") dsp.set_samp_rate(cfg.samp_rate) dsp.set_fft_size(cfg.fft_size) dsp.set_fft_fps(cfg.fft_fps) dsp.set_fft_compression(cfg.fft_compression) dsp.set_format_conversion(cfg.format_conversion) apply_csdr_cfg_to_dsp(dsp) sleep_sec = 0.87 / cfg.fft_fps print("[openwebrx-spectrum] Spectrum thread initialized successfully.") dsp.start() if cfg.csdr_dynamic_bufsize: dsp.read(8) # dummy read to skip bufsize & preamble print("[openwebrx-spectrum] Note: CSDR_DYNAMIC_BUFSIZE_ON = 1") print("[openwebrx-spectrum] Spectrum thread started.") bytes_to_read = int(dsp.get_fft_bytes_to_read()) spectrum_thread_counter = 0 while True: data = dsp.read(bytes_to_read) # print "gotcha",len(data),"bytes of spectrum data via spectrum_thread_function()" if spectrum_thread_counter >= cfg.fft_fps: spectrum_thread_counter = 0 spectrum_thread_watchdog_last_tick = time.time() # once every second else: spectrum_thread_counter += 1 cma("spectrum_thread") correction = 0 for i in range(0, len(clients)): i -= correction if (clients[i].ws_started): if clients[i].spectrum_queue.full(): print("[openwebrx-spectrum] client spectrum queue full, closing it.") close_client(i, False) correction += 1 else: clients[i].spectrum_queue.put([data]) # add new string by "reference" to all clients cmr()