示例#1
0
文件: wbfm_chain.py 项目: mr0w1/cp
    def __init__(self):
        gr.hier_block2.__init__(
            self, "WBFM Chain",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signature(1, 1, gr.sizeof_float*1),
        )

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=192000,
                decimation=2400000,
                taps=None,
                fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, 2400000, 200e3, 10e3, firdes.WIN_HAMMING, 6.76))
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
        	quad_rate=192000,
        	audio_decimation=4,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_wfm_rcv_0, 0), (self, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.analog_wfm_rcv_0, 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.transition = transition = 1000000
        self.samp_rate = samp_rate = 2000000
        self.quadrature = quadrature = 500000
        self.cutoff = cutoff = 100000
        self.audio_decimation = audio_decimation = 10

        ##################################################
        # Blocks
        ##################################################
        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(107.8e6, 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(20, 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=2000,
                decimation=500,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                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, cutoff, transition, firdes.WIN_HAMMING, 6.76))
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1, ))
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
        	quad_rate=quadrature,
        	audio_decimation=audio_decimation,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.rtlsdr_source_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_1, 0))
        self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_null_sink_0, 0))
示例#3
0
 def raw_resampler(self, intpol, decim, tps, fractional):
     return filter.rational_resampler_ccc(
                 interpolation=intpol,
                 decimation=decim,
                 taps=tps,
                 fractional_bw=fractional,
            )
示例#4
0
文件: acoust_in.py 项目: npgm/acoust
    def __init__(self):
        gr.top_block.__init__(self, "Acoust In")

        ##################################################
        # Variables
        ##################################################
        self.transistion = transistion = 100
        self.sps = sps = 2
        self.sideband_rx = sideband_rx = 1000
        self.sideband = sideband = 1000
        self.samp_rate = samp_rate = 48000
        self.payload = payload = 20
        self.interpolation = interpolation = 200
        self.fd = fd = 1
        self.carrier = carrier = 23000

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=interpolation,
                taps=None,
                fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(1, (filter.firdes.low_pass(1, samp_rate, sideband_rx,100)), carrier, samp_rate)
        self.digital_gfsk_demod_0 = digital.gfsk_demod(
        	samples_per_symbol=sps,
        	sensitivity=1.0,
        	gain_mu=0.175,
        	mu=0.5,
        	omega_relative_limit=0.005,
        	freq_error=0.0,
        	verbose=False,
        	log=False,
        )
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blks2_tcp_sink_0 = grc_blks2.tcp_sink(
        	itemsize=gr.sizeof_char*1,
        	addr="127.0.0.1",
        	port=11000,
        	server=False,
        )
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder(
        		access_code="",
        		threshold=-1,
        		callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload),
        	),
        )
        self.audio_source_0 = audio.source(48000, "", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_float_to_complex_0, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.rational_resampler_xxx_0_0_0, 0))
        self.connect((self.audio_source_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.digital_gfsk_demod_0, 0))
        self.connect((self.digital_gfsk_demod_0, 0), (self.blks2_packet_decoder_0, 0))
        self.connect((self.blks2_packet_decoder_0, 0), (self.blks2_tcp_sink_0, 0))
示例#5
0
文件: dsd_chain.py 项目: mr0w1/cp
    def __init__(self):
        gr.hier_block2.__init__(
            self, "DSD Chain",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signature(1, 1, gr.sizeof_float*1),
        )

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_3 = filter.rational_resampler_fff(
                interpolation=48000,
                decimation=8000,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_2 = filter.rational_resampler_ccc(
                interpolation=48000,
                decimation=2400000,
                taps=None,
                fractional_bw=None,
        )
        self.dsd_block_ff_0 = dsd.block_ff(dsd.dsd_FRAME_DMR_MOTOTRBO,dsd.dsd_MOD_GFSK,3,True,3)
        self.analog_quadrature_demod_cf_1 = analog.quadrature_demod_cf(1.6)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_1, 0), (self.dsd_block_ff_0, 0))    
        self.connect((self.dsd_block_ff_0, 0), (self.rational_resampler_xxx_3, 0))    
        self.connect((self, 0), (self.rational_resampler_xxx_2, 0))    
        self.connect((self.rational_resampler_xxx_2, 0), (self.analog_quadrature_demod_cf_1, 0))    
        self.connect((self.rational_resampler_xxx_3, 0), (self, 0))    
示例#6
0
文件: acoust_out.py 项目: npgm/acoust
    def __init__(self):
        gr.top_block.__init__(self, "Acoust Out")

        ##################################################
        # Variables
        ##################################################
        self.transistion = transistion = 100
        self.sps = sps = 2
        self.sideband_rx = sideband_rx = 1000
        self.sideband = sideband = 1000
        self.samp_rate = samp_rate = 48000
        self.payload = payload = 20
        self.interpolation = interpolation = 200
        self.fd = fd = 0
        self.carrier = carrier = 13000

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=interpolation,
                decimation=1,
                taps=None,
                fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (firdes.band_pass (0.50,samp_rate,carrier-sideband,carrier+sideband,transistion)), -carrier, samp_rate)
        self.digital_gfsk_mod_0 = digital.gfsk_mod(
        	samples_per_symbol=sps,
        	sensitivity=1.0,
        	bt=0.35,
        	verbose=False,
        	log=False,
        )
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blks2_tcp_source_0 = grc_blks2.tcp_source(
        	itemsize=gr.sizeof_char*1,
        	addr="127.0.0.1",
        	port=9000,
        	server=True,
        )
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder(
        		samples_per_symbol=sps,
        		bits_per_symbol=1,
        		preamble="",
        		access_code="",
        		pad_for_usrp=False,
        	),
        	payload_length=payload,
        )
        self.audio_sink_0 = audio.sink(48000, "", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_real_0, 0), (self.audio_sink_0, 0))
        self.connect((self.digital_gfsk_mod_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gfsk_mod_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.blks2_tcp_source_0, 0), (self.blks2_packet_encoder_0, 0))
示例#7
0
    def __init__(self, samp_rate, src_filename, dest_filename):
        gr.top_block.__init__(self, "SAME Encoder")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate

        ##################################################
        # Blocks
        ##################################################
        self.msg_source = blocks.file_source(1, src_filename)
        self.packed_to_unpacked = blocks.packed_to_unpacked_bb(1, gr.GR_LSB_FIRST)
        self.repeat = blocks.repeat(4, 96)
        self.chunks_to_symbols = digital.chunks_to_symbols_bf(([-1, 1]), 1)
        self.freq_mod = analog.frequency_modulator_fc(3.14159265 / 96)
        # TODO: Make amplitude adjustable
        self.center_freq_src = analog.sig_source_c(50000, analog.GR_COS_WAVE, 1822.916666, 0.1, 0)
        self.freq_mult = blocks.multiply_vcc(1)
        self.rational_resampler = filter.rational_resampler_ccc(
            interpolation=samp_rate / 100, decimation=500, taps=None, fractional_bw=None
        )
        self.complex_to_float = blocks.complex_to_float()
        self.float_to_short = blocks.float_to_short(1, 32767)
        self.sink = blocks.file_sink(2, dest_filename)
        self.sink.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.msg_source, 0), (self.packed_to_unpacked, 0), (self.chunks_to_symbols, 0))
        self.connect((self.chunks_to_symbols, 0), (self.repeat, 0), (self.freq_mod, 0), (self.freq_mult, 0))
        self.connect((self.center_freq_src, 0), (self.freq_mult, 1))
        self.connect((self.freq_mult, 0), (self.rational_resampler, 0), (self.complex_to_float, 0))
        self.connect((self.complex_to_float, 0), (self.float_to_short, 0), (self.sink, 0))
示例#8
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 80000

        ##################################################
        # Blocks
        ##################################################
        self.test1_dds_fpga_0 = test1.dds_fpga(8192*2, "/dev/iqram")
	
	self.fir_filter_xxx_0 = filter.rational_resampler_ccc(
	        interpolation=1, decimation=1, taps=None,
	       fractional_bw = None,
        )

        self.audio_sink_0 = audio.sink(samp_rate/5, "", True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
        	quad_rate=samp_rate,
        	audio_decimation=5
        )
        #self.analog_wfm_rcv_0.set_max_output_buffer(4096)

        ##################################################
        # Connections
        ##################################################
        #self.connect((self.test1_dds_fpga_0, 0), (self.analog_wfm_rcv_0, 0))
        #self.connect((self.analog_wfm_rcv_0, 0), (self.audio_sink_0, 0))
        self.connect((self.test1_dds_fpga_0, 0), (self.fir_filter_xxx_0, 0))
        self.connect((self.fir_filter_xxx_0, 0), (self.analog_wfm_rcv_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0), (self.audio_sink_0, 0))
示例#9
0
    def __init__(self):
        gr.top_block.__init__(self, "Dttsptx")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 8000000
        self.output_rate = output_rate = 8000000

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=output_rate,
                decimation=48000,
                taps=None,
                fractional_bw=None,
        )
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/txiq", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_interleaved_char_0 = blocks.complex_to_interleaved_char(False)
        self.audio_source_0 = audio.source(48000, "", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.audio_source_0, 0), (self.blocks_float_to_complex_0, 0))    
        self.connect((self.audio_source_0, 1), (self.blocks_float_to_complex_0, 1))    
        self.connect((self.blocks_complex_to_interleaved_char_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.blocks_float_to_complex_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_complex_to_interleaved_char_0, 0))    
示例#10
0
文件: nbfm_chain.py 项目: mr0w1/cp
    def __init__(self):
        gr.hier_block2.__init__(
            self, "NBFM Chain",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signature(1, 1, gr.sizeof_float*1),
        )

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=192000,
                decimation=2400000,
                taps=None,
                fractional_bw=None,
        )
        self.low_pass_filter_1 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, 192000, 5e3, 5e3, firdes.WIN_HAMMING, 6.76))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((5, ))
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=48000,
        	quad_rate=192000,
        	tau=75e-6,
        	max_dev=2.5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self, 0))    
        self.connect((self.low_pass_filter_1, 0), (self.analog_nbfm_rx_0, 0))    
        self.connect((self, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_1, 0))    
示例#11
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 125e6

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.GetWin(),
        	baseband_freq=500e6,
        	dynamic_range=40,
        	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.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
                interpolation=3,
                decimation=125,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=48,
                decimation=30,
                taps=None,
                fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(10, firdes.low_pass(
        	1, 3e6, 5e3, 8e3, firdes.WIN_HAMMING, 6.76))
        self.blocks_interleaved_short_to_complex_0 = blocks.interleaved_short_to_complex(False, False)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_short*1, "/dev/langford", True)
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=30000,
        	quad_rate=300000,
        	tau=75e-6,
        	max_dev=5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0), (self.blocks_interleaved_short_to_complex_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_nbfm_rx_0, 0))
        self.connect((self.analog_nbfm_rx_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.blocks_interleaved_short_to_complex_0, 0), (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.blocks_interleaved_short_to_complex_0, 0), (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.low_pass_filter_0, 0))
示例#12
0
文件: top_block.py 项目: m0zic/vuhf
    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

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=70,
                decimation=64,
                taps=None,
                fractional_bw=None,
        )
        self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "bladerf=0,buffers=128,buflen=32768" )
        self.osmosdr_sink_0.set_sample_rate(10e6)
        self.osmosdr_sink_0.set_center_freq(800e6, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(19, 0)
        self.osmosdr_sink_0.set_if_gain(0, 0)
        self.osmosdr_sink_0.set_bb_gain(0, 0)
        self.osmosdr_sink_0.set_antenna("", 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)
          
        self.fft_vxx_0 = fft.fft_vcc(2048, False, (window.rectangular(2048)), True, 10)
        self.dvbt_symbol_inner_interleaver_0 = dvbt.symbol_inner_interleaver(1512, dvbt.T2k, 1)
        self.dvbt_reference_signals_0 = dvbt.reference_signals(gr.sizeof_gr_complex, 1512, 2048, dvbt.QAM16, dvbt.NH, dvbt.C1_2, dvbt.C1_2, dvbt.G1_32, dvbt.T2k, 0, 0)
        self.dvbt_reed_solomon_enc_0 = dvbt.reed_solomon_enc(2, 8, 0x11d, 255, 239, 8, 51, 8)
        self.dvbt_inner_coder_0 = dvbt.inner_coder(1, 1512, dvbt.QAM16, dvbt.NH, dvbt.C1_2)
        self.dvbt_energy_dispersal_0 = dvbt.energy_dispersal(1)
        self.dvbt_dvbt_map_0 = dvbt.dvbt_map(1512, dvbt.QAM16, dvbt.NH, dvbt.T2k, 1)
        self.dvbt_convolutional_interleaver_0 = dvbt.convolutional_interleaver(136, 12, 17)
        self.dvbt_bit_inner_interleaver_0 = dvbt.bit_inner_interleaver(1512, dvbt.QAM16, dvbt.NH, dvbt.T2k)
        self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(2048, 2048+64, 0, "")
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.0022097087, ))
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "test.ts", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0), (self.dvbt_energy_dispersal_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.dvbt_bit_inner_interleaver_0, 0), (self.dvbt_symbol_inner_interleaver_0, 0))    
        self.connect((self.dvbt_convolutional_interleaver_0, 0), (self.dvbt_inner_coder_0, 0))    
        self.connect((self.dvbt_dvbt_map_0, 0), (self.dvbt_reference_signals_0, 0))    
        self.connect((self.dvbt_energy_dispersal_0, 0), (self.dvbt_reed_solomon_enc_0, 0))    
        self.connect((self.dvbt_inner_coder_0, 0), (self.dvbt_bit_inner_interleaver_0, 0))    
        self.connect((self.dvbt_reed_solomon_enc_0, 0), (self.dvbt_convolutional_interleaver_0, 0))    
        self.connect((self.dvbt_reference_signals_0, 0), (self.fft_vxx_0, 0))    
        self.connect((self.dvbt_symbol_inner_interleaver_0, 0), (self.dvbt_dvbt_map_0, 0))    
        self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.osmosdr_sink_0, 0))    
示例#13
0
    def __init__(self, txstr="Hello World", carrier=10000, samp_rate = 80000, bw=4000, amp=1):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate 
        self.carrier = carrier 
        self.bw = bw

        ##################################################
        # Blocks
        ##################################################
        self.source = blocks.vector_source_b(tuple(bytearray(txstr)), False, 1, [])

        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=int(samp_rate/bw),
                decimation=1,
                taps=None,
                fractional_bw=None,
        )
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((CODE_TABLE), CODE_LEN)
        self.blocks_vector_source_x_0 = blocks.vector_source_c([0, sin(pi/4), 1, sin(3*pi/4)], True, 1, [])
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, 4)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(CHUNK_LEN, gr.GR_LSB_FIRST)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, 2)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.audio_sink_0 = audio.sink(samp_rate, "")
        #XXX Hack: 0.07 should actually be parameter amp, but RPI crashes
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, carrier, 0.07, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.source, 0), (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_repeat_0, 0))

        self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_repeat_0, 0), (self.blocks_multiply_xx_0, 1))

        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_float_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_delay_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_float_to_complex_0, 1))

        self.connect((self.blocks_float_to_complex_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0_0, 1))

        self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.audio_sink_0, 0))
示例#14
0
    def __init__(self, win, sat_name, mode_name):
        gr.hier_block2.__init__(self, "Channel "+str(sat_name)+" "+str(mode_name)+" SSB",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(1, 1, gr.sizeof_gr_complex))

        self.trans = trans = 500
        self.sample_rate = sample_rate = 2048000
        self.low_ssb = low_ssb = 200
        self.high_ssb = high_ssb = 2800
        self.decim = decim = 8
        self.agc_decay = agc_decay = 50e-6

        ##################################################
        # Blocks
        ##################################################
        self.fftsink_audio = fftsink2.fft_sink_f(
            win,
            baseband_freq=0,
            y_per_div=5,
            y_divs=10,
            ref_level=-20,
            ref_scale=2.0,
            sample_rate=32000,
            fft_size=1024,
            fft_rate=15,
            average=True,
            avg_alpha=None,
            title="FFT Plot (Audio - "+sat_name+" "+str(mode_name)+")",
            peak_hold=True,
            )

        self.multiply_const_64 = blocks.multiply_const_vff((0.1, ))
        self.complex_to_real = blocks.complex_to_real(1)

        self.rational_resampler = filter.rational_resampler_ccc(
            interpolation=32,
            decimation=64,
            taps=None,
            fractional_bw=None,
            )
        self.band_pass_filter = filter.fir_filter_ccc(4, filter.firdes.complex_band_pass(
            1, sample_rate/decim, low_ssb, high_ssb, trans, filter.firdes.WIN_HAMMING, 6.76))
        self.agc = analog.agc2_cc(0.1, agc_decay, 0.9, 1.0)
        
        ##################################################
        # Connections
        ##################################################
        #self.connect(self, (self.gr_throttle_0, 0))

        self.connect(self, (self.band_pass_filter, 0))
        self.connect((self.band_pass_filter, 0), (self.agc, 0))
        self.connect((self.agc, 0), (self.rational_resampler, 0))
        self.connect((self.rational_resampler, 0), (self.complex_to_real, 0))
        self.connect((self.complex_to_real, 0), (self.multiply_const_64, 0))
        self.connect((self.multiply_const_64, 0), (self.fftsink_audio, 0))
        self.connect((self.multiply_const_64, 0), self)
示例#15
0
def main(args):
    nargs = len(args)
    if nargs == 1:
        infile  = args[0]
        outfile = None
    elif nargs == 2:
        infile  = args[0]
        outfile  = args[1]
    else:
        sys.stderr.write("Usage: atsc-blade.py input_file [output_file]\n");
        sys.exit(1)

    symbol_rate = 4500000.0 / 286 * 684
    pilot_freq = 309441
    center_freq = 441000000
    txvga1_gain = -4
    txvga2_gain = 25

    tb = gr.top_block()

    src = blocks.file_source(gr.sizeof_char, infile, True)

    pad = atsc.pad()
    rand = atsc.randomizer()
    rs_enc = atsc.rs_encoder()
    inter = atsc.interleaver()
    trell = atsc.trellis_encoder()
    fsm = atsc.field_sync_mux()

    v2s = blocks.vector_to_stream(gr.sizeof_char, 1024)
    minn = blocks.keep_m_in_n(gr.sizeof_char, 832, 1024, 4)
    c2sym = digital.chunks_to_symbols_bc(([symbol + 1.25 for symbol in [-7,-5,-3,-1,1,3,5,7]]), 1)
    offset = analog.sig_source_c(symbol_rate, analog.GR_COS_WAVE, -3000000 + pilot_freq, 0.9, 0)
    mix = blocks.multiply_vcc(1)
    rrc_taps = firdes.root_raised_cosine(0.1, symbol_rate*2, symbol_rate/2, 0.1152, 200)
    rrc = filter.rational_resampler_ccc(interpolation=2, decimation=3, taps=rrc_taps, fractional_bw=None, )

    out = osmosdr.sink(args="bladerf=0,buffers=128,buflen=32768")
    out.set_sample_rate(symbol_rate * 2 / 3)
    out.set_center_freq(center_freq, 0)
    out.set_freq_corr(0, 0)
    out.set_gain(txvga2_gain, 0)
    out.set_bb_gain(txvga1_gain, 0)
    out.set_bandwidth(6000000, 0)

    tb.connect(src, pad, rand, rs_enc, inter, trell, fsm, v2s, minn, c2sym)
    tb.connect((c2sym, 0), (mix, 0))
    tb.connect((offset, 0), (mix, 1))
    tb.connect(mix, rrc, out)

    if outfile:
        dst = blocks.file_sink(gr.sizeof_gr_complex, outfile)
        tb.connect(rrc, dst)

    tb.run()
示例#16
0
    def __init__(self):
        gr.top_block.__init__(self, "SAME Decoder test")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 8000

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_44k = filter.rational_resampler_fff(
                interpolation=80,
                decimation=441,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=100,
                decimation=96,
                taps=None,
                fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_fcc(1, (firdes.low_pass(1, samp_rate, 600, 100)), 1822.916667, samp_rate)
        self.digital_gmsk_demod_0 = digital.gmsk_demod(
        	samples_per_symbol=16,
        	gain_mu=0.175,
        	mu=0.5,
        	omega_relative_limit=0.1,
        	freq_error=0.0,
        	verbose=True,
        	log=False,
        )
        #self.src = audio.source(samp_rate, "plughw:CARD=PCH,DEV=2", True)
        self.blocks_wavfile_source_0 = blocks.wavfile_source("eas-test-11-7-2013.wav", False)
        self.blocks_bitstream_sink = blocks.file_sink(1, "bitstream.bin")
        self.xlat_sink = blocks.wavfile_sink("xlat.wav", 1, 8333)
        self.xlat_complex_to_float = blocks.complex_to_float()
        self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_ff(-50, 0.0001, 0)
        self.msg_queue = gr.msg_queue(10)
        self.same_dec_0 = same.same_dec(self.msg_queue)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.xlat_complex_to_float, 0), (self.xlat_sink, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.digital_gmsk_demod_0, 0))
        self.connect((self.digital_gmsk_demod_0, 0), (self.same_dec_0, 0))
        self.connect((self.digital_gmsk_demod_0, 0), (self.blocks_bitstream_sink, 0))
        #self.connect((self.src, 0), (self.rational_resampler_44k, 0))
        #self.connect((self.rational_resampler_44k, 0), (self.analog_pwr_squelch_xx_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0), (self.analog_pwr_squelch_xx_0,0))
        self.connect((self.analog_pwr_squelch_xx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))

        self._watcher = _queue_watcher_thread(self.msg_queue)
示例#17
0
    def __init__(self):
        gr.top_block.__init__(self, "Blade Tx")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 4000000
        self.interpolation = interpolation = 80
        self.wpm = wpm = 15
        self.tune = tune = 100
        self.rf_gain = rf_gain = 10
        self.offset = offset = 200000
        self.cw_vector = cw_vector = (1,0,1,0,1,0,1,1,1, 0,0,0, 1,0,1,0,1,0,1,1,1, 0,0,0, 1,0,1,0,1,0,1,1,1, 0,0,0,0,0,0,0, 1,1,1,0,1,0,1, 0,0,0, 1, 0,0,0,0,0,0,0, 1,0,1,0,1,0,1,1,1, 0,0,0, 1, 0,0,0, 1,0,1,0,1,0,1,1,1,0,1,1,1, 0,0,0, 1,0,1, 0,0,0, 1,0,1,1,1,0,1, 0,0,0, 1,0,1,1,1,0,1, 0,0,0,0,0,0,0, 1,1,1, 0,0,0, 1, 0,0,0, 1,0,1,0,1, 0,0,0, 1,1,1, 0,0,0, 1,0,1, 0,0,0, 1,1,1,0,1, 0,0,0, 1,1,1,0,1,1,1,0,1, 0,0,0,0,0,0,0)
        self.correction = correction = 0
        self.bb_gain = bb_gain = -25
        self.band = band = 432
        self.audio_rate = audio_rate = samp_rate / interpolation

        ##################################################
        # Blocks
        ##################################################
        self.resamp = filter.rational_resampler_ccc(
                interpolation=interpolation,
                decimation=1,
                taps=None,
                fractional_bw=None,
        )
        self.out = osmosdr.sink( args="numchan=" + str(1) + " " + "" )
        self.out.set_sample_rate(samp_rate)
        self.out.set_center_freq(band * (1 + correction / 1e6) * 1e6 + 100000 - offset, 0)
        self.out.set_freq_corr(0, 0)
        self.out.set_gain(rf_gain, 0)
        self.out.set_if_gain(0, 0)
        self.out.set_bb_gain(bb_gain, 0)
        self.out.set_antenna("", 0)
        self.out.set_bandwidth(0, 0)
          
        self.offset_osc = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, tune * 1000 + 100000, 0.9, 0)
        self.mixer = blocks.multiply_vcc(1)
        self.cw_vector_source = blocks.vector_source_c(cw_vector, False, 1, [])
        self.cw_repeat = blocks.repeat(gr.sizeof_gr_complex*1, int(1.2 * audio_rate / wpm))
        self.click_filter = filter.single_pole_iir_filter_cc(1e-2, 1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vcc((0.000001, ))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_add_const_vxx_0, 0), (self.resamp, 0))    
        self.connect((self.click_filter, 0), (self.blocks_add_const_vxx_0, 0))    
        self.connect((self.cw_repeat, 0), (self.click_filter, 0))    
        self.connect((self.cw_vector_source, 0), (self.cw_repeat, 0))    
        self.connect((self.mixer, 0), (self.out, 0))    
        self.connect((self.offset_osc, 0), (self.mixer, 0))    
        self.connect((self.resamp, 0), (self.mixer, 1))    
