def __init__(self, freq_sample_delay_samps, freq_samps_to_avg, mag_samps_to_avg, thresh): gr.hier_block2.__init__( self, "Sample and Hold Detector", gr.io_signaturev(2, 2, [gr.sizeof_float * 1, gr.sizeof_float * 1]), gr.io_signaturev(4, 4, [ gr.sizeof_float * 1, gr.sizeof_float * 1, gr.sizeof_float * 1, gr.sizeof_float * 1 ])) ''' Constructor @param freq_sample_delay_samps - @param freq_samps_to_avg - @param mag_samps_to_avg - @param thresh - ''' ################################################## # Parameters ################################################## self.freq_sample_delay_samps = freq_sample_delay_samps self.freq_samps_to_avg = freq_samps_to_avg self.mag_samps_to_avg = mag_samps_to_avg self.thresh = thresh ################################################## # Blocks ################################################## self.edge_detector = timing_utils.edge_detector_bb( timing_utils.RISING_EDGE) self.threshold = blocks.threshold_ff(thresh / 4.0, thresh, 0) self.samp_hold = blocks.sample_and_hold_ff() self.mag_avg = blocks.moving_average_ff(int(mag_samps_to_avg), 1.0 / (mag_samps_to_avg), 4000) self.freq_avg = blocks.moving_average_ff(int(freq_samps_to_avg), 1.0 / (freq_samps_to_avg), 4000) self.f2c = blocks.float_to_char(1, 1) self.delay = blocks.delay( gr.sizeof_float * 1, int(freq_samps_to_avg - mag_samps_to_avg + freq_sample_delay_samps)) ################################################## # Connections ################################################## self.connect((self.delay, 0), (self.mag_avg, 0)) self.connect((self.f2c, 0), (self.edge_detector, 0)) self.connect((self.freq_avg, 0), (self.samp_hold, 0)) self.connect((self.freq_avg, 0), (self, 1)) self.connect((self.mag_avg, 0), (self.threshold, 0)) self.connect((self.mag_avg, 0), (self, 3)) self.connect((self.samp_hold, 0), (self, 0)) self.connect((self.threshold, 0), (self.f2c, 0)) self.connect((self.threshold, 0), (self, 2)) self.connect((self, 0), (self.delay, 0)) self.connect((self, 1), (self.freq_avg, 0)) self.connect((self.edge_detector, 0), (self.samp_hold, 1))
def __init__(self, abs_cfo_threshold=1e6, alpha=0.001, fft_len=512, fft_peak_threshold=0.5, rf_center_freq=1e9, samp_rate=32e3): gr.hier_block2.__init__( self, "Coarse Frequency Recovery", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signaturev(2, 2, [gr.sizeof_float*fft_len, gr.sizeof_float*1]), ) ################################################## # Parameters ################################################## self.abs_cfo_threshold = abs_cfo_threshold self.alpha = alpha self.fft_len = fft_len self.fft_peak_threshold = fft_peak_threshold self.rf_center_freq = rf_center_freq self.samp_rate = samp_rate ################################################## # Blocks ################################################## self.logpwrfft_x_0 = logpwrfft.logpwrfft_c( sample_rate=samp_rate, fft_size=fft_len, ref_scale=2, frame_rate=samp_rate/fft_len, avg_alpha=alpha, average=True, ) self.blocksat_wrap_fft_index_0 = blocksat.wrap_fft_index(fft_len) self.blocksat_runtime_cfo_ctrl_0 = blocksat.runtime_cfo_ctrl(7*int(1/alpha), abs_cfo_threshold, int(rf_center_freq)) self.blocksat_exponentiate_const_cci_0 = blocksat.exponentiate_const_cci(4, 1) self.blocksat_argpeak_0 = blocksat.argpeak(fft_len, fft_peak_threshold) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_short_to_float_0 = blocks.short_to_float(1, 1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((samp_rate/(fft_len*4), )) self.blocks_moving_average_xx_0_0 = blocks.moving_average_ff(int(1/alpha), 1.0/int(1/alpha), int(4/alpha)) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(int(1/alpha), 1.0/int(1/alpha), int(4/alpha)) ################################################## # Connections ################################################## self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocksat_runtime_cfo_ctrl_0, 1)) self.connect((self.blocks_moving_average_xx_0_0, 0), (self.blocksat_runtime_cfo_ctrl_0, 2)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocksat_runtime_cfo_ctrl_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_moving_average_xx_0_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocksat_argpeak_0, 0), (self.blocksat_wrap_fft_index_0, 0)) self.connect((self.blocksat_exponentiate_const_cci_0, 0), (self.logpwrfft_x_0, 0)) self.connect((self.blocksat_runtime_cfo_ctrl_0, 0), (self, 1)) self.connect((self.blocksat_wrap_fft_index_0, 0), (self.blocks_short_to_float_0, 0)) self.connect((self.logpwrfft_x_0, 0), (self.blocksat_argpeak_0, 0)) self.connect((self.logpwrfft_x_0, 0), (self, 0)) self.connect((self, 0), (self.blocksat_exponentiate_const_cci_0, 0))
def __init__(self, sample_rate): super(fsk_center_tracking, self).__init__( "fsk_center_tracking", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_gr_complex*1), ) # Arbitrary averaging values that seem to work OK. window_symbols = 20 symbol_rate = 19200 average_window = int(floor(sample_rate * window_symbols / symbol_rate)) self.delay = blocks.delay(gr.sizeof_gr_complex*1, average_window) self.demod = analog.quadrature_demod_cf(1) self.moving_average = blocks.moving_average_ff(average_window, 1.0 / average_window, 4000) self.vco = blocks.vco_c(sample_rate, -sample_rate, 1) self.multiply = blocks.multiply_vcc(1) self.connect((self, 0), (self.delay, 0)) self.connect((self.delay, 0), (self.multiply, 0)) self.connect((self, 0), (self.demod, 0)) self.connect((self.demod, 0), (self.moving_average, 0)) self.connect((self.moving_average, 0), (self.vco, 0)) self.connect((self.vco, 0), (self.multiply, 1)) self.connect((self.multiply, 0), (self, 0))
def __init__(self, interpolation=36, decimation=125): gr.hier_block2.__init__(self, "indri_smartnet_control_channel", gr.io_signature(1,1,gr.sizeof_float), gr.io_signature(1,1,1)) # Figure out where zero should be, despite RTL-SDR drift avglen = 1000 # should be big enough to catch drifts offset = blocks.moving_average_ff(avglen, 1.0/avglen, 40*avglen) differential = blocks.sub_ff() self.connect(self, (differential,0)) self.connect(self, offset) self.connect(offset, (differential,1)) # sample off the offsets to adjust tuning offset_sampler = blocks.keep_one_in_n(gr.sizeof_float, 10*avglen) offset_mag_block = blocks.probe_signal_f() self.offset_mag = offset_mag_block self.connect(offset, offset_sampler, offset_mag_block) rational_resampler = gr_filter.rational_resampler_fff( interpolation=interpolation, decimation=decimation, taps=None, fractional_bw=0.45, ) slicer = digital.binary_slicer_fb() self.connect(differential, rational_resampler, slicer, self)
def __init__(self, sample_rate): super(fsk_center_tracking, self).__init__( "fsk_center_tracking", gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), ) # Arbitrary averaging values that seem to work OK. window_symbols = 20 symbol_rate = 19200 average_window = int(floor(sample_rate * window_symbols / symbol_rate)) self.delay = blocks.delay(gr.sizeof_gr_complex * 1, average_window) self.demod = analog.quadrature_demod_cf(1) self.moving_average = blocks.moving_average_ff(average_window, 1.0 / average_window, 4000) self.vco = blocks.vco_c(sample_rate, -sample_rate, 1) self.multiply = blocks.multiply_vcc(1) self.connect((self, 0), (self.delay, 0)) self.connect((self.delay, 0), (self.multiply, 0)) self.connect((self, 0), (self.demod, 0)) self.connect((self.demod, 0), (self.moving_average, 0)) self.connect((self.moving_average, 0), (self.vco, 0)) self.connect((self.vco, 0), (self.multiply, 1)) self.connect((self.multiply, 0), (self, 0))
def __init__(self, n_bits=1000, bits_per_symbol=3): gr.hier_block2.__init__( self, "Custom Ber", gr.io_signaturev(2, 2, [gr.sizeof_char*1, gr.sizeof_char*1]), gr.io_signature(1, 1, gr.sizeof_float*1), ) ################################################## # Parameters ################################################## self.n_bits = n_bits self.bits_per_symbol = bits_per_symbol ################################################## # Variables ################################################## self.samp_rate = samp_rate = 8e6 ################################################## # Blocks ################################################## self.blocks_xor_xx_0 = blocks.xor_bb() self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(bits_per_symbol) self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_moving_average_xx_0 = blocks.moving_average_ff(n_bits, 1/float(n_bits), n_bits*4) ################################################## # Connections ################################################## self.connect((self.blocks_moving_average_xx_0, 0), (self, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_xor_xx_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self, 1), (self.blocks_xor_xx_0, 1)) self.connect((self, 0), (self.blocks_xor_xx_0, 0))
def __init__(self, rate, threshold, queue, use_pmf=False, use_dcblock=False): gr.hier_block2.__init__(self, "modes_rx_path", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(0, 0, 0)) self._rate = int(rate) self._threshold = threshold self._queue = queue self._spc = int(rate / 2e6) # Convert incoming I/Q baseband to amplitude self._demod = blocks.complex_to_mag_squared() if use_dcblock: self._dcblock = filter.dc_blocker_cc(100 * self._spc, False) self.connect(self, self._dcblock, self._demod) else: self.connect(self, self._demod) self._dcblock = None self._bb = self._demod # Pulse matched filter for 0.5us pulses if use_pmf: self._pmf = blocks.moving_average_ff(self._spc, 1.0 / self._spc) #, self._rate) self.connect(self._demod, self._pmf) self._bb = self._pmf # Establish baseline amplitude (noise, interference) self._avg = blocks.moving_average_ff( 48 * self._spc, 1.0 / (48 * self._spc)) #, self._rate) # 3 preambles # Synchronize to Mode-S preamble self._sync = air_modes.preamble(self._rate, self._threshold) # Slice Mode-S bits and send to message queue self._slicer = air_modes.slicer(self._queue) # Wire up the flowgraph self.connect(self._bb, (self._sync, 0)) self.connect(self._bb, self._avg, (self._sync, 1)) self.connect(self._sync, self._slicer)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 44100 ################################################## # Blocks ################################################## self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="Hz", minval=50, maxval=280, factor=1, decimal_places=2, ref_level=0, sample_rate=samp_rate, number_rate=15, average=False, avg_alpha=None, label="Number Plot", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( samp_rate / 50, 25 / pi, 200) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_float * 1, 10) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.band_pass_filter_0 = filter.fir_filter_ccc( 1, firdes.complex_band_pass(1, samp_rate, 60, 255, 100, firdes.WIN_BLACKMAN, 6.76)) self.audio_source_0 = audio.source(samp_rate, "default", True) self.analog_pll_freqdet_cf_0 = analog.pll_freqdet_cf( 200 * 2.0 * pi / samp_rate, 260 * 2.0 * pi / samp_rate, 60 * 2.0 * pi / samp_rate) ################################################## # Connections ################################################## self.connect((self.blocks_moving_average_xx_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.analog_pll_freqdet_cf_0, 0)) self.connect((self.audio_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_pll_freqdet_cf_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_moving_average_xx_0, 0))
def test_002_t(self): # Generate frames with AWGN and test SNR estimation sample_rate = 10.0e6 frame_duration = 1.0e-3 test_duration = 0.1 * frame_duration snr = 10 scale_value = 15.0 samples_per_frame = int(round(frame_duration * sample_rate)) samples_per_test = int(round(test_duration * sample_rate)) random_samples_skip = 0 #np.random.randint(samples_per_frame) preamble_seq = zadoffchu(63, 1, 0) preamble_pwr_sum = np.sum(np.abs(preamble_seq)**2) print "***** Start test 002 *****" framer = specmonitor.framer_c(sample_rate, frame_duration, preamble_seq) awgn = analog.noise_source_c(analog.GR_GAUSSIAN, 1.0 / snr) add = blocks.add_cc() scaler = blocks.multiply_const_vcc([complex(scale_value)]) mag2 = blocks.complex_to_mag_squared() mavg = blocks.moving_average_ff( len(preamble_seq), 1.0 / len(preamble_seq) ) # i need to divide by the preamble size in case the preamble seq has amplitude 1 (sum of power is len) sqrtavg = blocks.transcendental("sqrt") # I have to compensate the amplitude of the input signal (scale) either through a feedback normalization loop that computes the scale, or manually (not practical) # additionally I have to scale down by the len(preamble)==sum(abs(preamble)^2) because the cross-corr does not divide by the preamble length #scaler2 = blocks.multiply_const_vcc([complex(1.0)/scale_value/len(preamble_seq)]) # if no feedback normalization loop, I have to scale the signal compensating additionally the scaling factor corr_est = specmonitor.corr_est_norm_cc( preamble_seq, 1, 0) #digital.corr_est_cc(preamble_seq, 1, 0) tag_db = blocks.tag_debug(gr.sizeof_gr_complex, "tag debugger") head = blocks.head(gr.sizeof_gr_complex, samples_per_test) dst = blocks.vector_sink_c() skiphead = blocks.skiphead(gr.sizeof_float, random_samples_skip) skiphead2 = blocks.skiphead(gr.sizeof_gr_complex, random_samples_skip) skiphead3 = blocks.skiphead(gr.sizeof_gr_complex, random_samples_skip) debug_vec = blocks.vector_sink_f() debug_vec2 = blocks.vector_sink_c() debug_vec3 = blocks.vector_sink_c() self.tb.connect(framer, (add, 0)) self.tb.connect(awgn, (add, 1)) self.tb.connect(add, scaler) self.tb.connect(scaler, mag2, mavg, sqrtavg) self.tb.connect(scaler, corr_est) self.tb.connect(corr_est, tag_db) self.tb.connect(corr_est, head, dst) self.tb.connect(sqrtavg, skiphead, debug_vec) self.tb.connect(scaler, skiphead2, debug_vec2) self.tb.run() result_data = dst.data() debug_vec_data = debug_vec.data() debug_vec_data2 = debug_vec2.data() debug_vec_data3 = debug_vec3.data()
def __init__(self): gr.top_block.__init__(self, "Scanner Grc") ################################################## # Variables ################################################## self.f_symb = f_symb = 1625000.0/6.0 self.f_900_b = f_900_b = 921.2e6 self.samp_rate = samp_rate = f_symb*4 self.fs = fs = f_900_b self.f_900_e = f_900_e = 959.8e6 self.f_1800_e = f_1800_e = 1879.8e6 self.f_1800_b = f_1800_b = 1805.2e6 self.OSR = OSR = 4 ################################################## # Blocks ################################################## self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "bladerf=0" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(fs, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(2, 0) self.osmosdr_source_0.set_gain_mode(True, 0) self.osmosdr_source_0.set_gain(30, 0) self.osmosdr_source_0.set_if_gain(30, 0) self.osmosdr_source_0.set_bb_gain(30, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(200000, 0) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, 200e3, 10e3, firdes.WIN_HAMMING, 6.76)) self.threshold_result = blocks.threshold_ff(0, 0.2, 0) self.blocks_threshold_ff_0_0 = blocks.threshold_ff(0, 0, 0) self.blocks_threshold_ff_0 = blocks.threshold_ff(int((138)*samp_rate/f_symb), int((138)*samp_rate/f_symb), 0) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(int((142)*samp_rate/f_symb), 1, int(1e6)) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, int(OSR)) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_threshold_ff_0_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.threshold_result, 0)) self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.threshold_result, 0), (self.blocks_null_sink_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_delay_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.low_pass_filter_0, 0))
def __init__(self, OSR=4): grgsm.hier_block.__init__( self, "FCCH bursts detector", gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), ) ################################################## # Parameters ################################################## self.OSR = OSR ################################################## # Variables ################################################## self.f_symb = f_symb = 1625000.0 / 6.0 self.samp_rate = samp_rate = f_symb * OSR ################################################## # Blocks ################################################## self.gsm_fcch_burst_tagger_0 = grgsm.fcch_burst_tagger(OSR) self.blocks_threshold_ff_0_0 = blocks.threshold_ff(0, 0, 0) self.blocks_threshold_ff_0 = blocks.threshold_ff( int((138) * samp_rate / f_symb), int((138) * samp_rate / f_symb), 0) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( int((142) * samp_rate / f_symb), 1, int(1e6)) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, int(OSR)) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) ################################################## # Connections ################################################## self.connect((self, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_threshold_ff_0_0, 0)) self.connect((self, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.gsm_fcch_burst_tagger_0, 0), (self, 0)) self.connect((self, 0), (self.gsm_fcch_burst_tagger_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.gsm_fcch_burst_tagger_0, 1))
def __init__(self, rate, threshold, queue, use_pmf=False, use_dcblock=False): gr.hier_block2.__init__(self, "modes_rx_path", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(0,0,0)) self._rate = int(rate) self._threshold = threshold self._queue = queue self._spc = int(rate/2e6) # Convert incoming I/Q baseband to amplitude self._demod = blocks.complex_to_mag_squared() if use_dcblock: self._dcblock = filter.dc_blocker_cc(100*self._spc,False) self.connect(self, self._dcblock, self._demod) else: self.connect(self, self._demod) self._dcblock = None self._bb = self._demod # Pulse matched filter for 0.5us pulses if use_pmf: self._pmf = blocks.moving_average_ff(self._spc, 1.0/self._spc)#, self._rate) self.connect(self._demod, self._pmf) self._bb = self._pmf # Establish baseline amplitude (noise, interference) self._avg = blocks.moving_average_ff(48*self._spc, 1.0/(48*self._spc))#, self._rate) # 3 preambles # Synchronize to Mode-S preamble self._sync = air_modes_swig.preamble(self._rate, self._threshold) # Slice Mode-S bits and send to message queue self._slicer = air_modes_swig.slicer(self._queue) # Wire up the flowgraph self.connect(self._bb, (self._sync, 0)) self.connect(self._bb, self._avg, (self._sync, 1)) self.connect(self._sync, self._slicer)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 44100 ################################################## # Blocks ################################################## self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="Hz", minval=50, maxval=280, factor=1, decimal_places=2, ref_level=0, sample_rate=samp_rate, number_rate=15, average=False, avg_alpha=None, label="Number Plot", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(samp_rate / 50, 25 / pi, 200) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_float * 1, 10) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.band_pass_filter_0 = filter.fir_filter_ccc( 1, firdes.complex_band_pass(1, samp_rate, 60, 255, 100, firdes.WIN_BLACKMAN, 6.76) ) self.audio_source_0 = audio.source(samp_rate, "default", True) self.analog_pll_freqdet_cf_0 = analog.pll_freqdet_cf( 200 * 2.0 * pi / samp_rate, 260 * 2.0 * pi / samp_rate, 60 * 2.0 * pi / samp_rate ) ################################################## # Connections ################################################## self.connect((self.blocks_moving_average_xx_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.analog_pll_freqdet_cf_0, 0)) self.connect((self.audio_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_pll_freqdet_cf_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_moving_average_xx_0, 0))
def __init__(self, OSR=4): gr.hier_block2.__init__( self, "FCCH bursts detector", gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), ) ################################################## # Parameters ################################################## self.OSR = OSR ################################################## # Variables ################################################## self.f_symb = f_symb = 1625000.0 / 6.0 self.samp_rate = samp_rate = f_symb * OSR ################################################## # Blocks ################################################## self.gsm_fcch_burst_tagger_0 = grgsm.fcch_burst_tagger(OSR) self.blocks_threshold_ff_0_0 = blocks.threshold_ff(0, 0, 0) self.blocks_threshold_ff_0 = blocks.threshold_ff( int((138) * samp_rate / f_symb), int((138) * samp_rate / f_symb), 0 ) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(int((142) * samp_rate / f_symb), 1, int(1e6)) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, int(OSR)) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) ################################################## # Connections ################################################## self.connect((self, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_threshold_ff_0_0, 0)) self.connect((self, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.gsm_fcch_burst_tagger_0, 0), (self, 0)) self.connect((self, 0), (self.gsm_fcch_burst_tagger_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.gsm_fcch_burst_tagger_0, 1))
def test_01(self): tb = self.tb N = 10000 data = make_random_float_tuple(N, 1) expected_result = N*[0,] src = blocks.vector_source_f(data, False) op = blocks.moving_average_ff(100, 0.001) dst = blocks.vector_sink_f() tb.connect(src, op) tb.connect(op, dst) tb.run() dst_data = dst.data() # make sure result is close to zero self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 1)
def test_01(self): tb = self.tb N = 10000 seed = 0 data = make_random_float_tuple(N, 1) expected_result = N*[0,] src = blocks.vector_source_f(data, False) op = blocks.moving_average_ff(100, 0.001) dst = blocks.vector_sink_f() tb.connect(src, op) tb.connect(op, dst) tb.run() dst_data = dst.data() # make sure result is close to zero self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 1)
def __init__(self, filter_len, gain, hi, low): gr.hier_block2.__init__( self, "carrier_detect", gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), gr.io_signature(1, 1, gr.sizeof_short * 1), ) ################################################## # Parameters ################################################## self.filter_len = filter_len self.gain = gain self.hi = hi self.low = low ################################################## # Blocks ################################################## self.blocks_threshold_ff_0 = blocks.threshold_ff(low, hi, 0) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((gain, )) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( filter_len, 1.0 / filter_len, 4000) self.blocks_float_to_short_0 = blocks.float_to_short(1, 1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_float_to_short_0, 0), (self, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_float_to_short_0, 0)) self.connect((self, 0), (self.blocks_complex_to_mag_squared_0, 0))
def __init__(self, preamble_length): gr.hier_block2.__init__(self, "burstsilence_corr", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(2, 2, gr.sizeof_gr_complex)) half_length = int(preamble_length) / 2 # Blocks self.equiv_delay = blocks.delay(gr.sizeof_gr_complex, preamble_length) self.to_power = blocks.complex_to_mag_squared(1) self.pw_delay = blocks.delay(gr.sizeof_float, half_length) self.sub_sigref = blocks.sub_ff(1) self.avg = blocks.moving_average_ff(half_length, 1, 4096) self.null_src = blocks.null_source(gr.sizeof_float) self.clamp = blocks.max_ff(1, 1) self.to_complex = blocks.float_to_complex(1) # Connections self.connect((self, 0), (self.to_power, 0)) self.connect((self, 0), (self.equiv_delay, 0)) self.connect((self.to_power, 0), (self.pw_delay, 0)) self.connect((self.to_power, 0), (self.sub_sigref, 1)) self.connect((self.pw_delay, 0), (self.sub_sigref, 0)) self.connect((self.sub_sigref, 0), (self.avg, 0)) self.connect((self.avg, 0), (self.clamp, 0)) self.connect((self.null_src, 0), (self.clamp, 1)) self.connect((self.clamp, 0), (self.to_complex, 0)) self.connect((self.null_src, 0), (self.to_complex, 1)) self.connect((self.equiv_delay, 0), (self, 0)) self.connect((self.to_complex, 0), (self, 1))
def __init__(self, system, site_uuid, overseer_uuid): gr.top_block.__init__(self, "moto receiver") ################################################## # Variables ################################################## self.instance_uuid = '%s' % uuid.uuid4() self.log = logging.getLogger('overseer.moto_control_demod.%s' % self.instance_uuid) self.log.info('Initializing instance: %s site: %s overseer: %s' % (self.instance_uuid, site_uuid, overseer_uuid)) self.overseer_uuid = overseer_uuid self.site_uuid = site_uuid self.channel_rate = 12500 self.packets = 0 self.packets_bad = 0 self.patches = {} self.quality = [] self.site_detail = {} self.symbol_rate = symbol_rate = 3600.0 self.control_source = 0 self.offset = offset = 0 self.is_locked = False self.system = system self.system_id = system['id'] self.channels = system['channels'] self.channels_list = self.channels.keys() self.thread_id = '%s-%s' % (self.system['type'], self.system_id) self.control_channel_key = 0 self.control_channel = control_channel = self.channels[ self.channels_list[0]] self.option_dc_offset = False self.option_udp_sink = False self.enable_capture = True self.keep_running = True ################################################## # Message Queues ################################################## self.control_msg_sink_msgq = gr.msg_queue(1024) ################################################## # Threads ################################################## receive_engine = threading.Thread(target=self.receive_engine) receive_engine.daemon = True receive_engine.start() quality_check = threading.Thread(target=self.quality_check) quality_check.daemon = True quality_check.start() self.connector = frontend_connector() self.redis_demod_publisher = redis_demod_publisher(parent_demod=self) self.client_redis = client_redis() ################################################## # Blocks ################################################## self.source = None control_sample_rate = 12500 channel_rate = control_sample_rate * 2 self.control_quad_demod = analog.quadrature_demod_cf(5) if (self.option_dc_offset): moving_sum = blocks.moving_average_ff(1000, 1, 4000) divide_const = blocks.multiply_const_vff((0.001, )) self.probe = blocks.probe_signal_f() self.control_clock_recovery = digital.clock_recovery_mm_ff( channel_rate / symbol_rate, 1.4395919, 0.5, 0.05, 0.005) self.control_binary_slicer = digital.binary_slicer_fb() self.control_byte_pack = blocks.unpacked_to_packed_bb( 1, gr.GR_MSB_FIRST) self.control_msg_sink = blocks.message_sink(gr.sizeof_char * 1, self.control_msg_sink_msgq, True) if (self.option_udp_sink): self.udp = blocks.udp_sink(gr.sizeof_gr_complex * 1, "127.0.0.1", self.system_id, 1472, True) moving_sum = blocks.moving_average_ff(10000, 1, 40000) subtract = blocks.sub_ff(1) divide_const = blocks.multiply_const_vff((0.0001, )) self.probe = blocks.probe_signal_f() self.connect(self.control_quad_demod, moving_sum, divide_const, self.probe) ################################################## # Connections ################################################## self.connect(self.control_quad_demod, self.control_clock_recovery) self.connect(self.control_clock_recovery, self.control_binary_slicer, self.control_byte_pack, self.control_msg_sink) if (self.option_dc_offset): self.connect(self.control_quad_demod, moving_sum, divide_const, self.probe) if (self.option_udp_sink): self.connect(self.control_prefilter, self.udp) self.tune_next_control()
def __init__(self): gr.top_block.__init__(self, "Uhd Hf Am") Qt.QWidget.__init__(self) self.setWindowTitle("Uhd Hf Am") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "uhd_hf_am") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2.5e6 self.rx_freq = rx_freq = 1.0e6 self.fine_freq = fine_freq = 0 self.coarse_freq = coarse_freq = 0 self.volume = volume = 1 self.usb_lsb = usb_lsb = -1 self.ssb_am = ssb_am = 0 self.selection = selection = ((1, 0, 0), (0, 1, 0), (0, 0, 1)) self.pll_lbw = pll_lbw = 200 self.pll_freq = pll_freq = 100 self.lpf_cutoff = lpf_cutoff = 2e3 self.interp = interp = 48 self.freq_label = freq_label = rx_freq + fine_freq + coarse_freq self.decim = decim = samp_rate / 1e3 self.decay_rate = decay_rate = 100e-6 self.audio_ref = audio_ref = 1 self.audio_max_gain = audio_max_gain = 1 self.audio_gain = audio_gain = 1 self.audio_decay = audio_decay = 100 self.audio_attack = audio_attack = 1000 ################################################## # Blocks ################################################## self._volume_range = Range(0, 100, .1, 1, 200) self._volume_win = RangeWidget(self._volume_range, self.set_volume, "volume", "counter_slider", float) self.top_grid_layout.addWidget(self._volume_win, 7, 0, 1, 4) for r in range(7, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self._usb_lsb_options = ( -1, 1, ) self._usb_lsb_labels = ( 'USB', 'LSB', ) self._usb_lsb_group_box = Qt.QGroupBox("usb_lsb") self._usb_lsb_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._usb_lsb_button_group = variable_chooser_button_group() self._usb_lsb_group_box.setLayout(self._usb_lsb_box) for i, label in enumerate(self._usb_lsb_labels): radio_button = Qt.QRadioButton(label) self._usb_lsb_box.addWidget(radio_button) self._usb_lsb_button_group.addButton(radio_button, i) self._usb_lsb_callback = lambda i: Qt.QMetaObject.invokeMethod( self._usb_lsb_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._usb_lsb_options.index(i))) self._usb_lsb_callback(self.usb_lsb) self._usb_lsb_button_group.buttonClicked[int].connect( lambda i: self.set_usb_lsb(self._usb_lsb_options[i])) self.top_grid_layout.addWidget(self._usb_lsb_group_box, 5, 5, 1, 1) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(5, 6): self.top_grid_layout.setColumnStretch(c, 1) self._ssb_am_options = ( 0, 1, 2, ) self._ssb_am_labels = ( 'SSB', 'AM', 'AM*', ) self._ssb_am_group_box = Qt.QGroupBox("ssb_am") self._ssb_am_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._ssb_am_button_group = variable_chooser_button_group() self._ssb_am_group_box.setLayout(self._ssb_am_box) for i, label in enumerate(self._ssb_am_labels): radio_button = Qt.QRadioButton(label) self._ssb_am_box.addWidget(radio_button) self._ssb_am_button_group.addButton(radio_button, i) self._ssb_am_callback = lambda i: Qt.QMetaObject.invokeMethod( self._ssb_am_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._ssb_am_options.index(i))) self._ssb_am_callback(self.ssb_am) self._ssb_am_button_group.buttonClicked[int].connect( lambda i: self.set_ssb_am(self._ssb_am_options[i])) self.top_grid_layout.addWidget(self._ssb_am_group_box, 4, 4, 1, 1) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 5): self.top_grid_layout.setColumnStretch(c, 1) self._rx_freq_range = Range(.2e6, 100e6, 100e3, 1.0e6, 200) self._rx_freq_win = RangeWidget(self._rx_freq_range, self.set_rx_freq, "rx_freq", "counter_slider", float) self.top_grid_layout.addWidget(self._rx_freq_win, 4, 0, 1, 4) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self._pll_lbw_tool_bar = Qt.QToolBar(self) self._pll_lbw_tool_bar.addWidget(Qt.QLabel("pll_lbw" + ": ")) self._pll_lbw_line_edit = Qt.QLineEdit(str(self.pll_lbw)) self._pll_lbw_tool_bar.addWidget(self._pll_lbw_line_edit) self._pll_lbw_line_edit.returnPressed.connect(lambda: self.set_pll_lbw( eng_notation.str_to_num( str(self._pll_lbw_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._pll_lbw_tool_bar, 9, 7, 1, 1) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(7, 8): self.top_grid_layout.setColumnStretch(c, 1) self._pll_freq_tool_bar = Qt.QToolBar(self) self._pll_freq_tool_bar.addWidget(Qt.QLabel("pll_freq" + ": ")) self._pll_freq_line_edit = Qt.QLineEdit(str(self.pll_freq)) self._pll_freq_tool_bar.addWidget(self._pll_freq_line_edit) self._pll_freq_line_edit.returnPressed.connect( lambda: self.set_pll_freq( eng_notation.str_to_num( str(self._pll_freq_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._pll_freq_tool_bar, 9, 6, 1, 1) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 7): self.top_grid_layout.setColumnStretch(c, 1) self._lpf_cutoff_options = ( 2e3, 3e3, 4e3, 8e3, ) self._lpf_cutoff_labels = ( str(self._lpf_cutoff_options[0]), str(self._lpf_cutoff_options[1]), str(self._lpf_cutoff_options[2]), str(self._lpf_cutoff_options[3]), ) self._lpf_cutoff_tool_bar = Qt.QToolBar(self) self._lpf_cutoff_tool_bar.addWidget(Qt.QLabel("lpf_cutoff" + ": ")) self._lpf_cutoff_combo_box = Qt.QComboBox() self._lpf_cutoff_tool_bar.addWidget(self._lpf_cutoff_combo_box) for label in self._lpf_cutoff_labels: self._lpf_cutoff_combo_box.addItem(label) self._lpf_cutoff_callback = lambda i: Qt.QMetaObject.invokeMethod( self._lpf_cutoff_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._lpf_cutoff_options.index(i))) self._lpf_cutoff_callback(self.lpf_cutoff) self._lpf_cutoff_combo_box.currentIndexChanged.connect( lambda i: self.set_lpf_cutoff(self._lpf_cutoff_options[i])) self.top_grid_layout.addWidget(self._lpf_cutoff_tool_bar, 4, 5, 1, 1) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(5, 6): self.top_grid_layout.setColumnStretch(c, 1) self._fine_freq_range = Range(-1e3, 1e3, 1, 0, 200) self._fine_freq_win = RangeWidget(self._fine_freq_range, self.set_fine_freq, "fine_freq", "counter_slider", float) self.top_grid_layout.addWidget(self._fine_freq_win, 6, 0, 1, 4) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self._decay_rate_options = ( 100e-6, 65e-3, 20e-3, ) self._decay_rate_labels = ( 'Fast', 'Medium', 'Slow', ) self._decay_rate_group_box = Qt.QGroupBox("decay_rate") self._decay_rate_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._decay_rate_button_group = variable_chooser_button_group() self._decay_rate_group_box.setLayout(self._decay_rate_box) for i, label in enumerate(self._decay_rate_labels): radio_button = Qt.QRadioButton(label) self._decay_rate_box.addWidget(radio_button) self._decay_rate_button_group.addButton(radio_button, i) self._decay_rate_callback = lambda i: Qt.QMetaObject.invokeMethod( self._decay_rate_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._decay_rate_options.index(i))) self._decay_rate_callback(self.decay_rate) self._decay_rate_button_group.buttonClicked[int].connect( lambda i: self.set_decay_rate(self._decay_rate_options[i])) self.top_grid_layout.addWidget(self._decay_rate_group_box, 4, 6, 1, 1) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 7): self.top_grid_layout.setColumnStretch(c, 1) self._coarse_freq_range = Range(-100e3, 100e3, 1, 0, 200) self._coarse_freq_win = RangeWidget(self._coarse_freq_range, self.set_coarse_freq, "coarse_freq", "counter_slider", float) self.top_grid_layout.addWidget(self._coarse_freq_win, 5, 0, 1, 4) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self._audio_ref_tool_bar = Qt.QToolBar(self) self._audio_ref_tool_bar.addWidget(Qt.QLabel("audio_ref" + ": ")) self._audio_ref_line_edit = Qt.QLineEdit(str(self.audio_ref)) self._audio_ref_tool_bar.addWidget(self._audio_ref_line_edit) self._audio_ref_line_edit.returnPressed.connect( lambda: self.set_audio_ref( eng_notation.str_to_num( str(self._audio_ref_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._audio_ref_tool_bar, 9, 3, 1, 1) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self._audio_max_gain_tool_bar = Qt.QToolBar(self) self._audio_max_gain_tool_bar.addWidget( Qt.QLabel("audio_max_gain" + ": ")) self._audio_max_gain_line_edit = Qt.QLineEdit(str(self.audio_max_gain)) self._audio_max_gain_tool_bar.addWidget(self._audio_max_gain_line_edit) self._audio_max_gain_line_edit.returnPressed.connect( lambda: self.set_audio_max_gain( eng_notation.str_to_num( str(self._audio_max_gain_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._audio_max_gain_tool_bar, 9, 5, 1, 1) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(5, 6): self.top_grid_layout.setColumnStretch(c, 1) self._audio_gain_tool_bar = Qt.QToolBar(self) self._audio_gain_tool_bar.addWidget(Qt.QLabel("audio_gain" + ": ")) self._audio_gain_line_edit = Qt.QLineEdit(str(self.audio_gain)) self._audio_gain_tool_bar.addWidget(self._audio_gain_line_edit) self._audio_gain_line_edit.returnPressed.connect( lambda: self.set_audio_gain( eng_notation.str_to_num( str(self._audio_gain_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._audio_gain_tool_bar, 9, 4, 1, 1) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 5): self.top_grid_layout.setColumnStretch(c, 1) self._audio_decay_tool_bar = Qt.QToolBar(self) self._audio_decay_tool_bar.addWidget(Qt.QLabel("audio_decay" + ": ")) self._audio_decay_line_edit = Qt.QLineEdit(str(self.audio_decay)) self._audio_decay_tool_bar.addWidget(self._audio_decay_line_edit) self._audio_decay_line_edit.returnPressed.connect( lambda: self.set_audio_decay( eng_notation.str_to_num( str(self._audio_decay_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._audio_decay_tool_bar, 9, 2, 1, 1) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self._audio_attack_tool_bar = Qt.QToolBar(self) self._audio_attack_tool_bar.addWidget(Qt.QLabel("audio_attack" + ": ")) self._audio_attack_line_edit = Qt.QLineEdit(str(self.audio_attack)) self._audio_attack_tool_bar.addWidget(self._audio_attack_line_edit) self._audio_attack_line_edit.returnPressed.connect( lambda: self.set_audio_attack( eng_notation.str_to_num( str(self._audio_attack_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._audio_attack_tool_bar, 9, 1, 1, 1) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.uhd_usrp_source_1 = uhd.usrp_source( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_1.set_clock_source('external', 0) self.uhd_usrp_source_1.set_time_source('external', 0) self.uhd_usrp_source_1.set_subdev_spec('A:AB', 0) self.uhd_usrp_source_1.set_samp_rate(samp_rate) self.uhd_usrp_source_1.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_1.set_center_freq(uhd.tune_request(rx_freq, ), 0) self.uhd_usrp_source_1.set_gain(0, 0) self.uhd_usrp_source_1.set_auto_dc_offset(True, 0) self.uhd_usrp_source_1.set_auto_iq_balance(True, 0) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=1, decimation=4, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=200, decimation=int(samp_rate / 1e3), taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=interp, decimation=int(decim), taps=None, fractional_bw=None, ) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate / decim * interp / 3, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 8, 0, 1, 4) for r in range(8, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0.set_update_time(0.010) self.qtgui_number_sink_0.set_title('') labels = ["RSSI", '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("blue", "red"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, 0) self.qtgui_number_sink_0.set_max(i, 50) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 5, 6, 1, 1) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 7): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim * interp / 3, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.0010) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(True) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ['', 'processed', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 6, 4, 3, 2) for r in range(6, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim * interp, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.010) self.qtgui_freq_sink_x_0.set_y_axis(-120, -10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['pre-d', 'processed', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 4, 4, 4) for r in range(0, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.low_pass_filter_0_1 = filter.interp_fir_filter_fff( 1, firdes.low_pass(1, samp_rate / decim * interp / 3, 1.5e3, 100, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 3, firdes.low_pass(1, samp_rate / decim * interp, lpf_cutoff, 100, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.interp_fir_filter_fff( 1, firdes.low_pass(1, samp_rate / decim * interp / 3, 1.5e3, 100, firdes.WIN_HAMMING, 6.76)) self._freq_label_tool_bar = Qt.QToolBar(self) if None: self._freq_label_formatter = None else: self._freq_label_formatter = lambda x: eng_notation.num_to_str(x) self._freq_label_tool_bar.addWidget(Qt.QLabel('Tuned Freq' + ": ")) self._freq_label_label = Qt.QLabel( str(self._freq_label_formatter(self.freq_label))) self._freq_label_tool_bar.addWidget(self._freq_label_label) self.top_grid_layout.addWidget(self._freq_label_tool_bar, 5, 4, 1, 1) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 5): self.top_grid_layout.setColumnStretch(c, 1) self.fosphor_qt_sink_c_0 = fosphor.qt_sink_c() self.fosphor_qt_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS) self.fosphor_qt_sink_c_0.set_frequency_range( rx_freq, samp_rate / int(samp_rate / 1e3) * 200) self._fosphor_qt_sink_c_0_win = sip.wrapinstance( self.fosphor_qt_sink_c_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._fosphor_qt_sink_c_0_win, 0, 0, 4, 4) for r in range(0, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.blocks_multiply_xx_1_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_matrix_xx_0_0_0 = blocks.multiply_matrix_cc( (selection[ssb_am], ), gr.TPP_ALL_TO_ALL) self.blocks_multiply_matrix_xx_0 = blocks.multiply_matrix_ff( (selection[ssb_am], ), gr.TPP_ALL_TO_ALL) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff( (100000, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff( (usb_lsb, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (volume, )) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( 1000, 1 / 1000.0, 4000, 1) self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.audio_sink_0 = audio.sink(16000, '', True) self.analog_sig_source_x_0_0_0 = analog.sig_source_f( samp_rate / decim * interp / 3, analog.GR_SIN_WAVE, 1.5e3, 1, 0) self.analog_sig_source_x_0_0 = analog.sig_source_f( samp_rate / decim * interp / 3, analog.GR_COS_WAVE, 1.5e3, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -1 * (fine_freq + coarse_freq), 1, 0) self.analog_pll_carriertracking_cc_0 = analog.pll_carriertracking_cc( math.pi / pll_lbw, math.pi / pll_freq, -math.pi / pll_freq) self.analog_agc2_xx_0_0 = analog.agc2_ff(audio_attack, audio_decay, audio_ref, audio_gain) self.analog_agc2_xx_0_0.set_max_gain(audio_max_gain) self.analog_agc2_xx_0 = analog.agc2_cc(0.1, decay_rate, .3, 1000) self.analog_agc2_xx_0.set_max_gain(65000) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.analog_agc2_xx_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.blocks_multiply_matrix_xx_0_0_0, 2)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.analog_sig_source_x_0_0_0, 0), (self.blocks_multiply_xx_1_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_matrix_xx_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.low_pass_filter_0_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_matrix_xx_0, 2)) self.connect((self.blocks_complex_to_real_0_0, 0), (self.blocks_multiply_matrix_xx_0, 1)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_multiply_matrix_xx_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.blocks_multiply_matrix_xx_0_0_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.blocks_multiply_matrix_xx_0_0_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_1_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.analog_pll_carriertracking_cc_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_complex_to_real_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_multiply_matrix_xx_0_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_multiply_matrix_xx_0_0_0, 1)) self.connect((self.low_pass_filter_0_1, 0), (self.blocks_multiply_xx_1_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.fosphor_qt_sink_c_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.uhd_usrp_source_1, 0), (self.analog_agc2_xx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Merapi Vco") Qt.QWidget.__init__(self) self.setWindowTitle("Merapi Vco") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "merapi_vco") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2.4e6 self.filt_len = filt_len = 1e6 self.ch_bw = ch_bw = 30e3 self.bb_rate = bb_rate = 192e3 self.audio_rate = audio_rate = 48e3 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=int(bb_rate), decimation=int(samp_rate), taps=None, fractional_bw=None, ) self.qtgui_time_sink_x_2 = qtgui.time_sink_f( 8192 * 8, #size audio_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_2.set_update_time(0.10) self.qtgui_time_sink_x_2.set_y_axis(-10, 10) self.qtgui_time_sink_x_2.set_y_label('Amplitude', "") self.qtgui_time_sink_x_2.enable_tags(-1, True) self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 8, 0, 0, "") self.qtgui_time_sink_x_2.enable_autoscale(False) self.qtgui_time_sink_x_2.enable_grid(False) self.qtgui_time_sink_x_2.enable_axis_labels(True) self.qtgui_time_sink_x_2.enable_control_panel(False) if not True: self.qtgui_time_sink_x_2.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_2.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_2_win = sip.wrapinstance( self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_2_win) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 8192 * 8, #size audio_rate, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size audio_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2 * 1): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 8192, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc bb_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-100, -20) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(0.2) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_1_win) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + '') self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(166.3e6, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(49, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.fft_filter_xxx_3 = filter.fft_filter_fff( 1, (firdes.low_pass(1, audio_rate, 100, 100, firdes.WIN_BLACKMAN)), 1) self.fft_filter_xxx_3.declare_sample_delay(0) self.fft_filter_xxx_2 = filter.fft_filter_ccc( 1, (firdes.complex_band_pass(1, audio_rate, 360, 2360, 1e3, firdes.WIN_BLACKMAN)), 1) self.fft_filter_xxx_2.declare_sample_delay(0) self.fft_filter_xxx_1 = filter.fft_filter_ccc(1, (firdes.low_pass( 1, bb_rate, ch_bw / 2, ch_bw / 10, firdes.WIN_BLACKMAN)), 1) self.fft_filter_xxx_1.declare_sample_delay(0) self.fft_filter_xxx_0 = filter.fft_filter_ccc(1, (firdes.low_pass( 1, samp_rate, bb_rate / 2, bb_rate / 10, firdes.WIN_BLACKMAN)), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_rotator_cc_0 = blocks.rotator_cc(502e3 / samp_rate * 2 * math.pi) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( int(filt_len), 1 / filt_len, 4000) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( audio_rate / (2 * math.pi * 1e3 / 8.0)) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=int(audio_rate), quad_rate=int(bb_rate), tau=75e-6, max_dev=5e3, ) ################################################## # Connections ################################################## self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.fft_filter_xxx_2, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_rotator_cc_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.fft_filter_xxx_3, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.fft_filter_xxx_1, 0), (self.analog_nbfm_rx_0, 0)) self.connect((self.fft_filter_xxx_2, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.fft_filter_xxx_3, 0), (self.qtgui_time_sink_x_1, 1)) self.connect((self.fft_filter_xxx_3, 0), (self.qtgui_time_sink_x_2, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_rotator_cc_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.fft_filter_xxx_1, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_1, 0))
def init(self, lookback = 1.0): samples = length * self.input.sample_rate scale = 1.0 / samples self.gr_block = blocks.moving_average_ff(int(samples), scale)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Keyfob Rx") ################################################## # Variables ################################################## self.sps = sps = 5 self.samp_rate = samp_rate = 48000 ################################################## # Blocks ################################################## self.wxgui_scopesink2_1 = scopesink2.scope_sink_f( self.GetWin(), title="Scope Plot", sample_rate=3400, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_1.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title="Scope Plot", sample_rate=3400 * 5, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_fff( 3393.75*sps/1000000.026491, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.osmosdr_source_0.set_sample_rate(1000000) self.osmosdr_source_0.set_center_freq(434400000, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(2, 0) self.osmosdr_source_0.set_if_gain(0, 0) self.osmosdr_source_0.set_bb_gain(0, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.keyfob_parse_packet_0 = keyfob.parse_packet() self.keyfob_manchester_decode_0 = keyfob.manchester_decode() self.digital_correlate_access_code_tag_bb_0 = digital.correlate_access_code_tag_bb("10101000", 0, "packet_start") self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(sps*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.05) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_moving_average_xx_1 = blocks.moving_average_ff(sps, 1.0/sps, 4000) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(10000, 1.0/10000, 4000) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_moving_average_xx_1, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.blocks_moving_average_xx_1, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.keyfob_manchester_decode_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.wxgui_scopesink2_1, 0)) self.connect((self.digital_correlate_access_code_tag_bb_0, 0), (self.keyfob_parse_packet_0, 0)) self.connect((self.keyfob_manchester_decode_0, 0), (self.digital_correlate_access_code_tag_bb_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_moving_average_xx_1, 0))
def __init__(self): gr.top_block.__init__(self, "Wwv X310 Corr 1") Qt.QWidget.__init__(self) self.setWindowTitle("Wwv X310 Corr 1") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "wwv_x310_corr_1") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.ts_str = ts_str = dt.strftime(dt.utcnow(), "%Y-%m-%dT%H:%M:%S.%fZ") self.y_min = y_min = -60 self.y_max = y_max = 0 self.variable_qtgui_label_0 = variable_qtgui_label_0 = ts_str self.samp_rate = samp_rate = 500e3 self.rx_freq = rx_freq = 4.51e6 self.nfft = nfft = 1024*32 self.lpf_cutoff = lpf_cutoff = 50e3 self.delay = delay = 0 self.decim = decim = 1 self.decay_rate = decay_rate = 20e-3 self.c_ms = c_ms = 299792458 ################################################## # Blocks ################################################## self.main_tab = Qt.QTabWidget() self.main_tab_widget_0 = Qt.QWidget() self.main_tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.main_tab_widget_0) self.main_tab_grid_layout_0 = Qt.QGridLayout() self.main_tab_layout_0.addLayout(self.main_tab_grid_layout_0) self.main_tab.addTab(self.main_tab_widget_0, 'Main') self.main_tab_widget_1 = Qt.QWidget() self.main_tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.main_tab_widget_1) self.main_tab_grid_layout_1 = Qt.QGridLayout() self.main_tab_layout_1.addLayout(self.main_tab_grid_layout_1) self.main_tab.addTab(self.main_tab_widget_1, 'Corr') self.top_grid_layout.addWidget(self.main_tab, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._y_min_tool_bar = Qt.QToolBar(self) self._y_min_tool_bar.addWidget(Qt.QLabel('FREQ'+": ")) self._y_min_line_edit = Qt.QLineEdit(str(self.y_min)) self._y_min_tool_bar.addWidget(self._y_min_line_edit) self._y_min_line_edit.returnPressed.connect( lambda: self.set_y_min(eng_notation.str_to_num(str(self._y_min_line_edit.text().toAscii())))) self.main_tab_grid_layout_0.addWidget(self._y_min_tool_bar, 8, 4, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(4, 5): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self._y_max_tool_bar = Qt.QToolBar(self) self._y_max_tool_bar.addWidget(Qt.QLabel('FREQ'+": ")) self._y_max_line_edit = Qt.QLineEdit(str(self.y_max)) self._y_max_tool_bar.addWidget(self._y_max_line_edit) self._y_max_line_edit.returnPressed.connect( lambda: self.set_y_max(eng_notation.str_to_num(str(self._y_max_line_edit.text().toAscii())))) self.main_tab_grid_layout_0.addWidget(self._y_max_tool_bar, 8, 5, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(5, 6): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel('SAMP_RATE'+": ")) self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate)) self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit) self._samp_rate_line_edit.returnPressed.connect( lambda: self.set_samp_rate(eng_notation.str_to_num(str(self._samp_rate_line_edit.text().toAscii())))) self.main_tab_grid_layout_0.addWidget(self._samp_rate_tool_bar, 8, 0, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self._rx_freq_tool_bar = Qt.QToolBar(self) self._rx_freq_tool_bar.addWidget(Qt.QLabel('FREQ'+": ")) self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq)) self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit) self._rx_freq_line_edit.returnPressed.connect( lambda: self.set_rx_freq(eng_notation.str_to_num(str(self._rx_freq_line_edit.text().toAscii())))) self.main_tab_grid_layout_0.addWidget(self._rx_freq_tool_bar, 8, 1, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self._lpf_cutoff_tool_bar = Qt.QToolBar(self) self._lpf_cutoff_tool_bar.addWidget(Qt.QLabel("lpf_cutoff"+": ")) self._lpf_cutoff_line_edit = Qt.QLineEdit(str(self.lpf_cutoff)) self._lpf_cutoff_tool_bar.addWidget(self._lpf_cutoff_line_edit) self._lpf_cutoff_line_edit.returnPressed.connect( lambda: self.set_lpf_cutoff(eng_notation.str_to_num(str(self._lpf_cutoff_line_edit.text().toAscii())))) self.main_tab_grid_layout_0.addWidget(self._lpf_cutoff_tool_bar, 8, 3, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(3, 4): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self._delay_tool_bar = Qt.QToolBar(self) self._delay_tool_bar.addWidget(Qt.QLabel('corr_delay'+": ")) self._delay_line_edit = Qt.QLineEdit(str(self.delay)) self._delay_tool_bar.addWidget(self._delay_line_edit) self._delay_line_edit.returnPressed.connect( lambda: self.set_delay(eng_notation.str_to_num(str(self._delay_line_edit.text().toAscii())))) self.main_tab_grid_layout_1.addWidget(self._delay_tool_bar, 8, 0, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self._decay_rate_options = (100e-6, 65e-3, 20e-3, ) self._decay_rate_labels = ('Fast', 'Medium', 'Slow', ) self._decay_rate_group_box = Qt.QGroupBox("decay_rate") self._decay_rate_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._decay_rate_button_group = variable_chooser_button_group() self._decay_rate_group_box.setLayout(self._decay_rate_box) for i, label in enumerate(self._decay_rate_labels): radio_button = Qt.QRadioButton(label) self._decay_rate_box.addWidget(radio_button) self._decay_rate_button_group.addButton(radio_button, i) self._decay_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(self._decay_rate_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._decay_rate_options.index(i))) self._decay_rate_callback(self.decay_rate) self._decay_rate_button_group.buttonClicked[int].connect( lambda i: self.set_decay_rate(self._decay_rate_options[i])) self.main_tab_grid_layout_0.addWidget(self._decay_rate_group_box, 8, 2, 1, 1) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(2, 3): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_formatter = None else: self._variable_qtgui_label_0_formatter = lambda x: str(x) self._variable_qtgui_label_0_tool_bar.addWidget(Qt.QLabel('Start Time [UTC]'+": ")) self._variable_qtgui_label_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_formatter(self.variable_qtgui_label_0))) self._variable_qtgui_label_0_tool_bar.addWidget(self._variable_qtgui_label_0_label) self.main_tab_grid_layout_0.addWidget(self._variable_qtgui_label_0_tool_bar, 8, 6, 1, 2) for r in range(8, 9): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(6, 8): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self.uhd_usrp_source_1 = uhd.usrp_source( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_1.set_clock_source('gpsdo', 0) self.uhd_usrp_source_1.set_time_source('gpsdo', 0) self.uhd_usrp_source_1.set_subdev_spec('A:AB B:AB', 0) self.uhd_usrp_source_1.set_samp_rate(samp_rate) self.uhd_usrp_source_1.set_time_unknown_pps(uhd.time_spec()) self.uhd_usrp_source_1.set_center_freq(uhd.tune_request(rx_freq), 0) self.uhd_usrp_source_1.set_gain(0, 0) self.uhd_usrp_source_1.set_antenna('A', 0) self.uhd_usrp_source_1.set_auto_dc_offset(True, 0) self.uhd_usrp_source_1.set_auto_iq_balance(True, 0) self.uhd_usrp_source_1.set_center_freq(uhd.tune_request(rx_freq), 1) self.uhd_usrp_source_1.set_gain(0, 1) self.uhd_usrp_source_1.set_antenna('A', 1) self.uhd_usrp_source_1.set_auto_dc_offset(True, 1) self.uhd_usrp_source_1.set_auto_iq_balance(True, 1) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate / decim, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0_0.enable_grid(False) self.qtgui_waterfall_sink_x_0_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0_0.set_intensity_range(-140, -40) self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_0_win, 4, 4, 4, 4) for r in range(4, 8): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(4, 8): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate / decim, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, -40) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win, 4, 0, 4, 4) for r in range(4, 8): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 4): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 10, #size samp_rate/decim, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.010) self.qtgui_time_sink_x_0_0.set_y_axis(-20, 20) self.qtgui_time_sink_x_0_0.set_y_label('Range Delta [km]', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_0_win, 4, 0, 2, 4) for r in range(4, 6): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 4): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( nfft, #size samp_rate/decim, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Correlation', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win, 0, 4, 4, 4) for r in range(0, 4): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(4, 8): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 3 ) self.qtgui_number_sink_0.set_update_time(0.010) self.qtgui_number_sink_0.set_title("") labels = ['Delay', '', 'Range Delta', '', '', '', '', '', '', ''] units = ['[usec]', '', '[km]', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(3): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(True) self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_1.addWidget(self._qtgui_number_sink_0_win, 6, 0, 1, 2) for r in range(6, 7): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 2): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self.qtgui_histogram_sink_x_0_0 = qtgui.histogram_sink_f( 20, 1000, 0, 100e4, "", 1 ) self.qtgui_histogram_sink_x_0_0.set_update_time(0.010) self.qtgui_histogram_sink_x_0_0.enable_autoscale(True) self.qtgui_histogram_sink_x_0_0.enable_accumulate(True) self.qtgui_histogram_sink_x_0_0.enable_grid(False) self.qtgui_histogram_sink_x_0_0.enable_axis_labels(True) if not True: self.qtgui_histogram_sink_x_0_0.disable_legend() labels = ['Correlation Magnitude', 'Corr Mag', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_histogram_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_histogram_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_histogram_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_histogram_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_histogram_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_histogram_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_histogram_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_histogram_sink_x_0_0_win = sip.wrapinstance(self.qtgui_histogram_sink_x_0_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_1.addWidget(self._qtgui_histogram_sink_x_0_0_win, 0, 0, 4, 4) for r in range(0, 4): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 4): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f( 20, 2000, -25*1/(samp_rate/decim) *c_ms / 1000.0, 25*1/(samp_rate/decim) *c_ms / 1000.0, "", 1 ) self.qtgui_histogram_sink_x_0.set_update_time(0.010) self.qtgui_histogram_sink_x_0.enable_autoscale(True) self.qtgui_histogram_sink_x_0.enable_accumulate(True) self.qtgui_histogram_sink_x_0.enable_grid(False) self.qtgui_histogram_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_histogram_sink_x_0.disable_legend() labels = ['Range Delta [km]', 'Corr Mag', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_histogram_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_histogram_sink_x_0.set_line_label(i, labels[i]) self.qtgui_histogram_sink_x_0.set_line_width(i, widths[i]) self.qtgui_histogram_sink_x_0.set_line_color(i, colors[i]) self.qtgui_histogram_sink_x_0.set_line_style(i, styles[i]) self.qtgui_histogram_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_histogram_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_histogram_sink_x_0_win = sip.wrapinstance(self.qtgui_histogram_sink_x_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_1.addWidget(self._qtgui_histogram_sink_x_0_win, 4, 4, 2, 4) for r in range(4, 6): self.main_tab_grid_layout_1.setRowStretch(r, 1) for c in range(4, 8): self.main_tab_grid_layout_1.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate /decim, #bw "E/W Dipole", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.010) self.qtgui_freq_sink_x_0_0.set_y_axis(y_min, y_max) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(True) self.qtgui_freq_sink_x_0_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_win, 0, 4, 4, 4) for r in range(0, 4): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(4, 8): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate / decim, #bw "N/S Dipole", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.010) self.qtgui_freq_sink_x_0.set_y_axis(y_min, y_max) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.main_tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 4, 4) for r in range(0, 4): self.main_tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 4): self.main_tab_grid_layout_0.setColumnStretch(c, 1) self.low_pass_filter_1 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate/decim, lpf_cutoff, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate/decim, lpf_cutoff, 1e3, firdes.WIN_HAMMING, 6.76)) self.fft_vxx_2 = fft.fft_vcc(nfft, True, (window.blackmanharris(nfft)), True, 4) self.fft_vxx_1 = fft.fft_vcc(nfft, False, (window.blackmanharris(nfft)), False, 4) self.fft_vxx_0 = fft.fft_vcc(nfft, False, (window.blackmanharris(nfft)), False, 4) self.blocks_vector_to_stream_1 = blocks.vector_to_stream(gr.sizeof_float*1, nfft) self.blocks_stream_to_vector_1 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, nfft) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, nfft) self.blocks_short_to_float_0 = blocks.short_to_float(1, 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_short*1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((1/(samp_rate/decim) *c_ms / 1000.0, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1/(samp_rate/decim) * 1e6, )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(nfft) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(10, .1, 4000, 1) self.blocks_max_xx_0 = blocks.max_ff(nfft,1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, int(delay)) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(nfft) self.blocks_argmax_xx_0 = blocks.argmax_fs(nfft) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-nfft/2.0, )) self.analog_agc2_xx_0_0 = analog.agc2_cc(decay_rate, decay_rate, 1.0, .5) self.analog_agc2_xx_0_0.set_max_gain(65536) self.analog_agc2_xx_0 = analog.agc2_cc(decay_rate, decay_rate, 1.0, .5) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.analog_agc2_xx_0_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_argmax_xx_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_argmax_xx_0, 0), (self.blocks_short_to_float_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_argmax_xx_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_max_xx_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_vector_to_stream_1, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_stream_to_vector_1, 0)) self.connect((self.blocks_max_xx_0, 0), (self.qtgui_histogram_sink_x_0_0, 0)) self.connect((self.blocks_max_xx_0, 0), (self.qtgui_number_sink_0, 1)) self.connect((self.blocks_max_xx_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_histogram_sink_x_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_number_sink_0, 2)) self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.fft_vxx_2, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_stream_to_vector_1, 0), (self.fft_vxx_1, 0)) self.connect((self.blocks_vector_to_stream_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.fft_vxx_1, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.fft_vxx_2, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.low_pass_filter_1, 0), (self.blocks_delay_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.qtgui_freq_sink_x_0_0, 1)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_waterfall_sink_x_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.uhd_usrp_source_1, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.uhd_usrp_source_1, 1), (self.analog_agc2_xx_0_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="DVBT Scanner") ################################################## # Variables ################################################## self.threshold = threshold = -60 self.signal_level = signal_level = 0 self.samp_rate = samp_rate = 2048000 self.freq = freq = 525200000 self.fft_size = fft_size = 1024 self.detected = detected = 0 ################################################## # Blocks ################################################## _threshold_sizer = wx.BoxSizer(wx.VERTICAL) self._threshold_text_box = forms.text_box( parent=self.GetWin(), sizer=_threshold_sizer, value=self.threshold, callback=self.set_threshold, label="Threshold", converter=forms.float_converter(), proportion=0, ) self._threshold_slider = forms.slider( parent=self.GetWin(), sizer=_threshold_sizer, value=self.threshold, callback=self.set_threshold, minimum=-100, maximum=0, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_threshold_sizer, 2, 0, 1, 1) self.probe_signal_lvl = blocks.probe_signal_f() self.notebook = self.notebook = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "Spektrum") self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "Output") self.GridAdd(self.notebook, 0, 0, 1, 1) _freq_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, label="Frequency", converter=forms.float_converter(), proportion=0, ) self._freq_slider = forms.slider( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, minimum=478000000, maximum=862000000, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_freq_sizer, 1, 0, 1, 1) self.wxgui_numbersink2_1 = numbersink2.number_sink_f( self.notebook.GetPage(1).GetWin(), unit="Signal present", minval=0, maxval=1, factor=1.0, decimal_places=0, ref_level=0, sample_rate=samp_rate, number_rate=15, average=False, avg_alpha=None, label="Signal Detection", peak_hold=False, show_gauge=True, ) self.notebook.GetPage(1).Add(self.wxgui_numbersink2_1.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.notebook.GetPage(1).GetWin(), unit="dB", minval=-120, maxval=0, factor=1.0, decimal_places=1, ref_level=0, sample_rate=samp_rate, number_rate=15, average=False, avg_alpha=0.03, label="Level", peak_hold=False, show_gauge=True, ) self.notebook.GetPage(1).Add(self.wxgui_numbersink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.notebook.GetPage(0).GetWin(), baseband_freq=freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=fft_size, fft_rate=15, average=True, avg_alpha=0.03, title="FFT Plot", peak_hold=False, win=window.flattop, ) self.notebook.GetPage(0).Add(self.wxgui_fftsink2_0.win) def _signal_level_probe(): while True: val = self.probe_signal_lvl.level() try: self.set_signal_level(val) except AttributeError: pass time.sleep(1.0 / (5)) _signal_level_thread = threading.Thread(target=_signal_level_probe) _signal_level_thread.daemon = True _signal_level_thread.start() self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "hackrf=0" ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(14, 0) self.rtlsdr_source_0.set_if_gain(24, 0) self.rtlsdr_source_0.set_bb_gain(12, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.probe_detected = blocks.probe_signal_f() self.fft_vxx_0 = fft.fft_vcc(fft_size, True, (window.rectangular(fft_size)), True, 1) def _detected_probe(): while True: val = self.probe_detected.level() try: self.set_detected(val) except AttributeError: pass time.sleep(1.0 / (5)) _detected_thread = threading.Thread(target=_detected_probe) _detected_thread.daemon = True _detected_thread.start() self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_float*1, fft_size) self.blocks_threshold_ff_0 = blocks.threshold_ff(threshold, threshold, threshold) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_size) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(1000, 0.001, 4000) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(fft_size) self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 1048580) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.probe_signal_lvl, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.probe_detected, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.wxgui_numbersink2_1, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0, 0))
try: self.set_probe_detection(val) except AttributeError, e: pass time.sleep(1.0 / (10)) _probe_detection_thread = threading.Thread(target=_probe_detection_probe) _probe_detection_thread.daemon = True _probe_detection_thread.start() self.fft_vxx_0 = fft.fft_vcc(fft_size, True, (window.rectangular(fft_size)), True, 1) self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_float * 1, fft_size) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate) self.blocks_threshold_ff_0 = blocks.threshold_ff(threshold, threshold, threshold) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex * 1, fft_size) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(fft_size, 1.0 / fft_size, 4000) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(fft_size) self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, fft_size * fft_size) ################################################## # Connections ################################################## self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.analog_const_source_x_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_1, 0))
def __init__(self, ampl=0.7, args='', arq_timeout=.1*0 + 0.04, dest_addr=-1, iface='tun0', max_arq_attempts=5 * 2, mtu=128, ogradio_addr=0, ogrx_freq=915e6, ogtx_freq=915e6, port="12345", rate=1e6, rx_antenna="TX/RX", rx_gain=65-20, rx_lo_offset=0, samps_per_sym=4, tx_gain=45, tx_lo_offset=0): grc_wxgui.top_block_gui.__init__(self, title="Broadcastwithfreqnomac") self._lock = threading.RLock() ################################################## # Parameters ################################################## self.ampl = ampl self.args = args self.arq_timeout = arq_timeout self.dest_addr = dest_addr self.iface = iface self.max_arq_attempts = max_arq_attempts self.mtu = mtu self.ogradio_addr = ogradio_addr self.ogrx_freq = ogrx_freq self.ogtx_freq = ogtx_freq self.port = port self.rate = rate self.rx_antenna = rx_antenna self.rx_gain = rx_gain self.rx_lo_offset = rx_lo_offset self.samps_per_sym = samps_per_sym self.tx_gain = tx_gain self.tx_lo_offset = tx_lo_offset ################################################## # Variables ################################################## self.user_tx_gain = user_tx_gain = tx_gain self.user_rx_gain = user_rx_gain = rx_gain self.tx_freq = tx_freq = 915e6 self.samp_rate = samp_rate = rate self.rx_freq = rx_freq = 915e6 ################################################## # Blocks ################################################## _user_tx_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._user_tx_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_user_tx_gain_sizer, value=self.user_tx_gain, callback=self.set_user_tx_gain, label="TX Gain", converter=forms.float_converter(), proportion=0, ) self._user_tx_gain_slider = forms.slider( parent=self.GetWin(), sizer=_user_tx_gain_sizer, value=self.user_tx_gain, callback=self.set_user_tx_gain, minimum=0, maximum=90, num_steps=90, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_user_tx_gain_sizer) _user_rx_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._user_rx_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_user_rx_gain_sizer, value=self.user_rx_gain, callback=self.set_user_rx_gain, label="RX Gain", converter=forms.float_converter(), proportion=0, ) self._user_rx_gain_slider = forms.slider( parent=self.GetWin(), sizer=_user_rx_gain_sizer, value=self.user_rx_gain, callback=self.set_user_rx_gain, minimum=0, maximum=90, num_steps=90, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_user_rx_gain_sizer) self._tx_freq_text_box = forms.text_box( parent=self.GetWin(), value=self.tx_freq, callback=self.set_tx_freq, label='tx_freq', converter=forms.float_converter(), ) self.Add(self._tx_freq_text_box) self._rx_freq_text_box = forms.text_box( parent=self.GetWin(), value=self.rx_freq, callback=self.set_rx_freq, label='rx_freq', converter=forms.float_converter(), ) self.Add(self._rx_freq_text_box) self.wxgui_scopesink2_0_0 = scopesink2.scope_sink_c( self.GetWin(), title="RX", sample_rate=samp_rate, v_scale=0.02, v_offset=0, t_scale=0.0001, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=wxgui.TRIG_MODE_NORM, y_axis_label="Counts", ) self.GridAdd(self.wxgui_scopesink2_0_0.win, 0, 0, 1, 1) self.gmsk_radio_0 = gmsk_radio( access_code_threshold=0 + 12 + 4*0, samps_per_sym=samps_per_sym, tx_lo_offset=tx_lo_offset, rx_lo_offset=rx_lo_offset, ampl=ampl, rx_gain=user_rx_gain, rx_freq=rx_freq, rx_ant=rx_antenna, tx_freq=tx_freq, tx_gain=user_tx_gain, args=args, rate=samp_rate, ) self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu(iface, mtu*0 + 1532, False) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1, )) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(10000, 1./10000, 40000/4) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'), (self.gmsk_radio_0, 'msg_in')) self.msg_connect((self.gmsk_radio_0, 'msg_out'), (self.blocks_tuntap_pdu_0, 'pdus')) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.wxgui_scopesink2_0_0, 1)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.gmsk_radio_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.gmsk_radio_0, 0), (self.wxgui_scopesink2_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Tetra Rx Multi") options = self.get_options() self.src = blocks.file_source(gr.sizeof_gr_complex*1, "/tmp/myout1.ch", False) ################################################## # Variables ################################################## self.srate_rx = srate_rx = options.sample_rate self.channels = srate_rx / 25000 self.srate_channel = 36000 self.afc_period = 15 self.afc_gain = 0.01 self.afc_channel = options.auto_tune or -1 self.afc_ppm_step = 100 self.debug = options.debug self.last_pwr = -100000 self.sig_det_period = 10 self.sig_det_bw = sig_det_bw = options.sig_detection_bw or srate_rx if self.sig_det_bw <= 1.: self.sig_det_bw *= srate_rx self.sig_det_threshold = options.sig_detection_threshold self.sig_det_channels = [] for ch in range(self.channels): if ch >= self.channels / 2: ch_ = (self.channels - ch - 1) else: ch_ = ch if (float(ch_) / self.channels * 2) <= (self.sig_det_bw / srate_rx): self.sig_det_channels.append(ch) self.channels = 10 ################################################## # RPC server ################################################## self.xmlrpc_server = SimpleXMLRPCServer.SimpleXMLRPCServer( ("localhost", options.listen_port), allow_none=True) self.xmlrpc_server.register_instance(self) threading.Thread(target=self.xmlrpc_server.serve_forever).start() ################################################## # Rx Blocks and connections ################################################## out_type, dst_path = options.output.split("://", 1) if out_type == "udp": dst_ip, dst_port = dst_path.split(':', 1) self.blocks_deinterleave_0 = blocks.deinterleave(gr.sizeof_gr_complex*1, 1) self.squelch = [] self.digital_mpsk_receiver_cc = [] self.diff_phasor = [] self.complex_to_arg = [] self.multiply_const = [] self.add_const = [] self.float_to_uchar = [] self.map_bits = [] self.unpack_k_bits = [] self.blocks_sink = [] for ch in range(0, self.channels): mpsk = digital.mpsk_receiver_cc( 4, math.pi/4, math.pi/100.0, -0.5, 0.5, 0.25, 0.001, 2, 0.001, 0.001) diff_phasor = digital.diff_phasor_cc() complex_to_arg = blocks.complex_to_arg(1) multiply_const = blocks.multiply_const_vff((2./math.pi, )) add_const = blocks.add_const_vff((1.5, )) float_to_uchar = blocks.float_to_uchar() map_bits = digital.map_bb(([3, 2, 0, 1, 3])) unpack_k_bits = blocks.unpack_k_bits_bb(2) brmchannels = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71] #brmchannels = [11,4,3,64,45,47,53,8,68,6,56,49,17,54,65,5,71,22,48,7,50] # itds kancl #brmchannels = [23,13,40,69,59,7,42,54,5,14,4,56,45,46,67,55,66,44,71,49,31,57,0,65,70] # doma - dole #brmchannels = [23,13,59,40,69,7,49,60,42,70,4,50,66,67,3,14,57,33,46,22,68,32,39,24,6,12,43,58,48,17,5,56,65,29,54,30,16,52,53,41,47,2,34,44,8] # doma - strecha #brmchannels = [67, 7, 23, 70] # doma - strecha - SDS #brmchannels = [67, 7, 23, 70,9,71,64,63,62,61,55,51,45,38,37,36,35,31,28,27,26,25,21,20,19,18,15,11,10,1,0] # doma - strecha - komplement if out_type == 'udp': sink = blocks.udp_sink(gr.sizeof_gr_char, dst_ip, int(dst_port)+ch, 1472, True) elif out_type == 'file': sink = blocks.file_sink(gr.sizeof_char, dst_path % ch, False) sink.set_unbuffered(True) else: raise ValueError("Invalid output URL '%s'" % options.output) print "connect %i"%ch if ch in brmchannels: self.connect((self.blocks_deinterleave_0, ch), #(squelch, 0), (mpsk, 0), (diff_phasor, 0), (complex_to_arg, 0), (multiply_const, 0), (add_const, 0), (float_to_uchar, 0), (map_bits, 0), (unpack_k_bits, 0), (sink, 0)) self.digital_mpsk_receiver_cc.append(mpsk) self.diff_phasor.append(diff_phasor) self.complex_to_arg.append(complex_to_arg) self.multiply_const.append(multiply_const) self.add_const.append(add_const) self.float_to_uchar.append(float_to_uchar) self.map_bits.append(map_bits) self.unpack_k_bits.append(unpack_k_bits) self.blocks_sink.append(sink) self.connect( (self.src, 0), (self.blocks_deinterleave_0, 0)) ################################################## # signal strenght identification ################################################## ''' self.pwr_probes = [] for ch in range(self.channels): pwr_probe = analog.probe_avg_mag_sqrd_c(0, 1./self.srate_channel) self.pwr_probes.append(pwr_probe) print "connect %i"%ch self.connect((self.blocks_deinterleave_0, ch), (pwr_probe, 0)) def _sig_det_probe(): while True: pwr = [self.pwr_probes[ch].level() for ch in range(self.channels) if ch in self.sig_det_channels] pwr = [10 * math.log10(p) for p in pwr if p > 0.] if not pwr: continue pwr = min(pwr) + self.sig_det_threshold print "power threshold target %f"%pwr if abs(pwr - self.last_pwr) > (self.sig_det_threshold / 2): for s in []: s.set_threshold(pwr) self.last_pwr = pwr time.sleep(self.sig_det_period) if self.sig_det_threshold is not None: self._sig_det_probe_thread = threading.Thread(target=_sig_det_probe) self._sig_det_probe_thread.daemon = True self._sig_det_probe_thread.start() ''' ################################################## # AFC blocks and connections ################################################## self.afc_selector = grc_blks2.selector( item_size=gr.sizeof_gr_complex, num_inputs=self.channels, num_outputs=1, input_index=0, output_index=0, ) self.afc_demod = analog.quadrature_demod_cf(self.srate_channel/(2*math.pi)) samp_afc = self.srate_channel*self.afc_period / 2 self.afc_avg = blocks.moving_average_ff(samp_afc, 1./samp_afc*self.afc_gain) self.afc_probe = blocks.probe_signal_f() def _afc_probe(): rt = 0.0 while True: time.sleep(self.afc_period) if self.afc_channel == -1: continue err = self.afc_probe.level() freq = err * self.afc_gain print "err: %f\tfreq: %f\trt %f" % (err, freq, rt) changed = False if err < -1: rt += 0.1 changed = True elif err > 1: rt -= 0.1 changed = True if changed: os.system("echo \"setrot %f\" | nc localhost 3333"%rt) self.afc_channel = 0 self._afc_err_thread = threading.Thread(target=_afc_probe) self._afc_err_thread.daemon = True self._afc_err_thread.start() for ch in range(self.channels): print "connect %i"%ch self.connect((self.blocks_deinterleave_0, ch), (self.afc_selector, ch)) self.connect( (self.afc_selector, 0), (self.afc_demod, 0), (self.afc_avg, 0), (self.afc_probe, 0)) if self.afc_channel != -1: self.afc_selector.set_input_index(self.afc_channel)
def __init__(self, freq=1698e6, rate=2e6, frames_file=os.environ['HOME'] + '/data/noaa/frames/NOAA-XX.hrpt', rtlsdr="rtl=0", ifgain=20, satellite='NOAA-XX', sync_check=False, rfgain=40): grc_wxgui.top_block_gui.__init__(self, title="Enhanced NOAA HRPT Receiver using USB DVB-T Dongles") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.freq = freq self.rate = rate self.frames_file = frames_file self.rtlsdr = rtlsdr self.ifgain = ifgain self.satellite = satellite self.sync_check = sync_check self.rfgain = rfgain ################################################## # Variables ################################################## self.sym_rate = sym_rate = 600*1109 self.samp_rate = samp_rate = rate self.config_filename = config_filename = os.environ['HOME']+'/.gnuradio/rtlsdr_noaa_hrpt.conf' self.sps = sps = samp_rate/sym_rate self._saved_pll_alpha_config = ConfigParser.ConfigParser() self._saved_pll_alpha_config.read(config_filename) try: saved_pll_alpha = self._saved_pll_alpha_config.getfloat(satellite, 'pll_alpha') except: saved_pll_alpha = 0.005 self.saved_pll_alpha = saved_pll_alpha self._saved_clock_alpha_config = ConfigParser.ConfigParser() self._saved_clock_alpha_config.read(config_filename) try: saved_clock_alpha = self._saved_clock_alpha_config.getfloat(satellite, 'clock_alpha') except: saved_clock_alpha = 0.001 self.saved_clock_alpha = saved_clock_alpha self.sync_check_cb = sync_check_cb = sync_check self._saved_rf_gain_config = ConfigParser.ConfigParser() self._saved_rf_gain_config.read(config_filename) try: saved_rf_gain = self._saved_rf_gain_config.getfloat(satellite, 'rf-gain') except: saved_rf_gain = rfgain self.saved_rf_gain = saved_rf_gain self._saved_if_gain_config = ConfigParser.ConfigParser() self._saved_if_gain_config.read(config_filename) try: saved_if_gain = self._saved_if_gain_config.getfloat(satellite, 'if-gain') except: saved_if_gain = ifgain self.saved_if_gain = saved_if_gain self.satellite_text = satellite_text = satellite self.sample_rate_text = sample_rate_text = samp_rate self.rf_gain_slider = rf_gain_slider = rfgain self.rate_tb = rate_tb = rate self.pll_alpha = pll_alpha = saved_pll_alpha self.max_clock_offset = max_clock_offset = 0.1 self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/samp_rate self.if_gain_slider = if_gain_slider = ifgain self.hs = hs = int(sps/2.0) self.freq_tb = freq_tb = freq self.frames_outfile_text = frames_outfile_text = frames_file self.datetime_text = datetime_text = strftime("%A, %B %d %Y %H:%M:%S", localtime()) self.clock_alpha = clock_alpha = saved_clock_alpha ################################################## # Blocks ################################################## _rf_gain_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._rf_gain_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_rf_gain_slider_sizer, value=self.rf_gain_slider, callback=self.set_rf_gain_slider, label="RF Gain", converter=forms.int_converter(), proportion=0, ) self._rf_gain_slider_slider = forms.slider( parent=self.GetWin(), sizer=_rf_gain_slider_sizer, value=self.rf_gain_slider, callback=self.set_rf_gain_slider, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.GridAdd(_rf_gain_slider_sizer, 2, 0, 1, 1) _if_gain_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._if_gain_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_if_gain_slider_sizer, value=self.if_gain_slider, callback=self.set_if_gain_slider, label="IF Gain", converter=forms.int_converter(), proportion=0, ) self._if_gain_slider_slider = forms.slider( parent=self.GetWin(), sizer=_if_gain_slider_sizer, value=self.if_gain_slider, callback=self.set_if_gain_slider, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.GridAdd(_if_gain_slider_sizer, 2, 1, 1, 1) self.displays = self.displays = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.displays.AddPage(grc_wxgui.Panel(self.displays), "RX NOAA HRPT") self.displays.AddPage(grc_wxgui.Panel(self.displays), "Information") self.Add(self.displays) _clock_alpha_sizer = wx.BoxSizer(wx.VERTICAL) self._clock_alpha_text_box = forms.text_box( parent=self.GetWin(), sizer=_clock_alpha_sizer, value=self.clock_alpha, callback=self.set_clock_alpha, label="Clock alpha", converter=forms.float_converter(), proportion=0, ) self._clock_alpha_slider = forms.slider( parent=self.GetWin(), sizer=_clock_alpha_sizer, value=self.clock_alpha, callback=self.set_clock_alpha, minimum=0.001, maximum=0.1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_clock_alpha_sizer, 2, 3, 1, 1) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.displays.GetPage(0).GetWin(), baseband_freq=0, y_per_div=5, y_divs=10, ref_level=-30, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=5, average=True, avg_alpha=0.4, title="NOAA HRPT FFT Spectrum", peak_hold=False, ) self.displays.GetPage(0).Add(self.wxgui_fftsink2_0.win) self._sync_check_cb_check_box = forms.check_box( parent=self.GetWin(), value=self.sync_check_cb, callback=self.set_sync_check_cb, label="Continuous sync check", true=True, false=False, ) self.GridAdd(self._sync_check_cb_check_box, 1, 2, 1, 1) self._satellite_text_static_text = forms.static_text( parent=self.GetWin(), value=self.satellite_text, callback=self.set_satellite_text, label="Satellite", converter=forms.str_converter(), ) self.GridAdd(self._satellite_text_static_text, 0, 1, 1, 1) self._sample_rate_text_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.sample_rate_text, callback=self.set_sample_rate_text, label="Sample rate", converter=forms.float_converter(), ) self.displays.GetPage(1).GridAdd(self._sample_rate_text_static_text, 3, 0, 1, 1) self._rate_tb_text_box = forms.text_box( parent=self.GetWin(), value=self.rate_tb, callback=self.set_rate_tb, label="Sample rate", converter=forms.float_converter(), ) self.GridAdd(self._rate_tb_text_box, 1, 0, 1, 1) self.poesweather_noaa_hrpt_deframer_0 = poesweather.noaa_hrpt_deframer(False) _pll_alpha_sizer = wx.BoxSizer(wx.VERTICAL) self._pll_alpha_text_box = forms.text_box( parent=self.GetWin(), sizer=_pll_alpha_sizer, value=self.pll_alpha, callback=self.set_pll_alpha, label="PLL Alpha", converter=forms.float_converter(), proportion=0, ) self._pll_alpha_slider = forms.slider( parent=self.GetWin(), sizer=_pll_alpha_sizer, value=self.pll_alpha, callback=self.set_pll_alpha, minimum=0.005, maximum=0.5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_pll_alpha_sizer, 2, 2, 1, 1) self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset) self.osmosdr_source_c_0 = osmosdr.source_c( args="nchan=" + str(1) + " " + rtlsdr ) self.osmosdr_source_c_0.set_sample_rate(samp_rate) self.osmosdr_source_c_0.set_center_freq(freq, 0) self.osmosdr_source_c_0.set_freq_corr(0, 0) self.osmosdr_source_c_0.set_iq_balance_mode(0, 0) self.osmosdr_source_c_0.set_gain_mode(0, 0) self.osmosdr_source_c_0.set_gain(rf_gain_slider, 0) self.osmosdr_source_c_0.set_if_gain(if_gain_slider, 0) self._freq_tb_text_box = forms.text_box( parent=self.GetWin(), value=self.freq_tb, callback=self.set_freq_tb, label="Frequency", converter=forms.float_converter(), ) self.GridAdd(self._freq_tb_text_box, 1, 1, 1, 1) self._frames_outfile_text_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.frames_outfile_text, callback=self.set_frames_outfile_text, label="Frames filename", converter=forms.str_converter(), ) self.displays.GetPage(1).GridAdd(self._frames_outfile_text_static_text, 4, 0, 1, 1) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(sps/2.0, clock_alpha**2/4.0, 0.5, clock_alpha, max_clock_offset) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self._datetime_text_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.datetime_text, callback=self.set_datetime_text, label="Acquisition start", converter=forms.str_converter(), ) self.displays.GetPage(1).GridAdd(self._datetime_text_static_text, 2, 0, 1, 1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(hs, 1.0/hs, 4000) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_short*1, frames_file) self.blocks_file_sink_0.set_unbuffered(False) self.analog_agc_xx_0 = analog.agc_cc(1e-5, 1.0, 1.0/32768.0, 1.0) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.pll, 0)) self.connect((self.pll, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.poesweather_noaa_hrpt_deframer_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.poesweather_noaa_hrpt_deframer_0, 0)) self.connect((self.osmosdr_source_c_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.osmosdr_source_c_0, 0), (self.analog_agc_xx_0, 0))
def __init__(self, satellite='NOAA-XX', gain=35, freq=1698e6, sync_check=False, side="A:0", rate=2e6, frames_file=os.environ['HOME'] + '/data/noaa/frames/NOAA-XX.hrpt', baseband_file=os.environ['HOME'] + '/data/noaa/baseband/NOAA-XX.dat'): grc_wxgui.top_block_gui.__init__(self, title="Enhanced NOAA HRPT Receiver") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.satellite = satellite self.gain = gain self.freq = freq self.sync_check = sync_check self.side = side self.rate = rate self.frames_file = frames_file self.baseband_file = baseband_file ################################################## # Variables ################################################## self.sym_rate = sym_rate = 600*1109 self.samp_rate = samp_rate = rate self.config_filename = config_filename = os.environ['HOME']+'/.gnuradio/noaa_hrpt.conf' self.sps = sps = samp_rate/sym_rate self._saved_pll_alpha_config = ConfigParser.ConfigParser() self._saved_pll_alpha_config.read(config_filename) try: saved_pll_alpha = self._saved_pll_alpha_config.getfloat(satellite, 'pll_alpha') except: saved_pll_alpha = 0.005 self.saved_pll_alpha = saved_pll_alpha self._saved_clock_alpha_config = ConfigParser.ConfigParser() self._saved_clock_alpha_config.read(config_filename) try: saved_clock_alpha = self._saved_clock_alpha_config.getfloat(satellite, 'clock_alpha') except: saved_clock_alpha = 0.001 self.saved_clock_alpha = saved_clock_alpha self.sync_check_txt = sync_check_txt = sync_check self.side_text = side_text = side self._saved_gain_config = ConfigParser.ConfigParser() self._saved_gain_config.read(config_filename) try: saved_gain = self._saved_gain_config.getfloat(satellite, 'gain') except: saved_gain = gain self.saved_gain = saved_gain self.satellite_text = satellite_text = satellite self.sample_rate_text = sample_rate_text = samp_rate self.rate_tb = rate_tb = rate self.pll_alpha = pll_alpha = saved_pll_alpha self.max_clock_offset = max_clock_offset = 0.1 self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/samp_rate self.hs = hs = int(sps/2.0) self.gain_slider = gain_slider = gain self.freq_tb = freq_tb = freq self.frames_outfile_text = frames_outfile_text = frames_file self.datetime_text = datetime_text = strftime("%A, %B %d %Y %H:%M:%S", localtime()) self.clock_alpha = clock_alpha = saved_clock_alpha ################################################## # Blocks ################################################## _gain_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, label="Gain", converter=forms.int_converter(), proportion=0, ) self._gain_slider_slider = forms.slider( parent=self.GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.GridAdd(_gain_slider_sizer, 2, 0, 1, 1) self.displays = self.displays = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.displays.AddPage(grc_wxgui.Panel(self.displays), "RX NOAA HRPT") self.displays.AddPage(grc_wxgui.Panel(self.displays), "Information") self.Add(self.displays) _clock_alpha_sizer = wx.BoxSizer(wx.VERTICAL) self._clock_alpha_text_box = forms.text_box( parent=self.GetWin(), sizer=_clock_alpha_sizer, value=self.clock_alpha, callback=self.set_clock_alpha, label="Clock alpha", converter=forms.float_converter(), proportion=0, ) self._clock_alpha_slider = forms.slider( parent=self.GetWin(), sizer=_clock_alpha_sizer, value=self.clock_alpha, callback=self.set_clock_alpha, minimum=0.001, maximum=0.1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_clock_alpha_sizer, 2, 2, 1, 1) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.displays.GetPage(0).GetWin(), baseband_freq=0, y_per_div=5, y_divs=10, ref_level=-70, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.4, title="NOAA HRPT FFT Spectrum", peak_hold=False, ) self.displays.GetPage(0).Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_subdev_spec(side, 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(gain_slider, 0) self._sync_check_txt_static_text = forms.static_text( parent=self.GetWin(), value=self.sync_check_txt, callback=self.set_sync_check_txt, label="Continuous sync check", converter=forms.str_converter(), ) self.GridAdd(self._sync_check_txt_static_text, 0, 2, 1, 1) self._side_text_static_text = forms.static_text( parent=self.GetWin(), value=self.side_text, callback=self.set_side_text, label="USRP Side", converter=forms.str_converter(), ) self.GridAdd(self._side_text_static_text, 0, 0, 1, 1) self._satellite_text_static_text = forms.static_text( parent=self.GetWin(), value=self.satellite_text, callback=self.set_satellite_text, label="Satellite", converter=forms.str_converter(), ) self.GridAdd(self._satellite_text_static_text, 0, 1, 1, 1) self._sample_rate_text_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.sample_rate_text, callback=self.set_sample_rate_text, label="Sample rate", converter=forms.float_converter(), ) self.displays.GetPage(1).GridAdd(self._sample_rate_text_static_text, 3, 0, 1, 1) self._rate_tb_text_box = forms.text_box( parent=self.GetWin(), value=self.rate_tb, callback=self.set_rate_tb, label="Sample rate", converter=forms.float_converter(), ) self.GridAdd(self._rate_tb_text_box, 1, 0, 1, 1) self.poesweather_noaa_hrpt_deframer_0 = poesweather.noaa_hrpt_deframer(False) _pll_alpha_sizer = wx.BoxSizer(wx.VERTICAL) self._pll_alpha_text_box = forms.text_box( parent=self.GetWin(), sizer=_pll_alpha_sizer, value=self.pll_alpha, callback=self.set_pll_alpha, label="PLL Alpha", converter=forms.float_converter(), proportion=0, ) self._pll_alpha_slider = forms.slider( parent=self.GetWin(), sizer=_pll_alpha_sizer, value=self.pll_alpha, callback=self.set_pll_alpha, minimum=0.005, maximum=0.5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_pll_alpha_sizer, 2, 1, 1, 1) self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset) self._freq_tb_text_box = forms.text_box( parent=self.GetWin(), value=self.freq_tb, callback=self.set_freq_tb, label="Frequency", converter=forms.float_converter(), ) self.GridAdd(self._freq_tb_text_box, 1, 1, 1, 1) self._frames_outfile_text_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.frames_outfile_text, callback=self.set_frames_outfile_text, label="Frames filename", converter=forms.str_converter(), ) self.displays.GetPage(1).GridAdd(self._frames_outfile_text_static_text, 4, 0, 1, 1) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(sps/2.0, clock_alpha**2/4.0, 0.5, clock_alpha, max_clock_offset) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self._datetime_text_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.datetime_text, callback=self.set_datetime_text, label="Acquisition start", converter=forms.str_converter(), ) self.displays.GetPage(1).GridAdd(self._datetime_text_static_text, 2, 0, 1, 1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(hs, 1.0/hs, 4000) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_short*1, baseband_file) self.blocks_file_sink_1.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_short*1, frames_file) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_complex_to_interleaved_short_0 = blocks.complex_to_interleaved_short() self.analog_agc_xx_0 = analog.agc_cc(1e-5, 1.0, 1.0/32768.0, 1.0) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.pll, 0)) self.connect((self.pll, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.poesweather_noaa_hrpt_deframer_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.poesweather_noaa_hrpt_deframer_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_interleaved_short_0, 0)) self.connect((self.blocks_complex_to_interleaved_short_0, 0), (self.blocks_file_sink_1, 0))
def __init__(self, freq=394e6, gain=0, sample_rate=2400000, args="", channel_bw=12500, listen_port=60100, ppm=0, output="channel%d.bits", output_offset=None, auto_tune=-1): gr.top_block.__init__(self, "TETRAPOL multichannel reciever") ################################################## # Parameters and variables ################################################## self.freq = freq self.gain = gain self.sample_rate = sample_rate self.args = args self.channel_bw = channel_bw self.listen_port = listen_port self.ppm = ppm self.output = output self.auto_tune = auto_tune # TODO: parametrize self.debug = True self.channels = channels = int(sample_rate/channel_bw) channel_symb_rate = 8000 samples_per_symbol = 2 self.channel_samp_rate = channel_samp_rate = \ channel_symb_rate * samples_per_symbol afc_period = 6 self.afc_gain = 1 self.afc_ppm_threshold = 100 if output_offset is None: self.output_offset = 0 else: self.output_offset = output_offset - ((channels - 1) // 2) ################################################## # Blocks - RPC server ################################################## self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer( ("localhost", listen_port), allow_none=True) self.xmlrpc_server_0.register_instance(self) threading.Thread(target=self.xmlrpc_server_0.serve_forever).start() ################################################## # Blocks - RX, demod, sink ################################################## self.src = osmosdr.source( args="numchan=" + str(1) + " " + "" + self.args ) self.src.set_sample_rate(sample_rate) self.src.set_center_freq(freq, 0) self.src.set_freq_corr(ppm, 0) # TODO: manual gain control self.src.set_gain_mode(True, 0) #self.src.set_gain(gain, 0) self.freq_xlating = freq_xlating_fft_filter_ccc(1, (1, ), 0, sample_rate) bw = (9200 + self.afc_ppm_threshold)/2 self.channelizer = pfb.channelizer_ccf( channels, firdes.low_pass(1, sample_rate, bw, bw*0.15, firdes.WIN_HANN), float(channel_samp_rate)/(sample_rate/channels), 100) self.connect( (self.src, 0), (self.freq_xlating, 0), (self.channelizer, 0)) self.valves = [] self.gmsk_demods = [] self.file_sinks = [] even_no_of_chs = not (channels % 2) center_ch = channels // 2 for ch_in in range(0, channels): ch_out = (ch_in + center_ch + 1) % channels if ch_out == center_ch and even_no_of_chs: null_sink = blocks.null_sink(gr.sizeof_gr_complex) self.connect( (self.channelizer, ch_out), (null_sink, 0)) continue valve = grc_blks2.valve(item_size=gr.sizeof_gr_complex, open=True) gmsk_demod = digital.gmsk_demod( samples_per_symbol=samples_per_symbol, gain_mu=0.050, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) o = output % (ch_in + self.output_offset) file_sink = blocks.file_sink(gr.sizeof_char, o, False) file_sink.set_unbuffered(True) self.connect( (self.channelizer, ch_out), (valve, 0), (gmsk_demod, 0), (file_sink, 0)) self.valves.append(valve) self.gmsk_demods.append(gmsk_demod) self.file_sinks.append(file_sink) ################################################## # Blocks - automatic fine tune ################################################## self.afc_selector = grc_blks2.selector( item_size=gr.sizeof_gr_complex*1, num_inputs=channels - even_no_of_chs, num_outputs=1, input_index=0, output_index=0, ) if auto_tune != -1: self.afc_selector.set_input_index(auto_tune) self.afc_demod = analog.quadrature_demod_cf(channel_samp_rate/(2*math.pi)) afc_samp = channel_samp_rate * afc_period / 2 self.afc_avg = blocks.moving_average_ff(afc_samp, 1./afc_samp*self.afc_gain) self.afc_probe = blocks.probe_signal_f() def _afc_probe(): while True: time.sleep(afc_period) if self.auto_tune == -1: continue err = self.afc_probe.level() if abs(err) < self.afc_ppm_threshold: continue freq = self.freq_xlating.center_freq + err * self.afc_gain if self.debug: print "freq err: % .0f\tfreq: %f" % (err, freq) self.freq_xlating.set_center_freq(freq) self._afc_err_thread = threading.Thread(target=_afc_probe) self._afc_err_thread.daemon = True self._afc_err_thread.start() for ch_in in range(0, channels - even_no_of_chs): ch_out = (ch_in + center_ch + 1) % channels self.connect((self.channelizer, ch_out), (self.afc_selector, ch_in)) self.connect((self.afc_selector, 0), (self.afc_demod, 0), (self.afc_avg, 0), (self.afc_probe, 0)) ################################################## # Blocks - signal strenght indication ################################################## self.pwr_probes = [] for ch in range(self.channels - even_no_of_chs): ch = (ch + center_ch + 1) % channels pwr_probe = analog.probe_avg_mag_sqrd_c(0, 1./channel_samp_rate) self.connect((self.channelizer, ch), (pwr_probe, 0)) self.pwr_probes.append(pwr_probe)
def __init__(self): gr.top_block.__init__(self, "NC-OFDM loopback") Qt.QWidget.__init__(self) self.setWindowTitle("NC-OFDM loopback") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "ncofdm_loopback") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.pn_symbols = pn_symbols = (1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1) self.occupied_carriers = occupied_carriers = (range(-31,32),) self.length_tag_name = length_tag_name = "packet_len" self.fft_len = fft_len = 64 self.ShSeqLen = ShSeqLen = 40 self.LgSeqLen = LgSeqLen = 320 self.DataSeqLen = DataSeqLen = 64 self.sync_len = sync_len = 20 self.samp_rate = samp_rate = 100000 self.pilot_symbols = pilot_symbols = ((1, 1, 1, -1,),) self.pilot_carriers = pilot_carriers = ((-21, -7, 7, 21,),) self.payload_mod = payload_mod = digital.constellation_qpsk() self.packet_len = packet_len = 100 self.ncofdm_amp = ncofdm_amp = 1 self.header_formatter = header_formatter = digital.packet_header_ofdm(occupied_carriers, 1, length_tag_name) self.fileprefix = fileprefix = "/root/" self.cp_len = cp_len = fft_len/4 self.cen_freq = cen_freq = 1500000000 self.ShThreshold = ShThreshold = 10 self.ShSymbols = ShSymbols = pn_symbols[0:ShSeqLen] self.ShSeqRep = ShSeqRep = 8 self.ShRepThreshold = ShRepThreshold = 3.5 self.LgThreshold = LgThreshold = 100 self.LgSymbols = LgSymbols = pn_symbols[ShSeqLen:ShSeqLen+LgSeqLen] self.DataSymbols = DataSymbols = pn_symbols[ShSeqLen+LgSeqLen:DataSeqLen+ShSeqLen+LgSeqLen] self.DataLen = DataLen = DataSeqLen*20 ################################################## # Blocks ################################################## self.ncofdm_stream2fftvector_0 = ncofdm.stream2fftvector(fft_len, cp_len) self.ncofdm_ncofdm_carrier_allocator_0 = ncofdm.ncofdm_carrier_allocator(fft_len, occupied_carriers, (), (), "packet_len") self._ncofdm_amp_layout = Qt.QVBoxLayout() self._ncofdm_amp_tool_bar = Qt.QToolBar(self) self._ncofdm_amp_layout.addWidget(self._ncofdm_amp_tool_bar) self._ncofdm_amp_tool_bar.addWidget(Qt.QLabel("ncofdm_amp"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._ncofdm_amp_counter = qwt_counter_pyslot() self._ncofdm_amp_counter.setRange(0, 2, 0.001) self._ncofdm_amp_counter.setNumButtons(2) self._ncofdm_amp_counter.setValue(self.ncofdm_amp) self._ncofdm_amp_tool_bar.addWidget(self._ncofdm_amp_counter) self._ncofdm_amp_counter.valueChanged.connect(self.set_ncofdm_amp) self._ncofdm_amp_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._ncofdm_amp_slider.setRange(0, 2, 0.001) self._ncofdm_amp_slider.setValue(self.ncofdm_amp) self._ncofdm_amp_slider.setMinimumWidth(200) self._ncofdm_amp_slider.valueChanged.connect(self.set_ncofdm_amp) self._ncofdm_amp_layout.addWidget(self._ncofdm_amp_slider) self.top_layout.addLayout(self._ncofdm_amp_layout) self.ncofdm_add_cp_underlay_0 = ncofdm.add_cp_underlay(fft_len, cp_len, 20, 1280, ShSeqLen, ShSeqRep, ShSymbols, DataSeqLen, DataSymbols, LgSeqLen, LgSymbols, "packet_len") self.ncofdm_ShortPNdetector_0 = ncofdm.ShortPNdetector(fft_len, cp_len, ShSeqRep, ShSeqLen, 1) self.ncofdm_ShortPNcorr_0 = ncofdm.ShortPNcorr(fft_len, cp_len, ShSeqRep, ShSeqLen, (ShSymbols)) self.ncofdm_LongPNcorrV2_0 = ncofdm.LongPNcorrV2(fft_len, cp_len, LgSeqLen, (LgSymbols), 60, ShSeqRep*ShSeqLen+LgSeqLen+DataLen+10) self.ncofdm_FreqOffCalc_0 = ncofdm.FreqOffCalc(fft_len, fft_len/4, ShSeqLen, ShSeqRep) self.fft_vxx_1 = fft.fft_vcc(fft_len, True, (), True, 1) self.fft_vxx_0 = fft.fft_vcc(fft_len, False, (()), True, 1) self.digital_chunks_to_symbols_xx_0_0_0 = digital.chunks_to_symbols_bc((payload_mod.points()), 1) self.channels_channel_model_0 = channels.channel_model( noise_voltage=0, frequency_offset=0.0004, epsilon=1.0, taps=(1, ), noise_seed=0, block_tags=False ) self.blocks_vector_to_stream_0_1 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, fft_len) self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, fft_len) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_threshold_ff_0_0 = blocks.threshold_ff(ShRepThreshold, ShRepThreshold, 0) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, packet_len, "packet_len") self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(8, payload_mod.bits_per_symbol(), length_tag_name, False, gr.GR_LSB_FIRST) self.blocks_null_sink_1_0_0_0_1_1_0_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_null_sink_1_0_0_0_1_1_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_null_sink_1_0_0_0_1_0_0_0 = blocks.null_sink(gr.sizeof_int*1) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc(([1/(math.sqrt(44))]*fft_len)) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(100, 0.01, 4000) self.blocks_float_to_int_0 = blocks.float_to_int(1, 1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_sink_1_0_0_0_3 = blocks.file_sink(gr.sizeof_gr_complex*1, fileprefix+"short.dat", False) self.blocks_file_sink_1_0_0_0_3.set_unbuffered(False) self.blocks_file_sink_1_0_0_0_2 = blocks.file_sink(gr.sizeof_gr_complex*1, fileprefix+"org.dat", False) self.blocks_file_sink_1_0_0_0_2.set_unbuffered(False) self.blocks_file_sink_1_0_0_0_1_1_1 = blocks.file_sink(gr.sizeof_float*1, fileprefix+"rxshth.dat", False) self.blocks_file_sink_1_0_0_0_1_1_1.set_unbuffered(False) self.blocks_file_sink_1_0_0_0_1_1_0 = blocks.file_sink(gr.sizeof_float*1, fileprefix+"lgth.dat", False) self.blocks_file_sink_1_0_0_0_1_1_0.set_unbuffered(False) self.blocks_file_sink_1_0_0_0_0_2_0 = blocks.file_sink(gr.sizeof_gr_complex*1, fileprefix+"txdata.dat", False) self.blocks_file_sink_1_0_0_0_0_2_0.set_unbuffered(False) self.blocks_file_sink_1_0_0_0_0_2 = blocks.file_sink(gr.sizeof_gr_complex*1, fileprefix+"rxd.dat", False) self.blocks_file_sink_1_0_0_0_0_2.set_unbuffered(False) self.blocks_file_sink_1_0_0_0_0_0 = blocks.file_sink(gr.sizeof_int*1, fileprefix+"corr.dat", False) self.blocks_file_sink_1_0_0_0_0_0.set_unbuffered(False) self.blocks_file_sink_1_0_0_0_0 = blocks.file_sink(gr.sizeof_gr_complex*1, fileprefix+"dec.dat", False) self.blocks_file_sink_1_0_0_0_0.set_unbuffered(False) self.blocks_file_sink_1_0_0_0 = blocks.file_sink(gr.sizeof_gr_complex*1, fileprefix+"long.dat", False) self.blocks_file_sink_1_0_0_0.set_unbuffered(False) self.blocks_delay_0_0_0_0_0_0_0 = blocks.delay(gr.sizeof_float*1, 2) self.blocks_delay_0_0_0_0_0_0 = blocks.delay(gr.sizeof_float*1, 2) self.blocks_delay_0_0_0_0_0 = blocks.delay(gr.sizeof_int*1, 1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_mag_0_0_0 = blocks.complex_to_mag(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 200, 10000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.ncofdm_ShortPNdetector_0, 0)) self.connect((self.blocks_complex_to_mag_0_0_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_file_sink_1_0_0_0_1_1_0, 0)) self.connect((self.blocks_delay_0_0_0_0_0, 0), (self.ncofdm_FreqOffCalc_0, 1)) self.connect((self.blocks_delay_0_0_0_0_0_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_delay_0_0_0_0_0_0_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.ncofdm_LongPNcorrV2_0, 1)) self.connect((self.blocks_float_to_int_0, 0), (self.blocks_delay_0_0_0_0_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.ncofdm_LongPNcorrV2_0, 2)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.ncofdm_add_cp_underlay_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.digital_chunks_to_symbols_xx_0_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_delay_0_0_0_0_0_0, 0)) self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_float_to_int_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_file_sink_1_0_0_0_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_null_sink_1, 0)) self.connect((self.blocks_vector_to_stream_0_1, 0), (self.blocks_file_sink_1_0_0_0_0_2, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_complex_to_mag_0_0_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_file_sink_1_0_0_0_2, 0)) self.connect((self.channels_channel_model_0, 0), (self.ncofdm_LongPNcorrV2_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.ncofdm_ShortPNcorr_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.ncofdm_stream2fftvector_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0_0, 0), (self.ncofdm_ncofdm_carrier_allocator_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.fft_vxx_1, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.ncofdm_FreqOffCalc_0, 0), (self.blocks_delay_0_0_0_0_0_0_0, 0)) self.connect((self.ncofdm_LongPNcorrV2_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.ncofdm_LongPNcorrV2_0, 1), (self.blocks_file_sink_1_0_0_0, 0)) self.connect((self.ncofdm_LongPNcorrV2_0, 2), (self.blocks_file_sink_1_0_0_0_0_0, 0)) self.connect((self.ncofdm_LongPNcorrV2_0, 2), (self.blocks_null_sink_1_0_0_0_1_0_0_0, 0)) self.connect((self.ncofdm_LongPNcorrV2_0, 1), (self.blocks_null_sink_1_0_0_0_1_1_0, 0)) self.connect((self.ncofdm_LongPNcorrV2_0, 0), (self.blocks_null_sink_1_0_0_0_1_1_0_0, 0)) self.connect((self.ncofdm_LongPNcorrV2_0, 2), (self.ncofdm_stream2fftvector_0, 1)) self.connect((self.ncofdm_ShortPNcorr_0, 1), (self.blocks_complex_to_mag_0, 0)) self.connect((self.ncofdm_ShortPNcorr_0, 1), (self.blocks_file_sink_1_0_0_0_3, 0)) self.connect((self.ncofdm_ShortPNcorr_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.ncofdm_ShortPNcorr_0, 1), (self.ncofdm_FreqOffCalc_0, 0)) self.connect((self.ncofdm_ShortPNdetector_0, 1), (self.blocks_file_sink_1_0_0_0_1_1_1, 0)) self.connect((self.ncofdm_ShortPNdetector_0, 0), (self.blocks_threshold_ff_0_0, 0)) self.connect((self.ncofdm_add_cp_underlay_0, 0), (self.blocks_file_sink_1_0_0_0_0_2_0, 0)) self.connect((self.ncofdm_add_cp_underlay_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.ncofdm_ncofdm_carrier_allocator_0, 0), (self.blocks_vector_to_stream_0_1, 0)) self.connect((self.ncofdm_ncofdm_carrier_allocator_0, 0), (self.fft_vxx_0, 0)) self.connect((self.ncofdm_stream2fftvector_0, 0), (self.fft_vxx_1, 0))
def __init__(self, alsa_dev="default:CARD=Device", averaging_period=1.0, zscore_period=300.0, trigger_threshold=1.0, trigger_holdoff=2.0, debug_print_period=3.0, logfile_path=None, NFFT = 128, audio_rate=48000, audio_decim=6): gr.top_block.__init__(self) ################################################## # Variables ################################################## self.samp_rate = samp_rate = audio_rate/audio_decim ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=1, decimation=audio_decim, taps=None, fractional_bw=None, ) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.audio_source_0 = audio.source(audio_rate, alsa_dev, True) self.pack_for_fft = blocks.stream_to_vector(gr.sizeof_float*1, NFFT) self.fft = fft.fft_vfc(NFFT, True, (fft.window.blackmanharris(NFFT)), 1) self.unpack_fft = blocks.vector_to_stream(gr.sizeof_gr_complex*1, NFFT) self.mag = blocks.complex_to_mag(1) self.median = np_median(NFFT) averaging_samples = int(averaging_period * self.samp_rate / NFFT) self.moving_average = blocks.moving_average_ff(averaging_samples, 1.0/averaging_samples) z_score_samples = int(zscore_period * self.samp_rate / NFFT) self.z_score = jbm_z_score(z_score_samples) debug_print_samples = int(debug_print_period * self.samp_rate/NFFT) self.print_decim = jbm_print_decim(debug_print_samples) if logfile_path == None: logfile_path = ("carlog_%d.txt" % time.time()) logfile = file(logfile_path, "a") self.threshold_ts = jbm_threshold_timestamp(time.time(), self.samp_rate/NFFT, trigger_threshold, trigger_holdoff, logfile) ################################################## # Connections ################################################## self.connect((self.audio_source_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect(self.rational_resampler_xxx_0, self.pack_for_fft) self.connect(self.pack_for_fft, self.fft, self.unpack_fft, self.mag) self.connect(self.mag, self.median) self.connect(self.median, self.moving_average, self.z_score) self.connect((self.z_score,0), self.threshold_ts) if debug_print_period != 0: for i in range(3): self.connect((self.z_score, i), (self.print_decim, i)) else: for i in range(3): dummy_null_sink = blocks.null_sink(gr.sizeof_float) self.connect((self.z_score, i), dummy_null_sink)
def __init__(self, meta_rate=10): gr.top_block.__init__(self, "Fox1D Playback") Qt.QWidget.__init__(self) self.setWindowTitle("Fox1D Playback") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "fox1d_playback") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.meta_rate = meta_rate ################################################## # Variables ################################################## self.samp_rate = samp_rate = 250e3 self.decim = decim = 5 self.baud = baud = 9600 self.xlate_taps_old = xlate_taps_old = firdes.low_pass( 1.0, samp_rate, samp_rate / 2, 1000, firdes.WIN_HAMMING, 6.76) self.xlate_taps = xlate_taps = firdes.low_pass(1.0, samp_rate, 15e3, 1000, firdes.WIN_HAMMING, 6.76) self.volume = volume = 0.01 self.throttle_factor = throttle_factor = 1 self.samps_per_symb = samps_per_symb = samp_rate / decim / baud self.rf_lpf_cutoff = rf_lpf_cutoff = 8e3 self.fsk_deviation_hz = fsk_deviation_hz = 4000 self.fll_loop_bw_fine = fll_loop_bw_fine = 0.0001 self.fll_loop_bw = fll_loop_bw = math.pi / 200 self.audio_lpf_cutoff = audio_lpf_cutoff = 7e3 ################################################## # Blocks ################################################## self._volume_tool_bar = Qt.QToolBar(self) self._volume_tool_bar.addWidget(Qt.QLabel("volume" + ": ")) self._volume_line_edit = Qt.QLineEdit(str(self.volume)) self._volume_tool_bar.addWidget(self._volume_line_edit) self._volume_line_edit.returnPressed.connect(lambda: self.set_volume( eng_notation.str_to_num( str(self._volume_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._volume_tool_bar, 7, 4, 1, 2) for r in range(7, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self._throttle_factor_tool_bar = Qt.QToolBar(self) self._throttle_factor_tool_bar.addWidget( Qt.QLabel("throttle_factor" + ": ")) self._throttle_factor_line_edit = Qt.QLineEdit( str(self.throttle_factor)) self._throttle_factor_tool_bar.addWidget( self._throttle_factor_line_edit) self._throttle_factor_line_edit.returnPressed.connect( lambda: self.set_throttle_factor( eng_notation.str_to_num( str(self._throttle_factor_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._throttle_factor_tool_bar, 6, 4, 1, 2) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self._rf_lpf_cutoff_tool_bar = Qt.QToolBar(self) self._rf_lpf_cutoff_tool_bar.addWidget( Qt.QLabel("rf_lpf_cutoff" + ": ")) self._rf_lpf_cutoff_line_edit = Qt.QLineEdit(str(self.rf_lpf_cutoff)) self._rf_lpf_cutoff_tool_bar.addWidget(self._rf_lpf_cutoff_line_edit) self._rf_lpf_cutoff_line_edit.returnPressed.connect( lambda: self.set_rf_lpf_cutoff( eng_notation.str_to_num( str(self._rf_lpf_cutoff_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._rf_lpf_cutoff_tool_bar, 6, 0, 1, 2) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._fll_loop_bw_fine_tool_bar = Qt.QToolBar(self) self._fll_loop_bw_fine_tool_bar.addWidget( Qt.QLabel("fll_loop_bw_fine" + ": ")) self._fll_loop_bw_fine_line_edit = Qt.QLineEdit( str(self.fll_loop_bw_fine)) self._fll_loop_bw_fine_tool_bar.addWidget( self._fll_loop_bw_fine_line_edit) self._fll_loop_bw_fine_line_edit.returnPressed.connect( lambda: self.set_fll_loop_bw_fine( eng_notation.str_to_num( str(self._fll_loop_bw_fine_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._fll_loop_bw_fine_tool_bar, 7, 2, 1, 2) for r in range(7, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) self._fll_loop_bw_tool_bar = Qt.QToolBar(self) self._fll_loop_bw_tool_bar.addWidget(Qt.QLabel("fll_loop_bw" + ": ")) self._fll_loop_bw_line_edit = Qt.QLineEdit(str(self.fll_loop_bw)) self._fll_loop_bw_tool_bar.addWidget(self._fll_loop_bw_line_edit) self._fll_loop_bw_line_edit.returnPressed.connect( lambda: self.set_fll_loop_bw( eng_notation.str_to_num( str(self._fll_loop_bw_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._fll_loop_bw_tool_bar, 6, 2, 1, 2) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) self._audio_lpf_cutoff_tool_bar = Qt.QToolBar(self) self._audio_lpf_cutoff_tool_bar.addWidget( Qt.QLabel("audio_lpf_cutoff" + ": ")) self._audio_lpf_cutoff_line_edit = Qt.QLineEdit( str(self.audio_lpf_cutoff)) self._audio_lpf_cutoff_tool_bar.addWidget( self._audio_lpf_cutoff_line_edit) self._audio_lpf_cutoff_line_edit.returnPressed.connect( lambda: self.set_audio_lpf_cutoff( eng_notation.str_to_num( str(self._audio_lpf_cutoff_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._audio_lpf_cutoff_tool_bar, 7, 0, 1, 2) for r in range(7, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=1, decimation=4, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=1, decimation=4, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=48, decimation=50, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim, #bw "corrected", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0_0.enable_grid(False) self.qtgui_waterfall_sink_x_0_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0_0.set_intensity_range(-80, 0) self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_0_win, 2, 4, 2, 4) for r in range(2, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim, #bw "Pre-D", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-80, 0) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 0, 4, 2, 4) for r in range(0, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate / decim / 50 * 48, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 8, 0, 1, 8) for r in range(8, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_number_sink_0_0_0_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_0_0_0_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0_0_0_0.set_title("") labels = ['SNR', '', '', '', '', '', '', '', '', ''] units = ['dB', '', '', '', '', '', '', '', '', ''] colors = [("blue", "red"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0_0_0_0.set_min(i, 0) self.qtgui_number_sink_0_0_0_0_0.set_max(i, 30) self.qtgui_number_sink_0_0_0_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_0_0_0.set_label( i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_0_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_0_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_0_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_0_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_0_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_0_0_win, 6, 6, 1, 1) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 7): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_number_sink_0_0_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_0_0_0_0.set_update_time(0.010) self.qtgui_number_sink_0_0_0_0.set_title("") labels = ['Freq Offset', 'Phase', 'Error', '', '', '', '', '', '', ''] units = ['Hz', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0_0_0.set_min(i, -32767) self.qtgui_number_sink_0_0_0_0.set_max(i, 32767) self.qtgui_number_sink_0_0_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_0_0.set_label( i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_0_win, 6, 7, 1, 1) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(7, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim, #bw "Pre-D", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.010) self.qtgui_freq_sink_x_0.set_y_axis(-60, 0) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['pre-d', 'corr', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 4, 4) for r in range(0, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.low_pass_filter_0_0_0 = filter.fir_filter_fff( 1, firdes.low_pass(1, samp_rate / decim / 50 * 48, audio_lpf_cutoff, 2e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate / decim, rf_lpf_cutoff, 2e3, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( decim, (xlate_taps), 0, samp_rate) self.digital_fll_band_edge_cc_0_0 = digital.fll_band_edge_cc( samps_per_symb, .5, 1024, fll_loop_bw_fine) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc( samps_per_symb, .5, 1024, fll_loop_bw) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate * throttle_factor, True) self.blocks_tagged_stream_to_pdu_0_0 = blocks.tagged_stream_to_pdu( blocks.float_t, 'snr') self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.float_t, 'rfo') self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream( gr.sizeof_float, 1, 1, "snr") self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_float, 1, 1, "rfo") self.blocks_socket_pdu_0_0 = blocks.socket_pdu("TCP_SERVER", '0.0.0.0', '52002', 10000, False) self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", '0.0.0.0', '52001', 10000, False) self.blocks_null_sink_0_1 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_null_sink_0_0_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_nlog10_ff_0_1 = blocks.nlog10_ff(10, 1, 0) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff( (-1 * samp_rate / decim / (2 * math.pi), )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (volume, )) self.blocks_moving_average_xx_0_0_1 = blocks.moving_average_ff( 10000, 0.0001, 4000, 1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( 100000, 0.00001, 4000, 1) self.blocks_keep_one_in_n_0_0 = blocks.keep_one_in_n( gr.sizeof_float * 1, int(samp_rate * meta_rate)) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_float * 1, int(samp_rate / 4 * meta_rate)) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, '/home/zleffke/captures/fox1d/20180913/FOX-1D_USRP_20180913_151002.518249_UTC_250k.fc32', False) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared( 1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, samp_rate / 2, 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( samp_rate / (2 * math.pi * fsk_deviation_hz / 8.0)) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0, 'pdus'), (self.blocks_socket_pdu_0_0, 'pdus')) self.connect((self.analog_agc2_xx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_0_0_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_nlog10_ff_0_1, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_stream_to_tagged_stream_0_0, 0)) self.connect((self.blocks_keep_one_in_n_0_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_keep_one_in_n_0_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_number_sink_0_0_0_0, 0)) self.connect((self.blocks_moving_average_xx_0_0_1, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_moving_average_xx_0_0_1, 0), (self.qtgui_number_sink_0_0_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.blocks_nlog10_ff_0_1, 0), (self.blocks_moving_average_xx_0_0_1, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.blocks_tagged_stream_to_pdu_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 1), (self.blocks_add_xx_0, 1)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 2), (self.blocks_null_sink_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 3), (self.blocks_null_sink_0_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.digital_fll_band_edge_cc_0_0, 1), (self.blocks_add_xx_0, 0)) self.connect((self.digital_fll_band_edge_cc_0_0, 3), (self.blocks_null_sink_0_0_0, 0)) self.connect((self.digital_fll_band_edge_cc_0_0, 2), (self.blocks_null_sink_0_1, 0)) self.connect((self.digital_fll_band_edge_cc_0_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.digital_fll_band_edge_cc_0_0, 0), (self.qtgui_waterfall_sink_x_0_0, 0)) self.connect((self.digital_fll_band_edge_cc_0_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.digital_fll_band_edge_cc_0_0, 0)) self.connect((self.low_pass_filter_0_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_complex_to_mag_squared_0_0, 0))
def __init__(self, large_sig_len=0.0015, signal_mult=2, freq=433866000): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.large_sig_len = large_sig_len self.signal_mult = signal_mult self.freq = freq ################################################## # Variables ################################################## self.samp_rate = samp_rate = 240000 ################################################## # Blocks ################################################## self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff( 0.2, 1) self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(-24, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(1, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(50, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 10000, 10000, firdes.WIN_HAMMING, 6.76)) self.blocks_threshold_ff_2 = blocks.threshold_ff(0, 0, 0) self.blocks_threshold_ff_1 = blocks.threshold_ff(0, 0, 0) self.blocks_sub_xx_2 = blocks.sub_ff(1) self.blocks_sub_xx_1 = blocks.sub_ff(1) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "localhost", "52001", 10000, False) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff( (signal_mult, )) self.blocks_moving_average_xx_1 = blocks.moving_average_ff( int(samp_rate * large_sig_len), 0.8 / samp_rate / large_sig_len, 4000) self.blocks_float_to_char_1 = blocks.float_to_char(1, 1) self.blocks_float_to_char_0_0 = blocks.float_to_char(1, 1) self.blocks_delay_1 = blocks.delay(gr.sizeof_float * 1, int(samp_rate * 0.00005)) self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, 1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.bitgate_triggered_bits_0 = bitgate.triggered_bits( int(samp_rate * large_sig_len * 5), False) self.analog_rail_ff_1 = analog.rail_ff(0.001, 1) self.analog_rail_ff_0 = analog.rail_ff(0, 1) ################################################## # Connections ################################################## self.msg_connect((self.bitgate_triggered_bits_0, 'pdus'), (self.blocks_socket_pdu_0, 'pdus')) self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_char_0_0, 0)) self.connect((self.analog_rail_ff_1, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.analog_rail_ff_1, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_delay_1, 0), (self.blocks_float_to_char_1, 0)) self.connect((self.blocks_float_to_char_0_0, 0), (self.bitgate_triggered_bits_0, 1)) self.connect((self.blocks_float_to_char_1, 0), (self.bitgate_triggered_bits_0, 0)) self.connect((self.blocks_moving_average_xx_1, 0), (self.blocks_sub_xx_1, 1)) self.connect((self.blocks_moving_average_xx_1, 0), (self.blocks_sub_xx_2, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_moving_average_xx_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.single_pole_iir_filter_xx_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.analog_rail_ff_0, 0)) self.connect((self.blocks_sub_xx_1, 0), (self.blocks_sub_xx_2, 0)) self.connect((self.blocks_sub_xx_1, 0), (self.blocks_threshold_ff_1, 0)) self.connect((self.blocks_sub_xx_2, 0), (self.blocks_threshold_ff_2, 0)) self.connect((self.blocks_threshold_ff_1, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_threshold_ff_1, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_threshold_ff_2, 0), (self.blocks_delay_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_sub_xx_1, 0))
def __init__(self, path="/captures/radio_jove", signal_type='RADIO-JOVE'): gr.top_block.__init__(self, "Radio Jove RTL-SDR Receiver") Qt.QWidget.__init__(self) self.setWindowTitle("Radio Jove RTL-SDR Receiver") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "radio_jove_dual_rtlsdr_sigmf") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.path = path self.signal_type = signal_type ################################################## # Variables ################################################## self.ts_str = ts_str = dt.strftime(dt.utcnow(), "%Y-%m-%dT%H:%M:%SZ") self.fn = fn = "{:s}_{:s}".format(signal_type.upper(), ts_str) self.samp_rate = samp_rate = 2000000 self.rx_freq = rx_freq = 20.1e6 self.keep_n = keep_n = 20000 self.fp = fp = "{:s}/{:s}".format(path, fn) self.decim = decim = 1 self.avg_len = avg_len = 20000.0 ################################################## # Blocks ################################################## self._rx_freq_tool_bar = Qt.QToolBar(self) self._rx_freq_tool_bar.addWidget(Qt.QLabel('Freq [Hz]' + ": ")) self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq)) self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit) self._rx_freq_line_edit.returnPressed.connect(lambda: self.set_rx_freq( eng_notation.str_to_num( str(self._rx_freq_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._rx_freq_tool_bar, 8, 0, 1, 2) for r in range(8, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._keep_n_tool_bar = Qt.QToolBar(self) self._keep_n_tool_bar.addWidget(Qt.QLabel('1inN' + ": ")) self._keep_n_line_edit = Qt.QLineEdit(str(self.keep_n)) self._keep_n_tool_bar.addWidget(self._keep_n_line_edit) self._keep_n_line_edit.returnPressed.connect(lambda: self.set_keep_n( int(str(self._keep_n_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._keep_n_tool_bar, 5, 5, 1, 1) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(5, 6): self.top_grid_layout.setColumnStretch(c, 1) self._avg_len_tool_bar = Qt.QToolBar(self) self._avg_len_tool_bar.addWidget(Qt.QLabel("avg_len" + ": ")) self._avg_len_line_edit = Qt.QLineEdit(str(self.avg_len)) self._avg_len_tool_bar.addWidget(self._avg_len_line_edit) self._avg_len_line_edit.returnPressed.connect(lambda: self.set_avg_len( eng_notation.str_to_num( str(self._avg_len_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._avg_len_tool_bar, 5, 4, 1, 1) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 5): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate / decim, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 4, 0, 4, 4) for r in range(4, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1000, #size samp_rate / keep_n, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.1) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 0, 4, 4, 4) for r in range(0, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0.set_update_time(0.010) self.qtgui_number_sink_0.set_title('') labels = ["RSSI", '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("blue", "red"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -140) self.qtgui_number_sink_0.set_max(i, -40) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 4, 4, 1, 4) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate / decim, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.010) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 4, 4) for r in range(0, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "rtl=0,direct_samp=2") self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(rx_freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(10, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.fosphor_glfw_sink_c_0 = fosphor.glfw_sink_c() self.fosphor_glfw_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS) self.fosphor_glfw_sink_c_0.set_frequency_range(0, samp_rate) self.dc_blocker_xx_0 = filter.dc_blocker_cc(256, True) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff( (1 / avg_len, )) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( int(avg_len), 1 / avg_len, 4000, 1) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_float * 1, keep_n) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.fosphor_glfw_sink_c_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.dc_blocker_xx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.wilab_cic_moving_average_0 = wilab.cic_moving_average(10) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 3 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-10, 10) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(3): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(10, 1, 4000) self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_time_sink_x_0, 2)) self.connect((self.blocks_throttle_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wilab_cic_moving_average_0, 0)) self.connect((self.wilab_cic_moving_average_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.wilab_cic_moving_average_0, 0), (self.qtgui_time_sink_x_0, 0))
def __init__(self, large_sig_len=0.0015, signal_mult=2, freq=433866000): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.large_sig_len = large_sig_len self.signal_mult = signal_mult self.freq = freq ################################################## # Variables ################################################## self.samp_rate = samp_rate = 240000 ################################################## # Blocks ################################################## self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(0.2, 1) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(-24, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(1, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(50, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, 10000, 10000, firdes.WIN_HAMMING, 6.76)) self.blocks_threshold_ff_2 = blocks.threshold_ff(0, 0, 0) self.blocks_threshold_ff_1 = blocks.threshold_ff(0, 0, 0) self.blocks_sub_xx_2 = blocks.sub_ff(1) self.blocks_sub_xx_1 = blocks.sub_ff(1) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "localhost", "52001", 10000, False) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((signal_mult, )) self.blocks_moving_average_xx_1 = blocks.moving_average_ff(int(samp_rate*large_sig_len), 0.8/samp_rate/large_sig_len, 4000) self.blocks_float_to_char_1 = blocks.float_to_char(1, 1) self.blocks_float_to_char_0_0 = blocks.float_to_char(1, 1) self.blocks_delay_1 = blocks.delay(gr.sizeof_float*1, int(samp_rate*0.00005)) self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, 1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.bitgate_triggered_bits_0 = bitgate.triggered_bits(int(samp_rate*large_sig_len*5), False) self.analog_rail_ff_1 = analog.rail_ff(0.001, 1) self.analog_rail_ff_0 = analog.rail_ff(0, 1) ################################################## # Connections ################################################## self.msg_connect((self.bitgate_triggered_bits_0, 'pdus'), (self.blocks_socket_pdu_0, 'pdus')) self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_char_0_0, 0)) self.connect((self.analog_rail_ff_1, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.analog_rail_ff_1, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_delay_1, 0), (self.blocks_float_to_char_1, 0)) self.connect((self.blocks_float_to_char_0_0, 0), (self.bitgate_triggered_bits_0, 1)) self.connect((self.blocks_float_to_char_1, 0), (self.bitgate_triggered_bits_0, 0)) self.connect((self.blocks_moving_average_xx_1, 0), (self.blocks_sub_xx_1, 1)) self.connect((self.blocks_moving_average_xx_1, 0), (self.blocks_sub_xx_2, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_moving_average_xx_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.single_pole_iir_filter_xx_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.analog_rail_ff_0, 0)) self.connect((self.blocks_sub_xx_1, 0), (self.blocks_sub_xx_2, 0)) self.connect((self.blocks_sub_xx_1, 0), (self.blocks_threshold_ff_1, 0)) self.connect((self.blocks_sub_xx_2, 0), (self.blocks_threshold_ff_2, 0)) self.connect((self.blocks_threshold_ff_1, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_threshold_ff_1, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_threshold_ff_2, 0), (self.blocks_delay_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_sub_xx_1, 0))
def __init__(self): gr.top_block.__init__(self, "udp-recive") Qt.QWidget.__init__(self) self.setWindowTitle("udp-recive") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.samp_rate = samp_rate = 850e3 self.dec = dec = 25 self.freq_0 = freq_0 = 137.50625e6 self.bandwidth = bandwidth = 34e3 self.RF_gain = RF_gain = 40 self.Out_samprate = Out_samprate = samp_rate / dec self.NOAA19 = NOAA19 = -0.40625e6 self.NOAA18 = NOAA18 = 0.40625e6 self.NOAA15 = NOAA15 = 0.11375e6 self.IF_gain = IF_gain = 40 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=11025, decimation=34000, taps=None, fractional_bw=None) self.qtgui_sink_x_0 = qtgui.sink_c( 2048, #fftsize firdes.WIN_HAMMING, #wintype 0, #fc 34e3, #bw "output sink", #name True, #plotfreq True, #plotwaterfall False, #plottime False #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_win = sip.wrapinstance( self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.qtgui_sink_x_0.enable_rf_freq(False) self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.set_block_alias("output sink") self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_short, 0, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_0.set_update_time(0.1) self.qtgui_number_sink_0.set_title("Selected channel") labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in range(1): self.qtgui_number_sink_0.set_min(i, 0) self.qtgui_number_sink_0.set_max(i, 2) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win) self.blocks_udp_source_0_2 = blocks.udp_source( gr.sizeof_gr_complex * 1, '0.0.0.0', 1232, 4000, True) self.blocks_udp_source_0_1 = blocks.udp_source( gr.sizeof_gr_complex * 1, '0.0.0.0', 1230, 4000, True) self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_gr_complex * 1, '0.0.0.0', 1231, 4000, True) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_float * 1, 'localhost', 7355, 1225, True) self.blocks_threshold_ff_0_1 = blocks.threshold_ff(1.5, 2.5, 0) self.blocks_threshold_ff_0_0 = blocks.threshold_ff(0.5, 1.5, 0) self.blocks_threshold_ff_0 = blocks.threshold_ff(-0.5, 0.5, 0) self.blocks_streams_to_vector_0 = blocks.streams_to_vector( gr.sizeof_float * 1, 3) self.blocks_short_to_float_0 = blocks.short_to_float(1, 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_short * 1) self.blocks_multiply_xx_2 = blocks.multiply_vcc(1) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_moving_average_2_0 = blocks.moving_average_ff( 4000, 1, 4000, 1) self.blocks_moving_average_2 = blocks.moving_average_ff( 4000, 1, 4000, 1) self.blocks_moving_average_1 = blocks.moving_average_ff( 4000, 1, 4000, 1) self.blocks_float_to_complex_1_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_1_0 = blocks.float_to_complex(1) self.blocks_float_to_complex_1 = blocks.float_to_complex(1) self.blocks_complex_to_mag_squared_0_1 = blocks.complex_to_mag_squared( 1) self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared( 1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_argmax_xx_0 = blocks.argmax_fs(3) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blocks_add_const_vxx_0_0_0 = blocks.add_const_ff(-1) self.blocks_add_const_vxx_0_0 = blocks.add_const_ff(-1) self.blocks_add_const_vxx_0 = blocks.add_const_ff(-1) self.blocks_abs_xx_0_0_0 = blocks.abs_ff(1) self.blocks_abs_xx_0_0 = blocks.abs_ff(1) self.blocks_abs_xx_0 = blocks.abs_ff(1) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=bandwidth, audio_decimation=1, ) self.NOAA19_fall = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype freq_0 + NOAA19, #fc Out_samprate, #bw "NOAA19 (stream 0)", #name True, #plotfreq True, #plotwaterfall False, #plottime False #plotconst ) self.NOAA19_fall.set_update_time(1.0 / 1) self._NOAA19_fall_win = sip.wrapinstance(self.NOAA19_fall.pyqwidget(), Qt.QWidget) self.NOAA19_fall.enable_rf_freq(True) self.top_grid_layout.addWidget(self._NOAA19_fall_win) self.NOAA18_fall = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype freq_0 + NOAA18, #fc Out_samprate, #bw "NOAA18 (stream 1)", #name True, #plotfreq True, #plotwaterfall False, #plottime False #plotconst ) self.NOAA18_fall.set_update_time(1.0 / 1) self._NOAA18_fall_win = sip.wrapinstance(self.NOAA18_fall.pyqwidget(), Qt.QWidget) self.NOAA18_fall.enable_rf_freq(True) self.top_grid_layout.addWidget(self._NOAA18_fall_win) self.NOAA15_fall = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype freq_0 + NOAA15, #fc Out_samprate, #bw "NOAA15 (stream 2)", #name True, #plotfreq True, #plotwaterfall False, #plottime False #plotconst ) self.NOAA15_fall.set_update_time(1.0 / 1) self._NOAA15_fall_win = sip.wrapinstance(self.NOAA15_fall.pyqwidget(), Qt.QWidget) self.NOAA15_fall.enable_rf_freq(True) self.top_grid_layout.addWidget(self._NOAA15_fall_win) ################################################## # Connections ################################################## self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_abs_xx_0, 0), (self.blocks_float_to_complex_1, 0)) self.connect((self.blocks_abs_xx_0_0, 0), (self.blocks_float_to_complex_1_0, 0)) self.connect((self.blocks_abs_xx_0_0_0, 0), (self.blocks_float_to_complex_1_1, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_abs_xx_0, 0)) self.connect((self.blocks_add_const_vxx_0_0, 0), (self.blocks_abs_xx_0_0, 0)) self.connect((self.blocks_add_const_vxx_0_0_0, 0), (self.blocks_abs_xx_0_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.blocks_argmax_xx_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_argmax_xx_0, 0), (self.blocks_short_to_float_0, 0)) self.connect((self.blocks_argmax_xx_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_moving_average_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0_0, 0), (self.blocks_moving_average_2, 0)) self.connect((self.blocks_complex_to_mag_squared_0_1, 0), (self.blocks_moving_average_2_0, 0)) self.connect((self.blocks_float_to_complex_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_float_to_complex_1_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.blocks_float_to_complex_1_1, 0), (self.blocks_multiply_xx_2, 1)) self.connect((self.blocks_moving_average_1, 0), (self.blocks_streams_to_vector_0, 0)) self.connect((self.blocks_moving_average_2, 0), (self.blocks_streams_to_vector_0, 1)) self.connect((self.blocks_moving_average_2_0, 0), (self.blocks_streams_to_vector_0, 2)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_add_xx_0, 2)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_threshold_ff_0_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_threshold_ff_0_1, 0)) self.connect((self.blocks_streams_to_vector_0, 0), (self.blocks_argmax_xx_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_add_const_vxx_0_0, 0)) self.connect((self.blocks_threshold_ff_0_1, 0), (self.blocks_add_const_vxx_0_0_0, 0)) self.connect((self.blocks_udp_source_0, 0), (self.NOAA19_fall, 0)) self.connect((self.blocks_udp_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.blocks_udp_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_udp_source_0_1, 0), (self.NOAA18_fall, 0)) self.connect((self.blocks_udp_source_0_1, 0), (self.blocks_complex_to_mag_squared_0_0, 0)) self.connect((self.blocks_udp_source_0_1, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_udp_source_0_2, 0), (self.NOAA15_fall, 0)) self.connect((self.blocks_udp_source_0_2, 0), (self.blocks_complex_to_mag_squared_0_1, 0)) self.connect((self.blocks_udp_source_0_2, 0), (self.blocks_multiply_xx_2, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_udp_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "Tetra Rx Multi") options = self.get_options() ################################################## # Variables ################################################## self.srate_rx = srate_rx = options.sample_rate self.channels = srate_rx / 25000 self.srate_channel = 36000 self.afc_period = 5 self.afc_gain = 1. self.afc_channel = options.auto_tune or -1 self.afc_ppm_step = 100 self.debug = options.debug self.last_pwr = -100000 self.sig_det_period = 1 self.sig_det_bw = sig_det_bw = options.sig_detection_bw or srate_rx if self.sig_det_bw <= 1.: self.sig_det_bw *= srate_rx self.sig_det_threshold = options.sig_detection_threshold self.sig_det_channels = [] for ch in range(self.channels): if ch >= self.channels / 2: ch_ = (self.channels - ch - 1) else: ch_ = ch if (float(ch_) / self.channels * 2) <= (self.sig_det_bw / srate_rx): self.sig_det_channels.append(ch) ################################################## # RPC server ################################################## self.xmlrpc_server = SimpleXMLRPCServer.SimpleXMLRPCServer( ("localhost", options.listen_port), allow_none=True) self.xmlrpc_server.register_instance(self) threading.Thread(target=self.xmlrpc_server.serve_forever).start() ################################################## # Rx Blocks and connections ################################################## self.src = osmosdr.source( args=options.args ) self.src.set_sample_rate(srate_rx) self.src.set_center_freq(options.frequency, 0) self.src.set_freq_corr(options.ppm, 0) self.src.set_dc_offset_mode(0, 0) self.src.set_iq_balance_mode(0, 0) if options.gain is not None: self.src.set_gain_mode(False, 0) self.src.set_gain(36, 0) else: self.src.set_gain_mode(True, 0) out_type, dst_path = options.output.split("://", 1) if out_type == "udp": dst_ip, dst_port = dst_path.split(':', 1) self.freq_xlating = freq_xlating_fft_filter_ccc(1, (1, ), 0, srate_rx) self.channelizer = pfb.channelizer_ccf( self.channels, (firdes.root_raised_cosine(1, srate_rx, 18000, 0.35, 1024)), 36./25., 100) self.squelch = [] self.digital_mpsk_receiver_cc = [] self.diff_phasor = [] self.complex_to_arg = [] self.multiply_const = [] self.add_const = [] self.float_to_uchar = [] self.map_bits = [] self.unpack_k_bits = [] self.blocks_sink = [] for ch in range(0, self.channels): squelch = analog.pwr_squelch_cc(0, 0.001, 0, True) mpsk = digital.mpsk_receiver_cc( 4, math.pi/4, math.pi/100.0, -0.5, 0.5, 0.25, 0.001, 2, 0.001, 0.001) diff_phasor = digital.diff_phasor_cc() complex_to_arg = blocks.complex_to_arg(1) multiply_const = blocks.multiply_const_vff((2./math.pi, )) add_const = blocks.add_const_vff((1.5, )) float_to_uchar = blocks.float_to_uchar() map_bits = digital.map_bb(([3, 2, 0, 1, 3])) unpack_k_bits = blocks.unpack_k_bits_bb(2) if out_type == 'udp': sink = blocks.udp_sink(gr.sizeof_gr_char, dst_ip, int(dst_port)+ch, 1472, True) elif out_type == 'file': sink = blocks.file_sink(gr.sizeof_char, dst_path % ch, False) sink.set_unbuffered(True) else: raise ValueError("Invalid output URL '%s'" % options.output) self.connect((self.channelizer, ch), (squelch, 0), (mpsk, 0), (diff_phasor, 0), (complex_to_arg, 0), (multiply_const, 0), (add_const, 0), (float_to_uchar, 0), (map_bits, 0), (unpack_k_bits, 0), (sink, 0)) self.squelch.append(squelch) self.digital_mpsk_receiver_cc.append(mpsk) self.diff_phasor.append(diff_phasor) self.complex_to_arg.append(complex_to_arg) self.multiply_const.append(multiply_const) self.add_const.append(add_const) self.float_to_uchar.append(float_to_uchar) self.map_bits.append(map_bits) self.unpack_k_bits.append(unpack_k_bits) self.blocks_sink.append(sink) self.connect( (self.src, 0), (self.freq_xlating, 0), (self.channelizer, 0)) ################################################## # signal strenght identification ################################################## self.pwr_probes = [] for ch in range(self.channels): pwr_probe = analog.probe_avg_mag_sqrd_c(0, 1./self.srate_channel) self.pwr_probes.append(pwr_probe) self.connect((self.channelizer, ch), (pwr_probe, 0)) def _sig_det_probe(): while True: pwr = [self.pwr_probes[ch].level() for ch in range(self.channels) if ch in self.sig_det_channels] pwr = [10 * math.log10(p) for p in pwr if p > 0.] if not pwr: continue pwr = min(pwr) + self.sig_det_threshold print "Power level for squelch % 5.1f" % pwr if abs(pwr - self.last_pwr) > (self.sig_det_threshold / 2): for s in self.squelch: s.set_threshold(pwr) self.last_pwr = pwr time.sleep(self.sig_det_period) if self.sig_det_threshold is not None: self._sig_det_probe_thread = threading.Thread(target=_sig_det_probe) self._sig_det_probe_thread.daemon = True self._sig_det_probe_thread.start() ################################################## # AFC blocks and connections ################################################## self.afc_selector = grc_blks2.selector( item_size=gr.sizeof_gr_complex, num_inputs=self.channels, num_outputs=1, input_index=0, output_index=0, ) self.afc_demod = analog.quadrature_demod_cf(self.srate_channel/(2*math.pi)) samp_afc = self.srate_channel*self.afc_period / 2 self.afc_avg = blocks.moving_average_ff(samp_afc, 1./samp_afc*self.afc_gain) self.afc_probe = blocks.probe_signal_f() def _afc_probe(): while True: time.sleep(self.afc_period) if self.afc_channel == -1: continue err = self.afc_probe.level() if abs(err) < self.afc_ppm_step: continue freq = self.freq_xlating.center_freq + err * self.afc_gain if self.debug: print "err: %f\tfreq: %f" % (err, freq, ) self.freq_xlating.set_center_freq(freq) self._afc_err_thread = threading.Thread(target=_afc_probe) self._afc_err_thread.daemon = True self._afc_err_thread.start() for ch in range(self.channels): self.connect((self.channelizer, ch), (self.afc_selector, ch)) self.connect( (self.afc_selector, 0), (self.afc_demod, 0), (self.afc_avg, 0), (self.afc_probe, 0)) if self.afc_channel != -1: self.afc_selector.set_input_index(self.afc_channel)
def __init__(self): gr.top_block.__init__(self, "Wifi Rx") Qt.QWidget.__init__(self) self.setWindowTitle("Wifi Rx") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "wifi_rx") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.window_size = window_size = 48 self.sync_length = sync_length = 320 self.samp_rate = samp_rate = 2e6 self.rf = rf = 14 self.lo_offset = lo_offset = 0 self.gain = gain = 0.75 self.freqq = freqq = 2.412e6 self.freq = freq = 2412000000.0 self.device_6 = device_6 = "hackrf=26b468dc3540b58f" self.device_5 = device_5 = "hackrf=88869dc38686a1b" self.device_4 = device_4 = "hackrf=88869dc2930b41b" self.device_3 = device_3 = "hackrf=88869dc3347501b" self.device_2 = device_2 = "hackrf=88869dc3918701b" self.device_1 = device_1 = "hackrf=88869dc3397a01b" self.chan_est = chan_est = 0 self.bb = bb = 20 self.IF = IF = 30 ################################################## # Blocks ################################################## # Create the options list self._samp_rate_options = [ 2000000.0, 5000000.0, 10000000.0, 20000000.0 ] # Create the labels list self._samp_rate_labels = ['2MHz', '5 MHz', '10 MHz', '20 MHz'] # Create the combo box self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate: ")) self._samp_rate_combo_box = Qt.QComboBox() self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box) for _label in self._samp_rate_labels: self._samp_rate_combo_box.addItem(_label) self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod( self._samp_rate_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._samp_rate_options.index(i))) self._samp_rate_callback(self.samp_rate) self._samp_rate_combo_box.currentIndexChanged.connect( lambda i: self.set_samp_rate(self._samp_rate_options[i])) # Create the radio buttons self.top_layout.addWidget(self._samp_rate_tool_bar) self._rf_range = Range(0, 50, 1, 14, 200) self._rf_win = RangeWidget(self._rf_range, self.set_rf, 'rf', "counter_slider", int) self.top_layout.addWidget(self._rf_win) # Create the options list self._chan_est_options = [0, 1, 3, 2] # Create the labels list self._chan_est_labels = ['LS', 'LMS', 'STA', 'Linear Comb'] # Create the combo box # Create the radio buttons self._chan_est_group_box = Qt.QGroupBox('chan_est' + ": ") self._chan_est_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._chan_est_button_group = variable_chooser_button_group() self._chan_est_group_box.setLayout(self._chan_est_box) for i, _label in enumerate(self._chan_est_labels): radio_button = Qt.QRadioButton(_label) self._chan_est_box.addWidget(radio_button) self._chan_est_button_group.addButton(radio_button, i) self._chan_est_callback = lambda i: Qt.QMetaObject.invokeMethod( self._chan_est_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._chan_est_options.index(i))) self._chan_est_callback(self.chan_est) self._chan_est_button_group.buttonClicked[int].connect( lambda i: self.set_chan_est(self._chan_est_options[i])) self.top_layout.addWidget(self._chan_est_group_box) self._bb_range = Range(0, 70, 1, 20, 200) self._bb_win = RangeWidget(self._bb_range, self.set_bb, 'bb', "counter_slider", int) self.top_layout.addWidget(self._bb_win) self._IF_range = Range(0, 50, 1, 30, 200) self._IF_win = RangeWidget(self._IF_range, self.set_IF, 'IF', "counter_slider", int) self.top_layout.addWidget(self._IF_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 48 * 10, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_win) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + device_5) self.osmosdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t()) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(2.45e9, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(rf, 0) self.osmosdr_source_0.set_if_gain(IF, 0) self.osmosdr_source_0.set_bb_gain(bb, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(0, 0) # Create the options list self._lo_offset_options = [0, 6000000.0, 11000000.0] # Create the labels list self._lo_offset_labels = ['0', '6000000.0', '11000000.0'] # Create the combo box self._lo_offset_tool_bar = Qt.QToolBar(self) self._lo_offset_tool_bar.addWidget(Qt.QLabel("lo_offset: ")) self._lo_offset_combo_box = Qt.QComboBox() self._lo_offset_tool_bar.addWidget(self._lo_offset_combo_box) for _label in self._lo_offset_labels: self._lo_offset_combo_box.addItem(_label) self._lo_offset_callback = lambda i: Qt.QMetaObject.invokeMethod( self._lo_offset_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._lo_offset_options.index(i))) self._lo_offset_callback(self.lo_offset) self._lo_offset_combo_box.currentIndexChanged.connect( lambda i: self.set_lo_offset(self._lo_offset_options[i])) # Create the radio buttons self.top_layout.addWidget(self._lo_offset_tool_bar) self.ieee802_11_sync_short_0 = ieee802_11.sync_short( 0.56, 2, False, False) self.ieee802_11_sync_long_0 = ieee802_11.sync_long( sync_length, True, False) self.ieee802_11_parse_mac_0 = ieee802_11.parse_mac(True, True) self.ieee802_11_frame_equalizer_0 = ieee802_11.frame_equalizer( chan_est, 2.45e9, samp_rate, False, False) self.ieee802_11_decode_mac_0 = ieee802_11.decode_mac(True, False) self._gain_range = Range(0, 1, 0.01, 0.75, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, 'gain', "counter_slider", float) self.top_layout.addWidget(self._gain_win) # Create the options list self._freqq_options = [2437000.0, 2462000.0, 2412000.0] # Create the labels list self._freqq_labels = ['ch6', 'ch11', 'ch1'] # Create the combo box self._freqq_tool_bar = Qt.QToolBar(self) self._freqq_tool_bar.addWidget(Qt.QLabel("freqq: ")) self._freqq_combo_box = Qt.QComboBox() self._freqq_tool_bar.addWidget(self._freqq_combo_box) for _label in self._freqq_labels: self._freqq_combo_box.addItem(_label) self._freqq_callback = lambda i: Qt.QMetaObject.invokeMethod( self._freqq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freqq_options.index(i))) self._freqq_callback(self.freqq) self._freqq_combo_box.currentIndexChanged.connect( lambda i: self.set_freqq(self._freqq_options[i])) # Create the radio buttons self.top_layout.addWidget(self._freqq_tool_bar) # Create the options list self._freq_options = [ 2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5250000000.0, 5260000000.0, 5270000000.0, 5280000000.0, 5290000000.0, 5300000000.0, 5310000000.0, 5320000000.0, 5500000000.0, 5510000000.0, 5520000000.0, 5530000000.0, 5540000000.0, 5550000000.0, 5560000000.0, 5570000000.0, 5580000000.0, 5590000000.0, 5600000000.0, 5610000000.0, 5620000000.0, 5630000000.0, 5640000000.0, 5660000000.0, 5670000000.0, 5680000000.0, 5690000000.0, 5700000000.0, 5710000000.0, 5720000000.0, 5745000000.0, 5755000000.0, 5765000000.0, 5775000000.0, 5785000000.0, 5795000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0 ] # Create the labels list self._freq_labels = [ ' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 50 | 5250.0 | 11a', ' 52 | 5260.0 | 11a', ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5290.0 | 11a', ' 60 | 5300.0 | 11a', ' 62 | 5310.0 | 11a', ' 64 | 5320.0 | 11a', '100 | 5500.0 | 11a', '102 | 5510.0 | 11a', '104 | 5520.0 | 11a', '106 | 5530.0 | 11a', '108 | 5540.0 | 11a', '110 | 5550.0 | 11a', '112 | 5560.0 | 11a', '114 | 5570.0 | 11a', '116 | 5580.0 | 11a', '118 | 5590.0 | 11a', '120 | 5600.0 | 11a', '122 | 5610.0 | 11a', '124 | 5620.0 | 11a', '126 | 5630.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '134 | 5670.0 | 11a', '136 | 5680.0 | 11a', '138 | 5690.0 | 11a', '140 | 5700.0 | 11a', '142 | 5710.0 | 11a', '144 | 5720.0 | 11a', '149 | 5745.0 | 11a (SRD)', '151 | 5755.0 | 11a (SRD)', '153 | 5765.0 | 11a (SRD)', '155 | 5775.0 | 11a (SRD)', '157 | 5785.0 | 11a (SRD)', '159 | 5795.0 | 11a (SRD)', '161 | 5805.0 | 11a (SRD)', '165 | 5825.0 | 11a (SRD)', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p' ] # Create the combo box self._freq_tool_bar = Qt.QToolBar(self) self._freq_tool_bar.addWidget(Qt.QLabel("freq: ")) self._freq_combo_box = Qt.QComboBox() self._freq_tool_bar.addWidget(self._freq_combo_box) for _label in self._freq_labels: self._freq_combo_box.addItem(_label) self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod( self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i))) self._freq_callback(self.freq) self._freq_combo_box.currentIndexChanged.connect( lambda i: self.set_freq(self._freq_options[i])) # Create the radio buttons self.top_layout.addWidget(self._freq_tool_bar) self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False) self.fft_vxx_0 = fft.fft_vcc(64, True, window.rectangular(64), True, 1) self.correctiq_correctiq_0 = correctiq.correctiq() self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, 64) self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream( blocks.complex_t, 'packet_len') self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_moving_average_xx_1 = blocks.moving_average_cc( window_size, 1, 4000, 1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( window_size + 16, 1, 4000, 1) self.blocks_file_sink_2 = blocks.file_sink( gr.sizeof_gr_complex * 1, '/home/erc/SDN/symbols_5_1.bin', False) self.blocks_file_sink_2.set_unbuffered(True) self.blocks_file_sink_1_1 = blocks.file_sink( gr.sizeof_gr_complex * 64, '/home/erc/SDN/before_fft_5_1.bin', False) self.blocks_file_sink_1_1.set_unbuffered(True) self.blocks_file_sink_1_0 = blocks.file_sink( gr.sizeof_char * 48, '/home/erc/SDN/output_equ_5_1.bin', False) self.blocks_file_sink_1_0.set_unbuffered(True) self.blocks_file_sink_1 = blocks.file_sink( gr.sizeof_gr_complex * 64, '/home/erc/SDN/after_fft_5_1.bin', False) self.blocks_file_sink_1.set_unbuffered(True) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_char * 1, '/home/erc/SDN/wifi_5_1.pcap', False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, 16) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, sync_length) self.blocks_conjugate_cc_0 = blocks.conjugate_cc() self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.msg_connect((self.ieee802_11_decode_mac_0, 'out'), (self.foo_wireshark_connector_0, 'in')) self.msg_connect((self.ieee802_11_decode_mac_0, 'out'), (self.ieee802_11_parse_mac_0, 'in')) self.msg_connect((self.ieee802_11_frame_equalizer_0, 'symbols'), (self.blocks_pdu_to_tagged_stream_1, 'pdus')) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.ieee802_11_sync_long_0, 1)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_conjugate_cc_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.ieee802_11_sync_short_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.ieee802_11_sync_short_0, 2)) self.connect((self.blocks_divide_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_moving_average_xx_1, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.blocks_moving_average_xx_1, 0), (self.ieee802_11_sync_short_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_moving_average_xx_1, 0)) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.blocks_file_sink_2, 0)) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.blocks_file_sink_1_1, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.correctiq_correctiq_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.correctiq_correctiq_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.correctiq_correctiq_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_file_sink_1, 0)) self.connect((self.fft_vxx_0, 0), (self.ieee802_11_frame_equalizer_0, 0)) self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.ieee802_11_frame_equalizer_0, 0), (self.blocks_file_sink_1_0, 0)) self.connect((self.ieee802_11_frame_equalizer_0, 0), (self.ieee802_11_decode_mac_0, 0)) self.connect((self.ieee802_11_sync_long_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.ieee802_11_sync_short_0, 0), (self.blocks_delay_0, 0)) self.connect((self.ieee802_11_sync_short_0, 0), (self.ieee802_11_sync_long_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.correctiq_correctiq_0, 0))
def __init__(self, mod_order=8, mod_scheme='ATSC_8VSB', rx_ant_model='Decotec Tape Measure Discone', rx_db_ser='na', rx_db_type='na', rx_ser_tag='F50030', rx_ser_uhd='F50030', rx_type='B210', signal_name='DTV', symbol_rate=10.76e6): gr.top_block.__init__(self, "Dtv Sigmf Playback") Qt.QWidget.__init__(self) self.setWindowTitle("Dtv Sigmf Playback") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "dtv_sigmf_playback") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.mod_order = mod_order self.mod_scheme = mod_scheme self.rx_ant_model = rx_ant_model self.rx_db_ser = rx_db_ser self.rx_db_type = rx_db_type self.rx_ser_tag = rx_ser_tag self.rx_ser_uhd = rx_ser_uhd self.rx_type = rx_type self.signal_name = signal_name self.symbol_rate = symbol_rate ################################################## # Variables ################################################## self.ts_str = ts_str = dt.strftime(dt.utcnow(), "%Y-%m-%dT%H:%M:%S.%fZ") self.fn = fn = "{:s}_{:s}".format(signal_name, ts_str) self.tune = tune = 0 self.samp_rate = samp_rate = 250e3 self.rx_gain = rx_gain = 45 self.rx_freq = rx_freq = 602.31e6 self.nfft = nfft = 1024 self.fp = fp = "/captures/dtv/{:s}".format(fn) self.avg_len = avg_len = 100.0 ################################################## # Blocks ################################################## self._tune_tool_bar = Qt.QToolBar(self) self._tune_tool_bar.addWidget(Qt.QLabel("tune" + ": ")) self._tune_line_edit = Qt.QLineEdit(str(self.tune)) self._tune_tool_bar.addWidget(self._tune_line_edit) self._tune_line_edit.returnPressed.connect(lambda: self.set_tune( eng_notation.str_to_num(str(self._tune_line_edit.text().toAscii())) )) self.top_grid_layout.addWidget(self._tune_tool_bar, 8, 2, 1, 2) for r in range(8, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate" + ": ")) self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate)) self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit) self._samp_rate_line_edit.returnPressed.connect( lambda: self.set_samp_rate( eng_notation.str_to_num( str(self._samp_rate_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._samp_rate_tool_bar, 9, 2, 1, 2) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) self._avg_len_tool_bar = Qt.QToolBar(self) self._avg_len_tool_bar.addWidget(Qt.QLabel("avg_len" + ": ")) self._avg_len_line_edit = Qt.QLineEdit(str(self.avg_len)) self._avg_len_tool_bar.addWidget(self._avg_len_line_edit) self._avg_len_line_edit.returnPressed.connect(lambda: self.set_avg_len( eng_notation.str_to_num( str(self._avg_len_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._avg_len_tool_bar, 8, 4, 1, 2) for r in range(8, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self.sigmf_source_0 = sigmf.source( '/captures/dtv/DTV_2019-02-20T18:06:10.sigmf-data', "cf32" + ("_le" if sys.byteorder == "little" else "_be"), True) self._rx_gain_tool_bar = Qt.QToolBar(self) self._rx_gain_tool_bar.addWidget(Qt.QLabel("rx_gain" + ": ")) self._rx_gain_line_edit = Qt.QLineEdit(str(self.rx_gain)) self._rx_gain_tool_bar.addWidget(self._rx_gain_line_edit) self._rx_gain_line_edit.returnPressed.connect(lambda: self.set_rx_gain( eng_notation.str_to_num( str(self._rx_gain_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._rx_gain_tool_bar, 8, 0, 1, 2) for r in range(8, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._rx_freq_tool_bar = Qt.QToolBar(self) self._rx_freq_tool_bar.addWidget(Qt.QLabel("rx_freq" + ": ")) self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq)) self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit) self._rx_freq_line_edit.returnPressed.connect(lambda: self.set_rx_freq( eng_notation.str_to_num( str(self._rx_freq_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._rx_freq_tool_bar, 9, 0, 1, 2) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_waterfall_sink_x_0_1 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "DTV", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0_1.set_update_time(0.010) self.qtgui_waterfall_sink_x_0_1.enable_grid(True) self.qtgui_waterfall_sink_x_0_1.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0_1.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0_1.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0_1.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0_1.set_intensity_range(-140, -40) self._qtgui_waterfall_sink_x_0_1_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_1_win, 2, 0, 2, 8) for r in range(2, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_vector_sink_f_0 = qtgui.vector_sink_f( nfft, 0, 1.0, "x-Axis", "y-Axis", "", 1 # Number of inputs ) self.qtgui_vector_sink_f_0.set_update_time(0.010) self.qtgui_vector_sink_f_0.set_y_axis(-140, 10) self.qtgui_vector_sink_f_0.enable_autoscale(False) self.qtgui_vector_sink_f_0.enable_grid(True) self.qtgui_vector_sink_f_0.set_x_axis_units("") self.qtgui_vector_sink_f_0.set_y_axis_units("") self.qtgui_vector_sink_f_0.set_ref_level(-40) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_vector_sink_f_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_vector_sink_f_0.set_line_label(i, labels[i]) self.qtgui_vector_sink_f_0.set_line_width(i, widths[i]) self.qtgui_vector_sink_f_0.set_line_color(i, colors[i]) self.qtgui_vector_sink_f_0.set_line_alpha(i, alphas[i]) self._qtgui_vector_sink_f_0_win = sip.wrapinstance( self.qtgui_vector_sink_f_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_vector_sink_f_0_win, 10, 0, 4, 8) for r in range(10, 14): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "DTV", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.01) self.qtgui_freq_sink_x_0.set_y_axis(-140, -40) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "red", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 2, 8) for r in range(0, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 8): self.top_grid_layout.setColumnStretch(c, 1) self.fft_vxx_0 = fft.fft_vcc(nfft, True, (window.blackmanharris(nfft)), True, 4) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_float * 1, nfft) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.float_t, 'fft') self.blocks_stream_to_vector_1 = blocks.stream_to_vector( gr.sizeof_float * 1, nfft) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, nfft) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_float, 1, nfft, "fft") self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", '0.0.0.0', '52001', 10000, True) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, nfft, -10 * math.log10(nfft)) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( int(avg_len), 1 / (avg_len) / nfft, 4000, nfft) self.blocks_message_strobe_0 = blocks.message_strobe( pmt.intern("fft"), 500) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared( nfft) self.analog_sig_source_x_0_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, tune, 1, 0) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.blocks_message_strobe_0, 'set_msg')) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_stream_to_vector_1, 0), (self.qtgui_vector_sink_f_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_waterfall_sink_x_0_1, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_stream_to_vector_1, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.sigmf_source_0, 0), (self.blocks_multiply_xx_0_0, 0))
def _setup_receiver(self): ### receiver blocks ### self.osmosdr_source_0 = osmosdr.source(args="numchan=1" + " " + self.radio_id) self.osmosdr_source_0.set_sample_rate(self.radio_sample_rate) self.osmosdr_source_0.set_center_freq( self.frequency + self.freq_offset, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(10, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(int(self.bandwidth * 10), 0) # something in the resampler blocks is causing 34 output samples to be lost in each # resampler, so adjust the total number in order to compensate for these lost samples, # calculating backwards up the path so the number gets scaled up by each decimation amount num_adjusted_samples = (34 + self.num_final_samples) * ( self.int2_sample_rate / self.final_sample_rate) num_adjusted_samples = (34 + num_adjusted_samples) * ( self.int1_sample_rate / self.int2_sample_rate) num_adjusted_samples = int( (34 + num_adjusted_samples) * (self.radio_sample_rate / self.int1_sample_rate)) self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex * 1, num_adjusted_samples) self.rational_resampler_recv_0 = filter.rational_resampler_ccc( interpolation=1, decimation=int(self.radio_sample_rate / self.int1_sample_rate), taps=None, fractional_bw=None, ) #self.low_pass_filter_recv_0 = filter.fir_filter_ccf(1, firdes.low_pass( # 1, self.int1_sample_rate, self.bandwidth*2, self.transition, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_recv_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, self.int1_sample_rate, self.bandwidth, self.transition, firdes.WIN_HAMMING, 6.76)) self.rational_resampler_recv_1 = filter.rational_resampler_ccc( interpolation=1, decimation=int(self.int1_sample_rate / self.int2_sample_rate), taps=None, fractional_bw=None, ) self.dc_blocker_0 = filter.dc_blocker_cc(32, True) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_moving_average_0 = blocks.moving_average_ff(length=1000, scale=1, max_iter=1000) self.rational_resampler_recv_2 = filter.rational_resampler_fff( interpolation=1, decimation=int(self.int2_sample_rate / self.final_sample_rate), taps=None, fractional_bw=None, ) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_float * 1, "localhost", self.data_port, 1472, True) ### end receiver blocks ### ### receiver connections ### self.connect((self.osmosdr_source_0, 0), (self.blocks_head_0, 0)) self.connect((self.blocks_head_0, 0), (self.rational_resampler_recv_0, 0)) self.connect((self.rational_resampler_recv_0, 0), (self.low_pass_filter_recv_0, 0)) self.connect((self.low_pass_filter_recv_0, 0), (self.rational_resampler_recv_1, 0)) #self.connect((self.blocks_head_0, 0), (self.low_pass_filter_recv_0, 0)) #self.connect((self.low_pass_filter_recv_0, 0), (self.rational_resampler_recv_0, 0)) #self.connect((self.rational_resampler_recv_0, 0), (self.rational_resampler_recv_1, 0)) self.connect((self.rational_resampler_recv_1, 0), (self.dc_blocker_0, 0)) self.connect((self.dc_blocker_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_moving_average_0, 0)) self.connect((self.blocks_moving_average_0, 0), (self.rational_resampler_recv_2, 0)) self.connect((self.rational_resampler_recv_2, 0), (self.blocks_udp_sink_0, 0)) ### end receiver connections ### return
def __init__(self): gr.top_block.__init__(self, "Receiver NC-OFDM") global expduration ################################################## # Read parameter for configuration ################################################## file_handle = open('/root/gr-ncofdm/examples/config_ncofdm_rx', 'r') for line in file_handle: # read rest of lines linefromfile = ([x for x in line.split()]) linesize = len(linefromfile)-1 if linesize > 1: linedata = map(float, linefromfile[1:linesize+1]) else: linedata = float(linefromfile[1]) if linefromfile[0] == "fft_len": fft_len = int(linedata) elif linefromfile[0] == "cp_len": cp_len = int(linedata) elif linefromfile[0] == "shseq_len": shseq_len = int(linedata) elif linefromfile[0] == "lgseq_len": lgseq_len = int(linedata) elif linefromfile[0] == "dataseq_len": dataseq_len = int(linedata) elif linefromfile[0] == "shseq_rep": shseq_rep = int(linedata) elif linefromfile[0] == "samp_rate": samp_rate = int(linedata) elif linefromfile[0] == "pnseq_offset": pnseq_offset = int(linedata) elif linefromfile[0] == "shseq": shseq = [int(z) for z in linedata] elif linefromfile[0] == "lgseq": lgseq = [int(z) for z in linedata] elif linefromfile[0] == "dataseq": dataseq = [int(z) for z in linedata] elif linefromfile[0] == "occupied_carriers": occupied_carriers = [int(z) for z in linedata] elif linefromfile[0] == "pilot_carriers": pilot_carriers = [int(z) for z in linedata] elif linefromfile[0] == "pilot_symbols": pilot_symbols = [int(z) for z in linedata] elif linefromfile[0] == "cen_freq": cen_freq = linedata elif linefromfile[0] == "noofsamples": noofsamples = int(linedata) elif linefromfile[0] == "expduration": expduration = linedata ################################################## # Variables ################################################## self.pn_symbols = pn_symbols = (1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1) self.lgseq_len = lgseq_len self.shseq_len = shseq_len self.fft_len = fft_len self.shseq_rep = shseq_rep self.shseq = shseq = pn_symbols[pnseq_offset+0:pnseq_offset+shseq_len] self.lgseq = lgseq = pn_symbols[pnseq_offset+shseq_len:pnseq_offset+shseq_len+lgseq_len] self.samp_rate = samp_rate self.pilot_symbols = pilot_symbols self.pilot_carriers = pilot_carriers self.packet_len = packet_len = 3*len(occupied_carriers) self.occupied_carriers = occupied_carriers self.length_tag_name = length_tag_name = "packet_len" self.fileprefix = fileprefix = "/root/" self.cp_len = cp_len self.cen_freq = cen_freq self.data_len = data_len = dataseq_len*20 self.ShThreshold = ShThreshold = 10 self.ShRepThreshold = ShRepThreshold = 3.5 self.LgThreshold = LgThreshold = 60 ################################################## # Blocks ################################################## self.uhd_usrp_source = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) # UHD self.uhd_usrp_source.set_samp_rate(samp_rate) self.uhd_usrp_source.set_center_freq(cen_freq, 0) self.uhd_usrp_source.set_gain(0, 0) self.uhd_usrp_source.set_antenna("RX2", 0) # Null sinks self.null_sink_shortpncorr_out = blocks.null_sink(gr.sizeof_gr_complex*1) self.null_sink_longpncorrv2_out = blocks.null_sink(gr.sizeof_gr_complex*1) self.null_sink_longpncorrv2_flag = blocks.null_sink(gr.sizeof_int*1) self.null_sink_longpncorrv2_corr = blocks.null_sink(gr.sizeof_gr_complex*1) # NCOFDM blocks self.ncofdm_ShortPNdetector = ncofdm.ShortPNdetector(fft_len, cp_len, shseq_rep, shseq_len, 1) self.ncofdm_ShortPNcorr = ncofdm.ShortPNcorr(fft_len, cp_len, shseq_rep, shseq_len, (shseq)) self.ncofdm_LongPNcorrV2 = ncofdm.LongPNcorrV2(fft_len, cp_len, lgseq_len, (lgseq), 60, shseq_len*shseq_rep+lgseq_len+data_len+10) self.ncofdm_FreqOffCalc = ncofdm.FreqOffCalc(fft_len, fft_len/4, shseq_len, shseq_rep) # File sinks self.file_sink_short = blocks.file_sink(gr.sizeof_gr_complex*1, fileprefix+"short.dat", False) self.file_sink_short.set_unbuffered(False) self.file_sink_rxshth = blocks.file_sink(gr.sizeof_float*1, fileprefix+"rxshth.dat", False) self.file_sink_rxshth.set_unbuffered(False) self.file_sink_org = blocks.file_sink(gr.sizeof_gr_complex*1, fileprefix+"org.dat", False) self.file_sink_org.set_unbuffered(False) self.file_sink_long = blocks.file_sink(gr.sizeof_gr_complex*1, fileprefix+"long.dat", False) self.file_sink_long.set_unbuffered(False) self.file_sink_lgth = blocks.file_sink(gr.sizeof_float*1, fileprefix+"lgth.dat", False) self.file_sink_lgth.set_unbuffered(False) self.file_sink_gain = blocks.file_sink(gr.sizeof_float*1, fileprefix+"gain.dat", False) self.file_sink_gain.set_unbuffered(False) #self.file_sink_freqoff = blocks.file_sink(gr.sizeof_float*1, fileprefix+"freqoff.dat", False) #self.file_sink_freqoff.set_unbuffered(False) self.file_sink_corr = blocks.file_sink(gr.sizeof_int*1, fileprefix+"corr.dat", False) self.file_sink_corr.set_unbuffered(False) # Blocks self.blocks_head = blocks.head(gr.sizeof_gr_complex*1, noofsamples) self.blocks_threshold_ff = blocks.threshold_ff(ShRepThreshold, ShRepThreshold, 0) self.blocks_moving_average = blocks.moving_average_ff(100, 0.01, 4000) self.blocks_float_to_int = blocks.float_to_int(1, 1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_delay_shpn_lgpn = blocks.delay(gr.sizeof_float*1, 2) self.blocks_delay_shpn_freqoff = blocks.delay(gr.sizeof_int*1, 1) self.blocks_delay_freqoff_lgpn = blocks.delay(gr.sizeof_float*1, 2) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_mag_org = blocks.complex_to_mag(1) self.blocks_complex_to_mag = blocks.complex_to_mag(1) self.analog_agc = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc.set_max_gain(50000.0) ################################################## # Connections ################################################## self.connect((self.uhd_usrp_source, 0), (self.blocks_head, 0)) self.connect((self.blocks_head, 0), (self.analog_agc, 0)) self.connect((self.analog_agc, 0), (self.blocks_complex_to_mag_org, 0)) self.connect((self.analog_agc, 1), (self.file_sink_gain, 0)) self.connect((self.analog_agc, 0), (self.file_sink_org, 0)) self.connect((self.analog_agc, 0), (self.ncofdm_LongPNcorrV2, 0)) self.connect((self.analog_agc, 0), (self.ncofdm_ShortPNcorr, 0)) self.connect((self.blocks_complex_to_mag, 0), (self.ncofdm_ShortPNdetector, 0)) self.connect((self.blocks_complex_to_mag_org, 0), (self.blocks_moving_average, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.file_sink_lgth, 0)) self.connect((self.blocks_delay_freqoff_lgpn, 0), (self.blocks_float_to_complex_0, 0)) #self.connect((self.blocks_delay_freqoff_lgpn, 0), (self.file_sink_freqoff, 0)) self.connect((self.blocks_delay_shpn_freqoff, 0), (self.ncofdm_FreqOffCalc, 1)) self.connect((self.blocks_delay_shpn_lgpn, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.ncofdm_LongPNcorrV2, 1)) self.connect((self.blocks_float_to_int, 0), (self.blocks_delay_shpn_freqoff, 0)) self.connect((self.blocks_moving_average, 0), (self.ncofdm_LongPNcorrV2, 2)) self.connect((self.blocks_threshold_ff, 0), (self.blocks_delay_shpn_lgpn, 0)) self.connect((self.blocks_threshold_ff, 0), (self.blocks_float_to_int, 0)) self.connect((self.ncofdm_FreqOffCalc, 0), (self.blocks_delay_freqoff_lgpn, 0)) self.connect((self.ncofdm_LongPNcorrV2, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.ncofdm_LongPNcorrV2, 2), (self.file_sink_corr, 0)) self.connect((self.ncofdm_LongPNcorrV2, 1), (self.file_sink_long, 0)) self.connect((self.ncofdm_LongPNcorrV2, 1), (self.null_sink_longpncorrv2_corr, 0)) self.connect((self.ncofdm_LongPNcorrV2, 2), (self.null_sink_longpncorrv2_flag, 0)) self.connect((self.ncofdm_LongPNcorrV2, 0), (self.null_sink_longpncorrv2_out, 0)) self.connect((self.ncofdm_ShortPNcorr, 1), (self.blocks_complex_to_mag, 0)) self.connect((self.ncofdm_ShortPNcorr, 1), (self.file_sink_short, 0)) self.connect((self.ncofdm_ShortPNcorr, 1), (self.ncofdm_FreqOffCalc, 0)) self.connect((self.ncofdm_ShortPNcorr, 0), (self.null_sink_shortpncorr_out, 0)) self.connect((self.ncofdm_ShortPNdetector, 0), (self.blocks_threshold_ff, 0)) self.connect((self.ncofdm_ShortPNdetector, 1), (self.file_sink_rxshth, 0))
def __init__(self, rtl_source, gnuradio_listener_address): logger.log("CellController - Starting") gr.top_block.__init__(self, "CogRIoT - Sensing Cell Controller") Qt.QWidget.__init__(self) self.setWindowTitle("CogRIoT - Sensing Cell Controller") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass ### self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "CellController") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.zmq_harddecision_pub_address = zmq_harddecision_pub_address = gnuradio_listener_address self.samp_rate = samp_rate = 2000000 self.rx_gain_if = rx_gain_if = 20 self.rx_gain_bb = rx_gain_bb = 20 self.rx_gain = rx_gain = 0 self.rx_freq = rx_freq = 950000000 self.rx_bw = rx_bw = samp_rate/2 self.remotesensor_address = remotesensor_address = rtl_source self.sensingprocessor_lambda = sensingprocessor_lambda = 0.5 ################################################## # Blocks ################################################## # receiver self._remotesensor_address_tool_bar = Qt.QToolBar(self) if None: self._remotesensor_address_formatter = None else: self._remotesensor_address_formatter = lambda x: x self._remotesensor_address_tool_bar.addWidget(Qt.QLabel("Sensing Cell"+": ")) self._remotesensor_address_label = Qt.QLabel(str(self._remotesensor_address_formatter(self.remotesensor_address))) self._remotesensor_address_tool_bar.addWidget(self._remotesensor_address_label) self.top_grid_layout.addWidget(self._remotesensor_address_tool_bar, 0,0,1,2) self._rx_gain_if_tool_bar = Qt.QToolBar(self) self._rx_gain_if_tool_bar.addWidget(Qt.QLabel("RX IF Gain"+": ")) self._rx_gain_if_line_edit = Qt.QLineEdit(str(self.rx_gain_if)) self._rx_gain_if_tool_bar.addWidget(self._rx_gain_if_line_edit) self._rx_gain_if_line_edit.returnPressed.connect( lambda: self.set_rx_gain_if(float(str(self._rx_gain_if_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._rx_gain_if_tool_bar, 2,0,1,1) self._rx_gain_bb_tool_bar = Qt.QToolBar(self) self._rx_gain_bb_tool_bar.addWidget(Qt.QLabel("RX BB Gain"+": ")) self._rx_gain_bb_line_edit = Qt.QLineEdit(str(self.rx_gain_bb)) self._rx_gain_bb_tool_bar.addWidget(self._rx_gain_bb_line_edit) self._rx_gain_bb_line_edit.returnPressed.connect( lambda: self.set_rx_gain_bb(float(str(self._rx_gain_bb_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._rx_gain_bb_tool_bar, 3,0,1,1) self._rx_gain_tool_bar = Qt.QToolBar(self) self._rx_gain_tool_bar.addWidget(Qt.QLabel("RX Gain"+": ")) self._rx_gain_line_edit = Qt.QLineEdit(str(self.rx_gain)) self._rx_gain_tool_bar.addWidget(self._rx_gain_line_edit) self._rx_gain_line_edit.returnPressed.connect( lambda: self.set_rx_gain(float(str(self._rx_gain_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._rx_gain_tool_bar, 1,0,1,1) self._rx_freq_tool_bar = Qt.QToolBar(self) self._rx_freq_tool_bar.addWidget(Qt.QLabel("RX Freq"+": ")) self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq)) self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit) self._rx_freq_line_edit.returnPressed.connect( lambda: self.set_rx_freq(int(str(self._rx_freq_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._rx_freq_tool_bar, 1,1,1,1) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + remotesensor_address ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(rx_freq, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(rx_gain, 0) self.rtlsdr_source_0.set_if_gain(rx_gain_if, 0) self.rtlsdr_source_0.set_bb_gain(rx_gain_bb, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(rx_bw, 0) self.zeromq_pub_msg_sink_0 = zeromq.pub_msg_sink(zmq_harddecision_pub_address, 100) # sensing processor self._Lambda_tool_bar = Qt.QToolBar(self) self._Lambda_tool_bar.addWidget(Qt.QLabel("Lambda"+": ")) self._Lambda_line_edit = Qt.QLineEdit(str(self.sensingprocessor_lambda)) self._Lambda_tool_bar.addWidget(self._Lambda_line_edit) self._Lambda_line_edit.returnPressed.connect( lambda: self.set_sensingprocessor_lambda(eng_notation.str_to_num(str(self._Lambda_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._Lambda_tool_bar, 2,1,1,1) self.sensingprocessor_hier_0 = sensingprocessor_hier( sensingprocessorLambda=sensingprocessor_lambda, ) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(1000, .001, 4000) # others self.blocks_message_debug_0 = blocks.message_debug() # graphic elements self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-0.2, 1.2) self.qtgui_time_sink_x_0_0.set_y_label("Probability of Detection", "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ["Avg", "Dec", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 4,1,1,1) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1 ) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ["Pd/Pfa", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("white", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, 0) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 4,0,1,1) ################################################## # Connections ################################################## self.connect((self.rtlsdr_source_0, 0), (self.sensingprocessor_hier_0, 0)) self.connect((self.sensingprocessor_hier_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.sensingprocessor_hier_0, 1), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.msg_connect((self.sensingprocessor_hier_0, 'msg_harddecision'), (self.zeromq_pub_msg_sink_0, 'in')) logger.log("CellController - Started")
def __init__(self, MTU=1500): gr.top_block.__init__(self, "Telemetry Rx Final") Qt.QWidget.__init__(self) self.setWindowTitle("Telemetry Rx Final") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "telemetry_rx_final") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.MTU = MTU ################################################## # Variables ################################################## self.symb_rate = symb_rate = 44643 self.sec_dec = sec_dec = 10 self.samp_per_symb = samp_per_symb = 10 self.rate = rate = 2 self.polys = polys = [109, 79] self.k = k = 7 self.first_dec = first_dec = 1 self.ss_ted_gain_range = ss_ted_gain_range = 100 self.ss_loopbw_range = ss_loopbw_range = 0.4 self.ss_damping_factor_range = ss_damping_factor_range = 0.5 self.source_option = source_option = False self.pll_loopbw_range = pll_loopbw_range = 0.4 self.doppler = doppler = 10000 self.dec_cc = dec_cc = fec.cc_decoder.make(MTU*8, k, rate, (polys), 0, -1, fec.CC_TERMINATED, False) self.channel_bw = channel_bw = 1200000 self.ad_samp_rate = ad_samp_rate = symb_rate*first_dec*sec_dec*samp_per_symb ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, 'Frequency Plot') self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, 'Control Tab') self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, 'Time') self.tab_widget_3 = Qt.QWidget() self.tab_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_3) self.tab_grid_layout_3 = Qt.QGridLayout() self.tab_layout_3.addLayout(self.tab_grid_layout_3) self.tab.addTab(self.tab_widget_3, 'Demoded Bits') self.tab_widget_4 = Qt.QWidget() self.tab_layout_4 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_4) self.tab_grid_layout_4 = Qt.QGridLayout() self.tab_layout_4.addLayout(self.tab_grid_layout_4) self.tab.addTab(self.tab_widget_4, 'Decoded Data') self.tab_widget_5 = Qt.QWidget() self.tab_layout_5 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_5) self.tab_grid_layout_5 = Qt.QGridLayout() self.tab_layout_5.addLayout(self.tab_grid_layout_5) self.tab.addTab(self.tab_widget_5, 'Decrypted Data') self.top_grid_layout.addWidget(self.tab, 0, 0, 4, 4) for r in range(0, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self._ss_ted_gain_range_range = Range(1, 1000, 1, 100, 10000) self._ss_ted_gain_range_win = RangeWidget(self._ss_ted_gain_range_range, self.set_ss_ted_gain_range, 'Symbol Sync TED gain', "dial", float) self.tab_grid_layout_1.addWidget(self._ss_ted_gain_range_win, 1, 2, 1, 1) for r in range(1, 2): self.tab_grid_layout_1.setRowStretch(r, 1) for c in range(2, 3): self.tab_grid_layout_1.setColumnStretch(c, 1) self._ss_loopbw_range_range = Range(0.001, 2, 0.001, 0.4, 10000) self._ss_loopbw_range_win = RangeWidget(self._ss_loopbw_range_range, self.set_ss_loopbw_range, 'Symbol Sync LBW', "dial", float) self.tab_grid_layout_1.addWidget(self._ss_loopbw_range_win, 1, 0, 1, 1) for r in range(1, 2): self.tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.tab_grid_layout_1.setColumnStretch(c, 1) self._ss_damping_factor_range_range = Range(0.001, 2, 0.001, 0.5, 10000) self._ss_damping_factor_range_win = RangeWidget(self._ss_damping_factor_range_range, self.set_ss_damping_factor_range, 'Symbol Sync DF', "dial", float) self.tab_grid_layout_1.addWidget(self._ss_damping_factor_range_win, 1, 1, 1, 1) for r in range(1, 2): self.tab_grid_layout_1.setRowStretch(r, 1) for c in range(1, 2): self.tab_grid_layout_1.setColumnStretch(c, 1) self._source_option_options = (True, False, ) self._source_option_labels = ('AD9361', 'File', ) self._source_option_group_box = Qt.QGroupBox('Source From') self._source_option_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._source_option_button_group = variable_chooser_button_group() self._source_option_group_box.setLayout(self._source_option_box) for i, label in enumerate(self._source_option_labels): radio_button = Qt.QRadioButton(label) self._source_option_box.addWidget(radio_button) self._source_option_button_group.addButton(radio_button, i) self._source_option_callback = lambda i: Qt.QMetaObject.invokeMethod(self._source_option_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._source_option_options.index(i))) self._source_option_callback(self.source_option) self._source_option_button_group.buttonClicked[int].connect( lambda i: self.set_source_option(self._source_option_options[i])) self.tab_grid_layout_1.addWidget(self._source_option_group_box, 2, 0, 1, 1) for r in range(2, 3): self.tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.tab_grid_layout_1.setColumnStretch(c, 1) self._pll_loopbw_range_range = Range(0.001, 2, 0.001, 0.4, 10000) self._pll_loopbw_range_win = RangeWidget(self._pll_loopbw_range_range, self.set_pll_loopbw_range, 'PLL LBW', "dial", float) self.tab_grid_layout_1.addWidget(self._pll_loopbw_range_win, 0, 0, 1, 1) for r in range(0, 1): self.tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.tab_grid_layout_1.setColumnStretch(c, 1) self._doppler_range = Range(-50000, 50000, 1, 10000, 10000) self._doppler_win = RangeWidget(self._doppler_range, self.set_doppler, 'Doppler', "dial", int) self.tab_grid_layout_1.addWidget(self._doppler_win, 0, 1, 1, 1) for r in range(0, 1): self.tab_grid_layout_1.setRowStretch(r, 1) for c in range(1, 2): self.tab_grid_layout_1.setColumnStretch(c, 1) self.satellites_decode_rs_general_0 = satellites.decode_rs_general(285, 0, 1, 32, False, True) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=first_dec, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc ad_samp_rate/first_dec, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(True) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not False: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win, 2, 0, 2, 4) for r in range(2, 4): self.tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 4): self.tab_grid_layout_0.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0_0_0_1_0_0 = qtgui.time_sink_f( 203, #size 1, #samp_rate "GCM-AES Decryptor Out", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0_0_1_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0_0_1_0_0.set_y_axis(-10, 300) self.qtgui_time_sink_x_0_0_0_0_1_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_0_0_1_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0_0_1_0_0.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "frm_len") self.qtgui_time_sink_x_0_0_0_0_1_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0_0_1_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0_0_1_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0_0_1_0_0.enable_control_panel(True) self.qtgui_time_sink_x_0_0_0_0_1_0_0.enable_stem_plot(False) if not False: self.qtgui_time_sink_x_0_0_0_0_1_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [2, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0_0_1_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0_0_1_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_0_1_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_0_1_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_0_1_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_0_1_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_0_1_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_0_1_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0_0_0_1_0_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_5.addWidget(self._qtgui_time_sink_x_0_0_0_0_1_0_0_win, 0, 0, 2, 4) for r in range(0, 2): self.tab_grid_layout_5.setRowStretch(r, 1) for c in range(0, 4): self.tab_grid_layout_5.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0_0_0_1_0 = qtgui.time_sink_f( 255, #size 1, #samp_rate "Viterbi Decoder Out", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0_0_1_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0_0_1_0.set_y_axis(-10, 300) self.qtgui_time_sink_x_0_0_0_0_1_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_0_0_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0_0_1_0.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "pkt_len") self.qtgui_time_sink_x_0_0_0_0_1_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0_0_1_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0_0_1_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0_0_1_0.enable_control_panel(True) self.qtgui_time_sink_x_0_0_0_0_1_0.enable_stem_plot(False) if not False: self.qtgui_time_sink_x_0_0_0_0_1_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [2, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0_0_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0_0_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_0_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_0_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_0_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_0_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_0_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_0_1_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0_0_0_1_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_4.addWidget(self._qtgui_time_sink_x_0_0_0_0_1_0_win, 0, 0, 2, 4) for r in range(0, 2): self.tab_grid_layout_4.setRowStretch(r, 1) for c in range(0, 4): self.tab_grid_layout_4.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0_0_0_1 = qtgui.time_sink_f( 223, #size 1, #samp_rate "Reed-Solomon Decoder Out", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0_0_1.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0_0_1.set_y_axis(-10, 300) self.qtgui_time_sink_x_0_0_0_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_0_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0_0_1.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "pkt_len") self.qtgui_time_sink_x_0_0_0_0_1.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0_0_1.enable_grid(False) self.qtgui_time_sink_x_0_0_0_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0_0_1.enable_control_panel(True) self.qtgui_time_sink_x_0_0_0_0_1.enable_stem_plot(False) if not False: self.qtgui_time_sink_x_0_0_0_0_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [2, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0_0_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_0_1_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0_0_0_1.pyqwidget(), Qt.QWidget) self.tab_grid_layout_4.addWidget(self._qtgui_time_sink_x_0_0_0_0_1_win, 2, 0, 2, 4) for r in range(2, 4): self.tab_grid_layout_4.setRowStretch(r, 1) for c in range(0, 4): self.tab_grid_layout_4.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0_0_0_0 = qtgui.time_sink_f( 4144, #size ad_samp_rate/first_dec/sec_dec/samp_per_symb, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0_0_0.set_y_axis(-1, 2) self.qtgui_time_sink_x_0_0_0_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "pkt_len") self.qtgui_time_sink_x_0_0_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0_0_0.enable_control_panel(True) self.qtgui_time_sink_x_0_0_0_0_0.enable_stem_plot(False) if not False: self.qtgui_time_sink_x_0_0_0_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [2, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0_0_0_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_3.addWidget(self._qtgui_time_sink_x_0_0_0_0_0_win, 2, 0, 2, 4) for r in range(2, 4): self.tab_grid_layout_3.setRowStretch(r, 1) for c in range(0, 4): self.tab_grid_layout_3.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 1024, #size ad_samp_rate/first_dec/sec_dec/samp_per_symb, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-20, 20) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(True) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not False: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [2, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_3.addWidget(self._qtgui_time_sink_x_0_0_win, 0, 0, 2, 2) for r in range(0, 2): self.tab_grid_layout_3.setRowStretch(r, 1) for c in range(0, 2): self.tab_grid_layout_3.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size ad_samp_rate/first_dec/sec_dec, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-20, 20) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(True) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not False: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [2, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_2.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_number_sink_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1 ) self.qtgui_number_sink_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0.set_title("Decrypted Frame Counter") labels = ['Counter', 'Rate', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0.set_min(i, -1) self.qtgui_number_sink_0_0.set_max(i, 1) self.qtgui_number_sink_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_win = sip.wrapinstance(self.qtgui_number_sink_0_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_3.addWidget(self._qtgui_number_sink_0_0_win, 0, 3, 2, 1) for r in range(0, 2): self.tab_grid_layout_3.setRowStretch(r, 1) for c in range(3, 4): self.tab_grid_layout_3.setColumnStretch(c, 1) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 2 ) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("Received Frame Counter") labels = ['Counter', 'Rate', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(2): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_3.addWidget(self._qtgui_number_sink_0_win, 0, 2, 2, 1) for r in range(0, 2): self.tab_grid_layout_3.setRowStretch(r, 1) for c in range(2, 3): self.tab_grid_layout_3.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc ad_samp_rate/first_dec, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-160, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 2, 4) for r in range(0, 2): self.tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 4): self.tab_grid_layout_0.setColumnStretch(c, 1) self.low_pass_filter_0 = filter.fir_filter_ccf(sec_dec, firdes.low_pass( 1, ad_samp_rate/first_dec, channel_bw, channel_bw/10, firdes.WIN_HAMMING, 6.76)) self.iustsat_zafar_telemetry_frame_extractor_1 = iustsat.zafar_telemetry_frame_extractor("pkt_len") self.iustsat_zafar_telemetry_derand_0 = iustsat.zafar_telemetry_derand("pkt_len") self.iustsat_tag_counter_0 = iustsat.tag_counter('pkt_len') self.iustsat_synch_detect_tag_1_0 = iustsat.synch_detect_tag(60,'pkt_len',259*2*8) self.iustsat_synch_detect_tag_1 = iustsat.synch_detect_tag(60,'pkt_len',259*2*8) self.iustsat_rs_to_decrypt_0_0 = iustsat.rs_to_decrypt('iv', ([0xCA, 0xFE, 0xBA, 0xBE, 0xFA, 0xCE, 0xDB, 0xAD, 0xDE, 0xCA, 0xF8, 0x88]), 'aad', 'auth_tag') self.iustsat_pdu_to_message_0 = iustsat.pdu_to_message('frm_len') self.iustsat_frame_analysis_0 = iustsat.frame_analysis('frm_len') self.iio_fmcomms2_source_0 = iio.fmcomms2_source_f32c('192.168.1.10', 436500000+doppler, ad_samp_rate, channel_bw, True, False, 0x8000, True, True, True, "fast_attack", 64.0, "manual", 64.0, "A_BALANCED", '', True) self.fir_filter_xxx_0 = filter.fir_filter_fff(1, ([1,1,1,-1,1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,-1,1,1,1,1,1,1,1,1,-1,-1,-1,1,1,-1,-1,-1,-1,-1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,1,-1,1,-1,1,1,1,-1,-1,-1,-1,-1,-1])) self.fir_filter_xxx_0.declare_sample_delay(0) self.fec_async_decoder_0 = fec.async_decoder(dec_cc, True, False, MTU) self.digital_symbol_sync_xx_0 = digital.symbol_sync_ff(digital.TED_GARDNER, samp_per_symb, ss_loopbw_range, ss_damping_factor_range, ss_ted_gain_range, 1, 1, digital.constellation_bpsk().base(), digital.IR_PFB_NO_MF, 128, ([])) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.dc_blocker_xx_0 = filter.dc_blocker_ff(100000, True) self.crypto_auth_dec_aes_gcm_0_0 = crypto.auth_dec_aes_gcm(([0xFE, 0xFF, 0xE9, 0x92, 0x86, 0x65, 0x73, 0x1C, 0x6D, 0x6A, 0x8F, 0x94, 0x67, 0x30, 0x83, 0x08]), 16, 96) self.blocks_uchar_to_float_1_0 = blocks.uchar_to_float() self.blocks_uchar_to_float_1 = blocks.uchar_to_float() self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, ad_samp_rate,True) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0.set_single_key("") self.blocks_pdu_to_tagged_stream_0_0_0_0 = blocks.pdu_to_tagged_stream(blocks.float_t, 'frm_len') self.blocks_pdu_to_tagged_stream_0_0_0 = blocks.pdu_to_tagged_stream(blocks.float_t, 'frm_len') self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'pkt_len') self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'pkt_len') self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_vcc((source_option, )) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vcc(((not source_option), )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((0.066666667, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2, )) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(samp_per_symb, 10, 4000, 1) self.blocks_message_debug_0_0 = blocks.message_debug() self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, '/home/iust/Documents/zafar_prj/gr-iustsat/examples/Records/REC7_GMSK.bin', True) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_float*1, 63) self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, 63) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blocks_add_const_vxx_1 = blocks.add_const_vff((0, )) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, )) self.analog_pll_freqdet_cf_0 = analog.pll_freqdet_cf(pll_loopbw_range, 700000*6.28/(ad_samp_rate/first_dec/sec_dec), 300000*6.28/(ad_samp_rate/first_dec/sec_dec)) ################################################## # Connections ################################################## self.msg_connect((self.crypto_auth_dec_aes_gcm_0_0, 'pdus'), (self.iustsat_frame_analysis_0, 'in')) self.msg_connect((self.crypto_auth_dec_aes_gcm_0_0, 'pdus'), (self.iustsat_pdu_to_message_0, 'in')) self.msg_connect((self.fec_async_decoder_0, 'out'), (self.iustsat_zafar_telemetry_derand_0, 'in')) self.msg_connect((self.iustsat_frame_analysis_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0_0, 'pdus')) self.msg_connect((self.iustsat_pdu_to_message_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0_0_0, 'pdus')) self.msg_connect((self.iustsat_rs_to_decrypt_0_0, 'out'), (self.crypto_auth_dec_aes_gcm_0_0, 'pdus')) self.msg_connect((self.iustsat_zafar_telemetry_derand_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.msg_connect((self.iustsat_zafar_telemetry_derand_0, 'out'), (self.satellites_decode_rs_general_0, 'in')) self.msg_connect((self.iustsat_zafar_telemetry_frame_extractor_1, 'out'), (self.fec_async_decoder_0, 'in')) self.msg_connect((self.satellites_decode_rs_general_0, 'out'), (self.blocks_message_debug_0_0, 'print_pdu')) self.msg_connect((self.satellites_decode_rs_general_0, 'out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.satellites_decode_rs_general_0, 'out'), (self.iustsat_rs_to_decrypt_0_0, 'in')) self.connect((self.analog_pll_freqdet_cf_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.digital_symbol_sync_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.iustsat_synch_detect_tag_1, 0)) self.connect((self.blocks_delay_0_0, 0), (self.iustsat_synch_detect_tag_1_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_add_const_vxx_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_uchar_to_float_1, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.blocks_uchar_to_float_1_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0_0, 0), (self.qtgui_number_sink_0_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0_0_0, 0), (self.qtgui_time_sink_x_0_0_0_0_1_0_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_multiply_const_vxx_2_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_uchar_to_float_1, 0), (self.qtgui_time_sink_x_0_0_0_0_1, 0)) self.connect((self.blocks_uchar_to_float_1_0, 0), (self.qtgui_time_sink_x_0_0_0_0_1_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.digital_symbol_sync_xx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.digital_symbol_sync_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_symbol_sync_xx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.iustsat_synch_detect_tag_1, 1)) self.connect((self.fir_filter_xxx_0, 0), (self.iustsat_synch_detect_tag_1_0, 1)) self.connect((self.iio_fmcomms2_source_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.iustsat_synch_detect_tag_1, 0), (self.iustsat_tag_counter_0, 0)) self.connect((self.iustsat_synch_detect_tag_1, 0), (self.iustsat_zafar_telemetry_frame_extractor_1, 0)) self.connect((self.iustsat_synch_detect_tag_1_0, 0), (self.qtgui_time_sink_x_0_0_0_0_0, 0)) self.connect((self.iustsat_tag_counter_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.iustsat_tag_counter_0, 1), (self.qtgui_number_sink_0, 1)) self.connect((self.low_pass_filter_0, 0), (self.analog_pll_freqdet_cf_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Testvolts") ################################################## # Variables - Some get overridden after block definition before connections. ################################################## self.samp_rate = samp_rate = 48000 # Initial wavelength assumption, which must be calibrated carefully. self.fundamental_wavelength_samples = 800 # self.probed_rms_volts = probed_rms_volts = 0 # Things from config file # self.avg_length = avg_length = 10000 self.probe_interval = probe_interval = float(SETTINGS["display"]["probe_interval"]) self.rms_alpha = rms_alpha = 1 # Calibration (Conversion) parameters, to convert from sample domain to volts/current domain. self.average_rms_slope = float(SETTINGS["calibration"]["average_rms_slope"]) self.average_rms_intercept = float(SETTINGS["calibration"]["average_rms_intercept"]) # RMS Block parameters self.voltage_calculation_rms_alpha = float(SETTINGS["calibration"]["voltage_calculation_rms_alpha"]) # Averaging block parameters self.voltage_rms_average_length = int(SETTINGS["calibration"]["voltage_rms_average_length"]) self.voltage_rms_average_scale = float(SETTINGS["calibration"]["voltage_rms_average_scale"]) self.voltage_rms_max_iter = int(SETTINGS["calibration"]["voltage_rms_max_iter"]) # for averaging block stuff self.last_sampled_wavelength = 1 # Input source parameters. self.audioSource = SETTINGS["input"]["input_type"] # Frequency calculation parameters self.freq_getfreq_alpha = float(SETTINGS["calibration"]["freq_getfreq_alpha"]) self.freq_interpolation = float(SETTINGS["calibration"]["freq_interpolation"]) self.freq_interpolation_multiplier = float(SETTINGS["calibration"]["freq_interpolation_multiplier"]) self.current_readings = self.getDefaultReadings() # AC Volts self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) # self.blocks_rms_volts = blocks.rms_ff(self.voltage_calculation_rms_alpha) # self.blocks_moving_average_volts = blocks.moving_average_ff(self.voltage_rms_average_length, self.voltage_rms_average_scale, self.voltage_rms_max_iter) # self.probe_rms_volts = blocks.probe_signal_f() # AC Frequency # if (setting_acfreq_enabled() is True): self.probe_avgwave = blocks.probe_signal_f() self.upsampler = filter.fractional_resampler_ff(0, self.freq_interpolation) self.getfreq_block = powerquality.getfreqcpp(self.freq_getfreq_alpha) # Streaming support - Permit access to the raw samples to ZeroMQ clients. self.zeromq_pub_sink_0 = zeromq.pub_sink(gr.sizeof_float, 1, SETTINGS["tap_rawsamples"]["zmq_bind_uri"], SETTINGS["tap_rawsamples"]["zmq_timeout"], True, -1) # TODO: Connect the streaming blocks # self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((-1, )) # self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, self.fundamental_wavelength_samples) # self.blocks_add_xx_0 = blocks.add_vff(1) # Bias detection - these parameters are tuned to 48khz samp rate: (1 * samp_rate / 60, .00125, 4000) if ("bias" in SETTINGS and "bias_avg_num_waves" in SETTINGS["bias"]): bias_avg_num_waves = SETTINGS["bias"]["bias_avg_num_waves"] else: bias_avg_num_waves = 1 # Calculate the number of samples associated with n wavelengths specified in settings or the default. avgBiasNumSamples = bias_avg_num_waves * samp_rate / 60 self.blocks_bias_moving_average = blocks.moving_average_ff(avgBiasNumSamples, 1.0/avgBiasNumSamples, 4000) self.probe_bias = blocks.probe_signal_f() ### Calibrate the blocks based on settings from config file # self.set_rms_alpha(asdfasdfasdfasdf from settings) # Instantiate the message consumer that we'll use to get json messages from the getfreq block self.msgConsumer = message_consumer() ################################################## # RMS Volts Connections ################################################## # self.connect((self.blocks_rms_volts, 0), (self.blocks_moving_average_volts, 0)) # self.connect((self.blocks_moving_average_volts, 0), (self.probe_rms_volts, 0)) # Set up a variable with a default value. Below we'll override the value depending on whether we are reading from file or audio device. self.sourceOfSamplesBlock = self.blocks_throttle_0 # Select input source - wav file or sound card. if (self.audioSource == "wav"): # Variable source type: wav file # self.wavfile_input = blocks.wavfile_source('./samples/sample.wav', False) self.input_wav_filename = SETTINGS["input"]["input_wav_filename"] self.wavfile_input = blocks.wavfile_source(self.input_wav_filename, True) # wav input requires throttle block. Then we connect things to the throttle block directly instead of the wav source. self.connect((self.wavfile_input, 0), (self.blocks_throttle_0, 0)) self.sourceOfSamplesBlock = self.blocks_throttle_0 else: # Variable source type: sound device. self.soundcard_device_name = "" if (SETTINGS["input"]["input_sound_device"]): self.soundcard_device_name = SETTINGS["input"]["input_sound_device"] self.soundcard_input = audio.source(samp_rate, self.soundcard_device_name, True) # no throttle block needed in the case of sound card self.sourceOfSamplesBlock = self.soundcard_input # Volts flow print "CONNECTIONS: Defining the voltage calculation flow" # self.connect((self.sourceOfSamplesBlock , 0), (self.blocks_rms_volts, 0)) # Hz flow print "CONNECTIONS: Defining the frequency calculation flow" self.connect((self.sourceOfSamplesBlock , 0), (self.upsampler, 0)) self.connect((self.upsampler, 0), (self.getfreq_block, 0)) self.connect((self.getfreq_block, 0), (self.probe_avgwave, 0)) # Raw Tap port Tap flow print "CONNECTIONS: Connecting raw samples tap (ZMQ)" self.connect((self.sourceOfSamplesBlock , 0), (self.zeromq_pub_sink_0, 0)) # Bias Detection flow self.connect((self.sourceOfSamplesBlock, 0), (self.blocks_bias_moving_average, 0)) self.connect((self.blocks_bias_moving_average, 0), (self.probe_bias, 0)) # Connect our message consumer block to the message output of the getfreq block so we can get messages from it. self.msg_connect((self.getfreq_block, 'out'), (self.msgConsumer, 'in_port'))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Keyfob Decode Wav") ################################################## # Variables ################################################## self.sps = sps = 5 self.samp_rate = samp_rate = 48000 ################################################## # Blocks ################################################## self.wxgui_scopesink2_1 = scopesink2.scope_sink_f( self.GetWin(), title="Scope Plot", sample_rate=3400, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_1.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title="Scope Plot", sample_rate=3400 * 5, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_fff( 3400.0*sps/48000, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.keyfob_parse_packet_0 = keyfob.parse_packet() self.keyfob_manchester_decode_0 = keyfob.manchester_decode() self.digital_correlate_access_code_tag_bb_0 = digital.correlate_access_code_tag_bb("10101000", 0, "packet_start") self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(5*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.05) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_wavfile_source_0 = blocks.wavfile_source("../gqrx_20150306_154200_434400000.wav", False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate*3,True) self.blocks_moving_average_xx_1 = blocks.moving_average_ff(sps, 1, 4000) ################################################## # Connections ################################################## self.connect((self.blocks_moving_average_xx_1, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.blocks_moving_average_xx_1, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.keyfob_manchester_decode_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.wxgui_scopesink2_1, 0)) self.connect((self.digital_correlate_access_code_tag_bb_0, 0), (self.keyfob_parse_packet_0, 0)) self.connect((self.keyfob_manchester_decode_0, 0), (self.digital_correlate_access_code_tag_bb_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_moving_average_xx_1, 0))
def __init__(self): gr.top_block.__init__(self, "Spin Echo") Qt.QWidget.__init__(self) self.setWindowTitle("Spin Echo") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "spin_echo") self.restoreGeometry(self.settings.value("geometry").toByteArray()) self._lock = threading.RLock() ################################################## # Variables ################################################## self.slave_delay = slave_delay = 0 self.samp_rate = samp_rate = 250000 self.ref_delay = ref_delay = 0 self.readout_delay = readout_delay = 0 self.power = power = 1 self.offset = offset = 0 self.master_delay = master_delay = 0 self.gz_on = gz_on = 0 self.gy_on = gy_on = 0 self.gx_on = gx_on = 0 self.ex_delay = ex_delay = 0 self.TR_clock = TR_clock = 0 self.TR = TR = 1. self.RUN = RUN = 1 self.Gz_delay = Gz_delay = 0 self.Gy_delay = Gy_delay = 0 self.Gx_delay = Gx_delay = 0 self.CF = CF = 21.3e6 #### ADDED FROM GR-MRI ##### f = open('spin_config.txt', 'r') foo = {} for line in f: k, v, bar = [q.strip() for q in line.split(',')] if k == 'leader_ID': self.leader_ID = str("serial = " + v) elif k == 'follower_ID': self.follower_ID = str("serial = " + v) else: pass f.close() ############################ ################################################## # Blocks ################################################## self.delay = blocks.delay(gr.sizeof_gr_complex * 1, 5) self.uhd_usrp_source_0_0 = uhd.usrp_source( ",".join((self.follower_ID, "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0_0.set_clock_source("external", 0) self.uhd_usrp_source_0_0.set_time_source("external", 0) self.uhd_usrp_source_0_0.set_subdev_spec("B:A B:B", 0) self.uhd_usrp_source_0_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0.set_center_freq(0, 0) self.uhd_usrp_source_0_0.set_gain(0, 0) self.uhd_usrp_source_0_0.set_antenna("B:A", 0) self.uhd_usrp_source_0_0.set_center_freq(0, 1) self.uhd_usrp_source_0_0.set_gain(0, 1) self.uhd_usrp_source_0_0.set_antenna("B:B", 1) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join((self.leader_ID, "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0.set_subdev_spec("A:A B:B", 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(CF + offset, 0) self.uhd_usrp_source_0.set_gain(15, 0) self.uhd_usrp_source_0.set_antenna("A:A", 0) self.uhd_usrp_source_0.set_bandwidth(25000, 0) self.uhd_usrp_source_0.set_center_freq(CF + offset, 1) self.uhd_usrp_source_0.set_gain(10, 1) self.uhd_usrp_source_0.set_antenna("B:B", 1) self.syncwin = MRI.triggered_vector_source_f( [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 1.0, 0.0, 1, 1) self.sync_data = blocks.vector_sink_c(1) self.signal_out = MRI.gated_vector_sink() self.s_delay_0_0_0 = blocks.delay(gr.sizeof_float * 1, 5) self.s_delay_0_0 = blocks.delay(gr.sizeof_float * 1, 5) self.s_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 5) self.s_delay = blocks.delay(gr.sizeof_gr_complex * 1, int(slave_delay)) self.rf_sink = uhd.usrp_sink( ",".join((self.leader_ID, "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.rf_sink.set_subdev_spec("A:AB B:AB", 0) self.rf_sink.set_samp_rate(samp_rate) self.rf_sink.set_center_freq(CF + offset, 0) self.rf_sink.set_gain(0, 0) self.rf_sink.set_antenna("A:AB", 0) self.rf_sink.set_center_freq(0, 1) self.rf_sink.set_gain(0, 1) self.rf_sink.set_antenna("B:AB", 1) self.ref_pulse = MRI.triggered_vector_source([0, 0, 0], 1.0, 0.0, 1, 1) self.readwin = MRI.triggered_vector_source_f([0, 0, 0], 1.0, 0.0, 1, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 3000, #size samp_rate, #samp_rate "", #name 4 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(.1) self.qtgui_time_sink_x_0.set_y_axis(-.25, .25) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_AUTO, qtgui.TRIG_SLOPE_POS, .01, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = [ "Read Window", "Real Signal", "Imag Signal", "RMS", "", "", "", "", "", "" ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "black", "blue", "red", "green", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [2, 1, 1, 2, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(4): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.m_delay = blocks.delay(gr.sizeof_gr_complex * 1, int(master_delay)) self.ex_pulse = MRI.triggered_vector_source([0, 0, 0], 1.0, 0.0, 1, 1) self.delay6 = blocks.delay(gr.sizeof_float * 1, Gx_delay) self.delay3_0_1_0 = blocks.delay(gr.sizeof_float * 1, Gy_delay) self.delay3_0_1 = blocks.delay(gr.sizeof_float * 1, Gz_delay) self.delay3 = blocks.delay(gr.sizeof_float * 1, readout_delay) self.delay1_0 = blocks.delay(gr.sizeof_float * 1, ref_delay) self.delay1 = blocks.delay(gr.sizeof_float * 1, ex_delay) self.dc_sinc = uhd.usrp_sink( ",".join((self.follower_ID, "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.dc_sinc.set_clock_source("external", 0) self.dc_sinc.set_time_source("external", 0) self.dc_sinc.set_subdev_spec("B:AB A:AB", 0) self.dc_sinc.set_samp_rate(samp_rate) self.dc_sinc.set_center_freq(0, 0) self.dc_sinc.set_gain(0, 0) self.dc_sinc.set_antenna("B:AB", 0) self.dc_sinc.set_center_freq(0, 1) self.dc_sinc.set_gain(0, 1) self.dc_sinc.set_antenna("A:AB", 1) self.blocks_threshold_ff_0_2 = blocks.threshold_ff(.000001, .000001, 0) self.blocks_threshold_ff_0_1 = blocks.threshold_ff(.05, .05, 0) self.blocks_threshold_ff_0_0 = blocks.threshold_ff(.01, .01, 0) self.blocks_threshold_ff_0 = blocks.threshold_ff(.01, .01, 0) self.blocks_rms_xx_1 = blocks.rms_cf(1) self.blocks_rms_xx_0_0 = blocks.rms_cf(1) self.blocks_rms_xx_0 = blocks.rms_cf(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_vff((RUN, )) self.blocks_multiply_const_vxx_1_0_0 = blocks.multiply_const_vff( (gy_on, )) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff( (gz_on, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((gx_on, )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(10, 1, 4000) self.blocks_float_to_complex_2 = blocks.float_to_complex(1) self.blocks_float_to_complex_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0_0_0 = blocks.float_to_complex(1) self.blocks_float_to_complex_0_0 = blocks.float_to_complex(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_divide_xx_0 = blocks.divide_cc(1) self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_1 = blocks.add_vcc(1) self.blocks_add_xx_0_0 = blocks.add_vcc(1) self.analog_sig_source_x_0_0_0 = analog.sig_source_f( samp_rate, analog.GR_SQR_WAVE, 5. / TR, 1, 0) self.analog_sig_source_x_0_0 = analog.sig_source_f( samp_rate, analog.GR_SQR_WAVE, 1. / TR, 1, 0) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) self.Gz = MRI.triggered_vector_source_f([0, 0, 0], 1, 0, 1, 1) self.Gy = MRI.triggered_vector_source_f([0, 0, 0], 1, 0, 1, 1) self.Gx = MRI.triggered_vector_source_f([0, 0, 0], 1, 0, 1, 1) ################################################## # Connections ################################################## self.connect((self.Gx, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.Gy, 0), (self.blocks_multiply_const_vxx_1_0_0, 0)) self.connect((self.Gz, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_const_vxx_2_0, 0)) self.connect((self.analog_sig_source_x_0_0_0, 0), (self.syncwin, 0)) self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_complex_to_mag_1, 0)) self.connect((self.blocks_add_xx_1, 0), (self.delay, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.qtgui_time_sink_x_0, 2)) self.connect((self.blocks_complex_to_float_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_threshold_ff_0_1, 0)) self.connect((self.blocks_complex_to_mag_1, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.blocks_float_to_complex_0_0, 0), (self.s_delay, 0)) self.connect((self.blocks_float_to_complex_0_0_0, 0), (self.s_delay, 1)) self.connect((self.blocks_float_to_complex_0_1, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_float_to_complex_1, 0), (self.sync_data, 0)) self.connect((self.blocks_float_to_complex_2, 0), (self.m_delay, 1)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_threshold_ff_0_2, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_rms_xx_1, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.signal_out, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.s_delay_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blocks_float_to_complex_0_0_0, 1)) self.connect((self.blocks_multiply_const_vxx_1_0_0, 0), (self.blocks_float_to_complex_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.delay1, 0)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.delay1_0, 0)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.delay3, 0)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.delay3_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.delay3_0_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.delay6, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_float_to_complex_0_1, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_rms_xx_0_0, 0), (self.blocks_threshold_ff_0_0, 0)) self.connect((self.blocks_rms_xx_1, 0), (self.qtgui_time_sink_x_0, 3)) self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_float_to_complex_1, 0)) self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_float_to_complex_1, 1)) self.connect((self.blocks_threshold_ff_0_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_threshold_ff_0_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_threshold_ff_0_1, 0), (self.signal_out, 0)) self.connect((self.blocks_threshold_ff_0_2, 0), (self.blocks_float_to_complex_2, 0)) self.connect((self.delay, 0), (self.m_delay, 0)) self.connect((self.delay1, 0), (self.ex_pulse, 0)) self.connect((self.delay1_0, 0), (self.ref_pulse, 0)) self.connect((self.delay3, 0), (self.readwin, 0)) self.connect((self.delay3_0_1, 0), (self.Gz, 0)) self.connect((self.delay3_0_1_0, 0), (self.Gy, 0)) self.connect((self.delay6, 0), (self.Gx, 0)) self.connect((self.ex_pulse, 0), (self.blocks_add_xx_0_0, 0)) self.connect((self.m_delay, 0), (self.rf_sink, 0)) self.connect((self.m_delay, 1), (self.rf_sink, 1)) self.connect((self.readwin, 0), (self.s_delay_0_0_0, 0)) self.connect((self.ref_pulse, 0), (self.blocks_add_xx_0_0, 1)) self.connect((self.s_delay, 0), (self.dc_sinc, 0)) self.connect((self.s_delay, 1), (self.s_delay_0, 0)) self.connect((self.s_delay_0, 0), (self.dc_sinc, 1)) self.connect((self.s_delay_0_0, 0), (self.blocks_float_to_complex_0_0, 1)) self.connect((self.s_delay_0_0_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.syncwin, 0), (self.blocks_float_to_complex_0_0, 0)) self.connect((self.syncwin, 0), (self.blocks_float_to_complex_2, 1)) self.connect((self.uhd_usrp_source_0, 1), (self.blocks_complex_to_mag_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.blocks_divide_xx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.uhd_usrp_source_0_0, 1), (self.blocks_rms_xx_0_0, 0))
def __init__(self, ampl=0.7, args='', arq_timeout=.1*0 + 0.04, dest_addr=-1, iface='tun0', max_arq_attempts=5 * 2, mtu=128, ogradio_addr=0, ogrx_freq=915e6, ogtx_freq=915e6, port="12345", rate=1e6, rx_antenna="TX/RX", rx_gain=65-20, rx_lo_offset=0, samps_per_sym=4, tx_gain=45, tx_lo_offset=0): grc_wxgui.top_block_gui.__init__(self, title="Broadcastwithfreqandmac") self._lock = threading.RLock() ################################################## # Parameters ################################################## self.ampl = ampl self.args = args self.arq_timeout = arq_timeout self.dest_addr = dest_addr self.iface = iface self.max_arq_attempts = max_arq_attempts self.mtu = mtu self.ogradio_addr = ogradio_addr self.ogrx_freq = ogrx_freq self.ogtx_freq = ogtx_freq self.port = port self.rate = rate self.rx_antenna = rx_antenna self.rx_gain = rx_gain self.rx_lo_offset = rx_lo_offset self.samps_per_sym = samps_per_sym self.tx_gain = tx_gain self.tx_lo_offset = tx_lo_offset ################################################## # Variables ################################################## self.user_tx_gain = user_tx_gain = tx_gain self.user_rx_gain = user_rx_gain = rx_gain self.tx_freq = tx_freq = 915e6 self.samp_rate = samp_rate = rate self.rx_freq = rx_freq = 915e6 self.radio_addr = radio_addr = 84 ################################################## # Blocks ################################################## _user_tx_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._user_tx_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_user_tx_gain_sizer, value=self.user_tx_gain, callback=self.set_user_tx_gain, label="TX Gain", converter=forms.float_converter(), proportion=0, ) self._user_tx_gain_slider = forms.slider( parent=self.GetWin(), sizer=_user_tx_gain_sizer, value=self.user_tx_gain, callback=self.set_user_tx_gain, minimum=0, maximum=90, num_steps=90, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_user_tx_gain_sizer) _user_rx_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._user_rx_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_user_rx_gain_sizer, value=self.user_rx_gain, callback=self.set_user_rx_gain, label="RX Gain", converter=forms.float_converter(), proportion=0, ) self._user_rx_gain_slider = forms.slider( parent=self.GetWin(), sizer=_user_rx_gain_sizer, value=self.user_rx_gain, callback=self.set_user_rx_gain, minimum=0, maximum=90, num_steps=90, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_user_rx_gain_sizer) self._tx_freq_text_box = forms.text_box( parent=self.GetWin(), value=self.tx_freq, callback=self.set_tx_freq, label='tx_freq', converter=forms.float_converter(), ) self.Add(self._tx_freq_text_box) self._rx_freq_text_box = forms.text_box( parent=self.GetWin(), value=self.rx_freq, callback=self.set_rx_freq, label='rx_freq', converter=forms.float_converter(), ) self.Add(self._rx_freq_text_box) self._radio_addr_text_box = forms.text_box( parent=self.GetWin(), value=self.radio_addr, callback=self.set_radio_addr, label="Local address", converter=forms.int_converter(), ) self.Add(self._radio_addr_text_box) self.mac_802_3_tracker = mac.tracker_802_3(verbose=False) self.wxgui_scopesink2_0_0 = scopesink2.scope_sink_c( self.GetWin(), title="RX", sample_rate=samp_rate, v_scale=0.02, v_offset=0, t_scale=0.0001, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=wxgui.TRIG_MODE_NORM, y_axis_label="Counts", ) self.GridAdd(self.wxgui_scopesink2_0_0.win, 0, 0, 1, 1) self.simple_mac_1 = mac.simple_mac( radio_addr, arq_timeout, max_arq_attempts, 2.0, False, 0.05, node_expiry_delay=10.0, expire_on_arq_failure=False, only_send_if_alive=False, prepend_dummy=False, ) self.mac_virtual_channel_encoder_0_0 = mac.virtual_channel_encoder(-1, True,mtu=mtu, chan_id=1, prepend_dummy=False, chan_tracker=self.mac_802_3_tracker, ) self.mac_virtual_channel_encoder_0 = mac.virtual_channel_encoder(-1, True,mtu=mtu, chan_id=0, prepend_dummy=False, ) self.mac_virtual_channel_decoder_0 = mac.virtual_channel_decoder(3, [0, 1]) self.gmsk_radio_0 = gmsk_radio( access_code_threshold=0 + 12 + 4*0, samps_per_sym=samps_per_sym, tx_lo_offset=tx_lo_offset, rx_lo_offset=rx_lo_offset, ampl=ampl, rx_gain=user_rx_gain, rx_freq=rx_freq, rx_ant=rx_antenna, tx_freq=tx_freq, tx_gain=user_tx_gain, args=args, rate=samp_rate, ) self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu(iface, mtu*0 + 1514, False) self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", "", port, mtu, False) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1, )) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(10000, 1./10000, 40000/4) self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("T"), 1) self.blocks_message_debug_0_0_1 = blocks.message_debug() self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.simple_mac_1, 'ctrl_in')) self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.mac_virtual_channel_encoder_0, 'in')) self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'), (self.mac_virtual_channel_encoder_0_0, 'in')) self.msg_connect((self.gmsk_radio_0, 'msg_out'), (self.simple_mac_1, 'from_radio')) self.msg_connect((self.mac_virtual_channel_decoder_0, 'out2'), (self.blocks_message_debug_0_0_1, 'print')) self.msg_connect((self.mac_virtual_channel_decoder_0, 'out0'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.mac_virtual_channel_decoder_0, 'out1'), (self.blocks_tuntap_pdu_0, 'pdus')) self.msg_connect((self.mac_virtual_channel_decoder_0, 'out1'), (self.mac_802_3_tracker, 'in')) self.msg_connect((self.mac_virtual_channel_encoder_0, 'out'), (self.simple_mac_1, 'from_app_arq')) self.msg_connect((self.mac_virtual_channel_encoder_0_0, 'out'), (self.simple_mac_1, 'from_app_arq')) self.msg_connect((self.simple_mac_1, 'to_radio'), (self.gmsk_radio_0, 'msg_in')) self.msg_connect((self.simple_mac_1, 'to_app'), (self.mac_virtual_channel_decoder_0, 'in')) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.wxgui_scopesink2_0_0, 1)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.gmsk_radio_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.gmsk_radio_0, 0), (self.wxgui_scopesink2_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Receptor APT NOAA") Qt.QWidget.__init__(self) self.setWindowTitle("Receptor APT NOAA") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "SdrApt") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.trans = trans = 1 self.samp_rate = samp_rate = 960000 self.prefix = prefix = "/home/gonzalo/workspace/sdr-apt/wav/" self.fcd_freq = fcd_freq = 137100000 self.cutoff = cutoff = 40 self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass( 1, samp_rate * 2, cutoff * 1000, trans * 1000, firdes.WIN_HAMMING, 6.76) self.variable_qtgui_label_0 = variable_qtgui_label_0 = fcd_freq self.recfile2 = recfile2 = prefix + "am_demod/" + datetime.now( ).strftime("%Y.%m.%d.%H.%M.%S") + ".wav" self.recfile = recfile = prefix + "fm_demod/" + datetime.now( ).strftime("%Y.%m.%d.%H.%M.%S") + ".wav" self.lpf_cutoff = lpf_cutoff = 40000 self.lna_gain_0 = lna_gain_0 = 30 self.delay = delay = 0 self.bpf_lp = bpf_lp = 500 self.bpf_hp = bpf_hp = 5000 self.af_gain = af_gain = 1.5 ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, "Senal en recepcion") self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, "Demodulacion FM") self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, "Detector de envolvente") self.top_layout.addWidget(self.tab) self._lna_gain_0_options = ( 0, 10, 20, 30, 35, ) self._lna_gain_0_labels = ( "0 dB", "+ 10 dB", "+ 20 dB", "+ 30 dB", "+ 35 dB", ) self._lna_gain_0_tool_bar = Qt.QToolBar(self) self._lna_gain_0_tool_bar.addWidget( Qt.QLabel("Ganancia SDR (dB)" + ": ")) self._lna_gain_0_combo_box = Qt.QComboBox() self._lna_gain_0_tool_bar.addWidget(self._lna_gain_0_combo_box) for label in self._lna_gain_0_labels: self._lna_gain_0_combo_box.addItem(label) self._lna_gain_0_callback = lambda i: Qt.QMetaObject.invokeMethod( self._lna_gain_0_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._lna_gain_0_options.index(i))) self._lna_gain_0_callback(self.lna_gain_0) self._lna_gain_0_combo_box.currentIndexChanged.connect( lambda i: self.set_lna_gain_0(self._lna_gain_0_options[i])) self.top_grid_layout.addWidget(self._lna_gain_0_tool_bar, 1, 4, 1, 1) self._fcd_freq_options = ( 137620000, 137912500, 137100000, 93900000, ) self._fcd_freq_labels = ( "NOAA 15", "NOAA 18", "NOAA 19", "Oceano FM", ) self._fcd_freq_group_box = Qt.QGroupBox("Seleccionar Satelite") self._fcd_freq_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._fcd_freq_button_group = variable_chooser_button_group() self._fcd_freq_group_box.setLayout(self._fcd_freq_box) for i, label in enumerate(self._fcd_freq_labels): radio_button = Qt.QRadioButton(label) self._fcd_freq_box.addWidget(radio_button) self._fcd_freq_button_group.addButton(radio_button, i) self._fcd_freq_callback = lambda i: Qt.QMetaObject.invokeMethod( self._fcd_freq_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._fcd_freq_options.index(i))) self._fcd_freq_callback(self.fcd_freq) self._fcd_freq_button_group.buttonClicked[int].connect( lambda i: self.set_fcd_freq(self._fcd_freq_options[i])) self.top_grid_layout.addWidget(self._fcd_freq_group_box, 1, 1, 1, 2) self._delay_range = Range(0, 5, 1, 0, 200) self._delay_win = RangeWidget(self._delay_range, self.set_delay, "Delay", "counter_slider", float) self.tab_layout_2.addWidget(self._delay_win) self._cutoff_range = Range(10, 48, 1, 40, 200) self._cutoff_win = RangeWidget(self._cutoff_range, self.set_cutoff, "Frecuencia de corte LPF (kHz)", "counter_slider", float) self.top_grid_layout.addWidget(self._cutoff_win, 2, 1, 1, 1) self._bpf_lp_range = Range(200, 500, 10, 500, 100) self._bpf_lp_win = RangeWidget(self._bpf_lp_range, self.set_bpf_lp, "Band Pass Filter Lp", "counter_slider", float) self.tab_layout_2.addWidget(self._bpf_lp_win) self._bpf_hp_range = Range(800, 8000, 10, 5000, 100) self._bpf_hp_win = RangeWidget(self._bpf_hp_range, self.set_bpf_hp, "Band Pass Filter Hp", "counter_slider", float) self.tab_layout_2.addWidget(self._bpf_hp_win) self._af_gain_range = Range(0, 3, .1, 1.5, 100) self._af_gain_win = RangeWidget(self._af_gain_range, self.set_af_gain, "Volumen audio", "dial", float) self.top_grid_layout.addWidget(self._af_gain_win, 2, 4, 1, 1) self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_formatter = None else: self._variable_qtgui_label_0_formatter = lambda x: x self._variable_qtgui_label_0_tool_bar.addWidget( Qt.QLabel("Frecuencia Portadora" + ": ")) self._variable_qtgui_label_0_label = Qt.QLabel( str( self._variable_qtgui_label_0_formatter( self.variable_qtgui_label_0))) self._variable_qtgui_label_0_tool_bar.addWidget( self._variable_qtgui_label_0_label) self.top_grid_layout.addWidget(self._variable_qtgui_label_0_tool_bar, 1, 3, 1, 1) self._trans_range = Range(1, 40, .2, 1, 200) self._trans_win = RangeWidget(self._trans_range, self.set_trans, "Ancho LPF (kHz)", "counter_slider", float) self.top_grid_layout.addWidget(self._trans_win, 2, 3, 1, 1) self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_fff( interpolation=20800, decimation=48000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=96000, decimation=samp_rate, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 96000, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0_0.enable_grid(False) if not True: self.qtgui_waterfall_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tab_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_0_win) self.qtgui_time_sink_x_2_0 = qtgui.time_sink_c( 1024, #size 96000, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_2_0.set_update_time(0.10) self.qtgui_time_sink_x_2_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_2_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_2_0.enable_tags(-1, True) self.qtgui_time_sink_x_2_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_2_0.enable_autoscale(False) self.qtgui_time_sink_x_2_0.enable_grid(False) self.qtgui_time_sink_x_2_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_2_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2 * 1): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_2_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_2_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_2_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_2_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_2_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_2_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_2_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_2_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_2_0_win = sip.wrapinstance( self.qtgui_time_sink_x_2_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_2_0_win) self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f( 2080, #size 2080 * 2, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0.set_update_time(.5) self.qtgui_time_sink_x_1_0.set_y_axis(0, 0.4) self.qtgui_time_sink_x_1_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.4, 0, 0, "") self.qtgui_time_sink_x_1_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0.enable_grid(True) self.qtgui_time_sink_x_1_0.enable_control_panel(True) if not True: self.qtgui_time_sink_x_1_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_win = sip.wrapinstance( self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget) self.tab_layout_2.addWidget(self._qtgui_time_sink_x_1_0_win) self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f( 1024, #size 20800, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_1.set_update_time(0.10) self.qtgui_time_sink_x_0_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_1.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_1.enable_tags(-1, False) self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_1.enable_autoscale(False) self.qtgui_time_sink_x_0_1.enable_grid(False) self.qtgui_time_sink_x_0_1.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_1.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_win = sip.wrapinstance( self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget) self.tab_layout_1.addWidget(self._qtgui_time_sink_x_0_1_win) self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f( 1024, #size 20800, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_0_0.enable_tags(-1, False) self.qtgui_time_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.tab_layout_2.addWidget(self._qtgui_time_sink_x_0_0_0_win) self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 20800, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1_0.set_update_time(0.10) self.qtgui_freq_sink_x_1_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1_0.enable_autoscale(False) self.qtgui_freq_sink_x_1_0.enable_grid(False) self.qtgui_freq_sink_x_1_0.set_fft_average(1.0) self.qtgui_freq_sink_x_1_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1_0.disable_legend() if "float" == "float" or "float" == "msg_float": self.qtgui_freq_sink_x_1_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_1_0.pyqwidget(), Qt.QWidget) self.tab_layout_1.addWidget(self._qtgui_freq_sink_x_1_0_win) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 96000, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tab_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_win) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(fcd_freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(lna_gain_0, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self._lpf_cutoff_range = Range(10000, 50000, 1, 40000, 100) self._lpf_cutoff_win = RangeWidget(self._lpf_cutoff_range, self.set_lpf_cutoff, "Low Pass Filter cutoff", "counter_slider", float) self.tab_layout_0.addWidget(self._lpf_cutoff_win) self.low_pass_filter_1_0 = filter.fir_filter_ccf( 1, firdes.low_pass(30, 96000, cutoff * 1000, 500, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = filter.fir_filter_fff( 1, firdes.low_pass(10, 20800, 2000, 500, firdes.WIN_HAMMING, 6.76)) self.hilbert_fc_0_0 = filter.hilbert_fc(5, firdes.WIN_HAMMING, 6.76) self.blocks_wavfile_sink_1_0 = blocks.wavfile_sink( recfile2, 1, 4160, 16) self.blocks_wavfile_sink_0_0 = blocks.wavfile_sink( recfile, 1, 20800, 16) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff( (af_gain, )) self.blocks_moving_average_xx_0_0 = blocks.moving_average_ff( 11, 1 / 11., 4000) self.blocks_keep_one_in_n_0_0 = blocks.keep_one_in_n( gr.sizeof_float * 1, 5) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_float * 1, delay) self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1) self.band_pass_filter_0 = filter.interp_fir_filter_fff( 1, firdes.band_pass(1, 48000, bpf_lp, bpf_hp, 200, firdes.WIN_HAMMING, 6.76)) self.audio_sink_0_0 = audio.sink(48000, "", True) self.analog_wfm_rcv_0_0 = analog.wfm_rcv( quad_rate=96000, audio_decimation=2, ) ################################################## # Connections ################################################## self.connect((self.analog_wfm_rcv_0_0, 0), (self.audio_sink_0_0, 0)) self.connect((self.analog_wfm_rcv_0_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.blocks_wavfile_sink_0_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.hilbert_fc_0_0, 0)) self.connect((self.blocks_complex_to_mag_0_0, 0), (self.blocks_moving_average_xx_0_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_keep_one_in_n_0_0, 0), (self.blocks_wavfile_sink_1_0, 0)) self.connect((self.blocks_keep_one_in_n_0_0, 0), (self.qtgui_time_sink_x_1_0, 0)) self.connect((self.blocks_moving_average_xx_0_0, 0), (self.rational_resampler_xxx_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_keep_one_in_n_0_0, 0)) self.connect((self.hilbert_fc_0_0, 0), (self.blocks_complex_to_mag_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_time_sink_x_0_0_0, 0)) self.connect((self.low_pass_filter_1_0, 0), (self.analog_wfm_rcv_0_0, 0)) self.connect((self.low_pass_filter_1_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.low_pass_filter_1_0, 0), (self.qtgui_time_sink_x_2_0, 0)) self.connect((self.low_pass_filter_1_0, 0), (self.qtgui_waterfall_sink_x_0_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_1_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.qtgui_freq_sink_x_1_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.qtgui_time_sink_x_0_0_0, 1)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.qtgui_time_sink_x_0_1, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="DVBT Scanner") ################################################## # Variables ################################################## self.threshold = threshold = -60 self.signal_level = signal_level = 0 self.samp_rate = samp_rate = 2048000 self.freq = freq = 525200000 self.fft_size = fft_size = 1024 self.detected = detected = 0 ################################################## # Blocks ################################################## _threshold_sizer = wx.BoxSizer(wx.VERTICAL) self._threshold_text_box = forms.text_box( parent=self.GetWin(), sizer=_threshold_sizer, value=self.threshold, callback=self.set_threshold, label="Threshold", converter=forms.float_converter(), proportion=0, ) self._threshold_slider = forms.slider( parent=self.GetWin(), sizer=_threshold_sizer, value=self.threshold, callback=self.set_threshold, minimum=-100, maximum=0, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_threshold_sizer, 2, 0, 1, 1) self.probe_signal_lvl = blocks.probe_signal_f() self.notebook = self.notebook = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "Spektrum") self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "Output") self.GridAdd(self.notebook, 0, 0, 1, 1) _freq_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, label="Frequency", converter=forms.float_converter(), proportion=0, ) self._freq_slider = forms.slider( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, minimum=478000000, maximum=862000000, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_freq_sizer, 1, 0, 1, 1) self.wxgui_numbersink2_1 = numbersink2.number_sink_f( self.notebook.GetPage(1).GetWin(), unit="Signal present", minval=0, maxval=1, factor=1.0, decimal_places=0, ref_level=0, sample_rate=samp_rate, number_rate=15, average=False, avg_alpha=None, label="Signal Detection", peak_hold=False, show_gauge=True, ) self.notebook.GetPage(1).Add(self.wxgui_numbersink2_1.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.notebook.GetPage(1).GetWin(), unit="dB", minval=-120, maxval=0, factor=1.0, decimal_places=1, ref_level=0, sample_rate=samp_rate, number_rate=15, average=False, avg_alpha=0.03, label="Level", peak_hold=False, show_gauge=True, ) self.notebook.GetPage(1).Add(self.wxgui_numbersink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.notebook.GetPage(0).GetWin(), baseband_freq=freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=fft_size, fft_rate=15, average=True, avg_alpha=0.03, title="FFT Plot", peak_hold=False, win=window.flattop, ) self.notebook.GetPage(0).Add(self.wxgui_fftsink2_0.win) def _signal_level_probe(): while True: val = self.probe_signal_lvl.level() try: self.set_signal_level(val) except AttributeError: pass time.sleep(1.0 / (5)) _signal_level_thread = threading.Thread(target=_signal_level_probe) _signal_level_thread.daemon = True _signal_level_thread.start() self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "hackrf=0") self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(14, 0) self.rtlsdr_source_0.set_if_gain(24, 0) self.rtlsdr_source_0.set_bb_gain(12, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.probe_detected = blocks.probe_signal_f() self.fft_vxx_0 = fft.fft_vcc(fft_size, True, (window.rectangular(fft_size)), True, 1) def _detected_probe(): while True: val = self.probe_detected.level() try: self.set_detected(val) except AttributeError: pass time.sleep(1.0 / (5)) _detected_thread = threading.Thread(target=_detected_probe) _detected_thread.daemon = True _detected_thread.start() self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_float * 1, fft_size) self.blocks_threshold_ff_0 = blocks.threshold_ff( threshold, threshold, threshold) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, fft_size) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( 1000, 0.001, 4000) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared( fft_size) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 1048580) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.probe_signal_lvl, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.probe_detected, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.wxgui_numbersink2_1, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0, 0))
def __init__(self): gr.top_block.__init__(self, "Receiver NC-OFDM") ################################################## # Variables ################################################## self.shseq_len = shseq_len = 40 self.pn_symbols = pn_symbols = (1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1) self.lgseq_len = lgseq_len = 320 self.fft_len = fft_len = 64 self.dataseq_len = dataseq_len = 64 self.shseq_rep = shseq_rep = 8 self.shseq = shseq = pn_symbols[0:shseq_len] self.samp_rate = samp_rate = 1000000 self.pilot_symbols = pilot_symbols = ((1, 1, 1, -1,),) self.pilot_carriers = pilot_carriers = ((-21, -7, 7, 21,),) self.packet_len = packet_len = 3*len(range(-26, -21)+ range(-20,-7) + range(8, 21) + range(22, 27),) self.occupied_carriers = occupied_carriers = (range(-26, -21)+ range(-20,-7) + range(8, 21) + range(22, 27),) self.lgseq = lgseq = pn_symbols[shseq_len:shseq_len+lgseq_len] self.length_tag_name = length_tag_name = "packet_len" self.fileprefix = fileprefix = "/root/" self.data_len = data_len = dataseq_len*20 self.cp_len = cp_len = fft_len/4 self.cen_freq = cen_freq = 1500000000 self.ShThreshold = ShThreshold = 10 self.ShRepThreshold = ShRepThreshold = 3.5 self.LgThreshold = LgThreshold = 60 ################################################## # Blocks ################################################## self.uhd_usrp_source = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source.set_samp_rate(samp_rate) self.uhd_usrp_source.set_center_freq(cen_freq, 0) self.uhd_usrp_source.set_gain(10, 0) self.null_sink_shortpncorr_out = blocks.null_sink(gr.sizeof_gr_complex*1) self.null_sink_longpncorrv2_out = blocks.null_sink(gr.sizeof_gr_complex*1) self.null_sink_longpncorrv2_flag = blocks.null_sink(gr.sizeof_int*1) self.null_sink_longpncorrv2_corr = blocks.null_sink(gr.sizeof_gr_complex*1) self.ncofdm_ShortPNdetector = ncofdm.ShortPNdetector(fft_len, cp_len, shseq_rep, shseq_len, 1) self.ncofdm_ShortPNcorr = ncofdm.ShortPNcorr(fft_len, cp_len, shseq_rep, shseq_len, (shseq)) self.ncofdm_LongPNcorrV2 = ncofdm.LongPNcorrV2(fft_len, cp_len, lgseq_len, (lgseq), 60, shseq_len*shseq_rep+lgseq_len+data_len+10) self.ncofdm_FreqOffCalc = ncofdm.FreqOffCalc(fft_len, fft_len/4, shseq_len, shseq_rep) self.file_sink_short = blocks.file_sink(gr.sizeof_gr_complex*1, fileprefix+"short.dat", False) self.file_sink_short.set_unbuffered(False) self.file_sink_rxshth = blocks.file_sink(gr.sizeof_float*1, fileprefix+"rxshth.dat", False) self.file_sink_rxshth.set_unbuffered(False) self.file_sink_org = blocks.file_sink(gr.sizeof_gr_complex*1, fileprefix+"org.dat", False) self.file_sink_org.set_unbuffered(False) self.file_sink_long = blocks.file_sink(gr.sizeof_gr_complex*1, fileprefix+"long.dat", False) self.file_sink_long.set_unbuffered(False) self.file_sink_lgth = blocks.file_sink(gr.sizeof_float*1, fileprefix+"lgth.dat", False) self.file_sink_lgth.set_unbuffered(False) self.file_sink_gain = blocks.file_sink(gr.sizeof_float*1, fileprefix+"gain.dat", False) self.file_sink_gain.set_unbuffered(False) self.file_sink_freqoff = blocks.file_sink(gr.sizeof_float*1, fileprefix+"freqoff.dat", False) self.file_sink_freqoff.set_unbuffered(False) self.file_sink_corr = blocks.file_sink(gr.sizeof_int*1, fileprefix+"corr.dat", False) self.file_sink_corr.set_unbuffered(False) self.blocks_threshold_ff = blocks.threshold_ff(ShRepThreshold, ShRepThreshold, 0) self.blocks_moving_average = blocks.moving_average_ff(100, 0.01, 4000) self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex*1, 10000) self.blocks_float_to_int = blocks.float_to_int(1, 1) self.blocks_float_to_complex_lgpn_input = blocks.float_to_complex(1) self.blocks_delay_shpn_lgpn = blocks.delay(gr.sizeof_float*1, 2) self.blocks_delay_shpn_freqoff = blocks.delay(gr.sizeof_int*1, 1) self.blocks_delay_freqoff_lgpn = blocks.delay(gr.sizeof_float*1, 2) self.blocks_complex_to_real_lgth = blocks.complex_to_real(1) self.blocks_complex_to_mag_org = blocks.complex_to_mag(1) self.blocks_complex_to_mag = blocks.complex_to_mag(1) self.analog_agc = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc.set_max_gain(50000.0) ################################################## # Connections ################################################## self.connect((self.analog_agc, 0), (self.blocks_complex_to_mag_org, 0)) self.connect((self.analog_agc, 1), (self.file_sink_gain, 0)) self.connect((self.analog_agc, 0), (self.file_sink_org, 0)) self.connect((self.analog_agc, 0), (self.ncofdm_LongPNcorrV2, 0)) self.connect((self.analog_agc, 0), (self.ncofdm_ShortPNcorr, 0)) self.connect((self.blocks_complex_to_mag, 0), (self.ncofdm_ShortPNdetector, 0)) self.connect((self.blocks_complex_to_mag_org, 0), (self.blocks_moving_average, 0)) self.connect((self.blocks_complex_to_real_lgth, 0), (self.file_sink_lgth, 0)) self.connect((self.blocks_delay_freqoff_lgpn, 0), (self.blocks_float_to_complex_lgpn_input, 0)) self.connect((self.blocks_delay_freqoff_lgpn, 0), (self.file_sink_freqoff, 0)) self.connect((self.blocks_delay_shpn_freqoff, 0), (self.ncofdm_FreqOffCalc, 1)) self.connect((self.blocks_delay_shpn_lgpn, 0), (self.blocks_float_to_complex_lgpn_input, 1)) self.connect((self.blocks_float_to_complex_lgpn_input, 0), (self.ncofdm_LongPNcorrV2, 1)) self.connect((self.blocks_float_to_int, 0), (self.blocks_delay_shpn_freqoff, 0)) self.connect((self.blocks_head_0, 0), (self.analog_agc, 0)) self.connect((self.blocks_moving_average, 0), (self.ncofdm_LongPNcorrV2, 2)) self.connect((self.blocks_threshold_ff, 0), (self.blocks_delay_shpn_lgpn, 0)) self.connect((self.blocks_threshold_ff, 0), (self.blocks_float_to_int, 0)) self.connect((self.ncofdm_FreqOffCalc, 0), (self.blocks_delay_freqoff_lgpn, 0)) self.connect((self.ncofdm_LongPNcorrV2, 0), (self.blocks_complex_to_real_lgth, 0)) self.connect((self.ncofdm_LongPNcorrV2, 2), (self.file_sink_corr, 0)) self.connect((self.ncofdm_LongPNcorrV2, 1), (self.file_sink_long, 0)) self.connect((self.ncofdm_LongPNcorrV2, 1), (self.null_sink_longpncorrv2_corr, 0)) self.connect((self.ncofdm_LongPNcorrV2, 2), (self.null_sink_longpncorrv2_flag, 0)) self.connect((self.ncofdm_LongPNcorrV2, 0), (self.null_sink_longpncorrv2_out, 0)) self.connect((self.ncofdm_ShortPNcorr, 1), (self.blocks_complex_to_mag, 0)) self.connect((self.ncofdm_ShortPNcorr, 1), (self.file_sink_short, 0)) self.connect((self.ncofdm_ShortPNcorr, 1), (self.ncofdm_FreqOffCalc, 0)) self.connect((self.ncofdm_ShortPNcorr, 0), (self.null_sink_shortpncorr_out, 0)) self.connect((self.ncofdm_ShortPNdetector, 0), (self.blocks_threshold_ff, 0)) self.connect((self.ncofdm_ShortPNdetector, 1), (self.file_sink_rxshth, 0)) self.connect((self.uhd_usrp_source, 0), (self.blocks_head_0, 0))
def __init__(self): gr.top_block.__init__(self, "Lab8") Qt.QWidget.__init__(self) self.setWindowTitle("Lab8") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "lab8") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.std_dev = std_dev = 0.05 self.samp_rate = samp_rate = 32000 self.p_xy = p_xy = 0 self.npts = npts = 8192 self.mimo_option = mimo_option = 0 self.lw = lw = 0.5 self.const_qam = const_qam = digital.constellation_calcdist( digital.qam_16()[0], digital.qam_16()[1], 2, 1).base() self.const_psk = const_psk = digital.constellation_calcdist( digital.psk_4()[0], digital.psk_4()[1], 2, 1).base() ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, 'Transmitted') self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, 'Received') self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, 'Histogram') self.top_grid_layout.addWidget(self.tab, 1, 0, 8, 7) for r in range(1, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 7): self.top_grid_layout.setColumnStretch(c, 1) self._std_dev_range = Range(0, 1, 0.001, 0.05, 200) self._std_dev_win = RangeWidget(self._std_dev_range, self.set_std_dev, 'Noise Std. Dev', "counter_slider", float) self.top_grid_layout.addWidget(self._std_dev_win, 0, 0, 1, 3) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 3): self.top_grid_layout.setColumnStretch(c, 1) self._p_xy_range = Range(0, 0.99, 0.001, 0, 200) self._p_xy_win = RangeWidget(self._p_xy_range, self.set_p_xy, 'Correlation Pxy', "counter_slider", float) self.top_grid_layout.addWidget(self._p_xy_win, 0, 3, 1, 3) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 6): self.top_grid_layout.setColumnStretch(c, 1) # Create the options list self._mimo_option_options = ( 0, 1, ) # Create the labels list self._mimo_option_labels = ( 'Alamouti', 'MIMO', ) # Create the combo box # Create the radio buttons self._mimo_option_group_box = Qt.QGroupBox('MIMO Option' + ": ") self._mimo_option_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._mimo_option_button_group = variable_chooser_button_group() self._mimo_option_group_box.setLayout(self._mimo_option_box) for i, _label in enumerate(self._mimo_option_labels): radio_button = Qt.QRadioButton(_label) self._mimo_option_box.addWidget(radio_button) self._mimo_option_button_group.addButton(radio_button, i) self._mimo_option_callback = lambda i: Qt.QMetaObject.invokeMethod( self._mimo_option_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._mimo_option_options.index(i))) self._mimo_option_callback(self.mimo_option) self._mimo_option_button_group.buttonClicked[int].connect( lambda i: self.set_mimo_option(self._mimo_option_options[i])) self.top_grid_layout.addWidget(self._mimo_option_group_box, 0, 6, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 4096, #size 1, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(0, 20) self.qtgui_time_sink_x_0.set_y_label('Eigenvalue Ratio (dB)', "") self.qtgui_time_sink_x_0.enable_tags(True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(True) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 9, 0, 2, 8) for r in range(9, 11): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f( npts, 200, -2, 2, "Histogram", 1) self.qtgui_histogram_sink_x_0.set_update_time(0.10) self.qtgui_histogram_sink_x_0.enable_autoscale(True) self.qtgui_histogram_sink_x_0.enable_accumulate(False) self.qtgui_histogram_sink_x_0.enable_grid(True) self.qtgui_histogram_sink_x_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [3, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_histogram_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_histogram_sink_x_0.set_line_label(i, labels[i]) self.qtgui_histogram_sink_x_0.set_line_width(i, widths[i]) self.qtgui_histogram_sink_x_0.set_line_color(i, colors[i]) self.qtgui_histogram_sink_x_0.set_line_style(i, styles[i]) self.qtgui_histogram_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_histogram_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_histogram_sink_x_0_win = sip.wrapinstance( self.qtgui_histogram_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_2.addWidget(self._qtgui_histogram_sink_x_0_win) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size "De-Correlated Constellation", #name 2 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-1.5, 1.5) self.qtgui_const_sink_x_1.set_x_axis(-1.5, 1.5) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(False) self.qtgui_const_sink_x_1.enable_grid(True) self.qtgui_const_sink_x_1.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 2, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, -1, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 0.2, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(2): if len(labels[i]) == 0: self.qtgui_const_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_win = sip.wrapinstance( self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget) self.tab_layout_1.addWidget(self._qtgui_const_sink_x_1_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "Correlated Constellation", #name 2 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-4, 4) self.qtgui_const_sink_x_0.set_x_axis(-4, 4) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(True) self.qtgui_const_sink_x_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 2, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, -1, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 0.2, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(2): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_0.addWidget(self._qtgui_const_sink_x_0_win) self.ofdm_alamouti_cc_0 = ofdm.alamouti_cc(p_xy, std_dev, mimo_option) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( const_psk.points(), 1) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( 4096, 1 / 4096, 4096, 1) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_deinterleave_0 = blocks.deinterleave( gr.sizeof_float * 1, 1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_random_source_x_0 = blocks.vector_source_b( list(map(int, numpy.random.randint(0, 4, 1000))), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_histogram_sink_x_0, 0)) self.connect((self.blocks_deinterleave_0, 1), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_deinterleave_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.ofdm_alamouti_cc_0, 0)) self.connect((self.ofdm_alamouti_cc_0, 1), (self.blocks_complex_to_real_0, 0)) self.connect((self.ofdm_alamouti_cc_0, 2), (self.blocks_deinterleave_0, 0)) self.connect((self.ofdm_alamouti_cc_0, 0), (self.qtgui_const_sink_x_0, 1)) self.connect((self.ofdm_alamouti_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.ofdm_alamouti_cc_0, 1), (self.qtgui_const_sink_x_1, 0)) self.connect((self.ofdm_alamouti_cc_0, 1), (self.qtgui_const_sink_x_1, 1))
def __init__(self): gr.top_block.__init__(self, "APRS S-Gate") Qt.QWidget.__init__(self) self.setWindowTitle("APRS S-Gate") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "aprs_satgate") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.freq = freq = 145.825e6 self.variable_qtgui_label_0 = variable_qtgui_label_0 = int(freq) self.samp_rate = samp_rate = 2.4e6 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(4, 48000, 1200, 0.35, 16*48000/1200) self.rfgain = rfgain = 35 self.audio_mute = audio_mute = True self.afgain = afgain = -7 ################################################## # Blocks ################################################## self._rfgain_range = Range(0, 49, 1, 35, 200) self._rfgain_win = RangeWidget(self._rfgain_range, self.set_rfgain, 'RF Gain (dB)', "counter_slider", float) self.top_grid_layout.addWidget(self._rfgain_win, 3,0,1,1) self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_formatter = None else: self._variable_qtgui_label_0_formatter = lambda x: x self._variable_qtgui_label_0_tool_bar.addWidget(Qt.QLabel('Freq (Hz)'+": ")) self._variable_qtgui_label_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_formatter(self.variable_qtgui_label_0))) self._variable_qtgui_label_0_tool_bar.addWidget(self._variable_qtgui_label_0_label) self.top_grid_layout.addWidget(self._variable_qtgui_label_0_tool_bar, 4,0,1,1) self.show_text_2 = display.show_text() self._show_text_2_win = sip.wrapinstance(self.show_text_2.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._show_text_2_win, 2,2,2,1) self.show_text_0 = display.show_text() self._show_text_0_win = sip.wrapinstance(self.show_text_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._show_text_0_win, 2,0,1,2) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 192e3, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(False) if not False: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [6, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-105, -20) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 0,2,1,1) self.qtgui_time_sink_x_2 = qtgui.time_sink_f( 2048, #size 1200, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_2.set_update_time(0.10) self.qtgui_time_sink_x_2.set_y_axis(-4, 4) self.qtgui_time_sink_x_2.set_y_label('Amplitude', "") self.qtgui_time_sink_x_2.enable_tags(-1, True) self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_2.enable_autoscale(False) self.qtgui_time_sink_x_2.enable_grid(True) self.qtgui_time_sink_x_2.enable_axis_labels(False) self.qtgui_time_sink_x_2.enable_control_panel(False) if not False: self.qtgui_time_sink_x_2.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [2, 2, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "blue", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [0.7, 0.7, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_2.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_2_win = sip.wrapinstance(self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_2_win, 1,0,1,3) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 144.39e6, #fc 192e3, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-120, -10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_axis_labels(False) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["red", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [0.8, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0,0,1,2) self.igate_aprs_pkt_gen_0 = igate.aprs_pkt_gen(120, 'YD1SDL-10', 'APGRC', 'WIDE2-2', 240, 3, '!0745.80S/11022.51E` Temporary / Experimental APRS I/S-Gate') self.igate_aprs_is_sink_0 = igate.aprs_is_sink('rotate.aprs.net', 14580, 'YD1SDL-10', 24505) self.igate_aprs_demod_0 = igate.aprs_demod(48000) self.gpredict_doppler_0 = gpredict.doppler(self.set_freq, "localhost", 4532, True) self.fft_filter_xxx_3 = filter.fft_filter_fff(1, (firdes.band_pass(0.5,48e3,1e3,2400,1e2,firdes.WIN_HAMMING)), 1) self.fft_filter_xxx_3.declare_sample_delay(0) self.fft_filter_xxx_2 = filter.fft_filter_fff(2, (firdes.band_pass(0.25,48e3,400,2500,500,firdes.WIN_BLACKMAN)), 1) self.fft_filter_xxx_2.declare_sample_delay(0) self.fft_filter_xxx_1 = filter.fft_filter_fff(1, (rrc_taps), 1) self.fft_filter_xxx_1.declare_sample_delay(0) self.fft_filter_xxx_0 = filter.fft_filter_ccc(1, (firdes.low_pass(1,48e3,1e3,1e2,firdes.WIN_BLACKMAN)), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_fff(48000 / 1200, 6.28 / 1000, (rrc_taps), 39, 20, 1.5, 1) self.blocks_wavfile_sink_0 = blocks.wavfile_sink('IO86-wav-dump.wav', 1, 24000, 16) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_rotator_cc_0 = blocks.rotator_cc(-1700 / 48e3 * 2 * math.pi) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, 10) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(int(10e3*math.pi), 1.0/(10e3*math.pi), 4000) self.blocks_float_to_complex_0_0 = blocks.float_to_complex(1) _audio_mute_check_box = Qt.QCheckBox('Audio Mute') self._audio_mute_choices = {True: True, False: False} self._audio_mute_choices_inv = dict((v,k) for k,v in self._audio_mute_choices.iteritems()) self._audio_mute_callback = lambda i: Qt.QMetaObject.invokeMethod(_audio_mute_check_box, "setChecked", Qt.Q_ARG("bool", self._audio_mute_choices_inv[i])) self._audio_mute_callback(self.audio_mute) _audio_mute_check_box.stateChanged.connect(lambda i: self.set_audio_mute(self._audio_mute_choices[bool(i)])) self.top_grid_layout.addWidget(_audio_mute_check_box, 4,1,1,1) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(48e3 / (2*math.pi*1200/8.0)) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-1, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) self.afsk_aprs2inet_1 = afsk.aprs2inet(12000, 4) self.afsk_afsk1200_0 = afsk.afsk1200(48000,4) self._afgain_range = Range(-20, -1, 0.1, -7, 200) self._afgain_win = RangeWidget(self._afgain_range, self.set_afgain, 'AF Gain (dB)', "counter_slider", float) self.top_grid_layout.addWidget(self._afgain_win, 3,1,1,1) self.RTL_APRS_RX_0 = RTL_APRS_RX( device_ppm=58, freq=freq, rf_gain=rfgain, samp_rate=samp_rate, ) ################################################## # Connections ################################################## self.msg_connect((self.igate_aprs_demod_0, 'out'), (self.igate_aprs_is_sink_0, 'in')) self.msg_connect((self.igate_aprs_pkt_gen_0, 'out'), (self.igate_aprs_is_sink_0, 'in')) self.connect((self.RTL_APRS_RX_0, 1), (self.fft_filter_xxx_2, 0)) self.connect((self.RTL_APRS_RX_0, 1), (self.fft_filter_xxx_3, 0)) self.connect((self.RTL_APRS_RX_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.RTL_APRS_RX_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.afsk_afsk1200_0, 0), (self.show_text_2, 0)) self.connect((self.afsk_aprs2inet_1, 0), (self.show_text_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_float_to_complex_0_0, 0), (self.blocks_rotator_cc_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_repeat_0, 0), (self.afsk_aprs2inet_1, 0)) self.connect((self.blocks_rotator_cc_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.fft_filter_xxx_1, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_time_sink_x_2, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.fft_filter_xxx_1, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.fft_filter_xxx_2, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.fft_filter_xxx_3, 0), (self.afsk_afsk1200_0, 0)) self.connect((self.fft_filter_xxx_3, 0), (self.blocks_float_to_complex_0_0, 0)) self.connect((self.fft_filter_xxx_3, 0), (self.igate_aprs_demod_0, 0))