Browse Source

moved freq search to separate thread -> dont block flowgraph

dev
Clemens Richter 9 years ago
parent
commit
7b887302ef
  1. 2
      apps/fft-multi-decoder_auto_freqs_slider-update.grc
  2. 28
      python/max_freq.py
  3. 2
      python/tmc_classes.py

2
apps/fft-multi-decoder_auto_freqs_slider-update.grc

@ -3080,7 +3080,7 @@ class blk(gr.sync_block): # other base classes are basic_block, decim_block, in
</param>
<param>
<key>debug</key>
<value>False</value>
<value>True</value>
</param>
<param>
<key>_enabled</key>

28
python/max_freq.py

@ -21,7 +21,7 @@
import numpy as np
from gnuradio import gr
import code,math,pmt,time
import code,math,pmt,time,threading
class max_freq(gr.sync_block):
"""
@ -45,6 +45,7 @@ class max_freq(gr.sync_block):
self.set_msg_handler(pmt.intern('ctrl'), self.handle_ctrl_msg)
self.searchMode=True
self.index_fixed=[False]*self.num_decoders
self.search_thread=None
def freq_to_index(self,freq):
startfreq=self.center_freq-self.samp_rate/2
#freq=self.samp_rate*index/self.fft_len+startfreq
@ -93,15 +94,10 @@ class max_freq(gr.sync_block):
self.center_freq=freq
else:
self.center_freq = int(freq)
def work(self, input_items, output_items):
if time.time()-self.timer<2:#every 2 seconds
return len(input_items[0])
elif self.searchMode:
#in0 = input_items[0]
#ii=input_items
def search(self,inputvector):
carrier_width=2
carrier=self.fft_len/2
numbers=np.delete(input_items[0][0],range(carrier-carrier_width,carrier+carrier_width+1))#read input and disregard center (hackrf LO)
numbers=np.delete(inputvector[0],range(carrier-carrier_width,carrier+carrier_width+1))#read input and disregard center (hackrf LO)
#threshold=40# uni
#threshold=60#home
#threshold=np.mean(numbers)#2017-03-21 fft-multi-decoder
@ -229,6 +225,22 @@ class max_freq(gr.sync_block):
#print(station_indices_tune)
#print(station_strength)
print(station_freqs)
def work(self, input_items, output_items):
if time.time()-self.timer<2:#every 2 seconds
return len(input_items[0])
elif self.searchMode:
inputvector=input_items[0]
if self.search_thread == None or self.search_thread.is_alive()==False:
if self.debug:
print("starting thread")
self.search_thread = threading.Thread(target=self.search, args=[inputvector], kwargs={})
self.search_thread.start()
elif self.debug:
print("thread exists")
#in0 = input_items[0]
#ii=input_items
return len(input_items[0])
else:

2
python/tmc_classes.py

@ -40,7 +40,7 @@ from collections import namedtuple
#Street(name='test', lcn=12)
#Street(lcn=12,name="test").name
import threading
#thr = threading.Thread(target=foo, args=(), kwargs={})
#thr = threading.Thread(target=foo, args=(), kwargs={})#kwargs = keyword-arguments
#thr.start() # will run "foo"
#....
#thr.is_alive() # will return whether foo is running currently

Loading…
Cancel
Save