示例#18
0
    def __init__(self, wpm, tx_freq, if_gain, rf_amp, morse_vector):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.wpm = wpm
        self.tx_freq = tx_freq - cw_tone_ofs
        self.rf_sample_rate = rf_sample_rate = 500000
        self.morse_vector = morse_vector
        self.audio_rate = audio_rate = 8000

        ##################################################
        # Blocks
        ##################################################
        self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine(
        	1, audio_rate, 5, 0.35, 200))
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=rf_sample_rate,
                decimation=audio_rate,
                taps=None,
                fractional_bw=None,
        )
        self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_sink_0.set_sample_rate(rf_sample_rate)
        self.osmosdr_sink_0.set_center_freq(self.tx_freq, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)

        # OK, osmocom is incredibly stupid. It interprets "0" for these fields as "not set",
        #and defaults to an IF gain of +16 and turning the RF amp *ON*.
        # A value of "1" for the RF gain turns it off, and a value >=7 turns it on.
        # For IF gain, 0->16, 1..47 behave as you'd expect. This means IF gain=0 is impossible.
        self.osmosdr_sink_0.set_gain(        14 if rf_amp  > 0 else 1, 0)
        self.osmosdr_sink_0.set_if_gain(if_gain if if_gain > 0 else 1, 0)

        self.osmosdr_sink_0.set_antenna("", 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)
          
        self.blocks_vector_source_x_0 = blocks.vector_source_c(morse_vector, False, 1, [])
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, int(1.2 * audio_rate / wpm))
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, cw_tone_ofs, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.rational_resampler_xxx_0, 0), (self.osmosdr_sink_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_repeat_0, 0))
        self.connect((self.blocks_repeat_0, 0), (self.root_raised_cosine_filter_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.root_raised_cosine_filter_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_0, 0))
示例#19
0
    def __init__(self, min_tx_len):
        gr.top_block.__init__(self, "OFDMChatApp")
        # Variables
        self.samp_rate = samp_rate = 1e6
        self.len_tag_key = len_tag_key = "packet_len"
        self.gain = gain = 60
        self.fft_len = fft_len = 128
        self.min_tx_len = min_tx_len
        self.pdu_port = pmt.intern("pdus")
        # Blocks
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            device_addr="",
            stream_args=uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_subdev_spec("A:A", 0)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(400e6, 0)
        self.uhd_usrp_sink_0.set_gain(gain, 0)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=2,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.fosdem_burst_marker_0 = fosdem.burst_marker(gr.sizeof_gr_complex, len_tag_key, 0)
        self.digital_ofdm_tx_0 = digital.ofdm_tx(
        	  fft_len=fft_len, cp_len=fft_len/4,
        	  packet_length_tag_key=len_tag_key,
        	  bps_header=1,
        	  bps_payload=2,
        	  rolloff=0,
        	  debug_log=False,
        	  scramble_bits=True
        	 )
        self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(gr.sizeof_gr_complex*1, len_tag_key, 2)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len")
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, ))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0))
        self.connect((self.digital_ofdm_tx_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0))
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.fosdem_burst_marker_0, 0))
        self.connect((self.fosdem_burst_marker_0, 0), (self.uhd_usrp_sink_0, 0))
示例#20
0
    def __init__(self):
        gr.top_block.__init__(self)

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=6,
                taps=None,
                fractional_bw=None,
        )

        # self.fcdproplus_fcdproplus_0 = fcdproplus.fcdproplus("",1)
        # self.fcdproplus_fcdproplus_0.set_lna(1)
        # self.fcdproplus_fcdproplus_0.set_mixer_gain(1)
        # self.fcdproplus_fcdproplus_0.set_if_gain(20)
        # self.fcdproplus_fcdproplus_0.set_freq_corr(0)
        # self.fcdproplus_fcdproplus_0.set_freq(70050000)
        self.fcdproplus_fcdproplus_0 = fcdproplus.fcdproplus("",1)
        self.fcdproplus_fcdproplus_0.set_lna(0)
        self.fcdproplus_fcdproplus_0.set_mixer_gain(0)
        self.fcdproplus_fcdproplus_0.set_if_gain(30) # new board, cal 17/12/17
        #self.fcdproplus_fcdproplus_0.set_if_gain(38) # new board, cal 17/12/17
        #self.fcdproplus_fcdproplus_0.set_if_gain(47) # new board
#        self.fcdproplus_fcdproplus_0.set_if_gain(38) # old board
        self.fcdproplus_fcdproplus_0.set_freq_corr(0)
        #delta=180
        delta=255
        self.fcdproplus_fcdproplus_0.set_freq(21406000+delta)
#        self.fcdproplus_fcdproplus_0.set_freq(21400000)
#        self.fcdproplus_fcdproplus_0.set_freq(29210000)
          

        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.audio_sink_0 = audio.sink(samp_rate, "skype", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_float_0, 0), (self.audio_sink_0, 0))
        self.connect((self.blocks_complex_to_float_0, 1), (self.audio_sink_0, 1))
        self.connect((self.fcdproplus_fcdproplus_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_complex_to_float_0, 0))
示例#21
0
    def __init__(self, input_samp_rate, output_samp_rate):
        gr.hier_block2.__init__(
                self, "FM Block",
                gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
                gr.io_signature(1, 1, gr.sizeof_float*1),
        )

        # Parameters
        self.input_samp_rate = input_samp_rate
        self.output_samp_rate = output_samp_rate
        self.decimation = decimation = 4
        self.cutoff = cutoff = 100e3
        self.transition = transition = 10e3

        # Blocks
        self.rational_resampler_1 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=decimation,
                taps=None,
                fractional_bw=None,
        )

        self.low_pass_filter = filter.fir_filter_ccf(1, filter.firdes.low_pass(
        	1, int(input_samp_rate/decimation), cutoff, transition, filter.firdes.WIN_HAMMING, 6.76))

        self.fm_demodulator = analog.wfm_rcv(
                quad_rate=int(input_samp_rate/decimation),
                audio_decimation=1,
        )

        self.rational_resampler_2 = filter.rational_resampler_fff(
                interpolation=output_samp_rate,
                decimation=int(input_samp_rate/decimation),
                taps=None,
                fractional_bw=None,
        )

        self.multiply = blocks.multiply_const_vff((80,))

        # Connections
        self.connect(
                self,
                self.rational_resampler_1,
                self.low_pass_filter,
                self.fm_demodulator,
                self.rational_resampler_2,
                self.multiply,
                self
        )
示例#22
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.wpm = wpm = 15
        self.tx_freq = tx_freq = 433.000e6
        self.rf_sample_rate = rf_sample_rate = 250000
        self.morse_vector = morse_vector = (1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0)
        self.audio_rate = audio_rate = 8000

        ##################################################
        # Blocks
        ##################################################
        self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine(
        	1, audio_rate, 5, 0.35, 200))
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=rf_sample_rate,
                decimation=audio_rate,
                taps=None,
                fractional_bw=None,
        )
        self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_sink_0.set_sample_rate(rf_sample_rate)
        self.osmosdr_sink_0.set_center_freq(tx_freq, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(0, 0)
        self.osmosdr_sink_0.set_if_gain(20, 0)
        self.osmosdr_sink_0.set_bb_gain(20, 0)
        self.osmosdr_sink_0.set_antenna("", 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)
          
        self.blocks_vector_source_x_0 = blocks.vector_source_c(morse_vector, False, 1, [])
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, int(1.2 * audio_rate / wpm))
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 1000, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.rational_resampler_xxx_0, 0), (self.osmosdr_sink_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_repeat_0, 0))
        self.connect((self.blocks_repeat_0, 0), (self.root_raised_cosine_filter_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.root_raised_cosine_filter_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_0, 0))
示例#23
0
文件: TXDigital.py 项目: acarmon2/FM
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Txdigital")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.baud_rate = baud_rate = 49260
        self.samp_rate = samp_rate = baud_rate*10
        self.deviation = deviation = 180000
        self.sps = sps = samp_rate/baud_rate
        self.samp_rate_TX = samp_rate_TX = samp_rate*2
        self.modulation_index = modulation_index = (float)(deviation)/((float)(baud_rate / 2))

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	device_addr="",
        	stream_args=uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate_TX)
        self.uhd_usrp_sink_0.set_center_freq(434e6, 0)
        self.uhd_usrp_sink_0.set_gain(20, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=samp_rate_TX,
                decimation=samp_rate,
                taps=None,
                fractional_bw=None,
        )
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.8, ))
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/gema/Documents/RF12B.dat", True)
        self.analog_cpfsk_bc_0 = analog.cpfsk_bc((float)((float)(deviation)/baud_rate), 0.1, sps)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.analog_cpfsk_bc_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_file_source_0, 0), (self.analog_cpfsk_bc_0, 0))
示例#24
0
    def __init__(self, filename="0.dat", freq=90.1e6, samp_rate=1e6):
        gr.top_block.__init__(self, "Fm Receiver")

        ##################################################
        # Parameters
        ##################################################
        self.filename = filename
        self.freq = freq
        self.samp_rate = samp_rate

        ##################################################
        # Variables
        ##################################################
        self.gain = gain = 30
        self.audio_rate = audio_rate = 48e3
        self.audio_interp = audio_interp = 4

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=int(audio_rate*audio_interp),
                decimation=int(samp_rate),
                taps=None,
                fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.interp_fir_filter_fff(1, firdes.low_pass(
        	1, int(audio_rate), 800, 100, firdes.WIN_HAMMING, 6.76))
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink("wav_out.wav", 1, int(audio_rate), 8)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_interleaved_short_to_complex_0 = blocks.interleaved_short_to_complex(False, False)
        self.blocks_file_source_0_0 = blocks.file_source(gr.sizeof_short*1, filename, False)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
        	quad_rate=int(audio_rate*audio_interp),
        	audio_decimation=int(audio_interp),
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_wfm_rcv_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.blocks_file_source_0_0, 0), (self.blocks_interleaved_short_to_complex_0, 0))    
        self.connect((self.blocks_interleaved_short_to_complex_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.blocks_wavfile_sink_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.analog_wfm_rcv_0, 0))    
示例#25
0
def oqpsktx(self, carrier=10000, samp_rate = 80000, bw=4000, amp=1, code=codes.mycode, **kwargs):
    code_table, code_len = codes.codes2table(code), len(code)
    chunk_len = int(log(code_len,2))

    topblock(self, carrier, samp_rate, bw, amp)

    ##################################################
    # Blocks
    ##################################################
    self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(chunk_len, gr.GR_LSB_FIRST)
    self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((code_table), code_len)

    self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, 4)
    self.blocks_vector_source_x_0 = blocks.vector_source_c([0, sin(pi/4), 1, sin(3*pi/4)], True, 1, [])

    self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
    self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
    self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, 2)

    self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
    self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=int(samp_rate/bw),
            decimation=1,
            taps=None,
            fractional_bw=None,
    )

    ##################################################
    # Connections
    ##################################################
    self.connect((self.source, 0), (self.blocks_packed_to_unpacked_xx_0, 0))
    self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))
    self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_repeat_0, 0))

    self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_multiply_xx_0, 0))
    self.connect((self.blocks_repeat_0, 0), (self.blocks_multiply_xx_0, 1))

    self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_float_0, 0))
    self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_float_to_complex_0, 0))
    self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_delay_0, 0))
    self.connect((self.blocks_delay_0, 0), (self.blocks_float_to_complex_0, 1))

    self.connect((self.blocks_float_to_complex_0, 0), (self.rational_resampler_xxx_0, 0))
    self.connect((self.rational_resampler_xxx_0, 0), (self.sink, 0))
示例#26
0
文件: cwtx.py 项目: 0x00-0xFF/cwtx
    def __init__(self):

        gr.top_block.__init__(self, "CW Tx")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2e6

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=int(samp_rate),
                decimation=176400,
                taps=None,
                fractional_bw=None,
        )
        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(DEF_MORSE_FREQ, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(10, 0)
        self.osmosdr_sink_0.set_if_gain(20, 0)
        self.osmosdr_sink_0.set_bb_gain(20, 0)
        self.osmosdr_sink_0.set_antenna("", 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)
          
        self.blocks_wavfile_source_0 = blocks.wavfile_source("/tmp/morse.wav", False)
        self.analog_wfm_tx_0 = analog.wfm_tx(
        	audio_rate=DEF_SAMPLE_RATE,
        	quad_rate=176400,
        	tau=75e-6,
        	max_dev=5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_wavfile_source_0, 0), (self.analog_wfm_tx_0, 0))    
        self.connect((self.analog_wfm_tx_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.osmosdr_sink_0, 0))    
示例#27
0
文件: am_chain.py 项目: mr0w1/cp
    def __init__(self):
        gr.hier_block2.__init__(
            self, "AM Chain",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signature(1, 1, gr.sizeof_float*1),
        )

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
                interpolation=2,
                decimation=75,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=3,
                decimation=4,
                taps=None,
                fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, 64000, 5000, 100, firdes.WIN_HAMMING, 6.76))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((5, ))
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.analog_agc2_xx_0 = analog.agc2_ff(6.25e-4, 1e-5, .2, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.analog_agc2_xx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self, 0), (self.rational_resampler_xxx_1, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.rational_resampler_xxx_1, 0), (self.low_pass_filter_0, 0))    
    def __init__(self, input_file, output_file):
        gr.top_block.__init__(self, "Uhd Shifter")


        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 256000
        self.offset = offset = -25e3

        ##################################################
        # Blocks
        ##################################################
        self.signal_source = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, offset, 1, 0)
        self.resampler = filter.rational_resampler_ccc(
                interpolation=96,
                decimation=256,
                taps=None,
                fractional_bw=None,
        )
        self.multiply_const = blocks.multiply_const_vcc((32768, ))
        self.multi = blocks.multiply_vcc(1)
        self.file_source = blocks.file_source(gr.sizeof_gr_complex*1, input_file, False)
        self.file_sink = blocks.file_sink(gr.sizeof_short*1, output_file, False)
        self.file_sink.set_unbuffered(True)
        self.c2is = blocks.complex_to_interleaved_short()

        ##################################################
        # Connections
        ##################################################
        self.connect((self.multi, 0), (self.resampler, 0))
        self.connect((self.file_source, 0), (self.multi, 0))
        self.connect((self.signal_source, 0), (self.multi, 1))
        self.connect((self.c2is, 0), (self.file_sink, 0))
        self.connect((self.multiply_const, 0), (self.c2is, 0))
        self.connect((self.resampler, 0), (self.multiply_const, 0))
示例#29
0
    def test_63(self):
        """
        Test case generated by test-case generator
        """
        ##################################################
        # Variables
        ##################################################
        # Input data into the system
        src_data = "PKdhtXMmr18n2L9K88eMlGn7CcctT9RwKSB1FebW397VI5uG1yhc3uavuaOb9vyJ"
        self.bw = bw = 250000
        self.sf = sf = 10
        self.samp_rate = samp_rate = 250000
        self.pay_len = pay_len = 64
        self.n_frame = n_frame = 2
        self.impl_head = impl_head = True
        self.has_crc = has_crc = False
        self.frame_period = frame_period = 200
        self.cr = cr = 6

        ##################################################
        # Blocks
        ##################################################
        # Tx side
        self.lora_sdr_whitening_0 = lora_sdr.whitening()
        self.lora_sdr_modulate_0 = lora_sdr.modulate(sf, samp_rate, bw)
        self.lora_sdr_modulate_0.set_min_output_buffer(10000000)
        self.lora_sdr_interleaver_0 = lora_sdr.interleaver(cr, sf)
        self.lora_sdr_header_0 = lora_sdr.header(impl_head, has_crc, cr)
        self.lora_sdr_hamming_enc_0 = lora_sdr.hamming_enc(cr, sf)
        self.lora_sdr_gray_decode_0 = lora_sdr.gray_decode(sf)
        self.lora_sdr_data_source_0_1_0 = lora_sdr.data_source(
            pay_len, n_frame, src_data)
        self.lora_sdr_add_crc_0 = lora_sdr.add_crc(has_crc)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_message_strobe_random_0_1_0 = blocks.message_strobe_random(
            pmt.intern(''), blocks.STROBE_UNIFORM, frame_period, 5)
        # Rx side
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=4,
            decimation=1,
            taps=None,
            fractional_bw=None)
        self.lora_sdr_header_decoder_0 = lora_sdr.header_decoder(
            impl_head, cr, pay_len, has_crc)
        self.lora_sdr_hamming_dec_0 = lora_sdr.hamming_dec()
        self.lora_sdr_gray_enc_0 = lora_sdr.gray_enc()
        self.lora_sdr_frame_sync_0 = lora_sdr.frame_sync(
            samp_rate, bw, sf, impl_head)
        self.lora_sdr_fft_demod_0 = lora_sdr.fft_demod(
            samp_rate, bw, sf, impl_head)
        self.lora_sdr_dewhitening_0 = lora_sdr.dewhitening()
        self.lora_sdr_deinterleaver_0 = lora_sdr.deinterleaver(sf)
        self.lora_sdr_crc_verif_0 = lora_sdr.crc_verif()
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_throttle_0 = blocks.throttle(
            gr.sizeof_gr_complex*1, samp_rate, True)

        ##################################################
        # Connections
        ##################################################
        # Tx side
        self.tb.msg_connect((self.blocks_message_strobe_random_0_1_0,
                             'strobe'), (self.lora_sdr_data_source_0_1_0, 'trigg'))
        self.tb.msg_connect((self.lora_sdr_data_source_0_1_0,
                             'msg'), (self.lora_sdr_add_crc_0, 'msg'))
        self.tb.msg_connect((self.lora_sdr_data_source_0_1_0,
                             'msg'), (self.lora_sdr_header_0, 'msg'))
        self.tb.msg_connect((self.lora_sdr_data_source_0_1_0,
                             'msg'), (self.lora_sdr_interleaver_0, 'msg'))
        self.tb.msg_connect((self.lora_sdr_data_source_0_1_0,
                             'msg'), (self.lora_sdr_modulate_0, 'msg'))
        self.tb.msg_connect((self.lora_sdr_data_source_0_1_0,
                             'msg'), (self.lora_sdr_whitening_0, 'msg'))
        self.tb.connect((self.lora_sdr_add_crc_0, 0),
                        (self.lora_sdr_hamming_enc_0, 0))
        self.tb.connect((self.lora_sdr_gray_decode_0, 0),
                        (self.lora_sdr_modulate_0, 0))
        self.tb.connect((self.lora_sdr_hamming_enc_0, 0),
                        (self.lora_sdr_interleaver_0, 0))
        self.tb.connect((self.lora_sdr_header_0, 0),
                        (self.lora_sdr_add_crc_0, 0))
        self.tb.connect((self.lora_sdr_interleaver_0, 0),
                        (self.lora_sdr_gray_decode_0, 0))
        self.tb.connect((self.lora_sdr_whitening_0, 0),
                        (self.lora_sdr_header_0, 0))
        self.tb.connect((self.lora_sdr_modulate_0, 0),
                        (self.blocks_throttle_0, 0))
        # Rx side

        self.tb.connect((self.blocks_throttle_0, 0),
                        (self.rational_resampler_xxx_0, 0))
        self.tb.msg_connect((self.lora_sdr_crc_verif_0, 'msg'),
                            (self.blocks_message_debug_0, 'store'))
        self.tb.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                            (self.lora_sdr_deinterleaver_0, 'new_frame'))
        self.tb.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                            (self.lora_sdr_dewhitening_0, 'new_frame'))
        self.tb.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                            (self.lora_sdr_fft_demod_0, 'new_frame'))
        self.tb.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                            (self.lora_sdr_hamming_dec_0, 'new_frame'))
        self.tb.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                            (self.lora_sdr_header_decoder_0, 'new_frame'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0,
                             'pay_len'), (self.lora_sdr_crc_verif_0, 'pay_len'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0,
                             'CRC'), (self.lora_sdr_crc_verif_0, 'CRC'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'CR'),
                            (self.lora_sdr_deinterleaver_0, 'CR'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0,
                             'pay_len'), (self.lora_sdr_dewhitening_0, 'pay_len'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0,
                             'CRC'), (self.lora_sdr_dewhitening_0, 'CRC'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0,
                             'CR'), (self.lora_sdr_fft_demod_0, 'CR'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0,
                             'CR'), (self.lora_sdr_frame_sync_0, 'CR'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0,
                             'err'), (self.lora_sdr_frame_sync_0, 'err'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0,
                             'CRC'), (self.lora_sdr_frame_sync_0, 'crc'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0,
                             'pay_len'), (self.lora_sdr_frame_sync_0, 'pay_len'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0,
                             'CR'), (self.lora_sdr_hamming_dec_0, 'CR'))
        self.tb.connect((self.lora_sdr_deinterleaver_0, 0),
                        (self.lora_sdr_hamming_dec_0, 0))
        self.tb.connect((self.lora_sdr_dewhitening_0, 0),
                        (self.lora_sdr_crc_verif_0, 0))
        self.tb.connect((self.lora_sdr_fft_demod_0, 0),
                        (self.lora_sdr_gray_enc_0, 0))
        self.tb.connect((self.lora_sdr_frame_sync_0, 0),
                        (self.lora_sdr_fft_demod_0, 0))
        self.tb.connect((self.lora_sdr_gray_enc_0, 0),
                        (self.lora_sdr_deinterleaver_0, 0))
        self.tb.connect((self.lora_sdr_hamming_dec_0, 0),
                        (self.lora_sdr_header_decoder_0, 0))
        self.tb.connect((self.lora_sdr_header_decoder_0, 0),
                        (self.lora_sdr_dewhitening_0, 0))
        self.tb.connect((self.rational_resampler_xxx_0, 0),
                        (self.lora_sdr_frame_sync_0, 0))

        # run the flowgraph, since we use a message strobe we have to run and stop the flowgraph with some computation time inbetween
        self.tb.start()
        time.sleep(10)
        self.tb.stop()
        self.tb.wait()
        # try to get get the message from the store port of the message debug printer and convert to string from pmt message
        try:
            msg = pmt.symbol_to_string(
                self.blocks_message_debug_0.get_message(0))
        except:
            # if not possible set message to be None
            msg = None

        # check if message received is the same as the message decoded
        self.assertMultiLineEqual(
            src_data, msg, msg="Error decoded data {0} is not the same as input data {1}".format(msg, src_data))
示例#30
0
    def __init__(
            self,
            channel_shift_hz=0,
            occupied_bw=100e3,
            random_source_seed=0,
            sample_rate=3e6,
            tx_len_s=1.0,
            fm_file_path="hurdle2/deps/hurdle2/beethoven_symphony_no5.wav",
            fm_file_start_s=27.75):
        gr.hier_block2.__init__(
            self,
            "Scalable Signal Fm",
            gr.io_signature(0, 0, 0),
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
        )

        ##################################################
        # Parameters
        ##################################################
        self.channel_shift_hz = channel_shift_hz
        self.occupied_bw = occupied_bw
        self.random_source_seed = random_source_seed
        self.sample_rate = sample_rate
        self.tx_len_s = tx_len_s
        self.fm_file_start_s = fm_file_start_s

        ##################################################
        # Variables
        ##################################################
        self.fm_scale_factor = fm_scale_factor = 1.0 / 0.728
        self.audio_rate = audio_rate = 44100
        self.samp_rate = samp_rate = sample_rate
        self.quad_rate = quad_rate = audio_rate * 20
        self.num_bins = num_bins = 2
        self.max_deviation = max_deviation = occupied_bw * fm_scale_factor

        ##################################################
        # Blocks
        ##################################################
        self.wavfile_source = blocks.wavfile_source(fm_file_path, True)
        self.skiphead = blocks.skiphead(gr.sizeof_float * 1,
                                        int(fm_file_start_s * audio_rate))
        self.scalable_fm = scalable_fm(
            audio_rate=audio_rate,
            max_dev=max_deviation,
            quad_rate=quad_rate,
        )
        self.rational_resampler_0 = filter.rational_resampler_ccc(
            interpolation=15,
            decimation=4,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler = filter.rational_resampler_ccc(
            interpolation=400,
            decimation=441,
            taps=None,
            fractional_bw=None,
        )
        self.null_sink = blocks.null_sink(gr.sizeof_float * 1)
        self.mult = blocks.multiply_vcc(1)
        self.low_pass_filter_0 = filter.interp_fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, occupied_bw * 1.5, samp_rate / 100.0,
                            firdes.WIN_BLACKMAN, 6.76))
        self.head = blocks.head(gr.sizeof_gr_complex * 1,
                                int(tx_len_s * samp_rate))
        self.freq_shift = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE,
                                              channel_shift_hz, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.freq_shift, 0), (self.mult, 1))
        self.connect((self.head, 0), (self, 0))
        self.connect((self.low_pass_filter_0, 0), (self.mult, 0))
        self.connect((self.mult, 0), (self.head, 0))
        self.connect((self.rational_resampler, 0),
                     (self.rational_resampler_0, 0))
        self.connect((self.rational_resampler_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.scalable_fm, 0), (self.rational_resampler, 0))
        self.connect((self.skiphead, 0), (self.scalable_fm, 0))
        self.connect((self.wavfile_source, 0), (self.null_sink, 0))
        self.connect((self.wavfile_source, 1), (self.skiphead, 0))
