|
|
|
|
@ -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: |
|
|
|
|
|