コード例 #1
0
    def setUp (self):
        print "qa_remove_cp2_cvc SetUp!"
        self.fftl = fftl = 2048
        cpl = 144*fftl/2048
        cpl0 = 160*fftl/2048
        self.slotl = slotl = 7*fftl+6*cpl+cpl0

        self.tb = gr.top_block ()
        
        #provide test data
        self.src = gr.noise_source_c(gr.GR_GAUSSIAN,1)
        self.head = gr.head( gr.sizeof_gr_complex, 10*slotl )
        self.tag = lte.pss_tagging_cc(fftl)
        # set up tagging block
        self.tag.set_half_frame_start(0)
        self.tag.set_N_id_2(1)
        self.tag.lock()
        
        # UUT
        self.rcp = lte.remove_cp2_cvc(fftl)
        
        # sinks
        self.snk = gr.vector_sink_c(fftl)
        self.tagsnc = gr.tag_debug(gr.sizeof_gr_complex*fftl, "remove_cp2_cvc")
        
        # connect blocks
        self.tb.connect(self.src, self.head, self.tag, self.rcp, self.snk )
コード例 #2
0
ファイル: qa_tag_debug.py プロジェクト: monikaomsharma/sandhi
 def test_001(self):
     # Just run some data through and make sure it doesn't puke.
     src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
     src = gr.vector_source_i(src_data)
     op = gr.tag_debug(gr.sizeof_int, "tag QA")
     self.tb.connect(src, op)
     self.tb.run()
     x = op.current_tags()
コード例 #3
0
 def test_001(self):
     # Just run some data through and make sure it doesn't puke.
     src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
     src = gr.vector_source_i(src_data)
     op = gr.tag_debug(gr.sizeof_int, "tag QA")
     self.tb.connect(src, op)
     self.tb.run()
     x = op.current_tags()
コード例 #4
0
ファイル: qa_pdu.py プロジェクト: denzfarid/gnuradio
    def test_000(self):
        # Just run some data through and make sure it doesn't puke.
        src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

        src = blocks.pdu_to_tagged_stream(blocks.byte_t)
        snk3 = blocks.tagged_stream_to_pdu(blocks.byte_t)
        snk2 = gr.vector_sink_b()
        snk = gr.tag_debug(1, "test")
        snk.set_display(False)

        dbg = gr.message_debug()

        # Test that the right number of ports exist.
        pi = snk3.message_ports_in()
        po = snk3.message_ports_out()
        self.assertEqual(pmt.pmt_length(pi), 0)
        self.assertEqual(pmt.pmt_length(po), 1)

        time.sleep(0.1)
        self.tb.connect(src, snk)
        self.tb.connect(src, snk2)
        self.tb.connect(src, snk3)
        self.tb.msg_connect(snk3, "pdus", dbg, "store")
        self.tb.start()

        # make our reference and message pmts
        port = pmt.pmt_intern("pdus")
        msg = pmt.pmt_cons(pmt.PMT_NIL, pmt.pmt_make_u8vector(16, 0xFF))

        # post the message
        src.to_basic_block()._post(port, msg)  # eww, what's that smell?

        while dbg.num_messages() < 1:
            time.sleep(0.5)
        self.tb.stop()
        self.tb.wait()

        # Get the vector of data from the vector sink
        result_data = snk2.data()

        # Get the vector of data from the message sink
        # Convert the message PMT as a pair into its vector
        result_msg = dbg.get_message(0)
        msg_vec = pmt.pmt_cdr(result_msg)
        #pmt.pmt_print(msg_vec)

        # Convert the PMT vector into a Python list
        msg_data = []
        for i in xrange(16):
            msg_data.append(pmt.pmt_u8vector_ref(msg_vec, i))

        actual_data = 16 * [
            0xFF,
        ]
        self.assertEqual(actual_data, list(result_data))
        self.assertEqual(actual_data, msg_data)