示例#31
0
    def __init__(self):
        gr.top_block.__init__(self, "Xceiver")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Xceiver")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "XCEIVER")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.transistion = transistion = 1000
        self.sync_word2 = sync_word2 = [
            0j, 0j, 0j, 0j, 0j, 0j, (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j),
            (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j),
            (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j),
            (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j),
            (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), 0j, (1 + 0j), (-1 + 0j),
            (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j),
            (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j),
            (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j),
            (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j),
            0j, 0j, 0j, 0j, 0j
        ]
        self.sync_word1 = sync_word1 = [
            0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0.,
            -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            0., 0., 0., 0., 0.
        ]
        self.sideband_rx = sideband_rx = 4000
        self.sideband = sideband = 4000
        self.samp_rate = samp_rate = 48000
        self.pilot_symbols = pilot_symbols = ((
            1,
            1,
            1,
            -1,
        ), )
        self.pilot_carriers = pilot_carriers = ((
            -21,
            -7,
            7,
            21,
        ), )
        self.packet_length_tag_key = packet_length_tag_key = "packet_len"
        self.packet_len = packet_len = 8
        self.occupied_carriers = occupied_carriers = (
            range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) +
            range(8, 21) + range(22, 27), )
        self.length_tag_key = length_tag_key = "packet_len"
        self.fft_len = fft_len = 64

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=220,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_sink_x_0_0 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_0_win)

        self.qtgui_sink_x_0_0.enable_rf_freq(False)

        self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(
            1, (filter.firdes.low_pass(1, samp_rate, sideband_rx, 1000)), 5000,
            samp_rate)
        self.digital_ofdm_rx_0 = digital.ofdm_rx(
            fft_len=fft_len,
            cp_len=fft_len / 4,
            frame_length_tag_key='frame_' + "length",
            packet_length_tag_key="length",
            occupied_carriers=occupied_carriers,
            pilot_carriers=pilot_carriers,
            pilot_symbols=pilot_symbols,
            sync_word1=sync_word1,
            sync_word2=sync_word2,
            bps_header=1,
            bps_payload=2,
            debug_log=False,
            scramble_bits=False)
        self.digital_hdlc_deframer_bp_0 = digital.hdlc_deframer_bp(4, 10)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((1, ))
        self.blocks_message_debug_1 = blocks.message_debug()
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.audio_source_0 = audio.source(48000, "", True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.digital_hdlc_deframer_bp_0, 'out'),
                         (self.blocks_message_debug_1, 'print_pdu'))
        self.connect((self.audio_source_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.digital_hdlc_deframer_bp_0, 0))
        self.connect((self.digital_ofdm_rx_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0),
                     (self.qtgui_sink_x_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.digital_ofdm_rx_0, 0))
示例#32
0
    def __init__(self):
        gr.top_block.__init__(self, "OFDM PU Phy")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("OFDM PU Phy")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "tx_ofdm")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 10e6
        self.taps = taps = filter.firdes.low_pass(1, samp_rate, 0.98e6, 0.5e6)
        self.sync_word2 = sync_word2 = [
            0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1,
            1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1,
            1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1,
            -1, 0, 0, 0, 0, 0
        ]
        self.sync_word1 = sync_word1 = [
            0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0.,
            -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            0., 0., 0., 0., 0.
        ]
        self.pilot_symbols = pilot_symbols = ((
            1,
            1,
            1,
            -1,
        ), )
        self.pilot_carriers = pilot_carriers = ((
            -21,
            -7,
            7,
            21,
        ), )
        self.packet_len = packet_len = 64
        self.occupied_carriers = occupied_carriers = (
            range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) +
            range(8, 21) + range(22, 27), )
        self.len_tag_key = len_tag_key = "packet_len"
        self.interp_factor = interp_factor = 5
        self.fft_len = fft_len = 64
        self.decim_factor = decim_factor = 1

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            "",  #",".join(("addr=192.168.10.2", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(pu_params.frequency, 0)
        self.uhd_usrp_sink_0.set_gain(15, 0)
        self.uhd_usrp_sink_0.set_antenna(pu_params.antenna, 0)
        self.rational_resampler_xxx_0_0_1_1 = filter.rational_resampler_ccc(
            interpolation=interp_factor,
            decimation=decim_factor,
            taps=(taps),
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0_0_1_0 = filter.rational_resampler_ccc(
            interpolation=interp_factor,
            decimation=decim_factor,
            taps=(taps),
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0_0_1 = filter.rational_resampler_ccc(
            interpolation=interp_factor,
            decimation=decim_factor,
            taps=(taps),
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
            interpolation=interp_factor,
            decimation=decim_factor,
            taps=(taps),
            fractional_bw=None,
        )
        self.digital_ofdm_tx_0_2 = digital.ofdm_tx(
            fft_len=fft_len,
            cp_len=fft_len / 4,
            packet_length_tag_key=len_tag_key,
            occupied_carriers=occupied_carriers,
            pilot_carriers=pilot_carriers,
            pilot_symbols=pilot_symbols,
            sync_word1=sync_word1,
            sync_word2=sync_word2,
            bps_header=1,
            bps_payload=2,
            rolloff=0,
            debug_log=False,
            scramble_bits=False)
        self.digital_ofdm_tx_0_1 = digital.ofdm_tx(
            fft_len=fft_len,
            cp_len=fft_len / 4,
            packet_length_tag_key=len_tag_key,
            occupied_carriers=occupied_carriers,
            pilot_carriers=pilot_carriers,
            pilot_symbols=pilot_symbols,
            sync_word1=sync_word1,
            sync_word2=sync_word2,
            bps_header=1,
            bps_payload=2,
            rolloff=0,
            debug_log=False,
            scramble_bits=False)
        self.digital_ofdm_tx_0_0 = digital.ofdm_tx(
            fft_len=fft_len,
            cp_len=fft_len / 4,
            packet_length_tag_key=len_tag_key,
            occupied_carriers=occupied_carriers,
            pilot_carriers=pilot_carriers,
            pilot_symbols=pilot_symbols,
            sync_word1=sync_word1,
            sync_word2=sync_word2,
            bps_header=1,
            bps_payload=2,
            rolloff=0,
            debug_log=False,
            scramble_bits=False)
        self.digital_ofdm_tx_0 = digital.ofdm_tx(
            fft_len=fft_len,
            cp_len=fft_len / 4,
            packet_length_tag_key=len_tag_key,
            occupied_carriers=occupied_carriers,
            pilot_carriers=pilot_carriers,
            pilot_symbols=pilot_symbols,
            sync_word1=sync_word1,
            sync_word2=sync_word2,
            bps_header=1,
            bps_payload=2,
            rolloff=0,
            debug_log=False,
            scramble_bits=False)
        if type(pu_params.gain) is list and len(pu_params.gain) > 1:
            gain_incr = pu_params.gain[1] - pu_params.gain[0]
            gain_max = pu_params.gain[-1]
            gain_min = pu_params.gain[0]
            static_gain = -1
        else:
            gain_incr = 0
            gain_max = pu_params.gain
            gain_min = pu_params.gain
            static_gain = pu_params.gain
            print "gain range: [", gain_min, ":", gain_incr, ":", gain_max, "]"
        self.dbconnect_pktgen_0 = dbconnect.pktgen(1, packet_len, False, False, False, pu_params.db_ip, 5003, 5, 10, 2, 20, 50, 100, 60000, 0.05, 6643, gain_min, gain_max, pu_params.gain_period, gain_incr,\
        pu_params.scenario,pu_params.channel1,pu_params.channel2,static_gain) # scenario,ch1,ch2,gain. Use -1 for default challenge
        self.dbconnect_pdu_fillpath_cpp_0_0_1 = dbconnect.pdu_fillpath_cpp()
        self.dbconnect_pdu_fillpath_cpp_0_0_0 = dbconnect.pdu_fillpath_cpp()
        self.dbconnect_pdu_fillpath_cpp_0_0 = dbconnect.pdu_fillpath_cpp()
        self.dbconnect_pdu_fillpath_cpp_0 = dbconnect.pdu_fillpath_cpp()
        self.blocks_tagged_stream_to_pdu_0_3_1 = blocks.tagged_stream_to_pdu(
            blocks.complex_t, "packet_len")
        self.blocks_tagged_stream_to_pdu_0_3_0 = blocks.tagged_stream_to_pdu(
            blocks.complex_t, "packet_len")
        self.blocks_tagged_stream_to_pdu_0_3 = blocks.tagged_stream_to_pdu(
            blocks.complex_t, "packet_len")
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(
            blocks.complex_t, "packet_len")
        self.blocks_pdu_to_tagged_stream_0_0_1 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, "packet_len")
        self.blocks_pdu_to_tagged_stream_0_0_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, "packet_len")
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, "packet_len")
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, "packet_len")
        self.blocks_multiply_xx_0_3 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_2 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.18, ))
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_add_xx_2 = blocks.add_vcc(1)
        self.analog_sig_source_x_0_3 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -3.75e6, 1, 0)
        self.analog_sig_source_x_0_2 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 3.75e6, 1, 0)
        self.analog_sig_source_x_0_1 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -1.25e6, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 1.25e6, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'),
                         (self.dbconnect_pdu_fillpath_cpp_0, 'in0'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0_3, 'pdus'),
                         (self.dbconnect_pdu_fillpath_cpp_0_0, 'in0'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0_3_0, 'pdus'),
                         (self.dbconnect_pdu_fillpath_cpp_0_0_0, 'in0'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0_3_1, 'pdus'),
                         (self.dbconnect_pdu_fillpath_cpp_0_0_1, 'in0'))
        self.msg_connect((self.dbconnect_pktgen_0, 'cmd'),
                         (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.dbconnect_pktgen_0, 'out0'),
                         (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.msg_connect((self.dbconnect_pktgen_0, 'out1'),
                         (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.msg_connect((self.dbconnect_pktgen_0, 'out2'),
                         (self.blocks_pdu_to_tagged_stream_0_0_0, 'pdus'))
        self.msg_connect((self.dbconnect_pktgen_0, 'out3'),
                         (self.blocks_pdu_to_tagged_stream_0_0_1, 'pdus'))
        self.msg_connect((self.dbconnect_pktgen_0, 'cmd'),
                         (self.uhd_usrp_sink_0, 'command'))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_0_1, 0),
                     (self.blocks_multiply_xx_0_1, 1))
        self.connect((self.analog_sig_source_x_0_2, 0),
                     (self.blocks_multiply_xx_0_2, 1))
        self.connect((self.analog_sig_source_x_0_3, 0),
                     (self.blocks_multiply_xx_0_3, 1))
        self.connect((self.blocks_add_xx_2, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_2, 0))
        self.connect((self.blocks_multiply_xx_0_1, 0),
                     (self.blocks_add_xx_2, 1))
        self.connect((self.blocks_multiply_xx_0_2, 0),
                     (self.blocks_add_xx_2, 2))
        self.connect((self.blocks_multiply_xx_0_3, 0),
                     (self.blocks_add_xx_2, 3))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0),
                     (self.digital_ofdm_tx_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0),
                     (self.digital_ofdm_tx_0_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0_0, 0),
                     (self.digital_ofdm_tx_0_1, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0_1, 0),
                     (self.digital_ofdm_tx_0_2, 0))
        self.connect((self.dbconnect_pdu_fillpath_cpp_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.dbconnect_pdu_fillpath_cpp_0_0, 0),
                     (self.rational_resampler_xxx_0_0_1, 0))
        self.connect((self.dbconnect_pdu_fillpath_cpp_0_0_0, 0),
                     (self.rational_resampler_xxx_0_0_1_0, 0))
        self.connect((self.dbconnect_pdu_fillpath_cpp_0_0_1, 0),
                     (self.rational_resampler_xxx_0_0_1_1, 0))
        self.connect((self.digital_ofdm_tx_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0, 0))
        self.connect((self.digital_ofdm_tx_0_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0_3, 0))
        self.connect((self.digital_ofdm_tx_0_1, 0),
                     (self.blocks_tagged_stream_to_pdu_0_3_0, 0))
        self.connect((self.digital_ofdm_tx_0_2, 0),
                     (self.blocks_tagged_stream_to_pdu_0_3_1, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0_0_1, 0),
                     (self.blocks_multiply_xx_0_1, 0))
        self.connect((self.rational_resampler_xxx_0_0_1_0, 0),
                     (self.blocks_multiply_xx_0_2, 0))
        self.connect((self.rational_resampler_xxx_0_0_1_1, 0),
                     (self.blocks_multiply_xx_0_3, 0))
示例#33
0
    def __init__(self):
        gr.top_block.__init__(self, "Hd Tx Rtl File")

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
            interpolation=2, decimation=1, taps=None, fractional_bw=None)
        self.nrsc5_sis_encoder_0 = nrsc5.sis_encoder('ABCD')
        self.nrsc5_psd_encoder_0 = nrsc5.psd_encoder(0, 'Title', 'Artist')
        self.nrsc5_l2_encoder_0 = nrsc5.l2_encoder(1, 0, 146176)
        self.nrsc5_l1_fm_encoder_mp1_0 = nrsc5.l1_fm_encoder(1)
        self.nrsc5_hdc_encoder_0 = nrsc5.hdc_encoder(2, 64000)
        self.fft_vxx_0 = fft.fft_vcc(2048, False, window.rectangular(2048),
                                     True, 1)
        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            'sample.wav', True)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, 2048)
        self.blocks_vector_source_x_0 = blocks.vector_source_c(
            [math.sin(math.pi / 2 * i / 112)
             for i in range(112)] + [1] * (2048 - 112) +
            [math.cos(math.pi / 2 * i / 112) for i in range(112)], True, 1, [])
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex * 2048, 2)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(0.5)
        self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(gr.sizeof_gr_complex,
                                                       2160, 4096, 0)
        self.blocks_interleave_0 = blocks.interleave(gr.sizeof_float * 1, 1)
        self.blocks_float_to_uchar_0 = blocks.float_to_uchar()
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   'hd-generated.raw', False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_add_const_vxx_0_0 = blocks.add_const_ff(127.5)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_add_const_vxx_0_0, 0),
                     (self.blocks_float_to_uchar_0, 0))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_interleave_0, 1))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_interleave_0, 0))
        self.connect((self.blocks_conjugate_cc_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.blocks_float_to_uchar_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_interleave_0, 0),
                     (self.blocks_add_const_vxx_0_0, 0))
        self.connect((self.blocks_keep_m_in_n_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_conjugate_cc_0, 0))
        self.connect((self.blocks_repeat_0, 0),
                     (self.blocks_vector_to_stream_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.blocks_keep_m_in_n_0, 0))
        self.connect((self.blocks_wavfile_source_0, 1),
                     (self.nrsc5_hdc_encoder_0, 1))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.nrsc5_hdc_encoder_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_repeat_0, 0))
        self.connect((self.nrsc5_hdc_encoder_0, 0),
                     (self.nrsc5_l2_encoder_0, 0))
        self.connect((self.nrsc5_l1_fm_encoder_mp1_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.nrsc5_l2_encoder_0, 0),
                     (self.nrsc5_l1_fm_encoder_mp1_0, 0))
        self.connect((self.nrsc5_psd_encoder_0, 0),
                     (self.nrsc5_l2_encoder_0, 1))
        self.connect((self.nrsc5_sis_encoder_0, 0),
                     (self.nrsc5_l1_fm_encoder_mp1_0, 1))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
示例#34
0
    def __init__(self,samp_rate=48000,tx_gain=1,rx_gain=1):
        gr.hier_block2.__init__(
           self, 
           "XCEIVER",
           # input signature,
           # Port 1 = audio in
           #      2 = frame in
           gr.io_signaturev(2, 2, [gr.sizeof_float, gr.sizeof_char]),
	   # output signature
           # Port 1 = audio out
           #      2 = frame out
           #      3 = receive filter output
           gr.io_signaturev(3, 3, [gr.sizeof_float, gr.sizeof_char, gr.sizeof_gr_complex]))

        #######################################################################
        # Variables
	self.tx_gain = tx_gain
        self.transition = 50
	# samples_per_symbol
        self.sps = 8
	self.sideband_tx = 800
        self.sideband_rx = 800
        self.samp_rate = samp_rate
        self.interpolation = 100 # w.r.t. transmitter
        self.carrier = 8000 # Hz
	# sensitivity is pi * modulation_index/samples_per_symbol
	self.sensitivity = (math.pi*0.6)/self.sps

        #######################################################################
        # Receiver
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)

        # Construct FIR filters with the given taps and a composite frequency 
        # translation that shifts center_freq down to zero Hz. The frequency 
        # translation logically comes before the filtering operation.
        # Parameters
        #   decimation set the integer decimation rate
        #   taps a vector/list of taps of type gr_complex
        #   center_freq	Center frequency of signal to down convert from (Hz)
        # Band pass filter (centered at carrier, no down conversion)
        self.freq_xlating_fir_filter_BP = \
	   filter.freq_xlating_fir_filter_ccc( \
	      1, \
	      (firdes.band_pass (1,self.samp_rate,self.carrier-self.sideband_rx, \
		self.carrier+self.sideband_rx,self.transition)), \
	      0, \
	      self.samp_rate)  
        # Low pass filter (centered at carrier, with down conversion to zero Hz)
        self.freq_xlating_fir_filter_LP = \
	   filter.freq_xlating_fir_filter_ccc( \
	      1, \
	      (filter.firdes.low_pass(1,self.samp_rate, self.sideband_rx,self.transition)),
	      self.carrier, \
	      self.samp_rate)  
        self.rational_resampler_R = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=self.interpolation,
                taps=None,
                fractional_bw=None,
        )
	# input is the complex modulated signal at baseband.
	# output is a stream of bits packed 1 bit per byte (the LSB)
        # gain_mu: controls rate of mu adjustment (float)
        # mu: fractional delay [0.0, 1.0] (float)
        # omega_relative_limit: sets max variation in omega (float, typically 0.000200 (200 ppm))
        # freq_error: bit rate error as a fraction
        self.digital_gfsk_demod_0 = digital.gfsk_demod(
        	samples_per_symbol=self.sps,
        	sensitivity=self.sensitivity,
        	gain_mu=0.175,
        	mu=0.5,
        	omega_relative_limit=0.005,
        	freq_error=0.0,
        	verbose=False,
        	log=False,
        )      
        self.connect((self, 0), \
	    (self.blocks_float_to_complex_0, 0))
	self.connect((self.blocks_float_to_complex_0, 0), \
	   (self.freq_xlating_fir_filter_BP, 0))  
	self.connect((self.freq_xlating_fir_filter_BP, 0), \
	   (self.freq_xlating_fir_filter_LP, 0))      
        self.connect((self.freq_xlating_fir_filter_LP, 0),
	   (self.rational_resampler_R, 0)) 
        self.connect((self.rational_resampler_R, 0), \
	   (self.digital_gfsk_demod_0, 0))
        self.connect((self.freq_xlating_fir_filter_LP, 0), \
            (self, 2))
        self.connect((self.digital_gfsk_demod_0, 0), \
            (self, 1))
  
        #######################################################################
        # Transmitter 
        # Gaussian Frequency Shift Key (GFSK) modulator
        # input is a byte stream (unsigned char) and the
        # output is the complex modulated signal at baseband.
        self.digital_gfsk_mod = digital.gfsk_mod(
        	samples_per_symbol=self.sps,
        	sensitivity=self.sensitivity,
        	bt=0.35, # Gaussian filter bandwidth * symbol time
        	verbose=False,
        	log=False,
        )
        self.rational_resampler = filter.rational_resampler_ccc(
                # assuming sing at 48,000 samples/sec
                # yields (8 samples/symbol*1800)/48,000 samples/sec=3 symbols/sec
                interpolation=self.interpolation, 
                decimation=1,
                taps=None,
                fractional_bw=None,
        )
        self.freq_xlating_fir_filter = \
	   filter.freq_xlating_fir_filter_ccc( \
              1, \
	      (firdes.band_pass (0.5,self.samp_rate,self.carrier-self.sideband_tx, \
	         self.carrier+self.sideband_tx,self.transition)), \
	      -self.carrier, \
              self.samp_rate)
        self.blocks_complex_to_real = blocks.complex_to_real(1)
        self.blocks_multiply_const = blocks.multiply_const_vff((self.tx_gain,))
        self.blocks_throttle = blocks.throttle(gr.sizeof_gr_complex*1,self.samp_rate,True)
        # Connections
        self.connect((self, 1), \
	   (self.digital_gfsk_mod, 0))  
        self.connect((self.digital_gfsk_mod, 0), \
	   (self.rational_resampler, 0))
        self.connect((self.rational_resampler, 0), 
	   (self.freq_xlating_fir_filter, 0)) 
        self.connect((self.freq_xlating_fir_filter, 0), \
	   (self.blocks_throttle, 0))
        self.connect((self.blocks_throttle, 0), \
           (self.blocks_complex_to_real, 0))
        self.connect((self.blocks_complex_to_real, 0), \
	   (self.blocks_multiply_const, 0))    
        self.connect((self.blocks_multiply_const, 0), \
	   (self, 0))
示例#35
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Lab 4 1 1")
        _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 = 250e3
        self.gain = gain = 40
        self.freq = freq = 89.7e6
        self.audio_rate = audio_rate = 48000
        self.audio_interp = audio_interp = 4

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.samp_rate,
        	callback=self.set_samp_rate,
        	label='Sample Rate',
        	converter=forms.float_converter(),
        )
        self.Add(self._samp_rate_text_box)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	label='Gain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	minimum=0,
        	maximum=90,
        	num_steps=90,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_gain_sizer)
        self._freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.freq,
        	callback=self.set_freq,
        	label='Frequency',
        	converter=forms.float_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=10,
        	ref_level=-30,
        	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.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' )
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(freq, 0)
        self.rtlsdr_source_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_0.set_gain_mode(True, 0)
        self.rtlsdr_source_0.set_gain(gain, 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(0, 0)

        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=audio_rate * audio_interp,
                decimation=int(samp_rate),
                taps=None,
                fractional_bw=None,
        )
        self.audio_sink_0 = audio.sink(audio_rate, '', True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
        	quad_rate=audio_rate * audio_interp,
        	audio_decimation=audio_interp,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_wfm_rcv_0, 0), (self.audio_sink_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.analog_wfm_rcv_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0, 0))
	def __init__(self, samps_per_sym, samp_rate, freq, file_sink, ampl):
		gr.hier_block2.__init__(self, "receive_path",
				gr.io_signature(0, 0, 0), # Input signature
				gr.io_signature(0, 0, 0)) # Output signature

		##################################################
		# Variables
		##################################################
		self.file_sink = file_sink
		self.rx_gain = rx_gain = 5
		self.samps_per_sym = samps_per_sym
		self.samp_rate = samp_rate
		self.freq = freq
		self.ampl = ampl 

		##################################################
		# Blocks
		##################################################
		self.uhd_usrp_source_0 = uhd.usrp_source(
			device_addr="",
			stream_args=uhd.stream_args(
				cpu_format="fc32",
				channels=range(1),
			),
		)
		self.uhd_usrp_source_0.set_samp_rate(samp_rate)
		self.uhd_usrp_source_0.set_center_freq(freq, 0)
		self.uhd_usrp_source_0.set_gain(rx_gain, 0)


		self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
				interpolation=4,
				decimation=125,
				taps=None,
				fractional_bw=None,
		)

		self.digital_dxpsk_demod_0 = digital.dbpsk_demod(
			samples_per_symbol=samps_per_sym,
			excess_bw=0.35,
			freq_bw=6.28/100.0,
			phase_bw=6.28/100.0,
			timing_bw=6.28/100.0,
			mod_code="gray",
			verbose=False,
			log=False)

		self.digital_mpsk_snr_est_cc_0 = digital.mpsk_snr_est_cc(2, 10000, 0.001)

		self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((ampl, ))

		self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, file_sink, True)
		self.blocks_file_sink_0.set_unbuffered(True)

		self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder(
				access_code="",
				threshold=-1,# END TRANSMIT_PATH

				callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload),
			),
		)

		##################################################
		# Connections
		##################################################
		self.connect((self.blocks_multiply_const_vxx_0, 0),(self.digital_mpsk_snr_est_cc_0, 0))
		self.connect((self.digital_mpsk_snr_est_cc_0, 0), (self.digital_dxpsk_demod_0, 0))
		self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0, 0))
		self.connect((self.digital_dxpsk_demod_0, 0), (self.blks2_packet_decoder_0, 0))
		self.connect((self.uhd_usrp_source_0, 0), (self.rational_resampler_xxx_0))
		self.connect((self.rational_resampler_xxx_0,0),(self.blocks_multiply_const_vxx_0,0))
示例#37
0
    def __init__(self,
                 fsk_dev=10000,
                 lpf_cutoff=12.5e3,
                 lpf_trans=1e3,
                 rx_freq=401.5e6,
                 rx_offset=250e3):
        gr.top_block.__init__(self, "Fsk Rx Uhd")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Fsk Rx Uhd")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "fsk_rx_uhd")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.fsk_dev = fsk_dev
        self.lpf_cutoff = lpf_cutoff
        self.lpf_trans = lpf_trans
        self.rx_freq = rx_freq
        self.rx_offset = rx_offset

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 250000
        self.interp = interp = 24
        self.decim = decim = 25 * 5
        self.baud = baud = 9600
        self.samps_per_symb = samps_per_symb = (samp_rate / decim *
                                                interp) / baud
        self.rx_gain = rx_gain = 0
        self.rx_correct = rx_correct = -300

        ##################################################
        # Blocks
        ##################################################
        self._rx_gain_range = Range(0, 86, 1, 0, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        'RX Gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._rx_gain_win, 4, 0, 1, 4)
        self._rx_correct_range = Range(-10000, 10000, 1, -300, 200)
        self._rx_correct_win = RangeWidget(self._rx_correct_range,
                                           self.set_rx_correct, "rx_correct",
                                           "counter_slider", float)
        self.top_grid_layout.addWidget(self._rx_correct_win, 5, 0, 1, 4)
        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(rx_freq + rx_correct, rx_offset), 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_source_0.set_antenna('TX/RX', 0)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=interp,
            decimation=decim,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim * interp,  #bw
            "RX Spectrum",  #name
            2  #number of inputs
        )
        self.qtgui_freq_sink_x_1_0.set_update_time(0.010)
        self.qtgui_freq_sink_x_1_0.set_y_axis(-150, 0)
        self.qtgui_freq_sink_x_1_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_1_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_1_0.enable_grid(True)
        self.qtgui_freq_sink_x_1_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_1_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_1_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_1_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_1_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_1_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_1_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_1_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_1_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_1_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_1_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_0_win, 0, 0,
                                       4, 4)
        self.pyqt_text_output_0 = pyqt.text_output()
        self._pyqt_text_output_0_win = self.pyqt_text_output_0
        self.top_grid_layout.addWidget(self._pyqt_text_output_0_win, 6, 0, 2,
                                       4)
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate / decim * interp, lpf_cutoff,
                            lpf_trans, firdes.WIN_HAMMING, 6.76))
        self.kiss_pdu_to_kiss_0 = kiss.pdu_to_kiss()
        self.kiss_nrzi_decode_0 = kiss.nrzi_decode()
        self.kiss_hdlc_deframer_0 = kiss.hdlc_deframer(check_fcs=True,
                                                       max_length=300)
        self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            samps_per_symb * (1 + 0.0), 0.25 * 0.175 * 0.175, 0.25, 0.175,
            0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_socket_pdu_0_2_0 = blocks.socket_pdu(
            "TCP_SERVER", '0.0.0.0', '8001', 1024, False)
        self.analog_quadrature_demod_cf_1 = analog.quadrature_demod_cf(
            (samp_rate / decim * interp) / (2 * math.pi * fsk_dev / 8.0))
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.kiss_hdlc_deframer_0, 'out'),
                         (self.kiss_pdu_to_kiss_0, 'in'))
        self.msg_connect((self.kiss_pdu_to_kiss_0, 'out'),
                         (self.blocks_socket_pdu_0_2_0, 'pdus'))
        self.msg_connect((self.kiss_pdu_to_kiss_0, 'out'),
                         (self.pyqt_text_output_0, 'pdus'))
        self.connect((self.analog_agc2_xx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.analog_quadrature_demod_cf_1, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.digital_descrambler_bb_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_descrambler_bb_0, 0),
                     (self.kiss_nrzi_decode_0, 0))
        self.connect((self.kiss_nrzi_decode_0, 0),
                     (self.kiss_hdlc_deframer_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.analog_quadrature_demod_cf_1, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.qtgui_freq_sink_x_1_0, 1))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_agc2_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.qtgui_freq_sink_x_1_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.rational_resampler_xxx_0, 0))
