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

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000
        self.freq = freq = 50

        ##################################################
        # Blocks
        ##################################################
        _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.int_converter(),
            proportion=0,
        )
        self._freq_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_freq_sizer,
            value=self.freq,
            callback=self.set_freq,
            minimum=0,
            maximum=100000,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_freq_sizer)
        self.eb500_control_0 = eb500.EB500Control(freq * 1000, 640000,
                                                  "192.168.2.5", 5555)
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Wifi Loopback Ah")

        ##################################################
        # Variables
        ##################################################
        self.snr = snr = 20
        self.pdu_length = pdu_length = 500
        self.out_buf_size = out_buf_size = 96000
        self.interval = interval = 100
        self.encoding = encoding = 0
        self.chan_est = chan_est = 1

        ##################################################
        # Blocks
        ##################################################
        _snr_sizer = wx.BoxSizer(wx.VERTICAL)
        self._snr_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_snr_sizer,
        	value=self.snr,
        	callback=self.set_snr,
        	label='snr',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._snr_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_snr_sizer,
        	value=self.snr,
        	callback=self.set_snr,
        	minimum=-15,
        	maximum=30,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_snr_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)
        _interval_sizer = wx.BoxSizer(wx.VERTICAL)
        self._interval_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_interval_sizer,
        	value=self.interval,
        	callback=self.set_interval,
        	label="PDU Interval (ms)",
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._interval_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_interval_sizer,
        	value=self.interval,
        	callback=self.set_interval,
        	minimum=10,
        	maximum=1000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_interval_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,8],
        	labels=["BPSK 1/2", "QPSK 1/2", "QPSK 3/4",  "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4", "64QAM 5/6", "256QAM 3/4"  ],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._encoding_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_c(
        	self.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.Add(self.wxgui_scopesink2_0.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.wifi_phy_hier_ah_0 = wifi_phy_hier_ah(
            chan_est=chan_est,
            encoding=encoding,
            sensitivity=0.56,
        )
        self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(False, True)
        self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0xff, 0xff, 0xff, 0xff, 0xff, 0xff]))
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 500, 0)
        (self.foo_packet_pad2_0).set_min_output_buffer(96000)
        self.channels_channel_model_0 = channels.channel_model(
        	noise_voltage=1,
        	frequency_offset=0,
        	epsilon=1.0,
        	taps=(1.0, ),
        	noise_seed=0,
        	block_tags=False
        )
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.float_t, "packet_len")
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(((10**(snr/10.0))**.5, ))
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("".join("x" for i in range(pdu_length))), interval)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.ieee802_11_ofdm_mac_0, 'app in'))    
        self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'), (self.wifi_phy_hier_ah_0, 'mac_in'))    
        self.msg_connect((self.ieee802_11_ofdm_parse_mac_0, 'fer'), (self.blocks_pdu_to_tagged_stream_0, 'pdus'))    
        self.msg_connect((self.wifi_phy_hier_ah_0, 'mac_out'), (self.ieee802_11_ofdm_parse_mac_0, 'in'))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.channels_channel_model_0, 0))    
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.wxgui_numbersink2_0, 0))    
        self.connect((self.channels_channel_model_0, 0), (self.wifi_phy_hier_ah_0, 0))    
        self.connect((self.foo_packet_pad2_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.wifi_phy_hier_ah_0, 0), (self.foo_packet_pad2_0, 0))    
        self.connect((self.wifi_phy_hier_ah_0, 1), (self.wxgui_scopesink2_0, 0))    
Example #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.samp_rate = samp_rate = 8*2**10
		self.nsps_mod = nsps_mod = 4
		self.noise = noise = .1
		self.freq_off = freq_off = 0
		self.ebw_mod = ebw_mod = 0.35

		##################################################
		# Notebooks
		##################################################
		self.n0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
		self.n0.AddPage(grc_wxgui.Panel(self.n0), "tab1")
		self.n0.AddPage(grc_wxgui.Panel(self.n0), "tab2")
		self.n0.AddPage(grc_wxgui.Panel(self.n0), "tab3")
		self.Add(self.n0)

		##################################################
		# Controls
		##################################################
		_nsps_mod_sizer = wx.BoxSizer(wx.VERTICAL)
		self._nsps_mod_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_nsps_mod_sizer,
			value=self.nsps_mod,
			callback=self.set_nsps_mod,
			label="Samples per symbol for DPSK modulator",
			converter=forms.int_converter(),
			proportion=0,
		)
		self._nsps_mod_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_nsps_mod_sizer,
			value=self.nsps_mod,
			callback=self.set_nsps_mod,
			minimum=2,
			maximum=32,
			num_steps=31,
			style=wx.SL_HORIZONTAL,
			cast=int,
			proportion=1,
		)
		self.Add(_nsps_mod_sizer)
		_noise_sizer = wx.BoxSizer(wx.VERTICAL)
		self._noise_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_noise_sizer,
			value=self.noise,
			callback=self.set_noise,
			label="Noise",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._noise_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_noise_sizer,
			value=self.noise,
			callback=self.set_noise,
			minimum=0,
			maximum=1,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Add(_noise_sizer)
		_freq_off_sizer = wx.BoxSizer(wx.VERTICAL)
		self._freq_off_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_freq_off_sizer,
			value=self.freq_off,
			callback=self.set_freq_off,
			label="Freq Offset",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._freq_off_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_freq_off_sizer,
			value=self.freq_off,
			callback=self.set_freq_off,
			minimum=-.5,
			maximum=.5,
			num_steps=1000,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Add(_freq_off_sizer)
		_ebw_mod_sizer = wx.BoxSizer(wx.VERTICAL)
		self._ebw_mod_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_ebw_mod_sizer,
			value=self.ebw_mod,
			callback=self.set_ebw_mod,
			label="Excess BW for DPSK modulator",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._ebw_mod_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_ebw_mod_sizer,
			value=self.ebw_mod,
			callback=self.set_ebw_mod,
			minimum=00.01,
			maximum=10.00,
			num_steps=10*100-1,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Add(_ebw_mod_sizer)

		##################################################
		# Blocks
		##################################################
		self.blks2_dxpsk2_mod_0 = blks2.dqpsk2_mod(
			samples_per_symbol=nsps_mod,
			excess_bw=ebw_mod,
			gray_code=True,
			verbose=False,
			log=False,
		)
		self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder(
				samples_per_symbol=1,
				bits_per_symbol=1,
				access_code="",
				pad_for_usrp=True,
			),
			payload_length=0,
		)
		self.gr_agc2_xx_0 = gr.agc2_cc(1e-1, 1e-2, 1.0, 1.0, 1e3)
		self.gr_channel_model_0 = gr.channel_model(
			noise_voltage=noise,
			frequency_offset=freq_off,
			epsilon=1.0,
			taps=(16.0, ),
			noise_seed=42,
		)
		self.gr_throttle_1_0 = gr.throttle(gr.sizeof_gr_complex*1, samp_rate*nsps_mod*8)
		self.random_source_x_0 = gr.vector_source_b(map(int, numpy.random.randint(0, 2, 1000)), True)
		self.wxgui_constellationsink2_0 = constsink_gl.const_sink_c(
			self.n0.GetPage(1).GetWin(),
			title="Constellation Plot",
			sample_rate=samp_rate*8*nsps_mod/2,
			frame_rate=5,
			const_size=512,
			M=4,
			theta=0,
			alpha=0.005,
			fmax=0.5,
			mu=0.5,
			gain_mu=0.005,
			symbol_rate=samp_rate*8/2,
			omega_limit=0.005,
		)
		self.n0.GetPage(1).Add(self.wxgui_constellationsink2_0.win)

		##################################################
		# Connections
		##################################################
		self.connect((self.blks2_packet_encoder_0, 0), (self.blks2_dxpsk2_mod_0, 0))
		self.connect((self.random_source_x_0, 0), (self.blks2_packet_encoder_0, 0))
		self.connect((self.gr_channel_model_0, 0), (self.gr_agc2_xx_0, 0))
		self.connect((self.gr_throttle_1_0, 0), (self.wxgui_constellationsink2_0, 0))
		self.connect((self.blks2_dxpsk2_mod_0, 0), (self.gr_channel_model_0, 0))
		self.connect((self.gr_agc2_xx_0, 0), (self.gr_throttle_1_0, 0))
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Decoder 433Mhz")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.variable_function_probe_0 = variable_function_probe_0 = 0
        self.target_rate_IM = target_rate_IM = 50000
        self.target_rate = target_rate = 1200
        self.samp_rate = samp_rate = 2000000
        self.xlate_offset = xlate_offset = -47000
        self.variable_text_box_0 = variable_text_box_0 = variable_function_probe_0
        self.variable_static_text_0 = variable_static_text_0 = target_rate
        self.samp_per_sym = samp_per_sym = 5
        self.gain = gain = 1
        self.firdes_tap = firdes_tap = firdes.low_pass(1, samp_rate, 2000, target_rate_IM/4, firdes.WIN_HAMMING, 6.76)

        ##################################################
        # Blocks
        ##################################################
        _target_rate_sizer = wx.BoxSizer(wx.VERTICAL)
        self._target_rate_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_target_rate_sizer,
        	value=self.target_rate,
        	callback=self.set_target_rate,
        	label='target_rate',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._target_rate_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_target_rate_sizer,
        	value=self.target_rate,
        	callback=self.set_target_rate,
        	minimum=1000,
        	maximum=2000,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_target_rate_sizer)
        _xlate_offset_sizer = wx.BoxSizer(wx.VERTICAL)
        self._xlate_offset_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_xlate_offset_sizer,
        	value=self.xlate_offset,
        	callback=self.set_xlate_offset,
        	label="xlate_offset",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._xlate_offset_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_xlate_offset_sizer,
        	value=self.xlate_offset,
        	callback=self.set_xlate_offset,
        	minimum=-samp_rate/10,
        	maximum=samp_rate/10,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_xlate_offset_sizer, 2, 2, 1, 1)
        _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.01,
        	maximum=10,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_gain_sizer, 3, 2, 1, 1)
        self.ask_demod_my_ask_clock_detector_0 = ask_demod.my_ask_clock_detector(0.01, target_rate, samp_per_sym)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
        	self.GetWin(),
        	unit="Units",
        	minval=0,
        	maxval=10,
        	factor=1.0,
        	decimal_places=10,
        	ref_level=0,
        	sample_rate=target_rate*samp_per_sym,
        	number_rate=15,
        	average=False,
        	avg_alpha=None,
        	label="Max level",
        	peak_hold=True,
        	show_gauge=True,
        )
        self.GridAdd(self.wxgui_numbersink2_0.win, 4, 2, 1, 1)
        self.wxgui_fftsink2_1 = 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=target_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=True,
        )
        self.GridAdd(self.wxgui_fftsink2_1.win, 1, 2, 1, 1)
        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="te",
        	converter=forms.int_converter(),
        )
        self.Add(self._variable_text_box_0_text_box)
        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="Sample rate out (target_rate * samp_pre_sym)",
        	converter=forms.float_converter(),
        )
        self.GridAdd(self._variable_static_text_0_static_text, 6, 2, 1, 1)
        def _variable_function_probe_0_probe():
            while True:
                val = self.ask_demod_my_ask_clock_detector_0.samp_adjust()
                try:
                    self.set_variable_function_probe_0(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (1))
        _variable_function_probe_0_thread = threading.Thread(target=_variable_function_probe_0_probe)
        _variable_function_probe_0_thread.daemon = True
        _variable_function_probe_0_thread.start()
        self.freq_xlating_fir_filter_xxx_1 = filter.freq_xlating_fir_filter_ccc(int(samp_rate/target_rate_IM), (firdes_tap), xlate_offset, samp_rate)
        self.fractional_resampler_xx_0 = filter.fractional_resampler_cc(0, (target_rate_IM)/(target_rate*samp_per_sym))
        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.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/home/ubuntu/433/2M_sample_record", True)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*1, "/tmp/gnu_radio_out", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.ask_demod_my_ask_clock_detector_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_numbersink2_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_1, 0))    
        self.connect((self.fractional_resampler_xx_0, 0), (self.blocks_complex_to_mag_squared_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.fractional_resampler_xx_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.wxgui_fftsink2_1, 0))    
Example #5
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Adanalyzer")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        self.channel = ipc.SharedMemory('/chan', ipc.O_CREAT, size=2)
        self.mem = mmap.mmap(self.channel.fd, 2)

        self.filerecord = ipc.SharedMemory('/rec', ipc.O_CREAT, size=2)
        self.rec = mmap.mmap(self.filerecord.fd, 2)

        self.file = ipc.SharedMemory('/file', ipc.O_CREAT, size=19)
        self.name = mmap.mmap(self.file.fd, 19)

        ##################################################
        # Variables
        ##################################################
        self.binfile = binfile = 'pomiar'
        self.samp_rate = samp_rate = 96000
        self.record = record = binfile

        self.mem.seek(0)
        self.channel = channel = int(self.mem.read(1))

        self.baseband = baseband = 60
        self.Recording = Recording = int(self.rec.read(1))

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.GetWin(),
        	baseband_freq=baseband,
        	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_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=baseband,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=50,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=True,
        	avg_alpha=0.666,
        	title="FFT Plot",
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self._record_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.record,
        	callback=self.set_record,
        	label='record',
        	converter=forms.str_converter(),
        )
        self.GridAdd(self._record_text_box, 0, 13, 2, 20)
        _channel_sizer = wx.BoxSizer(wx.VERTICAL)
        self._channel_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_channel_sizer,
        	value=self.channel,
        	callback=self.set_channel,
        	label='channel',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._channel_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_channel_sizer,
        	value=self.channel,
        	callback=self.set_channel,
        	minimum=0,
        	maximum=7,
        	num_steps=7,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.GridAdd(_channel_sizer, 0, 1, 2, 8)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_short*1, "/home/jszum/github/zmqtransfer/zmqfifo", False)
        self._Recording_chooser = forms.button(
        	parent=self.GetWin(),
        	value=self.Recording,
        	callback=self.set_Recording,
        	label='Recording',
        	choices=[0, 1],
        	labels=[],
        )
        self.GridAdd(self._Recording_chooser, 0, 10, 2, 2)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0), (self.blocks_short_to_float_0, 0))    
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.blocks_short_to_float_0, 0), (self.blocks_float_to_complex_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_waterfallsink2_0, 0))    
    def __init__(self,
                 pll_alpha=0.005,
                 satellite='NOAA18',
                 decim=50,
                 gain=25,
                 clock_alpha=0.005,
                 freq=1707e6,
                 deframer_sync_check=True,
                 deframer_insync_frames=2,
                 deframer_outsync_frames=5,
                 symb_rate=600 * 1109,
                 baseband_file=os.environ['HOME'] + '/noaa_hrpt_baseband.dat',
                 frames_file=os.environ['HOME'] + '/noaa_hrpt_frames.hmf'):
        grc_wxgui.top_block_gui.__init__(self,
                                         title="USRP2 NOAA HRPT Receiver")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Parameters
        ##################################################
        self.pll_alpha = pll_alpha
        self.satellite = satellite
        self.decim = decim
        self.gain = gain
        self.clock_alpha = clock_alpha
        self.freq = freq
        self.deframer_sync_check = deframer_sync_check
        self.deframer_insync_frames = deframer_insync_frames
        self.deframer_outsync_frames = deframer_outsync_frames
        self.symb_rate = symb_rate
        self.baseband_file = baseband_file
        self.frames_file = frames_file

        ##################################################
        # Variables
        ##################################################
        self.decim_tb = decim_tb = decim
        self.symb_rate_tb = symb_rate_tb = symb_rate
        self.samp_rate = samp_rate = 100e6 / decim_tb
        self.sps = sps = samp_rate / symb_rate_tb
        self.satellite_text = satellite_text = satellite
        self.samp_rate_st = samp_rate_st = samp_rate
        self.pll_alpha_sl = pll_alpha_sl = pll_alpha
        self.max_clock_offset = max_clock_offset = 0.1
        self.max_carrier_offset = max_carrier_offset = 2 * math.pi * 100e3 / samp_rate
        self.hs = hs = int(sps / 2.0)
        self.gain_tb = gain_tb = gain
        self.freq_tb = freq_tb = freq
        self.frames_file_text_inf = frames_file_text_inf = frames_file
        self.deframer_sync_after_text = deframer_sync_after_text = deframer_insync_frames
        self.deframer_nosync_after_text = deframer_nosync_after_text = deframer_outsync_frames
        self.deframer_check_sync_text = deframer_check_sync_text = deframer_sync_check
        self.datetime_text = datetime_text = strftime("%A, %B %d %Y %H:%M:%S",
                                                      localtime())
        self.clock_alpha_sl = clock_alpha_sl = clock_alpha
        self.baseband_file_text_inf = baseband_file_text_inf = baseband_file

        ##################################################
        # Notebooks
        ##################################################
        self.rx_ntb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "USRP Receiver")
        self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb),
                            "PLL demodulator and Clock sync")
        self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Deframer")
        self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Output")
        self.Add(self.rx_ntb)

        ##################################################
        # Controls
        ##################################################
        self._decim_tb_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(0).GetWin(),
            value=self.decim_tb,
            callback=self.set_decim_tb,
            label="Decimation",
            converter=forms.int_converter(),
        )
        self.rx_ntb.GetPage(0).GridAdd(self._decim_tb_text_box, 1, 3, 1, 1)
        self._symb_rate_tb_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            value=self.symb_rate_tb,
            callback=self.set_symb_rate_tb,
            label="Symbol rate",
            converter=forms.int_converter(),
        )
        self.rx_ntb.GetPage(1).GridAdd(self._symb_rate_tb_text_box, 2, 1, 1, 1)
        self._satellite_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(0).GetWin(),
            value=self.satellite_text,
            callback=self.set_satellite_text,
            label="Sat ",
            converter=forms.str_converter(),
        )
        self.rx_ntb.GetPage(0).GridAdd(self._satellite_text_static_text, 1, 0,
                                       1, 1)
        self._samp_rate_st_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(0).GetWin(),
            value=self.samp_rate_st,
            callback=self.set_samp_rate_st,
            label="Sample rate",
            converter=forms.float_converter(),
        )
        self.rx_ntb.GetPage(0).GridAdd(self._samp_rate_st_static_text, 1, 4, 1,
                                       1)
        _pll_alpha_sl_sizer = wx.BoxSizer(wx.VERTICAL)
        self._pll_alpha_sl_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            sizer=_pll_alpha_sl_sizer,
            value=self.pll_alpha_sl,
            callback=self.set_pll_alpha_sl,
            label="PLL Alpha",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._pll_alpha_sl_slider = forms.slider(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            sizer=_pll_alpha_sl_sizer,
            value=self.pll_alpha_sl,
            callback=self.set_pll_alpha_sl,
            minimum=0.001,
            maximum=0.1,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.rx_ntb.GetPage(1).GridAdd(_pll_alpha_sl_sizer, 1, 0, 1, 1)
        self._gain_tb_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(0).GetWin(),
            value=self.gain_tb,
            callback=self.set_gain_tb,
            label="RX gain [dB]",
            converter=forms.int_converter(),
        )
        self.rx_ntb.GetPage(0).GridAdd(self._gain_tb_text_box, 1, 2, 1, 1)
        self._freq_tb_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(0).GetWin(),
            value=self.freq_tb,
            callback=self.set_freq_tb,
            label="Frequency",
            converter=forms.float_converter(),
        )
        self.rx_ntb.GetPage(0).GridAdd(self._freq_tb_text_box, 1, 1, 1, 1)
        self._frames_file_text_inf_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(3).GetWin(),
            value=self.frames_file_text_inf,
            callback=self.set_frames_file_text_inf,
            label="Frames filename",
            converter=forms.str_converter(),
        )
        self.rx_ntb.GetPage(3).GridAdd(self._frames_file_text_inf_static_text,
                                       3, 0, 1, 1)
        self._deframer_sync_after_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(2).GetWin(),
            value=self.deframer_sync_after_text,
            callback=self.set_deframer_sync_after_text,
            label="Deframe sync after",
            converter=forms.float_converter(),
        )
        self.rx_ntb.GetPage(2).GridAdd(
            self._deframer_sync_after_text_static_text, 3, 0, 1, 1)
        self._deframer_nosync_after_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(2).GetWin(),
            value=self.deframer_nosync_after_text,
            callback=self.set_deframer_nosync_after_text,
            label="Deframer out of sync after",
            converter=forms.float_converter(),
        )
        self.rx_ntb.GetPage(2).GridAdd(
            self._deframer_nosync_after_text_static_text, 4, 0, 1, 1)
        self._deframer_check_sync_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(2).GetWin(),
            value=self.deframer_check_sync_text,
            callback=self.set_deframer_check_sync_text,
            label="Deframer check sync enable",
            converter=forms.str_converter(),
        )
        self.rx_ntb.GetPage(2).GridAdd(
            self._deframer_check_sync_text_static_text, 2, 0, 1, 1)
        self._datetime_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(3).GetWin(),
            value=self.datetime_text,
            callback=self.set_datetime_text,
            label="Local time of aquisition start",
            converter=forms.str_converter(),
        )
        self.rx_ntb.GetPage(3).GridAdd(self._datetime_text_static_text, 1, 0,
                                       1, 1)
        _clock_alpha_sl_sizer = wx.BoxSizer(wx.VERTICAL)
        self._clock_alpha_sl_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            sizer=_clock_alpha_sl_sizer,
            value=self.clock_alpha_sl,
            callback=self.set_clock_alpha_sl,
            label="Clock alpha",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._clock_alpha_sl_slider = forms.slider(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            sizer=_clock_alpha_sl_sizer,
            value=self.clock_alpha_sl,
            callback=self.set_clock_alpha_sl,
            minimum=0.001,
            maximum=0.1,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.rx_ntb.GetPage(1).GridAdd(_clock_alpha_sl_sizer, 1, 1, 1, 1)
        self._baseband_file_text_inf_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(3).GetWin(),
            value=self.baseband_file_text_inf,
            callback=self.set_baseband_file_text_inf,
            label="Baseband filename",
            converter=forms.str_converter(),
        )
        self.rx_ntb.GetPage(3).GridAdd(
            self._baseband_file_text_inf_static_text, 4, 0, 1, 1)

        ##################################################
        # Blocks
        ##################################################
        self.gr_agc_xx_0 = gr.agc_cc(10e-6, 1, 1.0 / 32767.0, 1.0)
        self.gr_binary_slicer_fb_0 = gr.binary_slicer_fb()
        self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_ff(
            sps / 2.0, clock_alpha**2 / 4.0, 0.5, clock_alpha,
            max_clock_offset)
        self.gr_file_sink_0_0 = gr.file_sink(gr.sizeof_short * 1, frames_file)
        self.gr_file_sink_0_0.set_unbuffered(False)
        self.gr_file_sink_0_1 = gr.file_sink(gr.sizeof_short * 2,
                                             baseband_file)
        self.gr_file_sink_0_1.set_unbuffered(False)
        self.gr_float_to_complex_0 = gr.float_to_complex(1)
        self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0 / hs, 4000)
        self.gr_short_to_float_0 = gr.short_to_float()
        self.gr_short_to_float_0_0 = gr.short_to_float()
        self.gr_vector_to_streams_0 = gr.vector_to_streams(
            gr.sizeof_short * 1, 2)
        self.noaa_hrpt_decoder_0 = noaa.hrpt_decoder(True, False)
        self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2 / 4.0,
                                    max_carrier_offset)
        self.poesweather_univ_hrpt_deframer_0 = poesweather.univ_hrpt_deframer(
            deframer_sync_check, 11090, deframer_insync_frames,
            deframer_outsync_frames)
        self.usrp2_source_xxxx2_0 = usrp2.source_16sc()
        self.usrp2_source_xxxx2_0.set_decim(decim_tb)
        self.usrp2_source_xxxx2_0.set_center_freq(freq_tb)
        self.usrp2_source_xxxx2_0.set_gain(gain_tb)
        self.wxgui_fftsink1 = fftsink2.fft_sink_c(
            self.rx_ntb.GetPage(0).GetWin(),
            baseband_freq=freq,
            y_per_div=5,
            y_divs=10,
            ref_level=65,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=30,
            average=True,
            avg_alpha=0.1,
            title="Not filtered spectrum",
            peak_hold=False,
        )
        self.rx_ntb.GetPage(0).Add(self.wxgui_fftsink1.win)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.gr_float_to_complex_0, 0), (self.wxgui_fftsink1, 0))
        self.connect((self.poesweather_univ_hrpt_deframer_0, 0),
                     (self.noaa_hrpt_decoder_0, 0))
        self.connect((self.gr_binary_slicer_fb_0, 0),
                     (self.poesweather_univ_hrpt_deframer_0, 0))
        self.connect((self.poesweather_univ_hrpt_deframer_0, 0),
                     (self.gr_file_sink_0_0, 0))
        self.connect((self.gr_clock_recovery_mm_xx_0, 0),
                     (self.gr_binary_slicer_fb_0, 0))
        self.connect((self.pll, 0), (self.gr_moving_average_xx_0, 0))
        self.connect((self.gr_moving_average_xx_0, 0),
                     (self.gr_clock_recovery_mm_xx_0, 0))
        self.connect((self.gr_agc_xx_0, 0), (self.pll, 0))
        self.connect((self.gr_float_to_complex_0, 0), (self.gr_agc_xx_0, 0))
        self.connect((self.gr_vector_to_streams_0, 0),
                     (self.gr_short_to_float_0, 0))
        self.connect((self.gr_vector_to_streams_0, 1),
                     (self.gr_short_to_float_0_0, 0))
        self.connect((self.usrp2_source_xxxx2_0, 0),
                     (self.gr_vector_to_streams_0, 0))
        self.connect((self.usrp2_source_xxxx2_0, 0),
                     (self.gr_file_sink_0_1, 0))
        self.connect((self.gr_short_to_float_0_0, 0),
                     (self.gr_float_to_complex_0, 1))
        self.connect((self.gr_short_to_float_0, 0),
                     (self.gr_float_to_complex_0, 0))
Example #7
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self,
                                         title="Wideband FM Receiver 1.0")
        _icon_path = "C:\Program Files\GNURadio-3.7\share\icons\hicolor\scalable/apps\gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2e6
        self.gain = gain = 50
        self.fft_size = fft_size = 512
        self.f = f = 106.1e6

        ##################################################
        # Blocks
        ##################################################
        self.notebook0 = self.notebook0 = wx.Notebook(self.GetWin(),
                                                      style=wx.NB_BOTTOM)
        self.notebook0.AddPage(grc_wxgui.Panel(self.notebook0), "RF FFT")
        self.notebook0.AddPage(grc_wxgui.Panel(self.notebook0), "Waterfall")
        self.notebook0.AddPage(grc_wxgui.Panel(self.notebook0), "Audio FFT")
        self.Add(self.notebook0)
        self._fft_size_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.fft_size,
            callback=self.set_fft_size,
            label='FFT Size',
            choices=[512, 1024, 2048, 4096, 8192],
            labels=[],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._fft_size_chooser)
        _f_sizer = wx.BoxSizer(wx.VERTICAL)
        self._f_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_f_sizer,
            value=self.f,
            callback=self.set_f,
            label='f',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._f_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_f_sizer,
            value=self.f,
            callback=self.set_f,
            minimum=88e6,
            maximum=110e6,
            num_steps=220,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_f_sizer)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
            self.notebook0.GetPage(1).GetWin(),
            baseband_freq=f,
            dynamic_range=100,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=fft_size,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='Waterfall Plot',
        )
        self.notebook0.GetPage(1).Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_fftsink2_1 = fftsink2.fft_sink_f(
            self.notebook0.GetPage(2).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=200e3,
            fft_size=2048,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='FFT Plot - Audio',
            peak_hold=False,
            win=window.rectangular,
        )
        self.notebook0.GetPage(2).Add(self.wxgui_fftsink2_1.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.notebook0.GetPage(0).GetWin(),
            baseband_freq=f,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=fft_size,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='FFT Plot',
            peak_hold=False,
            win=window.blackmanharris,
        )
        self.notebook0.GetPage(0).Add(self.wxgui_fftsink2_0.win)
        self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              '')
        self.rtlsdr_source_0.set_clock_source('internal', 0)
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(f, 0)
        self.rtlsdr_source_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(1, 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(5, 0)
        self.rtlsdr_source_0.set_if_gain(5, 0)
        self.rtlsdr_source_0.set_bb_gain(5, 0)
        self.rtlsdr_source_0.set_antenna('ant0', 0)
        self.rtlsdr_source_0.set_bandwidth(250000, 0)

        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=100,
            decimation=441,
            taps=None,
            fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            20,
            firdes.low_pass(1, samp_rate, 100e3, 10e3, firdes.WIN_BLACKMAN,
                            6.76))
        _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 Control',
            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.audio_sink_0 = audio.sink(44100, '', True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=100e3,
            audio_decimation=1,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0), (self.wxgui_fftsink2_1, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.wxgui_waterfallsink2_0, 0))
Example #8
0
    def __init__(
            self,
            satellite='NOAAxx',
            decim=50,
            baseband_file="/home/martin/GNURadioData/hrpt/baseband/HRPT_NOAA19_2010-09-10_12-35-34_UTC_U2_d50.sam",
            frames_file=os.environ['HOME'] + '/noaa_hrpt_frames.hmf',
            deframer_outsync_frames=5,
            deframer_insync_frames=2,
            clock_alpha=0.005,
            gain_mu=0.005,
            pll_alpha=0.005,
            pll_beta=0.00001,
            deframer_sync_check=True,
            symb_rate=600 * 1109):
        grc_wxgui.top_block_gui.__init__(
            self, title="NOAA HRPT Receiver from baseband file")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Parameters
        ##################################################
        self.satellite = satellite
        self.decim = decim
        self.baseband_file = baseband_file
        self.frames_file = frames_file
        self.deframer_outsync_frames = deframer_outsync_frames
        self.deframer_insync_frames = deframer_insync_frames
        self.clock_alpha = clock_alpha
        self.gain_mu = gain_mu
        self.pll_alpha = pll_alpha
        self.pll_beta = pll_beta
        self.deframer_sync_check = deframer_sync_check
        self.symb_rate = symb_rate

        ##################################################
        # Variables
        ##################################################
        self.decim_tb = decim_tb = decim
        self.symb_rate_tb = symb_rate_tb = symb_rate
        self.samp_rate = samp_rate = 100e6 / decim_tb
        self.sps = sps = samp_rate / symb_rate_tb
        self.satellite_text = satellite_text = satellite
        self.samp_rate_st = samp_rate_st = samp_rate
        self.pll_beta_sl = pll_beta_sl = pll_beta
        self.pll_alpha_sl = pll_alpha_sl = pll_alpha
        self.max_clock_offset = max_clock_offset = 0.1
        self.max_carrier_offset = max_carrier_offset = 2 * math.pi * 100e3 / samp_rate
        self.hs = hs = int(sps / 2.0)
        self.gain_mu_sl = gain_mu_sl = gain_mu
        self.frames_file_text_inf = frames_file_text_inf = frames_file
        self.deframer_sync_after_text = deframer_sync_after_text = deframer_insync_frames
        self.deframer_nosync_after_text = deframer_nosync_after_text = deframer_outsync_frames
        self.deframer_check_sync_text = deframer_check_sync_text = deframer_sync_check
        self.datetime_text = datetime_text = strftime("%A, %B %d %Y %H:%M:%S",
                                                      localtime())
        self.clock_alpha_sl = clock_alpha_sl = clock_alpha
        self.baseband_file_text_inf = baseband_file_text_inf = baseband_file

        ##################################################
        # Notebooks
        ##################################################
        self.rx_ntb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Input baseband")
        self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb),
                            "PLL demodulator and Clock sync")
        self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Deframer")
        self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Output")
        self.Add(self.rx_ntb)

        ##################################################
        # Controls
        ##################################################
        self._decim_tb_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(0).GetWin(),
            value=self.decim_tb,
            callback=self.set_decim_tb,
            label="Decimation",
            converter=forms.int_converter(),
        )
        self.rx_ntb.GetPage(0).GridAdd(self._decim_tb_text_box, 1, 3, 1, 1)
        self._symb_rate_tb_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            value=self.symb_rate_tb,
            callback=self.set_symb_rate_tb,
            label="Symbol rate",
            converter=forms.int_converter(),
        )
        self.rx_ntb.GetPage(1).GridAdd(self._symb_rate_tb_text_box, 2, 1, 1, 1)
        self._satellite_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(0).GetWin(),
            value=self.satellite_text,
            callback=self.set_satellite_text,
            label="Sat ",
            converter=forms.str_converter(),
        )
        self.rx_ntb.GetPage(0).GridAdd(self._satellite_text_static_text, 1, 0,
                                       1, 1)
        self._samp_rate_st_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(0).GetWin(),
            value=self.samp_rate_st,
            callback=self.set_samp_rate_st,
            label="Sample rate",
            converter=forms.float_converter(),
        )
        self.rx_ntb.GetPage(0).GridAdd(self._samp_rate_st_static_text, 1, 4, 1,
                                       1)
        _pll_beta_sl_sizer = wx.BoxSizer(wx.VERTICAL)
        self._pll_beta_sl_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            sizer=_pll_beta_sl_sizer,
            value=self.pll_beta_sl,
            callback=self.set_pll_beta_sl,
            label="PLL Beta",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._pll_beta_sl_slider = forms.slider(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            sizer=_pll_beta_sl_sizer,
            value=self.pll_beta_sl,
            callback=self.set_pll_beta_sl,
            minimum=0.000001,
            maximum=0.001,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.rx_ntb.GetPage(1).GridAdd(_pll_beta_sl_sizer, 2, 0, 1, 1)
        _pll_alpha_sl_sizer = wx.BoxSizer(wx.VERTICAL)
        self._pll_alpha_sl_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            sizer=_pll_alpha_sl_sizer,
            value=self.pll_alpha_sl,
            callback=self.set_pll_alpha_sl,
            label="PLL Alpha",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._pll_alpha_sl_slider = forms.slider(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            sizer=_pll_alpha_sl_sizer,
            value=self.pll_alpha_sl,
            callback=self.set_pll_alpha_sl,
            minimum=0.001,
            maximum=0.1,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.rx_ntb.GetPage(1).GridAdd(_pll_alpha_sl_sizer, 1, 0, 1, 1)
        _gain_mu_sl_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_mu_sl_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            sizer=_gain_mu_sl_sizer,
            value=self.gain_mu_sl,
            callback=self.set_gain_mu_sl,
            label="Gain MU",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._gain_mu_sl_slider = forms.slider(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            sizer=_gain_mu_sl_sizer,
            value=self.gain_mu_sl,
            callback=self.set_gain_mu_sl,
            minimum=0.0001,
            maximum=0.01,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.rx_ntb.GetPage(1).GridAdd(_gain_mu_sl_sizer, 1, 2, 1, 1)
        self._frames_file_text_inf_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(3).GetWin(),
            value=self.frames_file_text_inf,
            callback=self.set_frames_file_text_inf,
            label="Frames filename",
            converter=forms.str_converter(),
        )
        self.rx_ntb.GetPage(3).GridAdd(self._frames_file_text_inf_static_text,
                                       3, 0, 1, 1)
        self._deframer_sync_after_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(2).GetWin(),
            value=self.deframer_sync_after_text,
            callback=self.set_deframer_sync_after_text,
            label="Deframe sync after",
            converter=forms.float_converter(),
        )
        self.rx_ntb.GetPage(2).GridAdd(
            self._deframer_sync_after_text_static_text, 3, 0, 1, 1)
        self._deframer_nosync_after_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(2).GetWin(),
            value=self.deframer_nosync_after_text,
            callback=self.set_deframer_nosync_after_text,
            label="Deframer out of sync after",
            converter=forms.float_converter(),
        )
        self.rx_ntb.GetPage(2).GridAdd(
            self._deframer_nosync_after_text_static_text, 4, 0, 1, 1)
        self._deframer_check_sync_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(2).GetWin(),
            value=self.deframer_check_sync_text,
            callback=self.set_deframer_check_sync_text,
            label="Deframer check sync enable",
            converter=forms.str_converter(),
        )
        self.rx_ntb.GetPage(2).GridAdd(
            self._deframer_check_sync_text_static_text, 2, 0, 1, 1)
        self._datetime_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(3).GetWin(),
            value=self.datetime_text,
            callback=self.set_datetime_text,
            label="Local time of aquisition start",
            converter=forms.str_converter(),
        )
        self.rx_ntb.GetPage(3).GridAdd(self._datetime_text_static_text, 1, 0,
                                       1, 1)
        _clock_alpha_sl_sizer = wx.BoxSizer(wx.VERTICAL)
        self._clock_alpha_sl_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            sizer=_clock_alpha_sl_sizer,
            value=self.clock_alpha_sl,
            callback=self.set_clock_alpha_sl,
            label="Clock alpha",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._clock_alpha_sl_slider = forms.slider(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            sizer=_clock_alpha_sl_sizer,
            value=self.clock_alpha_sl,
            callback=self.set_clock_alpha_sl,
            minimum=0.001,
            maximum=0.1,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.rx_ntb.GetPage(1).GridAdd(_clock_alpha_sl_sizer, 1, 1, 1, 1)
        self._baseband_file_text_inf_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(3).GetWin(),
            value=self.baseband_file_text_inf,
            callback=self.set_baseband_file_text_inf,
            label="Baseband filename",
            converter=forms.str_converter(),
        )
        self.rx_ntb.GetPage(3).GridAdd(
            self._baseband_file_text_inf_static_text, 4, 0, 1, 1)

        ##################################################
        # Blocks
        ##################################################
        self.cs2cf = gr.interleaved_short_to_complex()
        self.gr_agc_xx_0_0 = gr.agc_cc(10e-6, 1, 1.0 / 32767.0, 1.0)
        self.gr_binary_slicer_fb_0 = gr.binary_slicer_fb()
        self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_cc(
            sps / 2.0, clock_alpha**2 / 4.0, 0.5, gain_mu_sl, max_clock_offset)
        self.gr_complex_to_real_0 = gr.complex_to_real(1)
        self.gr_costas_loop_cc_0 = gr.costas_loop_cc(pll_alpha_sl, pll_beta_sl,
                                                     0.07, -0.07, 2)
        self.gr_file_sink_0_0 = gr.file_sink(gr.sizeof_short * 1, frames_file)
        self.gr_file_sink_0_0.set_unbuffered(False)
        self.gr_file_source_0 = gr.file_source(gr.sizeof_short * 1,
                                               baseband_file, False)
        self.gr_moving_average_xx_0 = gr.moving_average_cc(hs, 1.0 / hs, 4000)
        self.gr_throttle_0 = gr.throttle(gr.sizeof_short * 1, samp_rate * 2)
        self.noaa_hrpt_decoder_0 = noaa.hrpt_decoder(True, False)
        self.poesweather_univ_hrpt_deframer_0 = poesweather.univ_hrpt_deframer(
            deframer_sync_check, 11090, deframer_insync_frames,
            deframer_outsync_frames)
        self.wxgui_fftsink1 = fftsink2.fft_sink_c(
            self.rx_ntb.GetPage(0).GetWin(),
            baseband_freq=0,
            y_per_div=5,
            y_divs=10,
            ref_level=50,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=30,
            average=True,
            avg_alpha=0.1,
            title="Not filtered spectrum",
            peak_hold=False,
        )
        self.rx_ntb.GetPage(0).Add(self.wxgui_fftsink1.win)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_c(
            self.rx_ntb.GetPage(1).GetWin(),
            title="PSK constellation diagram",
            sample_rate=symb_rate,
            v_scale=0.4,
            v_offset=0,
            t_scale=1 / samp_rate,
            ac_couple=False,
            xy_mode=True,
            num_inputs=1,
            trig_mode=gr.gr_TRIG_MODE_AUTO,
        )
        self.rx_ntb.GetPage(1).Add(self.wxgui_scopesink2_1.win)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.gr_file_source_0, 0), (self.gr_throttle_0, 0))
        self.connect((self.gr_throttle_0, 0), (self.cs2cf, 0))
        self.connect((self.cs2cf, 0), (self.gr_agc_xx_0_0, 0))
        self.connect((self.cs2cf, 0), (self.wxgui_fftsink1, 0))
        self.connect((self.gr_complex_to_real_0, 0),
                     (self.gr_binary_slicer_fb_0, 0))
        self.connect((self.poesweather_univ_hrpt_deframer_0, 0),
                     (self.gr_file_sink_0_0, 0))
        self.connect((self.gr_binary_slicer_fb_0, 0),
                     (self.poesweather_univ_hrpt_deframer_0, 0))
        self.connect((self.poesweather_univ_hrpt_deframer_0, 0),
                     (self.noaa_hrpt_decoder_0, 0))
        self.connect((self.gr_moving_average_xx_0, 0),
                     (self.gr_clock_recovery_mm_xx_0, 0))
        self.connect((self.gr_agc_xx_0_0, 0), (self.gr_costas_loop_cc_0, 0))
        self.connect((self.gr_costas_loop_cc_0, 0),
                     (self.gr_moving_average_xx_0, 0))
        self.connect((self.gr_clock_recovery_mm_xx_0, 0),
                     (self.gr_complex_to_real_0, 0))
        self.connect((self.gr_clock_recovery_mm_xx_0, 0),
                     (self.wxgui_scopesink2_1, 0))
Example #9
0
   def __init__(self, options):
	grc_wxgui.top_block_gui.__init__(self, title="mm3 Nearfield")

	self._down_gain = options.gain
	self._down_freq = options.freq
	self._down_bitrate = options.bitrate
	self._down_bitrate_accuracy = options.bitrate_accuracy
	self._down_post_bitrate_accuracy = options.post_bitrate_accuracy
	self._pulse_len = options.pulse_len
	self._pulse_len_accuracy = options.pulse_len_accuracy
	self._post_pulse_len_accuracy = options.post_pulse_len_accuracy
	self._header_len = options.header_len
	self._packet_len = options.packet_len
	self._sample_rate = options.sample_rate
	self._upload = options.upload
	self._trigger_level = 1.0

	#Set up the GUI elements
	self.nb0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
	self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "RX")
	self.Add(self.nb0)
	self._carrier_text_box = forms.text_box(
		parent=self.nb0.GetPage(0).GetWin(),
		value=self._down_freq,
		callback=self.setDownFreq,
		label="Carrier Frequency",
		converter=forms.float_converter(),
	)
	self.nb0.GetPage(0).Add(self._carrier_text_box)
	self._gain_text_box = forms.text_box(
		parent=self.nb0.GetPage(0).GetWin(),
		value=self._down_gain,
		callback=self.setDownGain,
		label="Baseband Gain",
		converter=forms.float_converter(),
	)
	self.nb0.GetPage(0).Add(self._gain_text_box)
	self._bitrate_text_box = forms.text_box(
		parent=self.nb0.GetPage(0).GetWin(),
		value=self._down_bitrate,
		callback=self.setDownBitrate,
		label="Bitrate",
		converter=forms.float_converter(),
	)
	self.nb0.GetPage(0).Add(self._bitrate_text_box)
	self._bitrate_accuracy_text_box = forms.text_box(
		parent=self.nb0.GetPage(0).GetWin(),
		value=self._down_bitrate_accuracy,
		callback=self.setDownBitrateAccuracy,
		label="Bitrate Accuracy (%)",
		converter=forms.float_converter(),
	)
	self.nb0.GetPage(0).Add(self._bitrate_accuracy_text_box)
	self._post_bitrate_accuracy_text_box = forms.text_box(
		parent=self.nb0.GetPage(0).GetWin(),
		value=self._down_post_bitrate_accuracy,
		callback=self.setDownPostBitrateAccuracy,
		label="Post-sync Bitrate Accuracy (%)",
		converter=forms.float_converter(),
	)
	self.nb0.GetPage(0).Add(self._post_bitrate_accuracy_text_box)
	self._pulse_len_text_box = forms.text_box(
		parent=self.nb0.GetPage(0).GetWin(),
		value=self._pulse_len,
		callback=self.setPulseLen,
		label="Pulse Length",
		converter=forms.float_converter(),
	)
	self.nb0.GetPage(0).Add(self._pulse_len_text_box)
	self._pulse_len_accuracy_text_box = forms.text_box(
		parent=self.nb0.GetPage(0).GetWin(),
		value=self._pulse_len_accuracy,
		callback=self.setPulseLenAccuracy,
		label="Pulse Length Accuracy (%)",
		converter=forms.float_converter(),
	)
	self.nb0.GetPage(0).Add(self._pulse_len_accuracy_text_box)
	self._post_pulse_len_accuracy_text_box = forms.text_box(
		parent=self.nb0.GetPage(0).GetWin(),
		value=self._post_pulse_len_accuracy,
		callback=self.setPostPulseLenAccuracy,
		label="Post-sync Pulse Length Accuracy (%)",
		converter=forms.float_converter(),
	)
	self.nb0.GetPage(0).Add(self._post_pulse_len_accuracy_text_box)
	self._header_len_text_box = forms.text_box(
		parent=self.nb0.GetPage(0).GetWin(),
		value=self._header_len,
		callback=self.setHeaderLen,
		label="Header Length (bits)",
		converter=forms.int_converter(),
	)
	self.nb0.GetPage(0).Add(self._header_len_text_box)
	self._packet_len_text_box = forms.text_box(
		parent=self.nb0.GetPage(0).GetWin(),
		value=self._packet_len,
		callback=self.setPacketLen,
		label="Packet Length (bits)",
		converter=forms.int_converter(),
	)
	self.nb0.GetPage(0).Add(self._packet_len_text_box)

	self._samplerate_text_box = forms.text_box(
		parent=self.nb0.GetPage(0).GetWin(),
		value=self._sample_rate,
		callback=self.setDownSampleRate,
		label="Sample Rate",
		converter=forms.float_converter(),
	)
	self.nb0.GetPage(0).Add(self._samplerate_text_box)
	self.prf_text = forms.static_text(
		parent=self.nb0.GetPage(0).GetWin(),
		value="",
		label="",
		converter=forms.str_converter(),
	)
	self.nb0.GetPage(0).Add(self.prf_text)
	self.pulse_len_text = forms.static_text(
		parent=self.nb0.GetPage(0).GetWin(),
		value="",
		label="",
		converter=forms.str_converter(),
	)
	self.nb0.GetPage(0).Add(self.pulse_len_text)
	self.threshold_text = forms.static_text(
		parent=self.nb0.GetPage(0).GetWin(),
		value="",
		label="",
		converter=forms.str_converter(),
		width=500
	)
	self.nb0.GetPage(0).Add(self.threshold_text)

	if options.playback == True:
		self.source2 = blocks.file_source(gr.sizeof_gr_complex, "iq_recording.dat", True)
		self.source = blocks.throttle(gr.sizeof_gr_complex,self._sample_rate)
		self.connect(self.source2, self.source)
	else:
		self.source = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32'))
		self.source.set_center_freq(options.freq)
		self.source.set_samp_rate(self._sample_rate)
		self.source.set_gain(self._down_gain)

	if options.record == True:
		self.file_sink = blocks.file_sink(gr.sizeof_gr_complex, "iq_recording.dat")
		self.connect(self.source, self.file_sink)

	self.mag = blocks.complex_to_mag_squared()

	self.tm_framer = nearfield.nearfield_demod(self._sample_rate, self._down_bitrate, self._down_bitrate_accuracy, self._down_post_bitrate_accuracy, self._pulse_len, self._pulse_len_accuracy, self._post_pulse_len_accuracy, self._packet_len, self._header_len, GATD_PROFILE_ID)
	self.socket_pdu = blocks.socket_pdu("TCP_SERVER", GATD_HOST, GATD_PORT, 10000)
	self.msg_connect(self.tm_framer, "frame_out", self.socket_pdu, "pdus")

	self.connect(self.source, self.mag, self.tm_framer)

	_threading.Thread(target=self.watchFramer).start()
Example #10
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Gfsk")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1000000
        self.ch = ch = 25
        self.rf_gain = rf_gain = 0
        self.if_gain = if_gain = 20
        self.fsk_deviation_hz = fsk_deviation_hz = 170000
        self.fc = fc = 2400000000+ch*1000000
        self.bw = bw = samp_rate
        self.bitrate = bitrate = 250000
        self.bb_gain = bb_gain = 30

        ##################################################
        # Blocks
        ##################################################
        _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=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_rf_gain_sizer)
        _if_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._if_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_if_gain_sizer,
        	value=self.if_gain,
        	callback=self.set_if_gain,
        	label='if_gain',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._if_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_if_gain_sizer,
        	value=self.if_gain,
        	callback=self.set_if_gain,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_if_gain_sizer)
        _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='bb_gain',
        	converter=forms.int_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=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_bb_gain_sizer)
        self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(fc, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(rf_gain, 0)
        self.osmosdr_sink_0.set_if_gain(if_gain, 0)
        self.osmosdr_sink_0.set_bb_gain(bb_gain, 0)
        self.osmosdr_sink_0.set_antenna("", 0)
        self.osmosdr_sink_0.set_bandwidth(samp_rate, 0)
          
        self.digital_gfsk_mod_0 = digital.gfsk_mod(
        	samples_per_symbol=samp_rate/bitrate,
        	sensitivity=0.5,
        	bt=0.5,
        	verbose=False,
        	log=False,
        )
        _ch_sizer = wx.BoxSizer(wx.VERTICAL)
        self._ch_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_ch_sizer,
        	value=self.ch,
        	callback=self.set_ch,
        	label='ch',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._ch_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_ch_sizer,
        	value=self.ch,
        	callback=self.set_ch,
        	minimum=0,
        	maximum=128,
        	num_steps=128,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_ch_sizer)
        self.blocks_vector_source_x_1 = blocks.vector_source_b([0x00, 0xaa, 0xa2, 0x00, 0x09, 0x89, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x95, 0x7f, 0x1e], True, 1, [])
        (self.blocks_vector_source_x_1).set_min_output_buffer(20)
        (self.blocks_vector_source_x_1).set_max_output_buffer(20)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_vector_source_x_1, 0), (self.digital_gfsk_mod_0, 0))    
        self.connect((self.digital_gfsk_mod_0, 0), (self.osmosdr_sink_0, 0))    
Example #11
0
	def __init__(self, freq_corr=0, avg_frames=1, decim=16, N_id_2=0, N_id_1=134):
		grc_wxgui.top_block_gui.__init__(self, title="Sss Corr5 Gui")
		_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
		self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

		##################################################
		# Parameters
		##################################################
		self.freq_corr = freq_corr
		self.avg_frames = avg_frames
		self.decim = decim
		self.N_id_2 = N_id_2
		self.N_id_1 = N_id_1

		##################################################
		# Variables
		##################################################
		self.vec_half_frame = vec_half_frame = 30720*5/decim
		self.symbol_start = symbol_start = 144/decim
		self.slot_0_10 = slot_0_10 = 1
		self.samp_rate = samp_rate = 30720e3/decim
		self.rot = rot = 0
		self.noise_level = noise_level = 0
		self.fft_size = fft_size = 2048/decim
		self.N_re = N_re = 62

		##################################################
		# Blocks
		##################################################
		_rot_sizer = wx.BoxSizer(wx.VERTICAL)
		self._rot_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_rot_sizer,
			value=self.rot,
			callback=self.set_rot,
			label='rot',
			converter=forms.float_converter(),
			proportion=0,
		)
		self._rot_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_rot_sizer,
			value=self.rot,
			callback=self.set_rot,
			minimum=0,
			maximum=1,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Add(_rot_sizer)
		self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
		self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "SSS ML")
		self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "SSS equ")
		self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "SSS in")
		self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "PSS equ")
		self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "PSS ch est")
		self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "foo")
		self.Add(self.notebook_0)
		_noise_level_sizer = wx.BoxSizer(wx.VERTICAL)
		self._noise_level_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_noise_level_sizer,
			value=self.noise_level,
			callback=self.set_noise_level,
			label='noise_level',
			converter=forms.float_converter(),
			proportion=0,
		)
		self._noise_level_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_noise_level_sizer,
			value=self.noise_level,
			callback=self.set_noise_level,
			minimum=0,
			maximum=10,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Add(_noise_level_sizer)
		self.wxgui_scopesink2_0_1_0_1 = scopesink2.scope_sink_c(
			self.notebook_0.GetPage(3).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=2,
			trig_mode=gr.gr_TRIG_MODE_AUTO,
			y_axis_label="Counts",
		)
		self.notebook_0.GetPage(3).Add(self.wxgui_scopesink2_0_1_0_1.win)
		self.wxgui_scopesink2_0_1_0_0 = scopesink2.scope_sink_c(
			self.notebook_0.GetPage(2).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.notebook_0.GetPage(2).Add(self.wxgui_scopesink2_0_1_0_0.win)
		self.wxgui_scopesink2_0_1_0 = scopesink2.scope_sink_c(
			self.notebook_0.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=gr.gr_TRIG_MODE_AUTO,
			y_axis_label="Counts",
		)
		self.notebook_0.GetPage(1).Add(self.wxgui_scopesink2_0_1_0.win)
		self.wxgui_scopesink2_0_1 = scopesink2.scope_sink_f(
			self.notebook_0.GetPage(0).GetWin(),
			title="Scope Plot",
			sample_rate=100/avg_frames,
			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.notebook_0.GetPage(0).Add(self.wxgui_scopesink2_0_1.win)
		_symbol_start_sizer = wx.BoxSizer(wx.VERTICAL)
		self._symbol_start_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_symbol_start_sizer,
			value=self.symbol_start,
			callback=self.set_symbol_start,
			label='symbol_start',
			converter=forms.int_converter(),
			proportion=0,
		)
		self._symbol_start_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_symbol_start_sizer,
			value=self.symbol_start,
			callback=self.set_symbol_start,
			minimum=0,
			maximum=144/decim,
			num_steps=144/decim,
			style=wx.SL_HORIZONTAL,
			cast=int,
			proportion=1,
		)
		self.Add(_symbol_start_sizer)
		self.sss_ml_fd_0 = sss_ml_fd(
			decim=decim,
			avg_frames=avg_frames,
			N_id_1=N_id_1,
			N_id_2=N_id_2,
			slot_0_10=slot_0_10,
		)
		self.pss_chan_est2_0 = pss_chan_est2(
			N_id_2=N_id_2,
		)
		self.gr_vector_to_stream_0_0_1_0 = gr.vector_to_stream(gr.sizeof_gr_complex*1, N_re)
		self.gr_vector_to_stream_0_0_1 = gr.vector_to_stream(gr.sizeof_gr_complex*1, N_re)
		self.gr_vector_to_stream_0_0_0 = gr.vector_to_stream(gr.sizeof_gr_complex*1, N_re)
		self.gr_vector_to_stream_0_0 = gr.vector_to_stream(gr.sizeof_gr_complex*1, N_re)
		self.gr_vector_to_stream_0 = gr.vector_to_stream(gr.sizeof_gr_complex*1, fft_size)
		self.gr_vector_source_x_0_0_0 = gr.vector_source_c((gen_pss_fd(N_id_2, N_re, False).get_data()), True, N_re)
		self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex*1, samp_rate)
		self.gr_stream_to_vector_0_0 = gr.stream_to_vector(gr.sizeof_gr_complex*1, N_re)
		self.gr_stream_to_vector_0 = gr.stream_to_vector(gr.sizeof_gr_complex*1, fft_size)
		self.gr_stream_mux_0 = gr.stream_mux(gr.sizeof_gr_complex*1, (N_re/2, N_re/2))
		self.gr_null_source_0 = gr.null_source(gr.sizeof_gr_complex*1)
		self.gr_noise_source_x_0 = gr.noise_source_c(gr.GR_GAUSSIAN, noise_level, 0)
		self.gr_multiply_xx_1_0 = gr.multiply_vcc(N_re)
		self.gr_multiply_xx_1 = gr.multiply_vcc(N_re)
		self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((0.005*exp(rot*2*numpy.pi*1j), ))
		self.gr_keep_m_in_n_0_0 = gr.keep_m_in_n(gr.sizeof_gr_complex, N_re/2, fft_size, (fft_size-N_re)/2-1)
		self.gr_keep_m_in_n_0 = gr.keep_m_in_n(gr.sizeof_gr_complex, N_re/2, fft_size, (fft_size)/2)
		self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex*1, "/home/user/git/gr-lte/gr-lte/test/octave/foo_sss_td_in.cfile", True)
		self.gr_fft_vxx_0 = gr.fft_vcc(fft_size, True, (window.blackmanharris(1024)), True, 1)
		self.gr_deinterleave_0 = gr.deinterleave(gr.sizeof_gr_complex*N_re)
		self.gr_channel_model_0 = gr.channel_model(
			noise_voltage=0.005*noise_level,
			frequency_offset=0.0,
			epsilon=1,
			taps=(0.005*exp(rot*2*numpy.pi*1j), ),
			noise_seed=0,
		)
		self.gr_add_xx_0 = gr.add_vcc(1)
		self.blks2_selector_0_0 = grc_blks2.selector(
			item_size=gr.sizeof_gr_complex*1,
			num_inputs=2,
			num_outputs=1,
			input_index=0,
			output_index=0,
		)
		self.blks2_selector_0 = grc_blks2.selector(
			item_size=gr.sizeof_gr_complex*1,
			num_inputs=3,
			num_outputs=2,
			input_index=0,
			output_index=0,
		)

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_noise_source_x_0, 0), (self.gr_add_xx_0, 1))
		self.connect((self.gr_add_xx_0, 0), (self.gr_multiply_const_vxx_0, 0))
		self.connect((self.blks2_selector_0, 0), (self.gr_channel_model_0, 0))
		self.connect((self.blks2_selector_0, 1), (self.gr_add_xx_0, 0))
		self.connect((self.gr_channel_model_0, 0), (self.blks2_selector_0_0, 0))
		self.connect((self.gr_multiply_const_vxx_0, 0), (self.blks2_selector_0_0, 1))
		self.connect((self.gr_file_source_0, 0), (self.blks2_selector_0, 0))
		self.connect((self.blks2_selector_0_0, 0), (self.gr_throttle_0, 0))
		self.connect((self.gr_deinterleave_0, 0), (self.gr_vector_to_stream_0_0_0, 0))
		self.connect((self.gr_vector_to_stream_0_0_0, 0), (self.wxgui_scopesink2_0_1_0_0, 0))
		self.connect((self.gr_vector_to_stream_0_0, 0), (self.wxgui_scopesink2_0_1_0, 0))
		self.connect((self.gr_fft_vxx_0, 0), (self.gr_vector_to_stream_0, 0))
		self.connect((self.gr_vector_to_stream_0, 0), (self.gr_keep_m_in_n_0, 0))
		self.connect((self.gr_stream_to_vector_0_0, 0), (self.gr_deinterleave_0, 0))
		self.connect((self.gr_stream_to_vector_0, 0), (self.gr_fft_vxx_0, 0))
		self.connect((self.gr_vector_to_stream_0_0_1, 0), (self.wxgui_scopesink2_0_1_0_1, 0))
		self.connect((self.gr_vector_to_stream_0_0_1_0, 0), (self.wxgui_scopesink2_0_1_0_1, 1))
		self.connect((self.gr_vector_source_x_0_0_0, 0), (self.gr_vector_to_stream_0_0_1_0, 0))
		self.connect((self.pss_chan_est2_0, 0), (self.gr_multiply_xx_1, 1))
		self.connect((self.gr_multiply_xx_1, 0), (self.sss_ml_fd_0, 0))
		self.connect((self.gr_multiply_xx_1, 0), (self.gr_vector_to_stream_0_0, 0))
		self.connect((self.pss_chan_est2_0, 0), (self.gr_multiply_xx_1_0, 0))
		self.connect((self.gr_deinterleave_0, 1), (self.gr_multiply_xx_1_0, 1))
		self.connect((self.gr_multiply_xx_1_0, 0), (self.gr_vector_to_stream_0_0_1, 0))
		self.connect((self.gr_deinterleave_0, 1), (self.pss_chan_est2_0, 0))
		self.connect((self.gr_vector_to_stream_0, 0), (self.gr_keep_m_in_n_0_0, 0))
		self.connect((self.gr_keep_m_in_n_0_0, 0), (self.gr_stream_mux_0, 0))
		self.connect((self.gr_keep_m_in_n_0, 0), (self.gr_stream_mux_0, 1))
		self.connect((self.gr_stream_mux_0, 0), (self.gr_stream_to_vector_0_0, 0))
		self.connect((self.gr_throttle_0, 0), (self.gr_stream_to_vector_0, 0))
		self.connect((self.gr_null_source_0, 0), (self.blks2_selector_0, 1))
		self.connect((self.gr_null_source_0, 0), (self.blks2_selector_0, 2))
		self.connect((self.sss_ml_fd_0, 0), (self.wxgui_scopesink2_0_1, 0))
		self.connect((self.gr_deinterleave_0, 0), (self.gr_multiply_xx_1, 0))
	def __init__(self, frames_file=os.environ['HOME'] + '/NOAA-XX.hrpt', decim=32, satellite='NOAA-XX', baseband_file=os.environ['HOME'] + '/NOAA-XX.dat', sync_check=False):
		grc_wxgui.top_block_gui.__init__(self, title="NOAA HRPT Baseband To Frames")
		_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
		self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

		##################################################
		# Parameters
		##################################################
		self.frames_file = frames_file
		self.decim = decim
		self.satellite = satellite
		self.baseband_file = baseband_file
		self.sync_check = sync_check

		##################################################
		# Variables
		##################################################
		self.sym_rate = sym_rate = 600*1109
		self.sample_rate = sample_rate = 64e6/decim
		self.config_filename = config_filename = os.environ['HOME']+'/.gnuradio/noaa_hrpt.conf'
		self.sps = sps = sample_rate/sym_rate
		self._saved_pll_alpha_config = ConfigParser.ConfigParser()
		self._saved_pll_alpha_config.read(config_filename)
		try: saved_pll_alpha = self._saved_pll_alpha_config.getfloat("satname", 'pll_alpha')
		except: saved_pll_alpha = 0.01
		self.saved_pll_alpha = saved_pll_alpha
		self._saved_clock_alpha_config = ConfigParser.ConfigParser()
		self._saved_clock_alpha_config.read(config_filename)
		try: saved_clock_alpha = self._saved_clock_alpha_config.getfloat("satname", 'clock_alpha')
		except: saved_clock_alpha = 0.01
		self.saved_clock_alpha = saved_clock_alpha
		self.sync_check_txt = sync_check_txt = sync_check
		self.satname_txt = satname_txt = satellite
		self.pll_alpha = pll_alpha = saved_pll_alpha
		self.max_clock_offset = max_clock_offset = 100e-6
		self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/sample_rate
		self.hs = hs = int(sps/2.0)
		self.frames_file_txt = frames_file_txt = frames_file
		self.decim_txt = decim_txt = decim
		self.clock_alpha = clock_alpha = saved_clock_alpha
		self.baseband_file_txt = baseband_file_txt = baseband_file

		##################################################
		# Notebooks
		##################################################
		self.displays = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
		self.displays.AddPage(grc_wxgui.Panel(self.displays), "NOAA HRPT Spectrum")
		self.displays.AddPage(grc_wxgui.Panel(self.displays), "Information")
		self.Add(self.displays)

		##################################################
		# Controls
		##################################################
		self._sync_check_txt_static_text = forms.static_text(
			parent=self.GetWin(),
			value=self.sync_check_txt,
			callback=self.set_sync_check_txt,
			label="Sync check",
			converter=forms.int_converter(),
		)
		self.GridAdd(self._sync_check_txt_static_text, 0, 3, 1, 1)
		self._satname_txt_static_text = forms.static_text(
			parent=self.GetWin(),
			value=self.satname_txt,
			callback=self.set_satname_txt,
			label="Satellite",
			converter=forms.str_converter(),
		)
		self.GridAdd(self._satname_txt_static_text, 0, 0, 1, 1)
		_pll_alpha_sizer = wx.BoxSizer(wx.VERTICAL)
		self._pll_alpha_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_pll_alpha_sizer,
			value=self.pll_alpha,
			callback=self.set_pll_alpha,
			label="PLL Alpha",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._pll_alpha_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_pll_alpha_sizer,
			value=self.pll_alpha,
			callback=self.set_pll_alpha,
			minimum=0.0,
			maximum=0.5,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_pll_alpha_sizer, 1, 0, 1, 1)
		self._frames_file_txt_static_text = forms.static_text(
			parent=self.displays.GetPage(1).GetWin(),
			value=self.frames_file_txt,
			callback=self.set_frames_file_txt,
			label="Frames output filename",
			converter=forms.str_converter(),
		)
		self.displays.GetPage(1).GridAdd(self._frames_file_txt_static_text, 2, 0, 1, 1)
		self._decim_txt_static_text = forms.static_text(
			parent=self.GetWin(),
			value=self.decim_txt,
			callback=self.set_decim_txt,
			label="Decimation",
			converter=forms.str_converter(),
		)
		self.GridAdd(self._decim_txt_static_text, 0, 1, 1, 1)
		_clock_alpha_sizer = wx.BoxSizer(wx.VERTICAL)
		self._clock_alpha_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_clock_alpha_sizer,
			value=self.clock_alpha,
			callback=self.set_clock_alpha,
			label="Clock Alpha",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._clock_alpha_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_clock_alpha_sizer,
			value=self.clock_alpha,
			callback=self.set_clock_alpha,
			minimum=0.0,
			maximum=0.5,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_clock_alpha_sizer, 1, 1, 1, 1)
		self._baseband_file_txt_static_text = forms.static_text(
			parent=self.displays.GetPage(1).GetWin(),
			value=self.baseband_file_txt,
			callback=self.set_baseband_file_txt,
			label="Baseband filename",
			converter=forms.str_converter(),
		)
		self.displays.GetPage(1).GridAdd(self._baseband_file_txt_static_text, 1, 0, 1, 1)

		##################################################
		# Blocks
		##################################################
		self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0)
		self.decoder = noaa.hrpt_decoder(True,False)
		self.frame_sink = gr.file_sink(gr.sizeof_short*1, "/home/jerry/NOAA-XX.hrpt")
		self.frame_sink.set_unbuffered(False)
		self.gr_binary_slicer_fb_0 = gr.binary_slicer_fb()
		self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_ff(sps/2.0, clock_alpha**2/4.0, 0.5, clock_alpha, max_clock_offset)
		self.gr_file_source_0 = gr.file_source(gr.sizeof_short*1, "/home/jerry/hrpt/baseband/NOAA-18/2011-01-07T132821-NOAA-18.dat", False)
		self.gr_interleaved_short_to_complex_0 = gr.interleaved_short_to_complex()
		self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000)
		self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset)
		self.poesweather_noaa_hrpt_deframer_0 = poesweather.noaa_hrpt_deframer(sync_check)
		self.rx_fft = fftsink2.fft_sink_c(
			self.displays.GetPage(0).GetWin(),
			baseband_freq=0,
			y_per_div=5,
			y_divs=10,
			ref_level=45,
			ref_scale=2.0,
			sample_rate=sample_rate,
			fft_size=1024,
			fft_rate=30,
			average=True,
			avg_alpha=0.1,
			title="NOAA HRPT Spectrum",
			peak_hold=False,
		)
		self.displays.GetPage(0).Add(self.rx_fft.win)
		self.throttle = gr.throttle(gr.sizeof_short*1, sample_rate*10)

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_interleaved_short_to_complex_0, 0), (self.agc, 0))
		self.connect((self.throttle, 0), (self.gr_interleaved_short_to_complex_0, 0))
		self.connect((self.gr_file_source_0, 0), (self.throttle, 0))
		self.connect((self.agc, 0), (self.rx_fft, 0))
		self.connect((self.poesweather_noaa_hrpt_deframer_0, 0), (self.frame_sink, 0))
		self.connect((self.poesweather_noaa_hrpt_deframer_0, 0), (self.decoder, 0))
		self.connect((self.gr_binary_slicer_fb_0, 0), (self.poesweather_noaa_hrpt_deframer_0, 0))
		self.connect((self.agc, 0), (self.pll, 0))
		self.connect((self.pll, 0), (self.gr_moving_average_xx_0, 0))
		self.connect((self.gr_moving_average_xx_0, 0), (self.gr_clock_recovery_mm_xx_0, 0))
		self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 0))
	def __init__(self, gain=25, clock_alpha=0.005, freq=1707e6, decim=25, satellite='MetOp', symb_rate=(3500e3/3+3500e3)/2, pll_alpha=0.005, deframer_sync_check=True, deframer_insync_frames=2, deframer_outsync_frames=5, frames_file=os.environ['HOME'] + '/metop_ahrpt_frames.cadu', baseband_file=os.environ['HOME'] + '/metop_ahrpt_baseband.dat', viterbi_sync_threshold=0.1, viterbi_sync_check=True, viterbi_insync_frames=5, viterbi_outsync_frames=20):
		grc_wxgui.top_block_gui.__init__(self, title="USRP2 MetOp AHRPT Receiver")

		##################################################
		# Parameters
		##################################################
		self.gain = gain
		self.clock_alpha = clock_alpha
		self.freq = freq
		self.decim = decim
		self.satellite = satellite
		self.symb_rate = symb_rate
		self.pll_alpha = pll_alpha
		self.deframer_sync_check = deframer_sync_check
		self.deframer_insync_frames = deframer_insync_frames
		self.deframer_outsync_frames = deframer_outsync_frames
		self.frames_file = frames_file
		self.baseband_file = baseband_file
		self.viterbi_sync_threshold = viterbi_sync_threshold
		self.viterbi_sync_check = viterbi_sync_check
		self.viterbi_insync_frames = viterbi_insync_frames
		self.viterbi_outsync_frames = viterbi_outsync_frames

		##################################################
		# Variables
		##################################################
		self.decim_tb = decim_tb = decim
		self.symb_rate_tb = symb_rate_tb = symb_rate
		self.samp_rate = samp_rate = 100e6/decim_tb
		self.viterbi_sync_threshold_text = viterbi_sync_threshold_text = viterbi_sync_threshold
		self.viterbi_sync_after_text = viterbi_sync_after_text = viterbi_insync_frames
		self.viterbi_outofsync_after_text = viterbi_outofsync_after_text = viterbi_outsync_frames
		self.viterbi_node_sync_text = viterbi_node_sync_text = viterbi_sync_check
		self.sps = sps = samp_rate/symb_rate_tb
		self.satellite_text = satellite_text = satellite
		self.samp_rate_st = samp_rate_st = samp_rate
		self.pll_alpha_sl = pll_alpha_sl = pll_alpha
		self.max_clock_offset = max_clock_offset = 0.1
		self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/samp_rate
		self.gain_tb = gain_tb = gain
		self.freq_tb = freq_tb = freq
		self.frames_file_text_inf = frames_file_text_inf = frames_file
		self.deframer_sync_after_text = deframer_sync_after_text = deframer_insync_frames
		self.deframer_nosync_after_text = deframer_nosync_after_text = deframer_outsync_frames
		self.deframer_check_sync_text = deframer_check_sync_text = deframer_sync_check
		self.datetime_text = datetime_text = strftime("%A, %B %d %Y %H:%M:%S", localtime())
		self.clock_alpha_sl = clock_alpha_sl = clock_alpha
		self.baseband_file_text_inf = baseband_file_text_inf = baseband_file

		##################################################
		# Notebooks
		##################################################
		self.rx_ntb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
		self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "USRP Receiver")
		self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "PLL demodulator and Clock sync")
		self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Viterbi decoder")
		self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Deframer")
		self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Output")
		self.Add(self.rx_ntb)

		##################################################
		# Controls
		##################################################
		self._decim_tb_text_box = forms.text_box(
			parent=self.rx_ntb.GetPage(0).GetWin(),
			value=self.decim_tb,
			callback=self.set_decim_tb,
			label="Decimation",
			converter=forms.int_converter(),
		)
		self.rx_ntb.GetPage(0).GridAdd(self._decim_tb_text_box, 1, 3, 1, 1)
		self._symb_rate_tb_text_box = forms.text_box(
			parent=self.rx_ntb.GetPage(1).GetWin(),
			value=self.symb_rate_tb,
			callback=self.set_symb_rate_tb,
			label="Symbol rate",
			converter=forms.int_converter(),
		)
		self.rx_ntb.GetPage(1).GridAdd(self._symb_rate_tb_text_box, 2, 1, 1, 1)
		self._viterbi_sync_threshold_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(2).GetWin(),
			value=self.viterbi_sync_threshold_text,
			callback=self.set_viterbi_sync_threshold_text,
			label="Viterbi node sync threshold [BER]",
			converter=forms.float_converter(),
		)
		self.rx_ntb.GetPage(2).GridAdd(self._viterbi_sync_threshold_text_static_text, 3, 0, 1, 1)
		self._viterbi_sync_after_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(2).GetWin(),
			value=self.viterbi_sync_after_text,
			callback=self.set_viterbi_sync_after_text,
			label="Valid frames for Viterbi decoder sync",
			converter=forms.float_converter(),
		)
		self.rx_ntb.GetPage(2).GridAdd(self._viterbi_sync_after_text_static_text, 4, 0, 1, 1)
		self._viterbi_outofsync_after_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(2).GetWin(),
			value=self.viterbi_outofsync_after_text,
			callback=self.set_viterbi_outofsync_after_text,
			label="Invalid frames for Viterbi decoder out of sync",
			converter=forms.float_converter(),
		)
		self.rx_ntb.GetPage(2).GridAdd(self._viterbi_outofsync_after_text_static_text, 5, 0, 1, 1)
		self._viterbi_node_sync_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(2).GetWin(),
			value=self.viterbi_node_sync_text,
			callback=self.set_viterbi_node_sync_text,
			label="Viterbi node sync enable",
			converter=forms.str_converter(),
		)
		self.rx_ntb.GetPage(2).GridAdd(self._viterbi_node_sync_text_static_text, 2, 0, 1, 1)
		self._satellite_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(0).GetWin(),
			value=self.satellite_text,
			callback=self.set_satellite_text,
			label="Sat ",
			converter=forms.str_converter(),
		)
		self.rx_ntb.GetPage(0).GridAdd(self._satellite_text_static_text, 1, 0, 1, 1)
		self._samp_rate_st_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(0).GetWin(),
			value=self.samp_rate_st,
			callback=self.set_samp_rate_st,
			label="Sample rate",
			converter=forms.float_converter(),
		)
		self.rx_ntb.GetPage(0).GridAdd(self._samp_rate_st_static_text, 1, 4, 1, 1)
		_pll_alpha_sl_sizer = wx.BoxSizer(wx.VERTICAL)
		self._pll_alpha_sl_text_box = forms.text_box(
			parent=self.rx_ntb.GetPage(1).GetWin(),
			sizer=_pll_alpha_sl_sizer,
			value=self.pll_alpha_sl,
			callback=self.set_pll_alpha_sl,
			label="PLL Alpha",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._pll_alpha_sl_slider = forms.slider(
			parent=self.rx_ntb.GetPage(1).GetWin(),
			sizer=_pll_alpha_sl_sizer,
			value=self.pll_alpha_sl,
			callback=self.set_pll_alpha_sl,
			minimum=0.001,
			maximum=0.1,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.rx_ntb.GetPage(1).GridAdd(_pll_alpha_sl_sizer, 1, 0, 1, 1)
		self._gain_tb_text_box = forms.text_box(
			parent=self.rx_ntb.GetPage(0).GetWin(),
			value=self.gain_tb,
			callback=self.set_gain_tb,
			label="RX gain [dB]",
			converter=forms.int_converter(),
		)
		self.rx_ntb.GetPage(0).GridAdd(self._gain_tb_text_box, 1, 2, 1, 1)
		self._freq_tb_text_box = forms.text_box(
			parent=self.rx_ntb.GetPage(0).GetWin(),
			value=self.freq_tb,
			callback=self.set_freq_tb,
			label="Frequency",
			converter=forms.float_converter(),
		)
		self.rx_ntb.GetPage(0).GridAdd(self._freq_tb_text_box, 1, 1, 1, 1)
		self._frames_file_text_inf_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(4).GetWin(),
			value=self.frames_file_text_inf,
			callback=self.set_frames_file_text_inf,
			label="Frames filename",
			converter=forms.str_converter(),
		)
		self.rx_ntb.GetPage(4).GridAdd(self._frames_file_text_inf_static_text, 3, 0, 1, 1)
		self._deframer_sync_after_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(3).GetWin(),
			value=self.deframer_sync_after_text,
			callback=self.set_deframer_sync_after_text,
			label="Deframe sync after",
			converter=forms.float_converter(),
		)
		self.rx_ntb.GetPage(3).GridAdd(self._deframer_sync_after_text_static_text, 3, 0, 1, 1)
		self._deframer_nosync_after_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(3).GetWin(),
			value=self.deframer_nosync_after_text,
			callback=self.set_deframer_nosync_after_text,
			label="Deframer out of sync after",
			converter=forms.float_converter(),
		)
		self.rx_ntb.GetPage(3).GridAdd(self._deframer_nosync_after_text_static_text, 4, 0, 1, 1)
		self._deframer_check_sync_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(3).GetWin(),
			value=self.deframer_check_sync_text,
			callback=self.set_deframer_check_sync_text,
			label="Deframer check sync enable",
			converter=forms.str_converter(),
		)
		self.rx_ntb.GetPage(3).GridAdd(self._deframer_check_sync_text_static_text, 2, 0, 1, 1)
		self._datetime_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(4).GetWin(),
			value=self.datetime_text,
			callback=self.set_datetime_text,
			label="Local time of aquisition start",
			converter=forms.str_converter(),
		)
		self.rx_ntb.GetPage(4).GridAdd(self._datetime_text_static_text, 1, 0, 1, 1)
		_clock_alpha_sl_sizer = wx.BoxSizer(wx.VERTICAL)
		self._clock_alpha_sl_text_box = forms.text_box(
			parent=self.rx_ntb.GetPage(1).GetWin(),
			sizer=_clock_alpha_sl_sizer,
			value=self.clock_alpha_sl,
			callback=self.set_clock_alpha_sl,
			label="Clock alpha",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._clock_alpha_sl_slider = forms.slider(
			parent=self.rx_ntb.GetPage(1).GetWin(),
			sizer=_clock_alpha_sl_sizer,
			value=self.clock_alpha_sl,
			callback=self.set_clock_alpha_sl,
			minimum=0.001,
			maximum=0.1,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.rx_ntb.GetPage(1).GridAdd(_clock_alpha_sl_sizer, 1, 1, 1, 1)
		self._baseband_file_text_inf_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(4).GetWin(),
			value=self.baseband_file_text_inf,
			callback=self.set_baseband_file_text_inf,
			label="Baseband filename",
			converter=forms.str_converter(),
		)
		self.rx_ntb.GetPage(4).Add(self._baseband_file_text_inf_static_text)

		##################################################
		# Blocks
		##################################################
		self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_cc(sps, clock_alpha_sl*clock_alpha_sl/4.0, 0.5, clock_alpha_sl, 0.05)
		self.gr_costas_loop_cc_0 = gr.costas_loop_cc(pll_alpha_sl, pll_alpha_sl*pll_alpha_sl/4.0, 0.07, -0.07, 4)
		self.gr_file_sink_0_1 = gr.file_sink(gr.sizeof_short*2, baseband_file)
		self.gr_float_to_complex_0 = gr.float_to_complex(1)
		self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((1, ))
		self.gr_short_to_float_0 = gr.short_to_float()
		self.gr_short_to_float_0_0 = gr.short_to_float()
		self.gr_vector_to_streams_0 = gr.vector_to_streams(gr.sizeof_short*1, 2)
		self.usrp2_source_xxxx2_0 = usrp2.source_16sc()
		self.usrp2_source_xxxx2_0.set_decim(decim_tb)
		self.usrp2_source_xxxx2_0.set_center_freq(freq_tb)
		self.usrp2_source_xxxx2_0.set_gain(gain_tb)
		self.wxgui_fftsink1 = fftsink2.fft_sink_c(
			self.rx_ntb.GetPage(0).GetWin(),
			baseband_freq=freq,
			y_per_div=5,
			y_divs=10,
			ref_level=50,
			ref_scale=2.0,
			sample_rate=samp_rate,
			fft_size=1024,
			fft_rate=30,
			average=True,
			avg_alpha=0.1,
			title="Not filtered spectrum",
			peak_hold=False,
		)
		self.rx_ntb.GetPage(0).Add(self.wxgui_fftsink1.win)
		self.wxgui_fftsink2 = fftsink2.fft_sink_c(
			self.rx_ntb.GetPage(0).GetWin(),
			baseband_freq=0,
			y_per_div=5,
			y_divs=10,
			ref_level=50,
			ref_scale=2.0,
			sample_rate=samp_rate,
			fft_size=1024,
			fft_rate=30,
			average=True,
			avg_alpha=0.1,
			title="RRC filtered spectrum",
			peak_hold=False,
		)
		self.rx_ntb.GetPage(0).Add(self.wxgui_fftsink2.win)
		self.wxgui_scopesink2_1 = scopesink2.scope_sink_c(
			self.rx_ntb.GetPage(1).GetWin(),
			title="QPSK constellation diagram",
			sample_rate=symb_rate,
			v_scale=0.4,
			v_offset=0,
			t_scale=1/samp_rate,
			ac_couple=False,
			xy_mode=True,
			num_inputs=1,
		)
		self.rx_ntb.GetPage(1).Add(self.wxgui_scopesink2_1.win)

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_float_to_complex_0, 0), (self.wxgui_fftsink1, 0))
		self.connect((self.gr_float_to_complex_0, 0), (self.wxgui_fftsink2, 0))
		self.connect((self.gr_short_to_float_0, 0), (self.gr_float_to_complex_0, 0))
		self.connect((self.gr_short_to_float_0_0, 0), (self.gr_float_to_complex_0, 1))
		self.connect((self.usrp2_source_xxxx2_0, 0), (self.gr_file_sink_0_1, 0))
		self.connect((self.usrp2_source_xxxx2_0, 0), (self.gr_vector_to_streams_0, 0))
		self.connect((self.gr_vector_to_streams_0, 1), (self.gr_short_to_float_0_0, 0))
		self.connect((self.gr_vector_to_streams_0, 0), (self.gr_short_to_float_0, 0))
		self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_multiply_const_vxx_0, 0))
		self.connect((self.gr_costas_loop_cc_0, 0), (self.gr_clock_recovery_mm_xx_0, 0))
		self.connect((self.gr_float_to_complex_0, 0), (self.gr_costas_loop_cc_0, 0))
		self.connect((self.gr_multiply_const_vxx_0, 0), (self.wxgui_scopesink2_1, 0))
Example #14
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="IEEE 802.15.4 Transceiver using CSS PHY")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.text_msg = text_msg = "Hello World, this is GNU Radio using the IEEE 802.15.4 CSS PHY!"
        self.freq = freq = 2480000000
        self.samp_rate = samp_rate = 1e6
        self.msg_interval = msg_interval = 1000
        self.gain = gain = 20
        self.cur_freq = cur_freq = freq
        self.c = c = ieee802_15_4.css_phy(chirp_number=4, phy_packetsize_bytes=len(text_msg)+15)

        ##################################################
        # Blocks
        ##################################################
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Waterfall")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX FFT")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Time")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Symbols")
        self.Add(self.nb)
        _msg_interval_sizer = wx.BoxSizer(wx.VERTICAL)
        self._msg_interval_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_msg_interval_sizer,
        	value=self.msg_interval,
        	callback=self.set_msg_interval,
        	label="Message interval [ms]",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._msg_interval_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_msg_interval_sizer,
        	value=self.msg_interval,
        	callback=self.set_msg_interval,
        	minimum=1,
        	maximum=5000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_msg_interval_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="TX/RX 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=1,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_gain_sizer)
        self._freq_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.freq,
        	callback=self.set_freq,
        	label="Channel",
        	choices=[1000000 * (2400 + 5 * (i - 10)) for i in range(11, 27)],
        	labels=[i for i in range(11, 27)],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._freq_chooser)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.nb.GetPage(0).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="RX Waterfall",
        )
        self.nb.GetPage(0).Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_scopesink2_3 = scopesink2.scope_sink_c(
        	self.nb.GetPage(3).GetWin(),
        	title="RX Correlator Output",
        	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(3).Add(self.wxgui_scopesink2_3.win)
        self.wxgui_scopesink2_2 = scopesink2.scope_sink_c(
        	self.nb.GetPage(2).GetWin(),
        	title="RX Time Signal",
        	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(2).Add(self.wxgui_scopesink2_2.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.nb.GetPage(1).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=None,
        	title="RX FFT",
        	peak_hold=False,
        )
        self.nb.GetPage(1).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, 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.uhd_usrp_source_0.set_antenna("RX2", 0)
        self.uhd_usrp_sink_1 = uhd.usrp_sink(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_1.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_1.set_center_freq(freq, 0)
        self.uhd_usrp_sink_1.set_gain(gain, 0)
        self.uhd_usrp_sink_1.set_antenna("TX/RX", 0)
        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(([129]), ([131]), ([132]), ([23,42]))
        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True)
        self.ieee802_15_4_css_phy_1 = ieee802_15_4_css_phy(
            bits_per_cw=c.bits_per_symbol,
            chirp_seq=c.chirp_seq,
            codewords=c.codewords,
            intlv_seq=c.intlv_seq,
            len_sub=38,
            nbytes_payload=c.phy_packetsize_bytes,
            nsamp_frame=c.nsamp_frame,
            num_subchirps=c.n_subchirps,
            nzeros_padding=c.padded_zeros,
            phr=c.PHR,
            preamble=c.preamble,
            sfd=c.SFD,
            sym_per_frame=c.nsym_frame,
            threshold=0.95,
            time_gap_1=c.time_gap_1,
            time_gap_2=c.time_gap_2,
        )
        self._cur_freq_static_text = forms.static_text(
        	parent=self.GetWin(),
        	value=self.cur_freq,
        	callback=self.set_cur_freq,
        	label="Current center frequency",
        	converter=forms.float_converter(),
        )
        self.Add(self._cur_freq_static_text)
        self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "127.0.0.1", "8048", 10000, False)
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern(text_msg), msg_interval)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.ieee802_15_4_rime_stack_0, 'bcin'))    
        self.msg_connect((self.blocks_socket_pdu_0_0, 'pdus'), (self.ieee802_15_4_rime_stack_0, 'bcin'))    
        self.msg_connect((self.ieee802_15_4_css_phy_1, 'rxout'), (self.ieee802_15_4_mac_0, 'pdu in'))    
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.ieee802_15_4_css_phy_1, 'txin'))    
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'), (self.ieee802_15_4_rime_stack_0, 'fromMAC'))    
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'bcout'), (self.blocks_socket_pdu_0_0, 'pdus'))    
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'), (self.ieee802_15_4_mac_0, 'app in'))    
        self.connect((self.ieee802_15_4_css_phy_1, 0), (self.uhd_usrp_sink_1, 0))    
        self.connect((self.ieee802_15_4_css_phy_1, 1), (self.wxgui_scopesink2_3, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.ieee802_15_4_css_phy_1, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_scopesink2_2, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_waterfallsink2_0, 0))    
	def __init__(self, freq=1698e6, rate=2e6, frames_file=os.environ['HOME'] + '/data/noaa/frames/NOAA-XX.hrpt', rtlsdr="rtl=0", ifgain=20, satellite='NOAA-XX', sync_check=False, rfgain=40):
		grc_wxgui.top_block_gui.__init__(self, title="Enhanced NOAA HRPT Receiver using USB DVB-T Dongles")
		_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
		self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

		##################################################
		# Parameters
		##################################################
		self.freq = freq
		self.rate = rate
		self.frames_file = frames_file
		self.rtlsdr = rtlsdr
		self.ifgain = ifgain
		self.satellite = satellite
		self.sync_check = sync_check
		self.rfgain = rfgain

		##################################################
		# Variables
		##################################################
		self.sym_rate = sym_rate = 600*1109
		self.samp_rate = samp_rate = rate
		self.config_filename = config_filename = os.environ['HOME']+'/.gnuradio/rtlsdr_noaa_hrpt.conf'
		self.sps = sps = samp_rate/sym_rate
		self._saved_pll_alpha_config = ConfigParser.ConfigParser()
		self._saved_pll_alpha_config.read(config_filename)
		try: saved_pll_alpha = self._saved_pll_alpha_config.getfloat(satellite, 'pll_alpha')
		except: saved_pll_alpha = 0.005
		self.saved_pll_alpha = saved_pll_alpha
		self._saved_clock_alpha_config = ConfigParser.ConfigParser()
		self._saved_clock_alpha_config.read(config_filename)
		try: saved_clock_alpha = self._saved_clock_alpha_config.getfloat(satellite, 'clock_alpha')
		except: saved_clock_alpha = 0.001
		self.saved_clock_alpha = saved_clock_alpha
		self.sync_check_cb = sync_check_cb = sync_check
		self._saved_rf_gain_config = ConfigParser.ConfigParser()
		self._saved_rf_gain_config.read(config_filename)
		try: saved_rf_gain = self._saved_rf_gain_config.getfloat(satellite, 'rf-gain')
		except: saved_rf_gain = rfgain
		self.saved_rf_gain = saved_rf_gain
		self._saved_if_gain_config = ConfigParser.ConfigParser()
		self._saved_if_gain_config.read(config_filename)
		try: saved_if_gain = self._saved_if_gain_config.getfloat(satellite, 'if-gain')
		except: saved_if_gain = ifgain
		self.saved_if_gain = saved_if_gain
		self.satellite_text = satellite_text = satellite
		self.sample_rate_text = sample_rate_text = samp_rate
		self.rf_gain_slider = rf_gain_slider = rfgain
		self.rate_tb = rate_tb = rate
		self.pll_alpha = pll_alpha = saved_pll_alpha
		self.max_clock_offset = max_clock_offset = 0.1
		self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/samp_rate
		self.if_gain_slider = if_gain_slider = ifgain
		self.hs = hs = int(sps/2.0)
		self.freq_tb = freq_tb = freq
		self.frames_outfile_text = frames_outfile_text = frames_file
		self.datetime_text = datetime_text = strftime("%A, %B %d %Y %H:%M:%S", localtime())
		self.clock_alpha = clock_alpha = saved_clock_alpha

		##################################################
		# Blocks
		##################################################
		_rf_gain_slider_sizer = wx.BoxSizer(wx.VERTICAL)
		self._rf_gain_slider_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_rf_gain_slider_sizer,
			value=self.rf_gain_slider,
			callback=self.set_rf_gain_slider,
			label="RF Gain",
			converter=forms.int_converter(),
			proportion=0,
		)
		self._rf_gain_slider_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_rf_gain_slider_sizer,
			value=self.rf_gain_slider,
			callback=self.set_rf_gain_slider,
			minimum=0,
			maximum=100,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=int,
			proportion=1,
		)
		self.GridAdd(_rf_gain_slider_sizer, 2, 0, 1, 1)
		_if_gain_slider_sizer = wx.BoxSizer(wx.VERTICAL)
		self._if_gain_slider_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_if_gain_slider_sizer,
			value=self.if_gain_slider,
			callback=self.set_if_gain_slider,
			label="IF Gain",
			converter=forms.int_converter(),
			proportion=0,
		)
		self._if_gain_slider_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_if_gain_slider_sizer,
			value=self.if_gain_slider,
			callback=self.set_if_gain_slider,
			minimum=0,
			maximum=100,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=int,
			proportion=1,
		)
		self.GridAdd(_if_gain_slider_sizer, 2, 1, 1, 1)
		self.displays = self.displays = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
		self.displays.AddPage(grc_wxgui.Panel(self.displays), "RX NOAA HRPT")
		self.displays.AddPage(grc_wxgui.Panel(self.displays), "Information")
		self.Add(self.displays)
		_clock_alpha_sizer = wx.BoxSizer(wx.VERTICAL)
		self._clock_alpha_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_clock_alpha_sizer,
			value=self.clock_alpha,
			callback=self.set_clock_alpha,
			label="Clock alpha",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._clock_alpha_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_clock_alpha_sizer,
			value=self.clock_alpha,
			callback=self.set_clock_alpha,
			minimum=0.001,
			maximum=0.1,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_clock_alpha_sizer, 2, 3, 1, 1)
		self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
			self.displays.GetPage(0).GetWin(),
			baseband_freq=0,
			y_per_div=5,
			y_divs=10,
			ref_level=-30,
			ref_scale=2.0,
			sample_rate=samp_rate,
			fft_size=512,
			fft_rate=5,
			average=True,
			avg_alpha=0.4,
			title="NOAA HRPT FFT Spectrum",
			peak_hold=False,
		)
		self.displays.GetPage(0).Add(self.wxgui_fftsink2_0.win)
		self._sync_check_cb_check_box = forms.check_box(
			parent=self.GetWin(),
			value=self.sync_check_cb,
			callback=self.set_sync_check_cb,
			label="Continuous sync check",
			true=True,
			false=False,
		)
		self.GridAdd(self._sync_check_cb_check_box, 1, 2, 1, 1)
		self._satellite_text_static_text = forms.static_text(
			parent=self.GetWin(),
			value=self.satellite_text,
			callback=self.set_satellite_text,
			label="Satellite",
			converter=forms.str_converter(),
		)
		self.GridAdd(self._satellite_text_static_text, 0, 1, 1, 1)
		self._sample_rate_text_static_text = forms.static_text(
			parent=self.displays.GetPage(1).GetWin(),
			value=self.sample_rate_text,
			callback=self.set_sample_rate_text,
			label="Sample rate",
			converter=forms.float_converter(),
		)
		self.displays.GetPage(1).GridAdd(self._sample_rate_text_static_text, 3, 0, 1, 1)
		self._rate_tb_text_box = forms.text_box(
			parent=self.GetWin(),
			value=self.rate_tb,
			callback=self.set_rate_tb,
			label="Sample rate",
			converter=forms.float_converter(),
		)
		self.GridAdd(self._rate_tb_text_box, 1, 0, 1, 1)
		self.poesweather_noaa_hrpt_deframer_0 = poesweather.noaa_hrpt_deframer(False)
		_pll_alpha_sizer = wx.BoxSizer(wx.VERTICAL)
		self._pll_alpha_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_pll_alpha_sizer,
			value=self.pll_alpha,
			callback=self.set_pll_alpha,
			label="PLL Alpha",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._pll_alpha_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_pll_alpha_sizer,
			value=self.pll_alpha,
			callback=self.set_pll_alpha,
			minimum=0.005,
			maximum=0.5,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_pll_alpha_sizer, 2, 2, 1, 1)
		self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset)
		self.osmosdr_source_c_0 = osmosdr.source_c( args="nchan=" + str(1) + " " + rtlsdr )
		self.osmosdr_source_c_0.set_sample_rate(samp_rate)
		self.osmosdr_source_c_0.set_center_freq(freq, 0)
		self.osmosdr_source_c_0.set_freq_corr(0, 0)
		self.osmosdr_source_c_0.set_iq_balance_mode(0, 0)
		self.osmosdr_source_c_0.set_gain_mode(0, 0)
		self.osmosdr_source_c_0.set_gain(rf_gain_slider, 0)
		self.osmosdr_source_c_0.set_if_gain(if_gain_slider, 0)
			
		self._freq_tb_text_box = forms.text_box(
			parent=self.GetWin(),
			value=self.freq_tb,
			callback=self.set_freq_tb,
			label="Frequency",
			converter=forms.float_converter(),
		)
		self.GridAdd(self._freq_tb_text_box, 1, 1, 1, 1)
		self._frames_outfile_text_static_text = forms.static_text(
			parent=self.displays.GetPage(1).GetWin(),
			value=self.frames_outfile_text,
			callback=self.set_frames_outfile_text,
			label="Frames filename",
			converter=forms.str_converter(),
		)
		self.displays.GetPage(1).GridAdd(self._frames_outfile_text_static_text, 4, 0, 1, 1)
		self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(sps/2.0, clock_alpha**2/4.0, 0.5, clock_alpha, max_clock_offset)
		self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
		self._datetime_text_static_text = forms.static_text(
			parent=self.displays.GetPage(1).GetWin(),
			value=self.datetime_text,
			callback=self.set_datetime_text,
			label="Acquisition start",
			converter=forms.str_converter(),
		)
		self.displays.GetPage(1).GridAdd(self._datetime_text_static_text, 2, 0, 1, 1)
		self.blocks_moving_average_xx_0 = blocks.moving_average_ff(hs, 1.0/hs, 4000)
		self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_short*1, frames_file)
		self.blocks_file_sink_0.set_unbuffered(False)
		self.analog_agc_xx_0 = analog.agc_cc(1e-5, 1.0, 1.0/32768.0, 1.0)

		##################################################
		# Connections
		##################################################
		self.connect((self.analog_agc_xx_0, 0), (self.pll, 0))
		self.connect((self.pll, 0), (self.blocks_moving_average_xx_0, 0))
		self.connect((self.blocks_moving_average_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
		self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0))
		self.connect((self.poesweather_noaa_hrpt_deframer_0, 0), (self.blocks_file_sink_0, 0))
		self.connect((self.digital_binary_slicer_fb_0, 0), (self.poesweather_noaa_hrpt_deframer_0, 0))
		self.connect((self.osmosdr_source_c_0, 0), (self.wxgui_fftsink2_0, 0))
		self.connect((self.osmosdr_source_c_0, 0), (self.analog_agc_xx_0, 0))
Example #16
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Lora Receive Realtime")

        ##################################################
        # Variables
        ##################################################
        self.target_freq = target_freq = 868.1e6
        self.sf = sf = 12
        self.samp_rate = samp_rate = 2e6
        self.capture_freq = capture_freq = 867.8e6
        self.bw = bw = 125e3
        self.symbols_per_sec = symbols_per_sec = bw / (2**sf)
        self.offset = offset = -(capture_freq - target_freq)
        self.firdes_tap = firdes_tap = firdes.low_pass(1, samp_rate, bw, 10000,
                                                       firdes.WIN_HAMMING,
                                                       6.67)
        self.finetune = finetune = -95
        self.bitrate = bitrate = sf * (1 / (2**sf / bw))

        ##################################################
        # Blocks
        ##################################################
        _finetune_sizer = wx.BoxSizer(wx.VERTICAL)
        self._finetune_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_finetune_sizer,
            value=self.finetune,
            callback=self.set_finetune,
            label='finetune',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._finetune_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_finetune_sizer,
            value=self.finetune,
            callback=self.set_finetune,
            minimum=-150,
            maximum=150,
            num_steps=300,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_finetune_sizer)
        self.wxgui_fftsink2_1 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=capture_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=False,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_1.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(capture_freq, 0)
        self.uhd_usrp_source_0.set_gain(15, 0)
        self.uhd_usrp_source_0.set_antenna("RX2", 0)
        self.lora_lora_receiver_0 = lora.lora_receiver(samp_rate, capture_freq,
                                                       offset, finetune, True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.lora_lora_receiver_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_1, 0))
Example #17
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "C:\Program Files\GNURadio-3.7\share\icons\hicolor\scalable/apps\gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.noise_volt_db = noise_volt_db = -30
        self.symb_rate = symb_rate = 10000
        self.samp_rate = samp_rate = 100000
        self.pi = pi = 3.14152
        self.noise_volt = noise_volt = math.pow(10, noise_volt_db / 20)
        self.freq_offset = freq_offset = 0
        self.error_count_decim = error_count_decim = 100000.0
        self.delay = delay = 2

        ##################################################
        # Blocks
        ##################################################
        _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=0,
            maximum=0.01,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_freq_offset_sizer)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_f(
            self.GetWin(),
            title='Scope Plot',
            sample_rate=symb_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_1.win)
        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=3,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.Add(self.wxgui_scopesink2_0.win)
        _noise_volt_db_sizer = wx.BoxSizer(wx.VERTICAL)
        self._noise_volt_db_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_noise_volt_db_sizer,
            value=self.noise_volt_db,
            callback=self.set_noise_volt_db,
            label='noise_volt_db',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._noise_volt_db_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_noise_volt_db_sizer,
            value=self.noise_volt_db,
            callback=self.set_noise_volt_db,
            minimum=-30,
            maximum=5,
            num_steps=35,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_noise_volt_db_sizer)
        self.fsk_transm_0 = fsk_transm(
            samp_rate=samp_rate,
            symb_rate=symb_rate,
        )
        _delay_sizer = wx.BoxSizer(wx.VERTICAL)
        self._delay_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_delay_sizer,
            value=self.delay,
            callback=self.set_delay,
            label='delay',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._delay_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_delay_sizer,
            value=self.delay,
            callback=self.set_delay,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_delay_sizer)
        self.channels_channel_model_0_0 = channels.channel_model(
            noise_voltage=noise_volt,
            frequency_offset=freq_offset,
            epsilon=1.0,
            taps=(1.0, ),
            noise_seed=0,
            block_tags=False)
        self.blocks_vector_source_x_0_0 = blocks.vector_source_b(
            (0, 1, 1, 1, 1, 1), True, 1, [])
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_copy_0 = blocks.copy(gr.sizeof_char * 1)
        self.blocks_copy_0.set_enabled(True)
        self.blocks_char_to_float_1 = blocks.char_to_float(1, 1)
        self.bfsk_rcv_0 = bfsk_rcv(
            samp_rate=samp_rate,
            symb_rate=symb_rate,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.bfsk_rcv_0, 3), (self.blocks_char_to_float_1, 0))
        self.connect((self.bfsk_rcv_0, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.bfsk_rcv_0, 1), (self.wxgui_scopesink2_0, 1))
        self.connect((self.bfsk_rcv_0, 2), (self.wxgui_scopesink2_0, 2))
        self.connect((self.blocks_char_to_float_1, 0),
                     (self.wxgui_scopesink2_1, 0))
        self.connect((self.blocks_copy_0, 0), (self.fsk_transm_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.channels_channel_model_0_0, 0))
        self.connect((self.blocks_vector_source_x_0_0, 0),
                     (self.blocks_copy_0, 0))
        self.connect((self.channels_channel_model_0_0, 0),
                     (self.bfsk_rcv_0, 0))
        self.connect((self.fsk_transm_0, 0), (self.blocks_throttle_0, 0))
Example #18
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="FM receiver")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2e6
        self.down_rate = down_rate = 150e3
        self.VOLUMEN = VOLUMEN = 70
        self.SINTONIZADOR = SINTONIZADOR = 90.1e6
        self.GANANCIA = GANANCIA = 50

        ##################################################
        # Blocks
        ##################################################
        _VOLUMEN_sizer = wx.BoxSizer(wx.VERTICAL)
        self._VOLUMEN_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_VOLUMEN_sizer,
            value=self.VOLUMEN,
            callback=self.set_VOLUMEN,
            label='Ajuste de sonido',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._VOLUMEN_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_VOLUMEN_sizer,
            value=self.VOLUMEN,
            callback=self.set_VOLUMEN,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_VOLUMEN_sizer, 1, 5, 1, 8)
        _SINTONIZADOR_sizer = wx.BoxSizer(wx.VERTICAL)
        self._SINTONIZADOR_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_SINTONIZADOR_sizer,
            value=self.SINTONIZADOR,
            callback=self.set_SINTONIZADOR,
            label='Sintonizador',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._SINTONIZADOR_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_SINTONIZADOR_sizer,
            value=self.SINTONIZADOR,
            callback=self.set_SINTONIZADOR,
            minimum=10e6,
            maximum=142e6,
            num_steps=10,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_SINTONIZADOR_sizer)
        _GANANCIA_sizer = wx.BoxSizer(wx.VERTICAL)
        self._GANANCIA_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_GANANCIA_sizer,
            value=self.GANANCIA,
            callback=self.set_GANANCIA,
            label='Ganancia',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._GANANCIA_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_GANANCIA_sizer,
            value=self.GANANCIA,
            callback=self.set_GANANCIA,
            minimum=10,
            maximum=70,
            num_steps=12,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.GridAdd(_GANANCIA_sizer, 1, 0, 1, 4)
        self.wxgui_fftsink2_1 = 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=1000,
            average=False,
            avg_alpha=None,
            title='Especto de frecuencias',
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_1.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(SINTONIZADOR, 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(GANANCIA, 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_fff(
            interpolation=48,
            decimation=50,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccf(
            interpolation=1,
            decimation=4,
            taps=None,
            fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 100e3, 1e6, firdes.WIN_HAMMING,
                            6.76))
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink(
            'C:\\Users\\camil\\Desktop\\PROYECTO DE PRUEBA\\Decodificador\\DemodulacionFM.wav',
            1, 20800, 16)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (VOLUMEN / 100, ))
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=500000,
            audio_decimation=10,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.analog_wfm_rcv_0, 0), (self.wxgui_fftsink2_1, 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.blocks_wavfile_sink_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.low_pass_filter_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.rational_resampler_xxx_0, 0))
Example #19
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.volume = volume = 500e-3
        self.samp_rate = samp_rate = 2.4e6
        self.offset_freq = offset_freq = 119e6
        self.freq_corr = freq_corr = 65
        self.freq = freq = 591.28e6
        self.base_freq = base_freq = 560e6

        ##################################################
        # 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)
        self._offset_freq_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.offset_freq,
        	callback=self.set_offset_freq,
        	label="Frequency select",
        	choices=[119e6,120.5e6,123.85e6,126.55e6,128.65e6,132.225e6,560e6],
        	labels=["bradley 119M","worc tow 120.5M", "worc ground 123.85M","worc atais126.55M","worc clrnc 128.65M","logan twr 132.225M","560AM"],
        	style=wx.RA_VERTICAL,
        )
        self.Add(self._offset_freq_chooser)
        _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=254,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_freq_corr_sizer)
        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(offset_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.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=48,
                decimation=48,
                taps=None,
                fractional_bw=None,
        )
        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)
        _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=500e6,
        	maximum=1200e6,
        	num_steps=700,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_freq_sizer)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((volume, ))
        self.audio_sink_0 = audio.sink(48000, "pulse", True)
        self.analog_am_demod_cf_0 = analog.am_demod_cf(
        	channel_rate=48e3,
        	audio_decim=1,
        	audio_pass=5000,
        	audio_stop=5500,
        )
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-5, 1, 0)
        self.analog_agc2_xx_0.set_max_gain(5)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0, 0))    
        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.freq_xlating_fir_filter_xxx_0, 0), (self.analog_agc2_xx_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.analog_am_demod_cf_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))    
Example #20
0
 def build_gui(self):
     self.vbox.AddSpacer(5)
     self.vbox.AddStretchSpacer()
     ##################################################
     # Baseband controls
     ##################################################
     bb_vbox = forms.static_box_sizer(parent=self.panel, label="Baseband Modulation", orient=wx.VERTICAL, bold=True)
     self.vbox.Add(bb_vbox, 0, wx.EXPAND)
     sine_bb_hbox = wx.BoxSizer(wx.HORIZONTAL)
     sweep_bb_hbox = wx.BoxSizer(wx.HORIZONTAL)
     tone_bb_hbox = wx.BoxSizer(wx.HORIZONTAL)
     self.vbox.AddSpacer(10)
     self.vbox.AddStretchSpacer()
     #callback to show/hide forms
     def set_type(type):
         sine_bb_hbox.ShowItems(type == gr.GR_SIN_WAVE)
         sweep_bb_hbox.ShowItems(type == 'sweep')
         tone_bb_hbox.ShowItems(type == '2tone')
         self.vbox.Layout()
     self.tb.subscribe(usrp_siggen.TYPE_KEY, set_type)
     #create sine forms
     sine_bb_hbox.AddSpacer(10)
     forms.text_box(
         parent=self.panel, sizer=sine_bb_hbox,
         label='Frequency (Hz)',
         ps=self.tb,
         key=usrp_siggen.WAVEFORM_FREQ_KEY,
         converter=forms.float_converter(),
     )
     sine_bb_hbox.AddStretchSpacer()
     #create sweep forms
     sweep_bb_hbox.AddSpacer(10)
     forms.text_box(
         parent=self.panel, sizer=sweep_bb_hbox,
         label='Sweep Width (Hz)',
         ps=self.tb,
         key=usrp_siggen.WAVEFORM_FREQ_KEY,
         converter=forms.float_converter(),
     )
     sweep_bb_hbox.AddStretchSpacer()
     forms.text_box(
         parent=self.panel, sizer=sweep_bb_hbox,
         label='Sweep Rate (Hz)',
         ps=self.tb,
         key=usrp_siggen.WAVEFORM2_FREQ_KEY,
         converter=forms.float_converter(),
     )
     sweep_bb_hbox.AddStretchSpacer()
     #create 2tone forms
     tone_bb_hbox.AddSpacer(10)
     forms.text_box(
         parent=self.panel, sizer=tone_bb_hbox,
         label='Tone 1 (Hz)',
         ps=self.tb,
         key=usrp_siggen.WAVEFORM_FREQ_KEY,
         converter=forms.float_converter(),
     )
     tone_bb_hbox.AddStretchSpacer()
     forms.text_box(
         parent=self.panel, sizer=tone_bb_hbox,
         label='Tone 2 (Hz)',
         ps=self.tb,
         key=usrp_siggen.WAVEFORM2_FREQ_KEY,
         converter=forms.float_converter(),
     )
     tone_bb_hbox.AddStretchSpacer()
     forms.radio_buttons(
         parent=self.panel, sizer=bb_vbox,
         choices=usrp_siggen.waveforms.keys(),
         labels=usrp_siggen.waveforms.values(),
         ps=self.tb,
         key=usrp_siggen.TYPE_KEY,
         style=wx.NO_BORDER | wx.RA_HORIZONTAL,
     )
     bb_vbox.AddSpacer(10)
     bb_vbox.Add(sine_bb_hbox, 0, wx.EXPAND)
     bb_vbox.Add(sweep_bb_hbox, 0, wx.EXPAND)
     bb_vbox.Add(tone_bb_hbox, 0, wx.EXPAND)
     set_type(self.tb[usrp_siggen.TYPE_KEY])
     ##################################################
     # Frequency controls
     ##################################################
     fc_vbox = forms.static_box_sizer(parent=self.panel, label="Center Frequency", orient=wx.VERTICAL, bold=True)
     fc_vbox.AddSpacer(5)
     # First row of frequency controls (center frequency)
     freq_hbox = wx.BoxSizer(wx.HORIZONTAL)
     fc_vbox.Add(freq_hbox, 0, wx.EXPAND)
     fc_vbox.AddSpacer(10)
     # Second row of frequency controls (results)
     tr_hbox = wx.BoxSizer(wx.HORIZONTAL)
     fc_vbox.Add(tr_hbox, 0, wx.EXPAND)
     fc_vbox.AddSpacer(5)
     # Add frequency controls to top window sizer
     self.vbox.Add(fc_vbox, 0, wx.EXPAND)
     self.vbox.AddSpacer(10)
     self.vbox.AddStretchSpacer()
     freq_hbox.AddSpacer(5)
     forms.text_box(
         parent=self.panel, sizer=freq_hbox,
         proportion=1,
         converter=forms.float_converter(),
         ps=self.tb,
         key=usrp_siggen.TX_FREQ_KEY,
     )
     freq_hbox.AddSpacer(10)
     forms.slider(
         parent=self.panel, sizer=freq_hbox,
         proportion=2,
         ps=self.tb,
         key=usrp_siggen.TX_FREQ_KEY,
         minimum=self.tb[usrp_siggen.FREQ_RANGE_KEY][0],
         maximum=self.tb[usrp_siggen.FREQ_RANGE_KEY][1],
         num_steps=100,
     )
     freq_hbox.AddSpacer(5)
     tr_hbox.AddSpacer(5)
     forms.static_text(
         parent=self.panel, sizer=tr_hbox,
         label='Daughterboard (Hz)',
         ps=self.tb,
         key=usrp_siggen.BB_FREQ_KEY,
         converter=forms.float_converter(),
         proportion=1,
     )
     tr_hbox.AddSpacer(10)
     forms.static_text(
         parent=self.panel, sizer=tr_hbox,
         label='USRP DDC (Hz)',
         ps=self.tb,
         key=usrp_siggen.DDC_FREQ_KEY,
         converter=forms.float_converter(),
         proportion=1,
     )
     tr_hbox.AddSpacer(5)
     ##################################################
     # Amplitude controls
     ##################################################
     amp_hbox = forms.static_box_sizer(parent=self.panel, label="Amplitude", orient=wx.VERTICAL, bold=True)
     amp_hbox.AddSpacer(5)
     # First row of amp controls (ampl)
     lvl_hbox = wx.BoxSizer(wx.HORIZONTAL)
     amp_hbox.Add(lvl_hbox, 0, wx.EXPAND)
     amp_hbox.AddSpacer(10)
     # Second row of amp controls (tx gain)
     gain_hbox = wx.BoxSizer(wx.HORIZONTAL)
     amp_hbox.Add(gain_hbox, 0, wx.EXPAND)
     amp_hbox.AddSpacer(5)
     self.vbox.Add(amp_hbox, 0, wx.EXPAND)
     self.vbox.AddSpacer(10)
     self.vbox.AddStretchSpacer()
     lvl_hbox.AddSpacer(5)
     forms.text_box(
         parent=self.panel, sizer=lvl_hbox,
         proportion=1,
         converter=forms.float_converter(),
         ps=self.tb,
         key=usrp_siggen.AMPLITUDE_KEY,
         label="Level (0.0-1.0)",
     )
     lvl_hbox.AddSpacer(10)
     forms.log_slider(
         parent=self.panel, sizer=lvl_hbox,
         proportion=2,
         ps=self.tb,
         key=usrp_siggen.AMPLITUDE_KEY,
         min_exp=-6,
         max_exp=0,
         base=10,
         num_steps=100,
     )
     lvl_hbox.AddSpacer(5)
     if self.tb[usrp_siggen.GAIN_RANGE_KEY][0] < self.tb[usrp_siggen.GAIN_RANGE_KEY][1]:
         gain_hbox.AddSpacer(5)
         forms.text_box(
             parent=self.panel, sizer=gain_hbox,
             proportion=1,
             converter=forms.float_converter(),
             ps=self.tb,
             key=usrp_siggen.GAIN_KEY,
             label="TX Gain (dB)",
         )
         gain_hbox.AddSpacer(10)
         forms.slider(
             parent=self.panel, sizer=gain_hbox,
             proportion=2,
             ps=self.tb,
             key=usrp_siggen.GAIN_KEY,
             minimum=self.tb[usrp_siggen.GAIN_RANGE_KEY][0],
             maximum=self.tb[usrp_siggen.GAIN_RANGE_KEY][1],
             step_size=self.tb[usrp_siggen.GAIN_RANGE_KEY][2],
         )
         gain_hbox.AddSpacer(5)
     ##################################################
     # Sample Rate controls
     ##################################################
     sam_hbox = forms.static_box_sizer(parent=self.panel, label="Sample Rate", orient=wx.HORIZONTAL, bold=True)
     self.vbox.Add(sam_hbox, 0, wx.EXPAND)
     self.vbox.AddSpacer(10)
     self.vbox.AddStretchSpacer()
     sam_hbox.AddSpacer(5)
     forms.text_box(
         parent=self.panel, sizer=sam_hbox,
         converter=forms.int_converter(),
         ps=self.tb,
         key=usrp_siggen.INTERP_KEY,
         label="Interpolation",
     )
     sam_hbox.AddStretchSpacer(20)
     forms.static_text(
         parent=self.panel, sizer=sam_hbox,
         label='Sample Rate (sps)',
         ps=self.tb,
         key=usrp_siggen.SAMP_RATE_KEY,
         converter=forms.float_converter(),
     )
     sam_hbox.AddStretchSpacer(20)
     forms.static_text(
         parent=self.panel, sizer=sam_hbox,
         label='Link Rate (bits/sec)',
         ps=self.tb,
         key=usrp_siggen.LINK_RATE_KEY,
         converter=forms.float_converter(),
     )
     sam_hbox.AddSpacer(5)
     ##################################################
     # USRP status
     ##################################################
     u2_hbox = forms.static_box_sizer(parent=self.panel, label="USRP Status", orient=wx.HORIZONTAL, bold=True)
     self.vbox.Add(u2_hbox, 0, wx.EXPAND)
     self.vbox.AddSpacer(10)
     self.vbox.AddStretchSpacer()
     u2_hbox.AddSpacer(10)
     forms.static_text(
         parent=self.panel, sizer=u2_hbox,
         ps=self.tb,
         key=usrp_siggen.DESC_KEY,
         converter=forms.str_converter(),
     )
     self.vbox.AddSpacer(5)
     self.vbox.AddStretchSpacer()
Example #21
0
    def __init__(self, queue):
        grc_wxgui.top_block_gui.__init__(self, title="Pager 6Ch Decode")
        _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 = 2000000
        self.xlate_decimation = xlate_decimation = 80
        self.hunter_freq_5 = hunter_freq_5 = 0
        self.hunter_freq_4 = hunter_freq_4 = 0
        self.hunter_freq_3 = hunter_freq_3 = 0
        self.hunter_freq_2 = hunter_freq_2 = 0
        self.hunter_freq_1 = hunter_freq_1 = 0
        self.hunter_freq_0 = hunter_freq_0 = 0
        self.gain = gain = 10
        self.frequency = frequency = 929000000
        self.filter_width = filter_width = 5120
        self.fft_taps = fft_taps = filter.firdes.low_pass_2(
            1, samp_rate, 10000, 1000, 0.1)
        self.fft_n_elements = fft_n_elements = 2048

        ##################################################
        # Blocks
        ##################################################
        _hunter_freq_5_sizer = wx.BoxSizer(wx.VERTICAL)
        self._hunter_freq_5_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_hunter_freq_5_sizer,
            value=self.hunter_freq_5,
            callback=self.set_hunter_freq_5,
            label='hunter_freq_5',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._hunter_freq_5_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_hunter_freq_5_sizer,
            value=self.hunter_freq_5,
            callback=self.set_hunter_freq_5,
            minimum=-5000000,
            maximum=5000000,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_hunter_freq_5_sizer)
        _hunter_freq_4_sizer = wx.BoxSizer(wx.VERTICAL)
        self._hunter_freq_4_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_hunter_freq_4_sizer,
            value=self.hunter_freq_4,
            callback=self.set_hunter_freq_4,
            label='hunter_freq_4',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._hunter_freq_4_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_hunter_freq_4_sizer,
            value=self.hunter_freq_4,
            callback=self.set_hunter_freq_4,
            minimum=-5000000,
            maximum=5000000,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_hunter_freq_4_sizer)
        _hunter_freq_3_sizer = wx.BoxSizer(wx.VERTICAL)
        self._hunter_freq_3_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_hunter_freq_3_sizer,
            value=self.hunter_freq_3,
            callback=self.set_hunter_freq_3,
            label='hunter_freq_3',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._hunter_freq_3_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_hunter_freq_3_sizer,
            value=self.hunter_freq_3,
            callback=self.set_hunter_freq_3,
            minimum=-5000000,
            maximum=5000000,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_hunter_freq_3_sizer)
        _hunter_freq_2_sizer = wx.BoxSizer(wx.VERTICAL)
        self._hunter_freq_2_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_hunter_freq_2_sizer,
            value=self.hunter_freq_2,
            callback=self.set_hunter_freq_2,
            label='hunter_freq_2',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._hunter_freq_2_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_hunter_freq_2_sizer,
            value=self.hunter_freq_2,
            callback=self.set_hunter_freq_2,
            minimum=-5000000,
            maximum=5000000,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_hunter_freq_2_sizer)
        _hunter_freq_1_sizer = wx.BoxSizer(wx.VERTICAL)
        self._hunter_freq_1_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_hunter_freq_1_sizer,
            value=self.hunter_freq_1,
            callback=self.set_hunter_freq_1,
            label='hunter_freq_1',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._hunter_freq_1_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_hunter_freq_1_sizer,
            value=self.hunter_freq_1,
            callback=self.set_hunter_freq_1,
            minimum=-5000000,
            maximum=5000000,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_hunter_freq_1_sizer)
        _hunter_freq_0_sizer = wx.BoxSizer(wx.VERTICAL)
        self._hunter_freq_0_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_hunter_freq_0_sizer,
            value=self.hunter_freq_0,
            callback=self.set_hunter_freq_0,
            label='hunter_freq_0',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._hunter_freq_0_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_hunter_freq_0_sizer,
            value=self.hunter_freq_0,
            callback=self.set_hunter_freq_0,
            minimum=-5000000,
            maximum=5000000,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_hunter_freq_0_sizer)
        _frequency_sizer = wx.BoxSizer(wx.VERTICAL)
        self._frequency_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_frequency_sizer,
            value=self.frequency,
            callback=self.set_frequency,
            label='Frequency',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._frequency_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_frequency_sizer,
            value=self.frequency,
            callback=self.set_frequency,
            minimum=80000000,
            maximum=1100000000,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_frequency_sizer)
        self.zeromq_push_sink_0_0 = zeromq.push_sink(gr.sizeof_float,
                                                     fft_n_elements,
                                                     'tcp://127.0.0.1:9000',
                                                     100, False, -1)
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(
            ('localhost', 8080), allow_none=True)
        self.xmlrpc_server_0.register_instance(self)
        self.xmlrpc_server_0_thread = threading.Thread(
            target=self.xmlrpc_server_0.serve_forever)
        self.xmlrpc_server_0_thread.daemon = True
        self.xmlrpc_server_0_thread.start()
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=frequency,
            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='master_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(frequency, 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(40, 0)
        self.rtlsdr_source_0.set_if_gain(0, 0)
        self.rtlsdr_source_0.set_bb_gain(0, 0)
        self.rtlsdr_source_0.set_antenna('', 0)
        self.rtlsdr_source_0.set_bandwidth(samp_rate, 0)

        _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=50,
            num_steps=50,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_gain_sizer)
        self.freq_xlating_fft_filter_ccc_0_0_3 = filter.freq_xlating_fft_filter_ccc(
            xlate_decimation, (fft_taps), frequency + hunter_freq_5, samp_rate)
        self.freq_xlating_fft_filter_ccc_0_0_3.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0_0_3.declare_sample_delay(0)
        self.freq_xlating_fft_filter_ccc_0_0_2 = filter.freq_xlating_fft_filter_ccc(
            xlate_decimation, (fft_taps), frequency + hunter_freq_4, samp_rate)
        self.freq_xlating_fft_filter_ccc_0_0_2.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0_0_2.declare_sample_delay(0)
        self.freq_xlating_fft_filter_ccc_0_0_1 = filter.freq_xlating_fft_filter_ccc(
            xlate_decimation, (fft_taps), frequency + hunter_freq_3, samp_rate)
        self.freq_xlating_fft_filter_ccc_0_0_1.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0_0_1.declare_sample_delay(0)
        self.freq_xlating_fft_filter_ccc_0_0_0 = filter.freq_xlating_fft_filter_ccc(
            xlate_decimation, (fft_taps), frequency + hunter_freq_2, 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(
            xlate_decimation, (fft_taps), frequency + hunter_freq_1, 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(
            xlate_decimation, (fft_taps), frequency + hunter_freq_0, samp_rate)
        self.freq_xlating_fft_filter_ccc_0.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0)
        _filter_width_sizer = wx.BoxSizer(wx.VERTICAL)
        self._filter_width_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_filter_width_sizer,
            value=self.filter_width,
            callback=self.set_filter_width,
            label='filter_width',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._filter_width_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_filter_width_sizer,
            value=self.filter_width,
            callback=self.set_filter_width,
            minimum=2048,
            maximum=40960,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_filter_width_sizer)
        self.fft_vxx_0 = fft.fft_vcc(fft_n_elements, True,
                                     (window.blackmanharris(fft_n_elements)),
                                     True, 1)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, fft_n_elements)
        self.blocks_stream_to_vector_1 = blocks.stream_to_vector(
            gr.sizeof_float * 1, fft_n_elements)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, fft_n_elements)
        self.blocks_null_sink_0_0_3 = blocks.null_sink(gr.sizeof_gr_complex *
                                                       1)
        self.blocks_null_sink_0_0_2 = blocks.null_sink(gr.sizeof_gr_complex *
                                                       1)
        self.blocks_null_sink_0_0_1 = blocks.null_sink(gr.sizeof_gr_complex *
                                                       1)
        self.blocks_null_sink_0_0_0 = blocks.null_sink(gr.sizeof_gr_complex *
                                                       1)
        self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        # FLEX protocol demodulator
        self.flex0 = pager.flex_demod(queue, 0, False,
                                      False)  # options.verbose, options.log
        self.flex1 = pager.flex_demod(queue, 0, False,
                                      False)  # options.verbose, options.log
        self.flex2 = pager.flex_demod(queue, 0, False,
                                      False)  # options.verbose, options.log
        self.flex3 = pager.flex_demod(queue, 0, False,
                                      False)  # options.verbose, options.log
        self.flex4 = pager.flex_demod(queue, 0, False,
                                      False)  # options.verbose, options.log
        self.flex5 = pager.flex_demod(queue, 0, False,
                                      False)  # options.verbose, options.log

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_stream_to_vector_1, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_stream_to_vector_1, 0),
                     (self.zeromq_push_sink_0_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.flex0, 0))
        self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0),
                     (self.flex1, 0))
        self.connect((self.freq_xlating_fft_filter_ccc_0_0_0, 0),
                     (self.flex2, 0))
        self.connect((self.freq_xlating_fft_filter_ccc_0_0_1, 0),
                     (self.flex3, 0))
        self.connect((self.freq_xlating_fft_filter_ccc_0_0_2, 0),
                     (self.flex4, 0))
        self.connect((self.freq_xlating_fft_filter_ccc_0_0_3, 0),
                     (self.flex5, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        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.freq_xlating_fft_filter_ccc_0_0_1, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.freq_xlating_fft_filter_ccc_0_0_2, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.freq_xlating_fft_filter_ccc_0_0_3, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0, 0))
Example #22
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()
Example #23
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.tuner = tuner = 434e6
        self.freq_offset = freq_offset = -200000
        self.width = width = 10000
        self.variable_static_text_0 = variable_static_text_0 = tuner - freq_offset
        self.squelch = squelch = -30
        self.samp_rate = samp_rate = 1.024e6
        self.demodgain = demodgain = 14
        self.cutoff = cutoff = 110000

        ##################################################
        # 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='width',
        	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=0,
        	maximum=400000,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_width_sizer, 0, 3, 1, 1)
        _tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_tuner_sizer,
        	value=self.tuner,
        	callback=self.set_tuner,
        	label='tuner',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_tuner_sizer,
        	value=self.tuner,
        	callback=self.set_tuner,
        	minimum=0,
        	maximum=2e9,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_tuner_sizer, 1, 0, 1, 7)
        _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=-50,
        	maximum=20,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_squelch_sizer, 0, 1, 1, 1)
        self.nbook = self.nbook = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nbook.AddPage(grc_wxgui.Panel(self.nbook), "Scope")
        self.nbook.AddPage(grc_wxgui.Panel(self.nbook), "FSK")
        self.nbook.AddPage(grc_wxgui.Panel(self.nbook), "Waterfall")
        self.GridAdd(self.nbook, 2, 0, 1, 10)
        _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=-1e6,
        	maximum=1e6,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_freq_offset_sizer, 0, 4, 1, 1)
        _demodgain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._demodgain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_demodgain_sizer,
        	value=self.demodgain,
        	callback=self.set_demodgain,
        	label='demodgain',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._demodgain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_demodgain_sizer,
        	value=self.demodgain,
        	callback=self.set_demodgain,
        	minimum=-1,
        	maximum=42,
        	num_steps=44,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.GridAdd(_demodgain_sizer, 0, 0, 1, 1)
        _cutoff_sizer = wx.BoxSizer(wx.VERTICAL)
        self._cutoff_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_cutoff_sizer,
        	value=self.cutoff,
        	callback=self.set_cutoff,
        	label='cutoff',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._cutoff_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_cutoff_sizer,
        	value=self.cutoff,
        	callback=self.set_cutoff,
        	minimum=0,
        	maximum=1000000,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_cutoff_sizer, 0, 2, 1, 1)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.nbook.GetPage(2).GetWin(),
        	baseband_freq=tuner,
        	dynamic_range=60,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        )
        self.nbook.GetPage(2).Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_scopesink2_0_0 = scopesink2.scope_sink_f(
        	self.nbook.GetPage(1).GetWin(),
        	title="Scope Plot 1",
        	sample_rate=samp_rate,
        	v_scale=1,
        	v_offset=0.5,
        	t_scale=0.02,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=2,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.nbook.GetPage(1).Add(self.wxgui_scopesink2_0_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.nbook.GetPage(0).GetWin(),
        	baseband_freq=tuner,
        	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.nbook.GetPage(0).Add(self.wxgui_fftsink2_0.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="Tuned to",
        	converter=forms.float_converter(),
        )
        self.GridAdd(self._variable_static_text_0_static_text, 0, 5, 1, 1)
        self.osmosdr_source_c_0_1 = osmosdr.source()
        self.osmosdr_source_c_0_1.set_sample_rate(samp_rate)
        self.osmosdr_source_c_0_1.set_center_freq(tuner+freq_offset, 0)
        self.osmosdr_source_c_0_1.set_freq_corr(21, 0)
        self.osmosdr_source_c_0_1.set_iq_balance_mode(0, 0)
        self.osmosdr_source_c_0_1.set_gain_mode(0, 0)
        self.osmosdr_source_c_0_1.set_gain(demodgain, 0)
        self.osmosdr_source_c_0_1.set_if_gain(24, 0)
        self.osmosdr_source_c_0_1.set_bb_gain(20, 0)
        self.osmosdr_source_c_0_1.set_antenna("", 0)
        self.osmosdr_source_c_0_1.set_bandwidth(0, 0)
          
        self.freq_xlating_fir_filter_xxx_0_1 = filter.freq_xlating_fir_filter_ccc(1, (firdes.low_pass(1, samp_rate,cutoff, width,  firdes.WIN_BLACKMAN, 6.76)), -freq_offset, samp_rate)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_uchar_to_float_0 = blocks.uchar_to_float()
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "capture", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch, 1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(demodgain)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0), (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_1, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_1, 0), (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.osmosdr_source_c_0_1, 0), (self.freq_xlating_fir_filter_xxx_0_1, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_uchar_to_float_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_uchar_to_float_0, 0), (self.wxgui_scopesink2_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_1, 0), (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.wxgui_scopesink2_0_0, 1))
Example #24
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.var_sample_rate = var_sample_rate = 2500000
        self.var_reverse_fft_size = var_reverse_fft_size = 32
        self.var_freq = var_freq = 433000000
        self.var_fft_size = var_fft_size = 2048

        ##################################################
        # Blocks
        ##################################################
        _var_sample_rate_sizer = wx.BoxSizer(wx.VERTICAL)
        self._var_sample_rate_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_var_sample_rate_sizer,
        	value=self.var_sample_rate,
        	callback=self.set_var_sample_rate,
        	label='var_sample_rate',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._var_sample_rate_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_var_sample_rate_sizer,
        	value=self.var_sample_rate,
        	callback=self.set_var_sample_rate,
        	minimum=1000000,
        	maximum=20000000,
        	num_steps=40,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_var_sample_rate_sizer)
        self._var_reverse_fft_size_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.var_reverse_fft_size,
        	callback=self.set_var_reverse_fft_size,
        	label='var_reverse_fft_size',
        	converter=forms.int_converter(),
        )
        self.Add(self._var_reverse_fft_size_text_box)
        self._var_freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.var_freq,
        	callback=self.set_var_freq,
        	label='var_freq',
        	converter=forms.float_converter(),
        )
        self.Add(self._var_freq_text_box)
        self._var_fft_size_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.var_fft_size,
        	callback=self.set_var_fft_size,
        	label='var_fft_size',
        	converter=forms.int_converter(),
        )
        self.Add(self._var_fft_size_text_box)
        self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_RIGHT)
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Before filter")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "After filter")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Post-FM")
        self.Add(self.notebook_0)
        self.wxgui_waterfallsink2_1_0_0 = waterfallsink2.waterfall_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	dynamic_range=100,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=var_sample_rate*var_reverse_fft_size/var_fft_size,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="From auto-tune",
        )
        self.Add(self.wxgui_waterfallsink2_1_0_0.win)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.notebook_0.GetPage(0).GetWin(),
        	baseband_freq=var_freq,
        	dynamic_range=100,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=var_sample_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        	win=window.hanning,
        )
        self.notebook_0.GetPage(0).GridAdd(self.wxgui_waterfallsink2_0.win, 0, 0, 1, 1)
        self.wxgui_scopesink2_1_0 = scopesink2.scope_sink_f(
        	self.GetWin(),
        	title="After C2M2",
        	sample_rate=var_sample_rate*var_reverse_fft_size/var_fft_size,
        	v_scale=20,
        	v_offset=0,
        	t_scale=1,
        	ac_couple=True,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_NORM,
        	y_axis_label="Amplitude",
        )
        self.Add(self.wxgui_scopesink2_1_0.win)
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "hackrf=0" )
        self.osmosdr_source_0.set_sample_rate(var_sample_rate)
        self.osmosdr_source_0.set_center_freq(var_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(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.fft_vxx_1_0 = fft.fft_vcc(var_reverse_fft_size, False, (), True, 4)
        self.fft_vxx_0 = fft.fft_vcc(var_fft_size, True, (), False, 4)
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(32, True)
        self.blocks_vector_to_stream_1_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, var_reverse_fft_size)
        self.blocks_stream_to_vector_2 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, var_reverse_fft_size)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, var_fft_size)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/home/mike/source/gr-autotune/examples/to-grc.fifo", False)
        self.blocks_file_sink_2 = blocks.file_sink(gr.sizeof_gr_complex*var_fft_size, "/home/mike/source/gr-autotune/examples/from-grc.fifo", True)
        self.blocks_file_sink_2.set_unbuffered(False)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.wxgui_scopesink2_1_0, 0))    
        self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_to_vector_2, 0))    
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))    
        self.connect((self.blocks_stream_to_vector_2, 0), (self.fft_vxx_1_0, 0))    
        self.connect((self.blocks_vector_to_stream_1_0, 0), (self.blocks_complex_to_mag_squared_0, 0))    
        self.connect((self.blocks_vector_to_stream_1_0, 0), (self.wxgui_waterfallsink2_1_0_0, 0))    
        self.connect((self.dc_blocker_xx_0, 0), (self.blocks_stream_to_vector_0, 0))    
        self.connect((self.dc_blocker_xx_0, 0), (self.wxgui_waterfallsink2_0, 0))    
        self.connect((self.fft_vxx_0, 0), (self.blocks_file_sink_2, 0))    
        self.connect((self.fft_vxx_1_0, 0), (self.blocks_vector_to_stream_1_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.dc_blocker_xx_0, 0))    
    def __init__(self, ampl=0.7, args='', arq_timeout=.1*0 + 0.04, dest_addr=-1, iface='tun0', max_arq_attempts=5 * 2, mtu=128, ogradio_addr=0, ogrx_freq=915e6, ogtx_freq=915e6, port="12345", rate=1e6, rx_antenna="TX/RX", rx_gain=65-20, rx_lo_offset=0, samps_per_sym=4, tx_gain=45, tx_lo_offset=0):
        grc_wxgui.top_block_gui.__init__(self, title="Broadcastwithfreqandmac")

        self._lock = threading.RLock()

        ##################################################
        # Parameters
        ##################################################
        self.ampl = ampl
        self.args = args
        self.arq_timeout = arq_timeout
        self.dest_addr = dest_addr
        self.iface = iface
        self.max_arq_attempts = max_arq_attempts
        self.mtu = mtu
        self.ogradio_addr = ogradio_addr
        self.ogrx_freq = ogrx_freq
        self.ogtx_freq = ogtx_freq
        self.port = port
        self.rate = rate
        self.rx_antenna = rx_antenna
        self.rx_gain = rx_gain
        self.rx_lo_offset = rx_lo_offset
        self.samps_per_sym = samps_per_sym
        self.tx_gain = tx_gain
        self.tx_lo_offset = tx_lo_offset

        ##################################################
        # Variables
        ##################################################
        self.user_tx_gain = user_tx_gain = tx_gain
        self.user_rx_gain = user_rx_gain = rx_gain
        self.tx_freq = tx_freq = 915e6
        self.samp_rate = samp_rate = rate
        self.rx_freq = rx_freq = 915e6
        self.radio_addr = radio_addr = 84

        ##################################################
        # Blocks
        ##################################################
        _user_tx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._user_tx_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_user_tx_gain_sizer,
        	value=self.user_tx_gain,
        	callback=self.set_user_tx_gain,
        	label="TX Gain",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._user_tx_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_user_tx_gain_sizer,
        	value=self.user_tx_gain,
        	callback=self.set_user_tx_gain,
        	minimum=0,
        	maximum=90,
        	num_steps=90,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_user_tx_gain_sizer)
        _user_rx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._user_rx_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_user_rx_gain_sizer,
        	value=self.user_rx_gain,
        	callback=self.set_user_rx_gain,
        	label="RX Gain",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._user_rx_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_user_rx_gain_sizer,
        	value=self.user_rx_gain,
        	callback=self.set_user_rx_gain,
        	minimum=0,
        	maximum=90,
        	num_steps=90,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_user_rx_gain_sizer)
        self._tx_freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.tx_freq,
        	callback=self.set_tx_freq,
        	label='tx_freq',
        	converter=forms.float_converter(),
        )
        self.Add(self._tx_freq_text_box)
        self._rx_freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.rx_freq,
        	callback=self.set_rx_freq,
        	label='rx_freq',
        	converter=forms.float_converter(),
        )
        self.Add(self._rx_freq_text_box)
        self._radio_addr_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.radio_addr,
        	callback=self.set_radio_addr,
        	label="Local address",
        	converter=forms.int_converter(),
        )
        self.Add(self._radio_addr_text_box)
        self.mac_802_3_tracker = mac.tracker_802_3(verbose=False)
        self.wxgui_scopesink2_0_0 = scopesink2.scope_sink_c(
        	self.GetWin(),
        	title="RX",
        	sample_rate=samp_rate,
        	v_scale=0.02,
        	v_offset=0,
        	t_scale=0.0001,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=2,
        	trig_mode=wxgui.TRIG_MODE_NORM,
        	y_axis_label="Counts",
        )
        self.GridAdd(self.wxgui_scopesink2_0_0.win, 0, 0, 1, 1)
        self.simple_mac_1 = mac.simple_mac(
        radio_addr,
        arq_timeout,
        max_arq_attempts,
        2.0,
        False,
        0.05,
        node_expiry_delay=10.0,
        expire_on_arq_failure=False,
        only_send_if_alive=False,
        prepend_dummy=False,
        )
        self.mac_virtual_channel_encoder_0_0 = mac.virtual_channel_encoder(-1, True,mtu=mtu,
        chan_id=1,
        prepend_dummy=False,
        chan_tracker=self.mac_802_3_tracker,
        )
        self.mac_virtual_channel_encoder_0 = mac.virtual_channel_encoder(-1, True,mtu=mtu,
        chan_id=0,
        prepend_dummy=False,
        )
        self.mac_virtual_channel_decoder_0 = mac.virtual_channel_decoder(3, [0, 1])
        self.gmsk_radio_0 = gmsk_radio(
            access_code_threshold=0 + 12 + 4*0,
            samps_per_sym=samps_per_sym,
            tx_lo_offset=tx_lo_offset,
            rx_lo_offset=rx_lo_offset,
            ampl=ampl,
            rx_gain=user_rx_gain,
            rx_freq=rx_freq,
            rx_ant=rx_antenna,
            tx_freq=tx_freq,
            tx_gain=user_tx_gain,
            args=args,
            rate=samp_rate,
        )
        self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu(iface, mtu*0 + 1514, False)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", "", port, mtu, False)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1, ))
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(10000, 1./10000, 40000/4)
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("T"), 1)
        self.blocks_message_debug_0_0_1 = blocks.message_debug()
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.simple_mac_1, 'ctrl_in'))    
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.mac_virtual_channel_encoder_0, 'in'))    
        self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'), (self.mac_virtual_channel_encoder_0_0, 'in'))    
        self.msg_connect((self.gmsk_radio_0, 'msg_out'), (self.simple_mac_1, 'from_radio'))    
        self.msg_connect((self.mac_virtual_channel_decoder_0, 'out2'), (self.blocks_message_debug_0_0_1, 'print'))    
        self.msg_connect((self.mac_virtual_channel_decoder_0, 'out0'), (self.blocks_socket_pdu_0, 'pdus'))    
        self.msg_connect((self.mac_virtual_channel_decoder_0, 'out1'), (self.blocks_tuntap_pdu_0, 'pdus'))    
        self.msg_connect((self.mac_virtual_channel_decoder_0, 'out1'), (self.mac_802_3_tracker, 'in'))    
        self.msg_connect((self.mac_virtual_channel_encoder_0, 'out'), (self.simple_mac_1, 'from_app_arq'))    
        self.msg_connect((self.mac_virtual_channel_encoder_0_0, 'out'), (self.simple_mac_1, 'from_app_arq'))    
        self.msg_connect((self.simple_mac_1, 'to_radio'), (self.gmsk_radio_0, 'msg_in'))    
        self.msg_connect((self.simple_mac_1, 'to_app'), (self.mac_virtual_channel_decoder_0, 'in'))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_float_to_complex_0, 0))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_moving_average_xx_0, 0))    
        self.connect((self.blocks_float_to_complex_0, 0), (self.wxgui_scopesink2_0_0, 1))    
        self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_complex_0, 1))    
        self.connect((self.gmsk_radio_0, 0), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self.gmsk_radio_0, 0), (self.wxgui_scopesink2_0_0, 0))    
Example #26
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Audio Fmcw 2")
        _icon_path = "C:\Program Files\GNURadio-3.7\share\icons\hicolor\scalable/apps\gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 48e3
        self.mul_constant = mul_constant = 50
        self.f = f = 50
        self.delay_ms = delay_ms = 350

        ##################################################
        # Blocks
        ##################################################
        self._mul_constant_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.mul_constant,
        	callback=self.set_mul_constant,
        	label='mul_constant',
        	converter=forms.float_converter(),
        )
        self.Add(self._mul_constant_text_box)
        self._f_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.f,
        	callback=self.set_f,
        	label='f',
        	converter=forms.float_converter(),
        )
        self.Add(self._f_text_box)
        _delay_ms_sizer = wx.BoxSizer(wx.VERTICAL)
        self._delay_ms_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_delay_ms_sizer,
        	value=self.delay_ms,
        	callback=self.set_delay_ms,
        	label='delay_ms',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._delay_ms_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_delay_ms_sizer,
        	value=self.delay_ms,
        	callback=self.set_delay_ms,
        	minimum=0,
        	maximum=1000,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_delay_ms_sizer)
        self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_f(
        	self.GetWin(),
        	baseband_freq=0,
        	dynamic_range=21,
        	ref_level=10,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=2014,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title='Waterfall Plot',
        )
        self.Add(self.wxgui_waterfallsink2_1.win)
        self.hilbert_fc_0 = filter.hilbert_fc(65, firdes.WIN_HAMMING, 6.76)
        self.fft_vxx_0 = fft.fft_vcc(1024, True, (window.blackmanharris(1024)), True, 2)
        self.chirp_gen_0 = chirp_gen(
            bf_hz=0,
            chirp_rate_hz=f,
            chirp_width_hz=48e3,
            samp_rate=48e3,
        )
        self.blocks_vector_to_stream_2 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 1024)
        self.blocks_vector_to_stream_1 = blocks.vector_to_stream(gr.sizeof_float*1, 512)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_float*1, 512)
        self.blocks_vector_source_x_1 = blocks.vector_source_c((0, 0, 0), True, 1, [])
        self.blocks_stream_to_vector_1 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 512)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 1024)
        self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_gr_complex*1, (1024, 1))
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(1, 512, 0)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_xx_0 = blocks.multiply_const_ff(mul_constant)
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_float*512, 1)
        self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(gr.sizeof_gr_complex, 512, 1024, 512)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, delay_ms)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(512)
        self.audio_source_0 = audio.source(48000, '', True)
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_const_source_x_1 = analog.sig_source_c(0, analog.GR_CONST_WAVE, 0, 0, 0)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_1, 0), (self.blocks_stream_mux_0, 1))
        self.connect((self.audio_source_0, 0), (self.hilbert_fc_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 1))
        self.connect((self.blocks_keep_m_in_n_0, 0), (self.blocks_stream_to_vector_1, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_vector_to_stream_1, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_multiply_const_xx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_stream_mux_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.blocks_stream_mux_0, 0), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_stream_to_vector_1, 0), (self.blocks_complex_to_mag_0, 0))
        self.connect((self.blocks_vector_source_x_1, 0), (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_multiply_const_xx_0, 0))
        self.connect((self.blocks_vector_to_stream_1, 0), (self.wxgui_waterfallsink2_1, 0))
        self.connect((self.blocks_vector_to_stream_2, 0), (self.blocks_keep_m_in_n_0, 0))
        self.connect((self.chirp_gen_0, 1), (self.blocks_delay_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_2, 0))
        self.connect((self.hilbert_fc_0, 0), (self.blocks_multiply_conjugate_cc_0, 0))
Example #27
0
    def __init__(self,
                 side="A",
                 gain=35,
                 decim=32,
                 sync_check=False,
                 satellite='METEOR-M-1',
                 frames_file=os.environ['HOME'] + '/METEOR-M-1.hrpt',
                 freq=1700e6):
        grc_wxgui.top_block_gui.__init__(self, title="USRP NOAA HRPT Receiver")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Parameters
        ##################################################
        self.side = side
        self.gain = gain
        self.decim = decim
        self.sync_check = sync_check
        self.satellite = satellite
        self.frames_file = frames_file
        self.freq = freq

        ##################################################
        # Variables
        ##################################################
        self.sym_rate = sym_rate = 600 * 1109
        self.samp_rate = samp_rate = 64e6 / decim
        self.config_filename = config_filename = os.environ[
            'HOME'] + '/.gnuradio/mn1_hrpt.conf'
        self.sps = sps = samp_rate / sym_rate
        self._saved_pll_alpha_config = ConfigParser.ConfigParser()
        self._saved_pll_alpha_config.read(config_filename)
        try:
            saved_pll_alpha = self._saved_pll_alpha_config.getfloat(
                "satname", 'pll_alpha')
        except:
            saved_pll_alpha = 0.005
        self.saved_pll_alpha = saved_pll_alpha
        self._saved_clock_alpha_config = ConfigParser.ConfigParser()
        self._saved_clock_alpha_config.read(config_filename)
        try:
            saved_clock_alpha = self._saved_clock_alpha_config.getfloat(
                "satname", 'clock_alpha')
        except:
            saved_clock_alpha = 0.001
        self.saved_clock_alpha = saved_clock_alpha
        self.sync_check_txt = sync_check_txt = sync_check
        self.side_text = side_text = side
        self._saved_gain_config = ConfigParser.ConfigParser()
        self._saved_gain_config.read(config_filename)
        try:
            saved_gain = self._saved_gain_config.getfloat("satname", 'gain')
        except:
            saved_gain = gain
        self.saved_gain = saved_gain
        self.satellite_text = satellite_text = satellite
        self.sample_rate_text = sample_rate_text = samp_rate
        self.pll_alpha = pll_alpha = saved_pll_alpha
        self.max_clock_offset = max_clock_offset = 0.1
        self.max_carrier_offset = max_carrier_offset = 2 * math.pi * 100e3 / samp_rate
        self.hs = hs = int(sps / 2.0)
        self.gain_slider = gain_slider = gain
        self.freq_tb = freq_tb = freq
        self.frames_outfile_text = frames_outfile_text = frames_file
        self.decim_tb = decim_tb = decim
        self.datetime_text = datetime_text = strftime("%A, %B %d %Y %H:%M:%S",
                                                      localtime())
        self.clock_alpha = clock_alpha = saved_clock_alpha

        ##################################################
        # Notebooks
        ##################################################
        self.displays = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.displays.AddPage(grc_wxgui.Panel(self.displays),
                              "RX Meteor M N1 HRPT")
        self.displays.AddPage(grc_wxgui.Panel(self.displays), "Information")
        self.Add(self.displays)

        ##################################################
        # Controls
        ##################################################
        self._sync_check_txt_static_text = forms.static_text(
            parent=self.GetWin(),
            value=self.sync_check_txt,
            callback=self.set_sync_check_txt,
            label="Sync check",
            converter=forms.float_converter(),
        )
        self.GridAdd(self._sync_check_txt_static_text, 0, 2, 1, 1)
        self._side_text_static_text = forms.static_text(
            parent=self.GetWin(),
            value=self.side_text,
            callback=self.set_side_text,
            label="USRP Side",
            converter=forms.str_converter(),
        )
        self.GridAdd(self._side_text_static_text, 0, 0, 1, 1)
        self._satellite_text_static_text = forms.static_text(
            parent=self.GetWin(),
            value=self.satellite_text,
            callback=self.set_satellite_text,
            label="Satellite",
            converter=forms.str_converter(),
        )
        self.GridAdd(self._satellite_text_static_text, 0, 1, 1, 1)
        self._sample_rate_text_static_text = forms.static_text(
            parent=self.displays.GetPage(1).GetWin(),
            value=self.sample_rate_text,
            callback=self.set_sample_rate_text,
            label="Sample rate",
            converter=forms.float_converter(),
        )
        self.displays.GetPage(1).GridAdd(self._sample_rate_text_static_text, 3,
                                         0, 1, 1)
        _pll_alpha_sizer = wx.BoxSizer(wx.VERTICAL)
        self._pll_alpha_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_pll_alpha_sizer,
            value=self.pll_alpha,
            callback=self.set_pll_alpha,
            label="PLL Alpha",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._pll_alpha_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_pll_alpha_sizer,
            value=self.pll_alpha,
            callback=self.set_pll_alpha,
            minimum=0.005,
            maximum=0.5,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_pll_alpha_sizer, 2, 1, 1, 1)
        _gain_slider_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_slider_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_gain_slider_sizer,
            value=self.gain_slider,
            callback=self.set_gain_slider,
            label="Gain",
            converter=forms.int_converter(),
            proportion=0,
        )
        self._gain_slider_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_gain_slider_sizer,
            value=self.gain_slider,
            callback=self.set_gain_slider,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.GridAdd(_gain_slider_sizer, 2, 0, 1, 1)
        self._freq_tb_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.freq_tb,
            callback=self.set_freq_tb,
            label="Frequency",
            converter=forms.float_converter(),
        )
        self.GridAdd(self._freq_tb_text_box, 1, 1, 1, 1)
        self._frames_outfile_text_static_text = forms.static_text(
            parent=self.displays.GetPage(1).GetWin(),
            value=self.frames_outfile_text,
            callback=self.set_frames_outfile_text,
            label="Frames filename",
            converter=forms.str_converter(),
        )
        self.displays.GetPage(1).GridAdd(self._frames_outfile_text_static_text,
                                         4, 0, 1, 1)
        self._decim_tb_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.decim_tb,
            callback=self.set_decim_tb,
            label="Decimation",
            converter=forms.int_converter(),
        )
        self.GridAdd(self._decim_tb_text_box, 1, 0, 1, 1)
        self._datetime_text_static_text = forms.static_text(
            parent=self.displays.GetPage(1).GetWin(),
            value=self.datetime_text,
            callback=self.set_datetime_text,
            label="Acquisition start",
            converter=forms.str_converter(),
        )
        self.displays.GetPage(1).GridAdd(self._datetime_text_static_text, 2, 0,
                                         1, 1)
        _clock_alpha_sizer = wx.BoxSizer(wx.VERTICAL)
        self._clock_alpha_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_clock_alpha_sizer,
            value=self.clock_alpha,
            callback=self.set_clock_alpha,
            label="Clock alpha",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._clock_alpha_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_clock_alpha_sizer,
            value=self.clock_alpha,
            callback=self.set_clock_alpha,
            minimum=0.001,
            maximum=0.1,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_clock_alpha_sizer, 2, 2, 1, 1)

        ##################################################
        # Blocks
        ##################################################
        self.agc = gr.agc_cc(1e-5, 1.0, 1.0 / 32768.0, 1.0)
        self.gr_binary_slicer_fb_0 = gr.binary_slicer_fb()
        self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_ff(
            sps / 2.0, clock_alpha**2 / 4.0, 0.5, clock_alpha,
            max_clock_offset)
        self.gr_file_sink_0_0 = gr.file_sink(gr.sizeof_short * 1, frames_file)
        self.gr_file_sink_0_0.set_unbuffered(False)
        self.gr_interleaved_short_to_complex_0 = gr.interleaved_short_to_complex(
        )
        self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0 / hs, 4000)
        self.gr_rms_xx_0 = gr.rms_cf(0.2)
        self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2 / 4.0,
                                    max_carrier_offset)
        self.poesweather_mn1_hrpt_deframer_0 = poesweather.mn1_hrpt_deframer(
            sync_check)
        self.usrp_simple_source_x_0 = grc_usrp.simple_source_s(which=0,
                                                               side=side,
                                                               rx_ant="RXA")
        self.usrp_simple_source_x_0.set_decim_rate(decim)
        self.usrp_simple_source_x_0.set_frequency(freq, verbose=True)
        self.usrp_simple_source_x_0.set_gain(gain)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.displays.GetPage(0).GetWin(),
            baseband_freq=0,
            y_per_div=5,
            y_divs=10,
            ref_level=45,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=30,
            average=True,
            avg_alpha=0.1,
            title="Meteor M N1 HRPT FFT Spectrum",
            peak_hold=False,
        )
        self.displays.GetPage(0).Add(self.wxgui_fftsink2_0.win)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
            self.GetWin(),
            unit="Units",
            minval=0,
            maxval=5000,
            factor=1.0,
            decimal_places=4,
            ref_level=0,
            sample_rate=samp_rate,
            number_rate=15,
            average=True,
            avg_alpha=0.07,
            label="S-Meter",
            peak_hold=False,
            show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_0.win)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.gr_binary_slicer_fb_0, 0),
                     (self.poesweather_mn1_hrpt_deframer_0, 0))
        self.connect((self.usrp_simple_source_x_0, 0),
                     (self.gr_interleaved_short_to_complex_0, 0))
        self.connect((self.gr_interleaved_short_to_complex_0, 0),
                     (self.agc, 0))
        self.connect((self.gr_clock_recovery_mm_xx_0, 0),
                     (self.gr_binary_slicer_fb_0, 0))
        self.connect((self.agc, 0), (self.pll, 0))
        self.connect((self.pll, 0), (self.gr_moving_average_xx_0, 0))
        self.connect((self.gr_moving_average_xx_0, 0),
                     (self.gr_clock_recovery_mm_xx_0, 0))
        self.connect((self.gr_interleaved_short_to_complex_0, 0),
                     (self.wxgui_fftsink2_0, 0))
        self.connect((self.gr_interleaved_short_to_complex_0, 0),
                     (self.gr_rms_xx_0, 0))
        self.connect((self.gr_rms_xx_0, 0), (self.wxgui_numbersink2_0, 0))
        self.connect((self.poesweather_mn1_hrpt_deframer_0, 0),
                     (self.gr_file_sink_0_0, 0))
Example #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.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))
Example #29
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))
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="NDR304 Example")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.wbddc1_tuner_freq_mhz = wbddc1_tuner_freq_mhz = 900
        self.wbddc1_nominal_sample_rate = wbddc1_nominal_sample_rate = 32000
        self.wbddc1_ddc_offset = wbddc1_ddc_offset = 0

        ##################################################
        # Blocks
        ##################################################
        self._wbddc1_tuner_freq_mhz_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.wbddc1_tuner_freq_mhz,
        	callback=self.set_wbddc1_tuner_freq_mhz,
        	label="WBDDC 1 Tuner Frequency (MHz)",
        	converter=forms.int_converter(),
        )
        self.Add(self._wbddc1_tuner_freq_mhz_text_box)
        self._wbddc1_ddc_offset_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.wbddc1_ddc_offset,
        	callback=self.set_wbddc1_ddc_offset,
        	label="WBDDC 1 Frequency Offset (Hz)",
        	converter=forms.float_converter(),
        )
        self.Add(self._wbddc1_ddc_offset_text_box)
        self.CyberRadio_NDR304_source_0 = CyberRadio.NDR304_source(
            verbose_mode=True,
            radio_device_name="/dev/ndr47x",
            radio_baud_rate=921600,
            gig_iface_to_use="eth0",
            num_tuners=1,
            tuner1_param_list=[True, wbddc1_tuner_freq_mhz * 1e6, 0],
            num_wbddcs=1,
            wbddc1_param_list=[40001, 0, 0, True, wbddc1_ddc_offset],
            tagged=True,
        )
        def _wbddc1_nominal_sample_rate_probe():
        	while True:
        		val = self.CyberRadio_NDR304_source_0.get_wbddc_nominal_sample_rate(1)
        		try: self.set_wbddc1_nominal_sample_rate(val)
        		except AttributeError, e: pass
        		time.sleep(1.0/(10))
        _wbddc1_nominal_sample_rate_thread = threading.Thread(target=_wbddc1_nominal_sample_rate_probe)
        _wbddc1_nominal_sample_rate_thread.daemon = True
        _wbddc1_nominal_sample_rate_thread.start()
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=wbddc1_tuner_freq_mhz * 1e6 + wbddc1_ddc_offset,
        	y_per_div=10,
        	y_divs=12,
        	ref_level=0,
        	ref_scale=2,
        	sample_rate=wbddc1_nominal_sample_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.blocks_file_descriptor_sink_0 = blocks.file_descriptor_sink(gr.sizeof_char*1, 2)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.CyberRadio_NDR304_source_0, 0), (self.blocks_file_descriptor_sink_0, 0))    
        self.connect((self.CyberRadio_NDR304_source_0, 1), (self.wxgui_fftsink2_0, 0))    
Example #31
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="AM Radio")

        ##################################################
        # Variables
        ##################################################
        self.am_center_freq = am_center_freq = 1536e3
        self.samp_rate = samp_rate = 20e6
        self.audio_gain = audio_gain = 3
        self.am_min_freq = am_min_freq = 540e3
        self.am_max_freq = am_max_freq = 1600e3
        self.am_channel_width = am_channel_width = 10e3
        self.am_channel_freq = am_channel_freq = am_center_freq

        ##################################################
        # Blocks
        ##################################################
        self.notebook_main = self.notebook_main = wx.Notebook(self.GetWin(),
                                                              style=wx.NB_TOP)
        self.notebook_main.AddPage(grc_wxgui.Panel(self.notebook_main),
                                   "Controls")
        self.Add(self.notebook_main)
        self.notebook_radio = self.notebook_radio = wx.Notebook(
            self.notebook_main.GetPage(0).GetWin(), style=wx.NB_TOP)
        self.notebook_radio.AddPage(grc_wxgui.Panel(self.notebook_radio),
                                    "Spectrum Analysis")
        self.notebook_main.GetPage(0).Add(self.notebook_radio)
        _audio_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._audio_gain_text_box = forms.text_box(
            parent=self.notebook_main.GetPage(0).GetWin(),
            sizer=_audio_gain_sizer,
            value=self.audio_gain,
            callback=self.set_audio_gain,
            label='Volume',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._audio_gain_slider = forms.slider(
            parent=self.notebook_main.GetPage(0).GetWin(),
            sizer=_audio_gain_sizer,
            value=self.audio_gain,
            callback=self.set_audio_gain,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.notebook_main.GetPage(0).GridAdd(_audio_gain_sizer, 0, 2, 1, 13)
        _am_channel_freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._am_channel_freq_text_box = forms.text_box(
            parent=self.notebook_radio.GetPage(0).GetWin(),
            sizer=_am_channel_freq_sizer,
            value=self.am_channel_freq,
            callback=self.set_am_channel_freq,
            label='Station',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._am_channel_freq_slider = forms.slider(
            parent=self.notebook_radio.GetPage(0).GetWin(),
            sizer=_am_channel_freq_sizer,
            value=self.am_channel_freq,
            callback=self.set_am_channel_freq,
            minimum=am_min_freq,
            maximum=am_max_freq,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.notebook_radio.GetPage(0).GridAdd(_am_channel_freq_sizer, 0, 1, 1,
                                               39)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.notebook_radio.GetPage(0).GetWin(),
            baseband_freq=am_channel_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=None,
            title='FFT Plot',
            peak_hold=False,
        )
        self.notebook_radio.GetPage(0).Add(self.wxgui_fftsink2_0.win)
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
            interpolation=12,
            decimation=16,
            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(am_channel_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.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (10, ), am_center_freq, samp_rate)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff(
            (audio_gain, ))
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_am_demod_cf_0 = analog.am_demod_cf(
            channel_rate=48e3,
            audio_decim=10,
            audio_pass=5000,
            audio_stop=5500,
        )
        self.analog_agc3_xx_0 = analog.agc3_cc(1e-1, 1e-2, .7, 1.0, 1)
        self.analog_agc3_xx_0.set_max_gain(65536)
        self.am_low_pass_filter = filter.fir_filter_ccf(
            int(samp_rate / am_channel_width),
            firdes.low_pass(1, samp_rate, 10e3, 1e3, firdes.WIN_HAMMING, 6.76))
        self.am_fosphor_wx_sink_c = fosphor.wx_sink_c(
            self.notebook_main.GetPage(0).GetWin())
        self.am_fosphor_wx_sink_c.set_fft_window(window.WIN_BLACKMAN_hARRIS)
        self.am_fosphor_wx_sink_c.set_frequency_range(am_channel_freq,
                                                      samp_rate)
        self.notebook_main.GetPage(0).Add(self.am_fosphor_wx_sink_c.win)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.am_low_pass_filter, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.analog_agc3_xx_0, 0),
                     (self.analog_am_demod_cf_0, 0))
        self.connect((self.analog_am_demod_cf_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.am_low_pass_filter, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.am_fosphor_wx_sink_c, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.analog_agc3_xx_0, 0))
Example #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.samp_rate = samp_rate = 8000
        self.mult_const = mult_const = 1
        self.delay = delay = 1

        ##################################################
        # Blocks
        ##################################################
        _delay_sizer = wx.BoxSizer(wx.VERTICAL)
        self._delay_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_delay_sizer,
        	value=self.delay,
        	callback=self.set_delay,
        	label="delay",
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._delay_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_delay_sizer,
        	value=self.delay,
        	callback=self.set_delay,
        	minimum=0,
        	maximum=100,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_delay_sizer)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=samp_rate*4,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=3,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        _mult_const_sizer = wx.BoxSizer(wx.VERTICAL)
        self._mult_const_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_mult_const_sizer,
        	value=self.mult_const,
        	callback=self.set_mult_const,
        	label="mult_const",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._mult_const_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_mult_const_sizer,
        	value=self.mult_const,
        	callback=self.set_mult_const,
        	minimum=0,
        	maximum=100,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_mult_const_sizer)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate*4,True)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1.2, ))
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, delay)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1000, 0.2, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.blocks_add_xx_0, 0), (self.wxgui_scopesink2_0, 2))    
        self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 1))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_scopesink2_0, 1))    
        self.connect((self.blocks_throttle_0, 0), (self.blocks_add_xx_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.blocks_delay_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_scopesink2_0, 0))    
    def __init__(self, RF=2.49e9, lowpass_cutoff_freq=1700, speed_samp_rate=1, fft_len=pow(2,20), angle=0, DC_filter_num_elements=4, samp_rate_sink=8000, samp_rate=1e6, max_num_of_targets=10, lo_offset_freq=1e6, highpass_cutoff_freq=0, doppler_signal_bw=20, threshold_dB=-70, rx_gain=30.5, tx_amp=0):
        grc_wxgui.top_block_gui.__init__(self, title="CW Radar Multiple Targets Receiver")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Parameters
        ##################################################
        self.RF = RF
        self.lowpass_cutoff_freq = lowpass_cutoff_freq
        self.speed_samp_rate = speed_samp_rate
        self.fft_len = fft_len
        self.angle = angle
        self.DC_filter_num_elements = DC_filter_num_elements
        self.samp_rate_sink = samp_rate_sink
        self.samp_rate = samp_rate
        self.max_num_of_targets = max_num_of_targets
        self.lo_offset_freq = lo_offset_freq
        self.highpass_cutoff_freq = highpass_cutoff_freq
        self.doppler_signal_bw = doppler_signal_bw
        self.threshold_dB = threshold_dB
        self.rx_gain = rx_gain
        self.tx_amp = tx_amp

        ##################################################
        # Variables
        ##################################################
        self.target_speed_vector = target_speed_vector = 0
        self.target_direction_vector = target_direction_vector = 0
        self.num_targets = num_targets = 0
        self.tx_amp_tuner = tx_amp_tuner = tx_amp
        self.threshold_dB_tuner = threshold_dB_tuner = threshold_dB
        self.speed_textbox = speed_textbox = target_speed_vector
        self.rx_gain_tuner = rx_gain_tuner = rx_gain
        self.num_targets_textbox = num_targets_textbox = num_targets
        self.max_num_of_targets_tuner = max_num_of_targets_tuner = max_num_of_targets
        self.lowpass_cutoff_freq_tuner = lowpass_cutoff_freq_tuner = lowpass_cutoff_freq
        self.highpass_cutoff_freq_tuner = highpass_cutoff_freq_tuner = highpass_cutoff_freq
        self.doppler_signal_bw_tuner = doppler_signal_bw_tuner = doppler_signal_bw
        self.direction_textbox = direction_textbox = target_direction_vector
        self.angle_tuner = angle_tuner = angle
        self.RF_tuner = RF_tuner = RF

        ##################################################
        # Blocks
        ##################################################
        _threshold_dB_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._threshold_dB_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_threshold_dB_tuner_sizer,
        	value=self.threshold_dB_tuner,
        	callback=self.set_threshold_dB_tuner,
        	label="Detected Target Threshold (dB)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._threshold_dB_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_threshold_dB_tuner_sizer,
        	value=self.threshold_dB_tuner,
        	callback=self.set_threshold_dB_tuner,
        	minimum=-90,
        	maximum=-30,
        	num_steps=60,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_threshold_dB_tuner_sizer, 2, 0, 1, 8)
        self.speed_vector_probe = blocks.probe_signal_vf(max_num_of_targets)
        _rx_gain_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_gain_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_rx_gain_tuner_sizer,
        	value=self.rx_gain_tuner,
        	callback=self.set_rx_gain_tuner,
        	label="USRP RX Gain (dB)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._rx_gain_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_rx_gain_tuner_sizer,
        	value=self.rx_gain_tuner,
        	callback=self.set_rx_gain_tuner,
        	minimum=0,
        	maximum=30.5 + 62,
        	num_steps=185,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_rx_gain_tuner_sizer, 0, 0, 1, 8)
        self.notebook = self.notebook = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "FFT CW Doppler Radar Receiver")
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "Frequency/Time CW Doppler Radar Receiver")
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "FFT CW Doppler Radar Receiver Full Spectrum")
        self.GridAdd(self.notebook, 6, 0, 13, 53)
        _max_num_of_targets_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._max_num_of_targets_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_max_num_of_targets_tuner_sizer,
        	value=self.max_num_of_targets_tuner,
        	callback=self.set_max_num_of_targets_tuner,
        	label="Maximum Number of Targets",
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._max_num_of_targets_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_max_num_of_targets_tuner_sizer,
        	value=self.max_num_of_targets_tuner,
        	callback=self.set_max_num_of_targets_tuner,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.GridAdd(_max_num_of_targets_tuner_sizer, 2, 8, 1, 21)
        _lowpass_cutoff_freq_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._lowpass_cutoff_freq_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_lowpass_cutoff_freq_tuner_sizer,
        	value=self.lowpass_cutoff_freq_tuner,
        	callback=self.set_lowpass_cutoff_freq_tuner,
        	label="Low-Pass Cutoff Frequency (Hz)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._lowpass_cutoff_freq_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_lowpass_cutoff_freq_tuner_sizer,
        	value=self.lowpass_cutoff_freq_tuner,
        	callback=self.set_lowpass_cutoff_freq_tuner,
        	minimum=0,
        	maximum=3000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_lowpass_cutoff_freq_tuner_sizer, 1, 29, 1, 24)
        _highpass_cutoff_freq_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._highpass_cutoff_freq_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_highpass_cutoff_freq_tuner_sizer,
        	value=self.highpass_cutoff_freq_tuner,
        	callback=self.set_highpass_cutoff_freq_tuner,
        	label="High-Pass Cutoff Frequency (Hz)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._highpass_cutoff_freq_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_highpass_cutoff_freq_tuner_sizer,
        	value=self.highpass_cutoff_freq_tuner,
        	callback=self.set_highpass_cutoff_freq_tuner,
        	minimum=0,
        	maximum=1600,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_highpass_cutoff_freq_tuner_sizer, 0, 29, 1, 24)
        _doppler_signal_bw_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._doppler_signal_bw_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_doppler_signal_bw_tuner_sizer,
        	value=self.doppler_signal_bw_tuner,
        	callback=self.set_doppler_signal_bw_tuner,
        	label="Doppler Spectrum Bandwidth (Hz)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._doppler_signal_bw_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_doppler_signal_bw_tuner_sizer,
        	value=self.doppler_signal_bw_tuner,
        	callback=self.set_doppler_signal_bw_tuner,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_doppler_signal_bw_tuner_sizer, 2, 29, 1, 24)
        self.direction_vector_probe = blocks.probe_signal_vi(max_num_of_targets)
        _angle_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._angle_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_angle_tuner_sizer,
        	value=self.angle_tuner,
        	callback=self.set_angle_tuner,
        	label="Angle of Approach of the Target (Deg)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._angle_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_angle_tuner_sizer,
        	value=self.angle_tuner,
        	callback=self.set_angle_tuner,
        	minimum=0,
        	maximum=89,
        	num_steps=890,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_angle_tuner_sizer, 1, 8, 1, 21)
        _RF_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._RF_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_RF_tuner_sizer,
        	value=self.RF_tuner,
        	callback=self.set_RF_tuner,
        	label="Radar Frequency (Hz)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._RF_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_RF_tuner_sizer,
        	value=self.RF_tuner,
        	callback=self.set_RF_tuner,
        	minimum=2.4e9,
        	maximum=2.5e9,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_RF_tuner_sizer, 1, 0, 1, 8)
        self.wxgui_waterfallsink = waterfallsink2.waterfall_sink_c(
        	self.notebook.GetPage(1).GetWin(),
        	baseband_freq=0,
        	dynamic_range=100,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate_sink,
        	fft_size=1024,
        	fft_rate=100,
        	average=False,
        	avg_alpha=None,
        	title="Time/Frequency CW Doppler Radar Receiver",
        	win=window.blackmanharris,
        )
        self.notebook.GetPage(1).Add(self.wxgui_waterfallsink.win)
        self.wxgui_fftsink2_full_spectrum = fftsink2.fft_sink_c(
        	self.notebook.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=4096,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="FFT CW Doppler Radar Receiver Full Spectrum",
        	peak_hold=False,
        	win=window.blackmanharris,
        )
        self.notebook.GetPage(2).Add(self.wxgui_fftsink2_full_spectrum.win)
        self.wxgui_fftsink = fftsink2.fft_sink_c(
        	self.notebook.GetPage(0).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate_sink,
        	fft_size=1024,
        	fft_rate=100,
        	average=False,
        	avg_alpha=None,
        	title="FFT CW Doppler Radar Receiver ",
        	peak_hold=False,
        	win=window.blackmanharris,
        )
        self.notebook.GetPage(0).Add(self.wxgui_fftsink.win)
        self.usrp_receiver = uhd.usrp_source(
        	",".join(('addr=192.168.10.3', "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.usrp_receiver.set_clock_source("external", 0)
        self.usrp_receiver.set_samp_rate(samp_rate)
        self.usrp_receiver.set_center_freq(uhd.tune_request(RF_tuner, lo_offset_freq), 0)
        self.usrp_receiver.set_gain(rx_gain_tuner, 0)
        self.usrp_receiver.set_antenna("J1", 0)
        _tx_amp_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tx_amp_tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_tx_amp_tuner_sizer,
        	value=self.tx_amp_tuner,
        	callback=self.set_tx_amp_tuner,
        	label="TX Signal Amp",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._tx_amp_tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_tx_amp_tuner_sizer,
        	value=self.tx_amp_tuner,
        	callback=self.set_tx_amp_tuner,
        	minimum=0,
        	maximum=1,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_tx_amp_tuner_sizer, 0, 8, 1, 21)
        def _target_speed_vector_probe():
            while True:
                val = self.speed_vector_probe.level()
                try:
                    self.set_target_speed_vector(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (speed_samp_rate))
        _target_speed_vector_thread = threading.Thread(target=_target_speed_vector_probe)
        _target_speed_vector_thread.daemon = True
        _target_speed_vector_thread.start()
        def _target_direction_vector_probe():
            while True:
                val = self.direction_vector_probe.level()
                try:
                    self.set_target_direction_vector(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (speed_samp_rate))
        _target_direction_vector_thread = threading.Thread(target=_target_direction_vector_probe)
        _target_direction_vector_thread.daemon = True
        _target_direction_vector_thread.start()
        self._speed_textbox_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.speed_textbox,
        	callback=self.set_speed_textbox,
        	label="Targets Speed (Kph)",
        	converter=forms.str_converter(),
        )
        self.GridAdd(self._speed_textbox_text_box, 4, 0, 1, 53)
        self.rational_resampler = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=int(samp_rate/samp_rate_sink),
                taps=None,
                fractional_bw=None,
        )
        self._num_targets_textbox_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.num_targets_textbox,
        	callback=self.set_num_targets_textbox,
        	label="Number of Targets Detected",
        	converter=forms.int_converter(),
        )
        self.GridAdd(self._num_targets_textbox_text_box, 3, 0, 1, 4)
        self.num_targets_probe = blocks.probe_signal_i()
        def _num_targets_probe():
            while True:
                val = self.num_targets_probe.level()
                try:
                    self.set_num_targets(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (speed_samp_rate))
        _num_targets_thread = threading.Thread(target=_num_targets_probe)
        _num_targets_thread.daemon = True
        _num_targets_thread.start()
        self.fft_vxx_0 = fft.fft_vcc(fft_len, True, (window.blackmanharris(fft_len)), True, 1)
        self._direction_textbox_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.direction_textbox,
        	callback=self.set_direction_textbox,
        	label="Targets Direction",
        	converter=forms.str_converter(),
        )
        self.GridAdd(self._direction_textbox_text_box, 5, 0, 1, 53)
        self.cwradar_vector_flip_ff = cwradar.vector_flip_ff(fft_len/2)
        self.cwradar_doppler_velocity_multiple_targets_ff_0 = cwradar.doppler_velocity_multiple_targets_ff(fft_len/2, samp_rate, RF_tuner, threshold_dB_tuner, angle_tuner, lowpass_cutoff_freq_tuner, highpass_cutoff_freq_tuner, max_num_of_targets_tuner, doppler_signal_bw_tuner)
        self.complex_to_mag = blocks.complex_to_mag(fft_len)
        self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream(gr.sizeof_float*1, fft_len)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_float*1, fft_len)
        self.blocks_stream_to_vector_1_0 = blocks.stream_to_vector(gr.sizeof_float*1, fft_len/2)
        self.blocks_stream_to_vector_1 = blocks.stream_to_vector(gr.sizeof_float*1, fft_len/2)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_len)
        self.blocks_keep_m_in_n_0_0 = blocks.keep_m_in_n(gr.sizeof_float, fft_len/2, fft_len, fft_len/2)
        self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(gr.sizeof_float, fft_len/2, fft_len, 0)
        self.DC_filter_0 = blocks.multiply_const_vff(([0]*DC_filter_num_elements+[1]*((fft_len/2)-DC_filter_num_elements)))
        self.DC_filter = blocks.multiply_const_vff(([0]*DC_filter_num_elements+[1]*((fft_len/2)-DC_filter_num_elements)))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.complex_to_mag, 0), (self.blocks_vector_to_stream_0_0, 0))
        self.connect((self.complex_to_mag, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.usrp_receiver, 0), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.complex_to_mag, 0))
        self.connect((self.rational_resampler, 0), (self.wxgui_fftsink, 0))
        self.connect((self.rational_resampler, 0), (self.wxgui_waterfallsink, 0))
        self.connect((self.usrp_receiver, 0), (self.rational_resampler, 0))
        self.connect((self.usrp_receiver, 0), (self.wxgui_fftsink2_full_spectrum, 0))
        self.connect((self.DC_filter, 0), (self.cwradar_doppler_velocity_multiple_targets_ff_0, 0))
        self.connect((self.DC_filter_0, 0), (self.cwradar_doppler_velocity_multiple_targets_ff_0, 1))
        self.connect((self.cwradar_doppler_velocity_multiple_targets_ff_0, 2), (self.num_targets_probe, 0))
        self.connect((self.cwradar_doppler_velocity_multiple_targets_ff_0, 1), (self.direction_vector_probe, 0))
        self.connect((self.cwradar_doppler_velocity_multiple_targets_ff_0, 0), (self.speed_vector_probe, 0))
        self.connect((self.blocks_vector_to_stream_0_0, 0), (self.blocks_keep_m_in_n_0_0, 0))
        self.connect((self.blocks_keep_m_in_n_0, 0), (self.blocks_stream_to_vector_1, 0))
        self.connect((self.blocks_keep_m_in_n_0_0, 0), (self.blocks_stream_to_vector_1_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_keep_m_in_n_0, 0))
        self.connect((self.blocks_stream_to_vector_1_0, 0), (self.DC_filter_0, 0))
        self.connect((self.blocks_stream_to_vector_1, 0), (self.cwradar_vector_flip_ff, 0))
        self.connect((self.cwradar_vector_flip_ff, 0), (self.DC_filter, 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))    
Example #35
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.samp_rate = samp_rate = 5e6
        self.lo_off = lo_off = 2e6
        self.gain_slider = gain_slider = 15
        self.freq_l1 = freq_l1 = 1.57542e6

        ##################################################
        # Blocks
        ##################################################
        _gain_slider_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_slider_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_gain_slider_sizer,
            value=self.gain_slider,
            callback=self.set_gain_slider,
            label='gain_slider',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._gain_slider_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_gain_slider_sizer,
            value=self.gain_slider,
            callback=self.set_gain_slider,
            minimum=0,
            maximum=50,
            num_steps=50,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_gain_slider_sizer)
        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.uhd_usrp_source_0 = uhd.usrp_source(
            device_addr="",
            stream_args=uhd.stream_args(
                cpu_format="fc32",
                otw_format="sc16",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_clock_source("gpsdo", 0)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(
            uhd.tune_request(freq_l1, lo_off), 0)
        self.uhd_usrp_source_0.set_gain(gain_slider, 0)
        self.uhd_usrp_source_0.set_antenna("RX2", 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0))
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Hand Detection")

        ##################################################
        # Variables
        ##################################################
        self.variable_slider_0 = variable_slider_0 = 0
        self.samp_rate = samp_rate = 8e5
        self.ctr_freq = ctr_freq = 883e6

        ##################################################
        # 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)
        _variable_slider_0_sizer = wx.BoxSizer(wx.VERTICAL)
        self._variable_slider_0_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_variable_slider_0_sizer,
        	value=self.variable_slider_0,
        	callback=self.set_variable_slider_0,
        	label='variable_slider_0',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._variable_slider_0_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_variable_slider_0_sizer,
        	value=self.variable_slider_0,
        	callback=self.set_variable_slider_0,
        	minimum=0,
        	maximum=360,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_variable_slider_0_sizer)
        self.uhd_usrp_source_1 = uhd.usrp_source(
        	",".join(("serial=30D6B32", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_1.set_samp_rate(samp_rate)
        self.uhd_usrp_source_1.set_center_freq(ctr_freq, 0)
        self.uhd_usrp_source_1.set_gain(10, 0)
        self.uhd_usrp_source_1.set_antenna('RX2', 0)
        self.uhd_usrp_source_1.set_auto_dc_offset("", 0)
        self.uhd_usrp_source_1.set_auto_iq_balance("", 0)
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=1,
                decimation=22,
                taps=None,
                fractional_bw=None,
        )
        self.blocks_threshold_ff_0 = blocks.threshold_ff(-0.040, 0.040, 0)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.audio_sink_0 = audio.sink(44100, '', True)
        self.analog_sig_source_x_2 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 10000, 1, 0)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_2, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.uhd_usrp_source_1, 0), (self.blocks_complex_to_mag_0, 0))
Example #37
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.samp_rate = samp_rate = 1920000
        self.freq = freq = 50e6
        self.audio_gain = audio_gain = 0.05

        ##################################################
        # Blocks
        ##################################################
        self._freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.freq,
        	callback=self.set_freq,
        	label="Frequency (Hz)",
        	converter=forms.int_converter(),
        )
        self.Add(self._freq_text_box)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=12,
        	ref_level=30,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=2048,
        	fft_rate=2,
        	average=True,
        	avg_alpha=1,
        	title="FFT Plot",
        	peak_hold=False,
        	win=window.blackmanharris,
        	size=(1200,400),
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.low_pass_filter_0 = filter.fir_filter_ccf(samp_rate/48000, firdes.low_pass(
        	1, samp_rate, 5000, 3000, firdes.WIN_BLACKMAN, 6.76))
        self.fcd_source_c_0 = fcd.source_c("hw:1")
        self.fcd_source_c_0.set_freq(freq)
            
        _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=1,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_audio_gain_sizer)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.fcd_source_c_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.wxgui_fftsink2_0, 0))
Example #38
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.samp_rate = samp_rate = 32000
        self.D = D = 2
        self.C = C = 1

        ##################################################
        # Blocks
        ##################################################
        _D_sizer = wx.BoxSizer(wx.VERTICAL)
        self._D_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_D_sizer,
            value=self.D,
            callback=self.set_D,
            label='D',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._D_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_D_sizer,
            value=self.D,
            callback=self.set_D,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_D_sizer)
        _C_sizer = wx.BoxSizer(wx.VERTICAL)
        self._C_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_C_sizer,
            value=self.C,
            callback=self.set_C,
            label='C',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._C_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_C_sizer,
            value=self.C,
            callback=self.set_C,
            minimum=0,
            maximum=2,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_C_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=2,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1,
                                                 samp_rate, True)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((C, ))
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, D)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, 1000, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.wxgui_scopesink2_0, 1))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_scopesink2_0, 0))
	def __init__(self, deframer_insync_frames=2, deframer_sync_check=True, viterbi_insync_frames=5, deframer_outsync_frames=5, viterbi_outsync_frames=20, viterbi_sync_check=True, viterbi_sync_threshold=0.1, satellite='GOES-LRIT', freq=1691.02e6, gain=23, decim=108, side="A", pll_alpha=0.005, symb_rate=293883, clock_alpha=0.005):
		grc_wxgui.top_block_gui.__init__(self, title="USRP LRIT Receiver - check signal quality")

		##################################################
		# Parameters
		##################################################
		self.deframer_insync_frames = deframer_insync_frames
		self.deframer_sync_check = deframer_sync_check
		self.viterbi_insync_frames = viterbi_insync_frames
		self.deframer_outsync_frames = deframer_outsync_frames
		self.viterbi_outsync_frames = viterbi_outsync_frames
		self.viterbi_sync_check = viterbi_sync_check
		self.viterbi_sync_threshold = viterbi_sync_threshold
		self.satellite = satellite
		self.freq = freq
		self.gain = gain
		self.decim = decim
		self.side = side
		self.pll_alpha = pll_alpha
		self.symb_rate = symb_rate
		self.clock_alpha = clock_alpha

		##################################################
		# Variables
		##################################################
		self.decim_tb = decim_tb = decim
		self.symb_rate_tb = symb_rate_tb = symb_rate
		self.samp_rate = samp_rate = 64e6/decim_tb
		self.viterbi_sync_threshold_text = viterbi_sync_threshold_text = viterbi_sync_threshold
		self.viterbi_sync_after_text = viterbi_sync_after_text = viterbi_insync_frames
		self.viterbi_outofsync_after_text = viterbi_outofsync_after_text = viterbi_outsync_frames
		self.viterbi_node_sync_text = viterbi_node_sync_text = viterbi_sync_check
		self.sps = sps = samp_rate/symb_rate_tb
		self.satellite_text = satellite_text = satellite
		self.samp_rate_st = samp_rate_st = samp_rate
		self.pll_alpha_sl = pll_alpha_sl = pll_alpha
		self.gain_tb = gain_tb = gain
		self.freq_tb = freq_tb = freq
		self.frames_file_text_inf = frames_file_text_inf = 'no output file'
		self.deframer_sync_after_text = deframer_sync_after_text = deframer_insync_frames
		self.deframer_nosync_after_text = deframer_nosync_after_text = deframer_outsync_frames
		self.deframer_check_sync_text = deframer_check_sync_text = deframer_sync_check
		self.datetime_text = datetime_text = strftime("%A, %B %d %Y %H:%M:%S", localtime())
		self.clock_alpha_sl = clock_alpha_sl = clock_alpha
		self.baseband_file_text_inf = baseband_file_text_inf = 'no output file'

		##################################################
		# Notebooks
		##################################################
		self.rx_ntb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
		self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "USRP Receiver")
		self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "PLL demodulator and Clock sync")
		self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Viterbi decoder")
		self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Deframer")
		self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Output")
		self.Add(self.rx_ntb)

		##################################################
		# Controls
		##################################################
		self._decim_tb_text_box = forms.text_box(
			parent=self.rx_ntb.GetPage(0).GetWin(),
			value=self.decim_tb,
			callback=self.set_decim_tb,
			label="Decimation",
			converter=forms.int_converter(),
		)
		self.rx_ntb.GetPage(0).GridAdd(self._decim_tb_text_box, 1, 3, 1, 1)
		self._symb_rate_tb_text_box = forms.text_box(
			parent=self.rx_ntb.GetPage(1).GetWin(),
			value=self.symb_rate_tb,
			callback=self.set_symb_rate_tb,
			label="Symbol rate",
			converter=forms.int_converter(),
		)
		self.rx_ntb.GetPage(1).GridAdd(self._symb_rate_tb_text_box, 2, 1, 1, 1)
		self._viterbi_sync_threshold_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(2).GetWin(),
			value=self.viterbi_sync_threshold_text,
			callback=self.set_viterbi_sync_threshold_text,
			label="Viterbi node sync threshold [BER]",
			converter=forms.float_converter(),
		)
		self.rx_ntb.GetPage(2).GridAdd(self._viterbi_sync_threshold_text_static_text, 3, 0, 1, 1)
		self._viterbi_sync_after_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(2).GetWin(),
			value=self.viterbi_sync_after_text,
			callback=self.set_viterbi_sync_after_text,
			label="Valid frames for Viterbi decoder sync",
			converter=forms.float_converter(),
		)
		self.rx_ntb.GetPage(2).GridAdd(self._viterbi_sync_after_text_static_text, 4, 0, 1, 1)
		self._viterbi_outofsync_after_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(2).GetWin(),
			value=self.viterbi_outofsync_after_text,
			callback=self.set_viterbi_outofsync_after_text,
			label="Invalid frames for Viterbi decoder out of sync",
			converter=forms.float_converter(),
		)
		self.rx_ntb.GetPage(2).GridAdd(self._viterbi_outofsync_after_text_static_text, 5, 0, 1, 1)
		self._viterbi_node_sync_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(2).GetWin(),
			value=self.viterbi_node_sync_text,
			callback=self.set_viterbi_node_sync_text,
			label="Viterbi node sync enable",
			converter=forms.str_converter(),
		)
		self.rx_ntb.GetPage(2).GridAdd(self._viterbi_node_sync_text_static_text, 2, 0, 1, 1)
		self._satellite_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(0).GetWin(),
			value=self.satellite_text,
			callback=self.set_satellite_text,
			label="Sat ",
			converter=forms.str_converter(),
		)
		self.rx_ntb.GetPage(0).GridAdd(self._satellite_text_static_text, 1, 0, 1, 1)
		self._samp_rate_st_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(0).GetWin(),
			value=self.samp_rate_st,
			callback=self.set_samp_rate_st,
			label="Sample rate",
			converter=forms.float_converter(),
		)
		self.rx_ntb.GetPage(0).GridAdd(self._samp_rate_st_static_text, 1, 4, 1, 1)
		_pll_alpha_sl_sizer = wx.BoxSizer(wx.VERTICAL)
		self._pll_alpha_sl_text_box = forms.text_box(
			parent=self.rx_ntb.GetPage(1).GetWin(),
			sizer=_pll_alpha_sl_sizer,
			value=self.pll_alpha_sl,
			callback=self.set_pll_alpha_sl,
			label="PLL Alpha",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._pll_alpha_sl_slider = forms.slider(
			parent=self.rx_ntb.GetPage(1).GetWin(),
			sizer=_pll_alpha_sl_sizer,
			value=self.pll_alpha_sl,
			callback=self.set_pll_alpha_sl,
			minimum=0.001,
			maximum=0.1,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.rx_ntb.GetPage(1).GridAdd(_pll_alpha_sl_sizer, 1, 0, 1, 1)
		self._gain_tb_text_box = forms.text_box(
			parent=self.rx_ntb.GetPage(0).GetWin(),
			value=self.gain_tb,
			callback=self.set_gain_tb,
			label="RX gain [dB]",
			converter=forms.int_converter(),
		)
		self.rx_ntb.GetPage(0).GridAdd(self._gain_tb_text_box, 1, 2, 1, 1)
		self._freq_tb_text_box = forms.text_box(
			parent=self.rx_ntb.GetPage(0).GetWin(),
			value=self.freq_tb,
			callback=self.set_freq_tb,
			label="Frequency",
			converter=forms.float_converter(),
		)
		self.rx_ntb.GetPage(0).GridAdd(self._freq_tb_text_box, 1, 1, 1, 1)
		self._frames_file_text_inf_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(4).GetWin(),
			value=self.frames_file_text_inf,
			callback=self.set_frames_file_text_inf,
			label="Frames filename",
			converter=forms.str_converter(),
		)
		self.rx_ntb.GetPage(4).GridAdd(self._frames_file_text_inf_static_text, 3, 0, 1, 1)
		self._deframer_sync_after_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(3).GetWin(),
			value=self.deframer_sync_after_text,
			callback=self.set_deframer_sync_after_text,
			label="Deframe sync after",
			converter=forms.float_converter(),
		)
		self.rx_ntb.GetPage(3).GridAdd(self._deframer_sync_after_text_static_text, 3, 0, 1, 1)
		self._deframer_nosync_after_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(3).GetWin(),
			value=self.deframer_nosync_after_text,
			callback=self.set_deframer_nosync_after_text,
			label="Deframer out of sync after",
			converter=forms.float_converter(),
		)
		self.rx_ntb.GetPage(3).GridAdd(self._deframer_nosync_after_text_static_text, 4, 0, 1, 1)
		self._deframer_check_sync_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(3).GetWin(),
			value=self.deframer_check_sync_text,
			callback=self.set_deframer_check_sync_text,
			label="Deframer check sync enable",
			converter=forms.str_converter(),
		)
		self.rx_ntb.GetPage(3).GridAdd(self._deframer_check_sync_text_static_text, 2, 0, 1, 1)
		self._datetime_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(4).GetWin(),
			value=self.datetime_text,
			callback=self.set_datetime_text,
			label="Local time of aquisition start",
			converter=forms.str_converter(),
		)
		self.rx_ntb.GetPage(4).GridAdd(self._datetime_text_static_text, 1, 0, 1, 1)
		_clock_alpha_sl_sizer = wx.BoxSizer(wx.VERTICAL)
		self._clock_alpha_sl_text_box = forms.text_box(
			parent=self.rx_ntb.GetPage(1).GetWin(),
			sizer=_clock_alpha_sl_sizer,
			value=self.clock_alpha_sl,
			callback=self.set_clock_alpha_sl,
			label="Clock alpha",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._clock_alpha_sl_slider = forms.slider(
			parent=self.rx_ntb.GetPage(1).GetWin(),
			sizer=_clock_alpha_sl_sizer,
			value=self.clock_alpha_sl,
			callback=self.set_clock_alpha_sl,
			minimum=0.001,
			maximum=0.1,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.rx_ntb.GetPage(1).GridAdd(_clock_alpha_sl_sizer, 1, 1, 1, 1)
		self._baseband_file_text_inf_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(4).GetWin(),
			value=self.baseband_file_text_inf,
			callback=self.set_baseband_file_text_inf,
			label="Baseband filename",
			converter=forms.str_converter(),
		)
		self.rx_ntb.GetPage(4).GridAdd(self._baseband_file_text_inf_static_text, 4, 0, 1, 1)

		##################################################
		# Blocks
		##################################################
		self.fec_decode_viterbi_bpsk_fb_0 = fec.decode_viterbi_bpsk_fb(viterbi_sync_check, viterbi_sync_threshold, viterbi_insync_frames, viterbi_outsync_frames, viterbi_outsync_frames*3)
		self.gr_agc_xx_0 = gr.agc_cc(10e-6, 1, 1.0/32767.0, 1.0)
		self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_cc(sps, clock_alpha_sl*clock_alpha_sl/4.0, 0.5, clock_alpha_sl, 0.05)
		self.gr_complex_to_real_0 = gr.complex_to_real(1)
		self.gr_costas_loop_cc_0 = gr.costas_loop_cc(pll_alpha_sl, pll_alpha_sl*pll_alpha_sl/4.0, 0.07, -0.07, 2)
		self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((1, ))
		self.gr_null_sink_0 = gr.null_sink(gr.sizeof_char*1)
		self.gr_packed_to_unpacked_xx_0 = gr.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)
		self.poesweather_metop_cadu_deframer_0 = poesweather.metop_cadu_deframer(True, 1024, deframer_insync_frames, deframer_outsync_frames)
		self.root_raised_cosine_filter_0 = gr.fir_filter_ccf(1, firdes.root_raised_cosine(
			1, samp_rate, symb_rate, 0.25, int(11*samp_rate/symb_rate)))
		self.usrp_simple_source = grc_usrp.simple_source_c(which=0, side=side, rx_ant="RXA")
		self.usrp_simple_source.set_decim_rate(decim_tb)
		self.usrp_simple_source.set_frequency(freq_tb, verbose=True)
		self.usrp_simple_source.set_gain(gain_tb)
		self.wxgui_fftsink1 = fftsink2.fft_sink_c(
			self.rx_ntb.GetPage(0).GetWin(),
			baseband_freq=freq,
			y_per_div=2,
			y_divs=10,
			ref_level=12,
			ref_scale=2.0,
			sample_rate=samp_rate,
			fft_size=1024,
			fft_rate=30,
			average=True,
			avg_alpha=0.1,
			title="Not filtered spectrum",
			peak_hold=False,
		)
		self.rx_ntb.GetPage(0).Add(self.wxgui_fftsink1.win)
		self.wxgui_fftsink2 = fftsink2.fft_sink_c(
			self.rx_ntb.GetPage(0).GetWin(),
			baseband_freq=0,
			y_per_div=2,
			y_divs=10,
			ref_level=12,
			ref_scale=2.0,
			sample_rate=samp_rate,
			fft_size=1024,
			fft_rate=30,
			average=True,
			avg_alpha=0.1,
			title="RRC filtered spectrum",
			peak_hold=False,
		)
		self.rx_ntb.GetPage(0).Add(self.wxgui_fftsink2.win)
		self.wxgui_scopesink2_1 = scopesink2.scope_sink_c(
			self.rx_ntb.GetPage(1).GetWin(),
			title="BPSK constellation diagram",
			sample_rate=symb_rate,
			v_scale=0.4,
			v_offset=0,
			t_scale=1/samp_rate,
			ac_couple=False,
			xy_mode=True,
			num_inputs=1,
		)
		self.rx_ntb.GetPage(1).Add(self.wxgui_scopesink2_1.win)

		##################################################
		# Connections
		##################################################
		self.connect((self.usrp_simple_source, 0), (self.gr_agc_xx_0, 0))
		self.connect((self.gr_agc_xx_0, 0), (self.root_raised_cosine_filter_0, 0))
		self.connect((self.gr_multiply_const_vxx_0, 0), (self.gr_complex_to_real_0, 0))
		self.connect((self.fec_decode_viterbi_bpsk_fb_0, 0), (self.gr_packed_to_unpacked_xx_0, 0))
		self.connect((self.gr_packed_to_unpacked_xx_0, 0), (self.poesweather_metop_cadu_deframer_0, 0))
		self.connect((self.gr_complex_to_real_0, 0), (self.fec_decode_viterbi_bpsk_fb_0, 0))
		self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_multiply_const_vxx_0, 0))
		self.connect((self.gr_costas_loop_cc_0, 0), (self.gr_clock_recovery_mm_xx_0, 0))
		self.connect((self.root_raised_cosine_filter_0, 0), (self.gr_costas_loop_cc_0, 0))
		self.connect((self.gr_multiply_const_vxx_0, 0), (self.wxgui_scopesink2_1, 0))
		self.connect((self.root_raised_cosine_filter_0, 0), (self.wxgui_fftsink2, 0))
		self.connect((self.gr_agc_xx_0, 0), (self.wxgui_fftsink1, 0))
		self.connect((self.poesweather_metop_cadu_deframer_0, 0), (self.gr_null_sink_0, 0))
Example #40
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Variables
        ##################################################
        self.channel_freq = channel_freq = 106.1e6
        self.samp_rate = samp_rate = 10e6
        self.rf_gain = rf_gain = 0
        self.if_gain = if_gain = 20
        self.channel_width = channel_width = 200e3
        self.center_freq = center_freq = channel_freq - 1e6
        self.bb_gain = bb_gain = 20
        self.audio_gain = audio_gain = .5

        ##################################################
        # Blocks
        ##################################################
        _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=30,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_rf_gain_sizer)
        _if_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._if_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_if_gain_sizer,
        	value=self.if_gain,
        	callback=self.set_if_gain,
        	label='if_gain',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._if_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_if_gain_sizer,
        	value=self.if_gain,
        	callback=self.set_if_gain,
        	minimum=0,
        	maximum=30,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_if_gain_sizer)
        _channel_freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._channel_freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_channel_freq_sizer,
        	value=self.channel_freq,
        	callback=self.set_channel_freq,
        	label='channel_freq',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._channel_freq_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_channel_freq_sizer,
        	value=self.channel_freq,
        	callback=self.set_channel_freq,
        	minimum=87.9e6,
        	maximum=107.9e6,
        	num_steps=200,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_channel_freq_sizer)
        _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='bb_gain',
        	converter=forms.int_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=30,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_bb_gain_sizer)
        _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=1,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_audio_gain_sizer)
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=channel_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=None,
        	title='FFT Plot',
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0_0.win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=12,
                decimation=5,
                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(False, 0)
        self.osmosdr_source_0.set_gain(rf_gain, 0)
        self.osmosdr_source_0.set_if_gain(if_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(0, 0)

        self.low_pass_filter_0 = filter.fir_filter_ccf(int(samp_rate/channel_width), firdes.low_pass(
        	1, samp_rate, 75e3, 25e3, firdes.WIN_HAMMING, 6.76))
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink('/home/james/Desktop/gnuradio_projects/hackrf_fm_radio/fm_radio.wav', 1, 48000, 16)
        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(48000, '', True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
        	quad_rate=480e3,
        	audio_decimation=10,
        )
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, center_freq - channel_freq , 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_wfm_rcv_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.blocks_wavfile_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_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.analog_wfm_rcv_0, 0))
    def __init__(self,
                 angle=0,
                 samp_rate=1e6,
                 fft_len=pow(2, 20),
                 samp_rate_sink=8000,
                 tx_amp=10e-3,
                 max_num_of_targets=10,
                 lowpass_cutoff_freq=1700,
                 RF=2.49e9,
                 speed_samp_rate=1,
                 DC_filter_num_elements=4,
                 threshold_dB=-70,
                 rx_gain=0,
                 highpass_cutoff_freq=0,
                 doppler_signal_bw=20):
        grc_wxgui.top_block_gui.__init__(
            self, title="CW Doppler Radar Simulator Multiple Targets")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Parameters
        ##################################################
        self.angle = angle
        self.samp_rate = samp_rate
        self.fft_len = fft_len
        self.samp_rate_sink = samp_rate_sink
        self.tx_amp = tx_amp
        self.max_num_of_targets = max_num_of_targets
        self.lowpass_cutoff_freq = lowpass_cutoff_freq
        self.RF = RF
        self.speed_samp_rate = speed_samp_rate
        self.DC_filter_num_elements = DC_filter_num_elements
        self.threshold_dB = threshold_dB
        self.rx_gain = rx_gain
        self.highpass_cutoff_freq = highpass_cutoff_freq
        self.doppler_signal_bw = doppler_signal_bw

        ##################################################
        # Variables
        ##################################################
        self.target_speed_vector = target_speed_vector = 0
        self.target_direction_vector = target_direction_vector = 0
        self.num_targets = num_targets = 0
        self.tx_amp_tuner = tx_amp_tuner = tx_amp
        self.threshold_dB_tuner = threshold_dB_tuner = threshold_dB
        self.speed_textbox = speed_textbox = target_speed_vector
        self.rx_gain_tuner = rx_gain_tuner = rx_gain
        self.num_targets_textbox = num_targets_textbox = num_targets
        self.max_num_of_targets_tuner = max_num_of_targets_tuner = max_num_of_targets
        self.lowpass_cutoff_freq_tuner = lowpass_cutoff_freq_tuner = lowpass_cutoff_freq
        self.highpass_cutoff_freq_tuner = highpass_cutoff_freq_tuner = highpass_cutoff_freq
        self.doppler_signal_bw_tuner = doppler_signal_bw_tuner = doppler_signal_bw
        self.doppler_freq_sim_tuner = doppler_freq_sim_tuner = 100
        self.direction_textbox = direction_textbox = target_direction_vector
        self.angle_tuner = angle_tuner = angle
        self.RF_tuner = RF_tuner = RF

        ##################################################
        # Blocks
        ##################################################
        _tx_amp_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tx_amp_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_tx_amp_tuner_sizer,
            value=self.tx_amp_tuner,
            callback=self.set_tx_amp_tuner,
            label="TX Signal Amp",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._tx_amp_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_tx_amp_tuner_sizer,
            value=self.tx_amp_tuner,
            callback=self.set_tx_amp_tuner,
            minimum=0,
            maximum=100e-3,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_tx_amp_tuner_sizer, 0, 8, 1, 21)
        _threshold_dB_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._threshold_dB_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_threshold_dB_tuner_sizer,
            value=self.threshold_dB_tuner,
            callback=self.set_threshold_dB_tuner,
            label="Detected Target Threshold (dB)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._threshold_dB_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_threshold_dB_tuner_sizer,
            value=self.threshold_dB_tuner,
            callback=self.set_threshold_dB_tuner,
            minimum=-90,
            maximum=-30,
            num_steps=60,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_threshold_dB_tuner_sizer, 2, 0, 1, 8)
        self.speed_vector_probe = blocks.probe_signal_vf(max_num_of_targets)
        self.notebook = self.notebook = wx.Notebook(self.GetWin(),
                                                    style=wx.NB_TOP)
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook),
                              "FFT CW Doppler Radar Receiver")
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook),
                              "Frequency/Time CW Doppler Radar Receiver")
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook),
                              "FFT CW Doppler Radar Receiver Full Spectrum")
        self.GridAdd(self.notebook, 6, 0, 13, 53)
        _max_num_of_targets_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._max_num_of_targets_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_max_num_of_targets_tuner_sizer,
            value=self.max_num_of_targets_tuner,
            callback=self.set_max_num_of_targets_tuner,
            label="Maximum Number of Targets",
            converter=forms.int_converter(),
            proportion=0,
        )
        self._max_num_of_targets_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_max_num_of_targets_tuner_sizer,
            value=self.max_num_of_targets_tuner,
            callback=self.set_max_num_of_targets_tuner,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.GridAdd(_max_num_of_targets_tuner_sizer, 2, 8, 1, 21)
        _lowpass_cutoff_freq_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._lowpass_cutoff_freq_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_lowpass_cutoff_freq_tuner_sizer,
            value=self.lowpass_cutoff_freq_tuner,
            callback=self.set_lowpass_cutoff_freq_tuner,
            label="Low-Pass Cutoff Frequency (Hz)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._lowpass_cutoff_freq_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_lowpass_cutoff_freq_tuner_sizer,
            value=self.lowpass_cutoff_freq_tuner,
            callback=self.set_lowpass_cutoff_freq_tuner,
            minimum=0,
            maximum=3000,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_lowpass_cutoff_freq_tuner_sizer, 1, 29, 1, 24)
        _highpass_cutoff_freq_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._highpass_cutoff_freq_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_highpass_cutoff_freq_tuner_sizer,
            value=self.highpass_cutoff_freq_tuner,
            callback=self.set_highpass_cutoff_freq_tuner,
            label="High-Pass Cutoff Frequency (Hz)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._highpass_cutoff_freq_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_highpass_cutoff_freq_tuner_sizer,
            value=self.highpass_cutoff_freq_tuner,
            callback=self.set_highpass_cutoff_freq_tuner,
            minimum=0,
            maximum=1600,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_highpass_cutoff_freq_tuner_sizer, 0, 29, 1, 24)
        _doppler_signal_bw_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._doppler_signal_bw_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_doppler_signal_bw_tuner_sizer,
            value=self.doppler_signal_bw_tuner,
            callback=self.set_doppler_signal_bw_tuner,
            label="Doppler Spectrum Bandwidth (Hz)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._doppler_signal_bw_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_doppler_signal_bw_tuner_sizer,
            value=self.doppler_signal_bw_tuner,
            callback=self.set_doppler_signal_bw_tuner,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_doppler_signal_bw_tuner_sizer, 2, 29, 1, 24)
        _doppler_freq_sim_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._doppler_freq_sim_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_doppler_freq_sim_tuner_sizer,
            value=self.doppler_freq_sim_tuner,
            callback=self.set_doppler_freq_sim_tuner,
            label="Doppler Frequency Simulator (Hz)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._doppler_freq_sim_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_doppler_freq_sim_tuner_sizer,
            value=self.doppler_freq_sim_tuner,
            callback=self.set_doppler_freq_sim_tuner,
            minimum=-2000,
            maximum=2000,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_doppler_freq_sim_tuner_sizer, 3, 29, 1, 24)
        self.direction_vector_probe = blocks.probe_signal_vi(
            max_num_of_targets)
        _angle_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._angle_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_angle_tuner_sizer,
            value=self.angle_tuner,
            callback=self.set_angle_tuner,
            label="Angle of Approach of the Target (Deg)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._angle_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_angle_tuner_sizer,
            value=self.angle_tuner,
            callback=self.set_angle_tuner,
            minimum=0,
            maximum=89,
            num_steps=890,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_angle_tuner_sizer, 1, 8, 1, 21)
        _RF_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._RF_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_RF_tuner_sizer,
            value=self.RF_tuner,
            callback=self.set_RF_tuner,
            label="Radar Frequency (Hz)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._RF_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_RF_tuner_sizer,
            value=self.RF_tuner,
            callback=self.set_RF_tuner,
            minimum=2.4e9,
            maximum=2.5e9,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_RF_tuner_sizer, 1, 0, 1, 8)
        self.wxgui_waterfallsink2_time_frequency = waterfallsink2.waterfall_sink_c(
            self.notebook.GetPage(1).GetWin(),
            baseband_freq=0,
            dynamic_range=100,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate_sink,
            fft_size=1024,
            fft_rate=15,
            average=True,
            avg_alpha=None,
            title="Time/Frequency CW Doppler Radar Receiver",
            win=window.blackmanharris,
        )
        self.notebook.GetPage(1).Add(
            self.wxgui_waterfallsink2_time_frequency.win)
        self.wxgui_fftsink2_full_spectrum = fftsink2.fft_sink_c(
            self.notebook.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=4096,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="FFT CW Doppler Radar Receiver Full Spectrum",
            peak_hold=False,
            win=window.blackmanharris,
        )
        self.notebook.GetPage(2).Add(self.wxgui_fftsink2_full_spectrum.win)
        self.wxgui_fftsink2 = fftsink2.fft_sink_c(
            self.notebook.GetPage(0).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate_sink,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="FFT CW Doppler Radar Receiver ",
            peak_hold=False,
            win=window.blackmanharris,
        )
        self.notebook.GetPage(0).Add(self.wxgui_fftsink2.win)
        self.vector_to_stream_positive = blocks.vector_to_stream(
            gr.sizeof_float * 1, fft_len)
        self.vector_to_stream_negative = blocks.vector_to_stream(
            gr.sizeof_float * 1, fft_len)
        self.tx_signal = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 0,
                                             1, 0)
        self.throtle_block = blocks.throttle(gr.sizeof_gr_complex * 1,
                                             samp_rate, True)

        def _target_speed_vector_probe():
            while True:
                val = self.speed_vector_probe.level()
                try:
                    self.set_target_speed_vector(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (speed_samp_rate))

        _target_speed_vector_thread = threading.Thread(
            target=_target_speed_vector_probe)
        _target_speed_vector_thread.daemon = True
        _target_speed_vector_thread.start()

        def _target_direction_vector_probe():
            while True:
                val = self.direction_vector_probe.level()
                try:
                    self.set_target_direction_vector(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (speed_samp_rate))

        _target_direction_vector_thread = threading.Thread(
            target=_target_direction_vector_probe)
        _target_direction_vector_thread.daemon = True
        _target_direction_vector_thread.start()
        self.stream_to_vector_positive = blocks.stream_to_vector(
            gr.sizeof_float * 1, fft_len / 2)
        self.stream_to_vector_negative = blocks.stream_to_vector(
            gr.sizeof_float * 1, fft_len / 2)
        self.stream_to_vector_for_fft = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, fft_len)
        self._speed_textbox_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.speed_textbox,
            callback=self.set_speed_textbox,
            label="Targets Speed (Kph)",
            converter=forms.str_converter(),
        )
        self.GridAdd(self._speed_textbox_text_box, 4, 0, 1, 53)
        self.rx_signal_2 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE,
                                               doppler_freq_sim_tuner + 15,
                                               tx_amp_tuner - 5e-3, 0)
        self.rx_signal_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE,
                                               doppler_freq_sim_tuner - 1300,
                                               tx_amp + 10e-3, 0)
        self.rx_signal_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE,
                                               doppler_freq_sim_tuner,
                                               tx_amp_tuner, 0)
        _rx_gain_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_gain_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rx_gain_tuner_sizer,
            value=self.rx_gain_tuner,
            callback=self.set_rx_gain_tuner,
            label="USRP RX Gain (dB)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rx_gain_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rx_gain_tuner_sizer,
            value=self.rx_gain_tuner,
            callback=self.set_rx_gain_tuner,
            minimum=0,
            maximum=70,
            num_steps=70,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_rx_gain_tuner_sizer, 0, 0, 1, 8)
        self.rational_resampler = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=int(samp_rate / samp_rate_sink),
            taps=None,
            fractional_bw=None,
        )
        self._num_targets_textbox_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.num_targets_textbox,
            callback=self.set_num_targets_textbox,
            label="Number of Targets Detected",
            converter=forms.int_converter(),
        )
        self.GridAdd(self._num_targets_textbox_text_box, 3, 0, 1, 4)
        self.num_targets_probe = blocks.probe_signal_i()

        def _num_targets_probe():
            while True:
                val = self.num_targets_probe.level()
                try:
                    self.set_num_targets(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (speed_samp_rate))

        _num_targets_thread = threading.Thread(target=_num_targets_probe)
        _num_targets_thread.daemon = True
        _num_targets_thread.start()
        self.mixer = blocks.multiply_vcc(1)
        self.keep_m_in_n_positive = blocks.keep_m_in_n(gr.sizeof_float,
                                                       fft_len / 2, fft_len,
                                                       fft_len / 2)
        self.keep_m_in_n_negative = blocks.keep_m_in_n(gr.sizeof_float,
                                                       fft_len / 2, fft_len, 0)
        self.fft_vxx_0 = fft.fft_vcc(fft_len, True,
                                     (window.blackmanharris(fft_len)), True, 1)
        self._direction_textbox_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.direction_textbox,
            callback=self.set_direction_textbox,
            label="Targets Direction",
            converter=forms.str_converter(),
        )
        self.GridAdd(self._direction_textbox_text_box, 5, 0, 1, 53)
        self.cwradar_vector_flip_ff = cwradar.vector_flip_ff(fft_len / 2)
        self.cwradar_doppler_velocity_multiple_targets_ff = cwradar.doppler_velocity_multiple_targets_ff(
            fft_len / 2, samp_rate, RF_tuner, threshold_dB_tuner, angle_tuner,
            lowpass_cutoff_freq_tuner, highpass_cutoff_freq_tuner,
            max_num_of_targets_tuner, doppler_signal_bw_tuner)
        self.blocks_complex_to_mag = blocks.complex_to_mag(fft_len)
        self.awgn_channel_simulator = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1e-3, 0)
        self.adder_2 = blocks.add_vcc(1)
        self.adder_1 = blocks.add_vcc(1)
        self.DC_filter_positive = blocks.multiply_const_vff(
            ([0] * DC_filter_num_elements + [1] *
             ((fft_len / 2) - DC_filter_num_elements)))
        self.DC_filter_negative = blocks.multiply_const_vff(
            ([0] * DC_filter_num_elements + [1] *
             ((fft_len / 2) - DC_filter_num_elements)))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.DC_filter_negative, 0),
                     (self.cwradar_doppler_velocity_multiple_targets_ff, 0))
        self.connect((self.DC_filter_positive, 0),
                     (self.cwradar_doppler_velocity_multiple_targets_ff, 1))
        self.connect((self.cwradar_doppler_velocity_multiple_targets_ff, 2),
                     (self.num_targets_probe, 0))
        self.connect((self.cwradar_doppler_velocity_multiple_targets_ff, 1),
                     (self.direction_vector_probe, 0))
        self.connect((self.cwradar_doppler_velocity_multiple_targets_ff, 0),
                     (self.speed_vector_probe, 0))
        self.connect((self.awgn_channel_simulator, 0), (self.adder_2, 0))
        self.connect((self.tx_signal, 0), (self.adder_2, 1))
        self.connect((self.adder_2, 0), (self.mixer, 0))
        self.connect((self.awgn_channel_simulator, 0), (self.adder_1, 0))
        self.connect((self.mixer, 0), (self.throtle_block, 0))
        self.connect((self.mixer, 0), (self.stream_to_vector_for_fft, 0))
        self.connect((self.throtle_block, 0),
                     (self.wxgui_fftsink2_full_spectrum, 0))
        self.connect((self.throtle_block, 0), (self.rational_resampler, 0))
        self.connect((self.adder_1, 0), (self.mixer, 1))
        self.connect((self.rational_resampler, 0),
                     (self.wxgui_waterfallsink2_time_frequency, 0))
        self.connect((self.stream_to_vector_for_fft, 0), (self.fft_vxx_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag, 0))
        self.connect((self.blocks_complex_to_mag, 0),
                     (self.vector_to_stream_negative, 0))
        self.connect((self.blocks_complex_to_mag, 0),
                     (self.vector_to_stream_positive, 0))
        self.connect((self.vector_to_stream_positive, 0),
                     (self.keep_m_in_n_positive, 0))
        self.connect((self.keep_m_in_n_negative, 0),
                     (self.stream_to_vector_negative, 0))
        self.connect((self.keep_m_in_n_positive, 0),
                     (self.stream_to_vector_positive, 0))
        self.connect((self.vector_to_stream_negative, 0),
                     (self.keep_m_in_n_negative, 0))
        self.connect((self.stream_to_vector_positive, 0),
                     (self.DC_filter_positive, 0))
        self.connect((self.stream_to_vector_negative, 0),
                     (self.cwradar_vector_flip_ff, 0))
        self.connect((self.cwradar_vector_flip_ff, 0),
                     (self.DC_filter_negative, 0))
        self.connect((self.rx_signal_1, 0), (self.adder_1, 3))
        self.connect((self.rx_signal_0, 0), (self.adder_1, 2))
        self.connect((self.tx_signal, 0), (self.adder_1, 1))
        self.connect((self.rx_signal_2, 0), (self.adder_1, 4))
        self.connect((self.rational_resampler, 0), (self.wxgui_fftsink2, 0))
Example #42
0
    def __init__(self,
                 gain=25,
                 clock_alpha=0.005,
                 freq=1707e6,
                 decim=25,
                 satellite='MetOp',
                 symb_rate=(3500e3 / 3 + 3500e3) / 2,
                 pll_alpha=0.005,
                 deframer_sync_check=True,
                 deframer_insync_frames=2,
                 deframer_outsync_frames=5,
                 frames_file=os.environ['HOME'] + '/metop_ahrpt_frames.cadu',
                 baseband_file=os.environ['HOME'] +
                 '/metop_ahrpt_baseband.dat',
                 viterbi_sync_threshold=0.1,
                 viterbi_sync_check=True,
                 viterbi_insync_frames=5,
                 viterbi_outsync_frames=20):
        grc_wxgui.top_block_gui.__init__(self,
                                         title="USRP2 MetOp AHRPT Receiver")

        ##################################################
        # Parameters
        ##################################################
        self.gain = gain
        self.clock_alpha = clock_alpha
        self.freq = freq
        self.decim = decim
        self.satellite = satellite
        self.symb_rate = symb_rate
        self.pll_alpha = pll_alpha
        self.deframer_sync_check = deframer_sync_check
        self.deframer_insync_frames = deframer_insync_frames
        self.deframer_outsync_frames = deframer_outsync_frames
        self.frames_file = frames_file
        self.baseband_file = baseband_file
        self.viterbi_sync_threshold = viterbi_sync_threshold
        self.viterbi_sync_check = viterbi_sync_check
        self.viterbi_insync_frames = viterbi_insync_frames
        self.viterbi_outsync_frames = viterbi_outsync_frames

        ##################################################
        # Variables
        ##################################################
        self.decim_tb = decim_tb = decim
        self.symb_rate_tb = symb_rate_tb = symb_rate
        self.samp_rate = samp_rate = 100e6 / decim_tb
        self.viterbi_sync_threshold_text = viterbi_sync_threshold_text = viterbi_sync_threshold
        self.viterbi_sync_after_text = viterbi_sync_after_text = viterbi_insync_frames
        self.viterbi_outofsync_after_text = viterbi_outofsync_after_text = viterbi_outsync_frames
        self.viterbi_node_sync_text = viterbi_node_sync_text = viterbi_sync_check
        self.sps = sps = samp_rate / symb_rate_tb
        self.satellite_text = satellite_text = satellite
        self.samp_rate_st = samp_rate_st = samp_rate
        self.pll_alpha_sl = pll_alpha_sl = pll_alpha
        self.max_clock_offset = max_clock_offset = 0.1
        self.max_carrier_offset = max_carrier_offset = 2 * math.pi * 100e3 / samp_rate
        self.gain_tb = gain_tb = gain
        self.freq_tb = freq_tb = freq
        self.frames_file_text_inf = frames_file_text_inf = frames_file
        self.deframer_sync_after_text = deframer_sync_after_text = deframer_insync_frames
        self.deframer_nosync_after_text = deframer_nosync_after_text = deframer_outsync_frames
        self.deframer_check_sync_text = deframer_check_sync_text = deframer_sync_check
        self.datetime_text = datetime_text = strftime("%A, %B %d %Y %H:%M:%S",
                                                      localtime())
        self.clock_alpha_sl = clock_alpha_sl = clock_alpha
        self.baseband_file_text_inf = baseband_file_text_inf = baseband_file

        ##################################################
        # Notebooks
        ##################################################
        self.rx_ntb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "USRP Receiver")
        self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb),
                            "PLL demodulator and Clock sync")
        self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Viterbi decoder")
        self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Deframer")
        self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Output")
        self.Add(self.rx_ntb)

        ##################################################
        # Controls
        ##################################################
        self._decim_tb_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(0).GetWin(),
            value=self.decim_tb,
            callback=self.set_decim_tb,
            label="Decimation",
            converter=forms.int_converter(),
        )
        self.rx_ntb.GetPage(0).GridAdd(self._decim_tb_text_box, 1, 3, 1, 1)
        self._symb_rate_tb_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            value=self.symb_rate_tb,
            callback=self.set_symb_rate_tb,
            label="Symbol rate",
            converter=forms.int_converter(),
        )
        self.rx_ntb.GetPage(1).GridAdd(self._symb_rate_tb_text_box, 2, 1, 1, 1)
        self._viterbi_sync_threshold_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(2).GetWin(),
            value=self.viterbi_sync_threshold_text,
            callback=self.set_viterbi_sync_threshold_text,
            label="Viterbi node sync threshold [BER]",
            converter=forms.float_converter(),
        )
        self.rx_ntb.GetPage(2).GridAdd(
            self._viterbi_sync_threshold_text_static_text, 3, 0, 1, 1)
        self._viterbi_sync_after_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(2).GetWin(),
            value=self.viterbi_sync_after_text,
            callback=self.set_viterbi_sync_after_text,
            label="Valid frames for Viterbi decoder sync",
            converter=forms.float_converter(),
        )
        self.rx_ntb.GetPage(2).GridAdd(
            self._viterbi_sync_after_text_static_text, 4, 0, 1, 1)
        self._viterbi_outofsync_after_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(2).GetWin(),
            value=self.viterbi_outofsync_after_text,
            callback=self.set_viterbi_outofsync_after_text,
            label="Invalid frames for Viterbi decoder out of sync",
            converter=forms.float_converter(),
        )
        self.rx_ntb.GetPage(2).GridAdd(
            self._viterbi_outofsync_after_text_static_text, 5, 0, 1, 1)
        self._viterbi_node_sync_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(2).GetWin(),
            value=self.viterbi_node_sync_text,
            callback=self.set_viterbi_node_sync_text,
            label="Viterbi node sync enable",
            converter=forms.str_converter(),
        )
        self.rx_ntb.GetPage(2).GridAdd(
            self._viterbi_node_sync_text_static_text, 2, 0, 1, 1)
        self._satellite_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(0).GetWin(),
            value=self.satellite_text,
            callback=self.set_satellite_text,
            label="Sat ",
            converter=forms.str_converter(),
        )
        self.rx_ntb.GetPage(0).GridAdd(self._satellite_text_static_text, 1, 0,
                                       1, 1)
        self._samp_rate_st_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(0).GetWin(),
            value=self.samp_rate_st,
            callback=self.set_samp_rate_st,
            label="Sample rate",
            converter=forms.float_converter(),
        )
        self.rx_ntb.GetPage(0).GridAdd(self._samp_rate_st_static_text, 1, 4, 1,
                                       1)
        _pll_alpha_sl_sizer = wx.BoxSizer(wx.VERTICAL)
        self._pll_alpha_sl_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            sizer=_pll_alpha_sl_sizer,
            value=self.pll_alpha_sl,
            callback=self.set_pll_alpha_sl,
            label="PLL Alpha",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._pll_alpha_sl_slider = forms.slider(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            sizer=_pll_alpha_sl_sizer,
            value=self.pll_alpha_sl,
            callback=self.set_pll_alpha_sl,
            minimum=0.001,
            maximum=0.1,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.rx_ntb.GetPage(1).GridAdd(_pll_alpha_sl_sizer, 1, 0, 1, 1)
        self._gain_tb_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(0).GetWin(),
            value=self.gain_tb,
            callback=self.set_gain_tb,
            label="RX gain [dB]",
            converter=forms.int_converter(),
        )
        self.rx_ntb.GetPage(0).GridAdd(self._gain_tb_text_box, 1, 2, 1, 1)
        self._freq_tb_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(0).GetWin(),
            value=self.freq_tb,
            callback=self.set_freq_tb,
            label="Frequency",
            converter=forms.float_converter(),
        )
        self.rx_ntb.GetPage(0).GridAdd(self._freq_tb_text_box, 1, 1, 1, 1)
        self._frames_file_text_inf_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(4).GetWin(),
            value=self.frames_file_text_inf,
            callback=self.set_frames_file_text_inf,
            label="Frames filename",
            converter=forms.str_converter(),
        )
        self.rx_ntb.GetPage(4).GridAdd(self._frames_file_text_inf_static_text,
                                       3, 0, 1, 1)
        self._deframer_sync_after_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(3).GetWin(),
            value=self.deframer_sync_after_text,
            callback=self.set_deframer_sync_after_text,
            label="Deframe sync after",
            converter=forms.float_converter(),
        )
        self.rx_ntb.GetPage(3).GridAdd(
            self._deframer_sync_after_text_static_text, 3, 0, 1, 1)
        self._deframer_nosync_after_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(3).GetWin(),
            value=self.deframer_nosync_after_text,
            callback=self.set_deframer_nosync_after_text,
            label="Deframer out of sync after",
            converter=forms.float_converter(),
        )
        self.rx_ntb.GetPage(3).GridAdd(
            self._deframer_nosync_after_text_static_text, 4, 0, 1, 1)
        self._deframer_check_sync_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(3).GetWin(),
            value=self.deframer_check_sync_text,
            callback=self.set_deframer_check_sync_text,
            label="Deframer check sync enable",
            converter=forms.str_converter(),
        )
        self.rx_ntb.GetPage(3).GridAdd(
            self._deframer_check_sync_text_static_text, 2, 0, 1, 1)
        self._datetime_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(4).GetWin(),
            value=self.datetime_text,
            callback=self.set_datetime_text,
            label="Local time of aquisition start",
            converter=forms.str_converter(),
        )
        self.rx_ntb.GetPage(4).GridAdd(self._datetime_text_static_text, 1, 0,
                                       1, 1)
        _clock_alpha_sl_sizer = wx.BoxSizer(wx.VERTICAL)
        self._clock_alpha_sl_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            sizer=_clock_alpha_sl_sizer,
            value=self.clock_alpha_sl,
            callback=self.set_clock_alpha_sl,
            label="Clock alpha",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._clock_alpha_sl_slider = forms.slider(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            sizer=_clock_alpha_sl_sizer,
            value=self.clock_alpha_sl,
            callback=self.set_clock_alpha_sl,
            minimum=0.001,
            maximum=0.1,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.rx_ntb.GetPage(1).GridAdd(_clock_alpha_sl_sizer, 1, 1, 1, 1)
        self._baseband_file_text_inf_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(4).GetWin(),
            value=self.baseband_file_text_inf,
            callback=self.set_baseband_file_text_inf,
            label="Baseband filename",
            converter=forms.str_converter(),
        )
        self.rx_ntb.GetPage(4).Add(self._baseband_file_text_inf_static_text)

        ##################################################
        # Blocks
        ##################################################
        self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_cc(
            sps, clock_alpha_sl * clock_alpha_sl / 4.0, 0.5, clock_alpha_sl,
            0.05)
        self.gr_costas_loop_cc_0 = gr.costas_loop_cc(
            pll_alpha_sl, pll_alpha_sl * pll_alpha_sl / 4.0, 0.07, -0.07, 4)
        self.gr_file_sink_0_1 = gr.file_sink(gr.sizeof_short * 2,
                                             baseband_file)
        self.gr_float_to_complex_0 = gr.float_to_complex(1)
        self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((1, ))
        self.gr_short_to_float_0 = gr.short_to_float()
        self.gr_short_to_float_0_0 = gr.short_to_float()
        self.gr_vector_to_streams_0 = gr.vector_to_streams(
            gr.sizeof_short * 1, 2)
        self.usrp2_source_xxxx2_0 = usrp2.source_16sc()
        self.usrp2_source_xxxx2_0.set_decim(decim_tb)
        self.usrp2_source_xxxx2_0.set_center_freq(freq_tb)
        self.usrp2_source_xxxx2_0.set_gain(gain_tb)
        self.wxgui_fftsink1 = fftsink2.fft_sink_c(
            self.rx_ntb.GetPage(0).GetWin(),
            baseband_freq=freq,
            y_per_div=5,
            y_divs=10,
            ref_level=50,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=30,
            average=True,
            avg_alpha=0.1,
            title="Not filtered spectrum",
            peak_hold=False,
        )
        self.rx_ntb.GetPage(0).Add(self.wxgui_fftsink1.win)
        self.wxgui_fftsink2 = fftsink2.fft_sink_c(
            self.rx_ntb.GetPage(0).GetWin(),
            baseband_freq=0,
            y_per_div=5,
            y_divs=10,
            ref_level=50,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=30,
            average=True,
            avg_alpha=0.1,
            title="RRC filtered spectrum",
            peak_hold=False,
        )
        self.rx_ntb.GetPage(0).Add(self.wxgui_fftsink2.win)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_c(
            self.rx_ntb.GetPage(1).GetWin(),
            title="QPSK constellation diagram",
            sample_rate=symb_rate,
            v_scale=0.4,
            v_offset=0,
            t_scale=1 / samp_rate,
            ac_couple=False,
            xy_mode=True,
            num_inputs=1,
        )
        self.rx_ntb.GetPage(1).Add(self.wxgui_scopesink2_1.win)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.gr_float_to_complex_0, 0), (self.wxgui_fftsink1, 0))
        self.connect((self.gr_float_to_complex_0, 0), (self.wxgui_fftsink2, 0))
        self.connect((self.gr_short_to_float_0, 0),
                     (self.gr_float_to_complex_0, 0))
        self.connect((self.gr_short_to_float_0_0, 0),
                     (self.gr_float_to_complex_0, 1))
        self.connect((self.usrp2_source_xxxx2_0, 0),
                     (self.gr_file_sink_0_1, 0))
        self.connect((self.usrp2_source_xxxx2_0, 0),
                     (self.gr_vector_to_streams_0, 0))
        self.connect((self.gr_vector_to_streams_0, 1),
                     (self.gr_short_to_float_0_0, 0))
        self.connect((self.gr_vector_to_streams_0, 0),
                     (self.gr_short_to_float_0, 0))
        self.connect((self.gr_clock_recovery_mm_xx_0, 0),
                     (self.gr_multiply_const_vxx_0, 0))
        self.connect((self.gr_costas_loop_cc_0, 0),
                     (self.gr_clock_recovery_mm_xx_0, 0))
        self.connect((self.gr_float_to_complex_0, 0),
                     (self.gr_costas_loop_cc_0, 0))
        self.connect((self.gr_multiply_const_vxx_0, 0),
                     (self.wxgui_scopesink2_1, 0))
Example #43
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="cdma_txrx")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.N0est = N0est = 1.0
        self.Esest = Esest = 1e-1
        self.EsN0dB_est = EsN0dB_est = 10*numpy.log10( cp.epsilon+ abs(Esest)/ (abs(N0est)+cp.epsilon) ) 
        self.symbol_rate = symbol_rate = 100e3
        self.DataEsN0dBthreshold = DataEsN0dBthreshold = 10
        self.DataEsN0dB_est = DataEsN0dB_est = EsN0dB_est + 10*numpy.log10( 1.0-cp.training_percent/100.0 ) 
        self.samp_rate = samp_rate = symbol_rate*cp.chips_per_symbol
        self.onoff_manual = onoff_manual = 1
        self.onoff_auto = onoff_auto = 0 if DataEsN0dB_est>DataEsN0dBthreshold else 1
        self.manual = manual = 1
        self.onoff = onoff = onoff_auto if manual==0 else onoff_manual
        self.freq_acq_est = freq_acq_est = 0
        self.df = df = cp.df*samp_rate
        self.TrainingEsN0dB_est = TrainingEsN0dB_est = EsN0dB_est + 10*numpy.log10( cp.training_percent/100.0 ) 
        self.EsN0dB = EsN0dB = 20
        self.Es = Es = 1
        self.variable_static_text = variable_static_text = 'Acquisition' if onoff==1 else 'Tracking'
        self.n_filt = n_filt = cp.n_filt
        self.freq_est_acq = freq_est_acq = freq_acq_est
        self.fmaxt = fmaxt = cp.freqs[-1]*samp_rate
        self.drift = drift = 0
        self.dft = dft = df
        self.df_Hz = df_Hz = 0
        self.delay = delay = 0
        self.acq_threshold_dB = acq_threshold_dB = -8.5
        self.TrainingEsN0dB = TrainingEsN0dB = TrainingEsN0dB_est
        self.N0 = N0 = 10**(-EsN0dB/10) * Es
        self.DataEsN0dB_estimated = DataEsN0dB_estimated = DataEsN0dB_est

        ##################################################
        # Blocks
        ##################################################
        _drift_sizer = wx.BoxSizer(wx.VERTICAL)
        self._drift_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_drift_sizer,
        	value=self.drift,
        	callback=self.set_drift,
        	label="drift  (ppm)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._drift_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_drift_sizer,
        	value=self.drift,
        	callback=self.set_drift,
        	minimum=0,
        	maximum=2,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_drift_sizer, 3, 0, 1, 1)
        _df_Hz_sizer = wx.BoxSizer(wx.VERTICAL)
        self._df_Hz_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_df_Hz_sizer,
        	value=self.df_Hz,
        	callback=self.set_df_Hz,
        	label="df_Hz",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._df_Hz_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_df_Hz_sizer,
        	value=self.df_Hz,
        	callback=self.set_df_Hz,
        	minimum=(cp.freqs[0]*samp_rate)-1e-6,
        	maximum=cp.freqs[-1]*samp_rate,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_df_Hz_sizer, 1, 0, 1, 1)
        _delay_sizer = wx.BoxSizer(wx.VERTICAL)
        self._delay_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_delay_sizer,
        	value=self.delay,
        	callback=self.set_delay,
        	label="delay",
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._delay_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_delay_sizer,
        	value=self.delay,
        	callback=self.set_delay,
        	minimum=0,
        	maximum=100-1,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.GridAdd(_delay_sizer, 2, 0, 1, 1)
        self.blocks_probe_signal_n0 = blocks.probe_signal_f()
        self.blocks_probe_signal_amp = blocks.probe_signal_f()
        self.blocks_probe_freq = blocks.probe_signal_f()
        _acq_threshold_dB_sizer = wx.BoxSizer(wx.VERTICAL)
        self._acq_threshold_dB_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_acq_threshold_dB_sizer,
        	value=self.acq_threshold_dB,
        	callback=self.set_acq_threshold_dB,
        	label="acq_threshold_dB",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._acq_threshold_dB_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_acq_threshold_dB_sizer,
        	value=self.acq_threshold_dB,
        	callback=self.set_acq_threshold_dB,
        	minimum=-30,
        	maximum=20,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_acq_threshold_dB_sizer, 7, 0, 1, 1)
        self._variable_static_text_static_text = forms.static_text(
        	parent=self.GetWin(),
        	value=self.variable_static_text,
        	callback=self.set_variable_static_text,
        	label="Ack/Tra Status",
        	converter=forms.str_converter(),
        )
        self.GridAdd(self._variable_static_text_static_text, 4, 0, 1, 1)
        self._onoff_manual_chooser = forms.button(
        	parent=self.GetWin(),
        	value=self.onoff_manual,
        	callback=self.set_onoff_manual,
        	label="Manual Acq/Tra",
        	choices=[0,1],
        	labels=['Tracking','Acquisition'],
        )
        self.GridAdd(self._onoff_manual_chooser, 5, 0, 1, 1)
        self._n_filt_static_text = forms.static_text(
        	parent=self.GetWin(),
        	value=self.n_filt,
        	callback=self.set_n_filt,
        	label="n_filt",
        	converter=forms.int_converter(),
        )
        self.Add(self._n_filt_static_text)
        self._manual_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.manual,
        	callback=self.set_manual,
        	label="Manual/Auto",
        	choices=[0,1],
        	labels=['Auto','Manual'],
        	style=wx.RA_HORIZONTAL,
        )
        self.GridAdd(self._manual_chooser, 6, 0, 1, 1)
        self._freq_est_acq_static_text = forms.static_text(
        	parent=self.GetWin(),
        	value=self.freq_est_acq,
        	callback=self.set_freq_est_acq,
        	label='freq_est_acq',
        	converter=forms.float_converter(),
        )
        self.Add(self._freq_est_acq_static_text)
        def _freq_acq_est_probe():
            while True:
                val = self.blocks_probe_freq.level()
                try:
                    self.set_freq_acq_est(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))
        _freq_acq_est_thread = threading.Thread(target=_freq_acq_est_probe)
        _freq_acq_est_thread.daemon = True
        _freq_acq_est_thread.start()
        self._fmaxt_static_text = forms.static_text(
        	parent=self.GetWin(),
        	value=self.fmaxt,
        	callback=self.set_fmaxt,
        	label="f_max (Hz)",
        	converter=forms.float_converter(),
        )
        self.Add(self._fmaxt_static_text)
        self._dft_static_text = forms.static_text(
        	parent=self.GetWin(),
        	value=self.dft,
        	callback=self.set_dft,
        	label="Deltaf (Hz)",
        	converter=forms.float_converter(),
        )
        self.Add(self._dft_static_text)
        self.channels_channel_model_0 = channels.channel_model(
        	noise_voltage=(cp.chips_per_symbol*cp.samples_per_chip*N0/2)**0.5,
        	frequency_offset=df_Hz/samp_rate,
        	epsilon=1.0+drift*1e-6,
        	taps=((delay)*(0,)+(1,)+(100-1-delay)*(0,)),
        	noise_seed=0,
        	block_tags=False
        )
        self.cdma_tx_hier_0 = cdma_tx_hier()
        self.cdma_rx_hier_0 = cdma_rx_hier(
            acq=onoff,
            acq_threshold_dB=acq_threshold_dB,
        )
        self.cdma_pac_err_cal_0 = cdma.pac_err_cal(1000, 2**cp.cdma_packet_num_bit, "cdma_packet_num")
        self.blocks_vector_source_x_0_1 = blocks.vector_source_b(map(int,numpy.random.randint(0,256,cp.payload_bytes_per_frame)), True, 1, tagged_streams.make_lengthtags((cp.payload_bytes_per_frame,), (0,), cp.length_tag_name))
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_char*1, (symbol_rate*cp.bits_per_uncoded_symbol)/8,True)
        self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False)
        self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char*1)
        self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff((samp_rate, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((Es**0.5, ))
        self._TrainingEsN0dB_static_text = forms.static_text(
        	parent=self.GetWin(),
        	value=self.TrainingEsN0dB,
        	callback=self.set_TrainingEsN0dB,
        	label="TrainingEsN0dB_est",
        	converter=forms.float_converter(),
        )
        self.Add(self._TrainingEsN0dB_static_text)
        def _N0est_probe():
            while True:
                val = self.blocks_probe_signal_n0.level()
                try:
                    self.set_N0est(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))
        _N0est_thread = threading.Thread(target=_N0est_probe)
        _N0est_thread.daemon = True
        _N0est_thread.start()
        def _Esest_probe():
            while True:
                val = self.blocks_probe_signal_amp.level()
                try:
                    self.set_Esest(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))
        _Esest_thread = threading.Thread(target=_Esest_probe)
        _Esest_thread.daemon = True
        _Esest_thread.start()
        _EsN0dB_sizer = wx.BoxSizer(wx.VERTICAL)
        self._EsN0dB_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_EsN0dB_sizer,
        	value=self.EsN0dB,
        	callback=self.set_EsN0dB,
        	label="EsN0dB",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._EsN0dB_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_EsN0dB_sizer,
        	value=self.EsN0dB,
        	callback=self.set_EsN0dB,
        	minimum=-20,
        	maximum=80,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_EsN0dB_sizer, 0, 0, 1, 1)
        _DataEsN0dBthreshold_sizer = wx.BoxSizer(wx.VERTICAL)
        self._DataEsN0dBthreshold_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_DataEsN0dBthreshold_sizer,
        	value=self.DataEsN0dBthreshold,
        	callback=self.set_DataEsN0dBthreshold,
        	label="DataEsN0dBthreshold",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._DataEsN0dBthreshold_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_DataEsN0dBthreshold_sizer,
        	value=self.DataEsN0dBthreshold,
        	callback=self.set_DataEsN0dBthreshold,
        	minimum=0,
        	maximum=20,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_DataEsN0dBthreshold_sizer, 8, 0, 1, 1)
        self._DataEsN0dB_estimated_static_text = forms.static_text(
        	parent=self.GetWin(),
        	value=self.DataEsN0dB_estimated,
        	callback=self.set_DataEsN0dB_estimated,
        	label="DataEsN0dB_est",
        	converter=forms.float_converter(),
        )
        self.Add(self._DataEsN0dB_estimated_static_text)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.cdma_rx_hier_0, 'decoded_header'), (self.cdma_pac_err_cal_0, 'errCal'))    
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.channels_channel_model_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blocks_probe_freq, 0))    
        self.connect((self.blocks_tag_gate_0, 0), (self.blocks_null_sink_0_0, 0))    
        self.connect((self.blocks_tag_gate_0, 0), (self.cdma_rx_hier_0, 0))    
        self.connect((self.blocks_throttle_0_0, 0), (self.cdma_tx_hier_0, 0))    
        self.connect((self.blocks_vector_source_x_0_1, 0), (self.blocks_throttle_0_0, 0))    
        self.connect((self.cdma_rx_hier_0, 3), (self.blocks_multiply_const_vxx_1_0, 0))    
        self.connect((self.cdma_rx_hier_0, 1), (self.blocks_null_sink_0, 0))    
        self.connect((self.cdma_rx_hier_0, 2), (self.blocks_probe_signal_amp, 0))    
        self.connect((self.cdma_rx_hier_0, 0), (self.blocks_probe_signal_n0, 0))    
        self.connect((self.cdma_tx_hier_0, 0), (self.blocks_multiply_const_vxx_1, 0))    
        self.connect((self.channels_channel_model_0, 0), (self.blocks_tag_gate_0, 0))    
	def __init__(self, satellite='NOAA-XX', gain=35, freq=1698e6, sync_check=False, side="A:0", rate=2e6, frames_file=os.environ['HOME'] + '/data/noaa/frames/NOAA-XX.hrpt', baseband_file=os.environ['HOME'] + '/data/noaa/baseband/NOAA-XX.dat'):
		grc_wxgui.top_block_gui.__init__(self, title="Enhanced NOAA HRPT Receiver")
		_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
		self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

		##################################################
		# Parameters
		##################################################
		self.satellite = satellite
		self.gain = gain
		self.freq = freq
		self.sync_check = sync_check
		self.side = side
		self.rate = rate
		self.frames_file = frames_file
		self.baseband_file = baseband_file

		##################################################
		# Variables
		##################################################
		self.sym_rate = sym_rate = 600*1109
		self.samp_rate = samp_rate = rate
		self.config_filename = config_filename = os.environ['HOME']+'/.gnuradio/noaa_hrpt.conf'
		self.sps = sps = samp_rate/sym_rate
		self._saved_pll_alpha_config = ConfigParser.ConfigParser()
		self._saved_pll_alpha_config.read(config_filename)
		try: saved_pll_alpha = self._saved_pll_alpha_config.getfloat(satellite, 'pll_alpha')
		except: saved_pll_alpha = 0.005
		self.saved_pll_alpha = saved_pll_alpha
		self._saved_clock_alpha_config = ConfigParser.ConfigParser()
		self._saved_clock_alpha_config.read(config_filename)
		try: saved_clock_alpha = self._saved_clock_alpha_config.getfloat(satellite, 'clock_alpha')
		except: saved_clock_alpha = 0.001
		self.saved_clock_alpha = saved_clock_alpha
		self.sync_check_txt = sync_check_txt = sync_check
		self.side_text = side_text = side
		self._saved_gain_config = ConfigParser.ConfigParser()
		self._saved_gain_config.read(config_filename)
		try: saved_gain = self._saved_gain_config.getfloat(satellite, 'gain')
		except: saved_gain = gain
		self.saved_gain = saved_gain
		self.satellite_text = satellite_text = satellite
		self.sample_rate_text = sample_rate_text = samp_rate
		self.rate_tb = rate_tb = rate
		self.pll_alpha = pll_alpha = saved_pll_alpha
		self.max_clock_offset = max_clock_offset = 0.1
		self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/samp_rate
		self.hs = hs = int(sps/2.0)
		self.gain_slider = gain_slider = gain
		self.freq_tb = freq_tb = freq
		self.frames_outfile_text = frames_outfile_text = frames_file
		self.datetime_text = datetime_text = strftime("%A, %B %d %Y %H:%M:%S", localtime())
		self.clock_alpha = clock_alpha = saved_clock_alpha

		##################################################
		# Blocks
		##################################################
		_gain_slider_sizer = wx.BoxSizer(wx.VERTICAL)
		self._gain_slider_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_gain_slider_sizer,
			value=self.gain_slider,
			callback=self.set_gain_slider,
			label="Gain",
			converter=forms.int_converter(),
			proportion=0,
		)
		self._gain_slider_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_gain_slider_sizer,
			value=self.gain_slider,
			callback=self.set_gain_slider,
			minimum=0,
			maximum=100,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=int,
			proportion=1,
		)
		self.GridAdd(_gain_slider_sizer, 2, 0, 1, 1)
		self.displays = self.displays = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
		self.displays.AddPage(grc_wxgui.Panel(self.displays), "RX NOAA HRPT")
		self.displays.AddPage(grc_wxgui.Panel(self.displays), "Information")
		self.Add(self.displays)
		_clock_alpha_sizer = wx.BoxSizer(wx.VERTICAL)
		self._clock_alpha_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_clock_alpha_sizer,
			value=self.clock_alpha,
			callback=self.set_clock_alpha,
			label="Clock alpha",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._clock_alpha_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_clock_alpha_sizer,
			value=self.clock_alpha,
			callback=self.set_clock_alpha,
			minimum=0.001,
			maximum=0.1,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_clock_alpha_sizer, 2, 2, 1, 1)
		self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
			self.displays.GetPage(0).GetWin(),
			baseband_freq=0,
			y_per_div=5,
			y_divs=10,
			ref_level=-70,
			ref_scale=2.0,
			sample_rate=samp_rate,
			fft_size=1024,
			fft_rate=15,
			average=True,
			avg_alpha=0.4,
			title="NOAA HRPT FFT Spectrum",
			peak_hold=False,
		)
		self.displays.GetPage(0).Add(self.wxgui_fftsink2_0.win)
		self.uhd_usrp_source_0 = uhd.usrp_source(
			device_addr="",
			stream_args=uhd.stream_args(
				cpu_format="fc32",
				channels=range(1),
			),
		)
		self.uhd_usrp_source_0.set_subdev_spec(side, 0)
		self.uhd_usrp_source_0.set_samp_rate(samp_rate)
		self.uhd_usrp_source_0.set_center_freq(freq, 0)
		self.uhd_usrp_source_0.set_gain(gain_slider, 0)
		self._sync_check_txt_static_text = forms.static_text(
			parent=self.GetWin(),
			value=self.sync_check_txt,
			callback=self.set_sync_check_txt,
			label="Continuous sync check",
			converter=forms.str_converter(),
		)
		self.GridAdd(self._sync_check_txt_static_text, 0, 2, 1, 1)
		self._side_text_static_text = forms.static_text(
			parent=self.GetWin(),
			value=self.side_text,
			callback=self.set_side_text,
			label="USRP Side",
			converter=forms.str_converter(),
		)
		self.GridAdd(self._side_text_static_text, 0, 0, 1, 1)
		self._satellite_text_static_text = forms.static_text(
			parent=self.GetWin(),
			value=self.satellite_text,
			callback=self.set_satellite_text,
			label="Satellite",
			converter=forms.str_converter(),
		)
		self.GridAdd(self._satellite_text_static_text, 0, 1, 1, 1)
		self._sample_rate_text_static_text = forms.static_text(
			parent=self.displays.GetPage(1).GetWin(),
			value=self.sample_rate_text,
			callback=self.set_sample_rate_text,
			label="Sample rate",
			converter=forms.float_converter(),
		)
		self.displays.GetPage(1).GridAdd(self._sample_rate_text_static_text, 3, 0, 1, 1)
		self._rate_tb_text_box = forms.text_box(
			parent=self.GetWin(),
			value=self.rate_tb,
			callback=self.set_rate_tb,
			label="Sample rate",
			converter=forms.float_converter(),
		)
		self.GridAdd(self._rate_tb_text_box, 1, 0, 1, 1)
		self.poesweather_noaa_hrpt_deframer_0 = poesweather.noaa_hrpt_deframer(False)
		_pll_alpha_sizer = wx.BoxSizer(wx.VERTICAL)
		self._pll_alpha_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_pll_alpha_sizer,
			value=self.pll_alpha,
			callback=self.set_pll_alpha,
			label="PLL Alpha",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._pll_alpha_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_pll_alpha_sizer,
			value=self.pll_alpha,
			callback=self.set_pll_alpha,
			minimum=0.005,
			maximum=0.5,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_pll_alpha_sizer, 2, 1, 1, 1)
		self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset)
		self._freq_tb_text_box = forms.text_box(
			parent=self.GetWin(),
			value=self.freq_tb,
			callback=self.set_freq_tb,
			label="Frequency",
			converter=forms.float_converter(),
		)
		self.GridAdd(self._freq_tb_text_box, 1, 1, 1, 1)
		self._frames_outfile_text_static_text = forms.static_text(
			parent=self.displays.GetPage(1).GetWin(),
			value=self.frames_outfile_text,
			callback=self.set_frames_outfile_text,
			label="Frames filename",
			converter=forms.str_converter(),
		)
		self.displays.GetPage(1).GridAdd(self._frames_outfile_text_static_text, 4, 0, 1, 1)
		self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(sps/2.0, clock_alpha**2/4.0, 0.5, clock_alpha, max_clock_offset)
		self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
		self._datetime_text_static_text = forms.static_text(
			parent=self.displays.GetPage(1).GetWin(),
			value=self.datetime_text,
			callback=self.set_datetime_text,
			label="Acquisition start",
			converter=forms.str_converter(),
		)
		self.displays.GetPage(1).GridAdd(self._datetime_text_static_text, 2, 0, 1, 1)
		self.blocks_moving_average_xx_0 = blocks.moving_average_ff(hs, 1.0/hs, 4000)
		self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_short*1, baseband_file)
		self.blocks_file_sink_1.set_unbuffered(False)
		self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_short*1, frames_file)
		self.blocks_file_sink_0.set_unbuffered(False)
		self.blocks_complex_to_interleaved_short_0 = blocks.complex_to_interleaved_short()
		self.analog_agc_xx_0 = analog.agc_cc(1e-5, 1.0, 1.0/32768.0, 1.0)

		##################################################
		# Connections
		##################################################
		self.connect((self.analog_agc_xx_0, 0), (self.pll, 0))
		self.connect((self.pll, 0), (self.blocks_moving_average_xx_0, 0))
		self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0))
		self.connect((self.uhd_usrp_source_0, 0), (self.analog_agc_xx_0, 0))
		self.connect((self.blocks_moving_average_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
		self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0))
		self.connect((self.poesweather_noaa_hrpt_deframer_0, 0), (self.blocks_file_sink_0, 0))
		self.connect((self.digital_binary_slicer_fb_0, 0), (self.poesweather_noaa_hrpt_deframer_0, 0))
		self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_interleaved_short_0, 0))
		self.connect((self.blocks_complex_to_interleaved_short_0, 0), (self.blocks_file_sink_1, 0))
	def __init__(self, decim=50, satellite='Meteor-M-N1', frames_file=os.environ['HOME'] + '/MN1_hrpt_frames.hmf', baseband_file="/home/martin/GNURadioData/hrpt/baseband/HRPT_Meteor-M-N1_2011-02-27_09-30-46_UTC_U2_d50.sam", symb_rate=600*1109, clock_alpha=0.050, pll_alpha=0.05, deframer_outsync_frames=100, deframer_insync_frames=3, deframer_sync_check=False):
		grc_wxgui.top_block_gui.__init__(self, title="Meteor M-N1 HRPT Receiver from baseband file")
		_icon_path = "/home/martin/.local/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
		self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

		##################################################
		# Parameters
		##################################################
		self.decim = decim
		self.satellite = satellite
		self.frames_file = frames_file
		self.baseband_file = baseband_file
		self.symb_rate = symb_rate
		self.clock_alpha = clock_alpha
		self.pll_alpha = pll_alpha
		self.deframer_outsync_frames = deframer_outsync_frames
		self.deframer_insync_frames = deframer_insync_frames
		self.deframer_sync_check = deframer_sync_check

		##################################################
		# Variables
		##################################################
		self.decim_tb = decim_tb = decim
		self.symb_rate_tb = symb_rate_tb = symb_rate
		self.samp_rate = samp_rate = 100e6/decim_tb
		self.sps = sps = samp_rate/symb_rate_tb
		self.v = v = True
		self.satellite_text = satellite_text = satellite
		self.samp_rate_st = samp_rate_st = samp_rate
		self.pll_alpha_sl = pll_alpha_sl = pll_alpha
		self.max_clock_offset = max_clock_offset = 0.1
		self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/samp_rate
		self.hs = hs = int(sps/2.0)
		self.frames_file_text_inf = frames_file_text_inf = frames_file
		self.deframer_sync_after_text = deframer_sync_after_text = deframer_insync_frames
		self.deframer_nosync_after_text = deframer_nosync_after_text = deframer_outsync_frames
		self.deframer_check_sync_text = deframer_check_sync_text = deframer_sync_check
		self.datetime_text = datetime_text = strftime("%A, %B %d %Y %H:%M:%S", localtime())
		self.clock_alpha_sl = clock_alpha_sl = clock_alpha
		self.baseband_file_text_inf = baseband_file_text_inf = baseband_file

		##################################################
		# Blocks
		##################################################
		self.rx_ntb = self.rx_ntb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
		self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Input baseband")
		self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "PLL demodulator and Clock sync")
		self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Deframer")
		self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Output")
		self.Add(self.rx_ntb)
		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_fftsink1 = fftsink2.fft_sink_c(
			self.rx_ntb.GetPage(0).GetWin(),
			baseband_freq=0,
			y_per_div=5,
			y_divs=10,
			ref_level=50,
			ref_scale=2.0,
			sample_rate=samp_rate,
			fft_size=1024,
			fft_rate=30,
			average=True,
			avg_alpha=0.1,
			title="Not filtered spectrum",
			peak_hold=False,
		)
		self.rx_ntb.GetPage(0).Add(self.wxgui_fftsink1.win)
		self._v_check_box = forms.check_box(
			parent=self.GetWin(),
			value=self.v,
			callback=self.set_v,
			label="Open",
			true=True,
			false=False,
		)
		self.Add(self._v_check_box)
		self._symb_rate_tb_text_box = forms.text_box(
			parent=self.rx_ntb.GetPage(1).GetWin(),
			value=self.symb_rate_tb,
			callback=self.set_symb_rate_tb,
			label="Symbol rate",
			converter=forms.int_converter(),
		)
		self.rx_ntb.GetPage(1).GridAdd(self._symb_rate_tb_text_box, 2, 1, 1, 1)
		self._satellite_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(0).GetWin(),
			value=self.satellite_text,
			callback=self.set_satellite_text,
			label="Sat ",
			converter=forms.str_converter(),
		)
		self.rx_ntb.GetPage(0).GridAdd(self._satellite_text_static_text, 1, 0, 1, 1)
		self._samp_rate_st_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(0).GetWin(),
			value=self.samp_rate_st,
			callback=self.set_samp_rate_st,
			label="Sample rate",
			converter=forms.float_converter(),
		)
		self.rx_ntb.GetPage(0).GridAdd(self._samp_rate_st_static_text, 1, 4, 1, 1)
		self.poesweather_meteor_cadu_deframer_0 = poesweather.meteor_cadu_deframer(deframer_sync_check, 256, deframer_insync_frames, deframer_outsync_frames)
		_pll_alpha_sl_sizer = wx.BoxSizer(wx.VERTICAL)
		self._pll_alpha_sl_text_box = forms.text_box(
			parent=self.rx_ntb.GetPage(1).GetWin(),
			sizer=_pll_alpha_sl_sizer,
			value=self.pll_alpha_sl,
			callback=self.set_pll_alpha_sl,
			label="PLL Alpha",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._pll_alpha_sl_slider = forms.slider(
			parent=self.rx_ntb.GetPage(1).GetWin(),
			sizer=_pll_alpha_sl_sizer,
			value=self.pll_alpha_sl,
			callback=self.set_pll_alpha_sl,
			minimum=0.001,
			maximum=0.1,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.rx_ntb.GetPage(1).GridAdd(_pll_alpha_sl_sizer, 1, 0, 1, 1)
		self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset)
		self.gr_throttle_0 = gr.throttle(gr.sizeof_short*1, samp_rate*10)
		self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((-1, ))
		self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000)
		self.gr_file_source_0_0 = gr.file_source(gr.sizeof_short*1, "/home/martin/hrpt/baseband/METEOR-M-1/2011/07/24/METEOR-M-1_2011-07-24T113448_U2d50.sam", False)
		self.gr_file_sink_0_0_0 = gr.file_sink(gr.sizeof_char*1, "frames.mn1")
		self.gr_file_sink_0_0_0.set_unbuffered(False)
		self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_ff(sps/2.0, clock_alpha**2/4.0, 0.5, clock_alpha, max_clock_offset)
		self.gr_binary_slicer_fb_0 = gr.binary_slicer_fb()
		self.gr_agc_xx_0_0 = gr.agc_cc(10e-6, 1, 1.0/32767.0, 1.0)
		self._frames_file_text_inf_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(3).GetWin(),
			value=self.frames_file_text_inf,
			callback=self.set_frames_file_text_inf,
			label="Frames filename",
			converter=forms.str_converter(),
		)
		self.rx_ntb.GetPage(3).GridAdd(self._frames_file_text_inf_static_text, 3, 0, 1, 1)
		self._deframer_sync_after_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(2).GetWin(),
			value=self.deframer_sync_after_text,
			callback=self.set_deframer_sync_after_text,
			label="Deframe sync after",
			converter=forms.float_converter(),
		)
		self.rx_ntb.GetPage(2).GridAdd(self._deframer_sync_after_text_static_text, 3, 0, 1, 1)
		self._deframer_nosync_after_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(2).GetWin(),
			value=self.deframer_nosync_after_text,
			callback=self.set_deframer_nosync_after_text,
			label="Deframer out of sync after",
			converter=forms.float_converter(),
		)
		self.rx_ntb.GetPage(2).GridAdd(self._deframer_nosync_after_text_static_text, 4, 0, 1, 1)
		self._deframer_check_sync_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(2).GetWin(),
			value=self.deframer_check_sync_text,
			callback=self.set_deframer_check_sync_text,
			label="Deframer check sync enable",
			converter=forms.str_converter(),
		)
		self.rx_ntb.GetPage(2).GridAdd(self._deframer_check_sync_text_static_text, 2, 0, 1, 1)
		self._decim_tb_text_box = forms.text_box(
			parent=self.rx_ntb.GetPage(0).GetWin(),
			value=self.decim_tb,
			callback=self.set_decim_tb,
			label="Decimation",
			converter=forms.int_converter(),
		)
		self.rx_ntb.GetPage(0).GridAdd(self._decim_tb_text_box, 1, 3, 1, 1)
		self._datetime_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(3).GetWin(),
			value=self.datetime_text,
			callback=self.set_datetime_text,
			label="Local time of aquisition start",
			converter=forms.str_converter(),
		)
		self.rx_ntb.GetPage(3).GridAdd(self._datetime_text_static_text, 1, 0, 1, 1)
		self.cs2cf = gr.interleaved_short_to_complex()
		_clock_alpha_sl_sizer = wx.BoxSizer(wx.VERTICAL)
		self._clock_alpha_sl_text_box = forms.text_box(
			parent=self.rx_ntb.GetPage(1).GetWin(),
			sizer=_clock_alpha_sl_sizer,
			value=self.clock_alpha_sl,
			callback=self.set_clock_alpha_sl,
			label="Clock alpha",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._clock_alpha_sl_slider = forms.slider(
			parent=self.rx_ntb.GetPage(1).GetWin(),
			sizer=_clock_alpha_sl_sizer,
			value=self.clock_alpha_sl,
			callback=self.set_clock_alpha_sl,
			minimum=0.001,
			maximum=0.1,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.rx_ntb.GetPage(1).GridAdd(_clock_alpha_sl_sizer, 1, 1, 1, 1)
		self._baseband_file_text_inf_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(3).GetWin(),
			value=self.baseband_file_text_inf,
			callback=self.set_baseband_file_text_inf,
			label="Baseband filename",
			converter=forms.str_converter(),
		)
		self.rx_ntb.GetPage(3).GridAdd(self._baseband_file_text_inf_static_text, 4, 0, 1, 1)

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_throttle_0, 0), (self.cs2cf, 0))
		self.connect((self.pll, 0), (self.gr_moving_average_xx_0, 0))
		self.connect((self.gr_moving_average_xx_0, 0), (self.gr_clock_recovery_mm_xx_0, 0))
		self.connect((self.cs2cf, 0), (self.gr_agc_xx_0_0, 0))
		self.connect((self.gr_agc_xx_0_0, 0), (self.pll, 0))
		self.connect((self.cs2cf, 0), (self.wxgui_fftsink1, 0))
		self.connect((self.gr_multiply_const_vxx_0, 0), (self.gr_binary_slicer_fb_0, 0))
		self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_multiply_const_vxx_0, 0))
		self.connect((self.poesweather_meteor_cadu_deframer_0, 0), (self.gr_file_sink_0_0_0, 0))
		self.connect((self.gr_binary_slicer_fb_0, 0), (self.poesweather_meteor_cadu_deframer_0, 0))
		self.connect((self.gr_file_source_0_0, 0), (self.gr_throttle_0, 0))
		self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.wxgui_scopesink2_0, 0))
Example #46
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.samp_rate = samp_rate = 192000
                self.Noise = Noise = 0.01
                self.Loudness = Loudness = 0.7
                self.Frequency = Frequency = 5000
 
                ##################################################
                # Blocks
                ##################################################
                _Noise_sizer = wx.BoxSizer(wx.VERTICAL)
                self._Noise_text_box = forms.text_box(
                        parent=self.GetWin(),
                        sizer=_Noise_sizer,
                        value=self.Noise,
                        callback=self.set_Noise,
                        label="Noise",
                        converter=forms.float_converter(),
                        proportion=0,
                )
                self._Noise_slider = forms.slider(
                        parent=self.GetWin(),
                        sizer=_Noise_sizer,
                        value=self.Noise,
                        callback=self.set_Noise,
                        minimum=0.0,
                        maximum=1,
                        num_steps=1000,
                        style=wx.SL_HORIZONTAL,
                        cast=float,
                        proportion=1,
                )
                self.Add(_Noise_sizer)
                _Loudness_sizer = wx.BoxSizer(wx.VERTICAL)
                self._Loudness_text_box = forms.text_box(
                        parent=self.GetWin(),
                        sizer=_Loudness_sizer,
                        value=self.Loudness,
                        callback=self.set_Loudness,
                        label="Loudness",
                        converter=forms.float_converter(),
                        proportion=0,
                )
                self._Loudness_slider = forms.slider(
                        parent=self.GetWin(),
                        sizer=_Loudness_sizer,
                        value=self.Loudness,
                        callback=self.set_Loudness,
                        minimum=0.0,
                        maximum=1.0,
                        num_steps=1000,
                        style=wx.SL_HORIZONTAL,
                        cast=float,
                        proportion=1,
                )
                self.Add(_Loudness_sizer)
                _Frequency_sizer = wx.BoxSizer(wx.VERTICAL)
                self._Frequency_text_box = forms.text_box(
                        parent=self.GetWin(),
                        sizer=_Frequency_sizer,
                        value=self.Frequency,
                        callback=self.set_Frequency,
                        label="Frequency",
                        converter=forms.int_converter(),
                        proportion=0,
                )
                self._Frequency_slider = forms.slider(
                        parent=self.GetWin(),
                        sizer=_Frequency_sizer,
                        value=self.Frequency,
                        callback=self.set_Frequency,
                        minimum=10,
                        maximum=20000,
                        num_steps=1000,
                        style=wx.SL_HORIZONTAL,
                        cast=int,
                        proportion=1,
                )
                self.Add(_Frequency_sizer)
                self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
                        self.GetWin(),
                        baseband_freq=0,
                        dynamic_range=100,
                        ref_level=0,
                        ref_scale=4.0,
                        sample_rate=samp_rate,
                        fft_size=2048,
                        fft_rate=15,
                        average=False,
                        avg_alpha=0.1,
                        title="Waterfall Plot",
                        size=(900,200),
                )
                self.Add(self.wxgui_waterfallsink2_0.win)
                def wxgui_waterfallsink2_0_callback(x, y):
                        self.set_Frequency(x)
 
                self.wxgui_waterfallsink2_0.set_callback(wxgui_waterfallsink2_0_callback)
                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=4.0,
                        sample_rate=samp_rate,
                        fft_size=2048,
                        fft_rate=15,
                        average=True,
                        avg_alpha=0.1,
                        title="FFT Plot",
                        peak_hold=True,
                )
                self.Add(self.wxgui_fftsink2_0.win)
                self.gr_sig_source_x_2 = gr.sig_source_c(samp_rate, gr.GR_SIN_WAVE, Frequency, Loudness, 0)
                self.gr_noise_source_x_0 = gr.noise_source_c(gr.GR_GAUSSIAN, Noise, 0)
                self.gr_complex_to_real_0 = gr.complex_to_real(1)
                self.gr_add_xx_1 = gr.add_vcc(1)
                self.audio_sink_0 = audio.sink(samp_rate, "", True)
 
                ##################################################
                # Connections
                ##################################################
                self.connect((self.gr_complex_to_real_0, 0), (self.audio_sink_0, 0))
                self.connect((self.gr_noise_source_x_0, 0), (self.gr_add_xx_1, 0))
                self.connect((self.gr_sig_source_x_2, 0), (self.gr_add_xx_1, 1))
                self.connect((self.gr_add_xx_1, 0), (self.gr_complex_to_real_0, 0))
                self.connect((self.gr_add_xx_1, 0), (self.wxgui_waterfallsink2_0, 0))
                self.connect((self.gr_add_xx_1, 0), (self.wxgui_fftsink2_0, 0))
Example #47
0
    def __init__(self,
                 deframer_insync_frames=2,
                 viterbi_insync_frames=5,
                 deframer_outsync_frames=5,
                 viterbi_outsync_frames=20,
                 viterbi_sync_check=True,
                 viterbi_sync_threshold=0.1,
                 deframer_sync_check=True,
                 clock_alpha=0.005,
                 symb_rate=293883,
                 pll_alpha=0.005,
                 satellite='GOES-LRIT',
                 freq=1691.02e6,
                 gain=23,
                 decim=108,
                 side="A",
                 frames_file=os.environ['HOME'] +
                 '/GOES-LRIT_cadu_frames.cadu',
                 baseband_file=os.environ['HOME'] + '/GOES-LRIT_baseband.dat'):
        grc_wxgui.top_block_gui.__init__(
            self, title="LRIT Receiver from baseband file")

        ##################################################
        # Parameters
        ##################################################
        self.deframer_insync_frames = deframer_insync_frames
        self.viterbi_insync_frames = viterbi_insync_frames
        self.deframer_outsync_frames = deframer_outsync_frames
        self.viterbi_outsync_frames = viterbi_outsync_frames
        self.viterbi_sync_check = viterbi_sync_check
        self.viterbi_sync_threshold = viterbi_sync_threshold
        self.deframer_sync_check = deframer_sync_check
        self.clock_alpha = clock_alpha
        self.symb_rate = symb_rate
        self.pll_alpha = pll_alpha
        self.satellite = satellite
        self.freq = freq
        self.gain = gain
        self.decim = decim
        self.side = side
        self.frames_file = frames_file
        self.baseband_file = baseband_file

        ##################################################
        # Variables
        ##################################################
        self.decim_tb = decim_tb = decim
        self.symb_rate_tb = symb_rate_tb = symb_rate
        self.samp_rate = samp_rate = 64e6 / decim_tb
        self.viterbi_sync_threshold_text = viterbi_sync_threshold_text = viterbi_sync_threshold
        self.viterbi_sync_after_text = viterbi_sync_after_text = viterbi_insync_frames
        self.viterbi_outofsync_after_text = viterbi_outofsync_after_text = viterbi_outsync_frames
        self.viterbi_node_sync_text = viterbi_node_sync_text = viterbi_sync_check
        self.sps = sps = samp_rate / symb_rate_tb
        self.satellite_text = satellite_text = satellite
        self.samp_rate_st = samp_rate_st = samp_rate
        self.pll_alpha_sl = pll_alpha_sl = pll_alpha
        self.gain_tb = gain_tb = gain
        self.freq_tb = freq_tb = freq
        self.frames_file_text_inf = frames_file_text_inf = frames_file
        self.deframer_sync_after_text = deframer_sync_after_text = deframer_insync_frames
        self.deframer_nosync_after_text = deframer_nosync_after_text = deframer_outsync_frames
        self.deframer_check_sync_text = deframer_check_sync_text = deframer_sync_check
        self.datetime_text = datetime_text = strftime("%A, %B %d %Y %H:%M:%S",
                                                      localtime())
        self.clock_alpha_sl = clock_alpha_sl = clock_alpha
        self.baseband_file_text_inf = baseband_file_text_inf = 'no output file'

        ##################################################
        # Notebooks
        ##################################################
        self.rx_ntb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "USRP Receiver")
        self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb),
                            "PLL demodulator and Clock sync")
        self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Viterbi decoder")
        self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Deframer")
        self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Output")
        self.Add(self.rx_ntb)

        ##################################################
        # Controls
        ##################################################
        self._decim_tb_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(0).GetWin(),
            value=self.decim_tb,
            callback=self.set_decim_tb,
            label="Decimation",
            converter=forms.int_converter(),
        )
        self.rx_ntb.GetPage(0).GridAdd(self._decim_tb_text_box, 1, 3, 1, 1)
        self._symb_rate_tb_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            value=self.symb_rate_tb,
            callback=self.set_symb_rate_tb,
            label="Symbol rate",
            converter=forms.int_converter(),
        )
        self.rx_ntb.GetPage(1).GridAdd(self._symb_rate_tb_text_box, 2, 1, 1, 1)
        self._viterbi_sync_threshold_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(2).GetWin(),
            value=self.viterbi_sync_threshold_text,
            callback=self.set_viterbi_sync_threshold_text,
            label="Viterbi node sync threshold [BER]",
            converter=forms.float_converter(),
        )
        self.rx_ntb.GetPage(2).GridAdd(
            self._viterbi_sync_threshold_text_static_text, 3, 0, 1, 1)
        self._viterbi_sync_after_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(2).GetWin(),
            value=self.viterbi_sync_after_text,
            callback=self.set_viterbi_sync_after_text,
            label="Valid frames for Viterbi decoder sync",
            converter=forms.float_converter(),
        )
        self.rx_ntb.GetPage(2).GridAdd(
            self._viterbi_sync_after_text_static_text, 4, 0, 1, 1)
        self._viterbi_outofsync_after_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(2).GetWin(),
            value=self.viterbi_outofsync_after_text,
            callback=self.set_viterbi_outofsync_after_text,
            label="Invalid frames for Viterbi decoder out of sync",
            converter=forms.float_converter(),
        )
        self.rx_ntb.GetPage(2).GridAdd(
            self._viterbi_outofsync_after_text_static_text, 5, 0, 1, 1)
        self._viterbi_node_sync_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(2).GetWin(),
            value=self.viterbi_node_sync_text,
            callback=self.set_viterbi_node_sync_text,
            label="Viterbi node sync enable",
            converter=forms.str_converter(),
        )
        self.rx_ntb.GetPage(2).GridAdd(
            self._viterbi_node_sync_text_static_text, 2, 0, 1, 1)
        self._satellite_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(0).GetWin(),
            value=self.satellite_text,
            callback=self.set_satellite_text,
            label="Sat ",
            converter=forms.str_converter(),
        )
        self.rx_ntb.GetPage(0).GridAdd(self._satellite_text_static_text, 1, 0,
                                       1, 1)
        self._samp_rate_st_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(0).GetWin(),
            value=self.samp_rate_st,
            callback=self.set_samp_rate_st,
            label="Sample rate",
            converter=forms.float_converter(),
        )
        self.rx_ntb.GetPage(0).GridAdd(self._samp_rate_st_static_text, 1, 4, 1,
                                       1)
        _pll_alpha_sl_sizer = wx.BoxSizer(wx.VERTICAL)
        self._pll_alpha_sl_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            sizer=_pll_alpha_sl_sizer,
            value=self.pll_alpha_sl,
            callback=self.set_pll_alpha_sl,
            label="PLL Alpha",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._pll_alpha_sl_slider = forms.slider(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            sizer=_pll_alpha_sl_sizer,
            value=self.pll_alpha_sl,
            callback=self.set_pll_alpha_sl,
            minimum=0.001,
            maximum=0.1,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.rx_ntb.GetPage(1).GridAdd(_pll_alpha_sl_sizer, 1, 0, 1, 1)
        self._gain_tb_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(0).GetWin(),
            value=self.gain_tb,
            callback=self.set_gain_tb,
            label="RX gain [dB]",
            converter=forms.int_converter(),
        )
        self.rx_ntb.GetPage(0).GridAdd(self._gain_tb_text_box, 1, 2, 1, 1)
        self._freq_tb_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(0).GetWin(),
            value=self.freq_tb,
            callback=self.set_freq_tb,
            label="Frequency",
            converter=forms.float_converter(),
        )
        self.rx_ntb.GetPage(0).GridAdd(self._freq_tb_text_box, 1, 1, 1, 1)
        self._frames_file_text_inf_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(4).GetWin(),
            value=self.frames_file_text_inf,
            callback=self.set_frames_file_text_inf,
            label="Frames filename",
            converter=forms.str_converter(),
        )
        self.rx_ntb.GetPage(4).GridAdd(self._frames_file_text_inf_static_text,
                                       3, 0, 1, 1)
        self._deframer_sync_after_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(3).GetWin(),
            value=self.deframer_sync_after_text,
            callback=self.set_deframer_sync_after_text,
            label="Deframe sync after",
            converter=forms.float_converter(),
        )
        self.rx_ntb.GetPage(3).GridAdd(
            self._deframer_sync_after_text_static_text, 3, 0, 1, 1)
        self._deframer_nosync_after_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(3).GetWin(),
            value=self.deframer_nosync_after_text,
            callback=self.set_deframer_nosync_after_text,
            label="Deframer out of sync after",
            converter=forms.float_converter(),
        )
        self.rx_ntb.GetPage(3).GridAdd(
            self._deframer_nosync_after_text_static_text, 4, 0, 1, 1)
        self._deframer_check_sync_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(3).GetWin(),
            value=self.deframer_check_sync_text,
            callback=self.set_deframer_check_sync_text,
            label="Deframer check sync enable",
            converter=forms.str_converter(),
        )
        self.rx_ntb.GetPage(3).GridAdd(
            self._deframer_check_sync_text_static_text, 2, 0, 1, 1)
        self._datetime_text_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(4).GetWin(),
            value=self.datetime_text,
            callback=self.set_datetime_text,
            label="Local time of aquisition start",
            converter=forms.str_converter(),
        )
        self.rx_ntb.GetPage(4).GridAdd(self._datetime_text_static_text, 1, 0,
                                       1, 1)
        _clock_alpha_sl_sizer = wx.BoxSizer(wx.VERTICAL)
        self._clock_alpha_sl_text_box = forms.text_box(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            sizer=_clock_alpha_sl_sizer,
            value=self.clock_alpha_sl,
            callback=self.set_clock_alpha_sl,
            label="Clock alpha",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._clock_alpha_sl_slider = forms.slider(
            parent=self.rx_ntb.GetPage(1).GetWin(),
            sizer=_clock_alpha_sl_sizer,
            value=self.clock_alpha_sl,
            callback=self.set_clock_alpha_sl,
            minimum=0.001,
            maximum=0.1,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.rx_ntb.GetPage(1).GridAdd(_clock_alpha_sl_sizer, 1, 1, 1, 1)
        self._baseband_file_text_inf_static_text = forms.static_text(
            parent=self.rx_ntb.GetPage(4).GetWin(),
            value=self.baseband_file_text_inf,
            callback=self.set_baseband_file_text_inf,
            label="Baseband filename",
            converter=forms.str_converter(),
        )
        self.rx_ntb.GetPage(4).GridAdd(
            self._baseband_file_text_inf_static_text, 4, 0, 1, 1)

        ##################################################
        # Blocks
        ##################################################
        self.fec_decode_viterbi_bpsk_fb_0 = fec.decode_viterbi_bpsk_fb(
            viterbi_sync_check, viterbi_sync_threshold, viterbi_insync_frames,
            viterbi_outsync_frames, viterbi_outsync_frames * 3)
        self.gr_agc_xx_0 = gr.agc_cc(10e-6, 1, 1.0 / 32767.0, 1.0)
        self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_cc(
            sps, clock_alpha_sl * clock_alpha_sl / 4.0, 0.5, clock_alpha_sl,
            0.05)
        self.gr_complex_to_real_0 = gr.complex_to_real(1)
        self.gr_costas_loop_cc_0 = gr.costas_loop_cc(
            pll_alpha_sl, pll_alpha_sl * pll_alpha_sl / 4.0, 0.07, -0.07, 2)
        self.gr_file_source_0 = gr.file_source(
            gr.sizeof_gr_complex * 1,
            "/home/martin/GNURadioData/lrit/goes_lrit_D108AD64MHz.sam", True)
        self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((1, ))
        self.gr_null_sink_0 = gr.null_sink(gr.sizeof_char * 1)
        self.gr_packed_to_unpacked_xx_0 = gr.packed_to_unpacked_bb(
            1, gr.GR_MSB_FIRST)
        self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex * 1, samp_rate)
        self.poesweather_metop_cadu_deframer_0 = poesweather.metop_cadu_deframer(
            True, 1024, deframer_insync_frames, deframer_outsync_frames)
        self.root_raised_cosine_filter_0 = gr.fir_filter_ccf(
            1,
            firdes.root_raised_cosine(1, samp_rate, symb_rate, 0.25,
                                      int(11 * samp_rate / symb_rate)))
        self.wxgui_fftsink1 = fftsink2.fft_sink_c(
            self.rx_ntb.GetPage(0).GetWin(),
            baseband_freq=freq,
            y_per_div=2,
            y_divs=10,
            ref_level=12,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=30,
            average=True,
            avg_alpha=0.1,
            title="Not filtered spectrum",
            peak_hold=False,
        )
        self.rx_ntb.GetPage(0).Add(self.wxgui_fftsink1.win)
        self.wxgui_fftsink2 = fftsink2.fft_sink_c(
            self.rx_ntb.GetPage(0).GetWin(),
            baseband_freq=0,
            y_per_div=2,
            y_divs=10,
            ref_level=12,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=30,
            average=True,
            avg_alpha=0.1,
            title="RRC filtered spectrum",
            peak_hold=False,
        )
        self.rx_ntb.GetPage(0).Add(self.wxgui_fftsink2.win)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_c(
            self.rx_ntb.GetPage(1).GetWin(),
            title="BPSK constellation diagram",
            sample_rate=symb_rate,
            v_scale=0.4,
            v_offset=0,
            t_scale=1 / samp_rate,
            ac_couple=False,
            xy_mode=True,
            num_inputs=1,
        )
        self.rx_ntb.GetPage(1).Add(self.wxgui_scopesink2_1.win)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.gr_agc_xx_0, 0),
                     (self.root_raised_cosine_filter_0, 0))
        self.connect((self.gr_multiply_const_vxx_0, 0),
                     (self.gr_complex_to_real_0, 0))
        self.connect((self.fec_decode_viterbi_bpsk_fb_0, 0),
                     (self.gr_packed_to_unpacked_xx_0, 0))
        self.connect((self.gr_packed_to_unpacked_xx_0, 0),
                     (self.poesweather_metop_cadu_deframer_0, 0))
        self.connect((self.gr_complex_to_real_0, 0),
                     (self.fec_decode_viterbi_bpsk_fb_0, 0))
        self.connect((self.gr_clock_recovery_mm_xx_0, 0),
                     (self.gr_multiply_const_vxx_0, 0))
        self.connect((self.gr_costas_loop_cc_0, 0),
                     (self.gr_clock_recovery_mm_xx_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.gr_costas_loop_cc_0, 0))
        self.connect((self.gr_multiply_const_vxx_0, 0),
                     (self.wxgui_scopesink2_1, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.wxgui_fftsink2, 0))
        self.connect((self.gr_agc_xx_0, 0), (self.wxgui_fftsink1, 0))
        self.connect((self.poesweather_metop_cadu_deframer_0, 0),
                     (self.gr_null_sink_0, 0))
        self.connect((self.gr_throttle_0, 0), (self.gr_agc_xx_0, 0))
        self.connect((self.gr_file_source_0, 0), (self.gr_throttle_0, 0))
Example #48
0
    def __init__(self,
                 default_bandwidth=1e6,
                 default_baud=450000,
                 default_bin_file_sink="/tmp/rx_data.bin",
                 default_freq=2410e6,
                 default_gain=1,
                 default_ip_0='127.0.0.1',
                 default_port_0=5000,
                 default_samp=1000000,
                 sdr_dev="uhd=0"):
        grc_wxgui.top_block_gui.__init__(self, title="GFSK Receiver")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Parameters
        ##################################################
        self.default_bandwidth = default_bandwidth
        self.default_baud = default_baud
        self.default_bin_file_sink = default_bin_file_sink
        self.default_freq = default_freq
        self.default_gain = default_gain
        self.default_ip_0 = default_ip_0
        self.default_port_0 = default_port_0
        self.default_samp = default_samp
        self.sdr_dev = sdr_dev

        ##################################################
        # Variables
        ##################################################
        self.sdr_rf_gain = sdr_rf_gain = 10
        self.sdr_if_gain = sdr_if_gain = 20
        self.sdr_bb_gain = sdr_bb_gain = 20
        self.samp_rate = samp_rate = default_samp
        self.freq = freq = default_freq
        self.baudrate = baudrate = default_baud
        self.bandwidth = bandwidth = default_bandwidth

        ##################################################
        # Blocks
        ##################################################
        _samp_rate_sizer = wx.BoxSizer(wx.VERTICAL)
        self._samp_rate_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_samp_rate_sizer,
            value=self.samp_rate,
            callback=self.set_samp_rate,
            label='Sample rate [S/s]',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._samp_rate_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_samp_rate_sizer,
            value=self.samp_rate,
            callback=self.set_samp_rate,
            minimum=100e3,
            maximum=4e6,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.GridAdd(_samp_rate_sizer, 1, 1, 1, 1)
        _freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freq_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_freq_sizer,
            value=self.freq,
            callback=self.set_freq,
            label='Frequency [Hz]',
            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=2400e6,
            maximum=2515e6,
            num_steps=115,
            style=wx.SL_VERTICAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_freq_sizer, 0, 1, 1, 1)
        _bandwidth_sizer = wx.BoxSizer(wx.VERTICAL)
        self._bandwidth_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_bandwidth_sizer,
            value=self.bandwidth,
            callback=self.set_bandwidth,
            label='Bandwidth [Hz]',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._bandwidth_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_bandwidth_sizer,
            value=self.bandwidth,
            callback=self.set_bandwidth,
            minimum=0,
            maximum=10e6,
            num_steps=60,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_bandwidth_sizer, 5, 1, 1, 1)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=default_freq,
            y_per_div=10,
            y_divs=9,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=default_samp,
            fft_size=1024,
            fft_rate=15,
            average=True,
            avg_alpha=0.5,
            title='',
            peak_hold=False,
            win=window.hanning,
            size=([800, 100]),
        )
        self.GridAdd(self.wxgui_fftsink2_0.win, 0, 0, 7, 1)
        self.uhd_usrp_source_0_0 = uhd.usrp_source(
            ",".join(("serial=307038D", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0.set_center_freq(freq, 0)
        self.uhd_usrp_source_0_0.set_gain(0, 0)
        self.uhd_usrp_source_0_0.set_bandwidth(bandwidth, 0)
        _sdr_rf_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._sdr_rf_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_sdr_rf_gain_sizer,
            value=self.sdr_rf_gain,
            callback=self.set_sdr_rf_gain,
            label='RF gain [dB]',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._sdr_rf_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_sdr_rf_gain_sizer,
            value=self.sdr_rf_gain,
            callback=self.set_sdr_rf_gain,
            minimum=0,
            maximum=20,
            num_steps=20,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.GridAdd(_sdr_rf_gain_sizer, 2, 1, 1, 1)
        _sdr_if_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._sdr_if_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_sdr_if_gain_sizer,
            value=self.sdr_if_gain,
            callback=self.set_sdr_if_gain,
            label='IF gain [dB]',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._sdr_if_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_sdr_if_gain_sizer,
            value=self.sdr_if_gain,
            callback=self.set_sdr_if_gain,
            minimum=0,
            maximum=30,
            num_steps=30,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.GridAdd(_sdr_if_gain_sizer, 3, 1, 1, 1)
        _sdr_bb_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._sdr_bb_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_sdr_bb_gain_sizer,
            value=self.sdr_bb_gain,
            callback=self.set_sdr_bb_gain,
            label='BB gain [dB]',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._sdr_bb_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_sdr_bb_gain_sizer,
            value=self.sdr_bb_gain,
            callback=self.set_sdr_bb_gain,
            minimum=0,
            maximum=30,
            num_steps=30,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.GridAdd(_sdr_bb_gain_sizer, 4, 1, 1, 1)
        self._baudrate_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.baudrate,
            callback=self.set_baudrate,
            label='Baudrate [bps]',
            converter=forms.int_converter(),
        )
        self.GridAdd(self._baudrate_text_box, 6, 1, 1, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.uhd_usrp_source_0_0, 0), (self.wxgui_fftsink2_0, 0))
Example #49
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="FM Receiver")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.volume = volume = 0
        self.tuner = tuner = 93.9e6
        self.samp_rate = samp_rate = 2e6
        self.rfgain = rfgain = 15
        self.down_rate = down_rate = 250e3

        ##################################################
        # 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=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_volume_sizer, 1, 5, 1, 8)
        self._tuner_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.tuner,
            callback=self.set_tuner,
            label='Station Select',
            choices=[93.9e6, 91.5e6, 97.9e6, 93.1e6],
            labels=["Hip-Hop", "Classical", "Rock", "Country"],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._tuner_chooser)
        _rfgain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rfgain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rfgain_sizer,
            value=self.rfgain,
            callback=self.set_rfgain,
            label='RF Gain',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._rfgain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rfgain_sizer,
            value=self.rfgain,
            callback=self.set_rfgain,
            minimum=10,
            maximum=70,
            num_steps=12,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.GridAdd(_rfgain_sizer, 1, 0, 1, 4)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=tuner,
            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='Sampling Bandpass',
            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(tuner, 0)
        self.rtlsdr_source_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(2, 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(rfgain, 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_0 = filter.rational_resampler_fff(
            interpolation=24,
            decimation=250,
            taps=None,
            fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            int(samp_rate / down_rate),
            firdes.low_pass(2, samp_rate, 100e3, 10e3, firdes.WIN_KAISER,
                            6.76))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (volume / 100, ))
        self.audio_sink_0 = audio.sink(24000, '', True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=down_rate,
            audio_decimation=1,
        )
        self.Demod_Out = 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=down_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='Demod Out',
            peak_hold=False,
        )
        self.Add(self.Demod_Out.win)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_wfm_rcv_0, 0), (self.Demod_Out, 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.audio_sink_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.blocks_multiply_const_vxx_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0, 0))
Example #50
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Nrf")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 4000000
        self.ch = ch = 25
        self.rf_gain = rf_gain = 0
        self.if_gain = if_gain = 20
        self.fsk_deviation_hz = fsk_deviation_hz = 170000
        self.freq_offset = freq_offset = -0
        self.fc = fc = 2399000000+ch*1000000
        self.bw = bw = samp_rate
        self.bitrate = bitrate = 250000
        self.bb_gain = bb_gain = 30

        ##################################################
        # Blocks
        ##################################################
        _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=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_rf_gain_sizer)
        _if_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._if_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_if_gain_sizer,
        	value=self.if_gain,
        	callback=self.set_if_gain,
        	label='if_gain',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._if_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_if_gain_sizer,
        	value=self.if_gain,
        	callback=self.set_if_gain,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_if_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=-1,
        	maximum=1,
        	num_steps=200,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_freq_offset_sizer)
        _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='bb_gain',
        	converter=forms.int_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=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_bb_gain_sizer)
        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=True,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.osmosdr_source_0_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_source_0_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0_0.set_center_freq(fc, 0)
        self.osmosdr_source_0_0.set_freq_corr(0, 0)
        self.osmosdr_source_0_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0_0.set_gain_mode(True, 0)
        self.osmosdr_source_0_0.set_gain(rf_gain, 0)
        self.osmosdr_source_0_0.set_if_gain(if_gain, 0)
        self.osmosdr_source_0_0.set_bb_gain(bb_gain, 0)
        self.osmosdr_source_0_0.set_antenna("", 0)
        self.osmosdr_source_0_0.set_bandwidth(samp_rate, 0)
          
        self.low_pass_filter_0_0 = filter.fir_filter_fff(samp_rate/bitrate, firdes.low_pass(
        	1, samp_rate, bitrate, bitrate/2, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, samp_rate, 2000000, 1000000, firdes.WIN_HAMMING, 6.76))
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        _ch_sizer = wx.BoxSizer(wx.VERTICAL)
        self._ch_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_ch_sizer,
        	value=self.ch,
        	callback=self.set_ch,
        	label='ch',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._ch_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_ch_sizer,
        	value=self.ch,
        	callback=self.set_ch,
        	minimum=0,
        	maximum=128,
        	num_steps=128,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_ch_sizer)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, "/opt/nrf_analyzer/fifo", False)
        self.blocks_file_sink_0_0.set_unbuffered(False)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((freq_offset, ))
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -1000000, 1, 0)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_0_0, 0))    
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.blocks_add_const_vxx_0, 0), (self.digital_binary_slicer_fb_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_file_sink_0_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.low_pass_filter_0_0, 0), (self.blocks_add_const_vxx_0, 0))    
        self.connect((self.osmosdr_source_0_0, 0), (self.blocks_multiply_xx_0, 0))    
Example #51
0
	def __init__(self, side="A", gain=35, decim=32, sync_check=False, satellite='METEOR-M-1', frames_file=os.environ['HOME'] + '/METEOR-M-1.hrpt', freq=1700e6):
		grc_wxgui.top_block_gui.__init__(self, title="USRP NOAA HRPT Receiver")
		_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
		self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

		##################################################
		# Parameters
		##################################################
		self.side = side
		self.gain = gain
		self.decim = decim
		self.sync_check = sync_check
		self.satellite = satellite
		self.frames_file = frames_file
		self.freq = freq

		##################################################
		# Variables
		##################################################
		self.sym_rate = sym_rate = 600*1109
		self.samp_rate = samp_rate = 64e6/decim
		self.config_filename = config_filename = os.environ['HOME']+'/.gnuradio/mn1_hrpt.conf'
		self.sps = sps = samp_rate/sym_rate
		self._saved_pll_alpha_config = ConfigParser.ConfigParser()
		self._saved_pll_alpha_config.read(config_filename)
		try: saved_pll_alpha = self._saved_pll_alpha_config.getfloat("satname", 'pll_alpha')
		except: saved_pll_alpha = 0.005
		self.saved_pll_alpha = saved_pll_alpha
		self._saved_clock_alpha_config = ConfigParser.ConfigParser()
		self._saved_clock_alpha_config.read(config_filename)
		try: saved_clock_alpha = self._saved_clock_alpha_config.getfloat("satname", 'clock_alpha')
		except: saved_clock_alpha = 0.001
		self.saved_clock_alpha = saved_clock_alpha
		self.sync_check_txt = sync_check_txt = sync_check
		self.side_text = side_text = side
		self._saved_gain_config = ConfigParser.ConfigParser()
		self._saved_gain_config.read(config_filename)
		try: saved_gain = self._saved_gain_config.getfloat("satname", 'gain')
		except: saved_gain = gain
		self.saved_gain = saved_gain
		self.satellite_text = satellite_text = satellite
		self.sample_rate_text = sample_rate_text = samp_rate
		self.pll_alpha = pll_alpha = saved_pll_alpha
		self.max_clock_offset = max_clock_offset = 0.1
		self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/samp_rate
		self.hs = hs = int(sps/2.0)
		self.gain_slider = gain_slider = gain
		self.freq_tb = freq_tb = freq
		self.frames_outfile_text = frames_outfile_text = frames_file
		self.decim_tb = decim_tb = decim
		self.datetime_text = datetime_text = strftime("%A, %B %d %Y %H:%M:%S", localtime())
		self.clock_alpha = clock_alpha = saved_clock_alpha

		##################################################
		# Notebooks
		##################################################
		self.displays = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
		self.displays.AddPage(grc_wxgui.Panel(self.displays), "RX Meteor M N1 HRPT")
		self.displays.AddPage(grc_wxgui.Panel(self.displays), "Information")
		self.Add(self.displays)

		##################################################
		# Controls
		##################################################
		self._sync_check_txt_static_text = forms.static_text(
			parent=self.GetWin(),
			value=self.sync_check_txt,
			callback=self.set_sync_check_txt,
			label="Sync check",
			converter=forms.float_converter(),
		)
		self.GridAdd(self._sync_check_txt_static_text, 0, 2, 1, 1)
		self._side_text_static_text = forms.static_text(
			parent=self.GetWin(),
			value=self.side_text,
			callback=self.set_side_text,
			label="USRP Side",
			converter=forms.str_converter(),
		)
		self.GridAdd(self._side_text_static_text, 0, 0, 1, 1)
		self._satellite_text_static_text = forms.static_text(
			parent=self.GetWin(),
			value=self.satellite_text,
			callback=self.set_satellite_text,
			label="Satellite",
			converter=forms.str_converter(),
		)
		self.GridAdd(self._satellite_text_static_text, 0, 1, 1, 1)
		self._sample_rate_text_static_text = forms.static_text(
			parent=self.displays.GetPage(1).GetWin(),
			value=self.sample_rate_text,
			callback=self.set_sample_rate_text,
			label="Sample rate",
			converter=forms.float_converter(),
		)
		self.displays.GetPage(1).GridAdd(self._sample_rate_text_static_text, 3, 0, 1, 1)
		_pll_alpha_sizer = wx.BoxSizer(wx.VERTICAL)
		self._pll_alpha_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_pll_alpha_sizer,
			value=self.pll_alpha,
			callback=self.set_pll_alpha,
			label="PLL Alpha",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._pll_alpha_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_pll_alpha_sizer,
			value=self.pll_alpha,
			callback=self.set_pll_alpha,
			minimum=0.005,
			maximum=0.5,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_pll_alpha_sizer, 2, 1, 1, 1)
		_gain_slider_sizer = wx.BoxSizer(wx.VERTICAL)
		self._gain_slider_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_gain_slider_sizer,
			value=self.gain_slider,
			callback=self.set_gain_slider,
			label="Gain",
			converter=forms.int_converter(),
			proportion=0,
		)
		self._gain_slider_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_gain_slider_sizer,
			value=self.gain_slider,
			callback=self.set_gain_slider,
			minimum=0,
			maximum=100,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=int,
			proportion=1,
		)
		self.GridAdd(_gain_slider_sizer, 2, 0, 1, 1)
		self._freq_tb_text_box = forms.text_box(
			parent=self.GetWin(),
			value=self.freq_tb,
			callback=self.set_freq_tb,
			label="Frequency",
			converter=forms.float_converter(),
		)
		self.GridAdd(self._freq_tb_text_box, 1, 1, 1, 1)
		self._frames_outfile_text_static_text = forms.static_text(
			parent=self.displays.GetPage(1).GetWin(),
			value=self.frames_outfile_text,
			callback=self.set_frames_outfile_text,
			label="Frames filename",
			converter=forms.str_converter(),
		)
		self.displays.GetPage(1).GridAdd(self._frames_outfile_text_static_text, 4, 0, 1, 1)
		self._decim_tb_text_box = forms.text_box(
			parent=self.GetWin(),
			value=self.decim_tb,
			callback=self.set_decim_tb,
			label="Decimation",
			converter=forms.int_converter(),
		)
		self.GridAdd(self._decim_tb_text_box, 1, 0, 1, 1)
		self._datetime_text_static_text = forms.static_text(
			parent=self.displays.GetPage(1).GetWin(),
			value=self.datetime_text,
			callback=self.set_datetime_text,
			label="Acquisition start",
			converter=forms.str_converter(),
		)
		self.displays.GetPage(1).GridAdd(self._datetime_text_static_text, 2, 0, 1, 1)
		_clock_alpha_sizer = wx.BoxSizer(wx.VERTICAL)
		self._clock_alpha_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_clock_alpha_sizer,
			value=self.clock_alpha,
			callback=self.set_clock_alpha,
			label="Clock alpha",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._clock_alpha_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_clock_alpha_sizer,
			value=self.clock_alpha,
			callback=self.set_clock_alpha,
			minimum=0.001,
			maximum=0.1,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.GridAdd(_clock_alpha_sizer, 2, 2, 1, 1)

		##################################################
		# Blocks
		##################################################
		self.agc = gr.agc_cc(1e-5, 1.0, 1.0/32768.0, 1.0)
		self.gr_binary_slicer_fb_0 = gr.binary_slicer_fb()
		self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_ff(sps/2.0, clock_alpha**2/4.0, 0.5, clock_alpha, max_clock_offset)
		self.gr_file_sink_0_0 = gr.file_sink(gr.sizeof_short*1, frames_file)
		self.gr_file_sink_0_0.set_unbuffered(False)
		self.gr_interleaved_short_to_complex_0 = gr.interleaved_short_to_complex()
		self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000)
		self.gr_rms_xx_0 = gr.rms_cf(0.2)
		self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset)
		self.poesweather_mn1_hrpt_deframer_0 = poesweather.mn1_hrpt_deframer(sync_check)
		self.usrp_simple_source_x_0 = grc_usrp.simple_source_s(which=0, side=side, rx_ant="RXA")
		self.usrp_simple_source_x_0.set_decim_rate(decim)
		self.usrp_simple_source_x_0.set_frequency(freq, verbose=True)
		self.usrp_simple_source_x_0.set_gain(gain)
		self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
			self.displays.GetPage(0).GetWin(),
			baseband_freq=0,
			y_per_div=5,
			y_divs=10,
			ref_level=45,
			ref_scale=2.0,
			sample_rate=samp_rate,
			fft_size=1024,
			fft_rate=30,
			average=True,
			avg_alpha=0.1,
			title="Meteor M N1 HRPT FFT Spectrum",
			peak_hold=False,
		)
		self.displays.GetPage(0).Add(self.wxgui_fftsink2_0.win)
		self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
			self.GetWin(),
			unit="Units",
			minval=0,
			maxval=5000,
			factor=1.0,
			decimal_places=4,
			ref_level=0,
			sample_rate=samp_rate,
			number_rate=15,
			average=True,
			avg_alpha=0.07,
			label="S-Meter",
			peak_hold=False,
			show_gauge=True,
		)
		self.Add(self.wxgui_numbersink2_0.win)

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_binary_slicer_fb_0, 0), (self.poesweather_mn1_hrpt_deframer_0, 0))
		self.connect((self.usrp_simple_source_x_0, 0), (self.gr_interleaved_short_to_complex_0, 0))
		self.connect((self.gr_interleaved_short_to_complex_0, 0), (self.agc, 0))
		self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 0))
		self.connect((self.agc, 0), (self.pll, 0))
		self.connect((self.pll, 0), (self.gr_moving_average_xx_0, 0))
		self.connect((self.gr_moving_average_xx_0, 0), (self.gr_clock_recovery_mm_xx_0, 0))
		self.connect((self.gr_interleaved_short_to_complex_0, 0), (self.wxgui_fftsink2_0, 0))
		self.connect((self.gr_interleaved_short_to_complex_0, 0), (self.gr_rms_xx_0, 0))
		self.connect((self.gr_rms_xx_0, 0), (self.wxgui_numbersink2_0, 0))
		self.connect((self.poesweather_mn1_hrpt_deframer_0, 0), (self.gr_file_sink_0_0, 0))
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Wifi Loopback Ah")

        ##################################################
        # Variables
        ##################################################
        self.snr = snr = 20
        self.pdu_length = pdu_length = 500
        self.out_buf_size = out_buf_size = 96000
        self.interval = interval = 100
        self.encoding = encoding = 0
        self.chan_est = chan_est = 1

        ##################################################
        # Blocks
        ##################################################
        _snr_sizer = wx.BoxSizer(wx.VERTICAL)
        self._snr_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_snr_sizer,
            value=self.snr,
            callback=self.set_snr,
            label='snr',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._snr_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_snr_sizer,
            value=self.snr,
            callback=self.set_snr,
            minimum=-15,
            maximum=30,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_snr_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)
        _interval_sizer = wx.BoxSizer(wx.VERTICAL)
        self._interval_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_interval_sizer,
            value=self.interval,
            callback=self.set_interval,
            label="PDU Interval (ms)",
            converter=forms.int_converter(),
            proportion=0,
        )
        self._interval_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_interval_sizer,
            value=self.interval,
            callback=self.set_interval,
            minimum=10,
            maximum=1000,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_interval_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, 8],
            labels=[
                "BPSK 1/2", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4",
                "64QAM 2/3", "64QAM 3/4", "64QAM 5/6", "256QAM 3/4"
            ],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._encoding_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_c(
            self.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.Add(self.wxgui_scopesink2_0.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.wifi_phy_hier_ah_0 = wifi_phy_hier_ah(
            chan_est=chan_est,
            encoding=encoding,
            sensitivity=0.56,
        )
        self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(
            False, True)
        self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(
            ([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]),
            ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]),
            ([0xff, 0xff, 0xff, 0xff, 0xff, 0xff]))
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 500, 0)
        (self.foo_packet_pad2_0).set_min_output_buffer(96000)
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=1,
            frequency_offset=0,
            epsilon=1.0,
            taps=(1.0, ),
            noise_seed=0,
            block_tags=False)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(
            blocks.float_t, "packet_len")
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(
            ((10**(snr / 10.0))**.5, ))
        self.blocks_message_strobe_0 = blocks.message_strobe(
            pmt.intern("".join("x" for i in range(pdu_length))), interval)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'),
                         (self.ieee802_11_ofdm_mac_0, 'app in'))
        self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'),
                         (self.wifi_phy_hier_ah_0, 'mac_in'))
        self.msg_connect((self.ieee802_11_ofdm_parse_mac_0, 'fer'),
                         (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.msg_connect((self.wifi_phy_hier_ah_0, 'mac_out'),
                         (self.ieee802_11_ofdm_parse_mac_0, 'in'))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0),
                     (self.wxgui_numbersink2_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.wifi_phy_hier_ah_0, 0))
        self.connect((self.foo_packet_pad2_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.wifi_phy_hier_ah_0, 0), (self.foo_packet_pad2_0, 0))
        self.connect((self.wifi_phy_hier_ah_0, 1),
                     (self.wxgui_scopesink2_0, 0))
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Pager 6Ch Decode")
        _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 = 2000000
        self.xlate_decimation = xlate_decimation = 40
        self.hunter_freq_5 = hunter_freq_5 = 0
        self.hunter_freq_4 = hunter_freq_4 = 0
        self.hunter_freq_3 = hunter_freq_3 = 0
        self.hunter_freq_2 = hunter_freq_2 = 0
        self.hunter_freq_1 = hunter_freq_1 = 0
        self.hunter_freq_0 = hunter_freq_0 = 0
        self.gain = gain = 10
        self.frequency = frequency = 929000000
        self.filter_width = filter_width = 5120
        self.fft_taps = fft_taps = filter.firdes.low_pass_2(1, samp_rate, 2000, 1000, 0.1)
        self.fft_n_elements = fft_n_elements = 2048

        ##################################################
        # Blocks
        ##################################################
        _hunter_freq_5_sizer = wx.BoxSizer(wx.VERTICAL)
        self._hunter_freq_5_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_hunter_freq_5_sizer,
        	value=self.hunter_freq_5,
        	callback=self.set_hunter_freq_5,
        	label='hunter_freq_5',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._hunter_freq_5_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_hunter_freq_5_sizer,
        	value=self.hunter_freq_5,
        	callback=self.set_hunter_freq_5,
        	minimum=-1000000,
        	maximum=1000000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_hunter_freq_5_sizer)
        _hunter_freq_4_sizer = wx.BoxSizer(wx.VERTICAL)
        self._hunter_freq_4_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_hunter_freq_4_sizer,
        	value=self.hunter_freq_4,
        	callback=self.set_hunter_freq_4,
        	label='hunter_freq_4',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._hunter_freq_4_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_hunter_freq_4_sizer,
        	value=self.hunter_freq_4,
        	callback=self.set_hunter_freq_4,
        	minimum=-1000000,
        	maximum=1000000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_hunter_freq_4_sizer)
        _hunter_freq_3_sizer = wx.BoxSizer(wx.VERTICAL)
        self._hunter_freq_3_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_hunter_freq_3_sizer,
        	value=self.hunter_freq_3,
        	callback=self.set_hunter_freq_3,
        	label='hunter_freq_3',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._hunter_freq_3_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_hunter_freq_3_sizer,
        	value=self.hunter_freq_3,
        	callback=self.set_hunter_freq_3,
        	minimum=-1000000,
        	maximum=1000000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_hunter_freq_3_sizer)
        _hunter_freq_2_sizer = wx.BoxSizer(wx.VERTICAL)
        self._hunter_freq_2_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_hunter_freq_2_sizer,
        	value=self.hunter_freq_2,
        	callback=self.set_hunter_freq_2,
        	label='hunter_freq_2',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._hunter_freq_2_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_hunter_freq_2_sizer,
        	value=self.hunter_freq_2,
        	callback=self.set_hunter_freq_2,
        	minimum=-1000000,
        	maximum=1000000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_hunter_freq_2_sizer)
        _hunter_freq_1_sizer = wx.BoxSizer(wx.VERTICAL)
        self._hunter_freq_1_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_hunter_freq_1_sizer,
        	value=self.hunter_freq_1,
        	callback=self.set_hunter_freq_1,
        	label='hunter_freq_1',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._hunter_freq_1_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_hunter_freq_1_sizer,
        	value=self.hunter_freq_1,
        	callback=self.set_hunter_freq_1,
        	minimum=-1000000,
        	maximum=1000000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_hunter_freq_1_sizer)
        _hunter_freq_0_sizer = wx.BoxSizer(wx.VERTICAL)
        self._hunter_freq_0_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_hunter_freq_0_sizer,
        	value=self.hunter_freq_0,
        	callback=self.set_hunter_freq_0,
        	label='hunter_freq_0',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._hunter_freq_0_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_hunter_freq_0_sizer,
        	value=self.hunter_freq_0,
        	callback=self.set_hunter_freq_0,
        	minimum=-1000000,
        	maximum=1000000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_hunter_freq_0_sizer)
        _frequency_sizer = wx.BoxSizer(wx.VERTICAL)
        self._frequency_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_frequency_sizer,
        	value=self.frequency,
        	callback=self.set_frequency,
        	label='Frequency',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._frequency_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_frequency_sizer,
        	value=self.frequency,
        	callback=self.set_frequency,
        	minimum=80000000,
        	maximum=1100000000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_frequency_sizer)
        self.zeromq_push_sink_0_0 = zeromq.push_sink(gr.sizeof_float, fft_n_elements, 'tcp://127.0.0.1:9000', 100, False, -1)
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(('localhost', 8080), allow_none=True)
        self.xmlrpc_server_0.register_instance(self)
        self.xmlrpc_server_0_thread = threading.Thread(target=self.xmlrpc_server_0.serve_forever)
        self.xmlrpc_server_0_thread.daemon = True
        self.xmlrpc_server_0_thread.start()
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=frequency,
        	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='master_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(frequency, 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)
          
        _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=50,
        	num_steps=50,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_gain_sizer)
        self.freq_xlating_fft_filter_ccc_0_0_3 = filter.freq_xlating_fft_filter_ccc(xlate_decimation, (fft_taps), frequency + hunter_freq_5, samp_rate)
        self.freq_xlating_fft_filter_ccc_0_0_3.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0_0_3.declare_sample_delay(0)
        self.freq_xlating_fft_filter_ccc_0_0_2 = filter.freq_xlating_fft_filter_ccc(xlate_decimation, (fft_taps), frequency + hunter_freq_4, samp_rate)
        self.freq_xlating_fft_filter_ccc_0_0_2.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0_0_2.declare_sample_delay(0)
        self.freq_xlating_fft_filter_ccc_0_0_1 = filter.freq_xlating_fft_filter_ccc(xlate_decimation, (fft_taps), frequency + hunter_freq_3, samp_rate)
        self.freq_xlating_fft_filter_ccc_0_0_1.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0_0_1.declare_sample_delay(0)
        self.freq_xlating_fft_filter_ccc_0_0_0 = filter.freq_xlating_fft_filter_ccc(xlate_decimation, (fft_taps), frequency + hunter_freq_2, 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(xlate_decimation, (fft_taps), frequency + hunter_freq_1, 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(xlate_decimation, (fft_taps), frequency + hunter_freq_0, samp_rate)
        self.freq_xlating_fft_filter_ccc_0.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0)
        _filter_width_sizer = wx.BoxSizer(wx.VERTICAL)
        self._filter_width_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_filter_width_sizer,
        	value=self.filter_width,
        	callback=self.set_filter_width,
        	label='filter_width',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._filter_width_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_filter_width_sizer,
        	value=self.filter_width,
        	callback=self.set_filter_width,
        	minimum=2048,
        	maximum=40960,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_filter_width_sizer)
        self.fft_vxx_0 = fft.fft_vcc(fft_n_elements, True, (window.blackmanharris(fft_n_elements)), True, 1)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, fft_n_elements)
        self.blocks_stream_to_vector_1 = blocks.stream_to_vector(gr.sizeof_float*1, fft_n_elements)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_n_elements)
        self.blocks_null_sink_0_0_3 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_null_sink_0_0_2 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_null_sink_0_0_1 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_null_sink_0_0_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_stream_to_vector_1, 0))    
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))    
        self.connect((self.blocks_stream_to_vector_1, 0), (self.zeromq_push_sink_0_0, 0))    
        self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0, 0))    
        self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.blocks_null_sink_0, 0))    
        self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.blocks_null_sink_0_0, 0))    
        self.connect((self.freq_xlating_fft_filter_ccc_0_0_0, 0), (self.blocks_null_sink_0_0_0, 0))    
        self.connect((self.freq_xlating_fft_filter_ccc_0_0_1, 0), (self.blocks_null_sink_0_0_1, 0))    
        self.connect((self.freq_xlating_fft_filter_ccc_0_0_2, 0), (self.blocks_null_sink_0_0_2, 0))    
        self.connect((self.freq_xlating_fft_filter_ccc_0_0_3, 0), (self.blocks_null_sink_0_0_3, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.blocks_stream_to_vector_0, 0))    
        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.freq_xlating_fft_filter_ccc_0_0_1, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0_2, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0_3, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0, 0))    
	def __init__(self, pll_alpha=0.005, satellite='NOAA18', decim=50, gain=25, clock_alpha=0.005, freq=1707e6, deframer_sync_check=True, deframer_insync_frames=2, deframer_outsync_frames=5, symb_rate=600*1109, baseband_file=os.environ['HOME'] + '/noaa_hrpt_baseband.dat', frames_file=os.environ['HOME'] + '/noaa_hrpt_frames.hmf'):
		grc_wxgui.top_block_gui.__init__(self, title="USRP2 NOAA HRPT Receiver")
		_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
		self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

		##################################################
		# Parameters
		##################################################
		self.pll_alpha = pll_alpha
		self.satellite = satellite
		self.decim = decim
		self.gain = gain
		self.clock_alpha = clock_alpha
		self.freq = freq
		self.deframer_sync_check = deframer_sync_check
		self.deframer_insync_frames = deframer_insync_frames
		self.deframer_outsync_frames = deframer_outsync_frames
		self.symb_rate = symb_rate
		self.baseband_file = baseband_file
		self.frames_file = frames_file

		##################################################
		# Variables
		##################################################
		self.decim_tb = decim_tb = decim
		self.symb_rate_tb = symb_rate_tb = symb_rate
		self.samp_rate = samp_rate = 100e6/decim_tb
		self.sps = sps = samp_rate/symb_rate_tb
		self.satellite_text = satellite_text = satellite
		self.samp_rate_st = samp_rate_st = samp_rate
		self.pll_alpha_sl = pll_alpha_sl = pll_alpha
		self.max_clock_offset = max_clock_offset = 0.1
		self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/samp_rate
		self.hs = hs = int(sps/2.0)
		self.gain_tb = gain_tb = gain
		self.freq_tb = freq_tb = freq
		self.frames_file_text_inf = frames_file_text_inf = frames_file
		self.deframer_sync_after_text = deframer_sync_after_text = deframer_insync_frames
		self.deframer_nosync_after_text = deframer_nosync_after_text = deframer_outsync_frames
		self.deframer_check_sync_text = deframer_check_sync_text = deframer_sync_check
		self.datetime_text = datetime_text = strftime("%A, %B %d %Y %H:%M:%S", localtime())
		self.clock_alpha_sl = clock_alpha_sl = clock_alpha
		self.baseband_file_text_inf = baseband_file_text_inf = baseband_file

		##################################################
		# Notebooks
		##################################################
		self.rx_ntb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
		self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "USRP Receiver")
		self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "PLL demodulator and Clock sync")
		self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Deframer")
		self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Output")
		self.Add(self.rx_ntb)

		##################################################
		# Controls
		##################################################
		self._decim_tb_text_box = forms.text_box(
			parent=self.rx_ntb.GetPage(0).GetWin(),
			value=self.decim_tb,
			callback=self.set_decim_tb,
			label="Decimation",
			converter=forms.int_converter(),
		)
		self.rx_ntb.GetPage(0).GridAdd(self._decim_tb_text_box, 1, 3, 1, 1)
		self._symb_rate_tb_text_box = forms.text_box(
			parent=self.rx_ntb.GetPage(1).GetWin(),
			value=self.symb_rate_tb,
			callback=self.set_symb_rate_tb,
			label="Symbol rate",
			converter=forms.int_converter(),
		)
		self.rx_ntb.GetPage(1).GridAdd(self._symb_rate_tb_text_box, 2, 1, 1, 1)
		self._satellite_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(0).GetWin(),
			value=self.satellite_text,
			callback=self.set_satellite_text,
			label="Sat ",
			converter=forms.str_converter(),
		)
		self.rx_ntb.GetPage(0).GridAdd(self._satellite_text_static_text, 1, 0, 1, 1)
		self._samp_rate_st_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(0).GetWin(),
			value=self.samp_rate_st,
			callback=self.set_samp_rate_st,
			label="Sample rate",
			converter=forms.float_converter(),
		)
		self.rx_ntb.GetPage(0).GridAdd(self._samp_rate_st_static_text, 1, 4, 1, 1)
		_pll_alpha_sl_sizer = wx.BoxSizer(wx.VERTICAL)
		self._pll_alpha_sl_text_box = forms.text_box(
			parent=self.rx_ntb.GetPage(1).GetWin(),
			sizer=_pll_alpha_sl_sizer,
			value=self.pll_alpha_sl,
			callback=self.set_pll_alpha_sl,
			label="PLL Alpha",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._pll_alpha_sl_slider = forms.slider(
			parent=self.rx_ntb.GetPage(1).GetWin(),
			sizer=_pll_alpha_sl_sizer,
			value=self.pll_alpha_sl,
			callback=self.set_pll_alpha_sl,
			minimum=0.001,
			maximum=0.1,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.rx_ntb.GetPage(1).GridAdd(_pll_alpha_sl_sizer, 1, 0, 1, 1)
		self._gain_tb_text_box = forms.text_box(
			parent=self.rx_ntb.GetPage(0).GetWin(),
			value=self.gain_tb,
			callback=self.set_gain_tb,
			label="RX gain [dB]",
			converter=forms.int_converter(),
		)
		self.rx_ntb.GetPage(0).GridAdd(self._gain_tb_text_box, 1, 2, 1, 1)
		self._freq_tb_text_box = forms.text_box(
			parent=self.rx_ntb.GetPage(0).GetWin(),
			value=self.freq_tb,
			callback=self.set_freq_tb,
			label="Frequency",
			converter=forms.float_converter(),
		)
		self.rx_ntb.GetPage(0).GridAdd(self._freq_tb_text_box, 1, 1, 1, 1)
		self._frames_file_text_inf_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(3).GetWin(),
			value=self.frames_file_text_inf,
			callback=self.set_frames_file_text_inf,
			label="Frames filename",
			converter=forms.str_converter(),
		)
		self.rx_ntb.GetPage(3).GridAdd(self._frames_file_text_inf_static_text, 3, 0, 1, 1)
		self._deframer_sync_after_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(2).GetWin(),
			value=self.deframer_sync_after_text,
			callback=self.set_deframer_sync_after_text,
			label="Deframe sync after",
			converter=forms.float_converter(),
		)
		self.rx_ntb.GetPage(2).GridAdd(self._deframer_sync_after_text_static_text, 3, 0, 1, 1)
		self._deframer_nosync_after_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(2).GetWin(),
			value=self.deframer_nosync_after_text,
			callback=self.set_deframer_nosync_after_text,
			label="Deframer out of sync after",
			converter=forms.float_converter(),
		)
		self.rx_ntb.GetPage(2).GridAdd(self._deframer_nosync_after_text_static_text, 4, 0, 1, 1)
		self._deframer_check_sync_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(2).GetWin(),
			value=self.deframer_check_sync_text,
			callback=self.set_deframer_check_sync_text,
			label="Deframer check sync enable",
			converter=forms.str_converter(),
		)
		self.rx_ntb.GetPage(2).GridAdd(self._deframer_check_sync_text_static_text, 2, 0, 1, 1)
		self._datetime_text_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(3).GetWin(),
			value=self.datetime_text,
			callback=self.set_datetime_text,
			label="Local time of aquisition start",
			converter=forms.str_converter(),
		)
		self.rx_ntb.GetPage(3).GridAdd(self._datetime_text_static_text, 1, 0, 1, 1)
		_clock_alpha_sl_sizer = wx.BoxSizer(wx.VERTICAL)
		self._clock_alpha_sl_text_box = forms.text_box(
			parent=self.rx_ntb.GetPage(1).GetWin(),
			sizer=_clock_alpha_sl_sizer,
			value=self.clock_alpha_sl,
			callback=self.set_clock_alpha_sl,
			label="Clock alpha",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._clock_alpha_sl_slider = forms.slider(
			parent=self.rx_ntb.GetPage(1).GetWin(),
			sizer=_clock_alpha_sl_sizer,
			value=self.clock_alpha_sl,
			callback=self.set_clock_alpha_sl,
			minimum=0.001,
			maximum=0.1,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.rx_ntb.GetPage(1).GridAdd(_clock_alpha_sl_sizer, 1, 1, 1, 1)
		self._baseband_file_text_inf_static_text = forms.static_text(
			parent=self.rx_ntb.GetPage(3).GetWin(),
			value=self.baseband_file_text_inf,
			callback=self.set_baseband_file_text_inf,
			label="Baseband filename",
			converter=forms.str_converter(),
		)
		self.rx_ntb.GetPage(3).GridAdd(self._baseband_file_text_inf_static_text, 4, 0, 1, 1)

		##################################################
		# Blocks
		##################################################
		self.gr_agc_xx_0 = gr.agc_cc(10e-6, 1, 1.0/32767.0, 1.0)
		self.gr_binary_slicer_fb_0 = gr.binary_slicer_fb()
		self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_ff(sps/2.0, clock_alpha**2/4.0, 0.5, clock_alpha, max_clock_offset)
		self.gr_file_sink_0_0 = gr.file_sink(gr.sizeof_short*1, frames_file)
		self.gr_file_sink_0_0.set_unbuffered(False)
		self.gr_file_sink_0_1 = gr.file_sink(gr.sizeof_short*2, baseband_file)
		self.gr_file_sink_0_1.set_unbuffered(False)
		self.gr_float_to_complex_0 = gr.float_to_complex(1)
		self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000)
		self.gr_short_to_float_0 = gr.short_to_float()
		self.gr_short_to_float_0_0 = gr.short_to_float()
		self.gr_vector_to_streams_0 = gr.vector_to_streams(gr.sizeof_short*1, 2)
		self.noaa_hrpt_decoder_0 = noaa.hrpt_decoder(True,False)
		self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset)
		self.poesweather_univ_hrpt_deframer_0 = poesweather.univ_hrpt_deframer(deframer_sync_check, 11090, deframer_insync_frames, deframer_outsync_frames)
		self.usrp2_source_xxxx2_0 = usrp2.source_16sc()
		self.usrp2_source_xxxx2_0.set_decim(decim_tb)
		self.usrp2_source_xxxx2_0.set_center_freq(freq_tb)
		self.usrp2_source_xxxx2_0.set_gain(gain_tb)
		self.wxgui_fftsink1 = fftsink2.fft_sink_c(
			self.rx_ntb.GetPage(0).GetWin(),
			baseband_freq=freq,
			y_per_div=5,
			y_divs=10,
			ref_level=65,
			ref_scale=2.0,
			sample_rate=samp_rate,
			fft_size=1024,
			fft_rate=30,
			average=True,
			avg_alpha=0.1,
			title="Not filtered spectrum",
			peak_hold=False,
		)
		self.rx_ntb.GetPage(0).Add(self.wxgui_fftsink1.win)

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_float_to_complex_0, 0), (self.wxgui_fftsink1, 0))
		self.connect((self.poesweather_univ_hrpt_deframer_0, 0), (self.noaa_hrpt_decoder_0, 0))
		self.connect((self.gr_binary_slicer_fb_0, 0), (self.poesweather_univ_hrpt_deframer_0, 0))
		self.connect((self.poesweather_univ_hrpt_deframer_0, 0), (self.gr_file_sink_0_0, 0))
		self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 0))
		self.connect((self.pll, 0), (self.gr_moving_average_xx_0, 0))
		self.connect((self.gr_moving_average_xx_0, 0), (self.gr_clock_recovery_mm_xx_0, 0))
		self.connect((self.gr_agc_xx_0, 0), (self.pll, 0))
		self.connect((self.gr_float_to_complex_0, 0), (self.gr_agc_xx_0, 0))
		self.connect((self.gr_vector_to_streams_0, 0), (self.gr_short_to_float_0, 0))
		self.connect((self.gr_vector_to_streams_0, 1), (self.gr_short_to_float_0_0, 0))
		self.connect((self.usrp2_source_xxxx2_0, 0), (self.gr_vector_to_streams_0, 0))
		self.connect((self.usrp2_source_xxxx2_0, 0), (self.gr_file_sink_0_1, 0))
		self.connect((self.gr_short_to_float_0_0, 0), (self.gr_float_to_complex_0, 1))
		self.connect((self.gr_short_to_float_0, 0), (self.gr_float_to_complex_0, 0))
Example #55
0
    def __init__(self, subdev="A:0", devid="addr=192.168.10.2", frequency=1.4125e9, fftsize=8192):
        grc_wxgui.top_block_gui.__init__(self, title="Total Power Radiometer - N200")

        ##################################################
        # Parameters
        ##################################################
        self.subdev = subdev
        self.devid = devid
        self.frequency = frequency
        self.fftsize = fftsize

        ##################################################
        # Variables
        ##################################################
        self.GUI_samp_rate = GUI_samp_rate = 10e6
        self.samp_rate = samp_rate = int(GUI_samp_rate)
        self.prefix = prefix = "tpr_"
        self.text_samp_rate = text_samp_rate = GUI_samp_rate
        self.text_deviceID = text_deviceID = subdev
        self.text_Device_addr = text_Device_addr = devid
        self.spec_data_fifo = spec_data_fifo = "spectrum_" + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat"
        self.spavg = spavg = 1
        self.scope_rate = scope_rate = 2
        self.recfile_tpr = recfile_tpr = prefix + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat"
        self.recfile_kelvin = recfile_kelvin = prefix+"kelvin" + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat"
        self.rec_button_tpr = rec_button_tpr = 1
        self.rec_button_iq = rec_button_iq = 1
        self.noise_amplitude = noise_amplitude = .5
        self.integ = integ = 2
        self.gain = gain = 26
        self.freq = freq = frequency
        self.file_rate = file_rate = 2.0
        self.fftrate = fftrate = int(samp_rate/fftsize)
        self.det_rate = det_rate = int(20.0)
        self.dc_gain = dc_gain = 1
        self.calib_2 = calib_2 = -342.774
        self.calib_1 = calib_1 = 4.0755e3
        self.add_noise = add_noise = 0

        ##################################################
        # Blocks
        ##################################################
        self.Main = self.Main = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.Main.AddPage(grc_wxgui.Panel(self.Main), "N200 Control Panel")
        self.Main.AddPage(grc_wxgui.Panel(self.Main), "TPR Measurements")
        self.Add(self.Main)
        _spavg_sizer = wx.BoxSizer(wx.VERTICAL)
        self._spavg_text_box = forms.text_box(
        	parent=self.Main.GetPage(0).GetWin(),
        	sizer=_spavg_sizer,
        	value=self.spavg,
        	callback=self.set_spavg,
        	label="Spectral Averaging (Seconds)",
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._spavg_slider = forms.slider(
        	parent=self.Main.GetPage(0).GetWin(),
        	sizer=_spavg_sizer,
        	value=self.spavg,
        	callback=self.set_spavg,
        	minimum=1,
        	maximum=20,
        	num_steps=20,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Main.GetPage(0).GridAdd(_spavg_sizer, 1, 1, 1, 1)
        self._rec_button_tpr_chooser = forms.button(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.rec_button_tpr,
        	callback=self.set_rec_button_tpr,
        	label="Record TPR Data",
        	choices=[0,1],
        	labels=['Stop','Start'],
        )
        self.Main.GetPage(0).GridAdd(self._rec_button_tpr_chooser, 4, 1, 1, 1)
        self._rec_button_iq_chooser = forms.button(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.rec_button_iq,
        	callback=self.set_rec_button_iq,
        	label="Record I/Q Data",
        	choices=[0,1],
        	labels=['Stop','Start'],
        )
        self.Main.GetPage(0).GridAdd(self._rec_button_iq_chooser, 4, 0, 1, 1)
        _integ_sizer = wx.BoxSizer(wx.VERTICAL)
        self._integ_text_box = forms.text_box(
        	parent=self.Main.GetPage(0).GetWin(),
        	sizer=_integ_sizer,
        	value=self.integ,
        	callback=self.set_integ,
        	label="Integration Time (Seconds)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._integ_slider = forms.slider(
        	parent=self.Main.GetPage(0).GetWin(),
        	sizer=_integ_sizer,
        	value=self.integ,
        	callback=self.set_integ,
        	minimum=1,
        	maximum=60,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Main.GetPage(0).GridAdd(_integ_sizer, 0, 2, 1, 1)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
        	parent=self.Main.GetPage(0).GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	label="RF Gain (dB)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._gain_slider = forms.slider(
        	parent=self.Main.GetPage(0).GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	minimum=0,
        	maximum=50,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Main.GetPage(0).GridAdd(_gain_sizer, 0, 1, 1, 1)
        self._freq_text_box = forms.text_box(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.freq,
        	callback=self.set_freq,
        	label="Center Frequency (Hz)",
        	converter=forms.float_converter(),
        )
        self.Main.GetPage(0).GridAdd(self._freq_text_box, 0, 0, 1, 1)
        self._dc_gain_chooser = forms.radio_buttons(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.dc_gain,
        	callback=self.set_dc_gain,
        	label="DC Gain",
        	choices=[1, 10, 100, 1000, 10000],
        	labels=[],
        	style=wx.RA_HORIZONTAL,
        )
        self.Main.GetPage(0).GridAdd(self._dc_gain_chooser, 1, 0, 1, 1)
        self._calib_2_text_box = forms.text_box(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.calib_2,
        	callback=self.set_calib_2,
        	label="Calibration value 2",
        	converter=forms.float_converter(),
        )
        self.Main.GetPage(0).GridAdd(self._calib_2_text_box, 3, 1, 1, 1)
        self._calib_1_text_box = forms.text_box(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.calib_1,
        	callback=self.set_calib_1,
        	label="Calibration value 1",
        	converter=forms.float_converter(),
        )
        self.Main.GetPage(0).GridAdd(self._calib_1_text_box, 3, 0, 1, 1)
        self._GUI_samp_rate_chooser = forms.radio_buttons(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.GUI_samp_rate,
        	callback=self.set_GUI_samp_rate,
        	label="Sample Rate (BW)",
        	choices=[1e6,2e6,5e6,10e6,25e6],
        	labels=['1 MHz','2 MHz','5 MHz','10 MHz','25 MHz'],
        	style=wx.RA_HORIZONTAL,
        )
        self.Main.GetPage(0).GridAdd(self._GUI_samp_rate_chooser, 1, 3, 1, 1)
        self.wxgui_scopesink2_2 = scopesink2.scope_sink_f(
        	self.Main.GetPage(1).GetWin(),
        	title="Total Power",
        	sample_rate=2,
        	v_scale=.1,
        	v_offset=0,
        	t_scale=100,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_STRIPCHART,
        	y_axis_label="power level",
        )
        self.Main.GetPage(1).Add(self.wxgui_scopesink2_2.win)
        self.wxgui_numbersink2_2 = numbersink2.number_sink_f(
        	self.GetWin(),
        	unit="Units",
        	minval=0,
        	maxval=1,
        	factor=1.0,
        	decimal_places=10,
        	ref_level=0,
        	sample_rate=GUI_samp_rate,
        	number_rate=15,
        	average=False,
        	avg_alpha=None,
        	label="Number Plot",
        	peak_hold=False,
        	show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_2.win)
        self.wxgui_numbersink2_0_0 = numbersink2.number_sink_f(
        	self.Main.GetPage(1).GetWin(),
        	unit="",
        	minval=0,
        	maxval=.2,
        	factor=1,
        	decimal_places=6,
        	ref_level=0,
        	sample_rate=scope_rate,
        	number_rate=15,
        	average=True,
        	avg_alpha=.01,
        	label="Raw Power level",
        	peak_hold=False,
        	show_gauge=True,
        )
        self.Main.GetPage(1).Add(self.wxgui_numbersink2_0_0.win)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
        	self.Main.GetPage(1).GetWin(),
        	unit="Kelvin",
        	minval=0,
        	maxval=400,
        	factor=1,
        	decimal_places=6,
        	ref_level=0,
        	sample_rate=scope_rate,
        	number_rate=15,
        	average=False,
        	avg_alpha=None,
        	label="Calibrated Temperature",
        	peak_hold=False,
        	show_gauge=True,
        )
        self.Main.GetPage(1).Add(self.wxgui_numbersink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.Main.GetPage(0).GetWin(),
        	baseband_freq=freq,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=20,
        	ref_scale=2.0,
        	sample_rate=GUI_samp_rate,
        	fft_size=1024,
        	fft_rate=5,
        	average=True,
        	avg_alpha=0.1,
        	title="Spectrum",
        	peak_hold=False,
        	size=(800,400),
        )
        self.Main.GetPage(0).Add(self.wxgui_fftsink2_0.win)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join((devid, "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_samp_rate(GUI_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_processor_affinity([0])
        self._text_samp_rate_static_text = forms.static_text(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.text_samp_rate,
        	callback=self.set_text_samp_rate,
        	label="Samp rate",
        	converter=forms.float_converter(),
        )
        self.Main.GetPage(0).GridAdd(self._text_samp_rate_static_text, 2, 0, 1, 1)
        self._text_deviceID_static_text = forms.static_text(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.text_deviceID,
        	callback=self.set_text_deviceID,
        	label="SubDev",
        	converter=forms.str_converter(),
        )
        self.Main.GetPage(0).GridAdd(self._text_deviceID_static_text, 2, 1, 1, 1)
        self._text_Device_addr_static_text = forms.static_text(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.text_Device_addr,
        	callback=self.set_text_Device_addr,
        	label="Device Address",
        	converter=forms.str_converter(),
        )
        self.Main.GetPage(0).GridAdd(self._text_Device_addr_static_text, 2, 2, 1, 1)
        self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(1.0/((samp_rate*integ)/2.0), 1)
        (self.single_pole_iir_filter_xx_0).set_processor_affinity([1])
        _noise_amplitude_sizer = wx.BoxSizer(wx.VERTICAL)
        self._noise_amplitude_text_box = forms.text_box(
        	parent=self.Main.GetPage(0).GetWin(),
        	sizer=_noise_amplitude_sizer,
        	value=self.noise_amplitude,
        	callback=self.set_noise_amplitude,
        	label='noise_amplitude',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._noise_amplitude_slider = forms.slider(
        	parent=self.Main.GetPage(0).GetWin(),
        	sizer=_noise_amplitude_sizer,
        	value=self.noise_amplitude,
        	callback=self.set_noise_amplitude,
        	minimum=.01,
        	maximum=1,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Main.GetPage(0).GridAdd(_noise_amplitude_sizer, 3, 2, 1, 1)
        self.logpwrfft_x_0 = logpwrfft.logpwrfft_c(
        	sample_rate=samp_rate,
        	fft_size=fftsize,
        	ref_scale=2,
        	frame_rate=fftrate,
        	avg_alpha=1.0/float(spavg*fftrate),
        	average=True,
        )
        self.blocks_peak_detector_xb_0 = blocks.peak_detector_fb(0.25, 0.40, 10, 0.001)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((calib_1, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((dc_gain, ))
        self.blocks_keep_one_in_n_4 = blocks.keep_one_in_n(gr.sizeof_float*1, samp_rate/det_rate)
        self.blocks_keep_one_in_n_3 = blocks.keep_one_in_n(gr.sizeof_float*fftsize, fftrate)
        self.blocks_keep_one_in_n_1 = blocks.keep_one_in_n(gr.sizeof_float*1, int(det_rate/file_rate))
        self.blocks_file_sink_5 = blocks.file_sink(gr.sizeof_float*fftsize, spec_data_fifo, False)
        self.blocks_file_sink_5.set_unbuffered(True)
        self.blocks_file_sink_4 = blocks.file_sink(gr.sizeof_float*1, recfile_tpr, False)
        self.blocks_file_sink_4.set_unbuffered(True)
        self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_gr_complex*1, prefix+"iq_raw" + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat", False)
        self.blocks_file_sink_1.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*1, recfile_kelvin, False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_mag_squared_1 = blocks.complex_to_mag_squared(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.blocks_add_const_vxx_1 = blocks.add_const_vff((calib_2, ))
        self.blks2_valve_2 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(rec_button_iq))
        self.blks2_valve_1 = grc_blks2.valve(item_size=gr.sizeof_float*1, open=bool(0))
        self.blks2_valve_0 = grc_blks2.valve(item_size=gr.sizeof_float*1, open=bool(rec_button_tpr))
        self._add_noise_chooser = forms.button(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.add_noise,
        	callback=self.set_add_noise,
        	label="Noise Source",
        	choices=[0,1],
        	labels=['Off','On'],
        )
        self.Main.GetPage(0).GridAdd(self._add_noise_chooser, 3, 3, 1, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_valve_0, 0), (self.blocks_file_sink_4, 0))    
        self.connect((self.blks2_valve_1, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.blks2_valve_2, 0), (self.blocks_file_sink_1, 0))    
        self.connect((self.blocks_add_const_vxx_1, 0), (self.blks2_valve_1, 0))    
        self.connect((self.blocks_add_const_vxx_1, 0), (self.wxgui_numbersink2_0, 0))    
        self.connect((self.blocks_char_to_float_0, 0), (self.wxgui_numbersink2_2, 0))    
        self.connect((self.blocks_complex_to_mag_squared_1, 0), (self.single_pole_iir_filter_xx_0, 0))    
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_peak_detector_xb_0, 0))    
        self.connect((self.blocks_keep_one_in_n_1, 0), (self.blks2_valve_0, 0))    
        self.connect((self.blocks_keep_one_in_n_1, 0), (self.blocks_multiply_const_vxx_1, 0))    
        self.connect((self.blocks_keep_one_in_n_1, 0), (self.wxgui_scopesink2_2, 0))    
        self.connect((self.blocks_keep_one_in_n_3, 0), (self.blocks_file_sink_5, 0))    
        self.connect((self.blocks_keep_one_in_n_4, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_keep_one_in_n_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_numbersink2_0_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_const_vxx_1, 0))    
        self.connect((self.blocks_peak_detector_xb_0, 0), (self.blocks_char_to_float_0, 0))    
        self.connect((self.logpwrfft_x_0, 0), (self.blocks_keep_one_in_n_3, 0))    
        self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_keep_one_in_n_4, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.blks2_valve_2, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_mag_squared_1, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_real_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.logpwrfft_x_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0))    
Example #56
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.volume = volume = 500e-3
        self.samp_rate = samp_rate = 2.4e6
        self.offset_freq = offset_freq = 119e6
        self.freq_corr = freq_corr = 65
        self.freq = freq = 591.28e6
        self.base_freq = base_freq = 560e6

        ##################################################
        # 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)
        self._offset_freq_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.offset_freq,
            callback=self.set_offset_freq,
            label="Frequency select",
            choices=[
                119e6, 120.5e6, 123.85e6, 126.55e6, 128.65e6, 132.225e6, 560e6
            ],
            labels=[
                "bradley 119M", "worc tow 120.5M", "worc ground 123.85M",
                "worc atais126.55M", "worc clrnc 128.65M",
                "logan twr 132.225M", "560AM"
            ],
            style=wx.RA_VERTICAL,
        )
        self.Add(self._offset_freq_chooser)
        _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=254,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_freq_corr_sizer)
        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(offset_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.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=48,
            decimation=48,
            taps=None,
            fractional_bw=None,
        )
        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)
        _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=500e6,
            maximum=1200e6,
            num_steps=700,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_freq_sizer)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (volume, ))
        self.audio_sink_0 = audio.sink(48000, "pulse", True)
        self.analog_am_demod_cf_0 = analog.am_demod_cf(
            channel_rate=48e3,
            audio_decim=1,
            audio_pass=5000,
            audio_stop=5500,
        )
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-5, 1, 0)
        self.analog_agc2_xx_0.set_max_gain(5)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        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.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_agc2_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_am_demod_cf_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))