Esempio n. 1
0
	def __init__(self):
		grc_wxgui.top_block_gui.__init__(self, title="Top Block")

		##################################################
		# Variables
		##################################################
		self.variable_chooser_0 = variable_chooser_0 = 1
		self.transition_width = transition_width = 10000
		self.sym_per_sec = sym_per_sec = 2032
		self.samp_rate = samp_rate = 2000000
		self.rf_gain = rf_gain = 10
		self.cutoff_freq = cutoff_freq = 10000

		##################################################
		# Blocks
		##################################################
		_transition_width_sizer = wx.BoxSizer(wx.VERTICAL)
		self._transition_width_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_transition_width_sizer,
			value=self.transition_width,
			callback=self.set_transition_width,
			label='transition_width',
			converter=forms.float_converter(),
			proportion=0,
		)
		self._transition_width_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_transition_width_sizer,
			value=self.transition_width,
			callback=self.set_transition_width,
			minimum=100,
			maximum=100000,
			num_steps=1000,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Add(_transition_width_sizer)
		_rf_gain_sizer = wx.BoxSizer(wx.VERTICAL)
		self._rf_gain_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_rf_gain_sizer,
			value=self.rf_gain,
			callback=self.set_rf_gain,
			label='rf_gain',
			converter=forms.int_converter(),
			proportion=0,
		)
		self._rf_gain_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_rf_gain_sizer,
			value=self.rf_gain,
			callback=self.set_rf_gain,
			minimum=0,
			maximum=47,
			num_steps=47,
			style=wx.SL_HORIZONTAL,
			cast=int,
			proportion=1,
		)
		self.Add(_rf_gain_sizer)
		_cutoff_freq_sizer = wx.BoxSizer(wx.VERTICAL)
		self._cutoff_freq_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_cutoff_freq_sizer,
			value=self.cutoff_freq,
			callback=self.set_cutoff_freq,
			label='cutoff_freq',
			converter=forms.int_converter(),
			proportion=0,
		)
		self._cutoff_freq_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_cutoff_freq_sizer,
			value=self.cutoff_freq,
			callback=self.set_cutoff_freq,
			minimum=100,
			maximum=100000,
			num_steps=1000,
			style=wx.SL_HORIZONTAL,
			cast=int,
			proportion=1,
		)
		self.Add(_cutoff_freq_sizer)
		self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
			self.GetWin(),
			title="Scope Plot",
			sample_rate=samp_rate,
			v_scale=0,
			v_offset=0,
			t_scale=0,
			ac_couple=False,
			xy_mode=False,
			num_inputs=1,
			trig_mode=gr.gr_TRIG_MODE_AUTO,
			y_axis_label="Counts",
		)
		self.Add(self.wxgui_scopesink2_0.win)
		self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
			self.GetWin(),
			baseband_freq=0,
			y_per_div=10,
			y_divs=10,
			ref_level=0,
			ref_scale=2.0,
			sample_rate=samp_rate,
			fft_size=1024,
			fft_rate=15,
			average=False,
			avg_alpha=None,
			title="FFT Plot",
			peak_hold=False,
		)
		self.Add(self.wxgui_fftsink2_0.win)
		self._variable_chooser_0_chooser = forms.drop_down(
			parent=self.GetWin(),
			value=self.variable_chooser_0,
			callback=self.set_variable_chooser_0,
			label='variable_chooser_0',
			choices=[1, 2, 3],
			labels=["a", "b", "c"],
		)
		self.Add(self._variable_chooser_0_chooser)
		self.osmosdr_sink_c_0 = osmosdr.sink_c( args="numchan=" + str(1) + " " + "" )
		self.osmosdr_sink_c_0.set_sample_rate(samp_rate)
		self.osmosdr_sink_c_0.set_center_freq(27.14e6, 0)
		self.osmosdr_sink_c_0.set_freq_corr(0, 0)
		self.osmosdr_sink_c_0.set_gain(10, 0)
		self.osmosdr_sink_c_0.set_if_gain(rf_gain, 0)
		self.osmosdr_sink_c_0.set_bb_gain(20, 0)
		self.osmosdr_sink_c_0.set_antenna("", 0)
		self.osmosdr_sink_c_0.set_bandwidth(0, 0)
		  
		self.low_pass_filter_0 = gr.interp_fir_filter_fff(1, firdes.low_pass(
			1, samp_rate, cutoff_freq, transition_width, firdes.WIN_BLACKMAN, 6.76))
		self.const_source_x_0 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0)
		self.blocks_vector_source_x_0 = blocks.vector_source_f([1,1,1,0,  1,1,1,0,  1,1,1,0,  1,1,1,0,  1,0, 1,0, 1,0, 1,0, 1,0, 1,0, 1,0, 1,0, 1,0, 1,0], True, 1, [])
		self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate)
		self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, samp_rate/sym_per_sec)
		self.blocks_float_to_complex_0 = blocks.float_to_complex(1)

		##################################################
		# Connections
		##################################################
		self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_repeat_0, 0))
		self.connect((self.blocks_repeat_0, 0), (self.blocks_throttle_0, 0))
		self.connect((self.blocks_throttle_0, 0), (self.wxgui_scopesink2_0, 0))
		self.connect((self.blocks_throttle_0, 0), (self.low_pass_filter_0, 0))
		self.connect((self.const_source_x_0, 0), (self.blocks_float_to_complex_0, 1))
		self.connect((self.low_pass_filter_0, 0), (self.blocks_float_to_complex_0, 0))
		self.connect((self.blocks_float_to_complex_0, 0), (self.osmosdr_sink_c_0, 0))
		self.connect((self.blocks_float_to_complex_0, 0), (self.wxgui_fftsink2_0, 0))
Esempio n. 2
0
    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.Ind_s = Ind_s = 0
        self.Am_s = Am_s = 1.25893
        self.samp_rate = samp_rate = 512000
        self.Ind = Ind = Ind_s
        self.Am_sig = Am_sig = Am_s

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	self.GetWin(),
        	title='Scope Plot',
        	sample_rate=samp_rate,
        	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.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((Am_sig, ))
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((1, ))
        self.blks2_selector_0 = grc_blks2.selector(
        	item_size=gr.sizeof_float*1,
        	num_inputs=2,
        	num_outputs=1,
        	input_index=Ind,
        	output_index=0,
        )
        self.analog_sig_source_x_0_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 30000, 1, 0)
        self.analog_noise_source_x_0 = analog.noise_source_f(analog.GR_GAUSSIAN, 1, 0)
        self._Ind_s_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.Ind_s,
        	callback=self.set_Ind_s,
        	label='Ind_s',
        	choices=[0, 1],
        	labels=[],
        )
        self.Add(self._Ind_s_chooser)
        _Am_s_sizer = wx.BoxSizer(wx.VERTICAL)
        self._Am_s_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_Am_s_sizer,
        	value=self.Am_s,
        	callback=self.set_Am_s,
        	label='Am_s',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._Am_s_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_Am_s_sizer,
        	value=self.Am_s,
        	callback=self.set_Am_s,
        	minimum=0,
        	maximum=50,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_Am_s_sizer)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blks2_selector_0, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_add_xx_0, 0), (self.blks2_selector_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blks2_selector_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
Esempio n. 3
0
    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.sr = sr = 3.5e6
        self.tw = tw = 10000
        self.samp_rate = samp_rate = sr
        self.rl = rl = -20
        self.gain = gain = 1
        self.co = co = 100000
        self.cf = cf = 100.3e6
        self.bw = bw = 2e6

        ##################################################
        # Blocks
        ##################################################
        self._gain_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.gain,
            callback=self.set_gain,
            label='gain',
            choices=[0.2, 0.4, 0.6, 0.8, 1, 1.5, 2, 2.5, 3, 3.5],
            labels=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
        )
        self.Add(self._gain_chooser)
        _cf_sizer = wx.BoxSizer(wx.VERTICAL)
        self._cf_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_cf_sizer,
            value=self.cf,
            callback=self.set_cf,
            label='cf',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._cf_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_cf_sizer,
            value=self.cf,
            callback=self.set_cf,
            minimum=88.5e6,
            maximum=108.5e6,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_cf_sizer)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=cf,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='Sample_Bandpass',
            peak_hold=False,
            win=window.hamming,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=441,
            decimation=2500,
            taps=None,
            fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            int(samp_rate / 250000),
            firdes.low_pass(4, samp_rate, co, tw, firdes.WIN_HAMMING, 6.76))
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink(
            'sample.wav', 1, 44100, 8)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((gain, ))
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=250000,
            audio_decimation=1,
        )
        self.analog_agc_xx_0 = analog.agc_ff(1e-4, 1.0, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)
        self.TekRSA_iq_stream_0_0 = TekRSA.iq_stream(cf, rl, bw, 1000000, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.TekRSA_iq_stream_0_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.TekRSA_iq_stream_0_0, 0),
                     (self.wxgui_fftsink2_0, 0))
        self.connect((self.analog_agc_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_wavfile_sink_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_agc_xx_0, 0))
    def __init__(self, filename="tx-test.32fc"):
        grc_wxgui.top_block_gui.__init__(self, title="SWiFi TX")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Parameters
        ##################################################
        self.filename = filename

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 20e6
        self.mult = mult = 1
        self.lo_offset = lo_offset = 0
        self.gain = gain = 25
        self.freq = freq = 2.462e9
        self.encoding = encoding = 3

        ##################################################
        # Blocks
        ##################################################
        _mult_sizer = wx.BoxSizer(wx.VERTICAL)
        self._mult_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_mult_sizer,
            value=self.mult,
            callback=self.set_mult,
            label='mult',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._mult_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_mult_sizer,
            value=self.mult,
            callback=self.set_mult,
            minimum=0,
            maximum=2,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_mult_sizer)
        self.swifi_wifi_conv_encoder_0 = swifi.wifi_conv_encoder("phy")
        self.swifi_scrambler_0_0 = swifi.scrambler(True, "phy")
        self.swifi_sample_adder_0 = swifi.sample_adder(100, 11, 320)
        self.swifi_phy_frame_generator_0 = swifi.phy_frame_generator(
            "phy", "packet_len")
        self.swifi_mac_frame_generator_0 = swifi.mac_frame_generator(
            "phy", 11, 100)
        self.swifi_interleaver_0_0 = swifi.interleaver(True, "phy")
        self.swifi_chunks_to_symbols_0_0 = swifi.chunks_to_symbols("phy")
        self.swifi_bit_stealer_0_0 = swifi.bit_stealer("phy")
        self.swifi_bit_packer_0_0 = swifi.bit_packer("phy", 1)
        self._samp_rate_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.samp_rate,
            callback=self.set_samp_rate,
            label="Sample Rate",
            choices=[10e6, 20e6],
            labels=["10 Mhz", "20 Mhz"],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._samp_rate_chooser)
        self._lo_offset_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.lo_offset,
            callback=self.set_lo_offset,
            label="LO Offset",
            choices=[0, 6e9, 11e9],
            labels=['0 MHz', '6 MHz', '11 MHz'],
        )
        self.Add(self._lo_offset_chooser)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            label='gain',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_gain_sizer)
        self._freq_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.freq,
            callback=self.set_freq,
            label="Channel",
            choices=[
                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, 5260000000.0, 5280000000.0,
                5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0,
                5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0,
                5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0,
                5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0,
                5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0,
                5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0,
                5920000000.0
            ],
            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',
                ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a',
                ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a',
                '100 | 5500.0 | 11a', '104 | 5520.0 | 11a',
                '108 | 5540.0 | 11a', '112 | 5560.0 | 11a',
                '116 | 5580.0 | 11a', '120 | 5600.0 | 11a',
                '124 | 5620.0 | 11a', '128 | 5640.0 | 11a',
                '132 | 5660.0 | 11a', '136 | 5680.0 | 11a',
                '140 | 5700.0 | 11a', '149 | 5745.0 | 11a',
                '153 | 5765.0 | 11a', '157 | 5785.0 | 11a',
                '161 | 5805.0 | 11a', '165 | 5825.0 | 11a',
                '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'
            ],
        )
        self.Add(self._freq_chooser)
        self.fft_vxx_0_0 = fft.fft_vcc(64, False, (tuple([1.0 / 64] * 64)),
                                       True, 1)
        self._encoding_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.encoding,
            callback=self.set_encoding,
            label="Encoding",
            choices=[0, 1, 2, 3, 4, 5, 6, 7],
            labels=[
                "BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2",
                "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"
            ],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._encoding_chooser)
        self.digital_ofdm_cyclic_prefixer_0_0 = digital.ofdm_cyclic_prefixer(
            64, 64 + 16, 2, "")
        (self.digital_ofdm_cyclic_prefixer_0_0).set_min_output_buffer(100000)
        self.digital_ofdm_carrier_allocator_cvc_0_0_0 = digital.ofdm_carrier_allocator_cvc(
            64, (range(-26, -21) + range(-20, -7) + range(-6, 0) +
                 range(1, 7) + range(8, 21) + range(22, 27), ),
            ((-21, -7, 7, 21), ),
            ((1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1),
             (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1),
             (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1),
             (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1),
             (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1),
             (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1),
             (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1),
             (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1),
             (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1),
             (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1),
             (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1),
             (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1),
             (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1),
             (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1),
             (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1),
             (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1),
             (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1),
             (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1),
             (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1),
             (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1),
             (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1),
             (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1),
             (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1),
             (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1),
             (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1),
             (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1),
             (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1),
             (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1),
             (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1),
             (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1),
             (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1),
             (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1,
                                                                 1)),
            ((0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
              (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0,
              (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0,
              (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0,
              (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0,
              (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0,
              (1.4719601443879746 +
               1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
              (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0,
              (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0,
              (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0,
              (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0,
              (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0,
              (1.4719601443879746 +
               1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
             (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
              (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0,
              (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0,
              (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0,
              (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0,
              (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0,
              (1.4719601443879746 +
               1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
              (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0,
              (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0,
              (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0,
              (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0,
              (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0,
              (1.4719601443879746 +
               1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
             (0, 0j, 0, 0j, 0, 0j, -1, 1j, -1, 1j, -1, 1j, -1, -1j, 1, 1j, 1,
              -1j, -1, 1j, 1, 1j, 1, 1j, 1, 1j, -1,
              (-0 - 1j), 1, -1j, -1, 1j, 0, -1j, 1,
              (-0 - 1j), 1, -1j, 1, 1j, -1, -1j, 1, (-0 - 1j), -1, 1j, 1, 1j,
              1, 1j, 1, 1j, -1, -1j, 1, 1j, 1, -1j, -1, 0j, 0, 0j, 0, 0j),
             (0, 0, 0, 0, 0, 0, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1,
              1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 0, 1, -1, -1, 1, 1, -1,
              1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1,
              1, 1, 0, 0, 0, 0, 0)), "packet_len")
        (self.digital_ofdm_carrier_allocator_cvc_0_0_0
         ).set_min_output_buffer(10000)
        self.blocks_vector_source_x_1 = blocks.vector_source_b([
            ord(x) for x in tuple(
                "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
            )
        ], False, 1, [])
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            1, gr.GR_LSB_FIRST)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((mult, ))
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1,
                                                   filename, False)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.swifi_sample_adder_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.swifi_scrambler_0_0, 0))
        self.connect((self.blocks_vector_source_x_1, 0),
                     (self.swifi_mac_frame_generator_0, 0))
        self.connect((self.digital_ofdm_carrier_allocator_cvc_0_0_0, 0),
                     (self.fft_vxx_0_0, 0))
        self.connect((self.digital_ofdm_cyclic_prefixer_0_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.fft_vxx_0_0, 0),
                     (self.digital_ofdm_cyclic_prefixer_0_0, 0))
        self.connect((self.swifi_bit_packer_0_0, 0),
                     (self.swifi_chunks_to_symbols_0_0, 0))
        self.connect((self.swifi_bit_stealer_0_0, 0),
                     (self.swifi_interleaver_0_0, 0))
        self.connect((self.swifi_chunks_to_symbols_0_0, 0),
                     (self.digital_ofdm_carrier_allocator_cvc_0_0_0, 0))
        self.connect((self.swifi_interleaver_0_0, 0),
                     (self.swifi_bit_packer_0_0, 0))
        self.connect((self.swifi_mac_frame_generator_0, 0),
                     (self.swifi_phy_frame_generator_0, 0))
        self.connect((self.swifi_phy_frame_generator_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.swifi_sample_adder_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.swifi_scrambler_0_0, 0),
                     (self.swifi_wifi_conv_encoder_0, 0))
        self.connect((self.swifi_wifi_conv_encoder_0, 0),
                     (self.swifi_bit_stealer_0_0, 0))
Esempio n. 5
0
	def __init__(self, ahw="default", freq=150.0e6, ppm=0.0, vol=1.0, ftune=0.0, xftune=0.0, srate=1.0e6, upclo=0.0, devinfo="rtl=0", agc=0, arate=48.0e3, upce=0, mthresh=-10.0, offs=50.e3, flist="", dfifo="multimode_fifo", mbw=2.0e3, deemph=75.0e-6, dmode="NFM1"):
		grc_wxgui.top_block_gui.__init__(self, title="Multimode Radio Receiver")
		_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
		self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

		##################################################
		# Parameters
		##################################################
		self.ahw = ahw
		self.freq = freq
		self.ppm = ppm
		self.vol = vol
		self.ftune = ftune
		self.xftune = xftune
		self.srate = srate
		self.upclo = upclo
		self.devinfo = devinfo
		self.agc = agc
		self.arate = arate
		self.upce = upce
		self.mthresh = mthresh
		self.offs = offs
		self.flist = flist
		self.dfifo = dfifo
		self.mbw = mbw
		self.deemph = deemph
		self.dmode = dmode

		##################################################
		# Variables
		##################################################
		self.sc_list_str = sc_list_str = flist
		self.zoom = zoom = 1
		self.thresh = thresh = mthresh
		self.scan_rate = scan_rate = 15
		self.scan_power = scan_power = 0
		self.sc_low = sc_low = 150e6
		self.sc_listm = sc_listm = False
		self.sc_list = sc_list = eval("["+sc_list_str+"]")
		self.sc_incr = sc_incr = 12.5e3
		self.sc_high = sc_high = 300e6
		self.sc_ena = sc_ena = False
		self.samp_rate = samp_rate = int(mh.get_good_rate(devinfo,srate))
		self.rf_power = rf_power = 0
		self.ifreq = ifreq = freq
		self.zoomed_lp = zoomed_lp = (samp_rate/2.1)/zoom
		self.wbfm = wbfm = 200e3
		self.rf_d_power = rf_d_power = 0
		self.mode = mode = dmode
		self.logpower = logpower = math.log10(rf_power+1.0e-14)*10.0
		self.cur_freq = cur_freq = mh.scan_freq_out(sc_ena,sc_low,sc_high,freq,ifreq,scan_power+1.0e-14,thresh,sc_incr,scan_rate,sc_listm,sc_list)
		self.bw = bw = mbw
		self.audio_int_rate = audio_int_rate = 40e3
		self.zoom_taps = zoom_taps = firdes.low_pass(1.0,samp_rate,zoomed_lp,zoomed_lp/3,firdes.WIN_HAMMING,6.76)
		self.xfine = xfine = xftune
		self.volume = volume = vol
		self.variable_static_text_1 = variable_static_text_1 = cur_freq
		self.variable_static_text_0_0 = variable_static_text_0_0 = samp_rate
		self.variable_static_text_0 = variable_static_text_0 = float(int(math.log10(rf_d_power+1.0e-14)*100.0)/10.0)
		self.upc_offset = upc_offset = upclo
		self.upc = upc = upce
		self.ssbo = ssbo = -bw/2 if mode == "LSB" else 0.0
		self.sc_list_len = sc_list_len = len(sc_list)
		self.rfgain = rfgain = 25
		self.record_file = record_file = "recording.wav"
		self.record = record = False
		self.offset = offset = offs
		self.muted = muted = 0.0 if logpower >= thresh else 1
		self.main_taps = main_taps = firdes.low_pass(1.0,wbfm,mh.get_mode_deviation(mode,bw)*1.05,mh.get_mode_deviation(mode,bw)/2.0,firdes.WIN_HAMMING,6.76)
		self.k = k = wbfm/(2*math.pi*mh.get_mode_deviation(mode,bw))
		self.iagc = iagc = agc
		self.freq_update = freq_update = 0
		self.fine = fine = ftune
		self.digi_rate = digi_rate = 50e3
		self.aratio = aratio = int(wbfm/audio_int_rate)

		##################################################
		# Blocks
		##################################################
		self.rf_probe = gr.probe_avg_mag_sqrd_c(0, 0.015)
		self.Main = self.Main = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
		self.Main.AddPage(grc_wxgui.Panel(self.Main), "Main Controls")
		self.Main.AddPage(grc_wxgui.Panel(self.Main), "Scan/Upconv Controls")
		self.Add(self.Main)
		self._zoom_chooser = forms.drop_down(
			parent=self.Main.GetPage(0).GetWin(),
			value=self.zoom,
			callback=self.set_zoom,
			label="Spectral Zoom Ratio",
			choices=[1, 2, 5, 10, 20, 50, 100],
			labels=[],
		)
		self.Main.GetPage(0).GridAdd(self._zoom_chooser, 1, 4, 1, 1)
		_xfine_sizer = wx.BoxSizer(wx.VERTICAL)
		self._xfine_text_box = forms.text_box(
			parent=self.Main.GetPage(0).GetWin(),
			sizer=_xfine_sizer,
			value=self.xfine,
			callback=self.set_xfine,
			label="Extra Fine Tuning",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._xfine_slider = forms.slider(
			parent=self.Main.GetPage(0).GetWin(),
			sizer=_xfine_sizer,
			value=self.xfine,
			callback=self.set_xfine,
			minimum=-1.0e3,
			maximum=1.0e3,
			num_steps=200,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Main.GetPage(0).GridAdd(_xfine_sizer, 0, 3, 1, 1)
		_volume_sizer = wx.BoxSizer(wx.VERTICAL)
		self._volume_text_box = forms.text_box(
			parent=self.Main.GetPage(0).GetWin(),
			sizer=_volume_sizer,
			value=self.volume,
			callback=self.set_volume,
			label="Volume",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._volume_slider = forms.slider(
			parent=self.Main.GetPage(0).GetWin(),
			sizer=_volume_sizer,
			value=self.volume,
			callback=self.set_volume,
			minimum=1.0,
			maximum=10.0,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Main.GetPage(0).GridAdd(_volume_sizer, 0, 0, 1, 1)
		self._upc_offset_text_box = forms.text_box(
			parent=self.Main.GetPage(1).GetWin(),
			value=self.upc_offset,
			callback=self.set_upc_offset,
			label="Upconv. LO Freq",
			converter=forms.float_converter(),
		)
		self.Main.GetPage(1).GridAdd(self._upc_offset_text_box, 3, 2, 1, 2)
		self._upc_check_box = forms.check_box(
			parent=self.Main.GetPage(1).GetWin(),
			value=self.upc,
			callback=self.set_upc,
			label="Ext. Upconv.",
			true=1,
			false=0,
		)
		self.Main.GetPage(1).GridAdd(self._upc_check_box, 3, 0, 1, 1)
		_rfgain_sizer = wx.BoxSizer(wx.VERTICAL)
		self._rfgain_text_box = forms.text_box(
			parent=self.Main.GetPage(0).GetWin(),
			sizer=_rfgain_sizer,
			value=self.rfgain,
			callback=self.set_rfgain,
			label="RF Gain",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._rfgain_slider = forms.slider(
			parent=self.Main.GetPage(0).GetWin(),
			sizer=_rfgain_sizer,
			value=self.rfgain,
			callback=self.set_rfgain,
			minimum=0,
			maximum=50,
			num_steps=200,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Main.GetPage(0).GridAdd(_rfgain_sizer, 2, 1, 1, 1)
		self._record_file_text_box = forms.text_box(
			parent=self.Main.GetPage(0).GetWin(),
			value=self.record_file,
			callback=self.set_record_file,
			label="Recording Filename",
			converter=forms.str_converter(),
		)
		self.Main.GetPage(0).GridAdd(self._record_file_text_box, 2, 3, 1, 3)
		self._record_check_box = forms.check_box(
			parent=self.Main.GetPage(0).GetWin(),
			value=self.record,
			callback=self.set_record,
			label="Record",
			true=True,
			false=False,
		)
		self.Main.GetPage(0).GridAdd(self._record_check_box, 2, 2, 1, 1)
		_offset_sizer = wx.BoxSizer(wx.VERTICAL)
		self._offset_text_box = forms.text_box(
			parent=self.Main.GetPage(0).GetWin(),
			sizer=_offset_sizer,
			value=self.offset,
			callback=self.set_offset,
			label="LO Offset",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._offset_slider = forms.slider(
			parent=self.Main.GetPage(0).GetWin(),
			sizer=_offset_sizer,
			value=self.offset,
			callback=self.set_offset,
			minimum=25e3,
			maximum=500e3,
			num_steps=200,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Main.GetPage(0).GridAdd(_offset_sizer, 1, 3, 1, 1)
		self._mode_chooser = forms.drop_down(
			parent=self.Main.GetPage(0).GetWin(),
			value=self.mode,
			callback=self.set_mode,
			label="Mode",
			choices=mh.get_modes_values(),
			labels=mh.get_modes_names(),
		)
		self.Main.GetPage(0).GridAdd(self._mode_chooser, 0, 4, 1, 1)
		self._iagc_check_box = forms.check_box(
			parent=self.Main.GetPage(0).GetWin(),
			value=self.iagc,
			callback=self.set_iagc,
			label="AGC",
			true=1,
			false=0,
		)
		self.Main.GetPage(0).GridAdd(self._iagc_check_box, 2, 0, 1, 1)
		def _freq_update_probe():
			while True:
				val = self.rf_probe.level()
				try: self.set_freq_update(val)
				except AttributeError, e: pass
				time.sleep(1.0/(1.0/(2.5)))
		_freq_update_thread = threading.Thread(target=_freq_update_probe)
		_freq_update_thread.daemon = True
		_freq_update_thread.start()
		_fine_sizer = wx.BoxSizer(wx.VERTICAL)
		self._fine_text_box = forms.text_box(
			parent=self.Main.GetPage(0).GetWin(),
			sizer=_fine_sizer,
			value=self.fine,
			callback=self.set_fine,
			label="Fine Tuning",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._fine_slider = forms.slider(
			parent=self.Main.GetPage(0).GetWin(),
			sizer=_fine_sizer,
			value=self.fine,
			callback=self.set_fine,
			minimum=-35e3,
			maximum=35e3,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Main.GetPage(0).GridAdd(_fine_sizer, 0, 2, 1, 1)
		self.display_probe = gr.probe_avg_mag_sqrd_c(0, 0.002)
		_bw_sizer = wx.BoxSizer(wx.VERTICAL)
		self._bw_text_box = forms.text_box(
			parent=self.Main.GetPage(0).GetWin(),
			sizer=_bw_sizer,
			value=self.bw,
			callback=self.set_bw,
			label="AM/SSB Bandwidth",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._bw_slider = forms.slider(
			parent=self.Main.GetPage(0).GetWin(),
			sizer=_bw_sizer,
			value=self.bw,
			callback=self.set_bw,
			minimum=1.0e3,
			maximum=audio_int_rate/2,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Main.GetPage(0).GridAdd(_bw_sizer, 1, 2, 1, 1)
		self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
			self.Main.GetPage(0).GetWin(),
			baseband_freq=mh.get_last_returned(freq_update),
			dynamic_range=40,
			ref_level=0,
			ref_scale=2.0,
			sample_rate=samp_rate/zoom,
			fft_size=1024,
			fft_rate=4,
			average=True,
			avg_alpha=None,
			title="Spectrogram",
			win=window.hamming,
		)
		self.Main.GetPage(0).Add(self.wxgui_waterfallsink2_0.win)
		def wxgui_waterfallsink2_0_callback(x, y):
			self.set_freq(x)
		
		self.wxgui_waterfallsink2_0.set_callback(wxgui_waterfallsink2_0_callback)
		self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
			self.Main.GetPage(0).GetWin(),
			baseband_freq=mh.get_last_returned(freq_update),
			y_per_div=10,
			y_divs=10,
			ref_level=0,
			ref_scale=2.0,
			sample_rate=samp_rate/zoom,
			fft_size=1024,
			fft_rate=4,
			average=True,
			avg_alpha=0.1,
			title="Panorama",
			peak_hold=False,
			win=window.hamming,
		)
		self.Main.GetPage(0).Add(self.wxgui_fftsink2_0.win)
		def wxgui_fftsink2_0_callback(x, y):
			self.set_freq(x)
		
		self.wxgui_fftsink2_0.set_callback(wxgui_fftsink2_0_callback)
		self._variable_static_text_1_static_text = forms.static_text(
			parent=self.Main.GetPage(1).GetWin(),
			value=self.variable_static_text_1,
			callback=self.set_variable_static_text_1,
			label="Current Scan Freq",
			converter=forms.float_converter(),
		)
		self.Main.GetPage(1).GridAdd(self._variable_static_text_1_static_text, 0, 5, 1, 2)
		self._variable_static_text_0_0_static_text = forms.static_text(
			parent=self.Main.GetPage(0).GetWin(),
			value=self.variable_static_text_0_0,
			callback=self.set_variable_static_text_0_0,
			label="Actual srate",
			converter=forms.float_converter(),
		)
		self.Main.GetPage(0).GridAdd(self._variable_static_text_0_0_static_text, 1, 5, 1, 1)
		self._variable_static_text_0_static_text = forms.static_text(
			parent=self.Main.GetPage(0).GetWin(),
			value=self.variable_static_text_0,
			callback=self.set_variable_static_text_0,
			label="RF Level",
			converter=forms.float_converter(),
		)
		self.Main.GetPage(0).GridAdd(self._variable_static_text_0_static_text, 1, 0, 1, 1)
		_thresh_sizer = wx.BoxSizer(wx.VERTICAL)
		self._thresh_text_box = forms.text_box(
			parent=self.Main.GetPage(0).GetWin(),
			sizer=_thresh_sizer,
			value=self.thresh,
			callback=self.set_thresh,
			label="Mute Threshold",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._thresh_slider = forms.slider(
			parent=self.Main.GetPage(0).GetWin(),
			sizer=_thresh_sizer,
			value=self.thresh,
			callback=self.set_thresh,
			minimum=-50,
			maximum=10,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Main.GetPage(0).GridAdd(_thresh_sizer, 1, 1, 1, 1)
		def _scan_power_probe():
			while True:
				val = self.rf_probe.level()
				try: self.set_scan_power(val)
				except AttributeError, e: pass
				time.sleep(1.0/(scan_rate))
		_scan_power_thread = threading.Thread(target=_scan_power_probe)
		_scan_power_thread.daemon = True
		_scan_power_thread.start()
		self._sc_low_text_box = forms.text_box(
			parent=self.Main.GetPage(1).GetWin(),
			value=self.sc_low,
			callback=self.set_sc_low,
			label="Scan Low",
			converter=forms.float_converter(),
		)
		self.Main.GetPage(1).GridAdd(self._sc_low_text_box, 0, 1, 1, 1)
		self._sc_listm_check_box = forms.check_box(
			parent=self.Main.GetPage(1).GetWin(),
			value=self.sc_listm,
			callback=self.set_sc_listm,
			label="Scan List Mode",
			true=True,
			false=False,
		)
		self.Main.GetPage(1).GridAdd(self._sc_listm_check_box, 2, 0, 1, 1)
		self._sc_list_str_text_box = forms.text_box(
			parent=self.Main.GetPage(1).GetWin(),
			value=self.sc_list_str,
			callback=self.set_sc_list_str,
			label="Scan List",
			converter=forms.str_converter(),
		)
		self.Main.GetPage(1).GridAdd(self._sc_list_str_text_box, 2, 1, 1, 5)
		self._sc_incr_chooser = forms.drop_down(
			parent=self.Main.GetPage(1).GetWin(),
			value=self.sc_incr,
			callback=self.set_sc_incr,
			label="Scan Increment (Hz)",
			choices=[5.0e3,6.25e3,10.0e3,12.5e3,15e3,25e3],
			labels=[],
		)
		self.Main.GetPage(1).GridAdd(self._sc_incr_chooser, 0, 0, 1, 1)
		self._sc_high_text_box = forms.text_box(
			parent=self.Main.GetPage(1).GetWin(),
			value=self.sc_high,
			callback=self.set_sc_high,
			label="Scan High",
			converter=forms.float_converter(),
		)
		self.Main.GetPage(1).GridAdd(self._sc_high_text_box, 0, 2, 1, 1)
		self._sc_ena_check_box = forms.check_box(
			parent=self.Main.GetPage(1).GetWin(),
			value=self.sc_ena,
			callback=self.set_sc_ena,
			label="Scan Enable",
			true=True,
			false=False,
		)
		self.Main.GetPage(1).GridAdd(self._sc_ena_check_box, 0, 3, 1, 1)
		def _rf_power_probe():
			while True:
				val = self.rf_probe.level()
				try: self.set_rf_power(val)
				except AttributeError, e: pass
				time.sleep(1.0/(10))
		_rf_power_thread = threading.Thread(target=_rf_power_probe)
		_rf_power_thread.daemon = True
		_rf_power_thread.start()
		def _rf_d_power_probe():
			while True:
				val = self.display_probe.level()
				try: self.set_rf_d_power(val)
				except AttributeError, e: pass
				time.sleep(1.0/(5))
		_rf_d_power_thread = threading.Thread(target=_rf_d_power_probe)
		_rf_d_power_thread.daemon = True
		_rf_d_power_thread.start()
		self.osmosdr_source_c_0 = osmosdr.source_c( args="nchan=" + str(1) + " " + devinfo )
		self.osmosdr_source_c_0.set_sample_rate(samp_rate)
		self.osmosdr_source_c_0.set_center_freq(cur_freq+offset+(upc_offset*float(upc)), 0)
		self.osmosdr_source_c_0.set_freq_corr(ppm, 0)
		self.osmosdr_source_c_0.set_gain_mode(iagc, 0)
		self.osmosdr_source_c_0.set_gain(25 if iagc == 1 else rfgain, 0)
		self.osmosdr_source_c_0.set_if_gain(20, 0)
			
		self._ifreq_text_box = forms.text_box(
			parent=self.Main.GetPage(0).GetWin(),
			value=self.ifreq,
			callback=self.set_ifreq,
			label="Frequency",
			converter=forms.float_converter(),
		)
		self.Main.GetPage(0).GridAdd(self._ifreq_text_box, 0, 1, 1, 1)
		self.gr_wavfile_sink_0 = gr.wavfile_sink("/dev/null" if record == False else record_file, 1, int(audio_int_rate), 8)
		self.gr_quadrature_demod_cf_0 = gr.quadrature_demod_cf(k)
		self.gr_multiply_const_vxx_2 = gr.multiply_const_vff((1.0 if mh.get_mode_type(mode) == "FM" else 0.0, ))
		self.gr_multiply_const_vxx_1 = gr.multiply_const_vff((0.0 if muted else volume/4.5, ))
		self.gr_multiply_const_vxx_0_0_0 = gr.multiply_const_vff((0.85 if mh.get_mode_type(mode) == "AM" else 0.0, ))
		self.gr_multiply_const_vxx_0_0 = gr.multiply_const_vff((0.85 if mh.get_mode_type(mode) == "SSB" else 0.0, ))
		self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc(((1.0/math.sqrt(mh.get_mode_deviation(mode,bw))*250), ))
		self.gr_keep_one_in_n_1 = gr.keep_one_in_n(gr.sizeof_gr_complex*1, aratio)
		self.gr_keep_one_in_n_0_0 = gr.keep_one_in_n(gr.sizeof_gr_complex*1, zoom)
		self.gr_keep_one_in_n_0 = gr.keep_one_in_n(gr.sizeof_gr_complex*1, int(wbfm/digi_rate))
		self.gr_freq_xlating_fir_filter_xxx_0_1 = gr.freq_xlating_fir_filter_ccc(1, (1.0, ), (offset+fine+xfine)/(samp_rate/1.0e6), samp_rate)
		self.gr_fractional_interpolator_xx_0 = gr.fractional_interpolator_ff(0, audio_int_rate/arate)
		self.gr_file_sink_0 = gr.file_sink(gr.sizeof_gr_complex*1, "/dev/null" if mh.get_mode_type(mode) != "DIG" else dfifo)
		self.gr_file_sink_0.set_unbuffered(True)
		self.gr_fft_filter_xxx_3 = gr.fft_filter_ccc(1, (zoom_taps), 1)
		self.gr_fft_filter_xxx_2_0 = gr.fft_filter_fff(5, (firdes.low_pass(1.0,wbfm,14.5e3,8.5e3,firdes.WIN_HAMMING,6.76)), 1)
		self.gr_fft_filter_xxx_2 = gr.fft_filter_ccc(1, (main_taps), 1)
		self.gr_fft_filter_xxx_0 = gr.fft_filter_ccc(int(samp_rate/wbfm), (firdes.low_pass(1.0,samp_rate,98.5e3,66e3,firdes.WIN_HAMMING,6.76)), 1)
		self.gr_feedforward_agc_cc_0 = gr.feedforward_agc_cc(1024, 0.75)
		self.gr_complex_to_real_0 = gr.complex_to_real(1)
		self.gr_complex_to_mag_squared_0 = gr.complex_to_mag_squared(1)
		self.gr_add_xx_0 = gr.add_vff(1)
		self.blks2_fm_deemph_0 = blks2.fm_deemph(fs=audio_int_rate, tau=deemph)
		self.audio_sink_0 = audio.sink(int(arate), ahw, True)

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.gr_add_xx_0, 1))
		self.connect((self.gr_fractional_interpolator_xx_0, 0), (self.gr_multiply_const_vxx_1, 0))
		self.connect((self.gr_multiply_const_vxx_1, 0), (self.audio_sink_0, 0))
		self.connect((self.gr_multiply_const_vxx_1, 0), (self.audio_sink_0, 1))
		self.connect((self.gr_feedforward_agc_cc_0, 0), (self.gr_complex_to_mag_squared_0, 0))
		self.connect((self.osmosdr_source_c_0, 0), (self.gr_freq_xlating_fir_filter_xxx_0_1, 0))
		self.connect((self.gr_multiply_const_vxx_0_0_0, 0), (self.gr_add_xx_0, 2))
		self.connect((self.gr_feedforward_agc_cc_0, 0), (self.gr_complex_to_real_0, 0))
		self.connect((self.gr_complex_to_real_0, 0), (self.gr_multiply_const_vxx_0_0, 0))
		self.connect((self.gr_multiply_const_vxx_2, 0), (self.gr_add_xx_0, 0))
		self.connect((self.gr_complex_to_mag_squared_0, 0), (self.gr_multiply_const_vxx_0_0_0, 0))
		self.connect((self.gr_multiply_const_vxx_0, 0), (self.display_probe, 0))
		self.connect((self.gr_multiply_const_vxx_0, 0), (self.rf_probe, 0))
		self.connect((self.gr_add_xx_0, 0), (self.gr_fractional_interpolator_xx_0, 0))
		self.connect((self.gr_add_xx_0, 0), (self.gr_wavfile_sink_0, 0))
		self.connect((self.gr_freq_xlating_fir_filter_xxx_0_1, 0), (self.gr_fft_filter_xxx_0, 0))
		self.connect((self.gr_keep_one_in_n_0, 0), (self.gr_file_sink_0, 0))
		self.connect((self.gr_freq_xlating_fir_filter_xxx_0_1, 0), (self.gr_fft_filter_xxx_3, 0))
		self.connect((self.gr_fft_filter_xxx_3, 0), (self.gr_keep_one_in_n_0_0, 0))
		self.connect((self.gr_keep_one_in_n_0_0, 0), (self.wxgui_fftsink2_0, 0))
		self.connect((self.gr_keep_one_in_n_0_0, 0), (self.wxgui_waterfallsink2_0, 0))
		self.connect((self.blks2_fm_deemph_0, 0), (self.gr_multiply_const_vxx_2, 0))
		self.connect((self.gr_quadrature_demod_cf_0, 0), (self.gr_fft_filter_xxx_2_0, 0))
		self.connect((self.gr_fft_filter_xxx_2, 0), (self.gr_keep_one_in_n_0, 0))
		self.connect((self.gr_fft_filter_xxx_2, 0), (self.gr_multiply_const_vxx_0, 0))
		self.connect((self.gr_fft_filter_xxx_0, 0), (self.gr_fft_filter_xxx_2, 0))
		self.connect((self.gr_keep_one_in_n_1, 0), (self.gr_feedforward_agc_cc_0, 0))
		self.connect((self.gr_fft_filter_xxx_2, 0), (self.gr_keep_one_in_n_1, 0))
		self.connect((self.gr_fft_filter_xxx_2, 0), (self.gr_quadrature_demod_cf_0, 0))
		self.connect((self.gr_fft_filter_xxx_2_0, 0), (self.blks2_fm_deemph_0, 0))
Esempio n. 6
0
    def __init__(self, parent):
        """
		Create a new control panel.
		
		Args:
		    parent: the wx parent window
		"""
        self.parent = parent
        wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER)
        parent[SHOW_CONTROL_PANEL_KEY] = True
        parent.subscribe(SHOW_CONTROL_PANEL_KEY, self.Show)
        control_box = wx.BoxSizer(wx.VERTICAL)
        control_box.AddStretchSpacer()
        options_box = forms.static_box_sizer(
            parent=self,
            sizer=control_box,
            label='Options',
            bold=True,
            orient=wx.VERTICAL,
        )
        #average
        #forms.check_box(
        #	sizer=options_box, parent=self, label='Average',
        #	ps=parent, key=AVERAGE_KEY,
        #)
        #avg_alpha_text = forms.static_text(
        #	sizer=options_box, parent=self, label='Avg Alpha',
        #	converter=forms.float_converter(lambda x: '%.4f'%x),
        #	ps=parent, key=AVG_ALPHA_KEY, width=50,
        #)
        #avg_alpha_slider = forms.log_slider(
        #	sizer=options_box, parent=self,
        #	min_exp=AVG_ALPHA_MIN_EXP,
        #	max_exp=AVG_ALPHA_MAX_EXP,
        #	num_steps=SLIDER_STEPS,
        #	ps=parent, key=AVG_ALPHA_KEY,
        #)
        #for widget in (avg_alpha_text, avg_alpha_slider):
        #	parent.subscribe(AVERAGE_KEY, widget.Enable)
        #	widget.Enable(parent[AVERAGE_KEY])
        #begin axes box
        control_box.AddStretchSpacer()
        axes_box = forms.static_box_sizer(
            parent=self,
            sizer=control_box,
            label='Axes Options',
            bold=True,
            orient=wx.VERTICAL,
        )
        #num lines buttons
        #forms.incr_decr_buttons(
        #	parent=self, sizer=axes_box, label='Time Scale',
        #	on_incr=self._on_incr_time_scale, on_decr=self._on_decr_time_scale,
        #)
        #dyanmic range buttons
        forms.incr_decr_buttons(
            parent=self,
            sizer=axes_box,
            label='Dyn Range',
            on_incr=self._on_incr_dynamic_range,
            on_decr=self._on_decr_dynamic_range,
        )
        #ref lvl buttons
        forms.incr_decr_buttons(
            parent=self,
            sizer=axes_box,
            label='Ref Level',
            on_incr=self._on_incr_ref_level,
            on_decr=self._on_decr_ref_level,
        )
        #color mode
        forms.drop_down(
            parent=self,
            sizer=axes_box,
            width=100,
            ps=parent,
            key=COLOR_MODE_KEY,
            label='Color',
            choices=map(lambda x: x[1], COLOR_MODES),
            labels=map(lambda x: x[0], COLOR_MODES),
        )
        #autoscale
        forms.single_button(
            parent=self,
            sizer=axes_box,
            label='Autoscale',
            callback=self.parent.autoscale,
        )
        #clear
        control_box.AddStretchSpacer()
        forms.single_button(
            parent=self,
            sizer=control_box,
            label='Clear',
            callback=self._on_clear_button,
        )
        #run/stop
        forms.toggle_button(
            sizer=control_box,
            parent=self,
            true_label='Stop',
            false_label='Run',
            ps=parent,
            key=RUNNING_KEY,
        )
        #set sizer
        self.SetSizerAndFit(control_box)
Esempio n. 7
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Airband")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.base_freq = base_freq = 134225000
        self.volume = volume = 0.9
        self.squelch = squelch = -28
        self.samp_rate = samp_rate = 2400000
        self.freq_corr = freq_corr = 96
        self.freq = freq = base_freq

        ##################################################
        # Blocks
        ##################################################
        _volume_sizer = wx.BoxSizer(wx.VERTICAL)
        self._volume_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_volume_sizer,
            value=self.volume,
            callback=self.set_volume,
            label="Volume",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._volume_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_volume_sizer,
            value=self.volume,
            callback=self.set_volume,
            minimum=0,
            maximum=1,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_volume_sizer)
        _squelch_sizer = wx.BoxSizer(wx.VERTICAL)
        self._squelch_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_squelch_sizer,
            value=self.squelch,
            callback=self.set_squelch,
            label="Squelch",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._squelch_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_squelch_sizer,
            value=self.squelch,
            callback=self.set_squelch,
            minimum=-150,
            maximum=200,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_squelch_sizer)
        _freq_corr_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freq_corr_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_freq_corr_sizer,
            value=self.freq_corr,
            callback=self.set_freq_corr,
            label="Freq correction (ppm)",
            converter=forms.int_converter(),
            proportion=0,
        )
        self._freq_corr_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_freq_corr_sizer,
            value=self.freq_corr,
            callback=self.set_freq_corr,
            minimum=-127,
            maximum=127,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_freq_corr_sizer)
        self._freq_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.freq,
            callback=self.set_freq,
            label="Frequency select",
            choices=[
                121250000, 121500000, 122200000, 122700000, 123450000,
                124175000, 124500000, 124925000, 125450000, 130875000,
                132700000, 134225000, 134925000, 136050000, 136575000,
                136975000, 169000000
            ],
            labels=[
                'EPSC TWR', 'EP EMRG', 'EPSD Kwadrat', 'EPSD Port',
                'Air-To-Air', 'Mueritz EDWW Radar', 'EP Przelotowa',
                'B FIR Warszawa', 'EPWW Radar 2', 'EPWW Radar 3',
                'EPWW Radar 4', 'D FIR Warszawa', 'EPWW Radar',
                'Mark EDWW Radar', 'E FIR Warszawa', 'Air-ToAir 2',
                'Lotnicze Pogotowie Ratunkowe'
            ],
        )
        self.Add(self._freq_chooser)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=512,
            fft_rate=30,
            average=False,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        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(freq_corr, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(2, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(49.6, 0)
        self.rtlsdr_source_0.set_if_gain(1, 0)
        self.rtlsdr_source_0.set_bb_gain(1, 0)
        self.rtlsdr_source_0.set_antenna("RX", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)

        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            50, (firdes.low_pass_2(1, samp_rate, 25e3, 10e3, 40)), 0,
            samp_rate)
        self.blocks_probe_signal_x_0 = blocks.probe_signal_f()
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (volume, ))
        self.audio_sink_0 = audio.sink(48000, "hw:0,1", True)
        self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(
            squelch, 0.1, 0, False)
        self.analog_am_demod_cf_0 = analog.am_demod_cf(
            channel_rate=48000,
            audio_decim=1,
            audio_pass=5000,
            audio_stop=5500,
        )
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 0.1e-4, 1.0, 0)
        self.analog_agc2_xx_0.set_max_gain(5)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.analog_am_demod_cf_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.analog_agc2_xx_0, 0),
                     (self.analog_am_demod_cf_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_pwr_squelch_xx_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0, 0),
                     (self.analog_agc2_xx_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0, 0),
                     (self.wxgui_fftsink2_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_probe_signal_x_0, 0))
Esempio n. 8
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Wifi Rx Rftap")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.window_size = window_size = 48
        self.sync_length = sync_length = 320
        self.samp_rate = samp_rate = 20e6
        self.freq = freq = 2.437e9
        self.chan_est = chan_est = ieee802_11.LMS

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.samp_rate,
            callback=self.set_samp_rate,
            label="Sample Rate",
            choices=[1e6, 3e6, 5e6, 10e6, 15e6, 20e6],
            labels=["1 MHz", "3 MHz", "5 MHz", "10 MHz", "15 MHz", "20 MHz"],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._samp_rate_chooser)
        self._freq_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.freq,
            callback=self.set_freq,
            label="Channel",
            choices=[
                2.412e9, 2.417e9, 2.422e9, 2.427e9, 2.432e9, 2.437e9, 2.442e9,
                2.447e9, 2.452e9, 2.457e9, 2.462e9, 5.035e9, 5.040e9, 5.045e9,
                5.055e9, 5.060e9, 5.080e9, 5.170e9, 5.180e9, 5.190e9, 5.200e9,
                5.210e9, 5.220e9, 5.230e9, 5.240e9, 5.250e9, 5.260e9, 5.270e9,
                5.280e9, 5.290e9, 5.300e9, 5.310e9, 5.320e9, 5.500e9, 5.510e9,
                5.520e9, 5.530e9, 5.540e9, 5.550e9, 5.560e9, 5.570e9, 5.580e9,
                5.590e9, 5.600e9, 5.610e9, 5.620e9, 5.630e9, 5.640e9, 5.660e9,
                5.670e9, 5.680e9, 5.690e9, 5.700e9, 5.710e9, 5.720e9, 5.745e9,
                5.755e9, 5.765e9, 5.775e9, 5.785e9, 5.795e9, 5.805e9, 5.825e9
            ],
            labels=[
                "Ch 1 | 2412", "Ch 2 | 2417", "Ch 3 | 2422", "Ch 4 | 2427",
                "Ch 5 | 2432", "Ch 6 | 2437", "Ch 7 | 2442", "Ch 8 | 2447",
                "Ch 9 | 2452", "Ch 10 | 2457", "Ch 11 | 2462", "Ch 36 | 5180",
                "Ch 7 | 5035", "Ch 8 | 5040", "Ch 9 | 5045", "Ch 11 | 5055",
                "Ch 12 | 5060", "Ch 16 | 5080", "Ch 34 | 5170", "Ch 36 | 5180",
                "Ch 38 | 5190", "Ch 40 | 5200", "Ch 42 | 5210", "Ch 44 | 5220",
                "Ch 46 | 5230", "Ch 48 | 5240", "Ch 50 | 5250", "Ch 52 | 5260",
                "Ch 54 | 5270", "Ch 56 | 5280", "Ch 58 | 5290", "Ch 60 | 5300",
                "Ch 62 | 5310", "Ch 64 | 5320", "Ch 100 | 5500",
                "Ch 102 | 5510", "Ch 104 | 5520", "Ch 106 | 5530",
                "Ch 108 | 5540", "Ch 110 | 5550", "Ch 112 | 5560",
                "Ch 114 | 5570", "Ch 116 | 5580", "Ch 118 | 5590",
                "Ch 120 | 5600", "Ch 122 | 5610", "Ch 124 | 5620",
                "Ch 126 | 5630", "Ch 128 | 5640", "Ch 132 | 5660",
                "Ch 134 | 5670", "Ch 136 | 5680", "Ch 138 | 5690",
                "Ch 140 | 5700", "Ch 142 | 5710", "Ch 144 | 5720",
                "Ch 149 | 5745", "Ch 151 | 5755", "Ch 153 | 5765",
                "Ch 155 | 5775", "Ch 157 | 5785", "Ch 159 | 5795",
                "Ch 161 | 5805", "Ch 165 | 5825"
            ])
        self.Add(self._freq_chooser)
        self._chan_est_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.chan_est,
            callback=self.set_chan_est,
            label='chan_est',
            choices=[
                ieee802_11.LS, ieee802_11.LMS, ieee802_11.STA, ieee802_11.COMB
            ],
            labels=["LS", "LMS", "STA", "Linear Comb"],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._chan_est_chooser)
        self.rftap_rftap_encap_0 = rftap.rftap_encap(0, -1, "")
        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(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.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, False, False)
        self.ieee802_11_parse_mac_0 = ieee802_11.parse_mac(freq, True, False)
        self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_ff(
            window_size + 16)
        self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc(
            window_size)
        self.ieee802_11_frame_equalizer_0 = ieee802_11.frame_equalizer(
            chan_est, freq, samp_rate, False, False)
        self.ieee802_11_decode_mac_0 = ieee802_11.decode_mac(False, False)
        self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True,
                                     1)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 64)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1",
                                                     "52001", 10000, False)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        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.ieee802_11_parse_mac_0, 'in'))
        self.msg_connect((self.ieee802_11_decode_mac_0, 'out'),
                         (self.rftap_rftap_encap_0, 'in'))
        self.msg_connect((self.rftap_rftap_encap_0, 'out'),
                         (self.blocks_socket_pdu_0, '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.ieee802_11_moving_average_xx_1, 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_multiply_xx_0, 0),
                     (self.ieee802_11_moving_average_xx_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.ieee802_11_frame_equalizer_0, 0))
        self.connect((self.ieee802_11_frame_equalizer_0, 0),
                     (self.ieee802_11_decode_mac_0, 0))
        self.connect((self.ieee802_11_moving_average_xx_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.ieee802_11_moving_average_xx_0, 0),
                     (self.ieee802_11_sync_short_0, 1))
        self.connect((self.ieee802_11_moving_average_xx_1, 0),
                     (self.blocks_divide_xx_0, 1))
        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.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.blocks_delay_0_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.blocks_multiply_xx_0, 0))
Esempio n. 9
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Hackrfone Am Rx 8Msps")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 8e6
        self.ppm = ppm = 0
        self.freq = freq = 472e3
        self.fi = fi = 200e3
        self.RF_Gain = RF_Gain = 0
        self.FI_Gain = FI_Gain = 10
        self.FI_BWD = FI_BWD = 10e3
        self.BandWidth = BandWidth = 0
        self.BB_Gain = BB_Gain = 20
        self.Audio_Gain = Audio_Gain = 5

        ##################################################
        # Blocks
        ##################################################
        _ppm_sizer = wx.BoxSizer(wx.VERTICAL)
        self._ppm_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_ppm_sizer,
        	value=self.ppm,
        	callback=self.set_ppm,
        	label='Freq. Corr. [ppm]',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._ppm_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_ppm_sizer,
        	value=self.ppm,
        	callback=self.set_ppm,
        	minimum=-10,
        	maximum=10,
        	num_steps=200,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_ppm_sizer, 1, 1, 1, 1)
        self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "RF")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "FI")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "AF")
        self.Add(self.notebook_0)
        _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=400e3,
        	maximum=1.2e6,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_freq_sizer, 1, 0, 1, 1)
        self._RF_Gain_chooser = forms.button(
        	parent=self.GetWin(),
        	value=self.RF_Gain,
        	callback=self.set_RF_Gain,
        	label='RF Amp',
        	choices=[0, 8],
        	labels=['0 dB', '13 dB'],
        )
        self.GridAdd(self._RF_Gain_chooser, 0, 0, 1, 1)
        _FI_Gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._FI_Gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_FI_Gain_sizer,
        	value=self.FI_Gain,
        	callback=self.set_FI_Gain,
        	label='Rx FI Gain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._FI_Gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_FI_Gain_sizer,
        	value=self.FI_Gain,
        	callback=self.set_FI_Gain,
        	minimum=0,
        	maximum=47,
        	num_steps=47,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_FI_Gain_sizer, 0, 1, 1, 1)
        _FI_BWD_sizer = wx.BoxSizer(wx.VERTICAL)
        self._FI_BWD_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_FI_BWD_sizer,
        	value=self.FI_BWD,
        	callback=self.set_FI_BWD,
        	label='FI Bandwidth',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._FI_BWD_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_FI_BWD_sizer,
        	value=self.FI_BWD,
        	callback=self.set_FI_BWD,
        	minimum=500,
        	maximum=20e3,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_FI_BWD_sizer, 1, 3, 1, 1)
        self._BandWidth_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.BandWidth,
        	callback=self.set_BandWidth,
        	label='Bandwidth',
        	choices=[0, 1.75e6, 20e6],
        	labels=['Auto', '1.75 MHz', '20 MHz'],
        )
        self.GridAdd(self._BandWidth_chooser, 0, 3, 1, 1)
        _BB_Gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._BB_Gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_BB_Gain_sizer,
        	value=self.BB_Gain,
        	callback=self.set_BB_Gain,
        	label='Base Band Gain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._BB_Gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_BB_Gain_sizer,
        	value=self.BB_Gain,
        	callback=self.set_BB_Gain,
        	minimum=0,
        	maximum=62,
        	num_steps=31,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_BB_Gain_sizer, 0, 2, 1, 1)
        _Audio_Gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._Audio_Gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_Audio_Gain_sizer,
        	value=self.Audio_Gain,
        	callback=self.set_Audio_Gain,
        	label='Audio Gain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._Audio_Gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_Audio_Gain_sizer,
        	value=self.Audio_Gain,
        	callback=self.set_Audio_Gain,
        	minimum=0,
        	maximum=10,
        	num_steps=50,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_Audio_Gain_sizer, 1, 2, 1, 1)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
        	self.GetWin(),
        	unit='Unidades',
        	minval=0,
        	maxval=2,
        	factor=1.0,
        	decimal_places=2,
        	ref_level=0,
        	sample_rate=samp_rate,
        	number_rate=2,
        	average=False,
        	avg_alpha=0.5,
        	label='RMS de Entrada',
        	peak_hold=False,
        	show_gauge=True,
        )
        self.GridAdd(self.wxgui_numbersink2_0.win, 2, 0, 1, 4)
        self.wxgui_fftsink2_0_1 = fftsink2.fft_sink_c(
        	self.notebook_0.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=1024,
        	fft_rate=15,
        	average=True,
        	avg_alpha=0.5,
        	title='FFT Plot',
        	peak_hold=False,
        	size=(800,400),
        )
        self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0_1.win)
        self.wxgui_fftsink2_0_0_0_0 = fftsink2.fft_sink_f(
        	self.notebook_0.GetPage(2).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=32000,
        	fft_size=1024,
        	fft_rate=15,
        	average=True,
        	avg_alpha=0.2,
        	title='AF',
        	peak_hold=False,
        	size=(800,500),
        )
        self.notebook_0.GetPage(2).Add(self.wxgui_fftsink2_0_0_0_0.win)
        self.wxgui_fftsink2_0_0_0 = fftsink2.fft_sink_c(
        	self.notebook_0.GetPage(1).GetWin(),
        	baseband_freq=fi,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate/80,
        	fft_size=1024,
        	fft_rate=15,
        	average=True,
        	avg_alpha=0.2,
        	title='FI',
        	peak_hold=False,
        	size=(800,500),
        )
        self.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_0_0_0.win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=8,
                decimation=25,
                taps=None,
                fractional_bw=None,
        )
        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(freq+fi, 0)
        self.osmosdr_source_0.set_freq_corr(ppm, 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(True, 0)
        self.osmosdr_source_0.set_gain(RF_Gain, 0)
        self.osmosdr_source_0.set_if_gain(FI_Gain, 0)
        self.osmosdr_source_0.set_bb_gain(BB_Gain, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(BandWidth, 0)
          
        self.low_pass_filter_0 = filter.fir_filter_ccf(80, firdes.low_pass(
        	1, samp_rate, FI_BWD/2, samp_rate/2500, firdes.WIN_HAMMING, 6.76))
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(160, True)
        self.blocks_rms_xx_0 = blocks.rms_cf(0.0001)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((Audio_Gain, ))
        self.audio_sink_0 = audio.sink(32000, '', True)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, fi, 1, 0)
        self.analog_am_demod_cf_0 = analog.am_demod_cf(
        	channel_rate=samp_rate/80,
        	audio_decim=1,
        	audio_pass=5000,
        	audio_stop=7000,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_am_demod_cf_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.wxgui_fftsink2_0_1, 0))    
        self.connect((self.blocks_rms_xx_0, 0), (self.wxgui_numbersink2_0, 0))    
        self.connect((self.dc_blocker_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.dc_blocker_xx_0, 0), (self.wxgui_fftsink2_0_0_0_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.analog_am_demod_cf_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.wxgui_fftsink2_0_0_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.blocks_rms_xx_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.dc_blocker_xx_0, 0))    
Esempio n. 10
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="[FG]MRS Receiver")
        _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 = 1e6
        self.channel_width = channel_width = 25e3
        self.rf_freq_mhz = rf_freq_mhz = 462.5625
        self.decimation = decimation = int(samp_rate/channel_width)
        self.squelch = squelch = -20
        self.spec_size = spec_size = 480,256
        self.rf_freq = rf_freq = rf_freq_mhz*1.0e6
        self.decimated_rate = decimated_rate = samp_rate/decimation
        self.center_freq = center_freq = (int(rf_freq_mhz)+0.5)*1e6
        self.cctss_freq = cctss_freq = 0
        self.audio_rate = audio_rate = int(11025)

        ##################################################
        # Blocks
        ##################################################
        _squelch_sizer = wx.BoxSizer(wx.VERTICAL)
        self._squelch_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_squelch_sizer,
        	value=self.squelch,
        	callback=self.set_squelch,
        	label="Squelch (dBm)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._squelch_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_squelch_sizer,
        	value=self.squelch,
        	callback=self.set_squelch,
        	minimum=-50,
        	maximum=0,
        	num_steps=50,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_squelch_sizer, 3, 3, 1, 2)
        self._cctss_freq_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.cctss_freq,
        	callback=self.set_cctss_freq,
        	label="Privacy Code",
        	choices=[0,67.0,71.9,74.4,77.0,79.7,82.5,85.4,88.5,91.5,94.8,97.4,100.0,103.5,107.2,110.9,114.8,118.8,123.0,127.3,131.8,136.5,141.3,146.2,151.4,156.7,162.2,167.9,173.8,179.9,186.2,192.8,203.5,210.7,218.1,225.7,233.7,241.8,250.3],
        	labels=['0 (Monitor)',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],
        )
        self.GridAdd(self._cctss_freq_chooser, 3, 2, 1, 1)
        self.wxgui_waterfallsink2_1_0 = waterfallsink2.waterfall_sink_f(
        	self.GetWin(),
        	baseband_freq=0,
        	dynamic_range=40,
        	ref_level=-25,
        	ref_scale=2.0,
        	sample_rate=audio_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Raw Audio Spectrum",
        	size=(spec_size),
        )
        self.GridAdd(self.wxgui_waterfallsink2_1_0.win, 2, 4, 1, 3)
        self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_f(
        	self.GetWin(),
        	baseband_freq=0,
        	dynamic_range=40,
        	ref_level=-25,
        	ref_scale=2.0,
        	sample_rate=audio_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Squelched Audio Spectrum",
        	size=(spec_size),
        )
        self.GridAdd(self.wxgui_waterfallsink2_1.win, 2, 1, 1, 3)
        self.wxgui_waterfallsink2_0_0 = waterfallsink2.waterfall_sink_c(
        	self.GetWin(),
        	baseband_freq=center_freq,
        	dynamic_range=40,
        	ref_level=-25,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="RF Spectrum",
        	size=(spec_size),
        )
        self.GridAdd(self.wxgui_waterfallsink2_0_0.win, 1, 1, 1, 3)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	dynamic_range=40,
        	ref_level=-25,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Baseband Spectrum",
        	size=(spec_size),
        )
        self.GridAdd(self.wxgui_waterfallsink2_0.win, 1, 4, 1, 3)
        self._rf_freq_mhz_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.rf_freq_mhz,
        	callback=self.set_rf_freq_mhz,
        	label="Channel",
        	choices=[462.5625, 462.5875, 462.6125, 462.6375, 462.6625, 462.6875, 462.7125, 467.5625, 467.5875, 467.6125, 467.6375, 467.6625, 467.6875, 467.7125, 462.550, 462.575, 462.600, 462.625,462.650,462.675,462.700, 462.725],
        	labels=['FRS1 / GMRS 9',2,3,4,5,6,'FRS7 / GMRS15 ','FRS8',9,10,11,12,13,'FRS14','GMRS1',2,3,4,5,6,7,'GMRS8'],
        )
        self.GridAdd(self._rf_freq_mhz_chooser, 3, 1, 1, 1)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=int(audio_rate),
                decimation=int(decimated_rate),
                taps=None,
                fractional_bw=None,
        )
        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(center_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(True, 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.low_pass_filter_0 = filter.fir_filter_ccf(decimation, firdes.low_pass(
        	1, samp_rate, decimated_rate*0.8, decimated_rate*0.2, firdes.WIN_HAMMING, 6.76))
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(32, True)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.audio_sink_0 = audio.sink(audio_rate, "", True)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, rf_freq, 1, 0)
        self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_ff(squelch, 0.0001, 1, False)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=audio_rate,
        	quad_rate=audio_rate,
        	tau=75e-6,
        	max_dev=5e3,
        )
        self.analog_ctcss_squelch_ff_0 = analog.ctcss_squelch_ff(audio_rate, cctss_freq, 0.01, 0, 1, False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.analog_nbfm_rx_0, 0))
        self.connect((self.analog_nbfm_rx_0, 0), (self.wxgui_waterfallsink2_1_0, 0))
        self.connect((self.analog_nbfm_rx_0, 0), (self.analog_ctcss_squelch_ff_0, 0))
        self.connect((self.analog_ctcss_squelch_ff_0, 0), (self.analog_pwr_squelch_xx_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0, 0), (self.wxgui_waterfallsink2_1, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.wxgui_waterfallsink2_0_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.blocks_multiply_xx_0, 1))
Esempio n. 11
0
    def __init__(self, antenna="TX/RX", vor_freq_1=111e6, com_freq_1=135.275e6, vor_freq_2=111e6, rx_gain=30, gain=20):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Parameters
        ##################################################
        self.antenna = antenna
        self.vor_freq_1 = vor_freq_1
        self.com_freq_1 = com_freq_1
        self.vor_freq_2 = vor_freq_2
        self.rx_gain = rx_gain
        self.gain = gain

        ##################################################
        # Variables
        ##################################################
        self.obs_decimation = obs_decimation = 25
        self.ils_decimation = ils_decimation = 50
        self.am_sample_rate = am_sample_rate = 12.5e3
        self.vor_samp_rate = vor_samp_rate = 250e3
        self.vor_freq_entry_2 = vor_freq_entry_2 = vor_freq_2
        self.vor_freq_entry_1 = vor_freq_entry_1 = vor_freq_1
        self.vor_center_freq_0 = vor_center_freq_0 = (117.95e6-108.00e6)/2+117.95e6
        self.vor_center_freq = vor_center_freq = (117.95e6-108.00e6)/2+117.95e6
        self.squelch_slider = squelch_slider = -110
        self.rxgain = rxgain = 15
        self.phase_correction = phase_correction = 5
        self.obs_sample_rate = obs_sample_rate = am_sample_rate/obs_decimation
        self.ils_sample_rate = ils_sample_rate = am_sample_rate/ils_decimation
        self.gain_slider = gain_slider = gain
        self.com_freq_entry_1 = com_freq_entry_1 = com_freq_1
        self.band_center_freq = band_center_freq = (136.975e6-108.0e6)/2+108.0e6
        self.audio_select = audio_select = 0
        self.audio_sample_rate = audio_sample_rate = 48e3
        self.am_decimation = am_decimation = 1

        ##################################################
        # Blocks
        ##################################################
        self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "RF Analyzer")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Channel FFT")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Demod Audio FFT")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Ref and Phase Scope")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Manipulated Ref and Phase")
        self.Add(self.notebook_0)
        self._vor_freq_entry_1_text_box = forms.text_box(
        	parent=self.notebook_0.GetPage(0).GetWin(),
        	value=self.vor_freq_entry_1,
        	callback=self.set_vor_freq_entry_1,
        	label='vor_freq_entry_1',
        	converter=forms.float_converter(),
        )
        self.notebook_0.GetPage(0).Add(self._vor_freq_entry_1_text_box)
        _gain_slider_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_slider_text_box = forms.text_box(
        	parent=self.notebook_0.GetPage(0).GetWin(),
        	sizer=_gain_slider_sizer,
        	value=self.gain_slider,
        	callback=self.set_gain_slider,
        	label='gain_slider',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._gain_slider_slider = forms.slider(
        	parent=self.notebook_0.GetPage(0).GetWin(),
        	sizer=_gain_slider_sizer,
        	value=self.gain_slider,
        	callback=self.set_gain_slider,
        	minimum=0,
        	maximum=30,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.notebook_0.GetPage(0).Add(_gain_slider_sizer)
        self._com_freq_entry_1_text_box = forms.text_box(
        	parent=self.notebook_0.GetPage(0).GetWin(),
        	value=self.com_freq_entry_1,
        	callback=self.set_com_freq_entry_1,
        	label='com_freq_entry_1',
        	converter=forms.float_converter(),
        )
        self.notebook_0.GetPage(0).Add(self._com_freq_entry_1_text_box)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	self.notebook_0.GetPage(1).GetWin(),
        	title="Scope Plot",
        	sample_rate=10e3,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=2,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.notebook_0.GetPage(1).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
        	self.GetWin(),
        	unit="Units",
        	minval=-100,
        	maxval=100,
        	factor=1.0,
        	decimal_places=10,
        	ref_level=0,
        	sample_rate=10,
        	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.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.notebook_0.GetPage(0).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=12.5e3,
        	fft_size=1024,
        	fft_rate=5,
        	average=False,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        )
        self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0.win)
        self._vor_freq_entry_2_text_box = forms.text_box(
        	parent=self.notebook_0.GetPage(0).GetWin(),
        	value=self.vor_freq_entry_2,
        	callback=self.set_vor_freq_entry_2,
        	label='vor_freq_entry_2',
        	converter=forms.float_converter(),
        )
        self.notebook_0.GetPage(0).Add(self._vor_freq_entry_2_text_box)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	device_addr="",
        	stream_args=uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(2),
        	),
        )
        self.uhd_usrp_source_0.set_subdev_spec("A:0 A:0", 0)
        self.uhd_usrp_source_0.set_samp_rate(vor_samp_rate)
        self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(com_freq_entry_1,rf_freq=band_center_freq, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_source_0.set_gain(gain_slider, 0)
        self.uhd_usrp_source_0.set_antenna("TX/RX", 0)
        self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(vor_freq_entry_1, rf_freq=band_center_freq, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 1)
        self.uhd_usrp_source_0.set_gain(gain_slider, 1)
        self.uhd_usrp_source_0.set_antenna("TX/RX", 1)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	device_addr="",
        	stream_args=uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0.set_samp_rate(250e3)
        self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(com_freq_entry_1,20e6), 0)
        self.uhd_usrp_sink_0.set_gain(15, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
        _squelch_slider_sizer = wx.BoxSizer(wx.VERTICAL)
        self._squelch_slider_text_box = forms.text_box(
        	parent=self.notebook_0.GetPage(0).GetWin(),
        	sizer=_squelch_slider_sizer,
        	value=self.squelch_slider,
        	callback=self.set_squelch_slider,
        	label='squelch_slider',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._squelch_slider_slider = forms.slider(
        	parent=self.notebook_0.GetPage(0).GetWin(),
        	sizer=_squelch_slider_sizer,
        	value=self.squelch_slider,
        	callback=self.set_squelch_slider,
        	minimum=-110,
        	maximum=0,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.notebook_0.GetPage(0).Add(_squelch_slider_sizer)
        self.squelch = analog.pwr_squelch_cc(squelch_slider, 0.01, 20, True)
        self.rational_resampler_xxx_2 = filter.rational_resampler_fff(
                interpolation=250,
                decimation=48,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1 = filter.rational_resampler_fff(
                interpolation=480,
                decimation=125,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=4,
                decimation=5,
                taps=None,
                fractional_bw=None,
        )
        self.openavionics_joystick_interface_0 = openavionics.joystick_interface()
        self.openavionics_audio_ptt_0 = openavionics.audio_ptt()
        self.null_sink_0_0_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.multiply_xx_0_0_0 = blocks.multiply_vcc(1)
        self.multiply_xx_0_0 = blocks.multiply_vff(1)
        self.low_pass_filter_3 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, 10e3, 1, 2, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_2_0_0 = filter.fir_filter_ccf(5, firdes.low_pass(
        	1, 40e3, 2e3, 1e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_2_0 = filter.fir_filter_ccf(5, firdes.low_pass(
        	1, 40e3, 2e3, 1e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_2 = filter.fir_filter_ccf(5, firdes.low_pass(
        	1, vor_samp_rate, 15e3, 5e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_1 = filter.interp_fir_filter_fff(1, firdes.low_pass(
        	1, 12.5e3, 3e3, 1e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(int(250e3/12.5e3), firdes.low_pass(
        	1, vor_samp_rate, 10e3, 1e3, firdes.WIN_HAMMING, 6.76))
        self.goertzel_fc_0_0 = fft.goertzel_fc(10000, 1000, 30)
        self.goertzel_fc_0 = fft.goertzel_fc(40000, 4000, 30)
        self.float_to_complex_0_0 = blocks.float_to_complex(1)
        self.const_source_x_0_0_0 = analog.sig_source_c(0, analog.GR_CONST_WAVE, 0, 0, 0.450)
        self.const_source_x_0_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0.550)
        self.const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0.450)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-87.2665e-3, ))
        self.band_pass_filter_0_0 = filter.fir_filter_fff(4, firdes.band_pass(
        	1, 40e3, 20, 40, 20, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0 = filter.fir_filter_fff(1, firdes.band_pass(
        	1, 10e3, 20, 40, 20, firdes.WIN_HAMMING, 6.76))
        self.audio_source_0 = audio.source(48000, "", True)
        self.audio_sink_0 = audio.sink(int(audio_sample_rate), "", True)
        self._audio_select_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.audio_select,
        	callback=self.set_audio_select,
        	label='audio_select',
        	choices=[0, 1],
        	labels=['AM Voice','VOR Subcarrier'],
        )
        self.Add(self._audio_select_chooser)
        self.analog_sig_source_x_0 = analog.sig_source_c(40e3, analog.GR_COS_WAVE, -9.96e3, 1, 0)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1)
        self.analog_am_demod_cf_0 = analog.am_demod_cf(
        	channel_rate=40e3,
        	audio_decim=4,
        	audio_pass=5000,
        	audio_stop=5500,
        )
        self.analog_agc2_xx_0_1_0 = analog.agc2_ff(1e-1, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0_1_0.set_max_gain(100)
        self.analog_agc2_xx_0_1 = analog.agc2_ff(1e-1, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0_1.set_max_gain(100)
        self.analog_agc2_xx_0_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0_0.set_max_gain(100)
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0.set_max_gain(100)
        self.am_demod_cf_0 = analog.am_demod_cf(
        	channel_rate=am_sample_rate,
        	audio_decim=am_decimation,
        	audio_pass=3e3,
        	audio_stop=4e3,
        )
        self.agc2_xx_0 = analog.agc2_cc(1, 1, 0.75, 1.0)
        self.agc2_xx_0.set_max_gain(0.0)
        self.add_xx_0_0 = blocks.add_vff(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.agc2_xx_0, 0), (self.am_demod_cf_0, 0))
        self.connect((self.am_demod_cf_0, 0), (self.low_pass_filter_1, 0))
        self.connect((self.agc2_xx_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.multiply_xx_0_0, 0), (self.add_xx_0_0, 0))
        self.connect((self.const_source_x_0, 0), (self.multiply_xx_0_0, 1))
        self.connect((self.const_source_x_0_0, 0), (self.add_xx_0_0, 1))
        self.connect((self.multiply_xx_0_0_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.add_xx_0_0, 0), (self.float_to_complex_0_0, 0))
        self.connect((self.add_xx_0_0, 0), (self.float_to_complex_0_0, 1))
        self.connect((self.float_to_complex_0_0, 0), (self.multiply_xx_0_0_0, 0))
        self.connect((self.const_source_x_0_0_0, 0), (self.multiply_xx_0_0_0, 1))
        self.connect((self.uhd_usrp_source_0, 0), (self.null_sink_0_0_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_1, 0), (self.rational_resampler_xxx_1, 0))
        self.connect((self.rational_resampler_xxx_1, 0), (self.audio_sink_0, 0))
        self.connect((self.analog_agc2_xx_0_1_0, 0), (self.wxgui_scopesink2_0, 1))
        self.connect((self.analog_agc2_xx_0_1, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.band_pass_filter_0, 0), (self.analog_agc2_xx_0_1, 0))
        self.connect((self.band_pass_filter_0_0, 0), (self.analog_agc2_xx_0_1_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.band_pass_filter_0_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.goertzel_fc_0, 0))
        self.connect((self.analog_am_demod_cf_0, 0), (self.band_pass_filter_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0), (self.wxgui_numbersink2_0, 0))
        self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.low_pass_filter_3, 0), (self.blocks_complex_to_arg_0, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.low_pass_filter_3, 0))
        self.connect((self.analog_agc2_xx_0, 0), (self.blocks_multiply_conjugate_cc_0, 1))
        self.connect((self.analog_agc2_xx_0_0, 0), (self.blocks_multiply_conjugate_cc_0, 0))
        self.connect((self.goertzel_fc_0_0, 0), (self.analog_agc2_xx_0_0, 0))
        self.connect((self.analog_am_demod_cf_0, 0), (self.goertzel_fc_0_0, 0))
        self.connect((self.goertzel_fc_0, 0), (self.analog_agc2_xx_0, 0))
        self.connect((self.low_pass_filter_2_0_0, 0), (self.analog_am_demod_cf_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_2_0_0, 0))
        self.connect((self.low_pass_filter_2_0, 0), (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_2_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.uhd_usrp_source_0, 1), (self.null_sink_0_0, 0))
        self.connect((self.low_pass_filter_2, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.audio_source_0, 0), (self.openavionics_audio_ptt_0, 0))
        self.connect((self.openavionics_audio_ptt_0, 0), (self.rational_resampler_xxx_2, 0))
        self.connect((self.rational_resampler_xxx_2, 0), (self.multiply_xx_0_0, 0))
        self.connect((self.squelch, 0), (self.agc2_xx_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.squelch, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_2, 0))

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.openavionics_joystick_interface_0, "out", self.openavionics_audio_ptt_0, "in2")
Esempio n. 12
0
	def __init__(self):
		grc_wxgui.top_block_gui.__init__(self, title="AM Receiver")
		_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 = 1e6
		self.offset_fine = offset_fine = 0
		self.offset_coarse = offset_coarse = 0
		self.freq = freq = 7200000
		self.LO = LO = 0
		self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(1, samp_rate, 125000, 25000, firdes.WIN_HAMMING, 6.76)
		self.width = width = 10000
		self.trans = trans = 1500
		self.rx_freq = rx_freq = LO+freq+(offset_coarse+offset_fine)
		self.rf_gain = rf_gain = 20
		self.lo_freq = lo_freq = LO
		self.display_selector = display_selector = 0
		self.af_gain = af_gain = 1

		##################################################
		# Blocks
		##################################################
		_width_sizer = wx.BoxSizer(wx.VERTICAL)
		self._width_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_width_sizer,
			value=self.width,
			callback=self.set_width,
			label="Filter",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._width_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_width_sizer,
			value=self.width,
			callback=self.set_width,
			minimum=2000,
			maximum=40000,
			num_steps=760,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_width_sizer, 7, 0, 1, 1)
		_trans_sizer = wx.BoxSizer(wx.VERTICAL)
		self._trans_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_trans_sizer,
			value=self.trans,
			callback=self.set_trans,
			label="Trans",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._trans_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_trans_sizer,
			value=self.trans,
			callback=self.set_trans,
			minimum=500,
			maximum=5000,
			num_steps=900,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_trans_sizer, 8, 0, 1, 1)
		self._rx_freq_static_text = forms.static_text(
			parent=self.GetWin(),
			value=self.rx_freq,
			callback=self.set_rx_freq,
			label="Receive",
			converter=forms.float_converter(),
		)
		self.GridAdd(self._rx_freq_static_text, 5, 3, 1, 1)
		_offset_fine_sizer = wx.BoxSizer(wx.VERTICAL)
		self._offset_fine_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_offset_fine_sizer,
			value=self.offset_fine,
			callback=self.set_offset_fine,
			label="Fine tune",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._offset_fine_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_offset_fine_sizer,
			value=self.offset_fine,
			callback=self.set_offset_fine,
			minimum=-1000,
			maximum=1000,
			num_steps=400,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_offset_fine_sizer, 6, 0, 1, 2)
		_offset_coarse_sizer = wx.BoxSizer(wx.VERTICAL)
		self._offset_coarse_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_offset_coarse_sizer,
			value=self.offset_coarse,
			callback=self.set_offset_coarse,
			label="Coarse tune",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._offset_coarse_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_offset_coarse_sizer,
			value=self.offset_coarse,
			callback=self.set_offset_coarse,
			minimum=-120000,
			maximum=120000,
			num_steps=960,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_offset_coarse_sizer, 6, 2, 1, 2)
		self._display_selector_chooser = forms.drop_down(
			parent=self.GetWin(),
			value=self.display_selector,
			callback=self.set_display_selector,
			label="Spectrum",
			choices=[0, 1],
			labels=['Baseband','USRP'],
		)
		self.GridAdd(self._display_selector_chooser, 5, 0, 1, 1)
		_af_gain_sizer = wx.BoxSizer(wx.VERTICAL)
		self._af_gain_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_af_gain_sizer,
			value=self.af_gain,
			callback=self.set_af_gain,
			label="VOL",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._af_gain_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_af_gain_sizer,
			value=self.af_gain,
			callback=self.set_af_gain,
			minimum=0,
			maximum=5,
			num_steps=50,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_af_gain_sizer, 8, 1, 1, 1)
		self.xlating_fir_filter = gr.freq_xlating_fir_filter_ccc(1, (xlate_filter_taps), -(offset_coarse+offset_fine), samp_rate)
		self.rtlsdr_source_c_0 = osmosdr.source_c( args="nchan=" + str(1) + " " + "" )
		self.rtlsdr_source_c_0.set_sample_rate(samp_rate)
		self.rtlsdr_source_c_0.set_center_freq(31e6, 0)
		self.rtlsdr_source_c_0.set_freq_corr(0, 0)
		self.rtlsdr_source_c_0.set_gain_mode(0, 0)
		self.rtlsdr_source_c_0.set_gain(10, 0)
		self.rtlsdr_source_c_0.set_if_gain(24, 0)
			
		_rf_gain_sizer = wx.BoxSizer(wx.VERTICAL)
		self._rf_gain_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_rf_gain_sizer,
			value=self.rf_gain,
			callback=self.set_rf_gain,
			label="RF",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._rf_gain_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_rf_gain_sizer,
			value=self.rf_gain,
			callback=self.set_rf_gain,
			minimum=0,
			maximum=50,
			num_steps=50,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_rf_gain_sizer, 7, 1, 1, 1)
		self.low_pass_filter = gr.fir_filter_ccf(5, firdes.low_pass(
			1, samp_rate, width/2, trans, firdes.WIN_HAMMING, 6.76))
		self._lo_freq_static_text = forms.static_text(
			parent=self.GetWin(),
			value=self.lo_freq,
			callback=self.set_lo_freq,
			label="LO",
			converter=forms.float_converter(),
		)
		self.GridAdd(self._lo_freq_static_text, 5, 2, 1, 1)
		self.gr_multiply_const_vxx_1 = gr.multiply_const_vff((af_gain, ))
		self.gr_agc2_xx_0 = gr.agc2_cc(0.1, 10e-6, 0.9, 1.0, 1.0)
		self._freq_text_box = forms.text_box(
			parent=self.GetWin(),
			value=self.freq,
			callback=self.set_freq,
			label="USRP",
			converter=forms.float_converter(),
		)
		self.GridAdd(self._freq_text_box, 5, 1, 1, 1)
		self.fftsink = fftsink2.fft_sink_c(
			self.GetWin(),
			baseband_freq=rx_freq*display_selector,
			y_per_div=10,
			y_divs=10,
			ref_level=0,
			ref_scale=13490.0,
			sample_rate=samp_rate,
			fft_size=512,
			fft_rate=15,
			average=True,
			avg_alpha=0.5,
			title="",
			peak_hold=False,
			size=(800,300),
		)
		self.GridAdd(self.fftsink.win, 0, 0, 5, 4)
		self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_ccc(
			interpolation=441,
			decimation=500,
			taps=None,
			fractional_bw=None,
		)
		self.blks2_am_demod_cf_0 = blks2.am_demod_cf(
			channel_rate=44100,
			audio_decim=1,
			audio_pass=5000,
			audio_stop=5500,
		)
		self.audio_sink_0 = audio.sink(44100, "", True)

		##################################################
		# Connections
		##################################################
		self.connect((self.xlating_fir_filter, 0), (self.fftsink, 0))
		self.connect((self.xlating_fir_filter, 0), (self.low_pass_filter, 0))
		self.connect((self.gr_multiply_const_vxx_1, 0), (self.audio_sink_0, 0))
		self.connect((self.gr_multiply_const_vxx_1, 0), (self.audio_sink_0, 1))
		self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.blks2_am_demod_cf_0, 0))
		self.connect((self.blks2_am_demod_cf_0, 0), (self.gr_multiply_const_vxx_1, 0))
		self.connect((self.low_pass_filter, 0), (self.gr_agc2_xx_0, 0))
		self.connect((self.gr_agc2_xx_0, 0), (self.blks2_rational_resampler_xxx_1, 0))
		self.connect((self.rtlsdr_source_c_0, 0), (self.xlating_fir_filter, 0))
Esempio n. 13
0
File: cp03a.py Progetto: mr0w1/cp
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="CP v0.3a")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.freq = freq = 92.9e6
        self.samp_rate = samp_rate = 2.4e6
        self.ch3_volume = ch3_volume = 1
        self.ch3_squelch = ch3_squelch = -30
        self.ch3_mute = ch3_mute = 1
        self.ch3_modulation = ch3_modulation = 0
        self.ch3_invert = ch3_invert = 1
        self.ch3_freq = ch3_freq = freq
        self.ch2_volume = ch2_volume = 1
        self.ch2_squelch = ch2_squelch = -30
        self.ch2_mute = ch2_mute = 1
        self.ch2_modulation = ch2_modulation = 0
        self.ch2_invert = ch2_invert = 1
        self.ch2_freq = ch2_freq = freq
        self.ch1_volume = ch1_volume = 1
        self.ch1_squelch = ch1_squelch = -30
        self.ch1_mute = ch1_mute = 1
        self.ch1_modulation = ch1_modulation = 0
        self.ch1_invert = ch1_invert = 1
        self.ch1_freq = ch1_freq = freq

        ##################################################
        # Blocks
        ##################################################
        self.tab = self.tab = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.tab.AddPage(grc_wxgui.Panel(self.tab), "Ch 1")
        self.tab.AddPage(grc_wxgui.Panel(self.tab), "Ch 2")
        self.tab.AddPage(grc_wxgui.Panel(self.tab), "Ch 3")
        self.GridAdd(self.tab, 5, 0, 1, 7)
        self._freq_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.freq,
            callback=self.set_freq,
            label="Radio Center Freq",
            converter=forms.float_converter(),
        )
        self.GridAdd(self._freq_text_box, 21, 0, 1, 10)
        _ch3_volume_sizer = wx.BoxSizer(wx.VERTICAL)
        self._ch3_volume_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_ch3_volume_sizer,
            value=self.ch3_volume,
            callback=self.set_ch3_volume,
            label="Volume",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._ch3_volume_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_ch3_volume_sizer,
            value=self.ch3_volume,
            callback=self.set_ch3_volume,
            minimum=0,
            maximum=10,
            num_steps=20,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_ch3_volume_sizer, 4, 2, 1, 1)
        _ch3_squelch_sizer = wx.BoxSizer(wx.VERTICAL)
        self._ch3_squelch_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_ch3_squelch_sizer,
            value=self.ch3_squelch,
            callback=self.set_ch3_squelch,
            label="Squelch",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._ch3_squelch_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_ch3_squelch_sizer,
            value=self.ch3_squelch,
            callback=self.set_ch3_squelch,
            minimum=-70,
            maximum=0,
            num_steps=14,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_ch3_squelch_sizer, 4, 3, 1, 1)
        self._ch3_mute_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.ch3_mute,
            callback=self.set_ch3_mute,
            label="Mute",
            true=0,
            false=1,
        )
        self.GridAdd(self._ch3_mute_check_box, 4, 5, 1, 1)
        self._ch3_modulation_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.ch3_modulation,
            callback=self.set_ch3_modulation,
            label="Modulation",
            choices=[0, 1, 2],
            labels=["DMR", "NBFM", "WBFM"],
        )
        self.GridAdd(self._ch3_modulation_chooser, 4, 1, 1, 1)
        self._ch3_invert_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.ch3_invert,
            callback=self.set_ch3_invert,
            label="Invert",
            true=-1,
            false=1,
        )
        self.GridAdd(self._ch3_invert_check_box, 4, 4, 1, 1)
        self._ch3_freq_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.ch3_freq,
            callback=self.set_ch3_freq,
            label="Ch3 Freq",
            converter=forms.float_converter(),
        )
        self.GridAdd(self._ch3_freq_text_box, 4, 0, 1, 1)
        _ch2_volume_sizer = wx.BoxSizer(wx.VERTICAL)
        self._ch2_volume_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_ch2_volume_sizer,
            value=self.ch2_volume,
            callback=self.set_ch2_volume,
            label="Volume",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._ch2_volume_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_ch2_volume_sizer,
            value=self.ch2_volume,
            callback=self.set_ch2_volume,
            minimum=0,
            maximum=10,
            num_steps=20,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_ch2_volume_sizer, 2, 2, 1, 1)
        _ch2_squelch_sizer = wx.BoxSizer(wx.VERTICAL)
        self._ch2_squelch_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_ch2_squelch_sizer,
            value=self.ch2_squelch,
            callback=self.set_ch2_squelch,
            label="Squelch",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._ch2_squelch_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_ch2_squelch_sizer,
            value=self.ch2_squelch,
            callback=self.set_ch2_squelch,
            minimum=-70,
            maximum=0,
            num_steps=14,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_ch2_squelch_sizer, 2, 3, 1, 1)
        self._ch2_mute_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.ch2_mute,
            callback=self.set_ch2_mute,
            label="Mute",
            true=0,
            false=1,
        )
        self.GridAdd(self._ch2_mute_check_box, 2, 5, 1, 1)
        self._ch2_modulation_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.ch2_modulation,
            callback=self.set_ch2_modulation,
            label="Modulation",
            choices=[0, 1, 2],
            labels=["DMR", "NBFM", "WBFM"],
        )
        self.GridAdd(self._ch2_modulation_chooser, 2, 1, 1, 1)
        self._ch2_invert_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.ch2_invert,
            callback=self.set_ch2_invert,
            label="Invert",
            true=-1,
            false=1,
        )
        self.GridAdd(self._ch2_invert_check_box, 2, 4, 1, 1)
        self._ch2_freq_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.ch2_freq,
            callback=self.set_ch2_freq,
            label="Ch2 Freq",
            converter=forms.float_converter(),
        )
        self.GridAdd(self._ch2_freq_text_box, 2, 0, 1, 1)
        _ch1_volume_sizer = wx.BoxSizer(wx.VERTICAL)
        self._ch1_volume_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_ch1_volume_sizer,
            value=self.ch1_volume,
            callback=self.set_ch1_volume,
            label="Volume",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._ch1_volume_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_ch1_volume_sizer,
            value=self.ch1_volume,
            callback=self.set_ch1_volume,
            minimum=0,
            maximum=10,
            num_steps=40,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_ch1_volume_sizer, 0, 2, 1, 1)
        _ch1_squelch_sizer = wx.BoxSizer(wx.VERTICAL)
        self._ch1_squelch_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_ch1_squelch_sizer,
            value=self.ch1_squelch,
            callback=self.set_ch1_squelch,
            label="Squelch",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._ch1_squelch_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_ch1_squelch_sizer,
            value=self.ch1_squelch,
            callback=self.set_ch1_squelch,
            minimum=-70,
            maximum=0,
            num_steps=14,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_ch1_squelch_sizer, 0, 3, 1, 1)
        self._ch1_mute_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.ch1_mute,
            callback=self.set_ch1_mute,
            label="Mute",
            true=0,
            false=1,
        )
        self.GridAdd(self._ch1_mute_check_box, 0, 5, 1, 1)
        self._ch1_modulation_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.ch1_modulation,
            callback=self.set_ch1_modulation,
            label="Modulation",
            choices=[0, 1, 2],
            labels=["DMR", "NBFM", "WBFM"],
        )
        self.GridAdd(self._ch1_modulation_chooser, 0, 1, 1, 1)
        self._ch1_invert_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.ch1_invert,
            callback=self.set_ch1_invert,
            label="Invert",
            true=-1,
            false=1,
        )
        self.GridAdd(self._ch1_invert_check_box, 0, 4, 1, 1)
        self._ch1_freq_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.ch1_freq,
            callback=self.set_ch1_freq,
            label="Ch1 Freq",
            converter=forms.float_converter(),
        )
        self.GridAdd(self._ch1_freq_text_box, 0, 0, 1, 1)
        self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c(
            self.GetWin(),
            baseband_freq=0,
            dynamic_range=100,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=512,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="Waterfall Plot",
        )
        self.GridAdd(self.wxgui_waterfallsink2_1.win, 6, 0, 15, 10)
        self.wxgui_fftsink2_0_0_0 = fftsink2.fft_sink_c(
            self.tab.GetPage(2).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=512,
            fft_rate=15,
            average=True,
            avg_alpha=0.1333,
            title="Channel 3",
            peak_hold=False,
        )
        self.tab.GetPage(2).GridAdd(self.wxgui_fftsink2_0_0_0.win, 0, 0, 12, 7)
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c(
            self.tab.GetPage(1).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=512,
            fft_rate=15,
            average=True,
            avg_alpha=0.1333,
            title="Channel 2",
            peak_hold=False,
        )
        self.tab.GetPage(1).GridAdd(self.wxgui_fftsink2_0_0.win, 0, 0, 12, 7)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.tab.GetPage(0).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=512,
            fft_rate=15,
            average=True,
            avg_alpha=0.1333,
            title="Channel 1",
            peak_hold=False,
        )
        self.tab.GetPage(0).GridAdd(self.wxgui_fftsink2_0.win, 0, 0, 12, 7)
        self.wbfm_chain_0_0_0 = wbfm_chain()
        self.wbfm_chain_0_0 = wbfm_chain()
        self.wbfm_chain_0 = wbfm_chain()
        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(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(10, 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.nbfm_chain_1_0 = nbfm_chain()
        self.nbfm_chain_1 = nbfm_chain()
        self.nbfm_chain_0 = nbfm_chain()
        self.freq_xlating_fft_filter_ccc_0_0_0 = filter.freq_xlating_fft_filter_ccc(
            1, (firdes.low_pass(1, samp_rate, 200000, 10000)), ch3_freq - freq,
            samp_rate)
        self.freq_xlating_fft_filter_ccc_0_0_0.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0_0_0.declare_sample_delay(0)
        self.freq_xlating_fft_filter_ccc_0_0 = filter.freq_xlating_fft_filter_ccc(
            1, (firdes.low_pass(1, samp_rate, 200000, 10000)), ch2_freq - freq,
            samp_rate)
        self.freq_xlating_fft_filter_ccc_0_0.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0_0.declare_sample_delay(0)
        self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(
            1, (firdes.low_pass(1, samp_rate, 200000, 10000)), ch1_freq - freq,
            samp_rate)
        self.freq_xlating_fft_filter_ccc_0.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0)
        self.dsd_chain_1_0 = dsd_chain()
        self.dsd_chain_1 = dsd_chain()
        self.dsd_chain_0 = dsd_chain()
        self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_vff(
            (ch3_invert * ch3_mute, ))
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff(
            (ch2_invert * ch2_mute, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff(
            (ch1_invert * ch1_mute, ))
        self.blocks_multiply_const_vxx_0_0_0 = blocks.multiply_const_vff(
            (ch3_volume, ))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff(
            (ch2_volume, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (ch1_volume, ))
        self.blks2_selector_0_1_0 = grc_blks2.selector(
            item_size=gr.sizeof_gr_complex * 1,
            num_inputs=1,
            num_outputs=3,
            input_index=0,
            output_index=ch3_modulation,
        )
        self.blks2_selector_0_1 = grc_blks2.selector(
            item_size=gr.sizeof_gr_complex * 1,
            num_inputs=1,
            num_outputs=3,
            input_index=0,
            output_index=ch2_modulation,
        )
        self.blks2_selector_0_0_0_0 = grc_blks2.selector(
            item_size=gr.sizeof_float * 1,
            num_inputs=3,
            num_outputs=1,
            input_index=ch3_modulation,
            output_index=0,
        )
        self.blks2_selector_0_0_0 = grc_blks2.selector(
            item_size=gr.sizeof_float * 1,
            num_inputs=3,
            num_outputs=1,
            input_index=ch2_modulation,
            output_index=0,
        )
        self.blks2_selector_0_0 = grc_blks2.selector(
            item_size=gr.sizeof_float * 1,
            num_inputs=3,
            num_outputs=1,
            input_index=ch1_modulation,
            output_index=0,
        )
        self.blks2_selector_0 = grc_blks2.selector(
            item_size=gr.sizeof_gr_complex * 1,
            num_inputs=1,
            num_outputs=3,
            input_index=0,
            output_index=ch1_modulation,
        )
        self.audio_sink_0_0_0 = audio.sink(48000, "", True)
        self.audio_sink_0_0 = audio.sink(48000, "", True)
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_pwr_squelch_xx_0_0_0_0 = analog.pwr_squelch_cc(
            ch3_squelch, 1e-4, 0, True)
        self.analog_pwr_squelch_xx_0_0_0 = analog.pwr_squelch_cc(
            ch2_squelch, 1e-4, 0, True)
        self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_cc(
            ch1_squelch, 1e-4, 0, True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_pwr_squelch_xx_0_0, 0),
                     (self.blks2_selector_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0_0_0, 0),
                     (self.blks2_selector_0_1, 0))
        self.connect((self.analog_pwr_squelch_xx_0_0_0_0, 0),
                     (self.blks2_selector_0_1_0, 0))
        self.connect((self.blks2_selector_0, 0), (self.dsd_chain_0, 0))
        self.connect((self.blks2_selector_0, 1), (self.nbfm_chain_0, 0))
        self.connect((self.blks2_selector_0, 2), (self.wbfm_chain_0, 0))
        self.connect((self.blks2_selector_0_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blks2_selector_0_0_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blks2_selector_0_0_0_0, 0),
                     (self.blocks_multiply_const_vxx_0_0_0, 0))
        self.connect((self.blks2_selector_0_1, 0), (self.dsd_chain_1, 0))
        self.connect((self.blks2_selector_0_1, 1), (self.nbfm_chain_1, 0))
        self.connect((self.blks2_selector_0_1, 2), (self.wbfm_chain_0_0, 0))
        self.connect((self.blks2_selector_0_1_0, 0), (self.dsd_chain_1_0, 0))
        self.connect((self.blks2_selector_0_1_0, 1), (self.nbfm_chain_1_0, 0))
        self.connect((self.blks2_selector_0_1_0, 2),
                     (self.wbfm_chain_0_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.blocks_multiply_const_vxx_2, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0_0, 0),
                     (self.blocks_multiply_const_vxx_2_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_2, 0),
                     (self.audio_sink_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_2_0, 0),
                     (self.audio_sink_0_0_0, 0))
        self.connect((self.dsd_chain_0, 0), (self.blks2_selector_0_0, 0))
        self.connect((self.dsd_chain_1, 0), (self.blks2_selector_0_0_0, 0))
        self.connect((self.dsd_chain_1_0, 0), (self.blks2_selector_0_0_0_0, 0))
        self.connect((self.freq_xlating_fft_filter_ccc_0, 0),
                     (self.analog_pwr_squelch_xx_0_0, 0))
        self.connect((self.freq_xlating_fft_filter_ccc_0, 0),
                     (self.wxgui_fftsink2_0, 0))
        self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0),
                     (self.analog_pwr_squelch_xx_0_0_0, 0))
        self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0),
                     (self.wxgui_fftsink2_0_0, 0))
        self.connect((self.freq_xlating_fft_filter_ccc_0_0_0, 0),
                     (self.analog_pwr_squelch_xx_0_0_0_0, 0))
        self.connect((self.freq_xlating_fft_filter_ccc_0_0_0, 0),
                     (self.wxgui_fftsink2_0_0_0, 0))
        self.connect((self.nbfm_chain_0, 0), (self.blks2_selector_0_0, 1))
        self.connect((self.nbfm_chain_1, 0), (self.blks2_selector_0_0_0, 1))
        self.connect((self.nbfm_chain_1_0, 0),
                     (self.blks2_selector_0_0_0_0, 1))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.freq_xlating_fft_filter_ccc_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.freq_xlating_fft_filter_ccc_0_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.freq_xlating_fft_filter_ccc_0_0_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.wxgui_waterfallsink2_1, 0))
        self.connect((self.wbfm_chain_0, 0), (self.blks2_selector_0_0, 2))
        self.connect((self.wbfm_chain_0_0, 0), (self.blks2_selector_0_0_0, 2))
        self.connect((self.wbfm_chain_0_0_0, 0),
                     (self.blks2_selector_0_0_0_0, 2))
Esempio n. 14
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="APRS Receiver")

        ##################################################
        # Variables
        ##################################################
        self.space = space = 1200
        self.mark = mark = 2200
        self.xlate_decim = xlate_decim = 8
        self.xlate_bandwidth = xlate_bandwidth = 1200 * 6
        self.sym_dev = sym_dev = (mark - space) / 2
        self.samp_rate = samp_rate = 1e6
        self.quad_rate = quad_rate = 96000
        self.gain = gain = 10
        self.freq_offset = freq_offset = 390e3
        self.freq = freq = 144e6
        self.baud = baud = 1200
        self.audio_rate = audio_rate = 48000
        self.audio_mul = audio_mul = 1
        self.aprs_rate = aprs_rate = 12000
        self.ant = ant = 'TX/RX'

        ##################################################
        # Message Queues
        ##################################################
        ax25_hdlc_framer_b_0_msgq_out = ax25_print_frame_0_msgq_in = gr.msg_queue(
            2)

        ##################################################
        # Blocks
        ##################################################
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Baseband")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Waterfall")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Signal")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Slicer")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Eye")
        self.Add(self.nb)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            label="RF Gain",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            minimum=0,
            maximum=50,
            num_steps=50,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_gain_sizer)
        _freq_offset_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freq_offset_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_freq_offset_sizer,
            value=self.freq_offset,
            callback=self.set_freq_offset,
            label="Freq Offset",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._freq_offset_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_freq_offset_sizer,
            value=self.freq_offset,
            callback=self.set_freq_offset,
            minimum=-500e3,
            maximum=500e3,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_freq_offset_sizer)
        self._freq_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.freq,
            callback=self.set_freq,
            label="Freq",
            converter=forms.float_converter(),
        )
        self.Add(self._freq_text_box)
        _audio_mul_sizer = wx.BoxSizer(wx.VERTICAL)
        self._audio_mul_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_audio_mul_sizer,
            value=self.audio_mul,
            callback=self.set_audio_mul,
            label="Audio",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._audio_mul_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_audio_mul_sizer,
            value=self.audio_mul,
            callback=self.set_audio_mul,
            minimum=0,
            maximum=10,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_audio_mul_sizer)
        self._ant_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.ant,
            callback=self.set_ant,
            label="Antenna",
            choices=['TX/RX', 'RX2'],
            labels=[],
        )
        self.Add(self._ant_chooser)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
            self.nb.GetPage(1).GetWin(),
            baseband_freq=0,
            dynamic_range=50,
            ref_level=-65,
            ref_scale=2.0,
            sample_rate=aprs_rate,
            fft_size=512,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="Waterfall Plot",
        )
        self.nb.GetPage(1).Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_scopesink2_0_0_0 = scopesink2.scope_sink_f(
            self.nb.GetPage(4).GetWin(),
            title="Scope Plot",
            sample_rate=aprs_rate / 10,
            v_scale=0.5,
            v_offset=0,
            t_scale=0.002,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=gr.gr_TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.nb.GetPage(4).Add(self.wxgui_scopesink2_0_0_0.win)
        self.wxgui_scopesink2_0_0 = scopesink2.scope_sink_f(
            self.nb.GetPage(3).GetWin(),
            title="Scope Plot",
            sample_rate=aprs_rate,
            v_scale=0.5,
            v_offset=0,
            t_scale=0.002,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=gr.gr_TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.nb.GetPage(3).Add(self.wxgui_scopesink2_0_0.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.nb.GetPage(2).GetWin(),
            title="Scope Plot",
            sample_rate=aprs_rate,
            v_scale=0.05,
            v_offset=0,
            t_scale=0.002,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=gr.gr_TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.nb.GetPage(2).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.nb.GetPage(0).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=-20,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=True,
            avg_alpha=0.5,
            title="FFT Plot",
            peak_hold=False,
        )
        self.nb.GetPage(0).Add(self.wxgui_fftsink2_0.win)

        def wxgui_fftsink2_0_callback(x, y):
            self.set_freq_offset(x)

        self.wxgui_fftsink2_0.set_callback(wxgui_fftsink2_0_callback)
        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_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(freq, 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.uhd_usrp_source_0.set_antenna(ant, 0)
        self.low_pass_filter_0 = gr.fir_filter_ccf(
            1, firdes.low_pass(1, aprs_rate, 2e3, 600, firdes.WIN_HAMMING,
                               6.76))
        self.gr_single_pole_iir_filter_xx_0 = gr.single_pole_iir_filter_ff(
            0.0001, 1)
        self.gr_null_sink_0 = gr.null_sink(gr.sizeof_float * 1)
        self.gr_multiply_xx_0 = gr.multiply_vcc(1)
        self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((audio_mul, ))
        self.gr_agc_xx_1 = gr.agc_ff(1e-3, 0.8, 0.1, 10.0)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            xlate_decim,
            (firdes.low_pass(1, samp_rate, xlate_bandwidth / 2, 1000)),
            freq_offset, samp_rate)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            10, .25 * (0.05)**2, 0.5, 0.005, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blks2_rational_resampler_xxx_0_0 = blks2.rational_resampler_ccc(
            interpolation=quad_rate,
            decimation=int(samp_rate / xlate_decim),
            taps=None,
            fractional_bw=None,
        )
        self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc(
            interpolation=aprs_rate,
            decimation=quad_rate,
            taps=None,
            fractional_bw=None,
        )
        self.blks2_nbfm_rx_0_0 = blks2.nbfm_rx(
            audio_rate=audio_rate,
            quad_rate=quad_rate,
            tau=75e-6,
            max_dev=25000,
        )
        self.blks2_nbfm_rx_0 = blks2.nbfm_rx(
            audio_rate=aprs_rate,
            quad_rate=quad_rate,
            tau=75e-6,
            max_dev=3e3,
        )
        self.ax25_print_frame_0 = packetradio.queue_watcher_thread(
            ax25_print_frame_0_msgq_in)
        self.ax25_hdlc_framer_b_0 = packetradio.hdlc_framer(
            ax25_hdlc_framer_b_0_msgq_out, False)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            aprs_rate, analog.GR_SIN_WAVE, -(min(mark, space) + sym_dev), 1, 0)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            aprs_rate / (2 * math.pi * sym_dev))
        self.analog_pwr_squelch_xx_0_0_0 = analog.pwr_squelch_cc(
            -70, 1e-1, 0, False)
        self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_cc(
            -70, 1e-1, 0, False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.blks2_rational_resampler_xxx_0_0, 0),
                     (self.blks2_rational_resampler_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.blks2_rational_resampler_xxx_0_0, 0))
        self.connect((self.blks2_rational_resampler_xxx_0, 0),
                     (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.blocks_sub_xx_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.gr_single_pole_iir_filter_xx_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.gr_single_pole_iir_filter_xx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.blocks_sub_xx_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.gr_multiply_xx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.gr_multiply_xx_0, 1))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.gr_multiply_xx_0, 0))
        self.connect((self.blks2_nbfm_rx_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blks2_nbfm_rx_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.wxgui_scopesink2_0_0_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.ax25_hdlc_framer_b_0, 0))
        self.connect((self.blks2_nbfm_rx_0, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.blks2_rational_resampler_xxx_0_0, 0),
                     (self.analog_pwr_squelch_xx_0_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0_0_0, 0),
                     (self.blks2_nbfm_rx_0, 0))
        self.connect((self.blks2_rational_resampler_xxx_0_0, 0),
                     (self.analog_pwr_squelch_xx_0_0_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.wxgui_scopesink2_0_0, 0))
        self.connect((self.blks2_nbfm_rx_0_0, 0), (self.gr_agc_xx_1, 0))
        self.connect((self.analog_pwr_squelch_xx_0_0, 0),
                     (self.blks2_nbfm_rx_0_0, 0))
        self.connect((self.gr_agc_xx_1, 0), (self.gr_multiply_const_vxx_0, 0))
        self.connect((self.gr_multiply_const_vxx_0, 0),
                     (self.gr_null_sink_0, 0))
Esempio n. 15
0
    def __init__(self,
                 subdev="A:0",
                 frequency=216928000,
                 ant="TX/RX",
                 gain=10,
                 enable_filter=0,
                 rate=3.2e6,
                 devid="type=b100"):
        grc_wxgui.top_block_gui.__init__(
            self, title="DAB VHF Baseband Player for UHD (USRP)")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Parameters
        ##################################################
        self.subdev = subdev
        self.frequency = frequency
        self.ant = ant
        self.gain = gain
        self.enable_filter = enable_filter
        self.rate = rate
        self.devid = devid

        ##################################################
        # Variables
        ##################################################
        self.transition0 = transition0 = 150000
        self.switch2 = switch2 = 1
        self.switch1 = switch1 = enable_filter
        self.switch0 = switch0 = False
        self.samp_rate = samp_rate = int(rate)
        self.gain0 = gain0 = gain
        self.frequency0 = frequency0 = frequency
        self.dgain = dgain = 1.0 / 32768
        self.cutoff0 = cutoff0 = 810000

        ##################################################
        # Blocks
        ##################################################
        _transition0_sizer = wx.BoxSizer(wx.VERTICAL)
        self._transition0_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_transition0_sizer,
            value=self.transition0,
            callback=self.set_transition0,
            label="Transition frequency",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._transition0_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_transition0_sizer,
            value=self.transition0,
            callback=self.set_transition0,
            minimum=100,
            maximum=1000000,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_transition0_sizer, 6, 0, 1, 20)
        self._switch2_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.switch2,
            callback=self.set_switch2,
            label="Spectrum display mute",
            true=1,
            false=0,
        )
        self.GridAdd(self._switch2_check_box, 3, 0, 1, 1)
        self._switch1_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.switch1,
            callback=self.set_switch1,
            label="Filter",
            true=1,
            false=0,
        )
        self.GridAdd(self._switch1_check_box, 4, 0, 1, 1)
        self._switch0_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.switch0,
            callback=self.set_switch0,
            label="Clean carrier (Modulator Off)",
            true=1.0,
            false=0,
        )
        self.GridAdd(self._switch0_check_box, 2, 0, 1, 1)
        _gain0_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain0_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_gain0_sizer,
            value=self.gain0,
            callback=self.set_gain0,
            label="Gain",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._gain0_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_gain0_sizer,
            value=self.gain0,
            callback=self.set_gain0,
            minimum=0,
            maximum=20,
            num_steps=40,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_gain0_sizer, 1, 0, 1, 20)
        self._frequency0_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.frequency0,
            callback=self.set_frequency0,
            label="Channel frequency",
            choices=[
                174928000, 176640000, 178352000, 180064000, 181936000,
                183648000, 185360000, 187072000, 188928000, 190640000,
                192352000, 194064000, 195936000, 197648000, 199360000,
                201072000, 202928000, 204640000, 206352000, 208064000,
                209936000, 211648000, 213360000, 215072000, 216928000,
                218640000, 220352000, 222064000, 223936000, 225648000,
                227360000, 229072000, 230784000, 232496000, 234208000,
                235776000, 237488000, 239200000
            ],
            labels=[
                "5A", "5B", "5C", "5D", "6A", "6B", "6C", "6D", "7A", "7B",
                "7C", "7D", "8A", "8B", "8C", "8D", "9A", "9B", "9C", "9D",
                "10A", "10B", "10C", "10D", "11A", "11B", "11C", "11D", "12A",
                "12B", "12C", "12D", "13A", "13B", "13C", "13D", "13E", "13F"
            ],
        )
        self.GridAdd(self._frequency0_chooser, 0, 0, 1, 1)
        _dgain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._dgain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_dgain_sizer,
            value=self.dgain,
            callback=self.set_dgain,
            label="Digital Gain",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._dgain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_dgain_sizer,
            value=self.dgain,
            callback=self.set_dgain,
            minimum=0,
            maximum=1.0 / 10000,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_dgain_sizer, 7, 0, 1, 20)
        _cutoff0_sizer = wx.BoxSizer(wx.VERTICAL)
        self._cutoff0_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_cutoff0_sizer,
            value=self.cutoff0,
            callback=self.set_cutoff0,
            label="Cutoff Frequency",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._cutoff0_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_cutoff0_sizer,
            value=self.cutoff0,
            callback=self.set_cutoff0,
            minimum=1,
            maximum=1500000,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_cutoff0_sizer, 5, 0, 1, 20)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=0,
            y_per_div=5,
            y_divs=15,
            ref_level=60,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=5,
            average=True,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            device_addr=devid,
            stream_args=uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_subdev_spec(subdev, 0)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(frequency0, 0)
        self.uhd_usrp_sink_0.set_gain(gain0, 0)
        self.uhd_usrp_sink_0.set_antenna(ant, 0)
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, cutoff0, transition0,
                            firdes.WIN_HAMMING, 6.76))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((dgain, ))
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1, "/dev/stdin", False)
        self.blks2_valve_1_0 = grc_blks2.valve(item_size=gr.sizeof_gr_complex *
                                               1,
                                               open=bool(switch0))
        self.blks2_valve_1 = grc_blks2.valve(item_size=gr.sizeof_gr_complex *
                                             1,
                                             open=bool(switch2))
        self.blks2_selector_1 = grc_blks2.selector(
            item_size=gr.sizeof_gr_complex * 1,
            num_inputs=2,
            num_outputs=1,
            input_index=switch1,
            output_index=0,
        )
        self.blks2_selector_0 = grc_blks2.selector(
            item_size=gr.sizeof_gr_complex * 1,
            num_inputs=1,
            num_outputs=2,
            input_index=0,
            output_index=switch1,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_valve_1, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.blks2_selector_1, 0), (self.blks2_valve_1, 0))
        self.connect((self.low_pass_filter_0, 0), (self.blks2_selector_1, 1))
        self.connect((self.blks2_selector_0, 0), (self.blks2_selector_1, 0))
        self.connect((self.blks2_selector_0, 1), (self.low_pass_filter_0, 0))
        self.connect((self.blks2_selector_1, 0), (self.blks2_valve_1_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blks2_selector_0, 0))
        self.connect((self.blks2_valve_1_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.uhd_usrp_sink_0, 0))
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Wifi Rx Only Power")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.window_size = window_size = 48
        self.sync_length = sync_length = 320
        self.samp_rate = samp_rate = 20e6
        self.lo_offset = lo_offset = 11e6
        self.gain = gain = 20
        self.freq = freq = 5.805e9
        self.chan_est = chan_est = 0

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.samp_rate,
        	callback=self.set_samp_rate,
        	label="Sample Rate",
        	choices=[5e6, 10e6, 20e6],
        	labels=["5 MHz", "10 MHz", "20 MHz"],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._samp_rate_chooser)
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "constellation")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "autocorrelation")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "FFT")
        self.Add(self.nb)
        self._lo_offset_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.lo_offset,
        	callback=self.set_lo_offset,
        	label="LO Offset",
        	choices=[0, 6e6, 11e6],
        	labels=['0 MHz', '6 MHz', '11 MHz'],
        )
        self.Add(self._lo_offset_chooser)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	label='gain',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_gain_sizer)
        self._freq_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.freq,
        	callback=self.set_freq,
        	label="Channel",
        	choices=[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, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0],
        	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', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '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'],
        )
        self.Add(self._freq_chooser)
        self._chan_est_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.chan_est,
        	callback=self.set_chan_est,
        	label='chan_est',
        	choices=[0, 1],
        	labels=["LMS", "Linear Comb"],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._chan_est_chooser)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	self.nb.GetPage(1).GetWin(),
        	title="Scope Plot",
        	sample_rate=samp_rate,
        	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.nb.GetPage(1).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_scopesink1 = scopesink2.scope_sink_c(
        	self.nb.GetPage(0).GetWin(),
        	title="Scope Plot",
        	sample_rate=12500,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=True,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.nb.GetPage(0).Add(self.wxgui_scopesink1.win)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
        	self.GetWin(),
        	unit="%",
        	minval=0,
        	maxval=100,
        	factor=1.0,
        	decimal_places=2,
        	ref_level=0,
        	sample_rate=1,
        	number_rate=15,
        	average=True,
        	avg_alpha=0.02,
        	label="Frame Error Rate",
        	peak_hold=False,
        	show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.nb.GetPage(2).GetWin(),
        	baseband_freq=580.5*10e6,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=gain,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=64,
        	fft_rate=15,
        	average=True,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        )
        self.nb.GetPage(2).Add(self.wxgui_fftsink2_0.win)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.ieee802_11_ofdm_sync_short_0 = ieee802_11.ofdm_sync_short(0.56, 2, False, False)
        self.ieee802_11_ofdm_sync_long_0 = ieee802_11.ofdm_sync_long(sync_length, True, False)
        self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(False, True)
        self.ieee802_11_ofdm_equalize_symbols_0 = ieee802_11.ofdm_equalize_symbols(chan_est, False)
        self.ieee802_11_ofdm_decode_signal_0 = ieee802_11.ofdm_decode_signal(True, False)
        self.ieee802_11_ofdm_decode_mac_0 = ieee802_11.ofdm_decode_mac(True, True)
        self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_ff(window_size + 16)
        self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc(window_size)
        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.blocks_vector_to_stream_1 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 64)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 48)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 64)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.float_t, "packet_len")
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_gr_complex*1, "/home/furonics/GNURadio/25Feb2016DataTransfer.dat", False)
        self.blocks_file_sink_1.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/furonics/GNURadio/11thFeb2016_AtHome.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_ofdm_decode_mac_0, 'out'), (self.foo_wireshark_connector_0, 'in'))    
        self.msg_connect((self.ieee802_11_ofdm_decode_mac_0, 'out'), (self.ieee802_11_ofdm_parse_mac_0, 'in'))    
        self.msg_connect((self.ieee802_11_ofdm_parse_mac_0, 'fer'), (self.blocks_pdu_to_tagged_stream_0, '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.ieee802_11_moving_average_xx_1, 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_ofdm_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_ofdm_sync_short_0, 0))    
        self.connect((self.blocks_divide_xx_0, 0), (self.ieee802_11_ofdm_sync_short_0, 2))    
        self.connect((self.blocks_divide_xx_0, 0), (self.wxgui_scopesink2_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.ieee802_11_moving_average_xx_0, 0))    
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.wxgui_numbersink2_0, 0))    
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))    
        self.connect((self.blocks_vector_to_stream_0, 0), (self.wxgui_scopesink1, 0))    
        self.connect((self.blocks_vector_to_stream_1, 0), (self.blocks_file_sink_1, 0))    
        self.connect((self.blocks_vector_to_stream_1, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_1, 0))    
        self.connect((self.fft_vxx_0, 0), (self.ieee802_11_ofdm_equalize_symbols_0, 0))    
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.ieee802_11_ofdm_sync_short_0, 1))    
        self.connect((self.ieee802_11_moving_average_xx_1, 0), (self.blocks_divide_xx_0, 1))    
        self.connect((self.ieee802_11_ofdm_decode_signal_0, 0), (self.blocks_vector_to_stream_0, 0))    
        self.connect((self.ieee802_11_ofdm_decode_signal_0, 0), (self.ieee802_11_ofdm_decode_mac_0, 0))    
        self.connect((self.ieee802_11_ofdm_equalize_symbols_0, 0), (self.ieee802_11_ofdm_decode_signal_0, 0))    
        self.connect((self.ieee802_11_ofdm_sync_long_0, 0), (self.blocks_stream_to_vector_0, 0))    
        self.connect((self.ieee802_11_ofdm_sync_short_0, 0), (self.blocks_delay_0, 0))    
        self.connect((self.ieee802_11_ofdm_sync_short_0, 0), (self.ieee802_11_ofdm_sync_long_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_delay_0_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_xx_0, 0))    
Esempio n. 17
0
  def __init__(self, subdev="A:0", devid="type=usrp1", frequency=216928000, ant="TX/RX", gain=10, enable_filter=0, rate=3.2e6):
		grc_wxgui.top_block_gui.__init__(self, title="DAB VHF Baseband Player for UHD (USRP)")
		_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
		self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

		##################################################
		# Parameters
		##################################################
		self.subdev = subdev
		self.devid = devid
		self.frequency = frequency
		self.ant = ant
		self.gain = gain
		self.enable_filter = enable_filter
		self.rate = rate

		##################################################
		# Variables
		##################################################
		self.transition0 = transition0 = 150000
		self.switch2 = switch2 = 1
		self.switch1 = switch1 = enable_filter
		self.switch0 = switch0 = False
		self.samp_rate = samp_rate = int(rate)
		self.gain0 = gain0 = gain
		self.frequency0 = frequency0 = frequency
		self.dgain = dgain = 1.0/32768
		self.cutoff0 = cutoff0 = 810000

		##################################################
		# Blocks
		##################################################
		_transition0_sizer = wx.BoxSizer(wx.VERTICAL)
		self._transition0_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_transition0_sizer,
			value=self.transition0,
			callback=self.set_transition0,
			label="Transition frequency",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._transition0_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_transition0_sizer,
			value=self.transition0,
			callback=self.set_transition0,
			minimum=100,
			maximum=1000000,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_transition0_sizer, 6, 0, 1, 20)
		self._switch2_check_box = forms.check_box(
			parent=self.GetWin(),
			value=self.switch2,
			callback=self.set_switch2,
			label="Spectrum display mute",
			true=1,
			false=0,
		)
		self.GridAdd(self._switch2_check_box, 3, 0, 1, 1)
		self._switch1_check_box = forms.check_box(
			parent=self.GetWin(),
			value=self.switch1,
			callback=self.set_switch1,
			label="Filter",
			true=1,
			false=0,
		)
		self.GridAdd(self._switch1_check_box, 4, 0, 1, 1)
		self._switch0_check_box = forms.check_box(
			parent=self.GetWin(),
			value=self.switch0,
			callback=self.set_switch0,
			label="Clean carrier (Modulator Off)",
			true=1.0,
			false=0,
		)
		self.GridAdd(self._switch0_check_box, 2, 0, 1, 1)
		_gain0_sizer = wx.BoxSizer(wx.VERTICAL)
		self._gain0_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_gain0_sizer,
			value=self.gain0,
			callback=self.set_gain0,
			label="Gain",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._gain0_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_gain0_sizer,
			value=self.gain0,
			callback=self.set_gain0,
			minimum=0,
			maximum=20,
			num_steps=40,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_gain0_sizer, 1, 0, 1, 20)
		self._frequency0_chooser = forms.drop_down(
			parent=self.GetWin(),
			value=self.frequency0,
			callback=self.set_frequency0,
			label="Channel frequency",
			choices=[174928000, 176640000, 178352000, 180064000, 181936000, 183648000, 185360000, 187072000, 188928000, 190640000, 192352000, 194064000, 195936000, 197648000, 199360000, 201072000, 202928000, 204640000, 206352000, 208064000, 209936000, 211648000, 213360000, 215072000, 216928000, 218640000, 220352000, 222064000, 223936000, 225648000, 227360000, 229072000, 230784000, 232496000, 234208000, 235776000, 237488000, 239200000],
			labels=["5A", "5B", "5C", "5D", "6A", "6B", "6C", "6D", "7A", "7B", "7C", "7D", "8A", "8B", "8C", "8D", "9A", "9B", "9C", "9D", "10A", "10B", "10C", "10D", "11A", "11B", "11C", "11D", "12A", "12B", "12C", "12D", "13A", "13B", "13C", "13D", "13E", "13F"],
		)
		self.GridAdd(self._frequency0_chooser, 0, 0, 1, 1)
		_dgain_sizer = wx.BoxSizer(wx.VERTICAL)
		self._dgain_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_dgain_sizer,
			value=self.dgain,
			callback=self.set_dgain,
			label="Digital Gain",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._dgain_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_dgain_sizer,
			value=self.dgain,
			callback=self.set_dgain,
			minimum=0,
			maximum=1.0/10000,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_dgain_sizer, 7, 0, 1, 20)
		_cutoff0_sizer = wx.BoxSizer(wx.VERTICAL)
		self._cutoff0_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_cutoff0_sizer,
			value=self.cutoff0,
			callback=self.set_cutoff0,
			label="Cutoff Frequency",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._cutoff0_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_cutoff0_sizer,
			value=self.cutoff0,
			callback=self.set_cutoff0,
			minimum=1,
			maximum=1500000,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_cutoff0_sizer, 5, 0, 1, 20)
		self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
			self.GetWin(),
			baseband_freq=0,
			y_per_div=5,
			y_divs=15,
			ref_level=60,
			ref_scale=2.0,
			sample_rate=samp_rate,
			fft_size=1024,
			fft_rate=5,
			average=True,
			avg_alpha=None,
			title="FFT Plot",
			peak_hold=False,
		)
		self.Add(self.wxgui_fftsink2_0.win)
		self.uhd_usrp_sink_0 = uhd.usrp_sink(
			device_addr=devid,
			stream_args=uhd.stream_args(
				cpu_format="fc32",
				channels=range(1),
			),
		)
		self.uhd_usrp_sink_0.set_subdev_spec(subdev, 0)
		self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
		self.uhd_usrp_sink_0.set_center_freq(frequency0, 0)
		self.uhd_usrp_sink_0.set_gain(gain0, 0)
		self.uhd_usrp_sink_0.set_antenna(ant, 0)
		self.low_pass_filter_0 = gr.fir_filter_ccf(1, firdes.low_pass(
			1, samp_rate, cutoff0, transition0, firdes.WIN_HAMMING, 6.76))
		self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((dgain, ))
		self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex*1, "/dev/stdin", False)
		self.blks2_valve_1_0 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(switch0))
		self.blks2_valve_1 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(switch2))
		self.blks2_selector_1 = grc_blks2.selector(
			item_size=gr.sizeof_gr_complex*1,
			num_inputs=2,
			num_outputs=1,
			input_index=switch1,
			output_index=0,
		)
		self.blks2_selector_0 = grc_blks2.selector(
			item_size=gr.sizeof_gr_complex*1,
			num_inputs=1,
			num_outputs=2,
			input_index=0,
			output_index=switch1,
		)

		##################################################
		# Connections
		##################################################
		self.connect((self.blks2_valve_1, 0), (self.wxgui_fftsink2_0, 0))
		self.connect((self.blks2_selector_1, 0), (self.blks2_valve_1, 0))
		self.connect((self.low_pass_filter_0, 0), (self.blks2_selector_1, 1))
		self.connect((self.blks2_selector_0, 0), (self.blks2_selector_1, 0))
		self.connect((self.blks2_selector_0, 1), (self.low_pass_filter_0, 0))
		self.connect((self.gr_file_source_0, 0), (self.blks2_selector_0, 0))
		self.connect((self.blks2_selector_1, 0), (self.blks2_valve_1_0, 0))
		self.connect((self.blks2_valve_1_0, 0), (self.gr_multiply_const_vxx_0, 0))
		self.connect((self.gr_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0))
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Wifi Transceiver")

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 40
        self.samp_rate = samp_rate = 20e6
        self.rx_gain = rx_gain = 40
        self.mult = mult = 0.38
        self.lo_offset = lo_offset = 0
        self.freq = freq = 2.412e9
        self.encoding = encoding = 0

        ##################################################
        # Blocks
        ##################################################
        _tx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tx_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_tx_gain_sizer,
        	value=self.tx_gain,
        	callback=self.set_tx_gain,
        	label='tx_gain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._tx_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_tx_gain_sizer,
        	value=self.tx_gain,
        	callback=self.set_tx_gain,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_tx_gain_sizer)
        self._samp_rate_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.samp_rate,
        	callback=self.set_samp_rate,
        	label="Sample Rate",
        	choices=[5e6,10e6, 20e6],
        	labels=["5MHz", "10 MHz", "20 MHz"],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._samp_rate_chooser)
        _rx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_rx_gain_sizer,
        	value=self.rx_gain,
        	callback=self.set_rx_gain,
        	label='rx_gain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._rx_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_rx_gain_sizer,
        	value=self.rx_gain,
        	callback=self.set_rx_gain,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_rx_gain_sizer)
        _mult_sizer = wx.BoxSizer(wx.VERTICAL)
        self._mult_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_mult_sizer,
        	value=self.mult,
        	callback=self.set_mult,
        	label='mult',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._mult_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_mult_sizer,
        	value=self.mult,
        	callback=self.set_mult,
        	minimum=0,
        	maximum=1,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_mult_sizer)
        self._lo_offset_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.lo_offset,
        	callback=self.set_lo_offset,
        	label="LO Offset",
        	choices=[0, 6e6, 11e6],
        	labels=['0 MHz', '6 MHz', '11 MHz'],
        )
        self.Add(self._lo_offset_chooser)
        self._freq_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.freq,
        	callback=self.set_freq,
        	label="Channel",
        	choices=[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, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0],
        	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', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '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'],
        )
        self.Add(self._freq_chooser)
        self._encoding_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.encoding,
        	callback=self.set_encoding,
        	label="Encoding",
        	choices=[0,1,2,3,4,5,6,7],
        	labels=["BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._encoding_chooser)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=5000,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=True,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.wifi_phy_hier_0 = wifi_phy_hier(
            chan_est=0,
            encoding=0,
            sensitivity=0.56,
        )
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        	"packet_len",
        )
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(False, True)
        self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]), ([0x30, 0x14, 0x4a, 0xe6, 0x46, 0xe4]), ([0x02, 0x11, 0x87, 0xBA, 0x68, 0x3B]))
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(False)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000, 10000)
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)
        self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap0", 440, False)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((mult, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/ofdm.pcap", True)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'), (self.ieee802_11_ether_encap_0, 'from tap'))    
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to tap'), (self.blocks_tuntap_pdu_0, 'pdus'))    
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to wifi'), (self.ieee802_11_ofdm_mac_0, 'app in'))    
        self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'), (self.wifi_phy_hier_0, 'mac_in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.foo_wireshark_connector_0, 'in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ether_encap_0, 'from wifi'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ofdm_mac_0, 'phy in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ofdm_parse_mac_0, 'in'))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0))    
        self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0, 0))    
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.wifi_phy_hier_0, 0))    
        self.connect((self.wifi_phy_hier_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.wifi_phy_hier_0, 1), (self.wxgui_scopesink2_0, 0))    
Esempio n. 19
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Wifi Rx Rftap")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.window_size = window_size = 48
        self.sync_length = sync_length = 320
        self.samp_rate = samp_rate = 20e6
        self.freq = freq = 2.437e9
        self.chan_est = chan_est = ieee802_11.LMS

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.samp_rate,
            callback=self.set_samp_rate,
            label="Sample Rate",
            choices=[1e6, 3e6, 5e6, 10e6, 15e6, 20e6],
            labels=["1 MHz", "3 MHz", "5 MHz", "10 MHz", "15 MHz", "20 MHz"],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._samp_rate_chooser)
        self._freq_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.freq,
            callback=self.set_freq,
            label="Channel",
            choices=[2.437e9, 5.805e9],
            labels=["Ch 6 | 2437", "Ch 161| 5805"],
        )
        self.Add(self._freq_chooser)
        self._chan_est_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.chan_est,
            callback=self.set_chan_est,
            label='chan_est',
            choices=[
                ieee802_11.LS, ieee802_11.LMS, ieee802_11.STA, ieee802_11.COMB
            ],
            labels=["LS", "LMS", "STA", "Linear Comb"],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._chan_est_chooser)
        self.rftap_rftap_encap_0 = rftap.rftap_encap(0, -1, "")
        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(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.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, False, False)
        self.ieee802_11_parse_mac_0 = ieee802_11.parse_mac(True, True)
        self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_ff(
            window_size + 16)
        self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc(
            window_size)
        self.ieee802_11_frame_equalizer_0 = ieee802_11.frame_equalizer(
            chan_est, freq, samp_rate, False, False)
        self.ieee802_11_decode_mac_0 = ieee802_11.decode_mac(False, False)
        self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True,
                                     1)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 64)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1",
                                                     "52001", 10000, False)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        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.ieee802_11_parse_mac_0, 'in'))
        self.msg_connect((self.ieee802_11_decode_mac_0, 'out'),
                         (self.rftap_rftap_encap_0, 'in'))
        self.msg_connect((self.rftap_rftap_encap_0, 'out'),
                         (self.blocks_socket_pdu_0, '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.ieee802_11_moving_average_xx_1, 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_multiply_xx_0, 0),
                     (self.ieee802_11_moving_average_xx_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.ieee802_11_frame_equalizer_0, 0))
        self.connect((self.ieee802_11_frame_equalizer_0, 0),
                     (self.ieee802_11_decode_mac_0, 0))
        self.connect((self.ieee802_11_moving_average_xx_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.ieee802_11_moving_average_xx_0, 0),
                     (self.ieee802_11_sync_short_0, 1))
        self.connect((self.ieee802_11_moving_average_xx_1, 0),
                     (self.blocks_divide_xx_0, 1))
        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.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.blocks_delay_0_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.blocks_multiply_xx_0, 0))
Esempio n. 20
0
    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.sat_freq = sat_freq = int(401.365e6)
        self.doppler_freq = doppler_freq = sat_freq
        self.variable_text_box_0 = variable_text_box_0 = doppler_freq - sat_freq
        self.tx_gain = tx_gain = 86
        self.samp_rate = samp_rate = 460800
        self.rx_gain = rx_gain = 40
        self.lo_offset = lo_offset = 150e3
        self.freq_xlation = freq_xlation = 120000
        self.freq_corr = freq_corr = 0
        self.baud_rate = baud_rate = 9600

        ##################################################
        # Blocks
        ##################################################
        _freq_corr_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freq_corr_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_freq_corr_sizer,
            value=self.freq_corr,
            callback=self.set_freq_corr,
            label='Frequency Correction',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._freq_corr_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_freq_corr_sizer,
            value=self.freq_corr,
            callback=self.set_freq_corr,
            minimum=-10000,
            maximum=10000,
            num_steps=500,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_freq_corr_sizer, 0, 2, 1, 1)
        self._doppler_freq_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.doppler_freq,
            callback=self.set_doppler_freq,
            label='Doppler Frequency',
            converter=forms.float_converter(),
        )
        self.GridAdd(self._doppler_freq_text_box, 0, 0, 1, 1)
        self._baud_rate_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.baud_rate,
            callback=self.set_baud_rate,
            label='Baud Rate',
            choices=[115200, 76800, 38400, 19200, 9600, 4800],
            labels=["115K2", "76K8", "38K4", "19K2", "9K6", "4K8"],
        )
        self.Add(self._baud_rate_chooser)
        self.wxgui_waterfallsink2_0_1_1 = waterfallsink2.waterfall_sink_c(
            self.GetWin(),
            baseband_freq=sat_freq + lo_offset,
            dynamic_range=50,
            ref_level=-50,
            ref_scale=2.0,
            sample_rate=460800,
            fft_size=512,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='Waterfall Plot',
        )
        self.GridAdd(self.wxgui_waterfallsink2_0_1_1.win, 1, 0, 1, 4)
        self.wxgui_waterfallsink2_0_0_0 = waterfallsink2.waterfall_sink_c(
            self.GetWin(),
            baseband_freq=doppler_freq + freq_corr,
            dynamic_range=50,
            ref_level=-70,
            ref_scale=2.0,
            sample_rate=baud_rate * 2,
            fft_size=512,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='Waterfall Plot',
        )
        self.GridAdd(self.wxgui_waterfallsink2_0_0_0.win, 3, 0, 1, 2)
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=doppler_freq + freq_corr,
            y_per_div=10,
            y_divs=10,
            ref_level=-50,
            ref_scale=2.0,
            sample_rate=baud_rate * 2,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='FFT Plot',
            peak_hold=False,
        )
        self.GridAdd(self.wxgui_fftsink2_0_0.win, 3, 2, 1, 2)
        self._variable_text_box_0_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.variable_text_box_0,
            callback=self.set_variable_text_box_0,
            label='Doppler Shift',
            converter=forms.float_converter(),
        )
        self.GridAdd(self._variable_text_box_0_text_box, 0, 1, 1, 1)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "master_clock_rate=46080000")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(sat_freq + lo_offset, 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.spacegrant_spirit1_basic_framer_0 = spacegrant.spirit1_basic_framer(
            pmt.cons(pmt.PMT_NIL, pmt.init_u8vector(4,
                                                    [0xAA, 0xAA, 0xAA, 0xAA])),
            pmt.cons(pmt.PMT_NIL,
                     pmt.init_u8vector(4, [0x88, 0x88, 0x88, 0x88])), 8, 0, 0,
            0)
        self.spacegrant_spirit1_basic_deframer_0 = spacegrant.spirit1_basic_deframer(
            pmt.cons(pmt.PMT_NIL, pmt.init_u8vector(4,
                                                    [0xAA, 0xAA, 0xAA, 0xAA])),
            pmt.cons(pmt.PMT_NIL,
                     pmt.init_u8vector(4, [0x88, 0x88, 0x88, 0x88])), 8, 0, 0,
            0)
        self.spacegrant_sg_uhd_usrp_sink_0 = spacegrant.sg_uhd_usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ), '')
        self.spacegrant_sg_uhd_usrp_sink_0.set_center_freq(
            sat_freq + lo_offset, 0)
        self.spacegrant_sg_uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.spacegrant_sg_uhd_usrp_sink_0.set_gain(tx_gain, 0)

        self.spacegrant_message_debug_0 = spacegrant.message_debug()
        self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(
            samp_rate / (baud_rate * 2),
            (firdes.low_pass(1, samp_rate, baud_rate, 5000)))
        self.interp_fir_filter_xxx_0.declare_sample_delay(0)
        self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(
            1, ([1]), freq_corr + lo_offset, samp_rate)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            samp_rate / (baud_rate * 2),
            (firdes.low_pass(1, samp_rate, baud_rate / 2, baud_rate / 10)),
            -freq_corr - lo_offset, samp_rate)
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
            samples_per_symbol=4,
            bt=0.5,
            verbose=True,
            log=True,
        )
        self.digital_gmsk_demod_0 = digital.gmsk_demod(
            samples_per_symbol=4,
            gain_mu=0.175,
            mu=0.5,
            omega_relative_limit=0.005,
            freq_error=0.0,
            verbose=False,
            log=False,
        )
        self.blocks_unpacked_to_packed_xx_1 = blocks.unpacked_to_packed_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu('tun0', 256, True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'),
                         (self.spacegrant_spirit1_basic_framer_0, 'in'))
        self.msg_connect((self.spacegrant_spirit1_basic_deframer_0, 'out'),
                         (self.blocks_tuntap_pdu_0, 'pdus'))
        self.msg_connect((self.spacegrant_spirit1_basic_deframer_0, 'out'),
                         (self.spacegrant_message_debug_0, 'pdu'))
        self.connect((self.blocks_unpacked_to_packed_xx_1, 0),
                     (self.digital_gmsk_mod_0, 0))
        self.connect((self.digital_gmsk_demod_0, 0),
                     (self.spacegrant_spirit1_basic_deframer_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0),
                     (self.interp_fir_filter_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.digital_gmsk_demod_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.wxgui_fftsink2_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.wxgui_waterfallsink2_0_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0),
                     (self.spacegrant_sg_uhd_usrp_sink_0, 0))
        self.connect((self.interp_fir_filter_xxx_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0_0, 0))
        self.connect((self.spacegrant_spirit1_basic_framer_0, 0),
                     (self.blocks_unpacked_to_packed_xx_1, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.wxgui_waterfallsink2_0_1_1, 0))
Esempio n. 21
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="AM Receiver")
        _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 = 2e6
        self.offset_fine = offset_fine = 0
        self.offset_coarse = offset_coarse = 0
        self.freq = freq = 7200000
        self.LO = LO = 0
        self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(1, samp_rate, 125000, 25000, firdes.WIN_HAMMING, 6.76)
        self.width = width = 10000
        self.trans = trans = 1500
        self.rx_freq = rx_freq = LO+freq+(offset_coarse+offset_fine)
        self.rf_gain = rf_gain = 20
        self.lo_freq = lo_freq = LO
        self.display_selector = display_selector = 0
        self.af_gain = af_gain = 1

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=50e3,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0_0.win)
        _width_sizer = wx.BoxSizer(wx.VERTICAL)
        self._width_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_width_sizer,
        	value=self.width,
        	callback=self.set_width,
        	label="Filter",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._width_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_width_sizer,
        	value=self.width,
        	callback=self.set_width,
        	minimum=2000,
        	maximum=40000,
        	num_steps=760,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_width_sizer, 7, 0, 1, 1)
        _trans_sizer = wx.BoxSizer(wx.VERTICAL)
        self._trans_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_trans_sizer,
        	value=self.trans,
        	callback=self.set_trans,
        	label="Trans",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._trans_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_trans_sizer,
        	value=self.trans,
        	callback=self.set_trans,
        	minimum=500,
        	maximum=5000,
        	num_steps=900,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_trans_sizer, 8, 0, 1, 1)
        self._rx_freq_static_text = forms.static_text(
        	parent=self.GetWin(),
        	value=self.rx_freq,
        	callback=self.set_rx_freq,
        	label="Receive",
        	converter=forms.float_converter(),
        )
        self.GridAdd(self._rx_freq_static_text, 5, 3, 1, 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(560e3, 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(10, 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)
          
        _rf_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rf_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_rf_gain_sizer,
        	value=self.rf_gain,
        	callback=self.set_rf_gain,
        	label="RF",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._rf_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_rf_gain_sizer,
        	value=self.rf_gain,
        	callback=self.set_rf_gain,
        	minimum=0,
        	maximum=50,
        	num_steps=50,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_rf_gain_sizer, 7, 1, 1, 1)
        _offset_fine_sizer = wx.BoxSizer(wx.VERTICAL)
        self._offset_fine_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_offset_fine_sizer,
        	value=self.offset_fine,
        	callback=self.set_offset_fine,
        	label="Fine tune",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._offset_fine_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_offset_fine_sizer,
        	value=self.offset_fine,
        	callback=self.set_offset_fine,
        	minimum=-1000,
        	maximum=1000,
        	num_steps=400,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_offset_fine_sizer, 6, 0, 1, 2)
        _offset_coarse_sizer = wx.BoxSizer(wx.VERTICAL)
        self._offset_coarse_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_offset_coarse_sizer,
        	value=self.offset_coarse,
        	callback=self.set_offset_coarse,
        	label="Coarse tune",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._offset_coarse_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_offset_coarse_sizer,
        	value=self.offset_coarse,
        	callback=self.set_offset_coarse,
        	minimum=-120000,
        	maximum=120000,
        	num_steps=960,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_offset_coarse_sizer, 6, 2, 1, 2)
        self._lo_freq_static_text = forms.static_text(
        	parent=self.GetWin(),
        	value=self.lo_freq,
        	callback=self.set_lo_freq,
        	label="LO",
        	converter=forms.float_converter(),
        )
        self.GridAdd(self._lo_freq_static_text, 5, 2, 1, 1)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(2, (xlate_filter_taps), 100e3, samp_rate)
        self._freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.freq,
        	callback=self.set_freq,
        	label="USRP",
        	converter=forms.float_converter(),
        )
        self.GridAdd(self._freq_text_box, 5, 1, 1, 1)
        self._display_selector_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.display_selector,
        	callback=self.set_display_selector,
        	label="Spectrum",
        	choices=[0, 1],
        	labels=['Baseband','USRP'],
        )
        self.GridAdd(self._display_selector_chooser, 5, 0, 1, 1)
        self.band_pass_filter_0 = filter.fir_filter_ccf(1, firdes.band_pass(
        	1, 1e6, -5000, 5000, 700, firdes.WIN_HAMMING, 6.76))
        _af_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._af_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_af_gain_sizer,
        	value=self.af_gain,
        	callback=self.set_af_gain,
        	label="VOL",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._af_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_af_gain_sizer,
        	value=self.af_gain,
        	callback=self.set_af_gain,
        	minimum=0,
        	maximum=5,
        	num_steps=50,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_af_gain_sizer, 8, 1, 1, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.band_pass_filter_0, 0), (self.wxgui_fftsink2_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.band_pass_filter_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))    
Esempio n. 22
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(
            self, title="narrow fm demod on high freq police radio bands")
        _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 = 2400000
        self.rx_freq = rx_freq = 854.388e6
        self.rx_fine = rx_fine = 0
        self.rx_coarse = rx_coarse = 0
        self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(
            1, samp_rate, 125000, 25000, firdes.WIN_HAMMING, 6.76)
        self.width = width = 12500
        self.variable_chooser_1 = variable_chooser_1 = 1
        self.tv_freq = tv_freq = 500.25e6
        self.trans = trans = 25000
        self.squelch = squelch = -55
        self.sql_lev = sql_lev = -20
        self.rx_freq_val = rx_freq_val = rx_freq + (rx_coarse + rx_fine)
        self.freq = freq = 155e6
        self.dev = dev = 7500
        self.decimation = decimation = 50
        self.af_gain = af_gain = 1

        ##################################################
        # Blocks
        ##################################################
        _width_sizer = wx.BoxSizer(wx.VERTICAL)
        self._width_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_width_sizer,
            value=self.width,
            callback=self.set_width,
            label="LP Filter",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._width_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_width_sizer,
            value=self.width,
            callback=self.set_width,
            minimum=2000,
            maximum=40000,
            num_steps=760,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_width_sizer, 2, 4, 1, 4)
        _trans_sizer = wx.BoxSizer(wx.VERTICAL)
        self._trans_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_trans_sizer,
            value=self.trans,
            callback=self.set_trans,
            label="LP Trans",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._trans_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_trans_sizer,
            value=self.trans,
            callback=self.set_trans,
            minimum=500,
            maximum=50000,
            num_steps=900,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_trans_sizer, 2, 8, 1, 4)
        _squelch_sizer = wx.BoxSizer(wx.VERTICAL)
        self._squelch_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_squelch_sizer,
            value=self.squelch,
            callback=self.set_squelch,
            label="squelch level",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._squelch_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_squelch_sizer,
            value=self.squelch,
            callback=self.set_squelch,
            minimum=-100,
            maximum=0,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_squelch_sizer)
        _rx_freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_freq_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rx_freq_sizer,
            value=self.rx_freq,
            callback=self.set_rx_freq,
            label="RX Center ",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rx_freq_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rx_freq_sizer,
            value=self.rx_freq,
            callback=self.set_rx_freq,
            minimum=840000000,
            maximum=860000000,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_rx_freq_sizer, 0, 0, 1, 16)
        _rx_fine_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_fine_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rx_fine_sizer,
            value=self.rx_fine,
            callback=self.set_rx_fine,
            label="RX Fine",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rx_fine_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rx_fine_sizer,
            value=self.rx_fine,
            callback=self.set_rx_fine,
            minimum=0,
            maximum=10000,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_rx_fine_sizer, 1, 4, 1, 4)
        _rx_coarse_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_coarse_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rx_coarse_sizer,
            value=self.rx_coarse,
            callback=self.set_rx_coarse,
            label="RX Offset",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rx_coarse_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rx_coarse_sizer,
            value=self.rx_coarse,
            callback=self.set_rx_coarse,
            minimum=0,
            maximum=1e6,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_rx_coarse_sizer, 1, 0, 1, 4)
        _dev_sizer = wx.BoxSizer(wx.VERTICAL)
        self._dev_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_dev_sizer,
            value=self.dev,
            callback=self.set_dev,
            label="NBFM deviation",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._dev_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_dev_sizer,
            value=self.dev,
            callback=self.set_dev,
            minimum=4000,
            maximum=16000,
            num_steps=24,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_dev_sizer)
        self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c(
            self.GetWin(),
            baseband_freq=rx_freq + rx_coarse + rx_fine,
            dynamic_range=100,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=512,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="Waterfall Plot",
        )
        self.Add(self.wxgui_waterfallsink2_1.win)
        self._variable_chooser_1_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.variable_chooser_1,
            callback=self.set_variable_chooser_1,
            label='variable_chooser_1',
            choices=[1, 2, 3],
            labels=[],
        )
        self.Add(self._variable_chooser_1_chooser)
        _sql_lev_sizer = wx.BoxSizer(wx.VERTICAL)
        self._sql_lev_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_sql_lev_sizer,
            value=self.sql_lev,
            callback=self.set_sql_lev,
            label="SQL",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._sql_lev_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_sql_lev_sizer,
            value=self.sql_lev,
            callback=self.set_sql_lev,
            minimum=-100,
            maximum=100,
            num_steps=200,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_sql_lev_sizer, 1, 12, 1, 4)
        self._rx_freq_val_static_text = forms.static_text(
            parent=self.GetWin(),
            value=self.rx_freq_val,
            callback=self.set_rx_freq_val,
            label="Receive",
            converter=forms.float_converter(),
        )
        self.GridAdd(self._rx_freq_val_static_text, 0, 16, 1, 1)
        self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              "")
        self.rtlsdr_source_0.set_time_now(osmosdr.time_spec_t(time.time()),
                                          osmosdr.ALL_MBOARDS)
        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(10, 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(
            decimation,
            firdes.low_pass(1, samp_rate, width, trans, firdes.WIN_HAMMING,
                            6.76))
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch, 1)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=48000,
            quad_rate=48000,
            tau=50e-6,
            max_dev=dev,
        )
        _af_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._af_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_af_gain_sizer,
            value=self.af_gain,
            callback=self.set_af_gain,
            label="VOL",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._af_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_af_gain_sizer,
            value=self.af_gain,
            callback=self.set_af_gain,
            minimum=0,
            maximum=5,
            num_steps=50,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_af_gain_sizer, 2, 12, 1, 4)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0),
                     (self.analog_nbfm_rx_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.wxgui_waterfallsink2_1, 0))
Esempio n. 23
0
        def __init__(self):
                grc_wxgui.top_block_gui.__init__(self, title="Kx3 Rx")
                _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
                self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

                ##################################################
                # Variables
                ##################################################
                self.rig_freq = rig_freq = float(pexpect.run("rigctl -m 2 f"))
                self.rigctl = pexpect.spawn("rigctl -m 2")
                self.rigctl.timeout = 2.5
                self.prefix = prefix = "~/grdata"
                self.sync_freq = sync_freq = 2
                self.samp_rate = samp_rate = 48000
                self.recfile = recfile = prefix + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat"
                self.freq = freq = rig_freq
                self.click_freq = click_freq = 0
                self.step_up = step_up = 1
                self.step_size = step_size = 1
                self.step_down = step_down = 1
                ##################################################
                # Blocks
                ##################################################
                self.nb0 = self.nb0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
                self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "Waterfall")
                self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "FFT")
                self.GridAdd(self.nb0, 2, 0, 5, 8)
                self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
                        self.nb0.GetPage(0).GetWin(),
                        baseband_freq=rig_freq,
                        dynamic_range=60,
                        ref_level=-10,
                        ref_scale=1.0,
                        sample_rate=samp_rate,
                        fft_size=2048,
                        fft_rate=30,
                        average=False,
                        avg_alpha=None,
                        title="Waterfall Plot",
                        win=window.hamming,
                        size=(1190/gui_scale,600/gui_scale),
                )
                self.nb0.GetPage(0).Add(self.wxgui_waterfallsink2_0.win)
                def wxgui_waterfallsink2_0_callback(x, y):
                        self.set_click_freq(x)
                
                self.wxgui_waterfallsink2_0.set_callback(wxgui_waterfallsink2_0_callback)
                self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
                        self.nb0.GetPage(1).GetWin(),
                        baseband_freq=rig_freq,
                        y_per_div=10,
                        y_divs=10,
                        ref_level=0,
                        ref_scale=2.0,
                        sample_rate=samp_rate,
                        fft_size=2048,
                        fft_rate=10,
                        average=True,
                        avg_alpha=None,
                        title="FFT Plot",
                        peak_hold=True,
                        win=window.flattop,
                        size=(1190/gui_scale,600/gui_scale),
                )
                self.nb0.GetPage(1).Add(self.wxgui_fftsink2_0.win)
                self.gr_float_to_complex_0 = gr.float_to_complex(1)
                self._freq_text_box = forms.text_box(
                        parent=self.GetWin(),
                        value=self.freq,
                        callback=self.set_text_freq,
                        label="Frequency",
                        converter=forms.float_converter(),
                )
                self.GridAdd(self._freq_text_box, 1, 0, 1, 1)
                self._sync_freq_chooser = forms.drop_down(
                        parent=self.GetWin(),
                        value=self.sync_freq,
                        callback=self.set_sync_freq,
                        label="",
                        choices=[1,2,3],
                        labels=["Entry","Track","Track & Click"],
                )
                self.GridAdd(self._sync_freq_chooser, 1, 1, 1, 1)
                self._step_size_chooser = forms.drop_down(
                        parent=self.GetWin(),
                        value=self.step_size,
                        callback=self.set_step_size,
                        label="Step",
                        choices=[1, 2, 3,4,5,6,7],
                        labels=["Band","1MHz","100kHz","10kHz","1kHz","100Hz","10Hz"],
                )
                self.GridAdd(self._step_size_chooser, 1, 2, 1, 1)
                self._step_up_chooser = forms.button(
                        parent=self.GetWin(),
                        value=self.step_up,
                        callback=self.set_step_up,
                        label="",
                        choices=[1],
                        labels=["Step Up"],
                )
                self.GridAdd(self._step_up_chooser, 1, 3, 1, 1)
                self._step_down_chooser = forms.button(
                        parent=self.GetWin(),
                        value=self.step_down,
                        callback=self.set_step_down,
                        label="",
                        choices=[1],
                        labels=["Step Down"],
                )
                self.GridAdd(self._step_down_chooser, 1, 4, 1, 1)		
                
                self.audio_source_0 = audio.source(samp_rate, "pulse", True)
                
                ##################################################
                # Connections
                ##################################################
                self.connect((self.gr_float_to_complex_0, 0), (self.wxgui_waterfallsink2_0, 0))
                self.connect((self.audio_source_0, 1), (self.gr_float_to_complex_0, 0))
                self.connect((self.audio_source_0, 0), (self.gr_float_to_complex_0, 1))
                self.connect((self.gr_float_to_complex_0, 0), (self.wxgui_fftsink2_0, 0))
                self.lock = RLock()
                self.vfo_poll_skip = 0
                self.set_rig_vfo = False
                _poll_vfo_thread = Thread(target=self._poll_vfo_probe)
                _poll_vfo_thread.daemon = True
                _poll_vfo_thread.start()
Esempio n. 24
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="narrow fm demod on high freq police radio bands")
        _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 = 2400000
        self.rx_freq = rx_freq = 854.388e6
        self.rx_fine = rx_fine = 0
        self.rx_coarse = rx_coarse = 0
        self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(1, samp_rate, 125000, 25000, firdes.WIN_HAMMING, 6.76)
        self.width = width = 12500
        self.variable_chooser_1 = variable_chooser_1 = 1
        self.tv_freq = tv_freq = 500.25e6
        self.trans = trans = 25000
        self.squelch = squelch = -55
        self.sql_lev = sql_lev = -20
        self.rx_freq_val = rx_freq_val = rx_freq+(rx_coarse+rx_fine)
        self.freq = freq = 155e6
        self.dev = dev = 7500
        self.decimation = decimation = 50
        self.af_gain = af_gain = 1

        ##################################################
        # Blocks
        ##################################################
        _width_sizer = wx.BoxSizer(wx.VERTICAL)
        self._width_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_width_sizer,
        	value=self.width,
        	callback=self.set_width,
        	label="LP Filter",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._width_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_width_sizer,
        	value=self.width,
        	callback=self.set_width,
        	minimum=2000,
        	maximum=40000,
        	num_steps=760,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_width_sizer, 2, 4, 1, 4)
        _trans_sizer = wx.BoxSizer(wx.VERTICAL)
        self._trans_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_trans_sizer,
        	value=self.trans,
        	callback=self.set_trans,
        	label="LP Trans",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._trans_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_trans_sizer,
        	value=self.trans,
        	callback=self.set_trans,
        	minimum=500,
        	maximum=50000,
        	num_steps=900,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_trans_sizer, 2, 8, 1, 4)
        _squelch_sizer = wx.BoxSizer(wx.VERTICAL)
        self._squelch_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_squelch_sizer,
        	value=self.squelch,
        	callback=self.set_squelch,
        	label="squelch level",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._squelch_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_squelch_sizer,
        	value=self.squelch,
        	callback=self.set_squelch,
        	minimum=-100,
        	maximum=0,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_squelch_sizer)
        _rx_freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_rx_freq_sizer,
        	value=self.rx_freq,
        	callback=self.set_rx_freq,
        	label="RX Center ",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._rx_freq_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_rx_freq_sizer,
        	value=self.rx_freq,
        	callback=self.set_rx_freq,
        	minimum=840000000,
        	maximum=860000000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_rx_freq_sizer, 0, 0, 1, 16)
        _rx_fine_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_fine_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_rx_fine_sizer,
        	value=self.rx_fine,
        	callback=self.set_rx_fine,
        	label="RX Fine",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._rx_fine_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_rx_fine_sizer,
        	value=self.rx_fine,
        	callback=self.set_rx_fine,
        	minimum=0,
        	maximum=10000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_rx_fine_sizer, 1, 4, 1, 4)
        _rx_coarse_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_coarse_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_rx_coarse_sizer,
        	value=self.rx_coarse,
        	callback=self.set_rx_coarse,
        	label="RX Offset",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._rx_coarse_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_rx_coarse_sizer,
        	value=self.rx_coarse,
        	callback=self.set_rx_coarse,
        	minimum=0,
        	maximum=1e6,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_rx_coarse_sizer, 1, 0, 1, 4)
        _dev_sizer = wx.BoxSizer(wx.VERTICAL)
        self._dev_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_dev_sizer,
        	value=self.dev,
        	callback=self.set_dev,
        	label="NBFM deviation",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._dev_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_dev_sizer,
        	value=self.dev,
        	callback=self.set_dev,
        	minimum=4000,
        	maximum=16000,
        	num_steps=24,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_dev_sizer)
        self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c(
        	self.GetWin(),
        	baseband_freq=rx_freq + rx_coarse + rx_fine,
        	dynamic_range=100,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        )
        self.Add(self.wxgui_waterfallsink2_1.win)
        self._variable_chooser_1_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.variable_chooser_1,
        	callback=self.set_variable_chooser_1,
        	label='variable_chooser_1',
        	choices=[1, 2, 3],
        	labels=[],
        )
        self.Add(self._variable_chooser_1_chooser)
        _sql_lev_sizer = wx.BoxSizer(wx.VERTICAL)
        self._sql_lev_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_sql_lev_sizer,
        	value=self.sql_lev,
        	callback=self.set_sql_lev,
        	label="SQL",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._sql_lev_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_sql_lev_sizer,
        	value=self.sql_lev,
        	callback=self.set_sql_lev,
        	minimum=-100,
        	maximum=100,
        	num_steps=200,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_sql_lev_sizer, 1, 12, 1, 4)
        self._rx_freq_val_static_text = forms.static_text(
        	parent=self.GetWin(),
        	value=self.rx_freq_val,
        	callback=self.set_rx_freq_val,
        	label="Receive",
        	converter=forms.float_converter(),
        )
        self.GridAdd(self._rx_freq_val_static_text, 0, 16, 1, 1)
        self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.rtlsdr_source_0.set_time_now(osmosdr.time_spec_t(time.time()), osmosdr.ALL_MBOARDS)
        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(10, 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(decimation, firdes.low_pass(
        	1, samp_rate, width, trans, firdes.WIN_HAMMING, 6.76))
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch, 1)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=48000,
        	quad_rate=48000,
        	tau=50e-6,
        	max_dev=dev,
        )
        _af_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._af_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_af_gain_sizer,
        	value=self.af_gain,
        	callback=self.set_af_gain,
        	label="VOL",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._af_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_af_gain_sizer,
        	value=self.af_gain,
        	callback=self.set_af_gain,
        	minimum=0,
        	maximum=5,
        	num_steps=50,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_af_gain_sizer, 2, 12, 1, 4)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.analog_simple_squelch_cc_0, 0), (self.analog_nbfm_rx_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.analog_simple_squelch_cc_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_waterfallsink2_1, 0))    
Esempio n. 25
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="FHSS transmit")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_sym = samp_sym = 64
        self.tx_freq = tx_freq = 2.414e9
        self.samp_rate = samp_rate = 400e3
        self.registers = registers = 3
        self.init = init = 1, 1, 1, 1
        self.generator = generator = 1, 1, 0, 0, 1
        self.code_rate = code_rate = int(samp_sym * 500)

        ##################################################
        # Blocks
        ##################################################
        self._tx_freq_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.tx_freq,
        	callback=self.set_tx_freq,
        	label="tx_freq",
        	choices=[2414000000, 2432000000, 2450000000, 2468000000],
        	labels=[1,2,3,4],
        )
        self.Add(self._tx_freq_chooser)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("addr=192.168.10.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(tx_freq, 0)
        self.uhd_usrp_sink_0.set_gain(20, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
        self.uhd_usrp_sink_0.set_bandwidth(1.125e6, 0)
        self.digital_gfsk_mod_0 = digital.gfsk_mod(
        	samples_per_symbol=64,
        	sensitivity=1.0,
        	bt=0.35,
        	verbose=False,
        	log=False,
        )
        self.blocks_vector_source_x_0 = blocks.vector_source_b((0, 1, 0, 1), True, 1, [])
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder(
        		samples_per_symbol=1,
        		bits_per_symbol=1,
        		preamble="",
        		access_code="",
        		pad_for_usrp=True,
        	),
        	payload_length=0,
        )
        self.Spread_synthesizer_0 = Spread.synthesizer(code_rate, 9000, samp_rate, (generator), (init))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.Spread_synthesizer_0, 0), (self.uhd_usrp_sink_0, 0))    
        self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gfsk_mod_0, 0))    
        self.connect((self.blocks_vector_source_x_0, 0), (self.blks2_packet_encoder_0, 0))    
        self.connect((self.digital_gfsk_mod_0, 0), (self.Spread_synthesizer_0, 0))    
Esempio n. 26
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="AM Receiver")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 64e6 / 256
        self.offset_fine = offset_fine = 0
        self.offset_coarse = offset_coarse = 0
        self.freq = freq = 15000000
        self.LO = LO = 0
        self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(
            1, samp_rate, 125000, 25000, firdes.WIN_HAMMING, 6.76)
        self.width = width = 10000
        self.trans = trans = 1500
        self.rx_freq = rx_freq = LO + freq + (offset_coarse + offset_fine)
        self.rf_gain = rf_gain = 10
        self.lo_freq = lo_freq = LO
        self.display_selector = display_selector = 0
        self.af_gain = af_gain = 0.200

        ##################################################
        # Blocks
        ##################################################
        _width_sizer = wx.BoxSizer(wx.VERTICAL)
        self._width_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_width_sizer,
            value=self.width,
            callback=self.set_width,
            label="Filter",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._width_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_width_sizer,
            value=self.width,
            callback=self.set_width,
            minimum=2000,
            maximum=40000,
            num_steps=760,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_width_sizer, 7, 0, 1, 1)
        _trans_sizer = wx.BoxSizer(wx.VERTICAL)
        self._trans_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_trans_sizer,
            value=self.trans,
            callback=self.set_trans,
            label="Trans",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._trans_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_trans_sizer,
            value=self.trans,
            callback=self.set_trans,
            minimum=500,
            maximum=5000,
            num_steps=900,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_trans_sizer, 8, 0, 1, 1)
        self._rx_freq_static_text = forms.static_text(
            parent=self.GetWin(),
            value=self.rx_freq,
            callback=self.set_rx_freq,
            label="Receive",
            converter=forms.float_converter(),
        )
        self.GridAdd(self._rx_freq_static_text, 5, 3, 1, 1)
        _rf_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rf_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rf_gain_sizer,
            value=self.rf_gain,
            callback=self.set_rf_gain,
            label="RF",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rf_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rf_gain_sizer,
            value=self.rf_gain,
            callback=self.set_rf_gain,
            minimum=0,
            maximum=50,
            num_steps=50,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_rf_gain_sizer, 7, 1, 1, 1)
        self._display_selector_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.display_selector,
            callback=self.set_display_selector,
            label="Spectrum",
            choices=[0, 1],
            labels=['Baseband', 'USRP'],
        )
        self.GridAdd(self._display_selector_chooser, 5, 0, 1, 1)
        _af_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._af_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_af_gain_sizer,
            value=self.af_gain,
            callback=self.set_af_gain,
            label="VOL",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._af_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_af_gain_sizer,
            value=self.af_gain,
            callback=self.set_af_gain,
            minimum=0,
            maximum=1,
            num_steps=500,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_af_gain_sizer, 8, 1, 1, 1)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=8,
            decimation=45,
            taps=(5, ),
            fractional_bw=None,
        )
        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(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(2, 0)
        self.osmosdr_source_0.set_gain_mode(True, 0)
        self.osmosdr_source_0.set_gain(rf_gain, 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)

        _offset_fine_sizer = wx.BoxSizer(wx.VERTICAL)
        self._offset_fine_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_offset_fine_sizer,
            value=self.offset_fine,
            callback=self.set_offset_fine,
            label="Fine tune",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._offset_fine_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_offset_fine_sizer,
            value=self.offset_fine,
            callback=self.set_offset_fine,
            minimum=-1000,
            maximum=1000,
            num_steps=400,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_offset_fine_sizer, 6, 0, 1, 2)
        _offset_coarse_sizer = wx.BoxSizer(wx.VERTICAL)
        self._offset_coarse_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_offset_coarse_sizer,
            value=self.offset_coarse,
            callback=self.set_offset_coarse,
            label="Coarse tune",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._offset_coarse_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_offset_coarse_sizer,
            value=self.offset_coarse,
            callback=self.set_offset_coarse,
            minimum=-250000,
            maximum=250000,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_offset_coarse_sizer, 6, 2, 1, 2)
        self._lo_freq_static_text = forms.static_text(
            parent=self.GetWin(),
            value=self.lo_freq,
            callback=self.set_lo_freq,
            label="LO",
            converter=forms.float_converter(),
        )
        self.GridAdd(self._lo_freq_static_text, 5, 2, 1, 1)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (xlate_filter_taps), 0, samp_rate)
        self._freq_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.freq,
            callback=self.set_freq,
            label="USRP",
            converter=forms.float_converter(),
        )
        self.GridAdd(self._freq_text_box, 5, 1, 1, 1)
        self.fftsink = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=rx_freq * display_selector,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=13490.0,
            sample_rate=samp_rate,
            fft_size=512,
            fft_rate=15,
            average=True,
            avg_alpha=0.5,
            title="",
            peak_hold=False,
            size=(800, 300),
        )
        self.GridAdd(self.fftsink.win, 0, 0, 5, 4)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (af_gain, ))
        self.band_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.band_pass(1, samp_rate, width / 4, width / 2, trans,
                             firdes.WIN_HAMMING, 6.76))
        self.audio_sink_0 = audio.sink(44100, "", True)
        self.analog_am_demod_cf_0 = analog.am_demod_cf(
            channel_rate=44100,
            audio_decim=1,
            audio_pass=5000,
            audio_stop=10000,
        )
        self.analog_agc_xx_0 = analog.agc_cc(1e-4, 1.0, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_am_demod_cf_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.analog_agc_xx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_am_demod_cf_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.fftsink, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.band_pass_filter_0, 0))
        self.connect((self.band_pass_filter_0, 0), (self.analog_agc_xx_0, 0))
Esempio n. 27
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Zoom Fft")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.ratio_chooser = ratio_chooser = 20
        self.zoom_ratio = zoom_ratio = ratio_chooser
        self.samp_rate = samp_rate = 2500000
        self.freq = freq = 94500000

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=freq,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate / zoom_ratio,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='FFT Plot',
            peak_hold=False,
            win=window.blackmanharris,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self._ratio_chooser_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.ratio_chooser,
            callback=self.set_ratio_chooser,
            label='ratio_chooser',
            choices=[
                2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
                20
            ],
            labels=[],
        )
        self.Add(self._ratio_chooser_chooser)
        self.osmosdr_source_1 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               'airspy')
        self.osmosdr_source_1.set_sample_rate(samp_rate)
        self.osmosdr_source_1.set_center_freq(freq, 0)
        self.osmosdr_source_1.set_freq_corr(0, 0)
        self.osmosdr_source_1.set_dc_offset_mode(0, 0)
        self.osmosdr_source_1.set_iq_balance_mode(0, 0)
        self.osmosdr_source_1.set_gain_mode(False, 0)
        self.osmosdr_source_1.set_gain(10, 0)
        self.osmosdr_source_1.set_if_gain(20, 0)
        self.osmosdr_source_1.set_bb_gain(20, 0)
        self.osmosdr_source_1.set_antenna('', 0)
        self.osmosdr_source_1.set_bandwidth(0, 0)

        self.low_pass_filter_0 = filter.fir_filter_ccf(
            zoom_ratio,
            firdes.low_pass(1, samp_rate, samp_rate / zoom_ratio / 2, 100,
                            firdes.WIN_HAMMING, 6.76))
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate / zoom_ratio, True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.osmosdr_source_1, 0), (self.low_pass_filter_0, 0))
Esempio n. 28
0
    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.tx_freq = tx_freq = 2.407e9
        self.samp_rate = samp_rate = 32e3

        ##################################################
        # Blocks
        ##################################################
        self._tx_freq_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.tx_freq,
            callback=self.set_tx_freq,
            label="tx_freq",
            choices=[
                2.407e9, 2.41e9, 2.413e9, 2.416e9, 2.419e9, 2.422e9, 2.425e9,
                2.427e9, 2.429e9, 2.431e9, 2.433e9, 2.436e9, 2.439e9, 2.441e9,
                2.443e9, 2.422e9, 2.446e9, 2.449e9, 2.452e9, 2.455e9, 2.458e9,
                2.460e9, 2.463e9, 2.466e9, 2.469e9, 2.472e9, 2.475e9, 2.478e9
            ],
            labels=[
                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
            ],
        )
        self.Add(self._tx_freq_chooser)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("addr=192.168.10.2", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_samp_rate(32e3)
        self.uhd_usrp_sink_0.set_center_freq(tx_freq, 0)
        self.uhd_usrp_sink_0.set_gain(20, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
        self.uhd_usrp_sink_0.set_bandwidth(3e6, 0)
        self.digital_gfsk_mod_0 = digital.gfsk_mod(
            samples_per_symbol=2,
            sensitivity=1.0,
            bt=0.35,
            verbose=False,
            log=False,
        )
        self.blocks_vector_source_x_0 = blocks.vector_source_b((1, 0, 1, 0),
                                                               True, 1, [])
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(
            grc_blks2.packet_encoder(
                samples_per_symbol=1,
                bits_per_symbol=1,
                preamble="",
                access_code="",
                pad_for_usrp=True,
            ),
            payload_length=0,
        )
        self.Spread_ds_spreader_0 = Spread.ds_spreader(2, (1, 1, 0, 1),
                                                       (1, 1, 1))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.Spread_ds_spreader_0, 0),
                     (self.digital_gfsk_mod_0, 0))
        self.connect((self.blks2_packet_encoder_0, 0),
                     (self.Spread_ds_spreader_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blks2_packet_encoder_0, 0))
        self.connect((self.digital_gfsk_mod_0, 0), (self.uhd_usrp_sink_0, 0))
Esempio n. 29
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Wifi Rx")

        ##################################################
        # Variables
        ##################################################
        self.window_size = window_size = 48
        self.sync_length = sync_length = 320
        self.samp_rate = samp_rate = 20e6
        self.lo_offset = lo_offset = 0
        self.gain = gain = 20
        self.freq = freq = 2.412e9
        self.chan_est = chan_est = 0

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.samp_rate,
        	callback=self.set_samp_rate,
        	label="Sample Rate",
        	choices=[5e6, 10e6, 20e6],
        	labels=["5 MHz", "10 MHz", "20 MHz"],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._samp_rate_chooser)
        self._lo_offset_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.lo_offset,
        	callback=self.set_lo_offset,
        	label="LO Offset",
        	choices=[0, 6e6, 11e6],
        	labels=['0 MHz', '6 MHz', '11 MHz'],
        )
        self.Add(self._lo_offset_chooser)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	label='gain',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_gain_sizer)
        self._freq_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.freq,
        	callback=self.set_freq,
        	label="Channel",
        	choices=[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, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0],
        	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', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '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'],
        )
        self.Add(self._freq_chooser)
        self._chan_est_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.chan_est,
        	callback=self.set_chan_est,
        	label='chan_est',
        	choices=[0, 1],
        	labels=["LMS", "Linear Comb"],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._chan_est_chooser)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.uhd_usrp_source_0.set_antenna("TX/RX", 0)
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "constellation")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "autocorrelation")
        self.Add(self.nb)
        self.ieee802_11_ofdm_sync_short_0 = ieee802_11.ofdm_sync_short(0.56, 2, False, False)
        self.ieee802_11_ofdm_sync_long_0 = ieee802_11.ofdm_sync_long(sync_length, False, False)
        self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(False, False)
        self.ieee802_11_ofdm_equalize_symbols_0 = ieee802_11.ofdm_equalize_symbols(chan_est, False)
        self.ieee802_11_ofdm_decode_signal_0 = ieee802_11.ofdm_decode_signal(False, False)
        self.ieee802_11_ofdm_decode_mac_0 = ieee802_11.ofdm_decode_mac(False, False)
        self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_ff(window_size + 16)
        self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc(window_size)
        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.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 64)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/ofdm.pcap", True)
        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_ofdm_decode_mac_0, 'out'), (self.foo_wireshark_connector_0, 'in'))    
        self.msg_connect((self.ieee802_11_ofdm_decode_mac_0, 'out'), (self.ieee802_11_ofdm_parse_mac_0, 'in'))    
        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.ieee802_11_moving_average_xx_1, 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_ofdm_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_ofdm_sync_short_0, 0))    
        self.connect((self.blocks_divide_xx_0, 0), (self.ieee802_11_ofdm_sync_short_0, 2))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.ieee802_11_moving_average_xx_0, 0))    
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))    
        self.connect((self.fft_vxx_0, 0), (self.ieee802_11_ofdm_equalize_symbols_0, 0))    
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.ieee802_11_ofdm_sync_short_0, 1))    
        self.connect((self.ieee802_11_moving_average_xx_1, 0), (self.blocks_divide_xx_0, 1))    
        self.connect((self.ieee802_11_ofdm_decode_signal_0, 0), (self.ieee802_11_ofdm_decode_mac_0, 0))    
        self.connect((self.ieee802_11_ofdm_equalize_symbols_0, 0), (self.ieee802_11_ofdm_decode_signal_0, 0))    
        self.connect((self.ieee802_11_ofdm_sync_long_0, 0), (self.blocks_stream_to_vector_0, 0))    
        self.connect((self.ieee802_11_ofdm_sync_short_0, 0), (self.blocks_delay_0, 0))    
        self.connect((self.ieee802_11_ofdm_sync_short_0, 0), (self.ieee802_11_ofdm_sync_long_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_delay_0_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_xx_0, 0))    
Esempio n. 30
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="gr-kx3")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))
        ##################################################
        # Variables
        ##################################################
        self.rig_freq = rig_freq = float(pexpect.run("rigctl -m 2 f"))
        self.rigctl = pexpect.spawn("rigctl -m 2")
        self.rigctl.timeout = 2.5
        self.prefix = prefix = "~/grdata"
        self.sync_freq = sync_freq = 3
        self.samp_rate = samp_rate
        self.recfile = recfile = prefix + datetime.now().strftime(
            "%Y.%m.%d.%H.%M.%S") + ".dat"
        self.freq = freq = rig_freq
        self.click_freq = click_freq = 0
        self.step_up = step_up = 1
        self.dwell_up = dwell_up = 1
        self.step_down = step_down = 1
        self.dwell_down = dwell_down = 1
        self.step_size = step_size = 250
        self.ctq_step = self.step_size

        # calculate the number of FFT bins based on the width of the charts
        log_width = math.log(gui_scale * plot_width, 2)
        if (0 != (log_width - int(log_width))):
            log_width = log_width + 1
        num_bins = pow(2, int(log_width))
        print "Setting number of FFT bins to:" + str(num_bins)

        ##################################################
        # Blocks
        ##################################################
        self.nb0 = self.nb0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "Waterfall")
        self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "FFT")
        self.GridAdd(self.nb0, 2, 0, 5, 8)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
            self.nb0.GetPage(0).GetWin(),
            baseband_freq=rig_freq,
            dynamic_range=20,
            ref_level=-80,
            ref_scale=1.0,
            sample_rate=samp_rate,
            fft_size=num_bins,
            fft_rate=30,
            average=False,
            avg_alpha=None,
            title="Waterfall Plot",
            win=window.hamming,
            size=(plot_width * gui_scale, plot_height * gui_scale),
        )
        self.nb0.GetPage(0).Add(self.wxgui_waterfallsink2_0.win)

        def wxgui_waterfallsink2_0_callback(x, y):
            self.set_click_freq(x)

        self.wxgui_waterfallsink2_0.set_callback(
            wxgui_waterfallsink2_0_callback)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.nb0.GetPage(1).GetWin(),
            baseband_freq=rig_freq,
            y_per_div=10,
            y_divs=12,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=num_bins,
            fft_rate=10,
            average=True,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=True,
            win=window.flattop,
            size=(plot_width * gui_scale, plot_height * gui_scale),
        )
        self.nb0.GetPage(1).Add(self.wxgui_fftsink2_0.win)
        self.gr_float_to_complex_0 = blocks.float_to_complex(1)
        self._freq_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.freq,
            callback=self.set_text_freq,
            label="  Frequency (Hz)",
            converter=forms.int_converter(),
        )
        self.GridAdd(self._freq_text_box, 1, 0, 1, 1)
        self._sync_freq_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.sync_freq,
            callback=self.set_sync_freq,
            label="",
            choices=[1, 2, 3],
            labels=["Entry", "Track", "Track & Click"],
        )
        self.GridAdd(self._sync_freq_chooser, 1, 1, 1, 1)

        self._dwell_down_chooser = forms.button(
            parent=self.GetWin(),
            value=self.dwell_down,
            callback=self.set_dwell_down,
            label="",
            choices=[1],
            labels=["FFT Down"],
        )
        self.GridAdd(self._dwell_down_chooser, 1, 2, 1, 1)

        self._dwell_up_chooser = forms.button(
            parent=self.GetWin(),
            value=self.dwell_up,
            callback=self.set_dwell_up,
            label="",
            choices=[1],
            labels=["FFT Up"],
        )
        self.GridAdd(self._dwell_up_chooser, 1, 3, 1, 1)

        self._step_size_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.step_size,
            callback=self.set_step_size,
            label="\tStep",
            choices=[1000000, 100000, 10000, 1000, 500, 250, 125, 100, 10],
            labels=[
                "1MHz", "100kHz", "10kHz", "1kHz", "500Hz", "250Hz", "125Hz",
                "100Hz", "10Hz"
            ],
        )
        self.GridAdd(self._step_size_chooser, 1, 4, 1, 1)

        self._step_down_chooser = forms.button(
            parent=self.GetWin(),
            value=self.step_down,
            callback=self.set_step_down,
            label="",
            choices=[1],
            labels=["Step Down"],
        )
        self.GridAdd(self._step_down_chooser, 1, 5, 1, 1)

        self._step_up_chooser = forms.button(
            parent=self.GetWin(),
            value=self.step_up,
            callback=self.set_step_up,
            label="",
            choices=[1],
            labels=["Step Up"],
        )
        self.GridAdd(self._step_up_chooser, 1, 6, 1, 1)

        self.audio_source_0 = audio.source(samp_rate, iq_device, True)
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(dc_correction_length, True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.audio_source_0, 1), (self.gr_float_to_complex_0, 0))
        self.connect((self.audio_source_0, 0), (self.gr_float_to_complex_0, 1))
        self.connect((self.gr_float_to_complex_0, 0),
                     (self.dc_blocker_xx_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.wxgui_fftsink2_0, 0))

        self.lock = RLock()
        self.vfo_poll_skip = 0
        self.set_rig_vfo = False
        self.quit = False
        _poll_vfo_thread = Thread(target=self._poll_vfo_probe)
        _poll_vfo_thread.daemon = True
        _poll_vfo_thread.start()
Esempio n. 31
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="SSB Receiver")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.width = width = 2600
        self.samp_rate = samp_rate = 64e6 / 256
        self.offset_fine = offset_fine = 1
        self.offset_coarse = offset_coarse = 1
        self.freq = freq = 4.0e6
        self.center = center = +1500
        self.LO = LO = 0
        self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(
            1, samp_rate, 125000, 25000, firdes.WIN_HAMMING, 6.76)
        self.trans = trans = 500
        self.rx_freq = rx_freq = LO + freq + (offset_coarse + offset_fine)
        self.rf_gain = rf_gain = 10
        self.low = low = center - width / 2
        self.lo_freq = lo_freq = LO
        self.high = high = center + width / 2
        self.display_selector = display_selector = 1
        self.agc_decay = agc_decay = 5e-5
        self.af_gain = af_gain = 0.18

        ##################################################
        # Blocks
        ##################################################
        _trans_sizer = wx.BoxSizer(wx.VERTICAL)
        self._trans_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_trans_sizer,
            value=self.trans,
            callback=self.set_trans,
            label="Trans",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._trans_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_trans_sizer,
            value=self.trans,
            callback=self.set_trans,
            minimum=100,
            maximum=2000,
            num_steps=190,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_trans_sizer, 9, 0, 1, 1)
        self._rx_freq_static_text = forms.static_text(
            parent=self.GetWin(),
            value=self.rx_freq,
            callback=self.set_rx_freq,
            label="Receive",
            converter=forms.float_converter(),
        )
        self.GridAdd(self._rx_freq_static_text, 5, 3, 1, 1)
        _rf_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rf_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rf_gain_sizer,
            value=self.rf_gain,
            callback=self.set_rf_gain,
            label="RF",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rf_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rf_gain_sizer,
            value=self.rf_gain,
            callback=self.set_rf_gain,
            minimum=1,
            maximum=50,
            num_steps=50,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_rf_gain_sizer, 7, 1, 1, 1)
        self._display_selector_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.display_selector,
            callback=self.set_display_selector,
            label="Spectrum",
            choices=[0, 1],
            labels=['Baseband', 'USRP'],
        )
        self.GridAdd(self._display_selector_chooser, 5, 0, 1, 1)
        self._agc_decay_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.agc_decay,
            callback=self.set_agc_decay,
            label="AGC",
            choices=[1e-5, 5e-5, 1e-4],
            labels=['Fast', 'Medium', 'Slow'],
        )
        self.GridAdd(self._agc_decay_chooser, 9, 1, 1, 1)
        _af_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._af_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_af_gain_sizer,
            value=self.af_gain,
            callback=self.set_af_gain,
            label="VOL",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._af_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_af_gain_sizer,
            value=self.af_gain,
            callback=self.set_af_gain,
            minimum=0,
            maximum=1.0,
            num_steps=500,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_af_gain_sizer, 8, 1, 1, 1)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
            self.GetWin(),
            baseband_freq=0,
            dynamic_range=100,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=512,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="Waterfall Plot",
            size=(800, 300),
        )
        self.Add(self.wxgui_waterfallsink2_0.win)
        _width_sizer = wx.BoxSizer(wx.VERTICAL)
        self._width_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_width_sizer,
            value=self.width,
            callback=self.set_width,
            label="Filter",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._width_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_width_sizer,
            value=self.width,
            callback=self.set_width,
            minimum=100,
            maximum=5000,
            num_steps=490,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_width_sizer, 7, 0, 1, 1)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=1,
            taps=None,
            fractional_bw=0.25,
        )
        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(rx_freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(2, 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_gain, 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)

        _offset_fine_sizer = wx.BoxSizer(wx.VERTICAL)
        self._offset_fine_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_offset_fine_sizer,
            value=self.offset_fine,
            callback=self.set_offset_fine,
            label="Fine tune",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._offset_fine_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_offset_fine_sizer,
            value=self.offset_fine,
            callback=self.set_offset_fine,
            minimum=-1000,
            maximum=1000,
            num_steps=400,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_offset_fine_sizer, 6, 0, 1, 2)
        _offset_coarse_sizer = wx.BoxSizer(wx.VERTICAL)
        self._offset_coarse_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_offset_coarse_sizer,
            value=self.offset_coarse,
            callback=self.set_offset_coarse,
            label="Coarse tune",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._offset_coarse_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_offset_coarse_sizer,
            value=self.offset_coarse,
            callback=self.set_offset_coarse,
            minimum=-120000,
            maximum=120000,
            num_steps=960,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_offset_coarse_sizer, 6, 2, 1, 2)
        self._lo_freq_static_text = forms.static_text(
            parent=self.GetWin(),
            value=self.lo_freq,
            callback=self.set_lo_freq,
            label="LO",
            converter=forms.float_converter(),
        )
        self.GridAdd(self._lo_freq_static_text, 5, 2, 1, 1)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (xlate_filter_taps), 0, samp_rate)
        self._freq_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.freq,
            callback=self.set_freq,
            label="USRP",
            converter=forms.float_converter(),
        )
        self.GridAdd(self._freq_text_box, 5, 1, 1, 1)
        self.fftsink = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=rx_freq * display_selector,
            y_per_div=10,
            y_divs=10,
            ref_level=1,
            ref_scale=13490.0,
            sample_rate=samp_rate,
            fft_size=512,
            fft_rate=15,
            average=True,
            avg_alpha=0.5,
            title="",
            peak_hold=False,
            size=(800, 300),
        )
        self.GridAdd(self.fftsink.win, 0, 0, 5, 4)
        _center_sizer = wx.BoxSizer(wx.VERTICAL)
        self._center_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_center_sizer,
            value=self.center,
            callback=self.set_center,
            label="Center",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._center_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_center_sizer,
            value=self.center,
            callback=self.set_center,
            minimum=-5000,
            maximum=5000,
            num_steps=200,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_center_sizer, 8, 0, 1, 1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (af_gain, ))
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.band_pass_filter = filter.fir_filter_ccc(
            5,
            firdes.complex_band_pass(1, samp_rate, -high, -low, trans,
                                     firdes.WIN_HAMMING, 6.76))
        self.audio_sink_0 = audio.sink(44100, "", True)
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, agc_decay, 1.0, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.band_pass_filter, 0), (self.analog_agc2_xx_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_multiply_const_vxx_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.audio_sink_0, 1))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.band_pass_filter, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.fftsink, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_complex_to_real_0, 0))
Esempio n. 32
0
    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.Modus_upper = Modus_upper = 431e6
        self.Modus = Modus = 431e6
        self.samp_rate = samp_rate = 192e3
        self.refresh_rate = refresh_rate = 5
        self.low_pass_cutoff_freq = low_pass_cutoff_freq = 5000
        self.center_freq = center_freq = Modus_upper - Modus
        self.baseband_freq = baseband_freq = 0
        self.IFGain = IFGain = 7
        self.FrequencyOffset = FrequencyOffset = 10
        self.Decim = Decim = 4
        self.Decay = Decay = 0.1
        self.Attack = Attack = 0.8

        ##################################################
        # Blocks
        ##################################################
        self._low_pass_cutoff_freq_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.low_pass_cutoff_freq,
            callback=self.set_low_pass_cutoff_freq,
            label='low_pass_cutoff_freq',
            choices=[5000, 15000, 14900],
            labels=['5000', '15000', '14900'],
        )
        self.Add(self._low_pass_cutoff_freq_chooser)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_f(
            self.GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_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(100e6, 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.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate / 4, low_pass_cutoff_freq, 1000,
                            firdes.WIN_HAMMING, 6.76))
        self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf(1)
        self._Modus_upper_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.Modus_upper,
            callback=self.set_Modus_upper,
            label='Modus_upper',
            choices=[144.18e6, 431e6],
            labels=['144.2 MHz', '431 MHz'],
        )
        self.Add(self._Modus_upper_chooser)
        self._Modus_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.Modus,
            callback=self.set_Modus,
            label='Modus',
            choices=[144.18e6, 431e6, 438e6],
            labels=['144.2 MHz', '431 MHz', '438 MHz'],
        )
        self.Add(self._Modus_chooser)
        _IFGain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._IFGain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_IFGain_sizer,
            value=self.IFGain,
            callback=self.set_IFGain,
            label='IFGain',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._IFGain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_IFGain_sizer,
            value=self.IFGain,
            callback=self.set_IFGain,
            minimum=1,
            maximum=25,
            num_steps=25,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_IFGain_sizer)
        _FrequencyOffset_sizer = wx.BoxSizer(wx.VERTICAL)
        self._FrequencyOffset_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_FrequencyOffset_sizer,
            value=self.FrequencyOffset,
            callback=self.set_FrequencyOffset,
            label='FrequencyOffset',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._FrequencyOffset_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_FrequencyOffset_sizer,
            value=self.FrequencyOffset,
            callback=self.set_FrequencyOffset,
            minimum=-20,
            maximum=20,
            num_steps=40,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_FrequencyOffset_sizer)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_0_0, 0),
                     (self.wxgui_fftsink2_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.analog_quadrature_demod_cf_0_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.low_pass_filter_0, 0))
Esempio n. 33
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="FHSS transmit")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_sym = samp_sym = 64
        self.tx_freq = tx_freq = 2.414e9
        self.samp_rate = samp_rate = 400e3
        self.registers = registers = 3
        self.init = init = 1, 1, 1, 1
        self.generator = generator = 1, 1, 0, 0, 1
        self.code_rate = code_rate = int(samp_sym * 500)

        ##################################################
        # Blocks
        ##################################################
        self._tx_freq_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.tx_freq,
            callback=self.set_tx_freq,
            label="tx_freq",
            choices=[2414000000, 2432000000, 2450000000, 2468000000],
            labels=[1, 2, 3, 4],
        )
        self.Add(self._tx_freq_chooser)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("addr=192.168.10.2", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(tx_freq, 0)
        self.uhd_usrp_sink_0.set_gain(20, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
        self.uhd_usrp_sink_0.set_bandwidth(1.125e6, 0)
        self.digital_gfsk_mod_0 = digital.gfsk_mod(
            samples_per_symbol=64,
            sensitivity=1.0,
            bt=0.35,
            verbose=False,
            log=False,
        )
        self.blocks_vector_source_x_0 = blocks.vector_source_b((0, 1, 0, 1),
                                                               True, 1, [])
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(
            grc_blks2.packet_encoder(
                samples_per_symbol=1,
                bits_per_symbol=1,
                preamble="",
                access_code="",
                pad_for_usrp=True,
            ),
            payload_length=0,
        )
        self.Spread_synthesizer_0 = Spread.synthesizer(code_rate, 9000,
                                                       samp_rate, (generator),
                                                       (init))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.Spread_synthesizer_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.blks2_packet_encoder_0, 0),
                     (self.digital_gfsk_mod_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blks2_packet_encoder_0, 0))
        self.connect((self.digital_gfsk_mod_0, 0),
                     (self.Spread_synthesizer_0, 0))
Esempio n. 34
0
	def __init__(self):
		grc_wxgui.top_block_gui.__init__(self, title="Ofdm Rx")

		##################################################
		# Variables
		##################################################
		self.window_size = window_size = 48
		self.sync_length = sync_length = 320 - 64
		self.samp_rate = samp_rate = 10e6
		self.gain = gain = 0
		self.freq = freq = 5.825e9

		##################################################
		# Blocks
		##################################################
		self._samp_rate_chooser = forms.radio_buttons(
			parent=self.GetWin(),
			value=self.samp_rate,
			callback=self.set_samp_rate,
			label="Sample Rate",
			choices=[10e6, 20e6],
			labels=["10 Mhz", "20 Mhz"],
			style=wx.RA_HORIZONTAL,
		)
		self.Add(self._samp_rate_chooser)
		_gain_sizer = wx.BoxSizer(wx.VERTICAL)
		self._gain_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_gain_sizer,
			value=self.gain,
			callback=self.set_gain,
			label='gain',
			converter=forms.float_converter(),
			proportion=0,
		)
		self._gain_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_gain_sizer,
			value=self.gain,
			callback=self.set_gain,
			minimum=0,
			maximum=100,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Add(_gain_sizer)
		self._freq_chooser = forms.drop_down(
			parent=self.GetWin(),
			value=self.freq,
			callback=self.set_freq,
			label="Channel",
			choices=[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, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0],
			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', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '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'],
		)
		self.Add(self._freq_chooser)
		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_samp_rate(samp_rate)
		self.uhd_usrp_source_0.set_center_freq(freq, 0)
		self.uhd_usrp_source_0.set_gain(gain, 0)
		self.ieee802_1_ofdm_sync_short_0 = gr_ieee802_11.ofdm_sync_short(0.8, 80 * 80, 2, False)
		self.ieee802_1_ofdm_sync_long_0 = gr_ieee802_11.ofdm_sync_long(sync_length, 100, False)
		self.ieee802_1_ofdm_equalize_symbols_0 = gr_ieee802_11.ofdm_equalize_symbols(False)
		self.ieee802_1_ofdm_decode_signal_0 = gr_ieee802_11.ofdm_decode_signal(False)
		self.ieee802_1_ofdm_decode_mac_0 = gr_ieee802_11.ofdm_decode_mac(False)
		self.ieee802_11_ofdm_parse_mac_0 = gr_ieee802_11.ofdm_parse_mac(True)
		self.gr_stream_to_vector_0 = gr.stream_to_vector(gr.sizeof_gr_complex*1, 64)
		self.gr_socket_pdu_0 = gr.socket_pdu("UDP_SERVER", "", "12345", 10000)
		self.gr_skiphead_0 = gr.skiphead(gr.sizeof_gr_complex*1, 20000000)
		self.gr_multiply_xx_0 = gr.multiply_vcc(1)
		self.gr_divide_xx_0 = gr.divide_ff(1)
		self.gr_delay_0_0 = gr.delay(gr.sizeof_gr_complex*1, sync_length)
		self.gr_delay_0 = gr.delay(gr.sizeof_gr_complex*1, 16)
		self.gr_conjugate_cc_0 = gr.conjugate_cc()
		self.gr_complex_to_mag_squared_0 = gr.complex_to_mag_squared(1)
		self.gr_complex_to_mag_0 = gr.complex_to_mag(1)
		self.fir_filter_xxx_0_0 = filter.fir_filter_ccf(1, ([1]*window_size))
		self.fir_filter_xxx_0 = filter.fir_filter_fff(1, ([1]*window_size))
		self.fft_vxx_0 = fft.fft_vcc(64, True, (), True, 1)

		##################################################
		# Connections
		##################################################
		self.connect((self.uhd_usrp_source_0, 0), (self.gr_skiphead_0, 0))
		self.connect((self.gr_skiphead_0, 0), (self.gr_complex_to_mag_squared_0, 0))
		self.connect((self.fir_filter_xxx_0, 0), (self.gr_divide_xx_0, 1))
		self.connect((self.gr_complex_to_mag_squared_0, 0), (self.fir_filter_xxx_0, 0))
		self.connect((self.gr_skiphead_0, 0), (self.gr_multiply_xx_0, 0))
		self.connect((self.gr_conjugate_cc_0, 0), (self.gr_multiply_xx_0, 1))
		self.connect((self.gr_complex_to_mag_0, 0), (self.gr_divide_xx_0, 0))
		self.connect((self.gr_multiply_xx_0, 0), (self.fir_filter_xxx_0_0, 0))
		self.connect((self.fir_filter_xxx_0_0, 0), (self.gr_complex_to_mag_0, 0))
		self.connect((self.gr_skiphead_0, 0), (self.gr_delay_0, 0))
		self.connect((self.gr_delay_0, 0), (self.gr_conjugate_cc_0, 0))
		self.connect((self.fft_vxx_0, 0), (self.ieee802_1_ofdm_equalize_symbols_0, 0))
		self.connect((self.ieee802_1_ofdm_equalize_symbols_0, 0), (self.ieee802_1_ofdm_decode_signal_0, 0))
		self.connect((self.ieee802_1_ofdm_decode_signal_0, 0), (self.ieee802_1_ofdm_decode_mac_0, 0))
		self.connect((self.ieee802_1_ofdm_sync_short_0, 0), (self.gr_delay_0_0, 0))
		self.connect((self.gr_delay_0, 0), (self.ieee802_1_ofdm_sync_short_0, 0))
		self.connect((self.gr_divide_xx_0, 0), (self.ieee802_1_ofdm_sync_short_0, 1))
		self.connect((self.gr_delay_0_0, 0), (self.ieee802_1_ofdm_sync_long_0, 1))
		self.connect((self.ieee802_1_ofdm_sync_short_0, 0), (self.ieee802_1_ofdm_sync_long_0, 0))
		self.connect((self.ieee802_1_ofdm_sync_long_0, 0), (self.gr_stream_to_vector_0, 0))
		self.connect((self.gr_stream_to_vector_0, 0), (self.fft_vxx_0, 0))

		##################################################
		# Asynch Message Connections
		##################################################
		self.msg_connect(self.ieee802_1_ofdm_decode_mac_0, "out", self.ieee802_11_ofdm_parse_mac_0, "in")
		self.msg_connect(self.ieee802_11_ofdm_parse_mac_0, "out", self.gr_socket_pdu_0, "pdus")
Esempio n. 35
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Wifi Rx Rftap")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.window_size = window_size = 48
        self.sync_length = sync_length = 320
        self.samp_rate = samp_rate = 20e6
        self.lo_offset = lo_offset = 0
        self.gain = gain = 80
        self.freq = freq = 5.18e9
        self.chan_est = chan_est = ieee802_11.LMS

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.samp_rate,
            callback=self.set_samp_rate,
            label="Sample Rate",
            choices=[5e6, 10e6, 20e6],
            labels=["5 MHz", "10 MHz", "20 MHz"],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._samp_rate_chooser)
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "constellation")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "autocorrelation")
        self.Add(self.nb)
        self._freq_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.freq,
            callback=self.set_freq,
            label="Channel",
            choices=[
                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
            ],
            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'
            ],
        )
        self.Add(self._freq_chooser)
        self._chan_est_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.chan_est,
            callback=self.set_chan_est,
            label='chan_est',
            choices=[
                ieee802_11.LS, ieee802_11.LMS, ieee802_11.STA, ieee802_11.COMB
            ],
            labels=["LS", "LMS", "STA", "Linear Comb"],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._chan_est_chooser)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.nb.GetPage(1).GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate,
            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.nb.GetPage(1).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_scopesink1 = scopesink2.scope_sink_c(
            self.nb.GetPage(0).GetWin(),
            title="Scope Plot",
            sample_rate=12500,
            v_scale=0.5,
            v_offset=0,
            t_scale=0.5,
            ac_couple=False,
            xy_mode=True,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.nb.GetPage(0).Add(self.wxgui_scopesink1.win)
        self.rftap_rftap_encap_0 = rftap.rftap_encap(0, -1, "")
        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(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._lo_offset_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.lo_offset,
            callback=self.set_lo_offset,
            label="LO Offset",
            choices=[0, 6e6, 11e6],
            labels=['0 MHz', '6 MHz', '11 MHz'],
        )
        self.Add(self._lo_offset_chooser)
        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_moving_average_xx_1 = ieee802_11.moving_average_ff(
            window_size + 16)
        self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc(
            window_size)
        self.ieee802_11_frame_equalizer_0 = ieee802_11.frame_equalizer(
            chan_est, freq, samp_rate, False, False)
        self.ieee802_11_decode_mac_0 = ieee802_11.decode_mac(True, False)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            label='gain',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_gain_sizer)
        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.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 64)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1",
                                                     "52001", 10000, False)
        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_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   "/tmp/wifi.pcap", True)
        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_decode_mac_0, 'out'),
                         (self.rftap_rftap_encap_0, 'in'))
        self.msg_connect((self.ieee802_11_frame_equalizer_0, 'symbols'),
                         (self.blocks_pdu_to_tagged_stream_1, 'pdus'))
        self.msg_connect((self.rftap_rftap_encap_0, 'out'),
                         (self.blocks_socket_pdu_0, '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.ieee802_11_moving_average_xx_1, 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.wxgui_scopesink2_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.ieee802_11_moving_average_xx_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_1, 0),
                     (self.wxgui_scopesink1, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 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.ieee802_11_decode_mac_0, 0))
        self.connect((self.ieee802_11_moving_average_xx_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.ieee802_11_moving_average_xx_0, 0),
                     (self.ieee802_11_sync_short_0, 1))
        self.connect((self.ieee802_11_moving_average_xx_1, 0),
                     (self.blocks_divide_xx_0, 1))
        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.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.blocks_delay_0_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.blocks_multiply_xx_0, 0))
Esempio n. 36
0
File: cp03a.py Progetto: mr0w1/cp
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="CP v0.3a")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.freq = freq = 92.9e6
        self.samp_rate = samp_rate = 2.4e6
        self.ch3_volume = ch3_volume = 1
        self.ch3_squelch = ch3_squelch = -30
        self.ch3_mute = ch3_mute = 1
        self.ch3_modulation = ch3_modulation = 0
        self.ch3_invert = ch3_invert = 1
        self.ch3_freq = ch3_freq = freq
        self.ch2_volume = ch2_volume = 1
        self.ch2_squelch = ch2_squelch = -30
        self.ch2_mute = ch2_mute = 1
        self.ch2_modulation = ch2_modulation = 0
        self.ch2_invert = ch2_invert = 1
        self.ch2_freq = ch2_freq = freq
        self.ch1_volume = ch1_volume = 1
        self.ch1_squelch = ch1_squelch = -30
        self.ch1_mute = ch1_mute = 1
        self.ch1_modulation = ch1_modulation = 0
        self.ch1_invert = ch1_invert = 1
        self.ch1_freq = ch1_freq = freq

        ##################################################
        # Blocks
        ##################################################
        self.tab = self.tab = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.tab.AddPage(grc_wxgui.Panel(self.tab), "Ch 1")
        self.tab.AddPage(grc_wxgui.Panel(self.tab), "Ch 2")
        self.tab.AddPage(grc_wxgui.Panel(self.tab), "Ch 3")
        self.GridAdd(self.tab, 5, 0, 1, 7)
        self._freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.freq,
        	callback=self.set_freq,
        	label="Radio Center Freq",
        	converter=forms.float_converter(),
        )
        self.GridAdd(self._freq_text_box, 21, 0, 1, 10)
        _ch3_volume_sizer = wx.BoxSizer(wx.VERTICAL)
        self._ch3_volume_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_ch3_volume_sizer,
        	value=self.ch3_volume,
        	callback=self.set_ch3_volume,
        	label="Volume",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._ch3_volume_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_ch3_volume_sizer,
        	value=self.ch3_volume,
        	callback=self.set_ch3_volume,
        	minimum=0,
        	maximum=10,
        	num_steps=20,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_ch3_volume_sizer, 4, 2, 1, 1)
        _ch3_squelch_sizer = wx.BoxSizer(wx.VERTICAL)
        self._ch3_squelch_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_ch3_squelch_sizer,
        	value=self.ch3_squelch,
        	callback=self.set_ch3_squelch,
        	label="Squelch",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._ch3_squelch_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_ch3_squelch_sizer,
        	value=self.ch3_squelch,
        	callback=self.set_ch3_squelch,
        	minimum=-70,
        	maximum=0,
        	num_steps=14,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_ch3_squelch_sizer, 4, 3, 1, 1)
        self._ch3_mute_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.ch3_mute,
        	callback=self.set_ch3_mute,
        	label="Mute",
        	true=0,
        	false=1,
        )
        self.GridAdd(self._ch3_mute_check_box, 4, 5, 1, 1)
        self._ch3_modulation_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.ch3_modulation,
        	callback=self.set_ch3_modulation,
        	label="Modulation",
        	choices=[0, 1,2],
        	labels=["DMR","NBFM","WBFM"],
        )
        self.GridAdd(self._ch3_modulation_chooser, 4, 1, 1, 1)
        self._ch3_invert_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.ch3_invert,
        	callback=self.set_ch3_invert,
        	label="Invert",
        	true=-1,
        	false=1,
        )
        self.GridAdd(self._ch3_invert_check_box, 4, 4, 1, 1)
        self._ch3_freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.ch3_freq,
        	callback=self.set_ch3_freq,
        	label="Ch3 Freq",
        	converter=forms.float_converter(),
        )
        self.GridAdd(self._ch3_freq_text_box, 4, 0, 1, 1)
        _ch2_volume_sizer = wx.BoxSizer(wx.VERTICAL)
        self._ch2_volume_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_ch2_volume_sizer,
        	value=self.ch2_volume,
        	callback=self.set_ch2_volume,
        	label="Volume",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._ch2_volume_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_ch2_volume_sizer,
        	value=self.ch2_volume,
        	callback=self.set_ch2_volume,
        	minimum=0,
        	maximum=10,
        	num_steps=20,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_ch2_volume_sizer, 2, 2, 1, 1)
        _ch2_squelch_sizer = wx.BoxSizer(wx.VERTICAL)
        self._ch2_squelch_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_ch2_squelch_sizer,
        	value=self.ch2_squelch,
        	callback=self.set_ch2_squelch,
        	label="Squelch",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._ch2_squelch_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_ch2_squelch_sizer,
        	value=self.ch2_squelch,
        	callback=self.set_ch2_squelch,
        	minimum=-70,
        	maximum=0,
        	num_steps=14,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_ch2_squelch_sizer, 2, 3, 1, 1)
        self._ch2_mute_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.ch2_mute,
        	callback=self.set_ch2_mute,
        	label="Mute",
        	true=0,
        	false=1,
        )
        self.GridAdd(self._ch2_mute_check_box, 2, 5, 1, 1)
        self._ch2_modulation_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.ch2_modulation,
        	callback=self.set_ch2_modulation,
        	label="Modulation",
        	choices=[0, 1,2],
        	labels=["DMR","NBFM","WBFM"],
        )
        self.GridAdd(self._ch2_modulation_chooser, 2, 1, 1, 1)
        self._ch2_invert_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.ch2_invert,
        	callback=self.set_ch2_invert,
        	label="Invert",
        	true=-1,
        	false=1,
        )
        self.GridAdd(self._ch2_invert_check_box, 2, 4, 1, 1)
        self._ch2_freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.ch2_freq,
        	callback=self.set_ch2_freq,
        	label="Ch2 Freq",
        	converter=forms.float_converter(),
        )
        self.GridAdd(self._ch2_freq_text_box, 2, 0, 1, 1)
        _ch1_volume_sizer = wx.BoxSizer(wx.VERTICAL)
        self._ch1_volume_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_ch1_volume_sizer,
        	value=self.ch1_volume,
        	callback=self.set_ch1_volume,
        	label="Volume",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._ch1_volume_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_ch1_volume_sizer,
        	value=self.ch1_volume,
        	callback=self.set_ch1_volume,
        	minimum=0,
        	maximum=10,
        	num_steps=40,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_ch1_volume_sizer, 0, 2, 1, 1)
        _ch1_squelch_sizer = wx.BoxSizer(wx.VERTICAL)
        self._ch1_squelch_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_ch1_squelch_sizer,
        	value=self.ch1_squelch,
        	callback=self.set_ch1_squelch,
        	label="Squelch",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._ch1_squelch_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_ch1_squelch_sizer,
        	value=self.ch1_squelch,
        	callback=self.set_ch1_squelch,
        	minimum=-70,
        	maximum=0,
        	num_steps=14,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_ch1_squelch_sizer, 0, 3, 1, 1)
        self._ch1_mute_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.ch1_mute,
        	callback=self.set_ch1_mute,
        	label="Mute",
        	true=0,
        	false=1,
        )
        self.GridAdd(self._ch1_mute_check_box, 0, 5, 1, 1)
        self._ch1_modulation_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.ch1_modulation,
        	callback=self.set_ch1_modulation,
        	label="Modulation",
        	choices=[0, 1,2],
        	labels=["DMR","NBFM","WBFM"],
        )
        self.GridAdd(self._ch1_modulation_chooser, 0, 1, 1, 1)
        self._ch1_invert_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.ch1_invert,
        	callback=self.set_ch1_invert,
        	label="Invert",
        	true=-1,
        	false=1,
        )
        self.GridAdd(self._ch1_invert_check_box, 0, 4, 1, 1)
        self._ch1_freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.ch1_freq,
        	callback=self.set_ch1_freq,
        	label="Ch1 Freq",
        	converter=forms.float_converter(),
        )
        self.GridAdd(self._ch1_freq_text_box, 0, 0, 1, 1)
        self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	dynamic_range=100,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        )
        self.GridAdd(self.wxgui_waterfallsink2_1.win, 6, 0, 15, 10)
        self.wxgui_fftsink2_0_0_0 = fftsink2.fft_sink_c(
        	self.tab.GetPage(2).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=True,
        	avg_alpha=0.1333,
        	title="Channel 3",
        	peak_hold=False,
        )
        self.tab.GetPage(2).GridAdd(self.wxgui_fftsink2_0_0_0.win, 0, 0, 12, 7)
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c(
        	self.tab.GetPage(1).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=True,
        	avg_alpha=0.1333,
        	title="Channel 2",
        	peak_hold=False,
        )
        self.tab.GetPage(1).GridAdd(self.wxgui_fftsink2_0_0.win, 0, 0, 12, 7)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.tab.GetPage(0).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=True,
        	avg_alpha=0.1333,
        	title="Channel 1",
        	peak_hold=False,
        )
        self.tab.GetPage(0).GridAdd(self.wxgui_fftsink2_0.win, 0, 0, 12, 7)
        self.wbfm_chain_0_0_0 = wbfm_chain()
        self.wbfm_chain_0_0 = wbfm_chain()
        self.wbfm_chain_0 = wbfm_chain()
        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(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(10, 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.nbfm_chain_1_0 = nbfm_chain()
        self.nbfm_chain_1 = nbfm_chain()
        self.nbfm_chain_0 = nbfm_chain()
        self.freq_xlating_fft_filter_ccc_0_0_0 = filter.freq_xlating_fft_filter_ccc(1, (firdes.low_pass(1,samp_rate,200000,10000)), ch3_freq - freq, samp_rate)
        self.freq_xlating_fft_filter_ccc_0_0_0.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0_0_0.declare_sample_delay(0)
        self.freq_xlating_fft_filter_ccc_0_0 = filter.freq_xlating_fft_filter_ccc(1, (firdes.low_pass(1,samp_rate,200000,10000)), ch2_freq - freq, samp_rate)
        self.freq_xlating_fft_filter_ccc_0_0.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0_0.declare_sample_delay(0)
        self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(1, (firdes.low_pass(1,samp_rate,200000,10000)), ch1_freq - freq, samp_rate)
        self.freq_xlating_fft_filter_ccc_0.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0)
        self.dsd_chain_1_0 = dsd_chain()
        self.dsd_chain_1 = dsd_chain()
        self.dsd_chain_0 = dsd_chain()
        self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_vff((ch3_invert * ch3_mute, ))
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((ch2_invert * ch2_mute, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((ch1_invert * ch1_mute, ))
        self.blocks_multiply_const_vxx_0_0_0 = blocks.multiply_const_vff((ch3_volume, ))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((ch2_volume, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((ch1_volume, ))
        self.blks2_selector_0_1_0 = grc_blks2.selector(
        	item_size=gr.sizeof_gr_complex*1,
        	num_inputs=1,
        	num_outputs=3,
        	input_index=0,
        	output_index=ch3_modulation,
        )
        self.blks2_selector_0_1 = grc_blks2.selector(
        	item_size=gr.sizeof_gr_complex*1,
        	num_inputs=1,
        	num_outputs=3,
        	input_index=0,
        	output_index=ch2_modulation,
        )
        self.blks2_selector_0_0_0_0 = grc_blks2.selector(
        	item_size=gr.sizeof_float*1,
        	num_inputs=3,
        	num_outputs=1,
        	input_index=ch3_modulation,
        	output_index=0,
        )
        self.blks2_selector_0_0_0 = grc_blks2.selector(
        	item_size=gr.sizeof_float*1,
        	num_inputs=3,
        	num_outputs=1,
        	input_index=ch2_modulation,
        	output_index=0,
        )
        self.blks2_selector_0_0 = grc_blks2.selector(
        	item_size=gr.sizeof_float*1,
        	num_inputs=3,
        	num_outputs=1,
        	input_index=ch1_modulation,
        	output_index=0,
        )
        self.blks2_selector_0 = grc_blks2.selector(
        	item_size=gr.sizeof_gr_complex*1,
        	num_inputs=1,
        	num_outputs=3,
        	input_index=0,
        	output_index=ch1_modulation,
        )
        self.audio_sink_0_0_0 = audio.sink(48000, "", True)
        self.audio_sink_0_0 = audio.sink(48000, "", True)
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_pwr_squelch_xx_0_0_0_0 = analog.pwr_squelch_cc(ch3_squelch, 1e-4, 0, True)
        self.analog_pwr_squelch_xx_0_0_0 = analog.pwr_squelch_cc(ch2_squelch, 1e-4, 0, True)
        self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_cc(ch1_squelch, 1e-4, 0, True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_pwr_squelch_xx_0_0, 0), (self.blks2_selector_0, 0))    
        self.connect((self.analog_pwr_squelch_xx_0_0_0, 0), (self.blks2_selector_0_1, 0))    
        self.connect((self.analog_pwr_squelch_xx_0_0_0_0, 0), (self.blks2_selector_0_1_0, 0))    
        self.connect((self.blks2_selector_0, 0), (self.dsd_chain_0, 0))    
        self.connect((self.blks2_selector_0, 1), (self.nbfm_chain_0, 0))    
        self.connect((self.blks2_selector_0, 2), (self.wbfm_chain_0, 0))    
        self.connect((self.blks2_selector_0_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blks2_selector_0_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))    
        self.connect((self.blks2_selector_0_0_0_0, 0), (self.blocks_multiply_const_vxx_0_0_0, 0))    
        self.connect((self.blks2_selector_0_1, 0), (self.dsd_chain_1, 0))    
        self.connect((self.blks2_selector_0_1, 1), (self.nbfm_chain_1, 0))    
        self.connect((self.blks2_selector_0_1, 2), (self.wbfm_chain_0_0, 0))    
        self.connect((self.blks2_selector_0_1_0, 0), (self.dsd_chain_1_0, 0))    
        self.connect((self.blks2_selector_0_1_0, 1), (self.nbfm_chain_1_0, 0))    
        self.connect((self.blks2_selector_0_1_0, 2), (self.wbfm_chain_0_0_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_const_vxx_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_multiply_const_vxx_2, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0_0, 0), (self.blocks_multiply_const_vxx_2_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.audio_sink_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_2, 0), (self.audio_sink_0_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.audio_sink_0_0_0, 0))    
        self.connect((self.dsd_chain_0, 0), (self.blks2_selector_0_0, 0))    
        self.connect((self.dsd_chain_1, 0), (self.blks2_selector_0_0_0, 0))    
        self.connect((self.dsd_chain_1_0, 0), (self.blks2_selector_0_0_0_0, 0))    
        self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.analog_pwr_squelch_xx_0_0, 0))    
        self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.analog_pwr_squelch_xx_0_0_0, 0))    
        self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.wxgui_fftsink2_0_0, 0))    
        self.connect((self.freq_xlating_fft_filter_ccc_0_0_0, 0), (self.analog_pwr_squelch_xx_0_0_0_0, 0))    
        self.connect((self.freq_xlating_fft_filter_ccc_0_0_0, 0), (self.wxgui_fftsink2_0_0_0, 0))    
        self.connect((self.nbfm_chain_0, 0), (self.blks2_selector_0_0, 1))    
        self.connect((self.nbfm_chain_1, 0), (self.blks2_selector_0_0_0, 1))    
        self.connect((self.nbfm_chain_1_0, 0), (self.blks2_selector_0_0_0_0, 1))    
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_waterfallsink2_1, 0))    
        self.connect((self.wbfm_chain_0, 0), (self.blks2_selector_0_0, 2))    
        self.connect((self.wbfm_chain_0_0, 0), (self.blks2_selector_0_0_0, 2))    
        self.connect((self.wbfm_chain_0_0_0, 0), (self.blks2_selector_0_0_0_0, 2))    
Esempio n. 37
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="TX Test")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.sampno = sampno = 32
        self.samp_rate_1 = samp_rate_1 = sampno * 1e3
        self.sigsource = sigsource = 100
        self.samp_rate = samp_rate = int(samp_rate_1)
        self.carfreqno = carfreqno = 1
        self.carfreq_1 = carfreq_1 = 1
        self.bbfreqno = bbfreqno = 1
        self.bbfreq_1 = bbfreq_1 = 1
        self.bb_amp = bb_amp = 0

        ##################################################
        # Blocks
        ##################################################
        self._bbfreqno_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.bbfreqno,
            callback=self.set_bbfreqno,
            label='Baseband Frequency',
            converter=forms.float_converter(),
        )
        self.GridAdd(self._bbfreqno_text_box, 0, 0, 1, 1)
        self._sigsource_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.sigsource,
            callback=self.set_sigsource,
            label='Signal Source',
            choices=[100, 101, 102, 103, 104, 105],
            labels=[
                'Constant', 'Sine Wave', 'Cosine Wave', 'Square', 'Triange',
                'Saw Tooth'
            ],
        )
        self.GridAdd(self._sigsource_chooser, 7, 0, 1, 1)
        self._sampno_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.sampno,
            callback=self.set_sampno,
            label='Sample Rate',
            converter=forms.float_converter(),
        )
        self.GridAdd(self._sampno_text_box, 4, 0, 1, 1)
        self.notebook = self.notebook = wx.Notebook(self.GetWin(),
                                                    style=wx.NB_TOP)
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "Scope Sink")
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "FFT Sink")
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "Histo Sink")
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "Waterfall Sink")
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook),
                              "Constellation Sink")
        self.GridAdd(self.notebook, 8, 0, 1, 1)
        self._carfreqno_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.carfreqno,
            callback=self.set_carfreqno,
            label='Carrier Frequency',
            converter=forms.float_converter(),
        )
        self.GridAdd(self._carfreqno_text_box, 2, 0, 1, 1)
        self._bbfreq_1_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.bbfreq_1,
            callback=self.set_bbfreq_1,
            label=' ',
            choices=[bbfreqno, bbfreqno * 1e3, bbfreqno * 1e6, bbfreqno * 1e9],
            labels=['Hz', 'kHz', 'MHz', 'GHz'],
            style=wx.RA_HORIZONTAL,
        )
        self.GridAdd(self._bbfreq_1_chooser, 1, 0, 1, 1)
        _bb_amp_sizer = wx.BoxSizer(wx.VERTICAL)
        self._bb_amp_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_bb_amp_sizer,
            value=self.bb_amp,
            callback=self.set_bb_amp,
            label='Baseband Amplitude',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._bb_amp_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_bb_amp_sizer,
            value=self.bb_amp,
            callback=self.set_bb_amp,
            minimum=-1,
            maximum=1,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_bb_amp_sizer, 6, 0, 1, 1)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_f(
            self.notebook.GetPage(3).GetWin(),
            baseband_freq=0,
            dynamic_range=100,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=512,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='Waterfall Plot',
            win=window.hanning,
        )
        self.notebook.GetPage(3).Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.notebook.GetPage(0).GetWin(),
            title='Scope Plot',
            sample_rate=samp_rate,
            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.notebook.GetPage(0).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_histosink2_0 = histosink_gl.histo_sink_f(
            self.notebook.GetPage(2).GetWin(),
            title='Histogram Plot',
            num_bins=27,
            frame_size=1000,
        )
        self.notebook.GetPage(2).Add(self.wxgui_histosink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_f(
            self.notebook.GetPage(1).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='FFT Plot',
            peak_hold=False,
            win=window.flattop,
        )
        self.notebook.GetPage(1).Add(self.wxgui_fftsink2_0.win)
        self.wxgui_constellationsink2_0 = constsink_gl.const_sink_c(
            self.notebook.GetPage(4).GetWin(),
            title='Constellation Plot',
            sample_rate=samp_rate,
            frame_rate=5,
            const_size=2048,
            M=4,
            theta=0,
            loop_bw=6.28 / 100.0,
            fmax=0.06,
            mu=0.5,
            gain_mu=0.005,
            symbol_rate=samp_rate / 4.,
            omega_limit=0.005,
        )
        self.notebook.GetPage(4).Add(self.wxgui_constellationsink2_0.win)
        self._samp_rate_1_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.samp_rate_1,
            callback=self.set_samp_rate_1,
            label=' ',
            choices=[sampno, sampno * 1e3, sampno * 1e6, sampno * 1e9],
            labels=['sp/s', 'ksp/s', 'msp/s', 'gsp/s'],
            style=wx.RA_HORIZONTAL,
        )
        self.GridAdd(self._samp_rate_1_chooser, 5, 0, 1, 1)
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=int(samp_rate / 32000),
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self._carfreq_1_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.carfreq_1,
            callback=self.set_carfreq_1,
            label=' ',
            choices=[
                carfreqno, carfreqno * 1e3, carfreqno * 1e6, carfreqno * 1e9
            ],
            labels=['Hz', 'kHz', 'MHz', 'GHz'],
            style=wx.RA_HORIZONTAL,
        )
        self.GridAdd(self._carfreq_1_chooser, 3, 0, 1, 1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            32e3, sigsource, bbfreq_1, bb_amp, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.wxgui_constellationsink2_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.wxgui_fftsink2_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.wxgui_histosink2_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.wxgui_scopesink2_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.wxgui_waterfallsink2_0, 0))
Esempio n. 38
0
    def __init__(self, options, hostname, msgq):
        grc_wxgui.top_block_gui.__init__(self, title="Wifi Rx")
        #_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        #self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.window_size = window_size = 48
        self.sync_length = sync_length = 320
        self.samp_rate = samp_rate = 20e6
        self.lo_offset = lo_offset = 0e6
        self.gain = gain = 20
        self.freq = freq = 5.87e9
        self.chan_est = chan_est = 0

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.samp_rate,
            callback=self.set_samp_rate,
            label="Sample Rate",
            choices=[5e6, 10e6, 20e6],
            labels=["5 MHz", "10 MHz", "20 MHz"],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._samp_rate_chooser)
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "constellation")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "autocorrelation")
        self.Add(self.nb)
        self._lo_offset_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.lo_offset,
            callback=self.set_lo_offset,
            label="LO Offset",
            choices=[0, 6e6, 11e6],
            labels=['0 MHz', '6 MHz', '11 MHz'],
        )
        self.Add(self._lo_offset_chooser)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            label='gain',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_gain_sizer)
        self._freq_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.freq,
            callback=self.set_freq,
            label="Channel",
            choices=[
                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, 5260000000.0, 5280000000.0,
                5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0,
                5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0,
                5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0,
                5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0,
                5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0,
                5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0,
                5920000000.0
            ],
            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',
                ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a',
                ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a',
                '100 | 5500.0 | 11a', '104 | 5520.0 | 11a',
                '108 | 5540.0 | 11a', '112 | 5560.0 | 11a',
                '116 | 5580.0 | 11a', '120 | 5600.0 | 11a',
                '124 | 5620.0 | 11a', '128 | 5640.0 | 11a',
                '132 | 5660.0 | 11a', '136 | 5680.0 | 11a',
                '140 | 5700.0 | 11a', '149 | 5745.0 | 11a',
                '153 | 5765.0 | 11a', '157 | 5785.0 | 11a',
                '161 | 5805.0 | 11a', '165 | 5825.0 | 11a',
                '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'
            ],
        )
        self.Add(self._freq_chooser)
        self._chan_est_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.chan_est,
            callback=self.set_chan_est,
            label='chan_est',
            choices=[0, 1],
            labels=["LMS", "Linear Comb"],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._chan_est_chooser)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.nb.GetPage(1).GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate,
            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.nb.GetPage(1).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_scopesink1 = scopesink2.scope_sink_c(
            self.nb.GetPage(0).GetWin(),
            title="Scope Plot",
            sample_rate=12500,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=True,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.nb.GetPage(0).Add(self.wxgui_scopesink1.win)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
            self.GetWin(),
            unit="%",
            minval=0,
            maxval=100,
            factor=1.0,
            decimal_places=2,
            ref_level=0,
            sample_rate=1,
            number_rate=15,
            average=True,
            avg_alpha=0.02,
            label="Frame Error Rate",
            peak_hold=False,
            show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_0.win)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(
            uhd.tune_request(freq,
                             rf_freq=freq - lo_offset,
                             rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.ieee802_11_ofdm_sync_short_0 = ieee802_11.ofdm_sync_short(
            0.56, 2, False, False)
        self.ieee802_11_ofdm_sync_long_0 = ieee802_11.ofdm_sync_long(
            sync_length, True, False)
        self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(
            False, True)
        self.ieee802_11_ofdm_equalize_symbols_0 = ieee802_11.ofdm_equalize_symbols(
            chan_est, False)
        self.ieee802_11_ofdm_decode_signal_0 = ieee802_11.ofdm_decode_signal(
            False, False, True)  #######Added 3rd argument
        self.ieee802_11_ofdm_decode_mac_0 = ieee802_11.ofdm_decode_mac(
            True, False)  ### _reg
        self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_ff(
            window_size + 16)
        self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc(
            window_size)
        self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True,
                                     1)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, 48)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 64)
        ##self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", "", "52001", 10000, False)

        ##self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.float_t, "packet_len")
        ##The following block is newly added
        self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_CLIENT", hostname,
                                                     str(options.PHYRXport),
                                                     10000)

        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        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)
        self.msg_sink = blocks.message_sink(4, msgq, True)
        ##################################################
        # Connections
        ##################################################

        self.msg_connect((self.ieee802_11_ofdm_decode_mac_0, 'out'),
                         (self.ieee802_11_ofdm_parse_mac_0, 'in'))

        ##self.msg_connect((self.ieee802_11_ofdm_parse_mac_0, 'fer'), (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        ##The following connection is newly added

        ###self.msg_connect(self.ieee802_11_ofdm_parse_mac_0, "fer", self.blocks_socket_pdu_0, "pdus")

        self.msg_connect((self.ieee802_11_ofdm_decode_mac_0, 'out'),
                         (self.blocks_socket_pdu_0, "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.ieee802_11_moving_average_xx_1, 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_ofdm_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_ofdm_sync_short_0, 0))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.ieee802_11_ofdm_sync_short_0, 2))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.wxgui_scopesink2_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.ieee802_11_moving_average_xx_0, 0))
        #self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.wxgui_numbersink2_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.wxgui_scopesink1, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.ieee802_11_ofdm_equalize_symbols_0, 0))
        self.connect((self.ieee802_11_moving_average_xx_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.ieee802_11_moving_average_xx_0, 0),
                     (self.ieee802_11_ofdm_sync_short_0, 1))
        self.connect((self.ieee802_11_moving_average_xx_1, 0),
                     (self.blocks_divide_xx_0, 1))
        ##new added connection
        self.connect((self.ieee802_11_moving_average_xx_1, 0), (self.msg_sink))
        self.connect((self.ieee802_11_ofdm_decode_signal_0, 0),
                     (self.blocks_vector_to_stream_0, 0))
        self.connect((self.ieee802_11_ofdm_decode_signal_0, 0),
                     (self.ieee802_11_ofdm_decode_mac_0, 0))
        self.connect((self.ieee802_11_ofdm_equalize_symbols_0, 0),
                     (self.ieee802_11_ofdm_decode_signal_0, 0))
        self.connect((self.ieee802_11_ofdm_sync_long_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.ieee802_11_ofdm_sync_short_0, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.ieee802_11_ofdm_sync_short_0, 0),
                     (self.ieee802_11_ofdm_sync_long_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_delay_0_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.blocks_multiply_xx_0, 0))
Esempio n. 39
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Stereo FM receiver and RDS Decoder")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.xlate_decim = xlate_decim = 4
        self.samp_rate = samp_rate = 1000000
        self.freq_offset = freq_offset = 250e3
        self.freq = freq = 88.5e6
        self.baseband_rate = baseband_rate = samp_rate/xlate_decim
        self.audio_decim = audio_decim = 4
        self.xlate_bandwidth = xlate_bandwidth = 250e3
        self.volume = volume = 0
        self.loop_bw = loop_bw = 16e3*0 + 18e3*1
        self.gain = gain = 10
        self.freq_tune = freq_tune = freq - freq_offset
        self.audio_rate = audio_rate = 48000
        self.audio_decim_rate = audio_decim_rate = baseband_rate/audio_decim
        self.antenna = antenna = 'TX/RX'

        ##################################################
        # Message Queues
        ##################################################
        gr_rds_data_decoder_0_msgq_out = gr_rds_panel_0_msgq_in = gr.msg_queue(2)

        ##################################################
        # Blocks
        ##################################################
        _volume_sizer = wx.BoxSizer(wx.VERTICAL)
        self._volume_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_volume_sizer,
        	value=self.volume,
        	callback=self.set_volume,
        	label="Volume",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._volume_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_volume_sizer,
        	value=self.volume,
        	callback=self.set_volume,
        	minimum=-20,
        	maximum=10,
        	num_steps=300,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_volume_sizer)
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "BB")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Demod")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "L+R")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Pilot")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "DSBSC")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS Raw")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "L-R")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS")
        self.Add(self.nb)
        _loop_bw_sizer = wx.BoxSizer(wx.VERTICAL)
        self._loop_bw_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_loop_bw_sizer,
        	value=self.loop_bw,
        	callback=self.set_loop_bw,
        	label="Loop BW",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._loop_bw_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_loop_bw_sizer,
        	value=self.loop_bw,
        	callback=self.set_loop_bw,
        	minimum=0,
        	maximum=baseband_rate,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_loop_bw_sizer)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	label="Gain",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	minimum=0,
        	maximum=50,
        	num_steps=50,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_gain_sizer)
        self._freq_offset_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.freq_offset,
        	callback=self.set_freq_offset,
        	label="Freq Offset",
        	converter=forms.float_converter(),
        )
        self.Add(self._freq_offset_text_box)
        _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="Freq",
        	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=87.5e6,
        	maximum=108e6,
        	num_steps=205,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_freq_sizer)
        self._antenna_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.antenna,
        	callback=self.set_antenna,
        	label="Antenna",
        	choices=['TX/RX', 'RX2'],
        	labels=[],
        )
        self.Add(self._antenna_chooser)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	self.nb.GetPage(3).GetWin(),
        	title="Pilot",
        	sample_rate=baseband_rate,
        	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.nb.GetPage(3).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0_0_0_1_0_1 = fftsink2.fft_sink_f(
        	self.nb.GetPage(7).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=-50,
        	ref_scale=2.0,
        	sample_rate=baseband_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="RDS",
        	peak_hold=False,
        )
        self.nb.GetPage(7).Add(self.wxgui_fftsink2_0_0_0_1_0_1.win)
        self.wxgui_fftsink2_0_0_0_1_0_0 = fftsink2.fft_sink_f(
        	self.nb.GetPage(6).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=-50,
        	ref_scale=2.0,
        	sample_rate=baseband_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="L-R",
        	peak_hold=False,
        )
        self.nb.GetPage(6).Add(self.wxgui_fftsink2_0_0_0_1_0_0.win)
        self.wxgui_fftsink2_0_0_0_1_0 = fftsink2.fft_sink_f(
        	self.nb.GetPage(5).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=baseband_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="RDS",
        	peak_hold=False,
        )
        self.nb.GetPage(5).Add(self.wxgui_fftsink2_0_0_0_1_0.win)
        self.wxgui_fftsink2_0_0_0_1 = fftsink2.fft_sink_f(
        	self.nb.GetPage(4).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=baseband_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="DSBSC Sub-carrier",
        	peak_hold=False,
        )
        self.nb.GetPage(4).Add(self.wxgui_fftsink2_0_0_0_1.win)
        self.wxgui_fftsink2_0_0_0 = fftsink2.fft_sink_f(
        	self.nb.GetPage(2).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=audio_decim_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="L+R",
        	peak_hold=False,
        )
        self.nb.GetPage(2).Add(self.wxgui_fftsink2_0_0_0.win)
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_f(
        	self.nb.GetPage(1).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=baseband_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=True,
        	avg_alpha=0.8,
        	title="FM Demod",
        	peak_hold=False,
        )
        self.nb.GetPage(1).Add(self.wxgui_fftsink2_0_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.nb.GetPage(0).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=-30,
        	ref_scale=2.0,
        	sample_rate=baseband_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=True,
        	avg_alpha=0.8,
        	title="Baseband",
        	peak_hold=False,
        )
        self.nb.GetPage(0).Add(self.wxgui_fftsink2_0.win)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(freq_tune, 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.uhd_usrp_source_0.set_antenna(antenna, 0)
        self.rational_resampler_xxx_1 = filter.rational_resampler_fff(
                interpolation=audio_rate,
                decimation=audio_decim_rate,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=audio_rate,
                decimation=audio_decim_rate,
                taps=None,
                fractional_bw=None,
        )
        self.gr_rds_panel_0 = rds.rdsPanel(gr_rds_panel_0_msgq_in, freq, self.GetWin())
        self.Add(self.gr_rds_panel_0)
        self.gr_rds_freq_divider_0 = rds.freq_divider(16)
        self.gr_rds_data_decoder_0 = rds.data_decoder(gr_rds_data_decoder_0_msgq_out)
        self.gr_rds_bpsk_demod_0 = rds.bpsk_demod(audio_decim_rate)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(xlate_decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth/2, 1000)), freq_offset, samp_rate)
        self.fir_filter_xxx_7 = filter.fir_filter_fff(audio_decim, (firdes.low_pass(1,baseband_rate,1.2e3,1.5e3,firdes.WIN_HAMMING)))
        self.fir_filter_xxx_7.declare_sample_delay(0)
        self.fir_filter_xxx_6 = filter.fir_filter_fff(audio_decim, (firdes.low_pass(1,baseband_rate,1.5e3,2e3,firdes.WIN_HAMMING)))
        self.fir_filter_xxx_6.declare_sample_delay(0)
        self.fir_filter_xxx_5 = filter.fir_filter_fff(audio_decim, (firdes.low_pass(1.0,baseband_rate,15e3,1e3,firdes.WIN_HAMMING)))
        self.fir_filter_xxx_5.declare_sample_delay(0)
        self.fir_filter_xxx_4 = filter.fir_filter_fff(1, (firdes.band_pass(1.0,baseband_rate,57e3-3e3,57e3+3e3,3e3,firdes.WIN_HAMMING)))
        self.fir_filter_xxx_4.declare_sample_delay(0)
        self.fir_filter_xxx_3 = filter.fir_filter_fff(1, (firdes.band_pass(1.0,baseband_rate,38e3-15e3/2,38e3+15e3/2,1e3,firdes.WIN_HAMMING)))
        self.fir_filter_xxx_3.declare_sample_delay(0)
        self.fir_filter_xxx_2 = filter.fir_filter_fff(1, (firdes.band_pass(1.0,baseband_rate,19e3-500,19e3+500,1e3,firdes.WIN_HAMMING)))
        self.fir_filter_xxx_2.declare_sample_delay(0)
        self.fir_filter_xxx_1 = filter.fir_filter_fff(audio_decim, (firdes.low_pass(1.0,baseband_rate,15e3,1e3,firdes.WIN_HAMMING)))
        self.fir_filter_xxx_1.declare_sample_delay(0)
        self.fir_filter_xxx_0 = filter.fir_filter_ccc(1, (firdes.low_pass(1.0, baseband_rate, 80e3,35e3,firdes.WIN_HAMMING)))
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((10**(1.*volume/10), ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((10**(1.*volume/10), ))
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.audio_sink_0 = audio.sink(audio_rate, "", True)
        self.analog_pll_freqdet_cf_0 = analog.pll_freqdet_cf(1.0*0 + (loop_bw*2*math.pi/baseband_rate), +(2.0 * math.pi * 90e3 / baseband_rate), -(2.0 * math.pi * 90e3 / baseband_rate))
        self.analog_fm_deemph_1 = analog.fm_deemph(fs=baseband_rate, tau=75e-6)
        self.analog_fm_deemph_0 = analog.fm_deemph(fs=baseband_rate, tau=75e-6)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.uhd_usrp_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.fir_filter_xxx_0, 0))
        self.connect((self.fir_filter_xxx_2, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.fir_filter_xxx_2, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.fir_filter_xxx_2, 0), (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.fir_filter_xxx_2, 0), (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.fir_filter_xxx_3, 0), (self.blocks_multiply_xx_0, 2))
        self.connect((self.fir_filter_xxx_4, 0), (self.blocks_multiply_xx_0_0, 3))
        self.connect((self.fir_filter_xxx_2, 0), (self.blocks_multiply_xx_0_0, 2))
        self.connect((self.fir_filter_xxx_1, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.fir_filter_xxx_2, 0), (self.gr_rds_freq_divider_0, 0))
        self.connect((self.fir_filter_xxx_1, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.fir_filter_xxx_5, 0))
        self.connect((self.gr_rds_freq_divider_0, 0), (self.fir_filter_xxx_7, 0))
        self.connect((self.fir_filter_xxx_7, 0), (self.gr_rds_bpsk_demod_0, 1))
        self.connect((self.digital_diff_decoder_bb_0, 0), (self.gr_rds_data_decoder_0, 0))
        self.connect((self.gr_rds_bpsk_demod_0, 0), (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.fir_filter_xxx_6, 0), (self.gr_rds_bpsk_demod_0, 0))
        self.connect((self.fir_filter_xxx_2, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.fir_filter_xxx_1, 0), (self.wxgui_fftsink2_0_0_0, 0))
        self.connect((self.fir_filter_xxx_3, 0), (self.wxgui_fftsink2_0_0_0_1, 0))
        self.connect((self.fir_filter_xxx_4, 0), (self.wxgui_fftsink2_0_0_0_1_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0), (self.fir_filter_xxx_6, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.wxgui_fftsink2_0_0_0_1_0_0, 0))
        self.connect((self.fir_filter_xxx_5, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.fir_filter_xxx_5, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.fir_filter_xxx_0, 0), (self.analog_pll_freqdet_cf_0, 0))
        self.connect((self.analog_pll_freqdet_cf_0, 0), (self.wxgui_fftsink2_0_0, 0))
        self.connect((self.analog_pll_freqdet_cf_0, 0), (self.fir_filter_xxx_1, 0))
        self.connect((self.analog_pll_freqdet_cf_0, 0), (self.fir_filter_xxx_2, 0))
        self.connect((self.analog_pll_freqdet_cf_0, 0), (self.fir_filter_xxx_4, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.analog_fm_deemph_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0), (self.wxgui_fftsink2_0_0_0_1_0_1, 0))
        self.connect((self.analog_fm_deemph_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0), (self.audio_sink_0, 1))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.rational_resampler_xxx_1, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.analog_fm_deemph_1, 0))
        self.connect((self.analog_fm_deemph_1, 0), (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.analog_pll_freqdet_cf_0, 0), (self.fir_filter_xxx_3, 0))
Esempio n. 40
0
    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.tx_freq = tx_freq = 2.407e9
        self.samp_rate = samp_rate = 32e3

        ##################################################
        # Blocks
        ##################################################
        self._tx_freq_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.tx_freq,
        	callback=self.set_tx_freq,
        	label="tx_freq",
        	choices=[2.407e9, 2.41e9, 2.413e9, 2.416e9, 2.419e9, 2.422e9, 2.425e9, 2.427e9, 2.429e9, 2.431e9, 2.433e9, 2.436e9, 2.439e9, 2.441e9, 2.443e9,2.422e9, 2.446e9, 2.449e9, 2.452e9, 2.455e9,  2.458e9, 2.460e9, 2.463e9, 2.466e9, 2.469e9, 2.472e9, 2.475e9, 2.478e9 ],
        	labels=[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],
        )
        self.Add(self._tx_freq_chooser)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("addr=192.168.10.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0.set_samp_rate(32e3)
        self.uhd_usrp_sink_0.set_center_freq(tx_freq, 0)
        self.uhd_usrp_sink_0.set_gain(20, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
        self.uhd_usrp_sink_0.set_bandwidth(3e6, 0)
        self.digital_gfsk_mod_0 = digital.gfsk_mod(
        	samples_per_symbol=2,
        	sensitivity=1.0,
        	bt=0.35,
        	verbose=False,
        	log=False,
        )
        self.blocks_vector_source_x_0 = blocks.vector_source_b((1,0,1,0), True, 1, [])
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder(
        		samples_per_symbol=1,
        		bits_per_symbol=1,
        		preamble="",
        		access_code="",
        		pad_for_usrp=True,
        	),
        	payload_length=0,
        )
        self.Spread_ds_spreader_0 = Spread.ds_spreader(2, (1, 1, 0, 1), (1, 1, 1))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.Spread_ds_spreader_0, 0), (self.digital_gfsk_mod_0, 0))    
        self.connect((self.blks2_packet_encoder_0, 0), (self.Spread_ds_spreader_0, 0))    
        self.connect((self.blocks_vector_source_x_0, 0), (self.blks2_packet_encoder_0, 0))    
        self.connect((self.digital_gfsk_mod_0, 0), (self.uhd_usrp_sink_0, 0))    
Esempio n. 41
0
        def __init__(self):
                grc_wxgui.top_block_gui.__init__(self, title="gr-kx3")
                _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
                self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))
                ##################################################
                # Variables
                ##################################################
                self.rig_freq = rig_freq = float(pexpect.run("rigctl -m 2 f"))
                self.rigctl = pexpect.spawn("rigctl -m 2")
                self.rigctl.timeout = 2.5
                self.prefix = prefix = "~/grdata"
                self.sync_freq = sync_freq = 3
                self.samp_rate = samp_rate
                self.recfile = recfile = prefix + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat"
                self.freq = freq = rig_freq
                self.click_freq = click_freq = 0
                self.step_up = step_up = 1
                self.dwell_up = dwell_up = 1
                self.step_down = step_down = 1
                self.dwell_down = dwell_down = 1
                self.step_size = step_size = 250
                self.ctq_step = self.step_size
                
                # calculate the number of FFT bins based on the width of the charts
                log_width = math.log(gui_scale * plot_width,2)
                if(0 != (log_width - int(log_width))):
                	log_width = log_width + 1
                num_bins = pow(2, int(log_width))
                print  "Setting number of FFT bins to:" + str(num_bins)
                
                ##################################################
                # Blocks
                ##################################################
                self.nb0 = self.nb0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
                self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "Waterfall")
                self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "FFT")
                self.GridAdd(self.nb0, 2, 0, 5, 8)
                self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
                        self.nb0.GetPage(0).GetWin(),
                        baseband_freq=rig_freq,
                        dynamic_range=20,
                        ref_level=-80,
                        ref_scale=1.0,
                        sample_rate=samp_rate,
                        fft_size=num_bins,
                        fft_rate=30,
                        average=False,
                        avg_alpha=None,
                        title="Waterfall Plot",
                        win=window.hamming,
                        size=(plot_width*gui_scale,plot_height*gui_scale),
                )
                self.nb0.GetPage(0).Add(self.wxgui_waterfallsink2_0.win)
                def wxgui_waterfallsink2_0_callback(x, y):
                        self.set_click_freq(x)
                
                self.wxgui_waterfallsink2_0.set_callback(wxgui_waterfallsink2_0_callback)
                self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
                        self.nb0.GetPage(1).GetWin(),
                        baseband_freq=rig_freq,
                        y_per_div=10,
                        y_divs=12,
                        ref_level=0,
                        ref_scale=2.0,
                        sample_rate=samp_rate,
                        fft_size=num_bins,
                        fft_rate=10,
                        average=True,
                        avg_alpha=None,
                        title="FFT Plot",
                        peak_hold=True,
                        win=window.flattop,
                        size=(plot_width*gui_scale,plot_height*gui_scale),
                )
                self.nb0.GetPage(1).Add(self.wxgui_fftsink2_0.win)
                self.gr_float_to_complex_0 = blocks.float_to_complex(1)
                self._freq_text_box = forms.text_box(
                        parent=self.GetWin(),
                        value=self.freq,
                        callback=self.set_text_freq,
                        label="  Frequency (Hz)",
                        converter=forms.int_converter(),
                )
                self.GridAdd(self._freq_text_box, 1, 0, 1, 1)
                self._sync_freq_chooser = forms.drop_down(
                        parent=self.GetWin(),
                        value=self.sync_freq,
                        callback=self.set_sync_freq,
                        label="",
                        choices=[1,2,3],
                        labels=["Entry","Track","Track & Click"],
                )
                self.GridAdd(self._sync_freq_chooser, 1, 1, 1, 1)
                        
                self._dwell_down_chooser = forms.button(
                        parent=self.GetWin(),
                        value=self.dwell_down,
                        callback=self.set_dwell_down,
                        label="",
                        choices=[1],
                        labels=["FFT Down"],
                )
                self.GridAdd(self._dwell_down_chooser, 1, 2, 1, 1)		
                
                self._dwell_up_chooser = forms.button(
                        parent=self.GetWin(),
                        value=self.dwell_up,
                        callback=self.set_dwell_up,
                        label="",
                        choices=[1],
                        labels=["FFT Up"],
                )
                self.GridAdd(self._dwell_up_chooser, 1, 3, 1, 1)                
                
                self._step_size_chooser = forms.drop_down(
                        parent=self.GetWin(),
                        value=self.step_size,
                        callback=self.set_step_size,
                        label="\tStep",
                        choices=[1000000,100000,10000,1000,500,250,125,100,10],
                        labels=["1MHz","100kHz","10kHz","1kHz","500Hz","250Hz","125Hz","100Hz","10Hz"],
                )
                self.GridAdd(self._step_size_chooser, 1, 4, 1, 1)

                self._step_down_chooser = forms.button(
                        parent=self.GetWin(),
                        value=self.step_down,
                        callback=self.set_step_down,
                        label="",
                        choices=[1],
                        labels=["Step Down"],
                )
                self.GridAdd(self._step_down_chooser, 1, 5, 1, 1)		
                
                self._step_up_chooser = forms.button(
                        parent=self.GetWin(),
                        value=self.step_up,
                        callback=self.set_step_up,
                        label="",
                        choices=[1],
                        labels=["Step Up"],
                )
                self.GridAdd(self._step_up_chooser, 1, 6, 1, 1)

                self.audio_source_0 = audio.source(samp_rate, iq_device, True)
                self.dc_blocker_xx_0 = filter.dc_blocker_cc(dc_correction_length, True)
                
                ##################################################
                # Connections
                ##################################################
                self.connect((self.audio_source_0, 1), (self.gr_float_to_complex_0, 0))
                self.connect((self.audio_source_0, 0), (self.gr_float_to_complex_0, 1))
                self.connect((self.gr_float_to_complex_0, 0), (self.dc_blocker_xx_0, 0))
                self.connect((self.dc_blocker_xx_0, 0), (self.wxgui_waterfallsink2_0, 0))
                self.connect((self.dc_blocker_xx_0, 0), (self.wxgui_fftsink2_0, 0))  
                             
                self.lock = RLock()
                self.vfo_poll_skip = 0
                self.set_rig_vfo = False
                self.quit = False
                _poll_vfo_thread = Thread(target=self._poll_vfo_probe)
                _poll_vfo_thread.daemon = True
                _poll_vfo_thread.start()
Esempio n. 42
0
            parent=self.GetWin(),
            label='+',
            callback=incfreqfine,)

    self.btndecfreqfine = forms.single_button(
            sizer=freq_sizer,
            width=25,
            parent=self.GetWin(),
            label='-',
            callback=decfreqfine,)

    self.channel_combo_box = forms.drop_down(
        sizer=freq_sizer,
        parent=self.GetWin(),
        width=55,
        value='0B',
        choices=combo_channels,
        label="Channel",
        
    )

    self.samplerate_text_box = forms.text_box(
        sizer=freq_sizer,
        width=40,
        parent=self.GetWin(),
        value=self.samprate,
        callback=set_samp_rate,
        label="Samp",
        proportion=0,
        converter=forms.float_converter(),
    )
Esempio n. 43
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Wifi Transceiver Juan")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 15
        self.samp_rate_0 = samp_rate_0 = 20e6
        self.samp_rate = samp_rate = 10e6
        self.rx_gain = rx_gain = 5
        self.oversampling = oversampling = 4
        self.mult = mult = 0.38
        self.lo_offset = lo_offset = 0
        self.freq = freq = 5.89e9
        self.encoding = encoding = 0

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.samp_rate,
            callback=self.set_samp_rate,
            label="Sample Rate",
            choices=[5e6, 10e6, 20e6],
            labels=["5MHz", "10 MHz", "20 MHz"],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._samp_rate_chooser)
        _mult_sizer = wx.BoxSizer(wx.VERTICAL)
        self._mult_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_mult_sizer,
            value=self.mult,
            callback=self.set_mult,
            label='mult',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._mult_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_mult_sizer,
            value=self.mult,
            callback=self.set_mult,
            minimum=0,
            maximum=1,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_mult_sizer)
        self._encoding_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.encoding,
            callback=self.set_encoding,
            label="Encoding",
            choices=[0, 1, 2, 3, 4, 5, 6, 7],
            labels=[
                "BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2",
                "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"
            ],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._encoding_chooser)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
            self.GetWin(),
            title="Scope Plot",
            sample_rate=5000,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=True,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.wifi_phy_hier_0 = wifi_phy_hier(
            chan_est=0,
            encoding=0,
        )
        _tx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tx_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_tx_gain_sizer,
            value=self.tx_gain,
            callback=self.set_tx_gain,
            label='tx_gain',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._tx_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_tx_gain_sizer,
            value=self.tx_gain,
            callback=self.set_tx_gain,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_tx_gain_sizer)
        _rx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rx_gain_sizer,
            value=self.rx_gain,
            callback=self.set_rx_gain,
            label='rx_gain',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rx_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rx_gain_sizer,
            value=self.rx_gain,
            callback=self.set_rx_gain,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_rx_gain_sizer)
        self._lo_offset_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.lo_offset,
            callback=self.set_lo_offset,
            label="LO Offset",
            choices=[0, 6e6, 11e6],
            labels=['0 MHz', '6 MHz', '11 MHz'],
        )
        self.Add(self._lo_offset_chooser)
        self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(
            ([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]),
            ([0x30, 0x14, 0x4a, 0xe6, 0x46, 0xe4]),
            ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]))
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(True)
        self._freq_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.freq,
            callback=self.set_freq,
            label="Channel",
            choices=[
                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, 5260000000.0, 5280000000.0,
                5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0,
                5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0,
                5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0,
                5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0,
                5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0,
                5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0,
                5920000000.0
            ],
            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',
                ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a',
                ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a',
                '100 | 5500.0 | 11a', '104 | 5520.0 | 11a',
                '108 | 5540.0 | 11a', '112 | 5560.0 | 11a',
                '116 | 5580.0 | 11a', '120 | 5600.0 | 11a',
                '124 | 5620.0 | 11a', '128 | 5640.0 | 11a',
                '132 | 5660.0 | 11a', '136 | 5680.0 | 11a',
                '140 | 5700.0 | 11a', '149 | 5745.0 | 11a',
                '153 | 5765.0 | 11a', '157 | 5785.0 | 11a',
                '161 | 5805.0 | 11a', '165 | 5825.0 | 11a',
                '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'
            ],
        )
        self.Add(self._freq_chooser)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000,
                                                 10000)
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=.5**.5,
            frequency_offset=0,
            epsilon=1.0,
            taps=(1.0, ),
            noise_seed=0,
            block_tags=False)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_char * 1,
                                                 "192.168.200.2", 1234, 100,
                                                 True)
        self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap0", 440, False)
        self.blocks_throttle_0 = blocks.throttle(
            gr.sizeof_char * 1,
            2 * 4e3 + 0 * samp_rate / 40 / (oversampling * 8 * 2), True)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((mult, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1,
            "/media/juan/d6aba572-c85c-40cc-9258-ae1538dfb8c5/home/juan/Music/de_mi.mp3",
            True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'),
                         (self.ieee802_11_ether_encap_0, 'from tap'))
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to tap'),
                         (self.blocks_tuntap_pdu_0, 'pdus'))
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to wifi'),
                         (self.ieee802_11_ofdm_mac_0, 'app in'))
        self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'),
                         (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'),
                         (self.wifi_phy_hier_0, 'mac_in'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.ieee802_11_ether_encap_0, 'from wifi'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.ieee802_11_ofdm_mac_0, 'phy in'))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.foo_packet_pad2_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_udp_sink_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.wifi_phy_hier_0, 0))
        self.connect((self.foo_packet_pad2_0, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.wifi_phy_hier_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.wifi_phy_hier_0, 1), (self.wxgui_scopesink2_0, 0))
Esempio n. 44
0
    def _generate_panel(self):
        # Rx LNA Selection
        self.rx_lna_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=umtrx_lms.lms_get_rx_lna(self.lms),
            callback=self.set_rx_lna,
            label="Rx LNA",
            choices=[0, 1, 2, 3],
            labels=["Disabled","LNA1","LNA2", "LNA3"],
#            style=wx.RA_HORIZONTAL,
            )
        self.GridAdd(self.rx_lna_chooser, 0, 0, 1, 1)

        # Rx LNA Mode
        self.rx_lna_gain_mode_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=umtrx_lms.lms_get_rx_lna_gain(self.lms),
            callback=self.set_rx_lna_gain_mode,
            label="Rx LNA Mode",
            choices=[3, 2, 1],
            labels=["3: Norm","3: -6dB","1: Bypass"],
#            style=wx.RA_HORIZONTAL,
            )
        self.GridAdd(self.rx_lna_gain_mode_chooser, 0, 1, 1, 1)

        # Rx LPF bandwidth
        self.rx_lna_gain_mode_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=umtrx_lms.lms_get_rx_lpf_raw(self.lms),
            callback=self.set_rx_lpf,
            label="Rx LNA LPF",
            choices=[15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],
            labels=[0.75, 0.875, 1.25, 1.375, 1.5, 1.92, 2.5, 2.75, 3, 3.5, 4.375, 5, 6, 7, 10, 14],
#            style=wx.RA_HORIZONTAL,
            )
        self.GridAdd(self.rx_lna_gain_mode_chooser, 0, 2, 1, 1)
        
        # Rx VGA1 gain
        self.rx_vga1gain = umtrx_lms.lms_get_rx_vga1gain_int(self.lms)
        hbox = wx.BoxSizer(wx.HORIZONTAL)
        self.rx_vga1gain_slider = form.slider_field(
            parent=self.GetWin(), sizer=hbox,
            value=self.rx_vga1gain,
            callback=self.set_rx_vga1gain,
            label="Rx VGA1 gain (raw)\n120=30dB, 102=19dB, 2=5dB",
            min=0, max=127,
            )
        self.GridAdd(hbox, 1, 0, 1, 4)
        
        # Rx VGA2 gain
        self.rx_vga2gain = umtrx_lms.lms_get_rx_vga2gain(self.lms)
        hbox = wx.BoxSizer(wx.HORIZONTAL)
        self.rx_vga2gain_slider = form.slider_field(
            parent=self.GetWin(), sizer=hbox,
            value=self.rx_vga2gain,
            callback=self.set_rx_vga2gain,
            label="\nRx VGA2 gain (dB)",
            min=0, max=30,# Not recommended to use above 30
            )
        self.GridAdd(hbox, 1, 4, 1, 4)
        
        # Tx VGA1 DC I offset
        self.tx_vga1dc_i_int = umtrx_lms.lms_get_vga1dc_i_int(self.lms)
        hbox = wx.BoxSizer(wx.HORIZONTAL)
        self.tx_vga1dc_i_int_slider = form.slider_field(
            parent=self.GetWin(), sizer=hbox,
            value=self.tx_vga1dc_i_int,
            callback=self.set_tx_vga1dc_i_int,
            label="\nTx VGA1 DC I offset (raw)",
            min=0, max=255,
            )
        self.GridAdd(hbox, 3, 0, 1, 4)
        
        # Tx VGA1 DC Q offset
        self.tx_vga1dc_q_int = umtrx_lms.lms_get_vga1dc_q_int(self.lms)
        hbox = wx.BoxSizer(wx.HORIZONTAL)
        self.tx_vga1dc_q_int_slider = form.slider_field(
            parent=self.GetWin(), sizer=hbox,
            value=self.tx_vga1dc_q_int,
            callback=self.set_tx_vga1dc_q_int,
            label="\nTx VGA1 DC Q offset (raw)",
            min=0, max=255,
            )
        self.GridAdd(hbox, 3, 4, 1, 4)

        # Tx VGA1 gain
        self.tx_vga1gain = umtrx_lms.lms_get_tx_vga1gain(self.lms)
        hbox = wx.BoxSizer(wx.HORIZONTAL)
        self.tx_vga1gain_slider = form.slider_field(
            parent=self.GetWin(), sizer=hbox,
            value=self.tx_vga1gain,
            callback=self.set_tx_vga1gain,
            label="\nTx VGA1 gain (dB)",
            min=-35, max=-4,
            )
        self.GridAdd(hbox, 4, 0, 1, 4)

        # Tx VGA2 gain
        self.tx_vga2gain = umtrx_lms.lms_get_tx_vga2gain(self.lms)
        hbox = wx.BoxSizer(wx.HORIZONTAL)
        self.tx_vga2gain_slider = form.slider_field(
            parent=self.GetWin(), sizer=hbox,
            value=self.tx_vga2gain,
            callback=self.set_tx_vga2gain,
            label="\nTx VGA2 gain (dB)",
            min=0, max=25,
            )
        self.GridAdd(hbox, 4, 4, 1, 4)
Esempio n. 45
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(
            self, title="Stereo FM receiver and RDS Decoder")

        ##################################################
        # Variables
        ##################################################
        self.xlate_decim = xlate_decim = 4
        self.samp_rate = samp_rate = 1000000
        self.freq_offset = freq_offset = 250e3
        self.freq = freq = 88.5e6
        self.baseband_rate = baseband_rate = samp_rate / xlate_decim
        self.audio_decim = audio_decim = 4
        self.xlate_bandwidth = xlate_bandwidth = 250e3
        self.volume = volume = 0
        self.loop_bw = loop_bw = 16e3 * 0 + 18e3 * 1
        self.gain = gain = 10
        self.freq_tune = freq_tune = freq - freq_offset
        self.audio_rate = audio_rate = 48000
        self.audio_decim_rate = audio_decim_rate = baseband_rate / audio_decim
        self.antenna = antenna = 'TX/RX'

        ##################################################
        # Message Queues
        ##################################################
        gr_rds_data_decoder_0_msgq_out = gr_rds_panel_0_msgq_in = gr.msg_queue(
            2)

        ##################################################
        # Blocks
        ##################################################
        _volume_sizer = wx.BoxSizer(wx.VERTICAL)
        self._volume_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_volume_sizer,
            value=self.volume,
            callback=self.set_volume,
            label="Volume",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._volume_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_volume_sizer,
            value=self.volume,
            callback=self.set_volume,
            minimum=-20,
            maximum=10,
            num_steps=300,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_volume_sizer)
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "BB")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Demod")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "L+R")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Pilot")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "DSBSC")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS Raw")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "L-R")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS")
        self.Add(self.nb)
        _loop_bw_sizer = wx.BoxSizer(wx.VERTICAL)
        self._loop_bw_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_loop_bw_sizer,
            value=self.loop_bw,
            callback=self.set_loop_bw,
            label="Loop BW",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._loop_bw_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_loop_bw_sizer,
            value=self.loop_bw,
            callback=self.set_loop_bw,
            minimum=0,
            maximum=baseband_rate,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_loop_bw_sizer)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            label="Gain",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            minimum=0,
            maximum=50,
            num_steps=50,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_gain_sizer)
        self._freq_offset_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.freq_offset,
            callback=self.set_freq_offset,
            label="Freq Offset",
            converter=forms.float_converter(),
        )
        self.Add(self._freq_offset_text_box)
        _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="Freq",
            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=87.5e6,
            maximum=108e6,
            num_steps=205,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_freq_sizer)
        self._antenna_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.antenna,
            callback=self.set_antenna,
            label="Antenna",
            choices=['TX/RX', 'RX2'],
            labels=[],
        )
        self.Add(self._antenna_chooser)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.nb.GetPage(3).GetWin(),
            title="Pilot",
            sample_rate=baseband_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=gr.gr_TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.nb.GetPage(3).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0_0_0_1_0_1 = fftsink2.fft_sink_f(
            self.nb.GetPage(7).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=-50,
            ref_scale=2.0,
            sample_rate=baseband_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="RDS",
            peak_hold=False,
        )
        self.nb.GetPage(7).Add(self.wxgui_fftsink2_0_0_0_1_0_1.win)
        self.wxgui_fftsink2_0_0_0_1_0_0 = fftsink2.fft_sink_f(
            self.nb.GetPage(6).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=-50,
            ref_scale=2.0,
            sample_rate=baseband_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="L-R",
            peak_hold=False,
        )
        self.nb.GetPage(6).Add(self.wxgui_fftsink2_0_0_0_1_0_0.win)
        self.wxgui_fftsink2_0_0_0_1_0 = fftsink2.fft_sink_f(
            self.nb.GetPage(5).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=baseband_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="RDS",
            peak_hold=False,
        )
        self.nb.GetPage(5).Add(self.wxgui_fftsink2_0_0_0_1_0.win)
        self.wxgui_fftsink2_0_0_0_1 = fftsink2.fft_sink_f(
            self.nb.GetPage(4).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=baseband_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="DSBSC Sub-carrier",
            peak_hold=False,
        )
        self.nb.GetPage(4).Add(self.wxgui_fftsink2_0_0_0_1.win)
        self.wxgui_fftsink2_0_0_0 = fftsink2.fft_sink_f(
            self.nb.GetPage(2).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=audio_decim_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="L+R",
            peak_hold=False,
        )
        self.nb.GetPage(2).Add(self.wxgui_fftsink2_0_0_0.win)
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_f(
            self.nb.GetPage(1).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=baseband_rate,
            fft_size=1024,
            fft_rate=15,
            average=True,
            avg_alpha=0.8,
            title="FM Demod",
            peak_hold=False,
        )
        self.nb.GetPage(1).Add(self.wxgui_fftsink2_0_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.nb.GetPage(0).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=-30,
            ref_scale=2.0,
            sample_rate=baseband_rate,
            fft_size=1024,
            fft_rate=15,
            average=True,
            avg_alpha=0.8,
            title="Baseband",
            peak_hold=False,
        )
        self.nb.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_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(freq_tune, 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.uhd_usrp_source_0.set_antenna(antenna, 0)
        self.gr_rds_panel_0 = rds.rdsPanel(gr_rds_panel_0_msgq_in, freq,
                                           self.GetWin())
        self.Add(self.gr_rds_panel_0)
        self.gr_rds_freq_divider_0 = rds.freq_divider(16)
        self.gr_rds_data_decoder_0 = rds.data_decoder(
            gr_rds_data_decoder_0_msgq_out)
        self.gr_rds_bpsk_demod_0 = rds.bpsk_demod(audio_decim_rate)
        self.gr_pll_freqdet_cf_0 = gr.pll_freqdet_cf(
            1.0 * 0 + (loop_bw * 2 * math.pi / baseband_rate),
            +(2.0 * math.pi * 90e3 / baseband_rate),
            -(2.0 * math.pi * 90e3 / baseband_rate))
        self.gr_multiply_const_vxx_0_0 = gr.multiply_const_vff(
            (10**(1. * volume / 10), ))
        self.gr_multiply_const_vxx_0 = gr.multiply_const_vff(
            (10**(1. * volume / 10), ))
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            xlate_decim,
            (firdes.low_pass(1, samp_rate, xlate_bandwidth / 2, 1000)),
            freq_offset, samp_rate)
        self.fir_filter_xxx_7 = filter.fir_filter_fff(
            audio_decim, (firdes.low_pass(1, baseband_rate, 1.2e3, 1.5e3,
                                          firdes.WIN_HAMMING)))
        self.fir_filter_xxx_6 = filter.fir_filter_fff(
            audio_decim, (firdes.low_pass(1, baseband_rate, 1.5e3, 2e3,
                                          firdes.WIN_HAMMING)))
        self.fir_filter_xxx_5 = filter.fir_filter_fff(
            audio_decim, (firdes.low_pass(1.0, baseband_rate, 15e3, 1e3,
                                          firdes.WIN_HAMMING)))
        self.fir_filter_xxx_4 = filter.fir_filter_fff(
            1, (firdes.band_pass(1.0, baseband_rate, 57e3 - 3e3, 57e3 + 3e3,
                                 3e3, firdes.WIN_HAMMING)))
        self.fir_filter_xxx_3 = filter.fir_filter_fff(
            1, (firdes.band_pass(1.0, baseband_rate, 38e3 - 15e3 / 2,
                                 38e3 + 15e3 / 2, 1e3, firdes.WIN_HAMMING)))
        self.fir_filter_xxx_2 = filter.fir_filter_fff(
            1, (firdes.band_pass(1.0, baseband_rate, 19e3 - 500, 19e3 + 500,
                                 1e3, firdes.WIN_HAMMING)))
        self.fir_filter_xxx_1 = filter.fir_filter_fff(
            audio_decim, (firdes.low_pass(1.0, baseband_rate, 15e3, 1e3,
                                          firdes.WIN_HAMMING)))
        self.fir_filter_xxx_0 = filter.fir_filter_ccc(1, (firdes.low_pass(
            1.0, baseband_rate, 80e3, 35e3, firdes.WIN_HAMMING)))
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.blks2_rational_resampler_xxx_0_0 = blks2.rational_resampler_fff(
            interpolation=audio_rate,
            decimation=audio_decim_rate,
            taps=None,
            fractional_bw=None,
        )
        self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff(
            interpolation=audio_rate,
            decimation=audio_decim_rate,
            taps=None,
            fractional_bw=None,
        )
        self.blks2_fm_deemph_0_0_0 = blks2.fm_deemph(fs=baseband_rate,
                                                     tau=75e-6)
        self.blks2_fm_deemph_0_0 = blks2.fm_deemph(fs=baseband_rate, tau=75e-6)
        self.audio_sink_0 = audio.sink(audio_rate, "", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.fir_filter_xxx_0, 0))
        self.connect((self.fir_filter_xxx_0, 0), (self.gr_pll_freqdet_cf_0, 0))
        self.connect((self.gr_pll_freqdet_cf_0, 0), (self.fir_filter_xxx_1, 0))
        self.connect((self.gr_pll_freqdet_cf_0, 0), (self.fir_filter_xxx_2, 0))
        self.connect((self.gr_pll_freqdet_cf_0, 0), (self.fir_filter_xxx_4, 0))
        self.connect((self.fir_filter_xxx_2, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.fir_filter_xxx_2, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.fir_filter_xxx_2, 0),
                     (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.fir_filter_xxx_2, 0),
                     (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.fir_filter_xxx_3, 0),
                     (self.blocks_multiply_xx_0, 2))
        self.connect((self.fir_filter_xxx_4, 0),
                     (self.blocks_multiply_xx_0_0, 3))
        self.connect((self.fir_filter_xxx_2, 0),
                     (self.blocks_multiply_xx_0_0, 2))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.wxgui_fftsink2_0, 0))
        self.connect((self.fir_filter_xxx_1, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.fir_filter_xxx_2, 0),
                     (self.gr_rds_freq_divider_0, 0))
        self.connect((self.fir_filter_xxx_1, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.fir_filter_xxx_5, 0))
        self.connect((self.gr_pll_freqdet_cf_0, 0), (self.fir_filter_xxx_3, 0))
        self.connect((self.gr_multiply_const_vxx_0, 0),
                     (self.blks2_rational_resampler_xxx_0, 0))
        self.connect((self.blks2_rational_resampler_xxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blks2_rational_resampler_xxx_0_0, 0),
                     (self.audio_sink_0, 1))
        self.connect((self.gr_multiply_const_vxx_0_0, 0),
                     (self.blks2_rational_resampler_xxx_0_0, 0))
        self.connect((self.gr_rds_freq_divider_0, 0),
                     (self.fir_filter_xxx_7, 0))
        self.connect((self.fir_filter_xxx_7, 0), (self.gr_rds_bpsk_demod_0, 1))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.gr_rds_data_decoder_0, 0))
        self.connect((self.gr_rds_bpsk_demod_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.fir_filter_xxx_6, 0), (self.gr_rds_bpsk_demod_0, 0))
        self.connect((self.fir_filter_xxx_2, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.fir_filter_xxx_1, 0),
                     (self.wxgui_fftsink2_0_0_0, 0))
        self.connect((self.fir_filter_xxx_3, 0),
                     (self.wxgui_fftsink2_0_0_0_1, 0))
        self.connect((self.fir_filter_xxx_4, 0),
                     (self.wxgui_fftsink2_0_0_0_1_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.fir_filter_xxx_6, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.wxgui_fftsink2_0_0_0_1_0_0, 0))
        self.connect((self.fir_filter_xxx_5, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.fir_filter_xxx_5, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.wxgui_fftsink2_0_0_0_1_0_1, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.blks2_fm_deemph_0_0, 0))
        self.connect((self.blks2_fm_deemph_0_0, 0),
                     (self.gr_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blks2_fm_deemph_0_0_0, 0))
        self.connect((self.blks2_fm_deemph_0_0_0, 0),
                     (self.gr_multiply_const_vxx_0, 0))
        self.connect((self.gr_pll_freqdet_cf_0, 0),
                     (self.wxgui_fftsink2_0_0, 0))
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="HAM 2m FM Receiver")

        ##################################################
        # Variables
        ##################################################
        self.repeaters = repeaters = struct({"a": 145270000, "b": 145410000, "c": 146685000, "d": 147030000, "e": 441700000, })
        self.repeater_chooser = repeater_chooser = repeaters.e
        self.variable_static_text_0 = variable_static_text_0 = repeater_chooser
        self.samp_rate = samp_rate = 2.4e6
        self.frequency = frequency = 441.700e6

        ##################################################
        # Blocks
        ##################################################
        self._repeater_chooser_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.repeater_chooser,
        	callback=self.set_repeater_chooser,
        	label='repeater_chooser',
        	choices=[repeaters.a, repeaters.b, repeaters.c, repeaters.d, repeaters.e],
        	labels=["W3PVI", "KD3WT", "WM3PEN", "W3QV", "W3WAN"],
        )
        self.Add(self._repeater_chooser_chooser)
        self.wxgui_fftsink2_0_1 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=repeater_chooser,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="RF Spectrum",
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0_1.win)
        self._variable_static_text_0_static_text = forms.static_text(
        	parent=self.GetWin(),
        	value=self.variable_static_text_0,
        	callback=self.set_variable_static_text_0,
        	label='variable_static_text_0',
        	converter=forms.float_converter(),
        )
        self.Add(self._variable_static_text_0_static_text)
        self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "rtl=0" )
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(repeater_chooser, 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(True, 0)
        self.rtlsdr_source_0.set_gain(10, 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.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
                interpolation=500,
                decimation=2400,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=48,
                decimation=50,
                taps=None,
                fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, 500000, 100000, 8000, firdes.WIN_HAMMING, 6.76))
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=50,
        	quad_rate=500000,
        	tau=75e-6,
        	max_dev=10e3,
          )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.analog_nbfm_rx_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.rational_resampler_xxx_1, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.rational_resampler_xxx_1, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0_1, 0))    
Esempio n. 47
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="AM Receiver")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 64e6 / 256
        self.offset_fine = offset_fine = 0
        self.offset_coarse = offset_coarse = 0
        self.freq = freq = 15000000
        self.LO = LO = 0
        self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(
            1, samp_rate, 125000, 25000, firdes.WIN_HAMMING, 6.76
        )
        self.width = width = 10000
        self.trans = trans = 1500
        self.rx_freq = rx_freq = LO + freq + (offset_coarse + offset_fine)
        self.rf_gain = rf_gain = 10
        self.lo_freq = lo_freq = LO
        self.display_selector = display_selector = 0
        self.af_gain = af_gain = 0.200

        ##################################################
        # Blocks
        ##################################################
        _width_sizer = wx.BoxSizer(wx.VERTICAL)
        self._width_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_width_sizer,
            value=self.width,
            callback=self.set_width,
            label="Filter",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._width_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_width_sizer,
            value=self.width,
            callback=self.set_width,
            minimum=2000,
            maximum=40000,
            num_steps=760,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_width_sizer, 7, 0, 1, 1)
        _trans_sizer = wx.BoxSizer(wx.VERTICAL)
        self._trans_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_trans_sizer,
            value=self.trans,
            callback=self.set_trans,
            label="Trans",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._trans_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_trans_sizer,
            value=self.trans,
            callback=self.set_trans,
            minimum=500,
            maximum=5000,
            num_steps=900,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_trans_sizer, 8, 0, 1, 1)
        self._rx_freq_static_text = forms.static_text(
            parent=self.GetWin(),
            value=self.rx_freq,
            callback=self.set_rx_freq,
            label="Receive",
            converter=forms.float_converter(),
        )
        self.GridAdd(self._rx_freq_static_text, 5, 3, 1, 1)
        _rf_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rf_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rf_gain_sizer,
            value=self.rf_gain,
            callback=self.set_rf_gain,
            label="RF",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rf_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rf_gain_sizer,
            value=self.rf_gain,
            callback=self.set_rf_gain,
            minimum=0,
            maximum=50,
            num_steps=50,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_rf_gain_sizer, 7, 1, 1, 1)
        self._display_selector_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.display_selector,
            callback=self.set_display_selector,
            label="Spectrum",
            choices=[0, 1],
            labels=["Baseband", "USRP"],
        )
        self.GridAdd(self._display_selector_chooser, 5, 0, 1, 1)
        _af_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._af_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_af_gain_sizer,
            value=self.af_gain,
            callback=self.set_af_gain,
            label="VOL",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._af_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_af_gain_sizer,
            value=self.af_gain,
            callback=self.set_af_gain,
            minimum=0,
            maximum=1,
            num_steps=500,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_af_gain_sizer, 8, 1, 1, 1)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=8, decimation=45, taps=(5,), fractional_bw=None
        )
        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(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(2, 0)
        self.osmosdr_source_0.set_gain_mode(True, 0)
        self.osmosdr_source_0.set_gain(rf_gain, 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)

        _offset_fine_sizer = wx.BoxSizer(wx.VERTICAL)
        self._offset_fine_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_offset_fine_sizer,
            value=self.offset_fine,
            callback=self.set_offset_fine,
            label="Fine tune",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._offset_fine_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_offset_fine_sizer,
            value=self.offset_fine,
            callback=self.set_offset_fine,
            minimum=-1000,
            maximum=1000,
            num_steps=400,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_offset_fine_sizer, 6, 0, 1, 2)
        _offset_coarse_sizer = wx.BoxSizer(wx.VERTICAL)
        self._offset_coarse_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_offset_coarse_sizer,
            value=self.offset_coarse,
            callback=self.set_offset_coarse,
            label="Coarse tune",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._offset_coarse_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_offset_coarse_sizer,
            value=self.offset_coarse,
            callback=self.set_offset_coarse,
            minimum=-250000,
            maximum=250000,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_offset_coarse_sizer, 6, 2, 1, 2)
        self._lo_freq_static_text = forms.static_text(
            parent=self.GetWin(),
            value=self.lo_freq,
            callback=self.set_lo_freq,
            label="LO",
            converter=forms.float_converter(),
        )
        self.GridAdd(self._lo_freq_static_text, 5, 2, 1, 1)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (xlate_filter_taps), 0, samp_rate)
        self._freq_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.freq,
            callback=self.set_freq,
            label="USRP",
            converter=forms.float_converter(),
        )
        self.GridAdd(self._freq_text_box, 5, 1, 1, 1)
        self.fftsink = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=rx_freq * display_selector,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=13490.0,
            sample_rate=samp_rate,
            fft_size=512,
            fft_rate=15,
            average=True,
            avg_alpha=0.5,
            title="",
            peak_hold=False,
            size=(800, 300),
        )
        self.GridAdd(self.fftsink.win, 0, 0, 5, 4)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((af_gain,))
        self.band_pass_filter_0 = filter.fir_filter_ccf(
            1, firdes.band_pass(1, samp_rate, width / 4, width / 2, trans, firdes.WIN_HAMMING, 6.76)
        )
        self.audio_sink_0 = audio.sink(44100, "", True)
        self.analog_am_demod_cf_0 = analog.am_demod_cf(
            channel_rate=44100, audio_decim=1, audio_pass=5000, audio_stop=10000
        )
        self.analog_agc_xx_0 = analog.agc_cc(1e-4, 1.0, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.analog_agc_xx_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.analog_am_demod_cf_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.fftsink, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.band_pass_filter_0, 0))
        self.connect((self.band_pass_filter_0, 0), (self.analog_agc_xx_0, 0))
Esempio n. 48
0
	def __init__(self):
		grc_wxgui.top_block_gui.__init__(self, title="APRS Receiver")

		##################################################
		# Variables
		##################################################
		self.space = space = 1200
		self.mark = mark = 2200
		self.xlate_decim = xlate_decim = 8
		self.xlate_bandwidth = xlate_bandwidth = 1200*6
		self.sym_dev = sym_dev = (mark-space)/2
		self.samp_rate = samp_rate = 1e6
		self.quad_rate = quad_rate = 96000
		self.gain = gain = 10
		self.freq_offset = freq_offset = 390e3
		self.freq = freq = 144e6
		self.baud = baud = 1200
		self.audio_rate = audio_rate = 48000
		self.audio_mul = audio_mul = 1
		self.aprs_rate = aprs_rate = 12000
		self.ant = ant = 'TX/RX'

		##################################################
		# Message Queues
		##################################################
		ax25_hdlc_framer_b_0_msgq_out = ax25_print_frame_0_msgq_in = gr.msg_queue(2)

		##################################################
		# Blocks
		##################################################
		self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
		self.nb.AddPage(grc_wxgui.Panel(self.nb), "Baseband")
		self.nb.AddPage(grc_wxgui.Panel(self.nb), "Waterfall")
		self.nb.AddPage(grc_wxgui.Panel(self.nb), "Signal")
		self.nb.AddPage(grc_wxgui.Panel(self.nb), "Slicer")
		self.nb.AddPage(grc_wxgui.Panel(self.nb), "Eye")
		self.Add(self.nb)
		_gain_sizer = wx.BoxSizer(wx.VERTICAL)
		self._gain_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_gain_sizer,
			value=self.gain,
			callback=self.set_gain,
			label="RF Gain",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._gain_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_gain_sizer,
			value=self.gain,
			callback=self.set_gain,
			minimum=0,
			maximum=50,
			num_steps=50,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Add(_gain_sizer)
		_freq_offset_sizer = wx.BoxSizer(wx.VERTICAL)
		self._freq_offset_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_freq_offset_sizer,
			value=self.freq_offset,
			callback=self.set_freq_offset,
			label="Freq Offset",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._freq_offset_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_freq_offset_sizer,
			value=self.freq_offset,
			callback=self.set_freq_offset,
			minimum=-500e3,
			maximum=500e3,
			num_steps=1000,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Add(_freq_offset_sizer)
		self._freq_text_box = forms.text_box(
			parent=self.GetWin(),
			value=self.freq,
			callback=self.set_freq,
			label="Freq",
			converter=forms.float_converter(),
		)
		self.Add(self._freq_text_box)
		_audio_mul_sizer = wx.BoxSizer(wx.VERTICAL)
		self._audio_mul_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_audio_mul_sizer,
			value=self.audio_mul,
			callback=self.set_audio_mul,
			label="Audio",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._audio_mul_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_audio_mul_sizer,
			value=self.audio_mul,
			callback=self.set_audio_mul,
			minimum=0,
			maximum=10,
			num_steps=1000,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Add(_audio_mul_sizer)
		self._ant_chooser = forms.drop_down(
			parent=self.GetWin(),
			value=self.ant,
			callback=self.set_ant,
			label="Antenna",
			choices=['TX/RX', 'RX2'],
			labels=[],
		)
		self.Add(self._ant_chooser)
		self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
			self.nb.GetPage(1).GetWin(),
			baseband_freq=0,
			dynamic_range=50,
			ref_level=-65,
			ref_scale=2.0,
			sample_rate=aprs_rate,
			fft_size=512,
			fft_rate=15,
			average=False,
			avg_alpha=None,
			title="Waterfall Plot",
		)
		self.nb.GetPage(1).Add(self.wxgui_waterfallsink2_0.win)
		self.wxgui_scopesink2_0_0_0 = scopesink2.scope_sink_f(
			self.nb.GetPage(4).GetWin(),
			title="Scope Plot",
			sample_rate=aprs_rate/10,
			v_scale=0.5,
			v_offset=0,
			t_scale=0.002,
			ac_couple=False,
			xy_mode=False,
			num_inputs=1,
			trig_mode=gr.gr_TRIG_MODE_AUTO,
			y_axis_label="Counts",
		)
		self.nb.GetPage(4).Add(self.wxgui_scopesink2_0_0_0.win)
		self.wxgui_scopesink2_0_0 = scopesink2.scope_sink_f(
			self.nb.GetPage(3).GetWin(),
			title="Scope Plot",
			sample_rate=aprs_rate,
			v_scale=0.5,
			v_offset=0,
			t_scale=0.002,
			ac_couple=False,
			xy_mode=False,
			num_inputs=1,
			trig_mode=gr.gr_TRIG_MODE_AUTO,
			y_axis_label="Counts",
		)
		self.nb.GetPage(3).Add(self.wxgui_scopesink2_0_0.win)
		self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
			self.nb.GetPage(2).GetWin(),
			title="Scope Plot",
			sample_rate=aprs_rate,
			v_scale=0.05,
			v_offset=0,
			t_scale=0.002,
			ac_couple=False,
			xy_mode=False,
			num_inputs=1,
			trig_mode=gr.gr_TRIG_MODE_AUTO,
			y_axis_label="Counts",
		)
		self.nb.GetPage(2).Add(self.wxgui_scopesink2_0.win)
		self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
			self.nb.GetPage(0).GetWin(),
			baseband_freq=0,
			y_per_div=10,
			y_divs=10,
			ref_level=-20,
			ref_scale=2.0,
			sample_rate=samp_rate,
			fft_size=1024,
			fft_rate=15,
			average=True,
			avg_alpha=0.5,
			title="FFT Plot",
			peak_hold=False,
		)
		self.nb.GetPage(0).Add(self.wxgui_fftsink2_0.win)
		def wxgui_fftsink2_0_callback(x, y):
			self.set_freq_offset(x)
		
		self.wxgui_fftsink2_0.set_callback(wxgui_fftsink2_0_callback)
		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_samp_rate(samp_rate)
		self.uhd_usrp_source_0.set_center_freq(freq, 0)
		self.uhd_usrp_source_0.set_gain(gain, 0)
		self.uhd_usrp_source_0.set_antenna(ant, 0)
		self.low_pass_filter_0 = gr.fir_filter_ccf(1, firdes.low_pass(
			1, aprs_rate, 2e3, 600, firdes.WIN_HAMMING, 6.76))
		self.gr_single_pole_iir_filter_xx_0 = gr.single_pole_iir_filter_ff(0.0001, 1)
		self.gr_null_sink_0 = gr.null_sink(gr.sizeof_float*1)
		self.gr_multiply_xx_0 = gr.multiply_vcc(1)
		self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((audio_mul, ))
		self.gr_agc_xx_1 = gr.agc_ff(1e-3, 0.8, 0.1, 10.0)
		self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(xlate_decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth/2, 1000)), freq_offset, samp_rate)
		self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(10, .25 * (0.05)**2, 0.5, 0.005, 0.005)
		self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
		self.blocks_sub_xx_0 = blocks.sub_ff(1)
		self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
		self.blks2_rational_resampler_xxx_0_0 = blks2.rational_resampler_ccc(
			interpolation=quad_rate,
			decimation=int(samp_rate/xlate_decim),
			taps=None,
			fractional_bw=None,
		)
		self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc(
			interpolation=aprs_rate,
			decimation=quad_rate,
			taps=None,
			fractional_bw=None,
		)
		self.blks2_nbfm_rx_0_0 = blks2.nbfm_rx(
			audio_rate=audio_rate,
			quad_rate=quad_rate,
			tau=75e-6,
			max_dev=25000,
		)
		self.blks2_nbfm_rx_0 = blks2.nbfm_rx(
			audio_rate=aprs_rate,
			quad_rate=quad_rate,
			tau=75e-6,
			max_dev=3e3,
		)
		self.ax25_print_frame_0 = packetradio.queue_watcher_thread(ax25_print_frame_0_msgq_in)
		self.ax25_hdlc_framer_b_0 = packetradio.hdlc_framer(ax25_hdlc_framer_b_0_msgq_out, False)
		self.analog_sig_source_x_0 = analog.sig_source_c(aprs_rate, analog.GR_SIN_WAVE, -(min(mark,space)+sym_dev), 1, 0)
		self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(aprs_rate/(2*math.pi*sym_dev))
		self.analog_pwr_squelch_xx_0_0_0 = analog.pwr_squelch_cc(-70, 1e-1, 0, False)
		self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_cc(-70, 1e-1, 0, False)

		##################################################
		# Connections
		##################################################
		self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0))
		self.connect((self.blks2_rational_resampler_xxx_0_0, 0), (self.blks2_rational_resampler_xxx_0, 0))
		self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blks2_rational_resampler_xxx_0_0, 0))
		self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.wxgui_waterfallsink2_0, 0))
		self.connect((self.uhd_usrp_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
		self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0))
		self.connect((self.blocks_sub_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
		self.connect((self.gr_single_pole_iir_filter_xx_0, 0), (self.blocks_sub_xx_0, 1))
		self.connect((self.analog_quadrature_demod_cf_0, 0), (self.gr_single_pole_iir_filter_xx_0, 0))
		self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_sub_xx_0, 0))
		self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0, 0))
		self.connect((self.gr_multiply_xx_0, 0), (self.low_pass_filter_0, 0))
		self.connect((self.analog_sig_source_x_0, 0), (self.gr_multiply_xx_0, 1))
		self.connect((self.blocks_float_to_complex_0, 0), (self.gr_multiply_xx_0, 0))
		self.connect((self.blks2_nbfm_rx_0, 0), (self.blocks_float_to_complex_0, 0))
		self.connect((self.blks2_nbfm_rx_0, 0), (self.blocks_float_to_complex_0, 1))
		self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.wxgui_scopesink2_0_0_0, 0))
		self.connect((self.digital_binary_slicer_fb_0, 0), (self.ax25_hdlc_framer_b_0, 0))
		self.connect((self.blks2_nbfm_rx_0, 0), (self.wxgui_scopesink2_0, 0))
		self.connect((self.blks2_rational_resampler_xxx_0_0, 0), (self.analog_pwr_squelch_xx_0_0, 0))
		self.connect((self.analog_pwr_squelch_xx_0_0_0, 0), (self.blks2_nbfm_rx_0, 0))
		self.connect((self.blks2_rational_resampler_xxx_0_0, 0), (self.analog_pwr_squelch_xx_0_0_0, 0))
		self.connect((self.analog_quadrature_demod_cf_0, 0), (self.wxgui_scopesink2_0_0, 0))
		self.connect((self.blks2_nbfm_rx_0_0, 0), (self.gr_agc_xx_1, 0))
		self.connect((self.analog_pwr_squelch_xx_0_0, 0), (self.blks2_nbfm_rx_0_0, 0))
		self.connect((self.gr_agc_xx_1, 0), (self.gr_multiply_const_vxx_0, 0))
		self.connect((self.gr_multiply_const_vxx_0, 0), (self.gr_null_sink_0, 0))
Esempio n. 49
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Wifi Tx")

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 50
        self.samp_rate = samp_rate = 10e6
        self.period = period = 100
        self.pdu_length = pdu_length = 100
        self.out_buf_size = out_buf_size = 96000
        self.mult = mult = .4
        self.lo_offset = lo_offset = 11e6
        self.freq = freq = 2.422e9
        self.encoding = encoding = 0

        ##################################################
        # Blocks
        ##################################################
        _tx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tx_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_tx_gain_sizer,
        	value=self.tx_gain,
        	callback=self.set_tx_gain,
        	label='tx_gain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._tx_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_tx_gain_sizer,
        	value=self.tx_gain,
        	callback=self.set_tx_gain,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_tx_gain_sizer)
        self._samp_rate_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.samp_rate,
        	callback=self.set_samp_rate,
        	label="Sample Rate",
        	choices=[10e6, 20e6],
        	labels=["10 Mhz", "20 Mhz"],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._samp_rate_chooser)
        _period_sizer = wx.BoxSizer(wx.VERTICAL)
        self._period_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_period_sizer,
        	value=self.period,
        	callback=self.set_period,
        	label='period',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._period_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_period_sizer,
        	value=self.period,
        	callback=self.set_period,
        	minimum=1,
        	maximum=10000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_period_sizer)
        _pdu_length_sizer = wx.BoxSizer(wx.VERTICAL)
        self._pdu_length_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_pdu_length_sizer,
        	value=self.pdu_length,
        	callback=self.set_pdu_length,
        	label='pdu_length',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._pdu_length_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_pdu_length_sizer,
        	value=self.pdu_length,
        	callback=self.set_pdu_length,
        	minimum=0,
        	maximum=1500,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_pdu_length_sizer)
        _mult_sizer = wx.BoxSizer(wx.VERTICAL)
        self._mult_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_mult_sizer,
        	value=self.mult,
        	callback=self.set_mult,
        	label='mult',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._mult_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_mult_sizer,
        	value=self.mult,
        	callback=self.set_mult,
        	minimum=0,
        	maximum=2,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_mult_sizer)
        self._lo_offset_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.lo_offset,
        	callback=self.set_lo_offset,
        	label="LO Offset",
        	choices=[0, 6e6, 11e6],
        	labels=['0 MHz', '6 MHz', '11 MHz'],
        )
        self.Add(self._lo_offset_chooser)
        self._freq_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.freq,
        	callback=self.set_freq,
        	label="Channel",
        	choices=[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, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0],
        	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', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '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'],
        )
        self.Add(self._freq_chooser)
        self._encoding_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.encoding,
        	callback=self.set_encoding,
        	label="Encoding",
        	choices=[0,1,2,3,4,5,6,7],
        	labels=["BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._encoding_chooser)
        self.wifi_phy_hier_0 = wifi_phy_hier(
            chan_est=0,
            encoding=encoding,
            sensitivity=0.56,
        )
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        	"packet_len",
        )
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
        self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0x02, 0x11, 0x87, 0xBA, 0x68, 0x3B]))
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.01, 100, 1000)
        (self.foo_packet_pad2_0).set_min_output_buffer(96000)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", "", "52001", 10000, False)
        self.blocks_null_source_0 = blocks.null_source(gr.sizeof_gr_complex*1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((mult, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.intern("".join("x" for i in range(pdu_length))), period)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'), (self.ieee802_11_ofdm_mac_0, 'app in'))    
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.ieee802_11_ofdm_mac_0, 'app in'))    
        self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'), (self.wifi_phy_hier_0, 'mac_in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ofdm_mac_0, 'phy in'))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0))    
        self.connect((self.blocks_null_source_0, 0), (self.wifi_phy_hier_0, 0))    
        self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0, 0))    
        self.connect((self.wifi_phy_hier_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.wifi_phy_hier_0, 1), (self.blocks_null_sink_0, 0))    
Esempio n. 50
0
    def __init__(self, sym_rate=256, samp_per_sym=256, nominal_uplink_freq=2041.95e6*0 + 2041.9479e6 + 1e6*0, lo_off=5e6 * 0, tx_gain=15*0 + 13.5*0, backoff=0.150*0 + (0.6+0.1)*0 + 1e-3, record_path='/media/balint/PATRIOT/ICE/TX/'):
        grc_wxgui.top_block_gui.__init__(self, title="Uplink")

        ##################################################
        # Parameters
        ##################################################
        self.sym_rate = sym_rate
        self.samp_per_sym = samp_per_sym
        self.nominal_uplink_freq = nominal_uplink_freq
        self.lo_off = lo_off
        self.tx_gain = tx_gain
        self.backoff = backoff
        self.record_path = record_path

        ##################################################
        # Variables
        ##################################################
        self.time_format = time_format = "%Y-%d-%m_%H-%M-%S"
        self.time_now = time_now = time.strftime(time_format)
        self.samp_rate = samp_rate = 250000
        self.pre_resamp_rate = pre_resamp_rate = sym_rate * samp_per_sym
        self.f1 = f1 = 9000.0
        self.f0 = f0 = 7500.0
        self.resamp_rate = resamp_rate = float(samp_rate)/float(pre_resamp_rate)
        self.pm = pm = 1.2*0 + 1.0
        self.nominal_uplink_freq_chooser = nominal_uplink_freq_chooser = nominal_uplink_freq
        self.manual_doppler = manual_doppler = 0
        self.file_name = file_name = time_now + ".mcfile"
        self.doppler = doppler = 0
        self.deviation = deviation = (f1 - f0) / 2.0
        self.tx_gain_user = tx_gain_user = tx_gain
        self.subcarrier_freq = subcarrier_freq = f0 + deviation
        self.source = source = 'external'
        self.pm_txt = pm_txt = pm
        self.nominal_uplink_freq_user = nominal_uplink_freq_user = nominal_uplink_freq_chooser
        self.lo_off_user = lo_off_user = lo_off
        self.length_mul = length_mul = float(samp_per_sym) * resamp_rate
        self.invert = invert = 1
        self.final_record_path = final_record_path = os.path.join(record_path, file_name)
        self.final_doppler = final_doppler = doppler + manual_doppler
        self.backoff_user = backoff_user = backoff

        ##################################################
        # Blocks
        ##################################################
        _tx_gain_user_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tx_gain_user_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_tx_gain_user_sizer,
        	value=self.tx_gain_user,
        	callback=self.set_tx_gain_user,
        	label="TX Gain",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._tx_gain_user_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_tx_gain_user_sizer,
        	value=self.tx_gain_user,
        	callback=self.set_tx_gain_user,
        	minimum=0,
        	maximum=32,
        	num_steps=32,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_tx_gain_user_sizer)
        self._nominal_uplink_freq_user_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.nominal_uplink_freq_user,
        	callback=self.set_nominal_uplink_freq_user,
        	label="Nominal Uplink Freq",
        	converter=forms.float_converter(),
        )
        self.Add(self._nominal_uplink_freq_user_text_box)
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Output FFT")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Input FFT")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Input Phase/Mag")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Mod Clk/Data")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "PM Output Scope")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "PM Input")
        self.Add(self.nb)
        self._lo_off_user_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.lo_off_user,
        	callback=self.set_lo_off_user,
        	label="LO Offset",
        	converter=forms.float_converter(),
        )
        self.Add(self._lo_off_user_text_box)
        self._final_doppler_static_text = forms.static_text(
        	parent=self.GetWin(),
        	value=self.final_doppler,
        	callback=self.set_final_doppler,
        	label="Final Doppler",
        	converter=forms.float_converter(),
        )
        self.Add(self._final_doppler_static_text)
        self._doppler_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.doppler,
        	callback=self.set_doppler,
        	label="Doppler Shift",
        	converter=forms.float_converter(),
        )
        self.Add(self._doppler_text_box)
        _backoff_user_sizer = wx.BoxSizer(wx.VERTICAL)
        self._backoff_user_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_backoff_user_sizer,
        	value=self.backoff_user,
        	callback=self.set_backoff_user,
        	label="Backoff",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._backoff_user_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_backoff_user_sizer,
        	value=self.backoff_user,
        	callback=self.set_backoff_user,
        	minimum=0,
        	maximum=1,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_backoff_user_sizer)
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(("", 52003), allow_none=True)
        self.xmlrpc_server_0.register_instance(self)
        threading.Thread(target=self.xmlrpc_server_0.serve_forever).start()
        self.wxgui_scopesink2_2 = scopesink2.scope_sink_f(
        	self.nb.GetPage(5).GetWin(),
        	title="Scope Plot",
        	sample_rate=pre_resamp_rate,
        	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.nb.GetPage(5).Add(self.wxgui_scopesink2_2.win)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_c(
        	self.nb.GetPage(4).GetWin(),
        	title="Scope Plot",
        	sample_rate=samp_rate,
        	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.nb.GetPage(4).Add(self.wxgui_scopesink2_1.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.nb.GetPage(0).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=256,
        	fft_rate=10,
        	average=False,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,	fft_in=False,
        	always_run=False,
        	fft_out=False,
        )
        self.nb.GetPage(0).Add(self.wxgui_fftsink2_0.win)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("serial=F4A7C3", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        	"",
        	True,
        )
        self.uhd_usrp_sink_0.set_clock_source(source, 0)
        self.uhd_usrp_sink_0.set_time_source(source, 0)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(nominal_uplink_freq_user,lo_off_user), 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain*0 + tx_gain_user, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=int(samp_rate),
                decimation=int(pre_resamp_rate),
                taps=None,
                fractional_bw=None,
        )
        self._pm_txt_static_text = forms.static_text(
        	parent=self.GetWin(),
        	value=self.pm_txt,
        	callback=self.set_pm_txt,
        	label="Phase Moduation Index",
        	converter=forms.float_converter(),
        )
        self.Add(self._pm_txt_static_text)
        self._nominal_uplink_freq_chooser_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.nominal_uplink_freq_chooser,
        	callback=self.set_nominal_uplink_freq_chooser,
        	label="Nomial Uplink Frequency",
        	choices=[2041.9479e6, 2090.66e6],
        	labels=['B: 2041.9479', 'A: 2090.66'],
        )
        self.Add(self._nominal_uplink_freq_chooser_chooser)
        self._manual_doppler_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.manual_doppler,
        	callback=self.set_manual_doppler,
        	label="Manual Doppler",
        	converter=forms.float_converter(),
        )
        self.Add(self._manual_doppler_text_box)
        self.mac_burst_tagger_0 = mac.burst_tagger('packet_len', length_mul, 256, 32*0 + 256, True, False)
        self.clock_and_data = scopesink2.scope_sink_c(
        	self.nb.GetPage(3).GetWin(),
        	title="Scope Plot",
        	sample_rate=pre_resamp_rate,
        	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.nb.GetPage(3).Add(self.clock_and_data.win)
        self.carrier = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, doppler*0 + final_doppler, 0*backoff + backoff_user, 0)
        self.blocks_vector_source_x_0 = blocks.vector_source_f(tuple([1] * (samp_per_sym/4) +  [0] * (samp_per_sym/4) +  [0] * (samp_per_sym/4) +  [1] * (samp_per_sym/4)), True, 1, [])
        self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", "", "52002", 10000, False)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, samp_per_sym)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len", 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff((2.0/3, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((2, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((invert, ))
        self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.cons(pmt.to_pmt({'ignore': True}), pmt.init_u8vector(1, 1*[0])), 0)
        self.blocks_float_to_complex_2 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_1 = blocks.float_to_complex(1)
        self.blocks_file_meta_sink_0 = blocks.file_meta_sink(gr.sizeof_gr_complex*1, final_record_path, samp_rate, 1, blocks.GR_FILE_FLOAT, True, 1000000, "", True)
        self.blocks_file_meta_sink_0.set_unbuffered(False)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.blocks_add_const_vxx_1_0 = blocks.add_const_vff((1.0/3, ))
        self.blocks_add_const_vxx_1 = blocks.add_const_vff((-1, ))
        self.binary_to_pdu0 = isee3.binary_to_pdu()
        self.analog_sig_source_x_0 = analog.sig_source_c(pre_resamp_rate, analog.GR_COS_WAVE, subcarrier_freq, 1/1.333, 0)
        self.analog_phase_modulator_fc_1 = analog.phase_modulator_fc(pm / (2.0*0 + 1))
        self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(float(deviation) / float(pre_resamp_rate) * math.pi*2.0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_char_to_float_0, 0))
        self.connect((self.blocks_char_to_float_0, 0), (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_const_vxx_1, 0))
        self.connect((self.blocks_add_const_vxx_1, 0), (self.blocks_repeat_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_float_0, 0))
        self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blocks_add_const_vxx_1_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_multiply_const_vxx_1_0, 0))
        self.connect((self.blocks_add_const_vxx_1_0, 0), (self.blocks_float_to_complex_2, 0))
        self.connect((self.blocks_float_to_complex_1, 0), (self.clock_and_data, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.carrier, 0), (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_add_const_vxx_1_0, 0), (self.blocks_float_to_complex_1, 1))
        self.connect((self.blocks_repeat_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.analog_frequency_modulator_fc_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0), (self.analog_phase_modulator_fc_1, 0))
        self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_null_sink_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0), (self.wxgui_scopesink2_2, 0))
        self.connect((self.blocks_add_const_vxx_1_0, 0), (self.blocks_float_to_complex_2, 1))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_complex_1, 0))
        self.connect((self.blocks_float_to_complex_2, 0), (self.blocks_multiply_xx_0, 2))
        self.connect((self.mac_burst_tagger_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.mac_burst_tagger_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.wxgui_scopesink2_1, 0))
        self.connect((self.analog_phase_modulator_fc_1, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_1, 0))
        self.connect((self.mac_burst_tagger_0, 0), (self.blocks_file_meta_sink_0, 0))

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.binary_to_pdu0, "pdu_out", self.blocks_pdu_to_tagged_stream_0, "pdus")
        self.msg_connect(self.blocks_socket_pdu_0, "pdus", self.binary_to_pdu0, "binary_in")
        self.msg_connect(self.blocks_message_strobe_0_0, "strobe", self.blocks_pdu_to_tagged_stream_0, "pdus")
        self.msg_connect(self.uhd_usrp_sink_0, "ctl", self.blocks_message_strobe_0_0, "trigger")
Esempio n. 51
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Wifi Rx")

        ##################################################
        # Variables
        ##################################################
        self.window_size = window_size = 48
        self.sync_length = sync_length = 320
        self.samp_rate = samp_rate = 10e6
        self.lo_offset = lo_offset = 11e6
        self.gain = gain = 20
        self.freq = freq = 5.89e9
        self.chan_est = chan_est = 1

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.samp_rate,
            callback=self.set_samp_rate,
            label="Sample Rate",
            choices=[5e6, 10e6, 20e6],
            labels=["5 MHz", "10 MHz", "20 MHz"],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._samp_rate_chooser)
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "constellation")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "autocorrelation")
        self.Add(self.nb)
        self._lo_offset_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.lo_offset,
            callback=self.set_lo_offset,
            label="LO Offset",
            choices=[0, 6e6, 11e6],
            labels=['0 MHz', '6 MHz', '11 MHz'],
        )
        self.Add(self._lo_offset_chooser)
        self.ieee802_11_ofdm_sync_short_0 = ieee802_11.ofdm_sync_short(
            0.56, 2, False, False)
        self.ieee802_11_ofdm_sync_long_0 = ieee802_11.ofdm_sync_long(
            sync_length, False, False)
        self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_ff(
            window_size + 16)
        self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc(
            window_size)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            label='gain',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_gain_sizer)
        self._freq_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.freq,
            callback=self.set_freq,
            label="Channel",
            choices=[
                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, 5260000000.0, 5280000000.0,
                5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0,
                5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0,
                5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0,
                5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0,
                5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0,
                5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0,
                5920000000.0
            ],
            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',
                ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a',
                ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a',
                '100 | 5500.0 | 11a', '104 | 5520.0 | 11a',
                '108 | 5540.0 | 11a', '112 | 5560.0 | 11a',
                '116 | 5580.0 | 11a', '120 | 5600.0 | 11a',
                '124 | 5620.0 | 11a', '128 | 5640.0 | 11a',
                '132 | 5660.0 | 11a', '136 | 5680.0 | 11a',
                '140 | 5700.0 | 11a', '149 | 5745.0 | 11a',
                '153 | 5765.0 | 11a', '157 | 5785.0 | 11a',
                '161 | 5805.0 | 11a', '165 | 5825.0 | 11a',
                '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'
            ],
        )
        self.Add(self._freq_chooser)
        self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True,
                                     1)
        self.data_equalizing_HYR_ofdm_0 = data_equalizing.HYR_ofdm()
        self._chan_est_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.chan_est,
            callback=self.set_chan_est,
            label='chan_est',
            choices=[0, 1],
            labels=["LMS", "Linear Comb"],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._chan_est_chooser)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 64)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 64)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1, "/home/esl/naver/TRANSCEIVERdump", False)
        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.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.ieee802_11_moving_average_xx_1, 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_ofdm_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_ofdm_sync_short_0, 0))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.ieee802_11_ofdm_sync_short_0, 2))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_delay_0_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.ieee802_11_moving_average_xx_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.data_equalizing_HYR_ofdm_0, 0),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.data_equalizing_HYR_ofdm_0, 0))
        self.connect((self.ieee802_11_moving_average_xx_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.ieee802_11_moving_average_xx_0, 0),
                     (self.ieee802_11_ofdm_sync_short_0, 1))
        self.connect((self.ieee802_11_moving_average_xx_1, 0),
                     (self.blocks_divide_xx_0, 1))
        self.connect((self.ieee802_11_ofdm_sync_long_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.ieee802_11_ofdm_sync_short_0, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.ieee802_11_ofdm_sync_short_0, 0),
                     (self.ieee802_11_ofdm_sync_long_0, 0))
Esempio n. 52
0
    def __init__(self,
                 antenna="TX/RX",
                 vor_freq_1=111e6,
                 com_freq_1=135.275e6,
                 vor_freq_2=111e6,
                 rx_gain=30,
                 gain=20):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Parameters
        ##################################################
        self.antenna = antenna
        self.vor_freq_1 = vor_freq_1
        self.com_freq_1 = com_freq_1
        self.vor_freq_2 = vor_freq_2
        self.rx_gain = rx_gain
        self.gain = gain

        ##################################################
        # Variables
        ##################################################
        self.obs_decimation = obs_decimation = 25
        self.ils_decimation = ils_decimation = 50
        self.am_sample_rate = am_sample_rate = 12.5e3
        self.vor_samp_rate = vor_samp_rate = 250e3
        self.vor_freq_entry_2 = vor_freq_entry_2 = vor_freq_2
        self.vor_freq_entry_1 = vor_freq_entry_1 = vor_freq_1
        self.vor_center_freq_0 = vor_center_freq_0 = (117.95e6 -
                                                      108.00e6) / 2 + 117.95e6
        self.vor_center_freq = vor_center_freq = (117.95e6 -
                                                  108.00e6) / 2 + 117.95e6
        self.squelch_slider = squelch_slider = -110
        self.rxgain = rxgain = 15
        self.phase_correction = phase_correction = 5
        self.obs_sample_rate = obs_sample_rate = am_sample_rate / obs_decimation
        self.ils_sample_rate = ils_sample_rate = am_sample_rate / ils_decimation
        self.gain_slider = gain_slider = gain
        self.com_freq_entry_1 = com_freq_entry_1 = com_freq_1
        self.band_center_freq = band_center_freq = (136.975e6 -
                                                    108.0e6) / 2 + 108.0e6
        self.audio_select = audio_select = 0
        self.audio_sample_rate = audio_sample_rate = 48e3
        self.am_decimation = am_decimation = 1

        ##################################################
        # Blocks
        ##################################################
        self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(),
                                                        style=wx.NB_TOP)
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0),
                                "RF Analyzer")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0),
                                "Channel FFT")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0),
                                "Demod Audio FFT")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0),
                                "Ref and Phase Scope")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0),
                                "Manipulated Ref and Phase")
        self.Add(self.notebook_0)
        self._vor_freq_entry_1_text_box = forms.text_box(
            parent=self.notebook_0.GetPage(0).GetWin(),
            value=self.vor_freq_entry_1,
            callback=self.set_vor_freq_entry_1,
            label='vor_freq_entry_1',
            converter=forms.float_converter(),
        )
        self.notebook_0.GetPage(0).Add(self._vor_freq_entry_1_text_box)
        _gain_slider_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_slider_text_box = forms.text_box(
            parent=self.notebook_0.GetPage(0).GetWin(),
            sizer=_gain_slider_sizer,
            value=self.gain_slider,
            callback=self.set_gain_slider,
            label='gain_slider',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._gain_slider_slider = forms.slider(
            parent=self.notebook_0.GetPage(0).GetWin(),
            sizer=_gain_slider_sizer,
            value=self.gain_slider,
            callback=self.set_gain_slider,
            minimum=0,
            maximum=30,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.notebook_0.GetPage(0).Add(_gain_slider_sizer)
        self._com_freq_entry_1_text_box = forms.text_box(
            parent=self.notebook_0.GetPage(0).GetWin(),
            value=self.com_freq_entry_1,
            callback=self.set_com_freq_entry_1,
            label='com_freq_entry_1',
            converter=forms.float_converter(),
        )
        self.notebook_0.GetPage(0).Add(self._com_freq_entry_1_text_box)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.notebook_0.GetPage(1).GetWin(),
            title="Scope Plot",
            sample_rate=10e3,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=2,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.notebook_0.GetPage(1).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
            self.GetWin(),
            unit="Units",
            minval=-100,
            maxval=100,
            factor=1.0,
            decimal_places=10,
            ref_level=0,
            sample_rate=10,
            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.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.notebook_0.GetPage(0).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=12.5e3,
            fft_size=1024,
            fft_rate=5,
            average=False,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=False,
        )
        self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0.win)
        self._vor_freq_entry_2_text_box = forms.text_box(
            parent=self.notebook_0.GetPage(0).GetWin(),
            value=self.vor_freq_entry_2,
            callback=self.set_vor_freq_entry_2,
            label='vor_freq_entry_2',
            converter=forms.float_converter(),
        )
        self.notebook_0.GetPage(0).Add(self._vor_freq_entry_2_text_box)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            device_addr="",
            stream_args=uhd.stream_args(
                cpu_format="fc32",
                channels=range(2),
            ),
        )
        self.uhd_usrp_source_0.set_subdev_spec("A:0 A:0", 0)
        self.uhd_usrp_source_0.set_samp_rate(vor_samp_rate)
        self.uhd_usrp_source_0.set_center_freq(
            uhd.tune_request(com_freq_entry_1,
                             rf_freq=band_center_freq,
                             rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_source_0.set_gain(gain_slider, 0)
        self.uhd_usrp_source_0.set_antenna("TX/RX", 0)
        self.uhd_usrp_source_0.set_center_freq(
            uhd.tune_request(vor_freq_entry_1,
                             rf_freq=band_center_freq,
                             rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 1)
        self.uhd_usrp_source_0.set_gain(gain_slider, 1)
        self.uhd_usrp_source_0.set_antenna("TX/RX", 1)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            device_addr="",
            stream_args=uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_samp_rate(250e3)
        self.uhd_usrp_sink_0.set_center_freq(
            uhd.tune_request(com_freq_entry_1, 20e6), 0)
        self.uhd_usrp_sink_0.set_gain(15, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
        _squelch_slider_sizer = wx.BoxSizer(wx.VERTICAL)
        self._squelch_slider_text_box = forms.text_box(
            parent=self.notebook_0.GetPage(0).GetWin(),
            sizer=_squelch_slider_sizer,
            value=self.squelch_slider,
            callback=self.set_squelch_slider,
            label='squelch_slider',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._squelch_slider_slider = forms.slider(
            parent=self.notebook_0.GetPage(0).GetWin(),
            sizer=_squelch_slider_sizer,
            value=self.squelch_slider,
            callback=self.set_squelch_slider,
            minimum=-110,
            maximum=0,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.notebook_0.GetPage(0).Add(_squelch_slider_sizer)
        self.squelch = analog.pwr_squelch_cc(squelch_slider, 0.01, 20, True)
        self.rational_resampler_xxx_2 = filter.rational_resampler_fff(
            interpolation=250,
            decimation=48,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_1 = filter.rational_resampler_fff(
            interpolation=480,
            decimation=125,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=4,
            decimation=5,
            taps=None,
            fractional_bw=None,
        )
        self.openavionics_joystick_interface_0 = openavionics.joystick_interface(
        )
        self.openavionics_audio_ptt_0 = openavionics.audio_ptt()
        self.null_sink_0_0_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.multiply_xx_0_0_0 = blocks.multiply_vcc(1)
        self.multiply_xx_0_0 = blocks.multiply_vff(1)
        self.low_pass_filter_3 = filter.fir_filter_ccf(
            1, firdes.low_pass(1, 10e3, 1, 2, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_2_0_0 = filter.fir_filter_ccf(
            5, firdes.low_pass(1, 40e3, 2e3, 1e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_2_0 = filter.fir_filter_ccf(
            5, firdes.low_pass(1, 40e3, 2e3, 1e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_2 = filter.fir_filter_ccf(
            5,
            firdes.low_pass(1, vor_samp_rate, 15e3, 5e3, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_1 = filter.interp_fir_filter_fff(
            1, firdes.low_pass(1, 12.5e3, 3e3, 1e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            int(250e3 / 12.5e3),
            firdes.low_pass(1, vor_samp_rate, 10e3, 1e3, firdes.WIN_HAMMING,
                            6.76))
        self.goertzel_fc_0_0 = fft.goertzel_fc(10000, 1000, 30)
        self.goertzel_fc_0 = fft.goertzel_fc(40000, 4000, 30)
        self.float_to_complex_0_0 = blocks.float_to_complex(1)
        self.const_source_x_0_0_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, 0.450)
        self.const_source_x_0_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE,
                                                      0, 0, 0.550)
        self.const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0,
                                                    0, 0.450)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-87.2665e-3, ))
        self.band_pass_filter_0_0 = filter.fir_filter_fff(
            4, firdes.band_pass(1, 40e3, 20, 40, 20, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0 = filter.fir_filter_fff(
            1, firdes.band_pass(1, 10e3, 20, 40, 20, firdes.WIN_HAMMING, 6.76))
        self.audio_source_0 = audio.source(48000, "", True)
        self.audio_sink_0 = audio.sink(int(audio_sample_rate), "", True)
        self._audio_select_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.audio_select,
            callback=self.set_audio_select,
            label='audio_select',
            choices=[0, 1],
            labels=['AM Voice', 'VOR Subcarrier'],
        )
        self.Add(self._audio_select_chooser)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            40e3, analog.GR_COS_WAVE, -9.96e3, 1, 0)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1)
        self.analog_am_demod_cf_0 = analog.am_demod_cf(
            channel_rate=40e3,
            audio_decim=4,
            audio_pass=5000,
            audio_stop=5500,
        )
        self.analog_agc2_xx_0_1_0 = analog.agc2_ff(1e-1, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0_1_0.set_max_gain(100)
        self.analog_agc2_xx_0_1 = analog.agc2_ff(1e-1, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0_1.set_max_gain(100)
        self.analog_agc2_xx_0_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0_0.set_max_gain(100)
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0.set_max_gain(100)
        self.am_demod_cf_0 = analog.am_demod_cf(
            channel_rate=am_sample_rate,
            audio_decim=am_decimation,
            audio_pass=3e3,
            audio_stop=4e3,
        )
        self.agc2_xx_0 = analog.agc2_cc(1, 1, 0.75, 1.0)
        self.agc2_xx_0.set_max_gain(0.0)
        self.add_xx_0_0 = blocks.add_vff(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.agc2_xx_0, 0), (self.am_demod_cf_0, 0))
        self.connect((self.am_demod_cf_0, 0), (self.low_pass_filter_1, 0))
        self.connect((self.agc2_xx_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.multiply_xx_0_0, 0), (self.add_xx_0_0, 0))
        self.connect((self.const_source_x_0, 0), (self.multiply_xx_0_0, 1))
        self.connect((self.const_source_x_0_0, 0), (self.add_xx_0_0, 1))
        self.connect((self.multiply_xx_0_0_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.add_xx_0_0, 0), (self.float_to_complex_0_0, 0))
        self.connect((self.add_xx_0_0, 0), (self.float_to_complex_0_0, 1))
        self.connect((self.float_to_complex_0_0, 0),
                     (self.multiply_xx_0_0_0, 0))
        self.connect((self.const_source_x_0_0_0, 0),
                     (self.multiply_xx_0_0_0, 1))
        self.connect((self.uhd_usrp_source_0, 0), (self.null_sink_0_0_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_1, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.analog_agc2_xx_0_1_0, 0),
                     (self.wxgui_scopesink2_0, 1))
        self.connect((self.analog_agc2_xx_0_1, 0),
                     (self.wxgui_scopesink2_0, 0))
        self.connect((self.band_pass_filter_0, 0),
                     (self.analog_agc2_xx_0_1, 0))
        self.connect((self.band_pass_filter_0_0, 0),
                     (self.analog_agc2_xx_0_1_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.band_pass_filter_0_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.goertzel_fc_0, 0))
        self.connect((self.analog_am_demod_cf_0, 0),
                     (self.band_pass_filter_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.wxgui_numbersink2_0, 0))
        self.connect((self.blocks_complex_to_arg_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.low_pass_filter_3, 0),
                     (self.blocks_complex_to_arg_0, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0),
                     (self.low_pass_filter_3, 0))
        self.connect((self.analog_agc2_xx_0, 0),
                     (self.blocks_multiply_conjugate_cc_0, 1))
        self.connect((self.analog_agc2_xx_0_0, 0),
                     (self.blocks_multiply_conjugate_cc_0, 0))
        self.connect((self.goertzel_fc_0_0, 0), (self.analog_agc2_xx_0_0, 0))
        self.connect((self.analog_am_demod_cf_0, 0), (self.goertzel_fc_0_0, 0))
        self.connect((self.goertzel_fc_0, 0), (self.analog_agc2_xx_0, 0))
        self.connect((self.low_pass_filter_2_0_0, 0),
                     (self.analog_am_demod_cf_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.low_pass_filter_2_0_0, 0))
        self.connect((self.low_pass_filter_2_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.low_pass_filter_2_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.uhd_usrp_source_0, 1), (self.null_sink_0_0, 0))
        self.connect((self.low_pass_filter_2, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.audio_source_0, 0),
                     (self.openavionics_audio_ptt_0, 0))
        self.connect((self.openavionics_audio_ptt_0, 0),
                     (self.rational_resampler_xxx_2, 0))
        self.connect((self.rational_resampler_xxx_2, 0),
                     (self.multiply_xx_0_0, 0))
        self.connect((self.squelch, 0), (self.agc2_xx_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.squelch, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_2, 0))

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.openavionics_joystick_interface_0, "out",
                         self.openavionics_audio_ptt_0, "in2")
Esempio n. 53
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Wifi Transceiver")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 15
        self.samp_rate = samp_rate = 10e6
        self.rx_gain = rx_gain = 5
        self.mult = mult = 0.38
        self.lo_offset = lo_offset = 0
        self.freq = freq = 5.89e9
        self.encoding = encoding = 0

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.samp_rate,
        	callback=self.set_samp_rate,
        	label="Sample Rate",
        	choices=[5e6,10e6, 20e6],
        	labels=["5MHz", "10 MHz", "20 MHz"],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._samp_rate_chooser)
        _mult_sizer = wx.BoxSizer(wx.VERTICAL)
        self._mult_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_mult_sizer,
        	value=self.mult,
        	callback=self.set_mult,
        	label='mult',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._mult_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_mult_sizer,
        	value=self.mult,
        	callback=self.set_mult,
        	minimum=0,
        	maximum=1,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_mult_sizer)
        self._encoding_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.encoding,
        	callback=self.set_encoding,
        	label="Encoding",
        	choices=[0,1,2,3,4,5,6,7],
        	labels=["BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._encoding_chooser)
        self.wxgui_scopesink2_0_0 = scopesink2.scope_sink_c(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=5000,
        	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_0.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=5000,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=True,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.wifi_phy_hier_0_0 = wifi_phy_hier(
            chan_est=0,
            encoding=0,
        )
        self.wifi_phy_hier_0 = wifi_phy_hier(
            chan_est=0,
            encoding=0,
        )
        _tx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tx_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_tx_gain_sizer,
        	value=self.tx_gain,
        	callback=self.set_tx_gain,
        	label='tx_gain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._tx_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_tx_gain_sizer,
        	value=self.tx_gain,
        	callback=self.set_tx_gain,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_tx_gain_sizer)
        _rx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_rx_gain_sizer,
        	value=self.rx_gain,
        	callback=self.set_rx_gain,
        	label='rx_gain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._rx_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_rx_gain_sizer,
        	value=self.rx_gain,
        	callback=self.set_rx_gain,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_rx_gain_sizer)
        self._lo_offset_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.lo_offset,
        	callback=self.set_lo_offset,
        	label="LO Offset",
        	choices=[0, 6e6, 11e6],
        	labels=['0 MHz', '6 MHz', '11 MHz'],
        )
        self.Add(self._lo_offset_chooser)
        self.ieee802_11_ofdm_parse_mac_0_0 = ieee802_11.ofdm_parse_mac(False, True)
        self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(False, True)
        self.ieee802_11_ofdm_mac_0_0 = ieee802_11.ofdm_mac(([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]), ([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]), ([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]))
        self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]), ([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]), ([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]))
        self.ieee802_11_ether_encap_0_0 = ieee802_11.ether_encap(False)
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(False)
        self._freq_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.freq,
        	callback=self.set_freq,
        	label="Channel",
        	choices=[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, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0],
        	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', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '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'],
        )
        self.Add(self._freq_chooser)
        self.foo_packet_pad2_0_0 = foo.packet_pad2(False, False, 0.001, 10000, 10000)
        (self.foo_packet_pad2_0_0).set_min_output_buffer(100000)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000, 10000)
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)
        self.blocks_tuntap_pdu_0_0 = blocks.tuntap_pdu("tap1", 1500, False)
        self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap0", 1500, False)
        self.blocks_throttle_1 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((mult, ))
        (self.blocks_multiply_const_vxx_0_0).set_min_output_buffer(100000)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((mult, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'), (self.ieee802_11_ether_encap_0, 'from tap'))    
        self.msg_connect((self.blocks_tuntap_pdu_0_0, 'pdus'), (self.ieee802_11_ether_encap_0_0, 'from tap'))    
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to tap'), (self.blocks_tuntap_pdu_0, 'pdus'))    
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to wifi'), (self.ieee802_11_ofdm_mac_0, 'app in'))    
        self.msg_connect((self.ieee802_11_ether_encap_0_0, 'to tap'), (self.blocks_tuntap_pdu_0_0, 'pdus'))    
        self.msg_connect((self.ieee802_11_ether_encap_0_0, 'to wifi'), (self.ieee802_11_ofdm_mac_0_0, 'app in'))    
        self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'), (self.wifi_phy_hier_0, 'mac_in'))    
        self.msg_connect((self.ieee802_11_ofdm_mac_0_0, 'phy out'), (self.wifi_phy_hier_0_0, 'mac_in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ether_encap_0, 'from wifi'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ofdm_mac_0, 'phy in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ofdm_parse_mac_0, 'in'))    
        self.msg_connect((self.wifi_phy_hier_0_0, 'mac_out'), (self.ieee802_11_ether_encap_0_0, 'from wifi'))    
        self.msg_connect((self.wifi_phy_hier_0_0, 'mac_out'), (self.ieee802_11_ofdm_mac_0_0, 'phy in'))    
        self.msg_connect((self.wifi_phy_hier_0_0, 'mac_out'), (self.ieee802_11_ofdm_parse_mac_0_0, 'in'))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.foo_packet_pad2_0_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.wifi_phy_hier_0_0, 0))    
        self.connect((self.blocks_throttle_1, 0), (self.wifi_phy_hier_0, 0))    
        self.connect((self.foo_packet_pad2_0, 0), (self.blocks_throttle_1, 0))    
        self.connect((self.foo_packet_pad2_0_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.wifi_phy_hier_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.wifi_phy_hier_0, 1), (self.wxgui_scopesink2_0, 0))    
        self.connect((self.wifi_phy_hier_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))    
        self.connect((self.wifi_phy_hier_0_0, 1), (self.wxgui_scopesink2_0_0, 0))    
Esempio n. 54
0
    def __init__(self, parent):
        """
		Create a new control panel.
		
		Args:
		    parent: the wx parent window
		"""
        self.parent = parent
        wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER)
        parent[SHOW_CONTROL_PANEL_KEY] = True
        parent.subscribe(SHOW_CONTROL_PANEL_KEY, self.Show)
        control_box = wx.BoxSizer(wx.VERTICAL)
        control_box.AddStretchSpacer()
        options_box = forms.static_box_sizer(
            parent=self, sizer=control_box, label="Options", bold=True, orient=wx.VERTICAL
        )
        # average
        # forms.check_box(
        # 	sizer=options_box, parent=self, label='Average',
        # 	ps=parent, key=AVERAGE_KEY,
        # )
        # avg_alpha_text = forms.static_text(
        # 	sizer=options_box, parent=self, label='Avg Alpha',
        # 	converter=forms.float_converter(lambda x: '%.4f'%x),
        # 	ps=parent, key=AVG_ALPHA_KEY, width=50,
        # )
        # avg_alpha_slider = forms.log_slider(
        # 	sizer=options_box, parent=self,
        # 	min_exp=AVG_ALPHA_MIN_EXP,
        # 	max_exp=AVG_ALPHA_MAX_EXP,
        # 	num_steps=SLIDER_STEPS,
        # 	ps=parent, key=AVG_ALPHA_KEY,
        # )
        # for widget in (avg_alpha_text, avg_alpha_slider):
        # 	parent.subscribe(AVERAGE_KEY, widget.Enable)
        # 	widget.Enable(parent[AVERAGE_KEY])
        # begin axes box
        control_box.AddStretchSpacer()
        axes_box = forms.static_box_sizer(
            parent=self, sizer=control_box, label="Axes Options", bold=True, orient=wx.VERTICAL
        )
        # num lines buttons
        # forms.incr_decr_buttons(
        # 	parent=self, sizer=axes_box, label='Time Scale',
        # 	on_incr=self._on_incr_time_scale, on_decr=self._on_decr_time_scale,
        # )
        # dyanmic range buttons
        forms.incr_decr_buttons(
            parent=self,
            sizer=axes_box,
            label="Dyn Range",
            on_incr=self._on_incr_dynamic_range,
            on_decr=self._on_decr_dynamic_range,
        )
        # ref lvl buttons
        forms.incr_decr_buttons(
            parent=self,
            sizer=axes_box,
            label="Ref Level",
            on_incr=self._on_incr_ref_level,
            on_decr=self._on_decr_ref_level,
        )
        # color mode
        forms.drop_down(
            parent=self,
            sizer=axes_box,
            width=100,
            ps=parent,
            key=COLOR_MODE_KEY,
            label="Color",
            choices=map(lambda x: x[1], COLOR_MODES),
            labels=map(lambda x: x[0], COLOR_MODES),
        )
        # autoscale
        forms.single_button(parent=self, sizer=axes_box, label="Autoscale", callback=self.parent.autoscale)
        # clear
        control_box.AddStretchSpacer()
        forms.single_button(parent=self, sizer=control_box, label="Clear", callback=self._on_clear_button)
        # run/stop
        forms.toggle_button(
            sizer=control_box, parent=self, true_label="Stop", false_label="Run", ps=parent, key=RUNNING_KEY
        )
        # set sizer
        self.SetSizerAndFit(control_box)
Esempio n. 55
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="SSB Receiver")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.width = width = 2600
        self.samp_rate = samp_rate = 64e6/256
        self.offset_fine = offset_fine = 1
        self.offset_coarse = offset_coarse = 1
        self.freq = freq = 4.0e6
        self.center = center = +1500
        self.LO = LO = 0
        self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(1, samp_rate, 125000, 25000, firdes.WIN_HAMMING, 6.76)
        self.trans = trans = 500
        self.rx_freq = rx_freq = LO+freq+(offset_coarse+offset_fine)
        self.rf_gain = rf_gain = 10
        self.low = low = center-width/2
        self.lo_freq = lo_freq = LO
        self.high = high = center+width/2
        self.display_selector = display_selector = 1
        self.agc_decay = agc_decay = 5e-5
        self.af_gain = af_gain = 0.18

        ##################################################
        # Blocks
        ##################################################
        _trans_sizer = wx.BoxSizer(wx.VERTICAL)
        self._trans_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_trans_sizer,
        	value=self.trans,
        	callback=self.set_trans,
        	label="Trans",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._trans_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_trans_sizer,
        	value=self.trans,
        	callback=self.set_trans,
        	minimum=100,
        	maximum=2000,
        	num_steps=190,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_trans_sizer, 9, 0, 1, 1)
        self._rx_freq_static_text = forms.static_text(
        	parent=self.GetWin(),
        	value=self.rx_freq,
        	callback=self.set_rx_freq,
        	label="Receive",
        	converter=forms.float_converter(),
        )
        self.GridAdd(self._rx_freq_static_text, 5, 3, 1, 1)
        _rf_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rf_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_rf_gain_sizer,
        	value=self.rf_gain,
        	callback=self.set_rf_gain,
        	label="RF",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._rf_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_rf_gain_sizer,
        	value=self.rf_gain,
        	callback=self.set_rf_gain,
        	minimum=1,
        	maximum=50,
        	num_steps=50,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_rf_gain_sizer, 7, 1, 1, 1)
        self._display_selector_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.display_selector,
        	callback=self.set_display_selector,
        	label="Spectrum",
        	choices=[0, 1],
        	labels=['Baseband','USRP'],
        )
        self.GridAdd(self._display_selector_chooser, 5, 0, 1, 1)
        self._agc_decay_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.agc_decay,
        	callback=self.set_agc_decay,
        	label="AGC",
        	choices=[1e-5, 5e-5, 1e-4],
        	labels=['Fast','Medium','Slow'],
        )
        self.GridAdd(self._agc_decay_chooser, 9, 1, 1, 1)
        _af_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._af_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_af_gain_sizer,
        	value=self.af_gain,
        	callback=self.set_af_gain,
        	label="VOL",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._af_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_af_gain_sizer,
        	value=self.af_gain,
        	callback=self.set_af_gain,
        	minimum=0,
        	maximum=1.0,
        	num_steps=500,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_af_gain_sizer, 8, 1, 1, 1)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	dynamic_range=100,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        	size=(800,300),
        )
        self.Add(self.wxgui_waterfallsink2_0.win)
        _width_sizer = wx.BoxSizer(wx.VERTICAL)
        self._width_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_width_sizer,
        	value=self.width,
        	callback=self.set_width,
        	label="Filter",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._width_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_width_sizer,
        	value=self.width,
        	callback=self.set_width,
        	minimum=100,
        	maximum=5000,
        	num_steps=490,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_width_sizer, 7, 0, 1, 1)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=1,
                taps=None,
                fractional_bw=0.25,
        )
        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(rx_freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(2, 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_gain, 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)
          
        _offset_fine_sizer = wx.BoxSizer(wx.VERTICAL)
        self._offset_fine_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_offset_fine_sizer,
        	value=self.offset_fine,
        	callback=self.set_offset_fine,
        	label="Fine tune",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._offset_fine_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_offset_fine_sizer,
        	value=self.offset_fine,
        	callback=self.set_offset_fine,
        	minimum=-1000,
        	maximum=1000,
        	num_steps=400,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_offset_fine_sizer, 6, 0, 1, 2)
        _offset_coarse_sizer = wx.BoxSizer(wx.VERTICAL)
        self._offset_coarse_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_offset_coarse_sizer,
        	value=self.offset_coarse,
        	callback=self.set_offset_coarse,
        	label="Coarse tune",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._offset_coarse_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_offset_coarse_sizer,
        	value=self.offset_coarse,
        	callback=self.set_offset_coarse,
        	minimum=-120000,
        	maximum=120000,
        	num_steps=960,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_offset_coarse_sizer, 6, 2, 1, 2)
        self._lo_freq_static_text = forms.static_text(
        	parent=self.GetWin(),
        	value=self.lo_freq,
        	callback=self.set_lo_freq,
        	label="LO",
        	converter=forms.float_converter(),
        )
        self.GridAdd(self._lo_freq_static_text, 5, 2, 1, 1)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (xlate_filter_taps), 0, samp_rate)
        self._freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.freq,
        	callback=self.set_freq,
        	label="USRP",
        	converter=forms.float_converter(),
        )
        self.GridAdd(self._freq_text_box, 5, 1, 1, 1)
        self.fftsink = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=rx_freq*display_selector,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=1,
        	ref_scale=13490.0,
        	sample_rate=samp_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=True,
        	avg_alpha=0.5,
        	title="",
        	peak_hold=False,
        	size=(800,300),
        )
        self.GridAdd(self.fftsink.win, 0, 0, 5, 4)
        _center_sizer = wx.BoxSizer(wx.VERTICAL)
        self._center_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_center_sizer,
        	value=self.center,
        	callback=self.set_center,
        	label="Center",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._center_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_center_sizer,
        	value=self.center,
        	callback=self.set_center,
        	minimum=-5000,
        	maximum=5000,
        	num_steps=200,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_center_sizer, 8, 0, 1, 1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((af_gain, ))
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.band_pass_filter = filter.fir_filter_ccc(5, firdes.complex_band_pass(
        	1, samp_rate, -high, -low, trans, firdes.WIN_HAMMING, 6.76))
        self.audio_sink_0 = audio.sink(44100, "", True)
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, agc_decay, 1.0, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.band_pass_filter, 0), (self.analog_agc2_xx_0, 0))    
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_const_vxx_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.audio_sink_0, 1))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.band_pass_filter, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.fftsink, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_waterfallsink2_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_complex_to_real_0, 0))