示例#38
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.interp = interp = 48
        self.input_rate = input_rate = 100e3
        self.variable_qtgui_range_0 = variable_qtgui_range_0 = 0
        self.samp_rate = samp_rate = interp * input_rate

        ##################################################
        # Blocks
        ##################################################
        self._variable_qtgui_range_0_range = Range(0, 47, 1, 0, 200)
        self._variable_qtgui_range_0_win = RangeWidget(
            self._variable_qtgui_range_0_range,
            self.set_variable_qtgui_range_0, 'Output Gain', "counter_slider",
            int)
        self.top_layout.addWidget(self._variable_qtgui_range_0_win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=interp,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " +
                                           'hackrf=995d5f')
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(437.502e6, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(14, 0)
        self.osmosdr_sink_0.set_if_gain(variable_qtgui_range_0, 0)
        self.osmosdr_sink_0.set_bb_gain(0, 0)
        self.osmosdr_sink_0.set_antenna('', 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)

        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((1, ))
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1, '/home/zacman/RawPing512.iq', True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.osmosdr_sink_0, 0))
示例#39
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Wbfm2")

        ##################################################
        # Variables
        ##################################################
        self.decim = decim = 1
        self.adc_rate = adc_rate = 2000000
        self.xlate_offset_fine_0 = xlate_offset_fine_0 = 0
        self.xlate_offset_fine = xlate_offset_fine = 0
        self.xlate_offset_0 = xlate_offset_0 = 0
        self.xlate_offset = xlate_offset = 0
        self.xlate_decim = xlate_decim = 8
        self.xlate_bandwidth_0 = xlate_bandwidth_0 = 250000
        self.xlate_bandwidth = xlate_bandwidth = 250000
        self.samp_rate = samp_rate = adc_rate / decim
        self.freq_slider_2 = freq_slider_2 = 98.9e6
        self.audio_rate = audio_rate = 48000
        self.audio_interp = audio_interp = 4

        ##################################################
        # Blocks
        ##################################################
        self.main_notebook = self.main_notebook = wx.Notebook(self.GetWin(),
                                                              style=wx.NB_TOP)
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook),
                                   "Baseband")
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook),
                                   "FIR 1")
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook),
                                   "FIR 2")
        self.Add(self.main_notebook)
        _xlate_offset_fine_0_sizer = wx.BoxSizer(wx.VERTICAL)
        self._xlate_offset_fine_0_text_box = forms.text_box(
            parent=self.main_notebook.GetPage(2).GetWin(),
            sizer=_xlate_offset_fine_0_sizer,
            value=self.xlate_offset_fine_0,
            callback=self.set_xlate_offset_fine_0,
            label="Fine Offset",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._xlate_offset_fine_0_slider = forms.slider(
            parent=self.main_notebook.GetPage(2).GetWin(),
            sizer=_xlate_offset_fine_0_sizer,
            value=self.xlate_offset_fine_0,
            callback=self.set_xlate_offset_fine_0,
            minimum=-10000,
            maximum=10000,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.main_notebook.GetPage(2).Add(_xlate_offset_fine_0_sizer)
        _xlate_offset_fine_sizer = wx.BoxSizer(wx.VERTICAL)
        self._xlate_offset_fine_text_box = forms.text_box(
            parent=self.main_notebook.GetPage(1).GetWin(),
            sizer=_xlate_offset_fine_sizer,
            value=self.xlate_offset_fine,
            callback=self.set_xlate_offset_fine,
            label="Fine Offset",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._xlate_offset_fine_slider = forms.slider(
            parent=self.main_notebook.GetPage(1).GetWin(),
            sizer=_xlate_offset_fine_sizer,
            value=self.xlate_offset_fine,
            callback=self.set_xlate_offset_fine,
            minimum=-10000,
            maximum=10000,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.main_notebook.GetPage(1).Add(_xlate_offset_fine_sizer)
        self._xlate_offset_0_text_box = forms.text_box(
            parent=self.main_notebook.GetPage(2).GetWin(),
            value=self.xlate_offset_0,
            callback=self.set_xlate_offset_0,
            label="Xlate Offset",
            converter=forms.float_converter(),
        )
        self.main_notebook.GetPage(2).Add(self._xlate_offset_0_text_box)
        self._xlate_offset_text_box = forms.text_box(
            parent=self.main_notebook.GetPage(1).GetWin(),
            value=self.xlate_offset,
            callback=self.set_xlate_offset,
            label="Xlate Offset",
            converter=forms.float_converter(),
        )
        self.main_notebook.GetPage(1).Add(self._xlate_offset_text_box)
        _xlate_bandwidth_0_sizer = wx.BoxSizer(wx.VERTICAL)
        self._xlate_bandwidth_0_text_box = forms.text_box(
            parent=self.main_notebook.GetPage(2).GetWin(),
            sizer=_xlate_bandwidth_0_sizer,
            value=self.xlate_bandwidth_0,
            callback=self.set_xlate_bandwidth_0,
            label="Xlate Bandwidth",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._xlate_bandwidth_0_slider = forms.slider(
            parent=self.main_notebook.GetPage(2).GetWin(),
            sizer=_xlate_bandwidth_0_sizer,
            value=self.xlate_bandwidth_0,
            callback=self.set_xlate_bandwidth_0,
            minimum=12500,
            maximum=500000,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.main_notebook.GetPage(2).Add(_xlate_bandwidth_0_sizer)
        _xlate_bandwidth_sizer = wx.BoxSizer(wx.VERTICAL)
        self._xlate_bandwidth_text_box = forms.text_box(
            parent=self.main_notebook.GetPage(1).GetWin(),
            sizer=_xlate_bandwidth_sizer,
            value=self.xlate_bandwidth,
            callback=self.set_xlate_bandwidth,
            label="Xlate Bandwidth",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._xlate_bandwidth_slider = forms.slider(
            parent=self.main_notebook.GetPage(1).GetWin(),
            sizer=_xlate_bandwidth_sizer,
            value=self.xlate_bandwidth,
            callback=self.set_xlate_bandwidth,
            minimum=12500,
            maximum=500000,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.main_notebook.GetPage(1).Add(_xlate_bandwidth_sizer)
        _freq_slider_2_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freq_slider_2_text_box = forms.text_box(
            parent=self.main_notebook.GetPage(2).GetWin(),
            sizer=_freq_slider_2_sizer,
            value=self.freq_slider_2,
            callback=self.set_freq_slider_2,
            label='freq_slider_2',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._freq_slider_2_slider = forms.slider(
            parent=self.main_notebook.GetPage(2).GetWin(),
            sizer=_freq_slider_2_sizer,
            value=self.freq_slider_2,
            callback=self.set_freq_slider_2,
            minimum=0,
            maximum=100e6,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.main_notebook.GetPage(2).Add(_freq_slider_2_sizer)
        self.wxgui_waterfallsink2_0_1 = waterfallsink2.waterfall_sink_c(
            self.main_notebook.GetPage(2).GetWin(),
            baseband_freq=0,
            dynamic_range=100,
            ref_level=50,
            ref_scale=2.0,
            sample_rate=samp_rate / xlate_decim,
            fft_size=512,
            fft_rate=30,
            average=False,
            avg_alpha=None,
            title="Waterfall Plot",
        )
        self.main_notebook.GetPage(2).Add(self.wxgui_waterfallsink2_0_1.win)
        self.wxgui_waterfallsink2_0_0 = waterfallsink2.waterfall_sink_c(
            self.main_notebook.GetPage(0).GetWin(),
            baseband_freq=0,
            dynamic_range=100,
            ref_level=50,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=512,
            fft_rate=30,
            average=False,
            avg_alpha=None,
            title="Waterfall Plot",
        )
        self.main_notebook.GetPage(0).Add(self.wxgui_waterfallsink2_0_0.win)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
            self.main_notebook.GetPage(1).GetWin(),
            baseband_freq=0,
            dynamic_range=100,
            ref_level=50,
            ref_scale=2.0,
            sample_rate=samp_rate / xlate_decim,
            fft_size=512,
            fft_rate=30,
            average=False,
            avg_alpha=None,
            title="Waterfall Plot",
        )
        self.main_notebook.GetPage(1).Add(self.wxgui_waterfallsink2_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(98.9e6, 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(2, 0)
        self.rtlsdr_source_0.set_gain_mode(True, 0)
        self.rtlsdr_source_0.set_gain(50, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)

        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
            interpolation=audio_rate * audio_interp,
            decimation=samp_rate / xlate_decim,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=audio_rate * audio_interp,
            decimation=samp_rate / xlate_decim,
            taps=None,
            fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(
            xlate_decim,
            (firdes.low_pass(1, samp_rate, xlate_bandwidth_0 / 2, 1000)),
            xlate_offset_0 + xlate_offset_fine_0 + freq_slider_2, samp_rate)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            xlate_decim,
            (firdes.low_pass(1, samp_rate, xlate_bandwidth / 2, 1000)),
            xlate_offset + xlate_offset_fine, samp_rate)
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_wfm_rcv_0_0 = analog.wfm_rcv(
            quad_rate=audio_rate * audio_interp,
            audio_decimation=4,
        )
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=audio_rate * audio_interp,
            audio_decimation=4,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_wfm_rcv_0, 0), (self.audio_sink_0, 0))
        self.connect((self.analog_wfm_rcv_0_0, 0), (self.audio_sink_0, 1))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0),
                     (self.wxgui_waterfallsink2_0_1, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_wfm_rcv_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.analog_wfm_rcv_0_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.wxgui_waterfallsink2_0_0, 0))
    def __init__(self):
        gr.top_block.__init__(
            self,
            "X310 Phase Calibration, Start Time [UTC]: 2020-08-08T03:19:17.667962Z"
        )
        Qt.QWidget.__init__(self)
        self.setWindowTitle(
            "X310 Phase Calibration, Start Time [UTC]: 2020-08-08T03:19:17.667962Z"
        )
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "x310_phase_cal_2")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.ts_str = ts_str = dt.strftime(dt.utcnow(),
                                           "%Y-%m-%dT%H:%M:%S.%fZ")
        self.phase_shift = phase_shift = 90
        self.phase_deg = phase_deg = 0
        self.title_str = title_str = "X310 Phase Calibration, Start Time [UTC]: {:s}".format(
            ts_str)
        self.samp_rate = samp_rate = .5e6
        self.rx_freq = rx_freq = 4.45e6
        self.phase_rad2 = phase_rad2 = phase_shift * math.pi / 180.0
        self.phase_rad = phase_rad = phase_deg * math.pi / 180.0
        self.phase_delta_avg = phase_delta_avg = 1000
        self.lpf_cutoff = lpf_cutoff = 10e3
        self.decim = decim = 10

        ##################################################
        # Blocks
        ##################################################
        self.main_tab = Qt.QTabWidget()
        self.main_tab_widget_0 = Qt.QWidget()
        self.main_tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                               self.main_tab_widget_0)
        self.main_tab_grid_layout_0 = Qt.QGridLayout()
        self.main_tab_layout_0.addLayout(self.main_tab_grid_layout_0)
        self.main_tab.addTab(self.main_tab_widget_0, 'Channel')
        self.main_tab_widget_1 = Qt.QWidget()
        self.main_tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                               self.main_tab_widget_1)
        self.main_tab_grid_layout_1 = Qt.QGridLayout()
        self.main_tab_layout_1.addLayout(self.main_tab_grid_layout_1)
        self.main_tab.addTab(self.main_tab_widget_1, 'Phase Align')
        self.main_tab_widget_2 = Qt.QWidget()
        self.main_tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                               self.main_tab_widget_2)
        self.main_tab_grid_layout_2 = Qt.QGridLayout()
        self.main_tab_layout_2.addLayout(self.main_tab_grid_layout_2)
        self.main_tab.addTab(self.main_tab_widget_2, 'RHCP_LHCP')
        self.top_grid_layout.addWidget(self.main_tab, 1, 0, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._samp_rate_tool_bar = Qt.QToolBar(self)
        self._samp_rate_tool_bar.addWidget(Qt.QLabel('SAMP_RATE' + ": "))
        self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate))
        self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit)
        self._samp_rate_line_edit.returnPressed.connect(
            lambda: self.set_samp_rate(
                eng_notation.str_to_num(
                    str(self._samp_rate_line_edit.text().toAscii()))))
        self.main_tab_grid_layout_0.addWidget(self._samp_rate_tool_bar, 8, 0,
                                              1, 1)
        for r in range(8, 9):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(0, 1):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self._rx_freq_tool_bar = Qt.QToolBar(self)
        self._rx_freq_tool_bar.addWidget(Qt.QLabel('FREQ' + ": "))
        self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq))
        self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit)
        self._rx_freq_line_edit.returnPressed.connect(lambda: self.set_rx_freq(
            eng_notation.str_to_num(
                str(self._rx_freq_line_edit.text().toAscii()))))
        self.main_tab_grid_layout_0.addWidget(self._rx_freq_tool_bar, 8, 1, 1,
                                              1)
        for r in range(8, 9):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(1, 2):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self._phase_delta_avg_tool_bar = Qt.QToolBar(self)
        self._phase_delta_avg_tool_bar.addWidget(
            Qt.QLabel("phase_delta_avg" + ": "))
        self._phase_delta_avg_line_edit = Qt.QLineEdit(
            str(self.phase_delta_avg))
        self._phase_delta_avg_tool_bar.addWidget(
            self._phase_delta_avg_line_edit)
        self._phase_delta_avg_line_edit.returnPressed.connect(
            lambda: self.set_phase_delta_avg(
                eng_notation.str_to_num(
                    str(self._phase_delta_avg_line_edit.text().toAscii()))))
        self.main_tab_grid_layout_1.addWidget(self._phase_delta_avg_tool_bar,
                                              4, 1, 1, 1)
        for r in range(4, 5):
            self.main_tab_grid_layout_1.setRowStretch(r, 1)
        for c in range(1, 2):
            self.main_tab_grid_layout_1.setColumnStretch(c, 1)
        self._lpf_cutoff_tool_bar = Qt.QToolBar(self)
        self._lpf_cutoff_tool_bar.addWidget(Qt.QLabel('LPF Cutoff' + ": "))
        self._lpf_cutoff_line_edit = Qt.QLineEdit(str(self.lpf_cutoff))
        self._lpf_cutoff_tool_bar.addWidget(self._lpf_cutoff_line_edit)
        self._lpf_cutoff_line_edit.returnPressed.connect(
            lambda: self.set_lpf_cutoff(
                eng_notation.str_to_num(
                    str(self._lpf_cutoff_line_edit.text().toAscii()))))
        self.main_tab_grid_layout_0.addWidget(self._lpf_cutoff_tool_bar, 8, 2,
                                              1, 1)
        for r in range(8, 9):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(2, 3):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self.uhd_usrp_source_1 = uhd.usrp_source(
            ",".join(("addr=192.168.10.2", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(2),
            ),
        )
        self.uhd_usrp_source_1.set_clock_source('internal', 0)
        self.uhd_usrp_source_1.set_time_source('gpsdo', 0)
        self.uhd_usrp_source_1.set_subdev_spec('A:AB B:AB', 0)
        self.uhd_usrp_source_1.set_samp_rate(samp_rate)
        self.uhd_usrp_source_1.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_source_1.set_center_freq(uhd.tune_request(rx_freq), 0)
        self.uhd_usrp_source_1.set_gain(0, 0)
        self.uhd_usrp_source_1.set_antenna('A', 0)
        self.uhd_usrp_source_1.set_auto_dc_offset(True, 0)
        self.uhd_usrp_source_1.set_auto_iq_balance(True, 0)
        self.uhd_usrp_source_1.set_center_freq(uhd.tune_request(rx_freq), 1)
        self.uhd_usrp_source_1.set_gain(0, 1)
        self.uhd_usrp_source_1.set_antenna('A', 1)
        self.uhd_usrp_source_1.set_auto_dc_offset(True, 1)
        self.uhd_usrp_source_1.set_auto_iq_balance(True, 1)
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=decim,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=decim,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0_1 = qtgui.waterfall_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            rx_freq,  #fc
            samp_rate / decim,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0_1.set_update_time(0.010)
        self.qtgui_waterfall_sink_x_0_1.enable_grid(False)
        self.qtgui_waterfall_sink_x_0_1.enable_axis_labels(True)

        if not True:
            self.qtgui_waterfall_sink_x_0_1.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_waterfall_sink_x_0_1.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0_1.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0_1.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0_1.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0_1.set_intensity_range(-140, -40)

        self._qtgui_waterfall_sink_x_0_1_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.main_tab_grid_layout_2.addWidget(
            self._qtgui_waterfall_sink_x_0_1_win, 4, 0, 4, 4)
        for r in range(4, 8):
            self.main_tab_grid_layout_2.setRowStretch(r, 1)
        for c in range(0, 4):
            self.main_tab_grid_layout_2.setColumnStretch(c, 1)
        self.qtgui_waterfall_sink_x_0_0_0 = qtgui.waterfall_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            rx_freq,  #fc
            samp_rate / decim,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0_0_0.set_update_time(0.010)
        self.qtgui_waterfall_sink_x_0_0_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_waterfall_sink_x_0_0_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_waterfall_sink_x_0_0_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0_0_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0_0_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0_0_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0_0_0.set_intensity_range(-140, -40)

        self._qtgui_waterfall_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.main_tab_grid_layout_2.addWidget(
            self._qtgui_waterfall_sink_x_0_0_0_win, 4, 4, 4, 4)
        for r in range(4, 8):
            self.main_tab_grid_layout_2.setRowStretch(r, 1)
        for c in range(4, 8):
            self.main_tab_grid_layout_2.setColumnStretch(c, 1)
        self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            rx_freq,  #fc
            samp_rate / decim,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0_0.set_update_time(0.010)
        self.qtgui_waterfall_sink_x_0_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_waterfall_sink_x_0_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_waterfall_sink_x_0_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0_0.set_intensity_range(-140, -40)

        self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.main_tab_grid_layout_0.addWidget(
            self._qtgui_waterfall_sink_x_0_0_win, 4, 4, 4, 4)
        for r in range(4, 8):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(4, 8):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            rx_freq,  #fc
            samp_rate / decim,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.010)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_waterfall_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, -40)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.main_tab_grid_layout_0.addWidget(
            self._qtgui_waterfall_sink_x_0_win, 4, 0, 4, 4)
        for r in range(4, 8):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(0, 4):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f(
            8192,  #size
            samp_rate / decim,  #samp_rate
            "90 degree shift",  #name
            3  #number of inputs
        )
        self.qtgui_time_sink_x_0_0_0.set_update_time(0.010)
        self.qtgui_time_sink_x_0_0_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0_0_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_NORM,
                                                      qtgui.TRIG_SLOPE_POS,
                                                      0.0, 0, 0, "")
        self.qtgui_time_sink_x_0_0_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0_0_0.enable_grid(True)
        self.qtgui_time_sink_x_0_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0_0_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0_0_0.disable_legend()

        labels = ['N/S', 'E/W', 'Delta', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(3):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.main_tab_grid_layout_1.addWidget(
            self._qtgui_time_sink_x_0_0_0_win, 2, 0, 2, 4)
        for r in range(2, 4):
            self.main_tab_grid_layout_1.setRowStretch(r, 1)
        for c in range(0, 4):
            self.main_tab_grid_layout_1.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            8192,  #size
            samp_rate / decim,  #samp_rate
            "Calibration",  #name
            3  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.010)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_NORM,
                                                    qtgui.TRIG_SLOPE_POS, 0.0,
                                                    0, 0, "")
        self.qtgui_time_sink_x_0_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0_0.enable_grid(True)
        self.qtgui_time_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0_0.disable_legend()

        labels = ['N/S', 'E/W', 'Delta', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(3):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.main_tab_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_0_win,
                                              0, 0, 2, 4)
        for r in range(0, 2):
            self.main_tab_grid_layout_1.setRowStretch(r, 1)
        for c in range(0, 4):
            self.main_tab_grid_layout_1.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0_1 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            rx_freq * 0,  #fc
            samp_rate / decim,  #bw
            "RHCP",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_1.set_update_time(0.010)
        self.qtgui_freq_sink_x_0_1.set_y_axis(-140, 0)
        self.qtgui_freq_sink_x_0_1.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_0_1.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_1.enable_grid(True)
        self.qtgui_freq_sink_x_0_1.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0_1.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_1.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0_1.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0_1.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0_1.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0_1.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0_1.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_1_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.main_tab_grid_layout_2.addWidget(self._qtgui_freq_sink_x_0_1_win,
                                              0, 0, 4, 4)
        for r in range(0, 4):
            self.main_tab_grid_layout_2.setRowStretch(r, 1)
        for c in range(0, 4):
            self.main_tab_grid_layout_2.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0_0_0 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            rx_freq * 0,  #fc
            samp_rate / decim,  #bw
            "LHCP",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_0_0.set_update_time(0.010)
        self.qtgui_freq_sink_x_0_0_0.set_y_axis(-140, 0)
        self.qtgui_freq_sink_x_0_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                      0.0, 0, "")
        self.qtgui_freq_sink_x_0_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0_0.enable_grid(True)
        self.qtgui_freq_sink_x_0_0_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0_0_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0_0_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0_0_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0_0_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0_0_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.main_tab_grid_layout_2.addWidget(
            self._qtgui_freq_sink_x_0_0_0_win, 0, 4, 4, 4)
        for r in range(0, 4):
            self.main_tab_grid_layout_2.setRowStretch(r, 1)
        for c in range(4, 8):
            self.main_tab_grid_layout_2.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            rx_freq * 0,  #fc
            samp_rate / decim,  #bw
            "East/West",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_0.set_update_time(0.010)
        self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 0)
        self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0.enable_grid(True)
        self.qtgui_freq_sink_x_0_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.main_tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_win,
                                              0, 4, 4, 4)
        for r in range(0, 4):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(4, 8):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            rx_freq * 0,  #fc
            samp_rate / decim,  #bw
            "North/South",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.010)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 0)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.main_tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0,
                                              0, 4, 4)
        for r in range(0, 4):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(0, 4):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self._phase_shift_range = Range(0, 359, 1, 90, 200)
        self._phase_shift_win = RangeWidget(self._phase_shift_range,
                                            self.set_phase_shift,
                                            'Phase Shift [deg]',
                                            "counter_slider", float)
        self.main_tab_grid_layout_2.addWidget(self._phase_shift_win, 8, 0, 1,
                                              2)
        for r in range(8, 9):
            self.main_tab_grid_layout_2.setRowStretch(r, 1)
        for c in range(0, 2):
            self.main_tab_grid_layout_2.setColumnStretch(c, 1)
        self._phase_deg_range = Range(0, 359, 1, 0, 200)
        self._phase_deg_win = RangeWidget(self._phase_deg_range,
                                          self.set_phase_deg,
                                          'Phase Shift [deg]',
                                          "counter_slider", float)
        self.main_tab_grid_layout_1.addWidget(self._phase_deg_win, 4, 0, 1, 1)
        for r in range(4, 5):
            self.main_tab_grid_layout_1.setRowStretch(r, 1)
        for c in range(0, 1):
            self.main_tab_grid_layout_1.setColumnStretch(c, 1)
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate / decim, lpf_cutoff, 1e3,
                            firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate / decim, lpf_cutoff, 1e3,
                            firdes.WIN_HAMMING, 6.76))
        self.blocks_sub_xx_0_0 = blocks.sub_ff(1)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_multiply_const_vxx_1_0_0 = blocks.multiply_const_vcc(
            (complex(math.cos(phase_rad2), math.sin(phase_rad2)), ))
        self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vcc(
            (complex(math.cos(phase_rad2), math.sin(phase_rad2)), ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc(
            (complex(math.cos(phase_rad), math.sin(phase_rad)), ))
        self.blocks_moving_average_xx_0_0 = blocks.moving_average_ff(
            int(phase_delta_avg), 1.0 / phase_delta_avg, 4000, 1)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            int(phase_delta_avg), 1.0 / phase_delta_avg, 4000, 1)
        self.blocks_complex_to_real_0_1 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0_0_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_add_xx_0_0 = blocks.add_vcc(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.blocks_abs_xx_0_0 = blocks.abs_ff(1)
        self.blocks_abs_xx_0 = blocks.abs_ff(1)
        self.analog_agc2_xx_1 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_1.set_max_gain(65536)
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.analog_agc2_xx_1, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_abs_xx_0, 0),
                     (self.qtgui_time_sink_x_0_0, 2))
        self.connect((self.blocks_abs_xx_0_0, 0),
                     (self.qtgui_time_sink_x_0_0_0, 2))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.qtgui_freq_sink_x_0_1, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.qtgui_waterfall_sink_x_0_1, 0))
        self.connect((self.blocks_add_xx_0_0, 0),
                     (self.qtgui_freq_sink_x_0_0_0, 0))
        self.connect((self.blocks_add_xx_0_0, 0),
                     (self.qtgui_waterfall_sink_x_0_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_complex_to_real_0_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_complex_to_real_0_0, 0),
                     (self.qtgui_time_sink_x_0_0, 1))
        self.connect((self.blocks_complex_to_real_0_0_0, 0),
                     (self.blocks_sub_xx_0_0, 1))
        self.connect((self.blocks_complex_to_real_0_0_0, 0),
                     (self.qtgui_time_sink_x_0_0_0, 1))
        self.connect((self.blocks_complex_to_real_0_1, 0),
                     (self.blocks_sub_xx_0_0, 0))
        self.connect((self.blocks_complex_to_real_0_1, 0),
                     (self.qtgui_time_sink_x_0_0_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_abs_xx_0, 0))
        self.connect((self.blocks_moving_average_xx_0_0, 0),
                     (self.blocks_abs_xx_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.analog_agc2_xx_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.blocks_complex_to_real_0_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0_0, 0),
                     (self.blocks_add_xx_0_0, 1))
        self.connect((self.blocks_sub_xx_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_sub_xx_0_0, 0),
                     (self.blocks_moving_average_xx_0_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_complex_to_real_0_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_complex_to_real_0_0_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_multiply_const_vxx_1_0_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.qtgui_freq_sink_x_0_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.qtgui_waterfall_sink_x_0_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.blocks_add_xx_0_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.blocks_multiply_const_vxx_1_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.uhd_usrp_source_1, 0), (self.analog_agc2_xx_0, 0))
        self.connect((self.uhd_usrp_source_1, 1),
                     (self.blocks_multiply_const_vxx_1, 0))