コード例 #5
0
ファイル: qa_pdu.py プロジェクト: denzfarid/gnuradio
    def test_000(self):
        # Just run some data through and make sure it doesn't puke.
        src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

        src = blocks.pdu_to_tagged_stream(blocks.byte_t)
        snk3 = blocks.tagged_stream_to_pdu(blocks.byte_t)
        snk2 = gr.vector_sink_b()
        snk = gr.tag_debug(1, "test")
        snk.set_display(False)

        dbg = gr.message_debug()

        # Test that the right number of ports exist.
        pi = snk3.message_ports_in()
        po = snk3.message_ports_out()
        self.assertEqual(pmt.pmt_length(pi), 0)
        self.assertEqual(pmt.pmt_length(po), 1)

        time.sleep(0.1)
        self.tb.connect(src, snk)
        self.tb.connect(src, snk2)
        self.tb.connect(src, snk3)
        self.tb.msg_connect(snk3, "pdus", dbg, "store")
        self.tb.start()

        # make our reference and message pmts
        port = pmt.pmt_intern("pdus")
        msg = pmt.pmt_cons( pmt.PMT_NIL, pmt.pmt_make_u8vector(16, 0xFF))

        # post the message
        src.to_basic_block()._post(port, msg) # eww, what's that smell?

        while dbg.num_messages() < 1:
            time.sleep(0.5)
        self.tb.stop()
        self.tb.wait()

        # Get the vector of data from the vector sink
        result_data = snk2.data()

        # Get the vector of data from the message sink
        # Convert the message PMT as a pair into its vector
        result_msg = dbg.get_message(0)
        msg_vec = pmt.pmt_cdr(result_msg)
        #pmt.pmt_print(msg_vec)

        # Convert the PMT vector into a Python list
        msg_data = []
        for i in xrange(16):
            msg_data.append(pmt.pmt_u8vector_ref(msg_vec, i))

        actual_data = 16*[0xFF,]
        self.assertEqual(actual_data, list(result_data))
        self.assertEqual(actual_data, msg_data)
コード例 #6
0
    def setUp(self):
        self.tb = gr.top_block()

        fftl = 2048
        N_rb_dl = 6

        # These blocks are just "dummy" blocks for this QA
        self.eq = lte.linear_OFDM_estimator_vcvc(N_rb_dl)
        self.demux = lte.pbch_demux_vcvc(N_rb_dl)
        self.descr = lte.descrambling_vfvf()
        self.daemon = lte.cell_id_daemon(self.eq, self.demux, self.descr)

        # Source 'n' Sink
        data = range(2 * fftl)
        self.src = gr.vector_source_c(data, False, fftl)
        self.snk = gr.vector_sink_c(fftl)
        self.tagsnk = gr.tag_debug(gr.sizeof_gr_complex * fftl, "SYMBOL TAG")
        # This is the UUT
        self.sss = lte.hier_sss_sync2_vcvc(self.daemon, fftl)

        self.tb.connect(self.src, self.sss, self.snk)
        self.tb.connect(self.sss, self.tagsnk)
コード例 #7
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        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)

        ##################################################
        # Variables
        ##################################################
        self.snr_db = snr_db = 3
        self.noiseAmplitude = noiseAmplitude = sqrt(1 / (10**(0.1 * snr_db)))
        self.constellation = constellation = [-1.3416, -0.4472, 0.4472, 1.3416]
        self.bits = bits = 2

        ##################################################
        # Blocks
        ##################################################
        self.random_source_x_0 = gr.vector_source_b(
            map(int, numpy.random.randint(0, 4, 10000)), True)
        self.qtgui_sink_x_0_0_1 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            400,  #bw
            "QT GUI Plot",  #name
            False,  #plotfreq
            False,  #plotwaterfall
            False,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0_0_1.set_update_time(1.0 / 100)
        self._qtgui_sink_x_0_0_1_win = sip.wrapinstance(
            self.qtgui_sink_x_0_0_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_0_1_win)
        self.gr_tag_debug_0 = gr.tag_debug(gr.sizeof_float * 1, "")
        self.gr_noise_source_x_0 = gr.noise_source_f(gr.GR_GAUSSIAN,
                                                     noiseAmplitude, 0)
        self.gr_file_sink_1 = gr.file_sink(gr.sizeof_gr_complex * 1,
                                           "symbols.bin")
        self.gr_file_sink_1.set_unbuffered(False)
        self.gr_file_sink_0_0 = gr.file_sink(gr.sizeof_char * 1, "output.bin")
        self.gr_file_sink_0_0.set_unbuffered(False)
        self.gr_file_sink_0 = gr.file_sink(gr.sizeof_char * 1, "input.bin")
        self.gr_file_sink_0.set_unbuffered(False)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            digital.constellation_calcdist([-3, -1, 1, 3], [], 1, 1).base())
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf(
            (constellation), 1)
        self.const_source_x_0 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, 100)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.blks2_error_rate_0 = grc_blks2.error_rate(
            type='BER',
            win_size=10000,
            bits_per_symbol=bits,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.random_source_x_0, 0), (self.blks2_error_rate_0, 0))
        self.connect((self.random_source_x_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.gr_noise_source_x_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.blks2_error_rate_0, 1))
        self.connect((self.random_source_x_0, 0), (self.gr_file_sink_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.gr_file_sink_0_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.const_source_x_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.qtgui_sink_x_0_0_1, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.gr_file_sink_1, 0))
        self.connect((self.blks2_error_rate_0, 0), (self.gr_tag_debug_0, 0))
