Ejemplo n.º 1
0
    def test_000(self):
        dst_data = [0,0,1,2,0,2,1,0];
        src0 = blocks.vector_source_f(200*[0])
        src1 = blocks.vector_source_f(200*[1])
        src2 = blocks.vector_source_f(200*[2])
        itg = blocks.patterned_interleaver(gr.sizeof_float, dst_data)
        dst = blocks.vector_sink_f()
        head = blocks.head(gr.sizeof_float, 8);

        self.tb.connect( src0, (itg,0) );
        self.tb.connect( src1, (itg,1) );
        self.tb.connect( src2, (itg,2) );
        self.tb.connect( itg, head, dst );

        self.tb.run()
        self.assertEqual(list(dst_data), list(dst.data()))
Ejemplo n.º 2
0
    def test_000(self):
        dst_data = [0, 0, 1, 2, 0, 2, 1, 0]
        src0 = blocks.vector_source_f(200 * [0])
        src1 = blocks.vector_source_f(200 * [1])
        src2 = blocks.vector_source_f(200 * [2])
        itg = blocks.patterned_interleaver(gr.sizeof_float, dst_data)
        dst = blocks.vector_sink_f()
        head = blocks.head(gr.sizeof_float, 8)

        self.tb.connect(src0, (itg, 0))
        self.tb.connect(src1, (itg, 1))
        self.tb.connect(src2, (itg, 2))
        self.tb.connect(itg, head, dst)

        self.tb.run()
        self.assertEqual(list(dst_data), list(dst.data()))
Ejemplo n.º 3
0
    def __init__(self,
                 spread_seq=(-1, 1)
                 ):
        gr.hier_block2.__init__(
            self, "Variable Symbol Rate Modulation Modulator",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
        )

        ##################################################
        # Parameters
        ##################################################
        self.spread_seq = spread_seq

        ##################################################
        # Variables
        ##################################################

        ##################################################
        # Blocks
        ##################################################
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, len(spread_seq))
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, len(spread_seq))
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, len(spread_seq))
        self.blocks_patterned_interleaver_0 = blocks.patterned_interleaver(gr.sizeof_gr_complex*1, ([0] + [1]*len(spread_seq)))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((spread_seq))
        self.blocks_deinterleave_0 = blocks.deinterleave(gr.sizeof_gr_complex*1, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_deinterleave_0, 0), (self.blocks_patterned_interleaver_0, 0))
        self.connect((self.blocks_deinterleave_0, 1), (self.blocks_repeat_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.blocks_patterned_interleaver_0, 0), (self, 0))
        self.connect((self.blocks_repeat_0, 0), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_patterned_interleaver_0, 1))
        self.connect((self, 0), (self.blocks_deinterleave_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.target_rate = target_rate = 1e6
        self.target_freq = target_freq = 433.847e6
        self.symbol_duration = symbol_duration = 0.35e-3
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        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.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 5000, 100, firdes.WIN_HAMMING, 6.76))
        self.epy_block_1 = blk(threshold=0.0, coeff=0.15)
        self.epy_block_0 = blk(threshold=0.5)
        self.blocks_vector_source_x_0 = blocks.vector_source_f(
            list(ord(i) for i in "HELLO"), True, 1, [])
        self.blocks_throttle_2 = blocks.throttle(gr.sizeof_float * 1,
                                                 target_rate, True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 target_rate, True)
        self.blocks_repeat_0 = blocks.repeat(
            gr.sizeof_float * 1, int(target_rate * symbol_duration))
        self.blocks_patterned_interleaver_1 = blocks.patterned_interleaver(
            gr.sizeof_float * 1, ([
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1,
                1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
            ]))
        self.blocks_patterned_interleaver_0 = blocks.patterned_interleaver(
            gr.sizeof_float * 1, ([1, 0, 2]))
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((1, ))
        self.blocks_float_to_complex_1 = blocks.float_to_complex(1)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_gr_complex * 1,
            "/home/pintu/Desktop/GnuRadio/FIR Filter/output.txt", False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            target_rate, analog.GR_COS_WAVE, target_freq, 1, 0)
        self.analog_const_source_x_1 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 1)
        self.analog_const_source_x_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_patterned_interleaver_0, 1))
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_patterned_interleaver_1, 1))
        self.connect((self.analog_const_source_x_1, 0),
                     (self.blocks_patterned_interleaver_0, 2))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_float_to_complex_1, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_float_to_complex_1, 0))
        self.connect((self.blocks_patterned_interleaver_0, 0),
                     (self.blocks_patterned_interleaver_1, 0))
        self.connect((self.blocks_patterned_interleaver_1, 0),
                     (self.blocks_repeat_0, 0))
        self.connect((self.blocks_repeat_0, 0), (self.blocks_throttle_2, 0))
        self.connect((self.blocks_throttle_0, 0), (self.epy_block_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.epy_block_1, 0))
        self.connect((self.blocks_throttle_2, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_patterned_interleaver_0, 0))
        self.connect((self.epy_block_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.epy_block_1, 0), (self.qtgui_sink_x_0_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.blocks_file_sink_0, 0))