示例#41
0
    def __init__(self):
        gr.top_block.__init__(self, "Usrp Echotimer Fsk Tracking Singletarget")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Usrp Echotimer Fsk Tracking Singletarget")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings(
            "GNU Radio", "usrp_echotimer_fsk_tracking_singletarget")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 10000000
        self.samp_per_freq = samp_per_freq = 2
        self.decim_fac = decim_fac = 2**12
        self.block_per_tag = block_per_tag = 2**20
        self.samp_rate_red = samp_rate_red = samp_rate / 2 / samp_per_freq / decim_fac
        self.packet_len_red = packet_len_red = block_per_tag / decim_fac
        self.freq_res = freq_res = samp_rate_red / float(packet_len_red)
        self.fac_corr = fac_corr = 2
        self.delta_freq = delta_freq = 11000000
        self.center_freq = center_freq = 2450000000
        self.wait_to_start = wait_to_start = 0.02
        self.vel_res = vel_res = freq_res / 2.0 / center_freq * 3e8
        self.threshold = threshold = -200
        self.samp_protect = samp_protect = 1
        self.range_time = range_time = 60
        self.range_res = range_res = 3e8 / 2 / delta_freq * fac_corr
        self.min_output_buffer = min_output_buffer = 2 * samp_per_freq * block_per_tag * 2
        self.measure_time = measure_time = (block_per_tag * samp_per_freq *
                                            2) / float(samp_rate)
        self.gain_tx = gain_tx = 10
        self.gain_rx = gain_rx = 10
        self.delay_samp = delay_samp = 39

        ##################################################
        # Blocks
        ##################################################
        self._threshold_range = Range(-200, 100, 1, -200, 200)
        self._threshold_win = RangeWidget(self._threshold_range,
                                          self.set_threshold,
                                          'Find peak threshold',
                                          "counter_slider", float)
        self.top_grid_layout.addWidget(self._threshold_win, 1, 0)
        self._samp_protect_range = Range(0, 100, 1, 1, 200)
        self._samp_protect_win = RangeWidget(self._samp_protect_range,
                                             self.set_samp_protect,
                                             'Find peak protected samples',
                                             "counter_slider", float)
        self.top_grid_layout.addWidget(self._samp_protect_win, 1, 1)
        self._gain_tx_range = Range(0, 100, 1, 10, 200)
        self._gain_tx_win = RangeWidget(self._gain_tx_range, self.set_gain_tx,
                                        'TX gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._gain_tx_win, 0, 0)
        self._gain_rx_range = Range(0, 100, 1, 10, 200)
        self._gain_rx_win = RangeWidget(self._gain_rx_range, self.set_gain_rx,
                                        'RX gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._gain_rx_win, 0, 1)
        self._delay_samp_range = Range(0, 100, 1, 39, 200)
        self._delay_samp_win = RangeWidget(self._delay_samp_range,
                                           self.set_delay_samp,
                                           'Number delay samples',
                                           "counter_slider", float)
        self.top_layout.addWidget(self._delay_samp_win)
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=decim_fac,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=decim_fac,
            taps=None,
            fractional_bw=None,
        )
        self.radar_usrp_echotimer_cc_0 = radar.usrp_echotimer_cc(
            samp_rate, center_freq, int(delay_samp), 'serial=30F4146', '',
            'internal', 'none', 'TX/RX', gain_tx, 0.1, wait_to_start, 0,
            'serial=30F4146', '', 'internal', 'none', 'RX2', gain_rx, 0.1,
            wait_to_start, 0, "packet_len")
        (self.radar_usrp_echotimer_cc_0).set_min_output_buffer(8388608)
        self.radar_ts_fft_cc_0_0 = radar.ts_fft_cc(packet_len_red,
                                                   "packet_len")
        self.radar_ts_fft_cc_0 = radar.ts_fft_cc(packet_len_red, "packet_len")
        self.radar_tracking_singletarget_0 = radar.tracking_singletarget(
            500, range_res / 100, vel_res, 2, 0.001, 1, "particle")
        self.radar_split_fsk_cc_0 = radar.split_fsk_cc(samp_per_freq,
                                                       samp_per_freq - 1,
                                                       "packet_len")
        (self.radar_split_fsk_cc_0).set_min_output_buffer(4194304)
        self.radar_signal_generator_fsk_c_0 = radar.signal_generator_fsk_c(
            samp_rate, samp_per_freq, block_per_tag, -delta_freq / 2,
            delta_freq / 2, 0.5, "packet_len")
        (self.radar_signal_generator_fsk_c_0).set_min_output_buffer(8388608)
        self.radar_qtgui_time_plot_0_1 = radar.qtgui_time_plot(
            100, 'velocity', (-3, 3), range_time, "TRACKING")
        self.radar_qtgui_time_plot_0_0_1 = radar.qtgui_time_plot(
            100, 'range', (0, 15), range_time, "TRACKING")
        self.radar_qtgui_time_plot_0_0 = radar.qtgui_time_plot(
            100, 'range', (0, 15), range_time, '')
        self.radar_qtgui_time_plot_0 = radar.qtgui_time_plot(
            100, 'velocity', (-3, 3), range_time, '')
        self.radar_print_results_1 = radar.print_results(
            False, "store_msgs.txt")
        self.radar_find_max_peak_c_0 = radar.find_max_peak_c(
            samp_rate_red, threshold, int(samp_protect), (), False,
            "packet_len")
        self.radar_estimator_fsk_0 = radar.estimator_fsk(
            center_freq, delta_freq / fac_corr, False)
        self.blocks_tagged_stream_multiply_length_0_0 = blocks.tagged_stream_multiply_length(
            gr.sizeof_gr_complex * 1, "packet_len", 1 / float(decim_fac))
        (self.blocks_tagged_stream_multiply_length_0_0
         ).set_min_output_buffer(512)
        self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(
            gr.sizeof_gr_complex * 1, "packet_len", 1 / float(decim_fac))
        (self.blocks_tagged_stream_multiply_length_0
         ).set_min_output_buffer(512)
        self.blocks_multiply_conjugate_cc_1 = blocks.multiply_conjugate_cc(1)
        (self.blocks_multiply_conjugate_cc_1).set_min_output_buffer(512)
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        (self.blocks_multiply_conjugate_cc_0).set_min_output_buffer(8388608)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.radar_estimator_fsk_0, 'Msg out'),
                         (self.radar_print_results_1, 'Msg in'))
        self.msg_connect((self.radar_estimator_fsk_0, 'Msg out'),
                         (self.radar_qtgui_time_plot_0, 'Msg in'))
        self.msg_connect((self.radar_estimator_fsk_0, 'Msg out'),
                         (self.radar_qtgui_time_plot_0_0, 'Msg in'))
        self.msg_connect((self.radar_estimator_fsk_0, 'Msg out'),
                         (self.radar_tracking_singletarget_0, 'Msg in'))
        self.msg_connect((self.radar_find_max_peak_c_0, 'Msg out'),
                         (self.radar_estimator_fsk_0, 'Msg in'))
        self.msg_connect((self.radar_tracking_singletarget_0, 'Msg out'),
                         (self.radar_qtgui_time_plot_0_0_1, 'Msg in'))
        self.msg_connect((self.radar_tracking_singletarget_0, 'Msg out'),
                         (self.radar_qtgui_time_plot_0_1, 'Msg in'))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0),
                     (self.radar_split_fsk_cc_0, 0))
        self.connect((self.blocks_multiply_conjugate_cc_1, 0),
                     (self.radar_find_max_peak_c_0, 0))
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0),
                     (self.radar_ts_fft_cc_0_0, 0))
        self.connect((self.blocks_tagged_stream_multiply_length_0_0, 0),
                     (self.radar_ts_fft_cc_0, 0))
        self.connect((self.radar_signal_generator_fsk_c_0, 0),
                     (self.blocks_multiply_conjugate_cc_0, 1))
        self.connect((self.radar_signal_generator_fsk_c_0, 0),
                     (self.radar_usrp_echotimer_cc_0, 0))
        self.connect((self.radar_split_fsk_cc_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.radar_split_fsk_cc_0, 1),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.radar_ts_fft_cc_0, 0),
                     (self.blocks_multiply_conjugate_cc_1, 1))
        self.connect((self.radar_ts_fft_cc_0_0, 0),
                     (self.blocks_multiply_conjugate_cc_1, 0))
        self.connect((self.radar_usrp_echotimer_cc_0, 0),
                     (self.blocks_multiply_conjugate_cc_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_tagged_stream_multiply_length_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.blocks_tagged_stream_multiply_length_0_0, 0))
示例#42
0
文件: dectrx.py 项目: znuh/re-DECTed
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Dectrx")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.channel = channel = 1
        self.samp_rate = samp_rate = 2.4e6
        self.rf_gain = rf_gain = 10
        self.ppm = ppm = 0
        self.if_gain = if_gain = 20
        self.freq = freq = 1897.344e6 - (channel * 1.728e6)
        self.dect_rate = dect_rate = 1.152e6
        self.bb_gain = bb_gain = 20

        ##################################################
        # 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.float_converter(),
            proportion=0,
        )
        self._rf_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rf_gain_sizer,
            value=self.rf_gain,
            callback=self.set_rf_gain,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_rf_gain_sizer)
        _ppm_sizer = wx.BoxSizer(wx.VERTICAL)
        self._ppm_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_ppm_sizer,
            value=self.ppm,
            callback=self.set_ppm,
            label="ppm",
            converter=forms.int_converter(),
            proportion=0,
        )
        self._ppm_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_ppm_sizer,
            value=self.ppm,
            callback=self.set_ppm,
            minimum=-70,
            maximum=+70,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_ppm_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.float_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=float,
            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.float_converter(),
            proportion=0,
        )
        self._bb_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_bb_gain_sizer,
            value=self.bb_gain,
            callback=self.set_bb_gain,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_bb_gain_sizer)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
            self.GetWin(),
            baseband_freq=freq,
            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.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=24,
            decimation=25,
            taps=None,
            fractional_bw=None,
        )
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               "")
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(ppm, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(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(dect_rate, 0)

        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, dect_rate, 10e3, firdes.WIN_HAMMING,
                            6.76))
        self.digital_gmsk_demod_0 = digital.gmsk_demod(
            samples_per_symbol=2,
            gain_mu=0.175,
            mu=0.5,
            omega_relative_limit=0.005,
            freq_error=0,
            verbose=False,
            log=False,
        )
        self._channel_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.channel,
            callback=self.set_channel,
            label="channel",
            major_dimension=10,
            choices=[
                0,
                1,
                2,
                3,
                4,
                5,
                6,
                7,
                8,
                9,
                10,
                11,
                12,
                13,
                14,
                15,
                16,
                17,
                18,
                19,
                20,
                21,
                22,
                23,
                24,
                25,
                26,
                27,
                28,
                29,
                30,
                31,
                32,
            ],
            labels=[],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._channel_chooser)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_char * 1,
                                                 "127.0.0.1", 2323, 1472, True)
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_pack_k_bits_bb_0, 0),
                     (self.blocks_udp_sink_0, 0))
        self.connect((self.digital_gmsk_demod_0, 0),
                     (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.digital_gmsk_demod_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.low_pass_filter_0, 0))
示例#43
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 25e3

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=8,
                decimation=1,
                taps=None,
                fractional_bw=None,
        )
        self.qtgui_time_sink_x_3 = qtgui.time_sink_f(
        	500, #size
        	samp_rate, #samp_rate
        	'before_mod', #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_3.set_update_time(0.10)
        self.qtgui_time_sink_x_3.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_3.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_3.enable_tags(-1, True)
        self.qtgui_time_sink_x_3.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_3.enable_autoscale(False)
        self.qtgui_time_sink_x_3.enable_grid(False)
        self.qtgui_time_sink_x_3.enable_axis_labels(True)
        self.qtgui_time_sink_x_3.enable_control_panel(False)

        if not True:
          self.qtgui_time_sink_x_3.disable_legend()

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_3.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_3.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_3.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_3.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_3.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_3.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_3.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_3_win = sip.wrapinstance(self.qtgui_time_sink_x_3.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_3_win)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_c(
        	500, #size
        	samp_rate, #samp_rate
        	'after_resampler', #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_1.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_1.enable_tags(-1, True)
        self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_1.enable_autoscale(False)
        self.qtgui_time_sink_x_1.enable_grid(False)
        self.qtgui_time_sink_x_1.enable_axis_labels(True)
        self.qtgui_time_sink_x_1.enable_control_panel(False)

        if not True:
          self.qtgui_time_sink_x_1.disable_legend()

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2):
            if len(labels[i]) == 0:
                if(i % 2 == 0):
                    self.qtgui_time_sink_x_1.set_line_label(i, "Re{{Data {0}}}".format(i/2))
                else:
                    self.qtgui_time_sink_x_1.set_line_label(i, "Im{{Data {0}}}".format(i/2))
            else:
                self.qtgui_time_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
        	500, #size
        	samp_rate, #samp_rate
        	'after_mod', #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)

        if not True:
          self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2):
            if len(labels[i]) == 0:
                if(i % 2 == 0):
                    self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2))
                else:
                    self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + '' )
        self.osmosdr_sink_0.set_sample_rate(1e6)
        self.osmosdr_sink_0.set_center_freq(1000e6, 0)
        self.osmosdr_sink_0.set_freq_corr(6, 0)
        self.osmosdr_sink_0.set_gain(0, 0)
        self.osmosdr_sink_0.set_if_gain(40, 0)
        self.osmosdr_sink_0.set_bb_gain(30, 0)
        self.osmosdr_sink_0.set_antenna('', 0)
        self.osmosdr_sink_0.set_bandwidth(250e3, 0)

        self.fractional_interpolator_xx_0 = filter.fractional_interpolator_ff(1, 0.875)
        self.before_interpolator = qtgui.time_sink_f(
        	500, #size
        	samp_rate, #samp_rate
        	'before_interpolator', #name
        	1 #number of inputs
        )
        self.before_interpolator.set_update_time(0.10)
        self.before_interpolator.set_y_axis(-1, 1)

        self.before_interpolator.set_y_label('Amplitude', "")

        self.before_interpolator.enable_tags(-1, True)
        self.before_interpolator.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.before_interpolator.enable_autoscale(False)
        self.before_interpolator.enable_grid(False)
        self.before_interpolator.enable_axis_labels(True)
        self.before_interpolator.enable_control_panel(False)

        if not True:
          self.before_interpolator.disable_legend()

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.before_interpolator.set_line_label(i, "Data {0}".format(i))
            else:
                self.before_interpolator.set_line_label(i, labels[i])
            self.before_interpolator.set_line_width(i, widths[i])
            self.before_interpolator.set_line_color(i, colors[i])
            self.before_interpolator.set_line_style(i, styles[i])
            self.before_interpolator.set_line_marker(i, markers[i])
            self.before_interpolator.set_line_alpha(i, alphas[i])

        self._before_interpolator_win = sip.wrapinstance(self.before_interpolator.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._before_interpolator_win)
        self.analog_wfm_tx_0 = analog.wfm_tx(
        	audio_rate=int(32e3),
        	quad_rate=int(320e3),
        	tau=3e-6,
        	max_dev=50e3,
        	fh=0,
        )
        self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_SQR_WAVE, 1000, 1, 0)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.analog_wfm_tx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.before_interpolator, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.fractional_interpolator_xx_0, 0))
        self.connect((self.analog_wfm_tx_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.analog_wfm_tx_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.fractional_interpolator_xx_0, 0), (self.qtgui_time_sink_x_3, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.osmosdr_sink_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_time_sink_x_1, 0))
    def __init__(self):
        gr.top_block.__init__(self, "10Ghz 2de Garmonic with hackrf")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("10Ghz 2de Garmonic with hackrf")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio",
                                     "The_10G_second_harmonic_hackrf")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(
                    self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = 10352560000
        self.variable_qtgui_range_0_0_0_0 = variable_qtgui_range_0_0_0_0 = 50
        self.variable_qtgui_range_0_0_0 = variable_qtgui_range_0_0_0 = 60
        self.variable_qtgui_range_0_0 = variable_qtgui_range_0_0 = 60
        self.variable_qtgui_range_0 = variable_qtgui_range_0 = 2.5e3
        self.variable_qtgui_label_0 = variable_qtgui_label_0 = variable_qtgui_range_0_1 / 2
        self.variable_qtgui_chooser_PTT_0 = variable_qtgui_chooser_PTT_0 = 0
        self.samp_rate = samp_rate = 4800000

        ##################################################
        # Blocks
        ##################################################
        self._variable_qtgui_range_0_1_range = Range(10338000000, 10702000000,
                                                     1, 10352560000, 200)
        self._variable_qtgui_range_0_1_win = RangeWidget(
            self._variable_qtgui_range_0_1_range,
            self.set_variable_qtgui_range_0_1, 'Frequency', "counter_slider",
            float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_1_win)
        self._variable_qtgui_range_0_0_0_0_range = Range(5, 60, 1, 50, 200)
        self._variable_qtgui_range_0_0_0_0_win = RangeWidget(
            self._variable_qtgui_range_0_0_0_0_range,
            self.set_variable_qtgui_range_0_0_0_0, 'bb_power',
            "counter_slider", float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_0_0_0_win)
        self._variable_qtgui_range_0_0_0_range = Range(5, 60, 1, 60, 200)
        self._variable_qtgui_range_0_0_0_win = RangeWidget(
            self._variable_qtgui_range_0_0_0_range,
            self.set_variable_qtgui_range_0_0_0, 'if_power', "counter_slider",
            float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_0_0_win)
        self._variable_qtgui_range_0_0_range = Range(10, 65, 1, 60, 200)
        self._variable_qtgui_range_0_0_win = RangeWidget(
            self._variable_qtgui_range_0_0_range,
            self.set_variable_qtgui_range_0_0, 'tx_power', "counter_slider",
            float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_0_win)
        self._variable_qtgui_range_0_range = Range(0, 12.5e3, 1, 2.5e3, 200)
        self._variable_qtgui_range_0_win = RangeWidget(
            self._variable_qtgui_range_0_range,
            self.set_variable_qtgui_range_0, 'div', "counter_slider", float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_win)
        # Create the options list
        self._variable_qtgui_chooser_PTT_0_options = (
            0,
            1,
        )
        # Create the labels list
        self._variable_qtgui_chooser_PTT_0_labels = (
            'TX',
            'RX',
        )
        # Create the combo box
        self._variable_qtgui_chooser_PTT_0_tool_bar = Qt.QToolBar(self)
        self._variable_qtgui_chooser_PTT_0_tool_bar.addWidget(
            Qt.QLabel('PTT' + ": "))
        self._variable_qtgui_chooser_PTT_0_combo_box = Qt.QComboBox()
        self._variable_qtgui_chooser_PTT_0_tool_bar.addWidget(
            self._variable_qtgui_chooser_PTT_0_combo_box)
        for _label in self._variable_qtgui_chooser_PTT_0_labels:
            self._variable_qtgui_chooser_PTT_0_combo_box.addItem(_label)
        self._variable_qtgui_chooser_PTT_0_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._variable_qtgui_chooser_PTT_0_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._variable_qtgui_chooser_PTT_0_options.index(i)
                     ))
        self._variable_qtgui_chooser_PTT_0_callback(
            self.variable_qtgui_chooser_PTT_0)
        self._variable_qtgui_chooser_PTT_0_combo_box.currentIndexChanged.connect(
            lambda i: self.set_variable_qtgui_chooser_PTT_0(
                self._variable_qtgui_chooser_PTT_0_options[i]))
        # Create the radio buttons
        self.top_grid_layout.addWidget(
            self._variable_qtgui_chooser_PTT_0_tool_bar)
        self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self)

        if None:
            self._variable_qtgui_label_0_formatter = None
        else:
            self._variable_qtgui_label_0_formatter = lambda x: eng_notation.num_to_str(
                x)

        self._variable_qtgui_label_0_tool_bar.addWidget(
            Qt.QLabel('freq' + ": "))
        self._variable_qtgui_label_0_label = Qt.QLabel(
            str(
                self._variable_qtgui_label_0_formatter(
                    self.variable_qtgui_label_0)))
        self._variable_qtgui_label_0_tool_bar.addWidget(
            self._variable_qtgui_label_0_label)
        self.top_grid_layout.addWidget(self._variable_qtgui_label_0_tool_bar)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=10, decimation=1, taps=None, fractional_bw=None)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1)
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " +
                                           'hackrf=0')
        self.osmosdr_sink_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(variable_qtgui_range_0_1 / 2, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(variable_qtgui_range_0_0, 0)
        self.osmosdr_sink_0.set_if_gain(variable_qtgui_range_0_0_0, 0)
        self.osmosdr_sink_0.set_bb_gain(variable_qtgui_range_0_0_0_0, 0)
        self.osmosdr_sink_0.set_antenna('', 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)
        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            '/home/anton/gnuradio-grc-examples/test_audio.wav', True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, 48000,
                                                 True)
        self.blocks_selector_0 = blocks.selector(gr.sizeof_gr_complex * 1,
                                                 variable_qtgui_chooser_PTT_0,
                                                 0)
        self.blocks_selector_0.set_enabled(True)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(1)
        self.analog_nbfm_tx_0_0 = analog.nbfm_tx(
            audio_rate=48000,
            quad_rate=480000,
            tau=75e-6,
            max_dev=variable_qtgui_range_0,
            fh=-1.0,
        )
        self.analog_const_source_x_0_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0_0, 0),
                     (self.blocks_selector_0, 1))
        self.connect((self.analog_nbfm_tx_0_0, 0), (self.blocks_selector_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_selector_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.analog_nbfm_tx_0_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.osmosdr_sink_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
示例#45
0
    def __init__(self, bb_gain=20, destination="localhost", freq=0, freq_corr=0, gpredict_port=4532, if_gain=20, offset=50e3, port=7355, rf_gain=40):
        gr.top_block.__init__(self, "Wide SSB receiver for an Airspy device")

        ##################################################
        # Parameters
        ##################################################
        self.bb_gain = bb_gain
        self.destination = destination
        self.freq = freq
        self.freq_corr = freq_corr
        self.gpredict_port = gpredict_port
        self.if_gain = if_gain
        self.offset = offset
        self.port = port
        self.rf_gain = rf_gain

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2.5e6
        self.doppler_freq = doppler_freq = freq

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=24,
                decimation=25,
                taps=None,
                fractional_bw=None,
        )
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq-offset, 0)
        self.osmosdr_source_0.set_freq_corr(freq_corr, 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.gpredict_doppler_0 = gpredict.doppler(self.set_doppler_freq, "localhost", 4532, False)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(50, (firdes.low_pass(1, samp_rate, 12000, 500)), doppler_freq-freq+offset, samp_rate)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short*1, destination, port, 1472, True)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_float_to_short_0 = blocks.float_to_short(1, 32767)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(48000, analog.GR_COS_WAVE, 12000, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_float_to_short_0, 0))    
        self.connect((self.blocks_float_to_short_0, 0), (self.blocks_udp_sink_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_real_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 1))    