コード例 #8
0
    def test_001(self):
        N = 1000
	outfile = "test_out.dat"

        detached = False
        samp_rate = 200000
        key = pmt.pmt_intern("samp_rate")
        val = pmt.pmt_from_double(samp_rate)
        extras = pmt.pmt_make_dict()
        extras = pmt.pmt_dict_add(extras, key, val)
        extras_str = pmt.pmt_serialize_str(extras)

        data = sig_source_c(samp_rate, 1000, 1, N)
        src  = gr.vector_source_c(data)
        fsnk = blocks.file_meta_sink(gr.sizeof_gr_complex, outfile,
                                     samp_rate, 1, 
                                     blocks.GR_FILE_FLOAT, True,
                                     1000000, extras_str, detached)
        fsnk.set_unbuffered(True)

	self.tb.connect(src, fsnk)
	self.tb.run()
        fsnk.close()

        handle = open(outfile, "rb")
        header_str = handle.read(parse_file_metadata.HEADER_LENGTH)
        if(len(header_str) == 0):
            self.assertFalse()

        try:
            header = pmt.pmt_deserialize_str(header_str)
        except RuntimeError:
            self.assertFalse()

        print header
        info = parse_file_metadata.parse_header(header, False)

        extra_str = handle.read(info["extra_len"])
        self.assertGreater(len(extra_str), 0)
        handle.close()

        try:
            extra = pmt.pmt_deserialize_str(extra_str)
        except RuntimeError:
            self.assertFalse()

        extra_info = parse_file_metadata.parse_extra_dict(extra, info, False)

        self.assertEqual(info['rx_rate'], samp_rate)
        self.assertEqual(pmt.pmt_to_double(extra_info['samp_rate']), samp_rate)


        # Test file metadata source
        src.rewind()
        fsrc = blocks.file_meta_source(outfile, False)
        vsnk = gr.vector_sink_c()
        tsnk = gr.tag_debug(gr.sizeof_gr_complex, "QA")
        ssnk = gr.vector_sink_c()
        self.tb.disconnect(src, fsnk)
        self.tb.connect(fsrc, vsnk)
        self.tb.connect(fsrc, tsnk)
        self.tb.connect(src, ssnk)
        self.tb.run()

        # Test to make sure tags with 'samp_rate' and 'rx_rate' keys
        # were generated and received correctly.
        tags = tsnk.current_tags()
        for t in tags:
            if(pmt.pmt_eq(t.key, pmt.pmt_intern("samp_rate"))):
                self.assertEqual(pmt.pmt_to_double(t.value), samp_rate)
            elif(pmt.pmt_eq(t.key, pmt.pmt_intern("rx_rate"))):
                self.assertEqual(pmt.pmt_to_double(t.value), samp_rate)

        # Test that the data portion was extracted and received correctly.
        self.assertComplexTuplesAlmostEqual(vsnk.data(), ssnk.data(), 5)

	os.remove(outfile)
コード例 #9
0
ファイル: ofdm_txrx.py プロジェクト: pjcfifa/gnuradio
 def __init__(self, fft_len=_def_fft_len, cp_len=_def_cp_len,
              frame_length_tag_key=_def_frame_length_tag_key,
              occupied_carriers=_def_occupied_carriers,
              pilot_carriers=_def_pilot_carriers,
              pilot_symbols=_def_pilot_symbols,
              bps_header=1,
              bps_payload=1,
              sync_word1=None,
              sync_word2=None,
              rolloff=0
              ):
     gr.hier_block2.__init__(self, "ofdm_tx",
                 gr.io_signature(1, 1, gr.sizeof_char),
                 gr.io_signature(1, 1, gr.sizeof_gr_complex))
     self.fft_len           = fft_len
     self.cp_len            = cp_len
     self.frame_length_tag_key    = frame_length_tag_key
     self.occupied_carriers = occupied_carriers
     self.pilot_carriers    = pilot_carriers
     self.pilot_symbols     = pilot_symbols
     self.bps_header        = bps_header
     self.bps_payload       = bps_payload
     n_sync_words = 1
     header_constellation  = _get_constellation(bps_header)
     header_mod = digital.chunks_to_symbols_bc(header_constellation.points())
     self.sync_word1 = sync_word1
     if sync_word1 is None:
         self.sync_word1 = _make_sync_word(fft_len, occupied_carriers, header_constellation)
     else:
         if len(sync_word1) != self.fft_len:
             raise ValueError("Length of sync sequence(s) must be FFT length.")
     total_sync_word = self.sync_word1
     self.sync_word2 = ()
     if sync_word2 is not None:
         if len(sync_word2) != fft_len:
             raise ValueError("Length of sync sequence(s) must be FFT length.")
         self.sync_word2 = sync_word2
         n_sync_words = 2
         total_sync_word = sync_word1 + sync_word2
     crc = digital.crc32_bb(False, self.frame_length_tag_key)
     formatter_object = digital.packet_header_ofdm(
         occupied_carriers, 1, "", "", "",
         bps_header
     )
     header_gen = digital.packet_headergenerator_bb(formatter_object.base())
     header_payload_mux = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, self.frame_length_tag_key)
     self.connect(self, crc, header_gen, header_mod, (header_payload_mux, 0))
     payload_constellation = _get_constellation(bps_payload)
     payload_mod = digital.chunks_to_symbols_bc(payload_constellation.points())
     self.connect(
         crc,
         blocks.repack_bits_bb(8, bps_payload, frame_length_tag_key),
         payload_mod,
         (header_payload_mux, 1)
     )
     self.connect(payload_mod, gr.tag_debug(gr.sizeof_gr_complex, "pmod"))
     sync_word_gen = gr.vector_source_c(
         total_sync_word, True, self.fft_len,
         tagged_streams.make_lengthtags((n_sync_words,), (0,), self.frame_length_tag_key)
     )
     allocator = digital.ofdm_carrier_allocator_cvc(
         self.fft_len,
         occupied_carriers=self.occupied_carriers,
         pilot_carriers=self.pilot_carriers,
         pilot_symbols=self.pilot_symbols,
         len_tag_key=self.frame_length_tag_key
     )
     syncword_data_mux  = blocks.tagged_stream_mux(gr.sizeof_gr_complex*self.fft_len, self.frame_length_tag_key)
     self.connect(sync_word_gen, (syncword_data_mux, 0))
     self.connect(header_payload_mux, allocator, (syncword_data_mux, 1))
     ffter = fft.fft_vcc(self.fft_len, False, (), False)
     cyclic_prefixer = digital.ofdm_cyclic_prefixer(
         self.fft_len,
         self.fft_len+self.cp_len,
         rolloff,
         self.frame_length_tag_key
     )
     self.connect(syncword_data_mux, ffter, cyclic_prefixer, self)