Ejemplo n.º 5
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.symbol_dur = symbol_dur = 0.000505
        self.samp_rate = samp_rate = 2e6
        self.radio_freq = radio_freq = 303.8e6

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.GetWin(),
            title='Scope Plot',
            sample_rate=samp_rate,
            v_scale=.2,
            v_offset=.5,
            t_scale=0.005,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_NORM,
            y_axis_label='Counts',
        )
        self.Add(self.wxgui_scopesink2_0.win)
        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(radio_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_wavfile_sink_0 = blocks.wavfile_sink(
            '/media/psf/Home/Desktop/fpgen.wav', 1, 2000000, 8)
        self.blocks_vector_source_x_0_0 = blocks.vector_source_c([
            0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1,
            1, 0, 1, 0, 0, 0, 1, 0, 0, 0
        ], True, 1, [])
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(0.1, .11, 0)
        self.blocks_repeat_0_3 = blocks.repeat(gr.sizeof_gr_complex * 1,
                                               int(samp_rate * symbol_dur))
        self.blocks_patterned_interleaver_0 = blocks.patterned_interleaver(
            gr.sizeof_gr_complex * 1, ([0, 1, 2]))
        self.blocks_interleave_0 = blocks.interleave(gr.sizeof_gr_complex * 1,
                                                     96)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.analog_const_source_x_0_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_const_source_x_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_patterned_interleaver_0, 0))
        self.connect((self.analog_const_source_x_0_0, 0),
                     (self.blocks_interleave_0, 1))
        self.connect((self.analog_const_source_x_0_0, 0),
                     (self.blocks_patterned_interleaver_0, 2))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_interleave_0, 0),
                     (self.blocks_repeat_0_3, 0))
        self.connect((self.blocks_patterned_interleaver_0, 0),
                     (self.blocks_interleave_0, 0))
        self.connect((self.blocks_repeat_0_3, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_wavfile_sink_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.wxgui_scopesink2_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.osmosdr_sink_0, 0))
        self.connect((self.blocks_vector_source_x_0_0, 0),
                     (self.blocks_patterned_interleaver_0, 1))
Ejemplo n.º 6
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Ask Keyer")

        ##################################################
        # Variables
        ##################################################
        self.tx_freq = tx_freq = 433.9e6
        self.symbol_length = symbol_length = 750e-6
        self.samp_rate = samp_rate = 2e6

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=samp_rate,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.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(tx_freq, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(20, 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_f([0,0,1,1,1,1,0,0,1,1,0,1,0,1,0,1,0,0,0,0,0,0,1,1,0], True, 1, [])
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, int(symbol_length*samp_rate))
        self.blocks_patterned_interleaver_0_0 = blocks.patterned_interleaver(gr.sizeof_float*1, ([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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]))
        self.blocks_patterned_interleaver_0 = blocks.patterned_interleaver(gr.sizeof_float*1, ([2,0,1]))
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, tx_freq, 1, 0)
        self.analog_const_source_x_0_1 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 1)
        self.analog_const_source_x_0_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0), (self.blocks_patterned_interleaver_0, 2))    
        self.connect((self.analog_const_source_x_0_0, 0), (self.blocks_patterned_interleaver_0_0, 1))    
        self.connect((self.analog_const_source_x_0_1, 0), (self.blocks_patterned_interleaver_0, 1))    
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.wxgui_scopesink2_0, 0))    
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_float_to_complex_0, 0))    
        self.connect((self.blocks_patterned_interleaver_0, 0), (self.blocks_patterned_interleaver_0_0, 0))    
        self.connect((self.blocks_patterned_interleaver_0_0, 0), (self.blocks_repeat_0, 0))    
        self.connect((self.blocks_repeat_0, 0), (self.blocks_throttle_0_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.osmosdr_sink_0, 0))    
        self.connect((self.blocks_throttle_0_0, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_patterned_interleaver_0, 0))