示例#46
0
    def __init__(self):
        gr.top_block.__init__(self, "Meteor QPSK LRPT")

        # get some variables in place for inputs
        #
        # Arguments:
        #   1. Full path and name of stream file (including file extension)
        #   2. Gain to be used
        #   3. Frequency offset (PPM)
        stream_name = sys.argv[1]
        gain = float(sys.argv[2])
        freq_offset = int(sys.argv[3])

        ##################################################
        # Variables
        ##################################################
        self.samp_rate_airspy = samp_rate_airspy = 1250000
        self.decim = decim = 8
        self.symb_rate = symb_rate = 72000
        self.samp_rate = samp_rate = samp_rate_airspy / decim
        self.sps = sps = (samp_rate * 1.0) / (symb_rate * 1.0)
        self.pll_alpha = pll_alpha = 0.006
        self.freq = freq = 137100000
        self.clock_alpha = clock_alpha = 0.002
        self.bitstream_name = bitstream_name = stream_name

        ##################################################
        # Blocks
        ##################################################
        self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              '')
        self.rtlsdr_source_0.set_sample_rate(samp_rate_airspy)
        self.rtlsdr_source_0.set_center_freq(freq, 0)
        self.rtlsdr_source_0.set_freq_corr(freq_offset, 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(gain, 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(1500000, 0)

        self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(
            1, firdes.root_raised_cosine(1, samp_rate, symb_rate, 0.6, 361))
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=decim,
            taps=None,
            fractional_bw=None,
        )
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            pll_alpha, 4, False)
        self.digital_constellation_soft_decoder_cf_1 = digital.constellation_soft_decoder_cf(
            digital.constellation_calcdist(
                ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4,
                1).base())
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc(
            sps, clock_alpha**2 / 4.0, 0.5, clock_alpha, 0.005)
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 127)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   bitstream_name, False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.analog_rail_ff_0 = analog.rail_ff(-1, 1)
        self.analog_agc_xx_0 = analog.agc_cc(1000e-4, 0.5, 1.0)
        self.analog_agc_xx_0.set_max_gain(4000)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0),
                     (self.root_raised_cosine_filter_0, 0))
        self.connect((self.analog_rail_ff_0, 0),
                     (self.blocks_float_to_char_0, 0))
        self.connect((self.blocks_float_to_char_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_constellation_soft_decoder_cf_1, 0))
        self.connect((self.digital_constellation_soft_decoder_cf_1, 0),
                     (self.analog_rail_ff_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_agc_xx_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.rational_resampler_xxx_0, 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 = 2e6
        self.fc = fc = 1147.5e6

        ##################################################
        # Blocks
        ##################################################
        _fc_sizer = wx.BoxSizer(wx.VERTICAL)
        self._fc_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_fc_sizer,
        	value=self.fc,
        	callback=self.set_fc,
        	label='fc',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._fc_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_fc_sizer,
        	value=self.fc,
        	callback=self.set_fc,
        	minimum=1146.5e6,
        	maximum=1150e6,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_fc_sizer)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=samp_rate,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate/100,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0_0.win)
        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(fc, 0)
        self.rtlsdr_source_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(10, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
          
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=100,
                taps=None,
                fractional_bw=None,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.rational_resampler_xxx_0, 0), (self.wxgui_fftsink2_0_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_scopesink2_0, 0))    
示例#48
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 250e3
        self.gain = gain = 40
        self.freq = freq = 435e6
        self.audio_rate = audio_rate = 48000
        self.audio_interp = audio_interp = 4

        ##################################################
        # Blocks
        ##################################################
        self._gain_range = Range(0, 74, 1, 40, 200)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain, 'gain',
                                     "counter_slider", float)
        self.top_layout.addWidget(self._gain_win)
        self._freq_range = Range(400e6, 60e9, 1000, 435e6, 200)
        self._freq_win = RangeWidget(self._freq_range, self.set_freq, 'freq',
                                     "counter_slider", float)
        self.top_layout.addWidget(self._freq_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.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=int(1.05 * (audio_rate * audio_interp)),
            decimation=int(samp_rate),
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_sink_x_0 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            'QT GUI Plot',  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_win)

        self.qtgui_sink_x_0.enable_rf_freq(True)

        self.audio_sink_0 = audio.sink(audio_rate, '', False)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=audio_rate * audio_interp,
            audio_decimation=audio_interp,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_wfm_rcv_0, 0), (self.audio_sink_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_wfm_rcv_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_sink_x_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.rational_resampler_xxx_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Bpsk Receiverpoly")

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 8
        self.probe_var = probe_var = 0
        self.nfilts = nfilts = 32
        self.eb = eb = 0.35
        self.SNR = SNR = 500
        self.transistion = transistion = 100
        self.timing_loop_bw = timing_loop_bw = 6.28 / 100.0
        self.sideband_rx = sideband_rx = 500
        self.sideband = sideband = 500
        self.samp_rate = samp_rate = 48000
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts / 16, nfilts / 16, 1.0 / float(sps), 0.35,
            11 * sps * nfilts / 16)
        self.qpsk = qpsk = digital.constellation_rect(([
            0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j
        ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.probe_var_n = probe_var_n = 0
        self.preamble = preamble = [
            1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1,
            -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1,
            -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1,
            1, 1, 1, 1, 1, -1, -1
        ]
        self.phase_bw = phase_bw = 6.28 / 100.0
        self.noise_amp = noise_amp = probe_var / (10**(SNR / 20))
        self.matched_filter = matched_filter = firdes.root_raised_cosine(
            nfilts, nfilts, 1, eb, int(11 * sps * nfilts))
        self.interpolation = interpolation = 2000
        self.eq_gain = eq_gain = 0.01
        self.delay = delay = 0
        self.decimation = decimation = 1
        self.constel = constel = digital.constellation_calcdist(
            ([1, -1]), ([0, 1]), 2, 1).base()
        self.carrier = carrier = 10000
        self.arity = arity = 2

        ##################################################
        # Blocks
        ##################################################
        self.probe_rms = blocks.probe_signal_f()
        self.probe_avg_n = blocks.probe_signal_f()
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
            interpolation=decimation,
            decimation=interpolation,
            taps=(rrc_taps),
            fractional_bw=None,
        )

        def _probe_var_n_probe():
            while True:
                val = self.probe_avg_n.level()
                try:
                    self.set_probe_var_n(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))

        _probe_var_n_thread = threading.Thread(target=_probe_var_n_probe)
        _probe_var_n_thread.daemon = True
        _probe_var_n_thread.start()

        def _probe_var_probe():
            while True:
                val = self.probe_rms.level()
                try:
                    self.set_probe_var(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))

        _probe_var_thread = threading.Thread(target=_probe_var_probe)
        _probe_var_thread.daemon = True
        _probe_var_thread.start()
        self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(
            1, (filter.firdes.low_pass(1, samp_rate * 10, sideband_rx, 1000)),
            carrier, samp_rate)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, timing_loop_bw, (rrc_taps), nfilts * 2, nfilts / 2, 1.5, 1)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            phase_bw, arity, False)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            constel)

        script, SNRinput, inputwav, outputBinary, delay = argv

        self.blocks_wavfile_source_0 = blocks.wavfile_source(inputwav, False)
        self.blocks_throttle_1_0_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                     samp_rate, True)
        self.blocks_rms_xx_1 = blocks.rms_cf(0.01)
        self.blocks_rms_xx_0 = blocks.rms_cf(0.01)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   outputBinary, False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_delay_1 = blocks.delay(gr.sizeof_char * 1, int(delay))
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, noise_amp, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_rms_xx_1, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.blocks_delay_1, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0_0, 0))
        self.connect((self.blocks_rms_xx_0, 0), (self.probe_rms, 0))
        self.connect((self.blocks_rms_xx_1, 0), (self.probe_avg_n, 0))
        self.connect((self.blocks_throttle_1_0_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_throttle_1_0_0, 0),
                     (self.blocks_rms_xx_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blocks_delay_1, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.blocks_throttle_1_0_0, 0))
示例#50
0
    def __init__(self):
        gr.top_block.__init__(self, "TGS FM Transciever")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("TGS FM Transciever")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "fm_transciever")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.rx_center_freq = rx_center_freq = 100e6
        self.doppler_freq = doppler_freq = rx_center_freq
        self.tx_ptt = tx_ptt = 1
        self.tx_gain = tx_gain = 30
        self.tx_freq = tx_freq = 100e6
        self.samp_rate = samp_rate = 250e3
        self.rx_switch = rx_switch = 1
        self.rx_mode = rx_mode = 1
        self.rx_gain = rx_gain = 30
        self.doppler_shift = doppler_shift = int(doppler_freq - rx_center_freq)
        self.doppler_mode = doppler_mode = 0
        self.audio_rate = audio_rate = 48e3
        self.audio_interp = audio_interp = 4

        ##################################################
        # Blocks
        ##################################################
        self.wrapper = Qt.QTabWidget()
        self.wrapper_widget_0 = Qt.QWidget()
        self.wrapper_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                              self.wrapper_widget_0)
        self.wrapper_grid_layout_0 = Qt.QGridLayout()
        self.wrapper_layout_0.addLayout(self.wrapper_grid_layout_0)
        self.wrapper.addTab(self.wrapper_widget_0, 'RX')
        self.wrapper_widget_1 = Qt.QWidget()
        self.wrapper_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                              self.wrapper_widget_1)
        self.wrapper_grid_layout_1 = Qt.QGridLayout()
        self.wrapper_layout_1.addLayout(self.wrapper_grid_layout_1)
        self.wrapper.addTab(self.wrapper_widget_1, 'TX')
        self.top_layout.addWidget(self.wrapper)
        _tx_ptt_push_button = Qt.QPushButton('PTT')
        self._tx_ptt_choices = {'Pressed': 0, 'Released': 1}
        _tx_ptt_push_button.pressed.connect(
            lambda: self.set_tx_ptt(self._tx_ptt_choices['Pressed']))
        _tx_ptt_push_button.released.connect(
            lambda: self.set_tx_ptt(self._tx_ptt_choices['Released']))
        self.wrapper_grid_layout_1.addWidget(_tx_ptt_push_button, 1, 0, 1, 4)
        self._tx_gain_range = Range(0, 90, 1, 30, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain,
                                        'TX Gain', "counter_slider", float)
        self.wrapper_grid_layout_1.addWidget(self._tx_gain_win, 0, 2, 1, 2)
        self._tx_freq_tool_bar = Qt.QToolBar(self)
        self._tx_freq_tool_bar.addWidget(Qt.QLabel('TX Freq' + ": "))
        self._tx_freq_line_edit = Qt.QLineEdit(str(self.tx_freq))
        self._tx_freq_tool_bar.addWidget(self._tx_freq_line_edit)
        self._tx_freq_line_edit.returnPressed.connect(lambda: self.set_tx_freq(
            eng_notation.str_to_num(
                str(self._tx_freq_line_edit.text().toAscii()))))
        self.wrapper_grid_layout_1.addWidget(self._tx_freq_tool_bar, 0, 0, 1,
                                             2)
        _rx_switch_check_box = Qt.QCheckBox('RX Switch')
        self._rx_switch_choices = {True: 0, False: 1}
        self._rx_switch_choices_inv = dict(
            (v, k) for k, v in self._rx_switch_choices.iteritems())
        self._rx_switch_callback = lambda i: Qt.QMetaObject.invokeMethod(
            _rx_switch_check_box, "setChecked",
            Qt.Q_ARG("bool", self._rx_switch_choices_inv[i]))
        self._rx_switch_callback(self.rx_switch)
        _rx_switch_check_box.stateChanged.connect(
            lambda i: self.set_rx_switch(self._rx_switch_choices[bool(i)]))
        self.wrapper_grid_layout_0.addWidget(_rx_switch_check_box, 1, 0, 1, 2)
        self._rx_mode_options = (
            0,
            1,
        )
        self._rx_mode_labels = (
            'NBFM RX',
            'WBFM RX',
        )
        self._rx_mode_tool_bar = Qt.QToolBar(self)
        self._rx_mode_tool_bar.addWidget(Qt.QLabel('RX Mode' + ": "))
        self._rx_mode_combo_box = Qt.QComboBox()
        self._rx_mode_tool_bar.addWidget(self._rx_mode_combo_box)
        for label in self._rx_mode_labels:
            self._rx_mode_combo_box.addItem(label)
        self._rx_mode_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._rx_mode_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._rx_mode_options.index(i)))
        self._rx_mode_callback(self.rx_mode)
        self._rx_mode_combo_box.currentIndexChanged.connect(
            lambda i: self.set_rx_mode(self._rx_mode_options[i]))
        self.wrapper_grid_layout_0.addWidget(self._rx_mode_tool_bar, 1, 2, 1,
                                             2)
        self._rx_gain_range = Range(0, 90, 1, 30, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        'RX gain', "counter_slider", float)
        self.wrapper_grid_layout_0.addWidget(self._rx_gain_win, 0, 2, 1, 2)
        self._rx_center_freq_tool_bar = Qt.QToolBar(self)
        self._rx_center_freq_tool_bar.addWidget(Qt.QLabel('RX Freq' + ": "))
        self._rx_center_freq_line_edit = Qt.QLineEdit(str(self.rx_center_freq))
        self._rx_center_freq_tool_bar.addWidget(self._rx_center_freq_line_edit)
        self._rx_center_freq_line_edit.returnPressed.connect(
            lambda: self.set_rx_center_freq(
                eng_notation.str_to_num(
                    str(self._rx_center_freq_line_edit.text().toAscii()))))
        self.wrapper_grid_layout_0.addWidget(self._rx_center_freq_tool_bar, 0,
                                             0, 1, 2)
        self._doppler_shift_tool_bar = Qt.QToolBar(self)

        if None:
            self._doppler_shift_formatter = None
        else:
            self._doppler_shift_formatter = lambda x: x

        self._doppler_shift_tool_bar.addWidget(
            Qt.QLabel('Doppler Shift' + ": "))
        self._doppler_shift_label = Qt.QLabel(
            str(self._doppler_shift_formatter(self.doppler_shift)))
        self._doppler_shift_tool_bar.addWidget(self._doppler_shift_label)
        self.top_layout.addWidget(self._doppler_shift_tool_bar)

        _doppler_mode_check_box = Qt.QCheckBox('Doppler correction')
        self._doppler_mode_choices = {True: 1, False: 0}
        self._doppler_mode_choices_inv = dict(
            (v, k) for k, v in self._doppler_mode_choices.iteritems())
        self._doppler_mode_callback = lambda i: Qt.QMetaObject.invokeMethod(
            _doppler_mode_check_box, "setChecked",
            Qt.Q_ARG("bool", self._doppler_mode_choices_inv[i]))
        self._doppler_mode_callback(self.doppler_mode)
        _doppler_mode_check_box.stateChanged.connect(
            lambda i: self.set_doppler_mode(self._doppler_mode_choices[bool(i)]
                                            ))
        self.top_layout.addWidget(_doppler_mode_check_box)
        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(rx_center_freq, 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(tx_freq, 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
            interpolation=int(samp_rate),
            decimation=int(audio_interp * audio_rate),
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=int(audio_rate * audio_interp),
            decimation=int(samp_rate),
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "RX Waterfall",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_waterfall_sink_x_0_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_waterfall_sink_x_0_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0_0.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.wrapper_grid_layout_0.addWidget(
            self._qtgui_waterfall_sink_x_0_0_win, 2, 2, 1, 2)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "TX Waterfall",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_waterfall_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.wrapper_grid_layout_1.addWidget(
            self._qtgui_waterfall_sink_x_0_win, 2, 2, 1, 2)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "RX FFT",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_0_0.enable_autoscale(True)
        self.qtgui_freq_sink_x_0_0.enable_grid(True)
        self.qtgui_freq_sink_x_0_0.set_fft_average(0.1)
        self.qtgui_freq_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.wrapper_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_win,
                                             2, 0, 1, 2)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "TX  FFT",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(True)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.1)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.wrapper_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_win, 2,
                                             0, 1, 2)
        self.gpredict_doppler_0_0 = gpredict.doppler(self.set_doppler_freq,
                                                     "localhost", 4532, True)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blks2_valve_0_0 = grc_blks2.valve(item_size=gr.sizeof_gr_complex *
                                               1,
                                               open=bool(rx_switch))
        self.blks2_valve_0 = grc_blks2.valve(item_size=gr.sizeof_float * 1,
                                             open=bool(tx_ptt))
        self.blks2_selector_1_0 = grc_blks2.selector(
            item_size=gr.sizeof_gr_complex * 1,
            num_inputs=2,
            num_outputs=1,
            input_index=doppler_mode,
            output_index=0,
        )
        self.blks2_selector_1 = grc_blks2.selector(
            item_size=gr.sizeof_float * 1,
            num_inputs=2,
            num_outputs=1,
            input_index=rx_mode,
            output_index=0,
        )
        self.blks2_selector_0 = grc_blks2.selector(
            item_size=gr.sizeof_gr_complex * 1,
            num_inputs=1,
            num_outputs=2,
            input_index=0,
            output_index=rx_mode,
        )
        self.audio_source_0 = audio.source(int(audio_rate), '', True)
        self.audio_sink_0 = audio.sink(int(audio_rate), '', True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=audio_interp * audio_rate,
            audio_decimation=audio_interp,
        )
        self.analog_sig_source_x_1 = analog.sig_source_c(
            int(audio_rate * audio_interp), analog.GR_COS_WAVE, doppler_shift,
            1, 0)
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
            audio_rate=int(audio_rate),
            quad_rate=int(audio_rate * audio_interp),
            tau=75e-6,
            max_dev=5e3,
            fh=-1.0,
        )
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=int(audio_rate),
            quad_rate=int(audio_rate * audio_interp),
            tau=75e-6,
            max_dev=5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.blks2_selector_1, 0))
        self.connect((self.analog_nbfm_tx_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_wfm_rcv_0, 0), (self.blks2_selector_1, 1))
        self.connect((self.audio_source_0, 0), (self.blks2_valve_0, 0))
        self.connect((self.blks2_selector_0, 0), (self.analog_nbfm_rx_0, 0))
        self.connect((self.blks2_selector_0, 1), (self.analog_wfm_rcv_0, 0))
        self.connect((self.blks2_selector_1, 0), (self.audio_sink_0, 0))
        self.connect((self.blks2_selector_1_0, 0), (self.blks2_selector_0, 0))
        self.connect((self.blks2_valve_0, 0), (self.analog_nbfm_tx_0, 0))
        self.connect((self.blks2_valve_0_0, 0),
                     (self.qtgui_freq_sink_x_0_0, 0))
        self.connect((self.blks2_valve_0_0, 0),
                     (self.qtgui_waterfall_sink_x_0_0, 0))
        self.connect((self.blks2_valve_0_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blks2_selector_1_0, 1))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blks2_selector_1_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.blks2_valve_0_0, 0))
示例#51
0
    def __init__(self):
        gr.top_block.__init__(self, "Hd Tx Am Ma3 Hackrf")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2000000
        self.freq = freq = 1710e3

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_2 = filter.rational_resampler_ccc(
                interpolation=4096,
                decimation=243,
                taps=None,
                fractional_bw=None)
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
                interpolation=125,
                decimation=49,
                taps=None,
                fractional_bw=None)
        self.osmosdr_sink_0 = osmosdr.sink(
            args="numchan=" + str(1) + " " + ""
        )
        self.osmosdr_sink_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(freq + 100000, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(0, 0)
        self.osmosdr_sink_0.set_if_gain(1, 0)
        self.osmosdr_sink_0.set_bb_gain(20, 0)
        self.osmosdr_sink_0.set_antenna('', 0)
        self.osmosdr_sink_0.set_bandwidth(1.5e6, 0)
        self.nrsc5_sis_encoder_0 = nrsc5.sis_encoder('ABCD')
        self.nrsc5_psd_encoder_0 = nrsc5.psd_encoder(0, 'Title', 'Artist')
        self.nrsc5_l2_encoder_0 = nrsc5.l2_encoder(1, 0, 3750)
        self.nrsc5_l1_am_encoder_ma3_0 = nrsc5.l1_am_encoder(3)
        self.nrsc5_hdc_encoder_0 = nrsc5.hdc_encoder(2, 17900)
        self.fft_vxx_0 = fft.fft_vcc(256, False, window.rectangular(256), True, 1)
        self.blocks_wavfile_source_0 = blocks.wavfile_source('sample.wav', True)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 256)
        self.blocks_vector_source_x_0 = blocks.vector_source_c([math.sin(math.pi / 2 * i / 14) for i in range(14)] + [1] * (256-14) + [math.cos(math.pi / 2 * i / 14) for i in range(14)], True, 1, [])
        self.blocks_rotator_cc_0 = blocks.rotator_cc(-2 * math.pi * 100000 / samp_rate)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*256, 2)
        self.blocks_null_source_0 = blocks.null_source(gr.sizeof_char*30000)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(0.1)
        self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(gr.sizeof_gr_complex, 270, 512, 121)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_keep_m_in_n_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_rotator_cc_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_1, 0))
        self.connect((self.blocks_null_source_0, 0), (self.nrsc5_l1_am_encoder_ma3_0, 1))
        self.connect((self.blocks_repeat_0, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.blocks_rotator_cc_0, 0), (self.osmosdr_sink_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_keep_m_in_n_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0), (self.nrsc5_hdc_encoder_0, 0))
        self.connect((self.blocks_wavfile_source_0, 1), (self.nrsc5_hdc_encoder_0, 1))
        self.connect((self.fft_vxx_0, 0), (self.blocks_repeat_0, 0))
        self.connect((self.nrsc5_hdc_encoder_0, 0), (self.nrsc5_l2_encoder_0, 0))
        self.connect((self.nrsc5_l1_am_encoder_ma3_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.nrsc5_l2_encoder_0, 0), (self.nrsc5_l1_am_encoder_ma3_0, 0))
        self.connect((self.nrsc5_psd_encoder_0, 0), (self.nrsc5_l2_encoder_0, 1))
        self.connect((self.nrsc5_sis_encoder_0, 0), (self.nrsc5_l1_am_encoder_ma3_0, 2))
        self.connect((self.rational_resampler_xxx_1, 0), (self.rational_resampler_xxx_2, 0))
        self.connect((self.rational_resampler_xxx_2, 0), (self.blocks_multiply_const_vxx_0, 0))