コード例 #10
0
ファイル: qa_file_metadata.py プロジェクト: zeokav/sandhi
    def test_001(self):
        N = 1000
        outfile = "test_out.dat"

        detached = False
        samp_rate = 200000
        key = pmt.pmt_intern("samp_rate")
        val = pmt.pmt_from_double(samp_rate)
        extras = pmt.pmt_make_dict()
        extras = pmt.pmt_dict_add(extras, key, val)
        extras_str = pmt.pmt_serialize_str(extras)

        data = sig_source_c(samp_rate, 1000, 1, N)
        src = gr.vector_source_c(data)
        fsnk = blocks.file_meta_sink(
            gr.sizeof_gr_complex, outfile, samp_rate, 1, blocks.GR_FILE_FLOAT, True, 1000000, extras_str, detached
        )
        fsnk.set_unbuffered(True)

        self.tb.connect(src, fsnk)
        self.tb.run()
        fsnk.close()

        handle = open(outfile, "rb")
        header_str = handle.read(parse_file_metadata.HEADER_LENGTH)
        if len(header_str) == 0:
            self.assertFalse()

        try:
            header = pmt.pmt_deserialize_str(header_str)
        except RuntimeError:
            self.assertFalse()

        print header
        info = parse_file_metadata.parse_header(header, False)

        extra_str = handle.read(info["extra_len"])
        self.assertGreater(len(extra_str), 0)
        handle.close()

        try:
            extra = pmt.pmt_deserialize_str(extra_str)
        except RuntimeError:
            self.assertFalse()

        extra_info = parse_file_metadata.parse_extra_dict(extra, info, False)

        self.assertEqual(info["rx_rate"], samp_rate)
        self.assertEqual(pmt.pmt_to_double(extra_info["samp_rate"]), samp_rate)

        # Test file metadata source
        src.rewind()
        fsrc = blocks.file_meta_source(outfile, False)
        vsnk = gr.vector_sink_c()
        tsnk = gr.tag_debug(gr.sizeof_gr_complex, "QA")
        ssnk = gr.vector_sink_c()
        self.tb.disconnect(src, fsnk)
        self.tb.connect(fsrc, vsnk)
        self.tb.connect(fsrc, tsnk)
        self.tb.connect(src, ssnk)
        self.tb.run()

        # Test to make sure tags with 'samp_rate' and 'rx_rate' keys
        # were generated and received correctly.
        tags = tsnk.current_tags()
        for t in tags:
            if pmt.pmt_eq(t.key, pmt.pmt_intern("samp_rate")):
                self.assertEqual(pmt.pmt_to_double(t.value), samp_rate)
            elif pmt.pmt_eq(t.key, pmt.pmt_intern("rx_rate")):
                self.assertEqual(pmt.pmt_to_double(t.value), samp_rate)

        # Test that the data portion was extracted and received correctly.
        self.assertComplexTuplesAlmostEqual(vsnk.data(), ssnk.data(), 5)

        os.remove(outfile)