示例#52
0
    def __init__(self,
                 bb_gain=1,
                 gs_name='MGS',
                 ip='0.0.0.0',
                 iq_file='./rocksat_125kbd_500ksps_date_comment.dat',
                 meta_rate=.1,
                 port='52001',
                 record_iq=0,
                 record_rfo=0,
                 record_snr=0,
                 rfo_file='./rocksat_rfo_date_comment.meta',
                 snr_file='./rocksat_snr_date_comment.meta',
                 tx_correct=0,
                 tx_freq=1265e6,
                 tx_offset=250e3):
        gr.top_block.__init__(self, "MGS Rocksat Receiver v1.0")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("MGS Rocksat Receiver v1.0")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "mgs_trx_1")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.bb_gain = bb_gain
        self.gs_name = gs_name
        self.ip = ip
        self.iq_file = iq_file
        self.meta_rate = meta_rate
        self.port = port
        self.record_iq = record_iq
        self.record_rfo = record_rfo
        self.record_snr = record_snr
        self.rfo_file = rfo_file
        self.snr_file = snr_file
        self.tx_correct = tx_correct
        self.tx_freq = tx_freq
        self.tx_offset = tx_offset

        ##################################################
        # Variables
        ##################################################
        self.ts_str = ts_str = dt.strftime(dt.utcnow(),
                                           "%Y%m%d_%H%M%S.%f") + '_UTC'
        self.samp_rate = samp_rate = 500e3
        self.baud = baud = 125e3
        self.samps_per_symb = samps_per_symb = int(samp_rate / baud)
        self.rx_freq = rx_freq = 2395e6
        self.iq_fn = iq_fn = "{:s}_{:s}_{:s}k.fc32".format(
            gs_name, ts_str, str(int(samp_rate) / 1000))
        self.alpha = alpha = 0.5
        self.uplink_label = uplink_label = ''
        self.tx_gain = tx_gain = 70
        self.rx_offset = rx_offset = 250e3
        self.rx_gain = rx_gain = 25
        self.rx_freq_lbl = rx_freq_lbl = "{:4.3f}".format(rx_freq / 1e6)

        self.rrc_filter_taps = rrc_filter_taps = firdes.root_raised_cosine(
            32, 1.0, 1.0 / (samps_per_symb * 32), alpha, samps_per_symb * 32)

        self.mult = mult = (samp_rate) / 2 / 3.141593

        self.lpf_taps = lpf_taps = firdes.low_pass(1.0, samp_rate,
                                                   samp_rate / 2, 1000,
                                                   firdes.WIN_HAMMING, 6.76)

        self.lo = lo = 1833e6
        self.khz_offset = khz_offset = 0
        self.iq_fp = iq_fp = "/home/zleffke/captures/rocksat/mgs/{:s}".format(
            iq_fn)

        ##################################################
        # Blocks
        ##################################################
        self._tx_gain_range = Range(0, 86, 1, 70, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain,
                                        'TX Gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._tx_gain_win, 10, 8, 1, 4)
        self._rx_gain_range = Range(0, 86, 1, 25, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        'RX Gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._rx_gain_win, 3, 8, 1, 4)
        self._khz_offset_range = Range(-150, 150, 1, 0, 200)
        self._khz_offset_win = RangeWidget(self._khz_offset_range,
                                           self.set_khz_offset, 'Offset [kHz]',
                                           "counter_slider", float)
        self.top_grid_layout.addWidget(self._khz_offset_win, 4, 8, 1, 4)
        self.vtgs_mult_descrambler_0 = vtgs.mult_descrambler(17, 0x3FFFF)
        self.vtgs_ao40_decoder_0_0 = vtgs.ao40_decoder()
        self._uplink_label_tool_bar = Qt.QToolBar(self)

        if None:
            self._uplink_label_formatter = None
        else:
            self._uplink_label_formatter = lambda x: str(x)

        self._uplink_label_tool_bar.addWidget(Qt.QLabel('TX MSG' + ": "))
        self._uplink_label_label = Qt.QLabel(
            str(self._uplink_label_formatter(self.uplink_label)))
        self._uplink_label_tool_bar.addWidget(self._uplink_label_label)
        self.top_grid_layout.addWidget(self._uplink_label_tool_bar, 9, 8, 1, 1)

        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(rx_freq, rx_offset), 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(
            uhd.tune_request(tx_freq + tx_correct, tx_offset), 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self._rx_freq_lbl_tool_bar = Qt.QToolBar(self)

        if None:
            self._rx_freq_lbl_formatter = None
        else:
            self._rx_freq_lbl_formatter = lambda x: str(x)

        self._rx_freq_lbl_tool_bar.addWidget(Qt.QLabel('RX Freq [MHz]' + ": "))
        self._rx_freq_lbl_label = Qt.QLabel(
            str(self._rx_freq_lbl_formatter(self.rx_freq_lbl)))
        self._rx_freq_lbl_tool_bar.addWidget(self._rx_freq_lbl_label)
        self.top_grid_layout.addWidget(self._rx_freq_lbl_tool_bar, 0, 10, 1, 2)

        self.rational_resampler_xxx_2 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=10,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=8,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=8,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            4096,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            '',  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.010)
        self.qtgui_waterfall_sink_x_0.enable_grid(True)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not False:
            self.qtgui_waterfall_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)

        labels = ['pre-d', 'post', '', '', '', '', '', '', '', '']
        colors = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-130, -20)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 5,
                                       0, 4, 8)
        self.qtgui_number_sink_2 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_HORIZ, 1)
        self.qtgui_number_sink_2.set_update_time(0.10)
        self.qtgui_number_sink_2.set_title("")

        labels = ['EVM', '', '', '', '', '', '', '', '', '']
        units = ['', '', '', '', '', '', '', '', '', '']
        colors = [("blue", "red"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        for i in xrange(1):
            self.qtgui_number_sink_2.set_min(i, -1)
            self.qtgui_number_sink_2.set_max(i, 1)
            self.qtgui_number_sink_2.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_2.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_2.set_label(i, labels[i])
            self.qtgui_number_sink_2.set_unit(i, units[i])
            self.qtgui_number_sink_2.set_factor(i, factor[i])

        self.qtgui_number_sink_2.enable_autoscale(False)
        self._qtgui_number_sink_2_win = sip.wrapinstance(
            self.qtgui_number_sink_2.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_2_win, 2, 8, 1,
                                       4)
        self.qtgui_number_sink_0_0_0_0 = qtgui.number_sink(
            gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1)
        self.qtgui_number_sink_0_0_0_0.set_update_time(0.10)
        self.qtgui_number_sink_0_0_0_0.set_title("")

        labels = ['SNR', '', '', '', '', '', '', '', '', '']
        units = ['dB', '', '', '', '', '', '', '', '', '']
        colors = [("blue", "red"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        for i in xrange(1):
            self.qtgui_number_sink_0_0_0_0.set_min(i, 0)
            self.qtgui_number_sink_0_0_0_0.set_max(i, 30)
            self.qtgui_number_sink_0_0_0_0.set_color(i, colors[i][0],
                                                     colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0_0_0_0.set_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0_0_0_0.set_label(i, labels[i])
            self.qtgui_number_sink_0_0_0_0.set_unit(i, units[i])
            self.qtgui_number_sink_0_0_0_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0_0_0_0.enable_autoscale(False)
        self._qtgui_number_sink_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_0_win, 1,
                                       8, 1, 4)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_NONE, 1)
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("")

        labels = ['RX Freq Offset', 'SNR', '', '', '', '', '', '', '', '']
        units = ['Hz', 'dB', '', '', '', '', '', '', '', '']
        colors = [("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        for i in xrange(1):
            self.qtgui_number_sink_0.set_min(i, -1)
            self.qtgui_number_sink_0.set_max(i, 1)
            self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0.set_label(i, labels[i])
            self.qtgui_number_sink_0.set_unit(i, units[i])
            self.qtgui_number_sink_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 0, 8, 1,
                                       2)
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / 10,  #bw
            "TX Spectrum",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_1.set_update_time(0.10)
        self.qtgui_freq_sink_x_1.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_1.enable_autoscale(True)
        self.qtgui_freq_sink_x_1.enable_grid(False)
        self.qtgui_freq_sink_x_1.set_fft_average(1.0)
        self.qtgui_freq_sink_x_1.enable_axis_labels(True)
        self.qtgui_freq_sink_x_1.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_1.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_1.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_1_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 9, 0, 4,
                                       8)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024 * 4,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            2  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.0010)
        self.qtgui_freq_sink_x_0.set_y_axis(-120, -20)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['pre-d', 'post', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 5,
                                       8)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            1024,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-1, 1)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                   qtgui.TRIG_SLOPE_POS, 0.0,
                                                   0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(True)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "red", "red", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 5, 8, 4,
                                       4)
        self.pyqt_text_input_0 = pyqt.text_input()
        self._pyqt_text_input_0_win = self.pyqt_text_input_0
        self.top_grid_layout.addWidget(self._pyqt_text_input_0_win, 9, 9, 1, 3)
        self.mapper_demapper_soft_0 = mapper.demapper_soft(
            mapper.BPSK, ([0, 1]))
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, (baud * (1 + alpha)) / 2, 1000,
                            firdes.WIN_HAMMING, 6.76))
        self.kiss_hdlc_framer_0 = kiss.hdlc_framer(preamble_bytes=48,
                                                   postamble_bytes=10)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (lpf_taps), khz_offset * 1000, samp_rate)
        self.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x0, 16)
        self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf(
            samps_per_symb, math.pi * 2 / 100, (rrc_filter_taps), 32, 16, 1.5,
            1)
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
            samples_per_symbol=50,
            bt=alpha,
            verbose=False,
            log=False,
        )
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(
            math.pi * 2 / 100, 2, False)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            math.pi * 2 / 100, 2, False)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_socket_pdu_0_2 = blocks.socket_pdu("UDP_SERVER", ip,
                                                       '52002', 1024, False)
        self.blocks_socket_pdu_0_1 = blocks.socket_pdu("TCP_SERVER", ip,
                                                       '52003', 1024, False)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", ip, port,
                                                     1024, False)
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'packet_len')
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_nlog10_ff_0_1 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc(
            (bb_gain, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((mult, ))
        self.blocks_moving_average_xx_0_0_1 = blocks.moving_average_ff(
            100000, 0.00001, 4000)
        self.blocks_moving_average_xx_0_0 = blocks.moving_average_ff(
            1000, 0.001, 4000)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            100000, 0.00001, 4000)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1,
                                                   iq_fp, False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared(
            1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, ))
        self.blks2_selector_0 = grc_blks2.selector(
            item_size=gr.sizeof_gr_complex * 1,
            num_inputs=1,
            num_outputs=2,
            input_index=0,
            output_index=int(record_iq),
        )
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 125e3, 1, 0)
        self.analog_agc2_xx_0_0 = analog.agc2_cc(1e-3, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0_1, 'pdus'),
                         (self.kiss_hdlc_framer_0, 'in'))
        self.msg_connect((self.blocks_socket_pdu_0_2, 'pdus'),
                         (self.kiss_hdlc_framer_0, 'in'))
        self.msg_connect((self.kiss_hdlc_framer_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.msg_connect((self.pyqt_text_input_0, 'pdus'),
                         (self.kiss_hdlc_framer_0, 'in'))
        self.msg_connect((self.vtgs_ao40_decoder_0_0, 'valid_frames'),
                         (self.blocks_socket_pdu_0, 'pdus'))
        self.msg_connect((self.vtgs_ao40_decoder_0_0, 'valid_frames'),
                         (self.blocks_socket_pdu_0_1, 'pdus'))
        self.connect((self.analog_agc2_xx_0_0, 0),
                     (self.digital_costas_loop_cc_0_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blks2_selector_0, 1), (self.blocks_file_sink_0, 0))
        self.connect((self.blks2_selector_0, 0), (self.blocks_null_sink_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.qtgui_number_sink_2, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_moving_average_xx_0_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_divide_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_0, 0),
                     (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.blocks_nlog10_ff_0_1, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_moving_average_xx_0_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_moving_average_xx_0_0_1, 0),
                     (self.qtgui_number_sink_0_0_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.rational_resampler_xxx_2, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.blocks_nlog10_ff_0_1, 0),
                     (self.blocks_moving_average_xx_0_0_1, 0))
        self.connect((self.blocks_pack_k_bits_bb_0, 0),
                     (self.digital_gmsk_mod_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0),
                     (self.digital_scrambler_bb_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.mapper_demapper_soft_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 1),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.vtgs_mult_descrambler_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_scrambler_bb_0, 0),
                     (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_agc2_xx_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.qtgui_freq_sink_x_0, 1))
        self.connect((self.mapper_demapper_soft_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.blocks_complex_to_mag_squared_0_0, 0))
        self.connect((self.rational_resampler_xxx_2, 0),
                     (self.qtgui_freq_sink_x_1, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.blks2_selector_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.vtgs_mult_descrambler_0, 0),
                     (self.vtgs_ao40_decoder_0_0, 0))
示例#53
0
    def __init__(self):
        gr.top_block.__init__(self, "Trial5 Record Fm Radio Playback")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Trial5 Record Fm Radio Playback")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio",
                                     "Trial5_record_fm_radio_playback")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 250e3
        self.gain = gain = 40
        self.freq = freq = 92.7e6
        self.deviation = deviation = 30e3 * 0 + 5e3
        self.audio_rate = audio_rate = int(48e3)

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_tool_bar = Qt.QToolBar(self)
        self._samp_rate_tool_bar.addWidget(Qt.QLabel('Sample Rate' + ": "))
        self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate))
        self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit)
        self._samp_rate_line_edit.returnPressed.connect(
            lambda: self.set_samp_rate(
                eng_notation.str_to_num(
                    str(self._samp_rate_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._samp_rate_tool_bar)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=audio_rate,
            decimation=int(samp_rate),
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2):
            if len(labels[i]) == 0:
                if (i % 2 == 0):
                    self.qtgui_time_sink_x_0.set_line_label(
                        i, "Re{{Data {0}}}".format(i / 2))
                else:
                    self.qtgui_time_sink_x_0.set_line_label(
                        i, "Im{{Data {0}}}".format(i / 2))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.low_pass_filter_0 = filter.fir_filter_fff(
            1,
            firdes.low_pass(1, audio_rate, 3.5e3, 0.5e3, firdes.WIN_HAMMING,
                            6.76))
        self._gain_range = Range(0, 90, 1, 40, 200)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain, 'Gain',
                                     "counter_slider", float)
        self.top_layout.addWidget(self._gain_win)
        self._freq_range = Range(90e6, 110e6, 50, 92.7e6, 200)
        self._freq_win = RangeWidget(self._freq_range, self.set_freq,
                                     'Frequency', "counter_slider", float)
        self.top_layout.addWidget(self._freq_win)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_meta_source_0 = blocks.file_meta_source(
            'C:\\Users\\Zyglabs\\Dropbox\\2017_05_Summer_Research\\1_EARS\\EarsMeasurementCampaignCode\\Trials\\Trial5_record_fm_radio.out',
            True, False, '')
        self.audio_sink_0 = audio.sink(audio_rate, '', True)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            (audio_rate / (2 * math.pi * deviation)) * 0 +
            ((2 * math.pi * deviation) / audio_rate))
        self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(
            -90, 1e-3, 0, False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_pwr_squelch_xx_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_file_meta_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.audio_sink_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_pwr_squelch_xx_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.audio_rate = audio_rate = int(48e3)
        self.rtl_rate = rtl_rate = int(240e3)
        self.out_intermediary_rate = out_intermediary_rate = audio_rate*4
        self.out_gain = out_gain = .25
        self.out_frequency_offset = out_frequency_offset = -50e3
        self.out_frequency = out_frequency = 145.521e6
        self.out_audio_inverted = out_audio_inverted = True
        self.in_frequency_offset = in_frequency_offset = 0
        self.in_frequency = in_frequency = 145.551e6
        self.in_final_gain = in_final_gain = 0.5
        self.in_decimation_factor = in_decimation_factor = 8
        self.in_audio_inverted = in_audio_inverted = True
        self.hackrf_rate = hackrf_rate = 2e6
        self.dstar_bandwidth = dstar_bandwidth = 6.5e3

        ##################################################
        # Blocks
        ##################################################
        self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.rtlsdr_source_0.set_sample_rate(rtl_rate)
        self.rtlsdr_source_0.set_center_freq(in_frequency+in_frequency_offset, 0)
        self.rtlsdr_source_0.set_freq_corr(69, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(10, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
          
        self.rational_resampler_xxx_3 = filter.rational_resampler_ccc(
                interpolation=int(hackrf_rate),
                decimation=out_intermediary_rate,
                taps=None,
                fractional_bw=None,
        )
        self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_sink_0.set_sample_rate(hackrf_rate)
        self.osmosdr_sink_0.set_center_freq(out_frequency-out_frequency_offset, 0)
        self.osmosdr_sink_0.set_freq_corr(4, 0)
        self.osmosdr_sink_0.set_gain(14, 0)
        self.osmosdr_sink_0.set_if_gain(0, 0)
        self.osmosdr_sink_0.set_bb_gain(0, 0)
        self.osmosdr_sink_0.set_antenna("0", 0)
        self.osmosdr_sink_0.set_bandwidth(100e3, 0)
          
        self.low_pass_filter_1 = filter.fir_filter_ccf(5, firdes.low_pass(
        	1, rtl_rate, dstar_bandwidth*2, 500, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass(
        	1, audio_rate, dstar_bandwidth*2, 200, firdes.WIN_KAISER, 6.76))
        self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(1, (1, ), 0-out_frequency_offset, out_intermediary_rate)
        self.freq_xlating_fft_filter_ccc_0.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0)
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(128, True)
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff(((-1 if out_audio_inverted else 1)*out_gain, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((0-in_final_gain if in_audio_inverted else in_final_gain, ))
        self.audio_source_0 = audio.source(audio_rate, "hw:10,1", True)
        self.audio_sink_1 = audio.sink(audio_rate, "plughw:11,0", True)
        self.analog_pwr_squelch_xx_1 = analog.pwr_squelch_cc(-30, 1, 1, False)
        self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_ff(-60, 1, 1, True)
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
        	audio_rate=int(audio_rate),
        	quad_rate=int(out_intermediary_rate),
        	tau=0,
        	max_dev=dstar_bandwidth,
        )
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=audio_rate,
        	quad_rate=audio_rate,
        	tau=0.000000000000000000001,
        	max_dev=dstar_bandwidth*2,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_multiply_const_vxx_1, 0))    
        self.connect((self.analog_nbfm_tx_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0))    
        self.connect((self.analog_pwr_squelch_xx_0, 0), (self.blocks_multiply_const_vxx_2, 0))    
        self.connect((self.analog_pwr_squelch_xx_1, 0), (self.analog_nbfm_rx_0, 0))    
        self.connect((self.audio_source_0, 0), (self.dc_blocker_xx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.audio_sink_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_2, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.dc_blocker_xx_0, 0), (self.analog_pwr_squelch_xx_0, 0))    
        self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.rational_resampler_xxx_3, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.analog_nbfm_tx_0, 0))    
        self.connect((self.low_pass_filter_1, 0), (self.analog_pwr_squelch_xx_1, 0))    
        self.connect((self.rational_resampler_xxx_3, 0), (self.osmosdr_sink_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_1, 0))    
示例#55
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="SSB Receiver")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

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

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

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

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.band_pass_filter, 0), (self.analog_agc2_xx_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 1))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.band_pass_filter, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.fftsink, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_complex_to_real_0, 0))
示例#56
0
    def __init__(self):
        gr.top_block.__init__(self, "Bpsk Sender1")

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 8
        self.nfilts = nfilts = 32
        self.transistion = transistion = 100
        self.sideband_rx = sideband_rx = 500
        self.sideband = sideband = 500
        self.samp_rate = samp_rate = 48000
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), 0.35, 11 * sps * nfilts)
        self.qpsk = qpsk = digital.constellation_rect(([
            0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j
        ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.preamble = preamble = [
            1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1,
            -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1,
            -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1,
            1, 1, 1, 1, 1, -1, -1
        ]
        self.payload_size = payload_size = 10
        self.interpolation = interpolation = 2000
        self.gap = gap = 0
        self.eb = eb = 0.35
        self.delay = delay = 0
        self.decimation = decimation = 1
        self.constel = constel = digital.constellation_calcdist(
            ([1, -1]), ([0, 1]), 2, 1).base()
        self.const_type = const_type = 1
        self.const = const = (digital.constellation_bpsk(),
                              digital.constellation_qpsk(),
                              digital.constellation_8psk())
        self.carrier = carrier = 10000
        self.arity = arity = 2

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=interpolation,
            decimation=decimation,
            taps=None,
            fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (firdes.band_pass(0.5, samp_rate, 10000 - sideband,
                                 10000 + sideband, transistion)), -carrier,
            samp_rate)
        self.digital_constellation_modulator_0 = digital.generic_mod(
            constellation=constel,
            differential=True,
            samples_per_symbol=sps,
            pre_diff_code=True,
            excess_bw=0.35,
            verbose=False,
            log=False,
        )
        self.blocks_wavfile_sink_1 = blocks.wavfile_sink(
            "BPSK_output.wav", 1, 48000, 16)
        self.blocks_unpack_k_bits_bb_0_0 = blocks.unpack_k_bits_bb(8)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.1, ))
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1,
                                                       "TestData2", False)
        self.blocks_file_sink_0_0_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                       "inputBinary", False)
        self.blocks_file_sink_0_0_0.set_unbuffered(False)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                     "inputBinary2", False)
        self.blocks_file_sink_0_0.set_unbuffered(False)

        script, sdelay = argv

        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_char * 1, int(sdelay))
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_delay_0_0, 0),
                     (self.blocks_file_sink_0_0, 0))
        self.connect((self.blocks_delay_0_0, 0),
                     (self.blocks_file_sink_0_0_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_unpack_k_bits_bb_0_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.digital_constellation_modulator_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_wavfile_sink_1, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0_0, 0),
                     (self.blocks_delay_0_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
示例#57
0
    def __init__(self):
        gr.top_block.__init__(self, "Multitransmit for RpiTX")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Multitransmit for RpiTX")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "gr_multitransmit_rpitx")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.wfm_on = wfm_on = False
        self.usb_on = usb_on = False
        self.test_tone_frequency = test_tone_frequency = 1000
        self.rpitx_frequency_correction = rpitx_frequency_correction = 0
        self.ptt_lock = ptt_lock = False
        self.ptt = ptt = False
        self.nfm_on = nfm_on = False
        self.lsb_on = lsb_on = False
        self.low_frequency_cutoff = low_frequency_cutoff = 200
        self.high_frequency_cutoff = high_frequency_cutoff = 2500
        self.enable_tone = enable_tone = False
        self.enable_test_tone = enable_test_tone = False
        self.ctcss_tone = ctcss_tone = 100
        self.audio_rate = audio_rate = 48000
        self.am_on = am_on = False

        ##################################################
        # Blocks
        ##################################################
        _wfm_on_check_box = Qt.QCheckBox('WFM')
        self._wfm_on_choices = {True: True, False: False}
        self._wfm_on_choices_inv = dict((v,k) for k,v in self._wfm_on_choices.iteritems())
        self._wfm_on_callback = lambda i: Qt.QMetaObject.invokeMethod(_wfm_on_check_box, "setChecked", Qt.Q_ARG("bool", self._wfm_on_choices_inv[i]))
        self._wfm_on_callback(self.wfm_on)
        _wfm_on_check_box.stateChanged.connect(lambda i: self.set_wfm_on(self._wfm_on_choices[bool(i)]))
        self.top_grid_layout.addWidget(_wfm_on_check_box, 4,0)
        _usb_on_check_box = Qt.QCheckBox('USB')
        self._usb_on_choices = {True: True, False: False}
        self._usb_on_choices_inv = dict((v,k) for k,v in self._usb_on_choices.iteritems())
        self._usb_on_callback = lambda i: Qt.QMetaObject.invokeMethod(_usb_on_check_box, "setChecked", Qt.Q_ARG("bool", self._usb_on_choices_inv[i]))
        self._usb_on_callback(self.usb_on)
        _usb_on_check_box.stateChanged.connect(lambda i: self.set_usb_on(self._usb_on_choices[bool(i)]))
        self.top_grid_layout.addWidget(_usb_on_check_box, 5,0)
        self._test_tone_frequency_range = Range(0, audio_rate, 1, 1000, 200)
        self._test_tone_frequency_win = RangeWidget(self._test_tone_frequency_range, self.set_test_tone_frequency, 'Tone Frequency', "counter", float)
        self.top_grid_layout.addWidget(self._test_tone_frequency_win, 11,1)
        self._rpitx_frequency_correction_range = Range(-24, 24, .1, 0, 200)
        self._rpitx_frequency_correction_win = RangeWidget(self._rpitx_frequency_correction_range, self.set_rpitx_frequency_correction, 'RpiTX Frequency Correction', "counter_slider", float)
        self.top_grid_layout.addWidget(self._rpitx_frequency_correction_win, 13,0)
        _ptt_lock_check_box = Qt.QCheckBox('PTT Lock')
        self._ptt_lock_choices = {True: True, False: False}
        self._ptt_lock_choices_inv = dict((v,k) for k,v in self._ptt_lock_choices.iteritems())
        self._ptt_lock_callback = lambda i: Qt.QMetaObject.invokeMethod(_ptt_lock_check_box, "setChecked", Qt.Q_ARG("bool", self._ptt_lock_choices_inv[i]))
        self._ptt_lock_callback(self.ptt_lock)
        _ptt_lock_check_box.stateChanged.connect(lambda i: self.set_ptt_lock(self._ptt_lock_choices[bool(i)]))
        self.top_grid_layout.addWidget(_ptt_lock_check_box, 0,1)
        _ptt_push_button = Qt.QPushButton('Push To Talk')
        self._ptt_choices = {'Pressed': True, 'Released': False}
        _ptt_push_button.pressed.connect(lambda: self.set_ptt(self._ptt_choices['Pressed']))
        _ptt_push_button.released.connect(lambda: self.set_ptt(self._ptt_choices['Released']))
        self.top_grid_layout.addWidget(_ptt_push_button, 0,0)
        _nfm_on_check_box = Qt.QCheckBox('NFM')
        self._nfm_on_choices = {True: True, False: False}
        self._nfm_on_choices_inv = dict((v,k) for k,v in self._nfm_on_choices.iteritems())
        self._nfm_on_callback = lambda i: Qt.QMetaObject.invokeMethod(_nfm_on_check_box, "setChecked", Qt.Q_ARG("bool", self._nfm_on_choices_inv[i]))
        self._nfm_on_callback(self.nfm_on)
        _nfm_on_check_box.stateChanged.connect(lambda i: self.set_nfm_on(self._nfm_on_choices[bool(i)]))
        self.top_grid_layout.addWidget(_nfm_on_check_box, 3,0)
        _lsb_on_check_box = Qt.QCheckBox('LSB')
        self._lsb_on_choices = {True: True, False: False}
        self._lsb_on_choices_inv = dict((v,k) for k,v in self._lsb_on_choices.iteritems())
        self._lsb_on_callback = lambda i: Qt.QMetaObject.invokeMethod(_lsb_on_check_box, "setChecked", Qt.Q_ARG("bool", self._lsb_on_choices_inv[i]))
        self._lsb_on_callback(self.lsb_on)
        _lsb_on_check_box.stateChanged.connect(lambda i: self.set_lsb_on(self._lsb_on_choices[bool(i)]))
        self.top_grid_layout.addWidget(_lsb_on_check_box, 6,0)
        self._low_frequency_cutoff_range = Range(1, audio_rate/2, 1, 200, 100)
        self._low_frequency_cutoff_win = RangeWidget(self._low_frequency_cutoff_range, self.set_low_frequency_cutoff, 'Low Frequency Cutoff', "counter_slider", float)
        self.top_grid_layout.addWidget(self._low_frequency_cutoff_win, 7,0)
        self._high_frequency_cutoff_range = Range(1, audio_rate/2, 1, 2500, 100)
        self._high_frequency_cutoff_win = RangeWidget(self._high_frequency_cutoff_range, self.set_high_frequency_cutoff, 'High Frequency Cutoff', "counter_slider", float)
        self.top_grid_layout.addWidget(self._high_frequency_cutoff_win, 7,1)
        _enable_tone_check_box = Qt.QCheckBox('CTCSS Tone Enable')
        self._enable_tone_choices = {True: True, False: False}
        self._enable_tone_choices_inv = dict((v,k) for k,v in self._enable_tone_choices.iteritems())
        self._enable_tone_callback = lambda i: Qt.QMetaObject.invokeMethod(_enable_tone_check_box, "setChecked", Qt.Q_ARG("bool", self._enable_tone_choices_inv[i]))
        self._enable_tone_callback(self.enable_tone)
        _enable_tone_check_box.stateChanged.connect(lambda i: self.set_enable_tone(self._enable_tone_choices[bool(i)]))
        self.top_grid_layout.addWidget(_enable_tone_check_box, 10,0)
        _enable_test_tone_check_box = Qt.QCheckBox('Test Tone')
        self._enable_test_tone_choices = {True: True, False: False}
        self._enable_test_tone_choices_inv = dict((v,k) for k,v in self._enable_test_tone_choices.iteritems())
        self._enable_test_tone_callback = lambda i: Qt.QMetaObject.invokeMethod(_enable_test_tone_check_box, "setChecked", Qt.Q_ARG("bool", self._enable_test_tone_choices_inv[i]))
        self._enable_test_tone_callback(self.enable_test_tone)
        _enable_test_tone_check_box.stateChanged.connect(lambda i: self.set_enable_test_tone(self._enable_test_tone_choices[bool(i)]))
        self.top_grid_layout.addWidget(_enable_test_tone_check_box, 11,0)
        self._ctcss_tone_range = Range(67, 254.1, .1, 100, 200)
        self._ctcss_tone_win = RangeWidget(self._ctcss_tone_range, self.set_ctcss_tone, 'CTCSS Tone', "counter", float)
        self.top_grid_layout.addWidget(self._ctcss_tone_win, 10,1)
        _am_on_check_box = Qt.QCheckBox('AM')
        self._am_on_choices = {True: True, False: False}
        self._am_on_choices_inv = dict((v,k) for k,v in self._am_on_choices.iteritems())
        self._am_on_callback = lambda i: Qt.QMetaObject.invokeMethod(_am_on_check_box, "setChecked", Qt.Q_ARG("bool", self._am_on_choices_inv[i]))
        self._am_on_callback(self.am_on)
        _am_on_check_box.stateChanged.connect(lambda i: self.set_am_on(self._am_on_choices[bool(i)]))
        self.top_grid_layout.addWidget(_am_on_check_box, 2,0)
        self.rational_resampler_wfm = filter.rational_resampler_ccc(
                interpolation=audio_rate,
                decimation=audio_rate*4,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_nbfm = filter.rational_resampler_ccc(
                interpolation=audio_rate,
                decimation=audio_rate*2,
                taps=None,
                fractional_bw=None,
        )
        self.qtgui_waterfall_sink_rpitx = qtgui.waterfall_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	audio_rate, #bw
        	"rpitx signal (I/Q)", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_rpitx.set_update_time(0.01)
        self.qtgui_waterfall_sink_rpitx.enable_grid(False)
        self.qtgui_waterfall_sink_rpitx.enable_axis_labels(True)
        
        if not True:
          self.qtgui_waterfall_sink_rpitx.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_waterfall_sink_rpitx.set_plot_pos_half(not True)
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        colors = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_rpitx.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_rpitx.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_rpitx.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_rpitx.set_line_alpha(i, alphas[i])
        
        self.qtgui_waterfall_sink_rpitx.set_intensity_range(-140, 10)
        
        self._qtgui_waterfall_sink_rpitx_win = sip.wrapinstance(self.qtgui_waterfall_sink_rpitx.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_rpitx_win, 1,1)
        self.qtgui_sink_transmit = qtgui.sink_c(
        	1024, #fftsize
        	firdes.WIN_HAMMING, #wintype
        	0, #fc
        	audio_rate, #bw
        	"Transmitted Signal (I/Q)", #name
        	True, #plotfreq
        	True, #plotwaterfall
        	True, #plottime
        	True, #plotconst
        )
        self.qtgui_sink_transmit.set_update_time(1.0/100)
        self._qtgui_sink_transmit_win = sip.wrapinstance(self.qtgui_sink_transmit.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_sink_transmit_win, 1,0)
        
        self.qtgui_sink_transmit.enable_rf_freq(False)
        
        
          
        self.low_pass_filter_nbfm = filter.fir_filter_fff(1, firdes.low_pass(
        	1, audio_rate, 4e3, 500, firdes.WIN_HAMMING, 6.76))
        self.freq_xlating_fir_filter_rpitx = filter.freq_xlating_fir_filter_ccc(1, ([1]), -rpitx_frequency_correction*1000, 48000)
        self.blocks_multiply_usb = blocks.multiply_vcc(1)
        self.blocks_multiply_lsb = blocks.multiply_vcc(1)
        self.blocks_multiply_const_wfm = blocks.multiply_const_vcc((wfm_on, ))
        self.blocks_multiply_const_test = blocks.multiply_const_vff((enable_test_tone, ))
        self.blocks_multiply_const_rpitx = blocks.multiply_const_vcc((ptt or ptt_lock, ))
        self.blocks_multiply_const_nbfm = blocks.multiply_const_vcc((nfm_on, ))
        self.blocks_multiply_const_ctcss = blocks.multiply_const_vff((enable_tone, ))
        self.blocks_multiply_am = blocks.multiply_vcc(1)
        self.blocks_float_to_complex_am_ssb = blocks.float_to_complex(1)
        self.blocks_add_nbfm = blocks.add_vff(1)
        self.blocks_add_fm = blocks.add_vcc(1)
        self.blocks_add_const_am = blocks.add_const_vcc((.5, ))
        self.blocks_add_am_ssb_fm = blocks.add_vcc(1)
        self.blocks_add_am_ssb = blocks.add_vcc(1)
        self.blocks_add = blocks.add_vff(1)
        self.blks_tcp_sink_rpitx = grc_blks2.tcp_sink(
        	itemsize=gr.sizeof_gr_complex*1,
        	addr='localhost',
        	port=8011,
        	server=False,
        )
        self.band_pass_filter_usb = filter.interp_fir_filter_ccc(1, firdes.complex_band_pass(
        	1, audio_rate, low_frequency_cutoff, high_frequency_cutoff, 200, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_lsb = filter.interp_fir_filter_ccc(1, firdes.complex_band_pass(
        	1, audio_rate, -high_frequency_cutoff, -low_frequency_cutoff, 200, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_am = filter.fir_filter_ccf(1, firdes.band_pass(
        	1, audio_rate, low_frequency_cutoff, high_frequency_cutoff, 400, firdes.WIN_HAMMING, 6.76))
        self.audio_source = audio.source(48000, '', True)
        self.analog_wfm_tx = analog.wfm_tx(
        	audio_rate=audio_rate,
        	quad_rate=audio_rate * 4,
        	tau=75e-6,
        	max_dev=75e3,
        	fh=-1.0,
        )
        self.analog_sig_source_usb = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 0, 1.8 if usb_on else 0, 0)
        self.analog_sig_source_test = analog.sig_source_f(audio_rate, analog.GR_SIN_WAVE, test_tone_frequency, .3, 0)
        self.analog_sig_source_lsb = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 0, 1.8 if lsb_on else 0, 0)
        self.analog_sig_source_ctcss = analog.sig_source_f(audio_rate, analog.GR_COS_WAVE, ctcss_tone, 0.1, 0)
        self.analog_sig_source_am = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 0, 1 if am_on else 0, 0)
        self.analog_nbfm_tx = analog.nbfm_tx(
        	audio_rate=audio_rate,
        	quad_rate=audio_rate*2,
        	tau=75e-6,
        	max_dev=5e3,
        	fh=-1.0,
                )
        self.analog_const_source = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source, 0), (self.blocks_float_to_complex_am_ssb, 1))    
        self.connect((self.analog_nbfm_tx, 0), (self.blocks_multiply_const_nbfm, 0))    
        self.connect((self.analog_sig_source_am, 0), (self.blocks_multiply_am, 1))    
        self.connect((self.analog_sig_source_ctcss, 0), (self.blocks_multiply_const_ctcss, 0))    
        self.connect((self.analog_sig_source_lsb, 0), (self.blocks_multiply_lsb, 1))    
        self.connect((self.analog_sig_source_test, 0), (self.blocks_multiply_const_test, 0))    
        self.connect((self.analog_sig_source_usb, 0), (self.blocks_multiply_usb, 1))    
        self.connect((self.analog_wfm_tx, 0), (self.blocks_multiply_const_wfm, 0))    
        self.connect((self.audio_source, 0), (self.blocks_add, 0))    
        self.connect((self.band_pass_filter_am, 0), (self.blocks_add_const_am, 0))    
        self.connect((self.band_pass_filter_lsb, 0), (self.blocks_multiply_lsb, 0))    
        self.connect((self.band_pass_filter_usb, 0), (self.blocks_multiply_usb, 0))    
        self.connect((self.blocks_add, 0), (self.analog_wfm_tx, 0))    
        self.connect((self.blocks_add, 0), (self.blocks_add_nbfm, 1))    
        self.connect((self.blocks_add, 0), (self.blocks_float_to_complex_am_ssb, 0))    
        self.connect((self.blocks_add_am_ssb, 0), (self.blocks_add_am_ssb_fm, 1))    
        self.connect((self.blocks_add_am_ssb_fm, 0), (self.blocks_multiply_const_rpitx, 0))    
        self.connect((self.blocks_add_const_am, 0), (self.blocks_multiply_am, 0))    
        self.connect((self.blocks_add_fm, 0), (self.blocks_add_am_ssb_fm, 0))    
        self.connect((self.blocks_add_nbfm, 0), (self.low_pass_filter_nbfm, 0))    
        self.connect((self.blocks_float_to_complex_am_ssb, 0), (self.band_pass_filter_am, 0))    
        self.connect((self.blocks_float_to_complex_am_ssb, 0), (self.band_pass_filter_lsb, 0))    
        self.connect((self.blocks_float_to_complex_am_ssb, 0), (self.band_pass_filter_usb, 0))    
        self.connect((self.blocks_multiply_am, 0), (self.blocks_add_am_ssb, 0))    
        self.connect((self.blocks_multiply_const_ctcss, 0), (self.blocks_add_nbfm, 0))    
        self.connect((self.blocks_multiply_const_nbfm, 0), (self.rational_resampler_nbfm, 0))    
        self.connect((self.blocks_multiply_const_rpitx, 0), (self.freq_xlating_fir_filter_rpitx, 0))    
        self.connect((self.blocks_multiply_const_rpitx, 0), (self.qtgui_sink_transmit, 0))    
        self.connect((self.blocks_multiply_const_test, 0), (self.blocks_add, 1))    
        self.connect((self.blocks_multiply_const_wfm, 0), (self.rational_resampler_wfm, 0))    
        self.connect((self.blocks_multiply_lsb, 0), (self.blocks_add_am_ssb, 1))    
        self.connect((self.blocks_multiply_usb, 0), (self.blocks_add_am_ssb, 2))    
        self.connect((self.freq_xlating_fir_filter_rpitx, 0), (self.blks_tcp_sink_rpitx, 0))    
        self.connect((self.freq_xlating_fir_filter_rpitx, 0), (self.qtgui_waterfall_sink_rpitx, 0))    
        self.connect((self.low_pass_filter_nbfm, 0), (self.analog_nbfm_tx, 0))    
        self.connect((self.rational_resampler_nbfm, 0), (self.blocks_add_fm, 0))    
        self.connect((self.rational_resampler_wfm, 0), (self.blocks_add_fm, 1))    
示例#58
0
    def __init__(self):
        gr.top_block.__init__(self, "Analog Phone Tx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Analog Phone Tx")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "Analog_Phone_TX")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 2
        self.excess_bw = excess_bw = 0.10
        self.samp_rate = samp_rate = 32000
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            1, sps, 1, excess_bw, 45)
        self.bpsk = bpsk = digital.constellation_rect(
            ([0.707 + 0.707j, -0.707 + 0.707j]), ([
                0,
                1,
            ]), 2, 2, 0, 1, 0).base()
        self.arity = arity = 4

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("addr=192.168.10.2", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(2.4175e9, 0)
        self.uhd_usrp_sink_0.set_gain(28, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
        self.uhd_usrp_sink_0.set_bandwidth(100e3, 0)
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
            interpolation=36,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.digital_crc32_bb_0 = digital.crc32_bb(False, "packet_len")
        self.digital_constellation_modulator_0 = digital.generic_mod(
            constellation=bpsk,
            differential=True,
            samples_per_symbol=sps,
            pre_diff_code=True,
            excess_bw=excess_bw,
            verbose=False,
            log=False,
        )
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, 8, "packet_len")
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(
            grc_blks2.packet_encoder(
                samples_per_symbol=1,
                bits_per_symbol=8,
                preamble="",
                access_code="",
                pad_for_usrp=True,
            ),
            payload_length=0,
        )
        self.analog_random_source_x_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, 256, 10000)), True)
        self.Spread_ds_spreader_0 = Spread.ds_spreader(2, (1, 1, 0, 1),
                                                       (1, 1, 1))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.Spread_ds_spreader_0, 0),
                     (self.digital_constellation_modulator_0, 0))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blks2_packet_encoder_0, 0))
        self.connect((self.blks2_packet_encoder_0, 0),
                     (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0),
                     (self.digital_crc32_bb_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.digital_crc32_bb_0, 0),
                     (self.Spread_ds_spreader_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.uhd_usrp_sink_0, 0))
示例#59
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
             self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
             pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.demod_rate = demod_rate = 192000
        self.audio_decimation = audio_decimation = 4
        self.volume = volume = 1
        self.samp_rate = samp_rate = 1000e3
        self.range1 = range1 = 88.1
        self.audio_rate = audio_rate = demod_rate / audio_decimation

        ##################################################
        # Blocks
        ##################################################
        self._volume_layout = Qt.QVBoxLayout()
        self._volume_tool_bar = Qt.QToolBar(self)
        self._volume_layout.addWidget(self._volume_tool_bar)
        self._volume_tool_bar.addWidget(Qt.QLabel("Volume"+": "))
        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)
            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)
        self._volume_counter = qwt_counter_pyslot()
        self._volume_counter.setRange(0.000001, 100, 0.01)
        self._volume_counter.setNumButtons(2)
        self._volume_counter.setValue(self.volume)
        self._volume_tool_bar.addWidget(self._volume_counter)
        self._volume_counter.valueChanged.connect(self.set_volume)
        self._volume_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._volume_slider.setRange(0.000001, 100, 0.01)
        self._volume_slider.setValue(self.volume)
        self._volume_slider.setMinimumWidth(200)
        self._volume_slider.valueChanged.connect(self.set_volume)
        self._volume_layout.addWidget(self._volume_slider)
        self.top_layout.addLayout(self._volume_layout)
        self._range1_layout = Qt.QVBoxLayout()
        self._range1_tool_bar = Qt.QToolBar(self)
        self._range1_layout.addWidget(self._range1_tool_bar)
        self._range1_tool_bar.addWidget(Qt.QLabel("Tune"+": "))
        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)
            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)
        self._range1_counter = qwt_counter_pyslot()
        self._range1_counter.setRange(88, 108, 0.1)
        self._range1_counter.setNumButtons(2)
        self._range1_counter.setValue(self.range1)
        self._range1_tool_bar.addWidget(self._range1_counter)
        self._range1_counter.valueChanged.connect(self.set_range1)
        self._range1_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._range1_slider.setRange(88, 108, 0.1)
        self._range1_slider.setValue(self.range1)
        self._range1_slider.setMinimumWidth(200)
        self._range1_slider.valueChanged.connect(self.set_range1)
        self._range1_layout.addWidget(self._range1_slider)
        self.top_layout.addLayout(self._range1_layout)
        self.rtl2832_source_0 = baz.rtl_source_c(defer_creation=True, output_size=gr.sizeof_gr_complex)
        self.rtl2832_source_0.set_verbose(True)
        self.rtl2832_source_0.set_vid(0x0)
        self.rtl2832_source_0.set_pid(0x0)
        self.rtl2832_source_0.set_tuner_name("")
        self.rtl2832_source_0.set_default_timeout(0)
        self.rtl2832_source_0.set_use_buffer(True)
        self.rtl2832_source_0.set_fir_coefficients(([]))
        
        self.rtl2832_source_0.set_read_length(0)
        
        
        
        
        if self.rtl2832_source_0.create() == False: raise Exception("Failed to create RTL2832 Source: rtl2832_source_0")
        
        
        self.rtl2832_source_0.set_sample_rate(samp_rate)
        
        self.rtl2832_source_0.set_frequency(range1*1e6)
        
        
        
        self.rtl2832_source_0.set_auto_gain_mode(True)
        self.rtl2832_source_0.set_relative_gain(True)
        self.rtl2832_source_0.set_gain(1)
          
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
                interpolation=demod_rate,
                decimation=int(samp_rate),
                taps=None,
                fractional_bw=None,
        )
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	audio_rate, #bw
        	"", #name
        	2 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.2)
        
        if float == type(float()):
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.audio_sink_0 = audio.sink(audio_rate, "", True)
        self.analog_wfm_rcv_pll_0 = analog.wfm_rcv_pll(
        	demod_rate=demod_rate,
        	audio_decimation=4,
        )
        self.analog_fm_deemph_0_1_0 = analog.fm_deemph(fs=audio_rate, tau=75e-6)
        self.analog_fm_deemph_0_1 = analog.fm_deemph(fs=audio_rate, tau=75e-6)
        self.analog_agc2_xx_0_0_0 = analog.agc2_ff(1e-1, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0_0_0.set_max_gain(volume)
        self.analog_agc2_xx_0_0 = analog.agc2_ff(1e-1, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0_0.set_max_gain(volume)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0_0, 0), (self.analog_fm_deemph_0_1_0, 0))    
        self.connect((self.analog_agc2_xx_0_0_0, 0), (self.analog_fm_deemph_0_1, 0))    
        self.connect((self.analog_fm_deemph_0_1, 0), (self.audio_sink_0, 1))    
        self.connect((self.analog_fm_deemph_0_1, 0), (self.qtgui_freq_sink_x_0, 1))    
        self.connect((self.analog_fm_deemph_0_1_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.analog_fm_deemph_0_1_0, 0), (self.qtgui_freq_sink_x_0, 0))    
        self.connect((self.analog_wfm_rcv_pll_0, 0), (self.analog_agc2_xx_0_0, 0))    
        self.connect((self.analog_wfm_rcv_pll_0, 1), (self.analog_agc2_xx_0_0_0, 0))    
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.analog_wfm_rcv_pll_0, 0))    
        self.connect((self.rtl2832_source_0, 0), (self.rational_resampler_xxx_0_0, 0))    
示例#60
0
    def __init__(self, lpf_cutoff=24e3, lpf_trans=1e3):
        gr.top_block.__init__(self, "Burst Detect Es5")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Burst Detect Es5")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "burst_detect_es5")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Parameters
        ##################################################
        self.lpf_cutoff = lpf_cutoff
        self.lpf_trans = lpf_trans

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 250000
        self.interp = interp = 24
        self.decim = decim = int(samp_rate/2000)
        self.baud = baud = 9600
        self.samps_per_symb = samps_per_symb = int((samp_rate/decim*interp)/baud)
        self.offset = offset = 0
        self.nfft = nfft = 2048
        self.max_symbols = max_symbols = samps_per_symb*300*8 *2
        self.fsk_dev = fsk_dev = 10000
        self.avg_len_freq = avg_len_freq = 10.0
        self.avg_len = avg_len = 100.0

        ##################################################
        # Blocks
        ##################################################
        self._offset_tool_bar = Qt.QToolBar(self)
        self._offset_tool_bar.addWidget(Qt.QLabel("offset"+": "))
        self._offset_line_edit = Qt.QLineEdit(str(self.offset))
        self._offset_tool_bar.addWidget(self._offset_line_edit)
        self._offset_line_edit.returnPressed.connect(
        	lambda: self.set_offset(eng_notation.str_to_num(str(self._offset_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._offset_tool_bar, 4, 6, 1, 2)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(6, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._avg_len_tool_bar = Qt.QToolBar(self)
        self._avg_len_tool_bar.addWidget(Qt.QLabel("avg_len"+": "))
        self._avg_len_line_edit = Qt.QLineEdit(str(self.avg_len))
        self._avg_len_tool_bar.addWidget(self._avg_len_line_edit)
        self._avg_len_line_edit.returnPressed.connect(
        	lambda: self.set_avg_len(eng_notation.str_to_num(str(self._avg_len_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._avg_len_tool_bar, 4, 4, 1, 2)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=interp,
                decimation=decim,
                taps=None,
                fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
        	2048, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate / decim*interp, #bw
        	"RX Spectrum", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.010)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
          self.qtgui_waterfall_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        colors = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 0, 4, 2, 4)
        for r in range(0, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_c(
        	2048, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate / decim*interp, #bw
        	"RX Spectrum", #name
        	2 #number of inputs
        )
        self.qtgui_freq_sink_x_1_0.set_update_time(0.010)
        self.qtgui_freq_sink_x_1_0.set_y_axis(-150, 0)
        self.qtgui_freq_sink_x_1_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_1_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_1_0.enable_grid(True)
        self.qtgui_freq_sink_x_1_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_1_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_1_0.enable_control_panel(False)

        if not False:
          self.qtgui_freq_sink_x_1_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_1_0.set_plot_pos_half(not True)

        labels = ['pre-d', 'agc_filt', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_1_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_1_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_1_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_1_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_1_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_1_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_0_win, 0, 0, 2, 4)
        for r in range(0, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	nfft, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate*interp/decim/2, #bw
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.0010)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(True)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
          self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 2, 0, 2, 4)
        for r in range(2, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.pyqt_meta_text_output_0 = pyqt.meta_text_output()
        self._pyqt_meta_text_output_0_win = self.pyqt_meta_text_output_0;
        self.top_grid_layout.addWidget(self._pyqt_meta_text_output_0_win, 7, 4, 1, 4)
        for r in range(7, 8):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 8):
            self.top_grid_layout.setColumnStretch(c, 1)

        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, samp_rate / decim *interp, lpf_cutoff, lpf_trans, firdes.WIN_HAMMING, 6.76))
        self.es_trigger_edge_f_0 = es.trigger_edge_f(-2,baud*samps_per_symb / 4,int(avg_len*2),gr.sizeof_gr_complex,300)
        self.es_sink_0 = es.sink(1*[gr.sizeof_gr_complex],8,64,0,2,0)
        self.es_handler_pdu_0 = es.es_make_handler_pdu(es.es_handler_print.TYPE_C32)
        self.burst_length_detect_0 = burst.length_detect()
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_float*1, 1)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.complex_t, 'es::event_length')
        (self.blocks_pdu_to_tagged_stream_0).set_min_output_buffer(48000)
        self.blocks_pdu_remove_0 = blocks.pdu_remove(pmt.intern("es::event_buffer"))
        self.blocks_multiply_xx_1_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((-1, ))
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(int(avg_len), 1/avg_len, 4000, 1)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, '/home/zleffke/captures/lithium_20180327/downlink_data_1.fc32', True)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((3, ))
        self.blocks_abs_xx_0 = blocks.abs_ff(1)
        self._avg_len_freq_tool_bar = Qt.QToolBar(self)
        self._avg_len_freq_tool_bar.addWidget(Qt.QLabel("avg_len_freq"+": "))
        self._avg_len_freq_line_edit = Qt.QLineEdit(str(self.avg_len_freq))
        self._avg_len_freq_tool_bar.addWidget(self._avg_len_freq_line_edit)
        self._avg_len_freq_line_edit.returnPressed.connect(
        	lambda: self.set_avg_len_freq(eng_notation.str_to_num(str(self._avg_len_freq_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._avg_len_freq_tool_bar, 5, 4, 1, 2)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -1*offset, 1, 0)
        self.analog_quadrature_demod_cf_1 = analog.quadrature_demod_cf((samp_rate/decim*interp)/(2*math.pi*fsk_dev/8.0))
        self.analog_agc2_xx_0 = analog.agc2_cc(10, 1e-1, 65536, 1)
        self.analog_agc2_xx_0.set_max_gain(65536)



        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_pdu_remove_0, 'pdus'), (self.burst_length_detect_0, 'cpdus'))
        self.msg_connect((self.burst_length_detect_0, 'cpdus'), (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.msg_connect((self.burst_length_detect_0, 'cpdus'), (self.pyqt_meta_text_output_0, 'pdus'))
        self.msg_connect((self.es_handler_pdu_0, 'pdus_out'), (self.blocks_pdu_remove_0, 'pdus'))
        self.msg_connect((self.es_trigger_edge_f_0, 'edge_event'), (self.es_handler_pdu_0, 'handle_event'))
        self.msg_connect((self.es_trigger_edge_f_0, 'which_stream'), (self.es_sink_0, 'schedule_event'))
        self.connect((self.analog_agc2_xx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.analog_quadrature_demod_cf_1, 0), (self.blocks_skiphead_0, 0))
        self.connect((self.analog_quadrature_demod_cf_1, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_abs_xx_0, 0), (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0), (self.es_trigger_edge_f_0, 0))
        self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_multiply_xx_1_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_multiply_xx_1_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_multiply_xx_1_0, 1))
        self.connect((self.blocks_skiphead_0, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_sub_xx_0, 0), (self.blocks_abs_xx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.es_trigger_edge_f_0, 0), (self.es_sink_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_1, 0))
        self.connect((self.low_pass_filter_0, 0), (self.es_trigger_edge_f_0, 1))
        self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_1_0, 1))
        self.connect((self.low_pass_filter_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.analog_agc2_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_1_0, 0))