예제 #1
0
    def test_005_t(self):
        # Interleaver to deinterleaver
        data_in_I = [
            i * 2 - 1
            for i in np.random.randint(0, 2, (2 * len(self.c.codewords[0]) * (
                self.c.nsym_frame - len(self.c.preamble) - len(self.c.SFD)), ))
        ]
        data_in_Q = [
            i * 2 - 1
            for i in np.random.randint(0, 2, (2 * len(self.c.codewords[0]) * (
                self.c.nsym_frame - len(self.c.preamble) - len(self.c.SFD)), ))
        ]
        self.src_I = blocks.vector_source_i(data_in_I)
        self.snk_I = blocks.vector_sink_i(1)
        self.src_Q = blocks.vector_source_i(data_in_Q)
        self.snk_Q = blocks.vector_sink_i(1)

        self.tb.connect(self.src_I, self.interleaver_I,
                        self.preamble_sfd_prefixer_I, (self.qpsk_mapper, 0))
        self.tb.connect(self.src_Q, self.interleaver_Q,
                        self.preamble_sfd_prefixer_Q, (self.qpsk_mapper, 1))
        self.tb.connect(self.qpsk_mapper, self.dqpsk_mapper, self.dqcsk_mapper,
                        self.dqcsk_demapper, self.dqpsk_demapper,
                        self.qpsk_demapper)
        self.tb.connect((self.qpsk_demapper, 0), self.preamble_sfd_removal_I,
                        self.deinterleaver_I, self.snk_I)
        self.tb.connect((self.qpsk_demapper, 1), self.preamble_sfd_removal_Q,
                        self.deinterleaver_Q, self.snk_Q)

        self.tb.run()

        data_out_I = self.snk_I.data()
        data_out_Q = self.snk_Q.data()
        self.assertFloatTuplesAlmostEqual(data_out_I, data_in_I)
        self.assertFloatTuplesAlmostEqual(data_out_I, data_in_I)
예제 #2
0
    def test_004_t(self):
        # Preamble and SFD prefixer to removal
        data_in_I = [
            i * 2 - 1 for i in np.random.randint(0, 2, (2 * (
                self.c.nsym_frame - len(self.c.preamble) - len(self.c.SFD)), ))
        ]
        data_in_Q = [
            i * 2 - 1 for i in np.random.randint(0, 2, (2 * (
                self.c.nsym_frame - len(self.c.preamble) - len(self.c.SFD)), ))
        ]
        self.src_I = blocks.vector_source_i(data_in_I)
        self.snk_I = blocks.vector_sink_i(1)
        self.src_Q = blocks.vector_source_i(data_in_Q)
        self.snk_Q = blocks.vector_sink_i(1)

        # self.dbg_sink1 = blocks.vector_sink_i(1)
        # self.dbg_sink2 = blocks.vector_sink_i(1)
        # self.dbg_sink3 = blocks.vector_sink_f(1)
        # self.dbg_sink4 = blocks.vector_sink_f(1)
        # self.dbg_sink5 = blocks.vector_sink_c(1)
        # self.dbg_sink6 = blocks.vector_sink_f(1)
        # self.dbg_sink7 = blocks.vector_sink_f(1)

        self.tb.connect(self.src_I, self.preamble_sfd_prefixer_I,
                        (self.qpsk_mapper, 0))
        self.tb.connect(self.src_Q, self.preamble_sfd_prefixer_Q,
                        (self.qpsk_mapper, 1))
        self.tb.connect(self.qpsk_mapper, self.dqpsk_mapper, self.dqcsk_mapper,
                        self.dqcsk_demapper, self.dqpsk_demapper,
                        self.qpsk_demapper)
        self.tb.connect((self.qpsk_demapper, 0), self.preamble_sfd_removal_I,
                        self.snk_I)
        self.tb.connect((self.qpsk_demapper, 1), self.preamble_sfd_removal_Q,
                        self.snk_Q)

        # self.tb.connect((self.qpsk_mapper,0), self.dbg_sink3)
        # self.tb.connect(self.preamble_sfd_prefixer_I, self.dbg_sink2)
        # self.tb.connect(self.dqpsk_mapper, self.dbg_sink4)
        # self.tb.connect(self.dqcsk_mapper, self.dbg_sink5)
        # self.tb.connect(self.dqcsk_demapper, self.dbg_sink6)
        # self.tb.connect(self.dqcsk_demapper, self.dbg_sink7)

        self.tb.run()

        # print "sfd prefixer output len:", len(self.dbg_sink2.data())
        # print "qpsk mapper output len:", len(self.dbg_sink3.data())
        # print "dqpsk mapper output len:", len(self.dbg_sink4.data())
        # print "dqcsk mapper output len:", len(self.dbg_sink5.data())
        # print "dqcsk demapper output len:", len(self.dbg_sink6.data())
        # print "dqpsk demapper output len:", len(self.dbg_sink7.data())

        data_out_I = self.snk_I.data()
        data_out_Q = self.snk_Q.data()
        self.assertFloatTuplesAlmostEqual(data_in_I, data_out_I)
        self.assertFloatTuplesAlmostEqual(data_in_Q, data_out_Q)
 def test_001_t (self):
     # set up fg
     self.src_I = blocks.vector_source_i([1,-1,1,-1])
     self.src_Q = blocks.vector_source_i([1,1,-1,-1])
     self.qpsk_mapper = ieee802_15_4.qpsk_mapper_if()
     self.snk = blocks.vector_sink_f(1)
     self.tb.connect(self.src_I, (self.qpsk_mapper,0))
     self.tb.connect(self.src_Q, (self.qpsk_mapper,1))
     self.tb.connect(self.qpsk_mapper, self.snk)
     self.tb.run ()
     # check data
     ref = [0, np.pi/2, -np.pi/2, np.pi]
     data = self.snk.data()
     self.assertFloatTuplesAlmostEqual(data, ref, 5)
예제 #4
0
 def test_001_t(self):
     # set up fg
     self.src_I = blocks.vector_source_i([1, -1, 1, -1])
     self.src_Q = blocks.vector_source_i([1, 1, -1, -1])
     self.qpsk_mapper = ieee802_15_4.qpsk_mapper_if()
     self.snk = blocks.vector_sink_f(1)
     self.tb.connect(self.src_I, (self.qpsk_mapper, 0))
     self.tb.connect(self.src_Q, (self.qpsk_mapper, 1))
     self.tb.connect(self.qpsk_mapper, self.snk)
     self.tb.run()
     # check data
     ref = [0, np.pi / 2, -np.pi / 2, np.pi]
     data = self.snk.data()
     self.assertFloatTuplesAlmostEqual(data, ref, 5)
예제 #5
0
    def test_007_dual_notags(self):
        '''
        Tests 2 inbound streams with no tags
        '''
        # Just run some data through and make sure it doesn't puke.
        src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
        src1 = blocks.vector_source_i(src_data)
        src2 = blocks.vector_source_i(src_data)
        dut = sandia_utils.sandia_tag_debug(gr.sizeof_int, "tag QA")
        self.tb.connect(src1, (dut, 0))
        self.tb.connect(src2, (dut, 1))

        self.tb.run()

        self.assertEqual(0, dut.num_tags())
예제 #6
0
 def __init__(self):
     gr.top_block.__init__(self)
     #variables
     self.samp_rate = samp_rate
     self.direction = RC_NOTHING #no direction to start 
     #blocks 
     #define the gnuradio blocks
     #interpolator expands the input function - this creates long zeros and ones  
     self.interpolator = rccar2.functioninterpolator(samp_rate)
     #functioncoder takes a functioncode into it and creates the appropriate command stream 
     self.functioncoder = rccar2.functioncoder(samplerate=samp_rate, functioncode=1)
     #sink (the hackRF in this case), can be changed to your transmitting device of course
     self.hackrf = osmosdr.sink(args="numchan=" +str(1) + " " + "hackhf")
     self.hackrf.set_sample_rate(samp_rate)
     self.hackrf.set_center_freq(RC_FREQUENCY,0)
     self.hackrf.set_freq_corr(0,0)
     #enable the hackrf to transmit (need to set the gain to 14dB) 
     self.hackrf.set_gain(14,0)
     self.hackrf.set_if_gain(30,0)
     self.hackrf.set_bb_gain(20,0)
     self.hackrf.set_antenna("",0)
     self.hackrf.set_bandwidth(0,0)
     #conversion blocks 
     self.float_to_complex = blocks.float_to_complex(1)
     self.char_to_float = blocks.char_to_float(1,1)
     #vector source which sends the direction to the functioncoder 
     self.vector_source = blocks.vector_source_i([self.direction], False) 
     #connect it all up
     self.connect((self.char_to_float,0), (self.float_to_complex,0))
     self.connect((self.char_to_float,0), (self.float_to_complex,1)) 
     self.connect((self.interpolator,0), (self.char_to_float,0))
     self.connect((self.float_to_complex,0), (self.hackrf,0))
     self.connect((self.vector_source,0), (self.functioncoder,0))
     self.connect((self.functioncoder,0), (self.interpolator,0))
예제 #7
0
 def __init__(self, Sps=4, h=[1, 1, 1, 1]):
     gr.hier_block2.__init__(
         self,
         "e_generador_fun_f",
         gr.io_signature(0, 0, 0),
         gr.io_signature(1, 1, gr.sizeof_float * 1),
     )
     ##################################################
     # Parameters
     ##################################################
     self.Sps = Sps
     self.h = h
     ##################################################
     # Blocks
     ##################################################
     self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff(Sps, (h))
     self.interp_fir_filter_xxx_0.declare_sample_delay(0)
     self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2., ))
     self.blocks_int_to_float_0 = blocks.int_to_float(1, 1)
     self.blocks_add_const_vxx_0 = blocks.add_const_vff((-0.5, ))
     self.analog_random_source_x_0 = blocks.vector_source_i(
         map(int, np.random.randint(0, 2, 1000000)), True)
     ##################################################
     # Connections
     ##################################################
     self.connect((self.analog_random_source_x_0, 0),
                  (self.blocks_int_to_float_0, 0))
     self.connect((self.blocks_add_const_vxx_0, 0),
                  (self.blocks_multiply_const_vxx_0, 0))
     self.connect((self.blocks_int_to_float_0, 0),
                  (self.blocks_add_const_vxx_0, 0))
     self.connect((self.blocks_multiply_const_vxx_0, 0),
                  (self.interp_fir_filter_xxx_0, 0))
     self.connect((self.interp_fir_filter_xxx_0, 0), (self, 0))
예제 #8
0
 def __init__(self, data):
     gr.hier_block2.__init__(self, "ints_to_floats",
                             gr.io_signature(0, 0, 0),
                             gr.io_signature(1, 1, gr.sizeof_float))
     self.src = blocks.vector_source_i(data)
     self.cvt = blocks.int_to_float()
     self.connect(self.src, self.cvt, self)
    def test_001_t (self):
    	# This test case is from Fundamentals of Error-Correcting
    	# Codes by Huffman and Pless. First part of Example 15.7.1.

    	# Generator matrix from textbook example
    	G = np.array([[1,0,0,0,0,1,1,1],
	                  [0,1,0,0,1,0,1,1],
	                  [0,0,1,0,1,1,0,1],
	                  [0,0,0,1,1,1,1,0]])
    	# this is the dataword to be encoded
    	dataword = (1,0,1,1)
    	# this is what the encoder should produce
    	codeword = (1,0,1,1,0,1,0,0)
    	k = len(dataword)
    	n = len(codeword)
    	src = blocks.vector_source_i(dataword)
        str2vec = blocks.stream_to_vector(4, k)
        vec2str = blocks.vector_to_stream(4, n)
        encoder = generator_matrix_encoder_ss(G)
        dst = blocks.vector_sink_i()
        self.tb.connect(src, str2vec, encoder, vec2str, dst)
        self.tb.run ()
        result_data = dst.data()
        # check data
        self.assertTupleEqual(codeword,result_data)
예제 #10
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000
        self.P = P = 10
        self.N = N = 8
        self.M = M = 20

        ##################################################
        # Blocks
        ##################################################
        self.gaussian_code_gaussian_code_if_0 = gaussian_code.gaussian_code_if(
            7, N, P)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1,
                                                 samp_rate, True)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float * 1,
                                                   "ber.txt", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.analog_random_source_x_0 = blocks.vector_source_i(
            map(int, numpy.random.randint(0, M - 1, 1000)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0),
                     (self.gaussian_code_gaussian_code_if_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.gaussian_code_gaussian_code_if_0, 0),
                     (self.blocks_throttle_0, 0))
예제 #11
0
    def test_vector_int(self):
        tb = self.tb

        vlen = 5
        N = 10 * vlen
        data = make_random_float_tuple(N, 2**10)
        data = [int(d * 1000) for d in data]
        src = blocks.vector_source_i(data, False)
        one_to_many = blocks.stream_to_streams(gr.sizeof_int, vlen)
        one_to_vector = blocks.stream_to_vector(gr.sizeof_int, vlen)
        many_to_vector = blocks.streams_to_vector(gr.sizeof_int, vlen)
        isolated = [blocks.moving_average_ii(100, 1) for i in range(vlen)]
        dut = blocks.moving_average_ii(100, 1, vlen=vlen)
        dut_dst = blocks.vector_sink_i(vlen=vlen)
        ref_dst = blocks.vector_sink_i(vlen=vlen)

        tb.connect(src, one_to_many)
        tb.connect(src, one_to_vector, dut, dut_dst)
        tb.connect(many_to_vector, ref_dst)
        for idx, single in enumerate(isolated):
            tb.connect((one_to_many, idx), single, (many_to_vector, idx))

        tb.run()

        dut_data = dut_dst.data()
        ref_data = ref_dst.data()

        # make sure result is close to zero
        self.assertTupleEqual(dut_data, ref_data)
예제 #12
0
    def __init__(self, data):
	gr.hier_block2.__init__(self, "ints_to_floats",
				gr.io_signature(0, 0, 0),
				gr.io_signature(1, 1, gr.sizeof_float))
        self.src = blocks.vector_source_i(data)
        self.cvt = blocks.int_to_float()
        self.connect(self.src, self.cvt, self)
    def test_003(self):
        data = range(1,9)

        self.src = blocks.vector_source_i(data, True)
        self.probe = blocks.ctrlport_probe2_i("samples","Integers",
                                              len(data), gr.DISPNULL)
        probe_name = self.probe.alias()

        self.tb.connect(self.src, self.probe)
        self.tb.start()

        expected_result = [1, 2, 3, 4, 5, 6, 7, 8,]

        # Make sure we have time for flowgraph to run
        time.sleep(0.1)

        # Get available endpoint
        ep = gr.rpcmanager_get().endpoints()[0]

        # Initialize a simple Ice client from endpoint
        ic = Ice.initialize(sys.argv)
        base = ic.stringToProxy(ep)
        radio = GNURadio.ControlPortPrx.checkedCast(base)

        # Get all exported knobs
        ret = radio.get([probe_name + "::samples"])
        for name in ret.keys():
            # Get data in probe, which might be offset; find the
            # beginning and unwrap.
            result = ret[name].value
            i = result.index(1.0)
            result = result[i:] + result[0:i]
            self.assertEqual(expected_result, result)

        self.tb.stop()
예제 #14
0
    def test_001(self):
        src_data = ( 1,  2,  3,  4,  5,  6,  7,  8,  9,  10)
        trg_data = (-1, -1,  1,  1, -1, -1,  1,  1, -1,  -1)
        src = blocks.vector_source_i(src_data)
        trg = blocks.vector_source_s(trg_data)
        op  = blocks.burst_tagger(gr.sizeof_int)
        snk = blocks.tagged_file_sink(gr.sizeof_int, 1)
        self.tb.connect(src, (op,0))
        self.tb.connect(trg, (op,1))
        self.tb.connect(op, snk)
        self.tb.run()

        # Tagged file sink gets 2 burst tags at index 2 and index 5.
        # Creates two new files, each with two integers in them from
        # src_data at these indexes (3,4) and (7,8).
        file0 = "file{0}_0_2.00000000.dat".format(snk.unique_id())
        file1 = "file{0}_1_6.00000000.dat".format(snk.unique_id())

        # Open the files and read in the data, then remove the files
        # to clean up the directory.
        outfile0 = open(file0, 'rb')
        outfile1 = open(file1, 'rb')
        data0 = outfile0.read(8)
        data1 = outfile1.read(8)
        outfile0.close()
        outfile1.close()
        os.remove(file0)
        os.remove(file1)

        # Convert the 8 bytes from the files into a tuple of 2 ints.
        idata0 = struct.unpack('ii', data0)
        idata1 = struct.unpack('ii', data1)

        self.assertEqual(idata0, (3, 4))
        self.assertEqual(idata1, (7, 8))
예제 #15
0
    def test_004_cleartags(self):
        '''
        testing sandia_tag_debug::clear_tags() function
        '''
        src_tag1 = gr.tag_utils.python_to_tag([
            0,
            pmt.intern("sam"),
            pmt.from_double(10000),
            pmt.intern("test_003_tags")
        ])
        src_tag2 = gr.tag_utils.python_to_tag([
            1,
            pmt.intern("peter"),
            pmt.from_double(1000),
            pmt.intern("test_003_tags")
        ])
        src_tag3 = gr.tag_utils.python_to_tag([
            2,
            pmt.intern("jacob"),
            pmt.from_double(100),
            pmt.intern("test_003_tags")
        ])

        src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
        src = blocks.vector_source_i(src_data, False, 1,
                                     [src_tag1, src_tag2, src_tag3])
        dut = sandia_utils.sandia_tag_debug(gr.sizeof_int, "tag QA")
        self.tb.connect(src, dut)

        self.tb.run()

        self.assertEqual(3, dut.num_tags())
        dut.clear_tags()
        self.assertEqual(0, dut.num_tags())
 def test_002_interleave_ints(self):
     # set up fg
     src1 = (1, 2, 3, 4)
     src2 = (5, 6, 7, 8)
     res_exp = (1, 2, 5, 6, 3, 4, 7, 8)
     src1_blk = blocks.vector_source_i(src1)
     src2_blk = blocks.vector_source_i(src2)
     inter_blk = interleaver.interleaver(4, 2)
     dst_blk = blocks.vector_sink_i()
     self.tb.connect((src1_blk, 0), (inter_blk, 0))
     self.tb.connect((src2_blk, 0), (inter_blk, 1))
     self.tb.connect(inter_blk, dst_blk)
     self.tb.run()
     # check data
     res_act = dst_blk.data()
     self.assertEqual(res_exp, res_act)
예제 #17
0
    def test_001(self):
        src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
        trg_data = (-1, -1, 1, 1, -1, -1, 1, 1, -1, -1)
        src = blocks.vector_source_i(src_data)
        trg = blocks.vector_source_s(trg_data)
        op = blocks.burst_tagger(gr.sizeof_int)
        snk = blocks.tagged_file_sink(gr.sizeof_int, 1)
        self.tb.connect(src, (op, 0))
        self.tb.connect(trg, (op, 1))
        self.tb.connect(op, snk)
        self.tb.run()

        # Tagged file sink gets 2 burst tags at index 2 and index 5.
        # Creates two new files, each with two integers in them from
        # src_data at these indexes (3,4) and (7,8).
        file0 = "file{0}_0_2.00000000.dat".format(snk.unique_id())
        file1 = "file{0}_1_6.00000000.dat".format(snk.unique_id())

        # Open the files and read in the data, then remove the files
        # to clean up the directory.
        outfile0 = open(file0, 'rb')
        outfile1 = open(file1, 'rb')
        data0 = outfile0.read(8)
        data1 = outfile1.read(8)
        outfile0.close()
        outfile1.close()
        os.remove(file0)
        os.remove(file1)

        # Convert the 8 bytes from the files into a tuple of 2 ints.
        idata0 = struct.unpack('ii', data0)
        idata1 = struct.unpack('ii', data1)

        self.assertEqual(idata0, (3, 4))
        self.assertEqual(idata1, (7, 8))
예제 #18
0
    def test_002_1tag(self):
        '''
        Tests a stream with a single tag
        '''

        src_tag = gr.tag_utils.python_to_tag([
            0,
            pmt.intern("sam"),
            pmt.from_double(10000),
            pmt.intern("test_002_1tag")
        ])

        src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
        src = blocks.vector_source_i(src_data, False, 1, [src_tag])
        dut = sandia_utils.sandia_tag_debug(gr.sizeof_int, "tag QA")
        self.tb.connect(src, dut)

        self.tb.run()

        self.assertEqual(1, dut.num_tags())

        tag0 = dut.get_tag(0)

        self.assertTrue(pmt.eq(tag0.key, pmt.intern("sam")))
        self.assertAlmostEqual(10000, pmt.to_double(tag0.value))
예제 #19
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32e3

        ##################################################
        # Blocks
        ##################################################
        self.blocks_vector_source_x_0 = blocks.vector_source_i((0, 1, 2, 3),
                                                               True, 1, [])
        self.blocks_null_source_0 = blocks.null_source(gr.sizeof_float * 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_int_to_float_0 = blocks.int_to_float(1, 1)
        self.Mercurial_SDR_0 = Mercurial_SDR.Mercurial_SDR(
            'psk', 'qpsk', 468000, 32000, 'natural_key', 'linear_key', 50, 8,
            'pll_120', 'pll_120', 'pll_120', 'pll_60', 5000000, 50000, 50000)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.Mercurial_SDR_0, 0), (self.blocks_null_sink_0, 0))
        self.connect((self.blocks_int_to_float_0, 0),
                     (self.Mercurial_SDR_0, 0))
        self.connect((self.blocks_null_source_0, 0), (self.Mercurial_SDR_0, 1))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_int_to_float_0, 0))
예제 #20
0
    def test_03(self):
        tb = self.tb

        vlen = 5
        N = 10*vlen
        seed = 0
        data = make_random_float_tuple(N, 2**10)
        data = [int(d*1000) for d in data]
        src = blocks.vector_source_i(data, False)
        one_to_many = blocks.stream_to_streams(gr.sizeof_int, vlen)
        one_to_vector = blocks.stream_to_vector(gr.sizeof_int, vlen)
        many_to_vector = blocks.streams_to_vector(gr.sizeof_int, vlen)
        isolated  = [ blocks.moving_average_ii(100, 1) for i in range(vlen)]
        dut = blocks.moving_average_ii(100, 1, vlen=vlen)
        dut_dst = blocks.vector_sink_i(vlen=vlen)
        ref_dst = blocks.vector_sink_i(vlen=vlen)

        tb.connect(src, one_to_many)
        tb.connect(src, one_to_vector, dut, dut_dst)
        tb.connect(many_to_vector, ref_dst)
        for idx, single in enumerate(isolated):
            tb.connect((one_to_many,idx), single, (many_to_vector,idx))

        tb.run()

        dut_data = dut_dst.data()
        ref_data = ref_dst.data()

        # make sure result is close to zero
        self.assertTupleEqual(dut_data, ref_data)
예제 #21
0
 def __init__(self):
     gr.top_block.__init__(self)
     #variables
     self.samp_rate = samp_rate
     self.direction = RC_NOTHING  #no direction to start
     #blocks
     #define the gnuradio blocks
     #interpolator expands the input function - this creates long zeros and ones
     self.interpolator = rccar2.functioninterpolator(samp_rate)
     #functioncoder takes a functioncode into it and creates the appropriate command stream
     self.functioncoder = rccar2.functioncoder(samplerate=samp_rate,
                                               functioncode=1)
     #sink (the hackRF in this case), can be changed to your transmitting device of course
     self.hackrf = osmosdr.sink(args="numchan=" + str(1) + " " + "hackhf")
     self.hackrf.set_sample_rate(samp_rate)
     self.hackrf.set_center_freq(RC_FREQUENCY, 0)
     self.hackrf.set_freq_corr(0, 0)
     #enable the hackrf to transmit (need to set the gain to 14dB)
     self.hackrf.set_gain(14, 0)
     self.hackrf.set_if_gain(30, 0)
     self.hackrf.set_bb_gain(20, 0)
     self.hackrf.set_antenna("", 0)
     self.hackrf.set_bandwidth(0, 0)
     #conversion blocks
     self.float_to_complex = blocks.float_to_complex(1)
     self.char_to_float = blocks.char_to_float(1, 1)
     #vector source which sends the direction to the functioncoder
     self.vector_source = blocks.vector_source_i([self.direction], False)
     #connect it all up
     self.connect((self.char_to_float, 0), (self.float_to_complex, 0))
     self.connect((self.char_to_float, 0), (self.float_to_complex, 1))
     self.connect((self.interpolator, 0), (self.char_to_float, 0))
     self.connect((self.float_to_complex, 0), (self.hackrf, 0))
     self.connect((self.vector_source, 0), (self.functioncoder, 0))
     self.connect((self.functioncoder, 0), (self.interpolator, 0))
예제 #22
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Blocks
        ##################################################
        self.quantomm_encoder_0 = quantomm.encoder(True)
        self.quantomm_decoder_0 = quantomm.decoder(True)
        self.quantomm_channel_ii_1 = quantomm.channel_ii()
        self.quantomm_channel_ii_0 = quantomm.channel_ii()
        self.analog_random_source_x_0 = blocks.vector_source_i(
            map(int, numpy.random.randint(0, 2, 5)), False)
        self.Message_Debug_Out_Plain_Text = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.quantomm_decoder_0, 'plaintext'),
                         (self.Message_Debug_Out_Plain_Text, 'print_pdu'))
        self.msg_connect((self.quantomm_decoder_0, 'feedback'),
                         (self.quantomm_encoder_0, 'feedback'))
        self.msg_connect((self.quantomm_encoder_0, 'ciphertext'),
                         (self.quantomm_decoder_0, 'ciphertext'))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.quantomm_encoder_0, 0))
        self.connect((self.quantomm_channel_ii_0, 0),
                     (self.quantomm_decoder_0, 0))
        self.connect((self.quantomm_channel_ii_1, 0),
                     (self.quantomm_decoder_0, 1))
        self.connect((self.quantomm_encoder_0, 0),
                     (self.quantomm_channel_ii_0, 0))
        self.connect((self.quantomm_encoder_0, 1),
                     (self.quantomm_channel_ii_1, 0))
예제 #23
0
    def test_003_t (self):
        src_data = ( 1,  2,  3,  4,  5,  6,  7,  8,  9,  10)
        trg_data = ( 0,  0,  0,  0, 10,  0,  0,  0,  0,   0)

        # Blocks
        src_data = blocks.vector_source_c(src_data)
        src_trig = blocks.vector_source_i(trg_data)

        op = marmote.peak_tagger_cc(
            threshold = 2,
            lookahead = 3,
            delay = 1
        )

        snk_tag = blocks.tag_debug(gr.sizeof_gr_complex, "peak tagger QA")
        snk_data = blocks.vector_sink_c()

        # Connections
        self.tb.connect(src_data, (op,0))
        self.tb.connect(src_trig, (op,1))
        self.tb.connect(op, snk_tag)
        self.tb.connect(op, snk_data)

        self.tb.run()

        # Check data
        x = snk_tag.current_tags()
        y = snk_data.data()

        self.assertEqual(6, y[x[0].offset])
예제 #24
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 = blocks.vector_source_i(src_data)
     op = blocks.tag_debug(gr.sizeof_int, "tag QA")
     self.tb.connect(src, op)
     self.tb.run()
     x = op.current_tags()
예제 #25
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 = blocks.vector_source_i(src_data)
     op = blocks.tag_debug(gr.sizeof_int, "tag QA")
     self.tb.connect(src, op)
     self.tb.run()
     x = op.current_tags()
예제 #26
0
 def test_and_const_ii (self):
     src_data =        (1,  2,  3,  0x5004,   0x1150)
     expected_result = (0,  2,  2,  0x5000,   0x1100)
     src = blocks.vector_source_i(src_data)
     op = blocks.and_const_ii (0x55AA)
     dst = blocks.vector_sink_i()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertEqual(dst.data(), expected_result)
예제 #27
0
 def help_ii (self, src_data, exp_data, op):
     for s in zip (range (len (src_data)), src_data):
         src = blocks.vector_source_i (s[1])
         self.tb.connect (src, (op, s[0]))
     dst = blocks.vector_sink_i ()
     self.tb.connect (op, dst)
     self.tb.run ()
     result_data = dst.data ()
     self.assertEqual (exp_data, result_data)
예제 #28
0
 def help_const_ii(self, src_data, exp_data, op):
     src = blocks.vector_source_i(src_data)
     srcv = blocks.stream_to_vector(gr.sizeof_int, len(src_data))
     rhs = blocks.vector_to_stream(gr.sizeof_int, len(src_data))
     dst = blocks.vector_sink_i()
     self.tb.connect(src, srcv, op, rhs, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertEqual(exp_data, result_data)
예제 #29
0
 def test_001_ii(self):
     src_data = (1, 2, 3, 4, 5, 6)
     dst_data = (6, 15)
     src = blocks.vector_source_i(src_data)
     itg = blocks.integrate_ii(3)
     dst = blocks.vector_sink_i()
     self.tb.connect(src, itg, dst)
     self.tb.run()
     self.assertEqual(dst_data, dst.data())
예제 #30
0
파일: qa_mute.py 프로젝트: dsorber/gnuradio
 def help_ii(self, src_data, exp_data, op):
     for s in zip(list(range(len(src_data))), src_data):
         src = blocks.vector_source_i(s[1])
         self.tb.connect(src, (op, s[0]))
     dst = blocks.vector_sink_i()
     self.tb.connect(op, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertEqual(exp_data, result_data)
예제 #31
0
    def test_001_ii(self):
	src_data = (1, 2, 3, 4, 5, 6)
	dst_data = (6, 15)
	src = blocks.vector_source_i(src_data)
	itg = blocks.integrate_ii(3)
	dst = blocks.vector_sink_i()
	self.tb.connect(src, itg, dst)
	self.tb.run()
	self.assertEqual(dst_data, dst.data())
예제 #32
0
 def test_int_to_float_scale(self):
     src_data = (1, 2, 3, 4, 5)
     expected_data = (0.2, 0.4, 0.6, 0.8, 1.0)
     src = blocks.vector_source_i(src_data)
     op = blocks.int_to_float(1, 5)
     dst = blocks.vector_sink_f()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertFloatTuplesAlmostEqual(expected_data, dst.data())
예제 #33
0
 def test_int_to_float_identity(self):
     src_data = (1, 2, 3, 4, 5)
     expected_data = (1.0, 2.0, 3.0, 4.0, 5.0)
     src = blocks.vector_source_i(src_data)
     op = blocks.int_to_float()
     dst = blocks.vector_sink_f()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertFloatTuplesAlmostEqual(expected_data, dst.data())
예제 #34
0
 def test_and_const_ii(self):
     src_data = [1, 2, 3, 0x5004, 0x1150]
     expected_result = [0, 2, 2, 0x5000, 0x1100]
     src = blocks.vector_source_i(src_data)
     op = blocks.and_const_ii(0x55AA)
     dst = blocks.vector_sink_i()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertEqual(dst.data(), expected_result)
예제 #35
0
 def test_int_to_float_identity(self):
     src_data = (1, 2, 3, 4, 5)
     expected_data = (1.0, 2.0, 3.0, 4.0, 5.0)
     src = blocks.vector_source_i(src_data)
     op = blocks.int_to_float()
     dst = blocks.vector_sink_f()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertFloatTuplesAlmostEqual(expected_data, dst.data())
예제 #36
0
    def help_const_ii(self, src_data, exp_data, op):
	src = blocks.vector_source_i(src_data)
	srcv = blocks.stream_to_vector(gr.sizeof_int, len(src_data))
	rhs = blocks.vector_to_stream(gr.sizeof_int, len(src_data))
        dst = blocks.vector_sink_i()
        self.tb.connect(src, srcv, op, rhs, dst)
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(exp_data, result_data)
예제 #37
0
 def test_int_to_float_scale(self):
     src_data = (1, 2, 3, 4, 5)
     expected_data = (0.2, 0.4, 0.6, 0.8, 1.0)
     src = blocks.vector_source_i(src_data)
     op = blocks.int_to_float(1, 5)
     dst = blocks.vector_sink_f()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertFloatTuplesAlmostEqual(expected_data, dst.data())
예제 #38
0
 def test_001_t (self):
     # set up fg
     src = blocks.vector_source_i([3,4,3,2,2,2,1],False,1)
     mux_ctrl = ofdm.tx_mux_ctrl(2)
     dst = blocks.vector_sink_b(1)
     self.tb.connect(src,mux_ctrl,dst)
     self.tb.run()
     # check data
     result = dst.data()
     print "mux stream: ", result
예제 #39
0
 def help_ii(self, src_data, exp_data, op):
     for s in zip(list(range(len(src_data))), src_data):
         src = blocks.vector_source_i(s[1])
         self.tb.connect(src, 0, op, s[0]).set_custom_buffer(gr.buffer_cuda_properties.make(gr.buffer_cuda_type.H2D))
     dst = blocks.vector_sink_i()
     self.tb.connect(op, dst).set_custom_buffer(gr.buffer_cuda_properties.make(gr.buffer_cuda_type.D2H))
     self.rt.initialize(self.tb)
     self.rt.run()
     result_data = dst.data()
     self.assertEqual(exp_data, result_data)
예제 #40
0
 def test_skip_all(self):
     skip_cnt = len(self.src_data)
     expected_result = tuple(self.src_data[skip_cnt:])
     src1 = blocks.vector_source_i(self.src_data)
     op = usrpcalibrator.skiphead_reset(gr.sizeof_int, skip_cnt)
     dst1 = blocks.vector_sink_i()
     self.tb.connect(src1, op, dst1)
     self.tb.run()
     dst_data = dst1.data()
     self.assertEqual(expected_result, dst_data)
예제 #41
0
 def test_skip_12678(self):
     skip_cnt = 12678
     expected_result = tuple(self.src_data[skip_cnt:])
     src1 = blocks.vector_source_i(self.src_data)
     op = blocks.skiphead(gr.sizeof_int, skip_cnt)
     dst1 = blocks.vector_sink_i()
     self.tb.connect(src1, op, dst1)
     self.tb.run()
     dst_data = dst1.data()
     self.assertEqual(expected_result, dst_data)
예제 #42
0
 def test_001_t(self):
     # set up fg
     src = blocks.vector_source_i([3, 4, 3, 2, 2, 2, 1], False, 1)
     mux_ctrl = ofdm.tx_mux_ctrl(2)
     dst = blocks.vector_sink_b(1)
     self.tb.connect(src, mux_ctrl, dst)
     self.tb.run()
     # check data
     result = dst.data()
     print "mux stream: ", result
예제 #43
0
 def test_skip_12678(self):
     skip_cnt = 12678
     expected_result = tuple(self.src_data[skip_cnt:])
     src1 = blocks.vector_source_i(self.src_data)
     op = blocks.skiphead(gr.sizeof_int, skip_cnt)
     dst1 = blocks.vector_sink_i()
     self.tb.connect(src1, op, dst1)
     self.tb.run()
     dst_data = dst1.data()
     self.assertEqual(expected_result, dst_data)
예제 #44
0
    def test_004_t (self):
        # Preamble and SFD prefixer to removal
        data_in_I = [i*2-1 for i in np.random.randint(0,2,(2*(self.c.nsym_frame-len(self.c.preamble)-len(self.c.SFD)),))]
        data_in_Q = [i*2-1 for i in np.random.randint(0,2,(2*(self.c.nsym_frame-len(self.c.preamble)-len(self.c.SFD)),))]
        self.src_I = blocks.vector_source_i(data_in_I)
        self.snk_I = blocks.vector_sink_i(1)
        self.src_Q = blocks.vector_source_i(data_in_Q)
        self.snk_Q = blocks.vector_sink_i(1)
        
        # self.dbg_sink1 = blocks.vector_sink_i(1)
        # self.dbg_sink2 = blocks.vector_sink_i(1)
        # self.dbg_sink3 = blocks.vector_sink_f(1)
        # self.dbg_sink4 = blocks.vector_sink_f(1)
        # self.dbg_sink5 = blocks.vector_sink_c(1)
        # self.dbg_sink6 = blocks.vector_sink_f(1)
        # self.dbg_sink7 = blocks.vector_sink_f(1)

        self.tb.connect(self.src_I, self.preamble_sfd_prefixer_I, (self.qpsk_mapper,0))
        self.tb.connect(self.src_Q, self.preamble_sfd_prefixer_Q, (self.qpsk_mapper,1))
        self.tb.connect(self.qpsk_mapper, self.dqpsk_mapper, self.dqcsk_mapper, self.dqcsk_demapper, self.dqpsk_demapper, self.qpsk_demapper)
        self.tb.connect((self.qpsk_demapper,0), self.preamble_sfd_removal_I, self.snk_I)        
        self.tb.connect((self.qpsk_demapper,1), self.preamble_sfd_removal_Q, self.snk_Q)

        # self.tb.connect((self.qpsk_mapper,0), self.dbg_sink3)
        # self.tb.connect(self.preamble_sfd_prefixer_I, self.dbg_sink2)
        # self.tb.connect(self.dqpsk_mapper, self.dbg_sink4)
        # self.tb.connect(self.dqcsk_mapper, self.dbg_sink5)
        # self.tb.connect(self.dqcsk_demapper, self.dbg_sink6)
        # self.tb.connect(self.dqcsk_demapper, self.dbg_sink7)

        self.tb.run()

        # print "sfd prefixer output len:", len(self.dbg_sink2.data())
        # print "qpsk mapper output len:", len(self.dbg_sink3.data())
        # print "dqpsk mapper output len:", len(self.dbg_sink4.data())
        # print "dqcsk mapper output len:", len(self.dbg_sink5.data())
        # print "dqcsk demapper output len:", len(self.dbg_sink6.data())
        # print "dqpsk demapper output len:", len(self.dbg_sink7.data())

        data_out_I = self.snk_I.data()
        data_out_Q = self.snk_Q.data()
        self.assertFloatTuplesAlmostEqual(data_in_I, data_out_I) 
        self.assertFloatTuplesAlmostEqual(data_in_Q, data_out_Q)        
예제 #45
0
    def test_003_t (self):
        # QPSK mapper to demapper
        data_in_I = [1,-1,1,-1]
        data_in_Q = [1,1,-1,-1]
        self.src_I = blocks.vector_source_i(data_in_I)
        self.snk_I = blocks.vector_sink_i(1)
        self.src_Q = blocks.vector_source_i(data_in_Q)
        self.snk_Q = blocks.vector_sink_i(1)

        self.tb.connect(self.src_I, (self.qpsk_mapper,0))
        self.tb.connect(self.src_Q, (self.qpsk_mapper,1))
        self.tb.connect(self.qpsk_mapper, self.dqpsk_mapper, self.dqcsk_mapper, self.dqcsk_demapper, self.dqpsk_demapper, self.qpsk_demapper)
        self.tb.connect((self.qpsk_demapper,0), self.snk_I)
        self.tb.connect((self.qpsk_demapper,1), self.snk_Q)
        self.tb.run()

        data_out_I = self.snk_I.data()
        data_out_Q = self.snk_Q.data()
        self.assertFloatTuplesAlmostEqual(data_in_I, data_out_I) 
        self.assertFloatTuplesAlmostEqual(data_in_Q, data_out_Q)     
예제 #46
0
    def test_sub_ii1(self):
        src1_data = (1, 2, 3, 4, 5)
        expected_result = (1, 2, 3, 4, 5)

        src = blocks.vector_source_i(src1_data)
        op = blocks.sub_ii()
        dst = blocks.vector_sink_i()
        self.tb.connect(src, op, dst)
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(expected_result, result_data)
예제 #47
0
 def test_head(self):
     src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
     expected_result = (1, 2, 3, 4)
     src1 = blocks.vector_source_i(src_data)
     op = blocks.head(gr.sizeof_int, 4)
     dst1 = blocks.vector_sink_i()
     self.tb.connect(src1, op)
     self.tb.connect(op, dst1)
     self.tb.run()
     dst_data = dst1.data()
     self.assertEqual(expected_result, dst_data)
예제 #48
0
    def test_sub_ii1(self):
        src1_data = (1, 2, 3, 4, 5)
        expected_result = (1, 2, 3, 4, 5)

        src = blocks.vector_source_i(src1_data)
        op = blocks.sub_ii()
        dst = blocks.vector_sink_i()
        self.tb.connect(src, op, dst)
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(expected_result, result_data)
예제 #49
0
파일: qa_head.py 프로젝트: yxw027/gnuradio
 def test_head(self):
     src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
     expected_result = (1, 2, 3, 4)
     src1 = blocks.vector_source_i(src_data)
     op = blocks.head(gr.sizeof_int, 4)
     dst1 = blocks.vector_sink_i()
     self.tb.connect(src1, op)
     self.tb.connect(op, dst1)
     self.tb.run()
     dst_data = dst1.data()
     self.assertEqual(expected_result, dst_data)
예제 #50
0
 def test_001_square_bb(self):
     src_data = (2, 3, 4, 5, 6)
     expected_result = (4, 9, 16, 25, 36)
     src = blocks.vector_source_i(src_data)
     sqr = howtogen.square_ii()
     dst = blocks.vector_sink_i()
     self.tb.connect(src, sqr)
     self.tb.connect(sqr, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertFloatTuplesAlmostEqual(expected_result, result_data, 6)
예제 #51
0
파일: top_block.py 프로젝트: trdean/grEME
    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.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_f(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"QT GUI Plot", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate)
        self.blocks_int_to_float_0 = blocks.int_to_float(1, 1)
        self.analog_random_source_x_0 = blocks.vector_source_i(map(int, numpy.random.randint(0, 4, 1000)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_throttle_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.analog_random_source_x_0, 0), (self.blocks_int_to_float_0, 0))
        self.connect((self.blocks_int_to_float_0, 0), (self.blocks_throttle_0, 0))
예제 #52
0
    def help_ii(self, size, src_data, exp_data, op):
        for s in zip(range (len (src_data)), src_data):
            src = blocks.vector_source_i(s[1])
	    srcv = blocks.stream_to_vector(gr.sizeof_int, size)
	    self.tb.connect(src, srcv)
            self.tb.connect(srcv, (op, s[0]))
	rhs = blocks.vector_to_stream(gr.sizeof_int, size)
        dst = blocks.vector_sink_i()
        self.tb.connect(op, rhs, dst)
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(exp_data, result_data)
예제 #53
0
    def test_005_t (self):
        # Interleaver to deinterleaver
        data_in_I = [i*2-1 for i in np.random.randint(0,2,(2*len(self.c.codewords[0])*(self.c.nsym_frame-len(self.c.preamble)-len(self.c.SFD)),))]
        data_in_Q = [i*2-1 for i in np.random.randint(0,2,(2*len(self.c.codewords[0])*(self.c.nsym_frame-len(self.c.preamble)-len(self.c.SFD)),))]
        self.src_I = blocks.vector_source_i(data_in_I)
        self.snk_I = blocks.vector_sink_i(1)
        self.src_Q = blocks.vector_source_i(data_in_Q)
        self.snk_Q = blocks.vector_sink_i(1)

        self.tb.connect(self.src_I, self.interleaver_I, self.preamble_sfd_prefixer_I, (self.qpsk_mapper,0))
        self.tb.connect(self.src_Q, self.interleaver_Q, self.preamble_sfd_prefixer_Q, (self.qpsk_mapper,1))
        self.tb.connect(self.qpsk_mapper, self.dqpsk_mapper, self.dqcsk_mapper, self.dqcsk_demapper, self.dqpsk_demapper, self.qpsk_demapper)
        self.tb.connect((self.qpsk_demapper,0), self.preamble_sfd_removal_I, self.deinterleaver_I, self.snk_I)        
        self.tb.connect((self.qpsk_demapper,1), self.preamble_sfd_removal_Q, self.deinterleaver_Q, self.snk_Q)

        self.tb.run()
    
        data_out_I = self.snk_I.data()
        data_out_Q = self.snk_Q.data()
        self.assertFloatTuplesAlmostEqual(data_out_I, data_in_I)
        self.assertFloatTuplesAlmostEqual(data_out_I, data_in_I)   
예제 #54
0
 def test_001_t(self):
     # Check impulse response
     # Impulse is 2^15 due to the fixed point format of the coefficients. With a large enough impulse,
     # the filter's impulse response will simply be the filter coefficients.
     src_data = (2 ** 15, 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)
     expected_result = (
         -51,
         -662,
         -190,
         510,
         12,
         -719,
         238,
         945,
         -671,
         -1161,
         1438,
         1341,
         -3060,
         -1460,
         10287,
         17886,
         10287,
         -1460,
         -3060,
         1341,
         1438,
         -1161,
         -671,
         945,
         238,
         -719,
         12,
         510,
         -190,
         -662,
         -51,
     )
     filter_taps = (-51, -662, -190, 510, 12, -719, 238, 945, -671, -1161, 1438, 1341, -3060, -1460, 10287, 17886)
     # Filter coefficients are fx1.31, so scale them up to allow us to retreive the filter coefficients from the impulse response.
     filter_taps = [x * 2 ** 16 for x in filter_taps]
     src = blocks.vector_source_i(src_data)
     # FIR filter taps are set to expected_result
     fir_filter = zynq.fir_filter_ii(filter_taps)
     dst = blocks.vector_sink_i()
     self.tb.connect(src, fir_filter)
     self.tb.connect(fir_filter, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertEqual(result_data, expected_result)
     self.tb.disconnect(src, fir_filter)
     self.tb.disconnect(fir_filter, dst)
예제 #55
0
    def test_002_int(self):
        tb = gr.top_block()

        data = [5, 0, 0, -1, -3, -10]
        exp = [1, 0, 0, -1, -1, -1]
        vlen = 1
        src = blocks.vector_source_i(data, False, vlen)
        sign = misc.signum_xx(misc.INT, vlen)
        snk = blocks.vector_sink_i(vlen)
        tb.connect(src, sign, snk)
        tb.run()
        res = snk.data()
        self.assertTupleEqual(res, tuple(exp))
예제 #56
0
    def test_002_t (self):
        # set up fg
        cfg = phy(slow_rate=False)
        data_in = range(541) # some random prime number
        self.src = blocks.vector_source_i(data_in)
        self.intlv = ieee802_15_4.interleaver_ii(intlv_seq=(),forward=False)
        self.snk = blocks.vector_sink_i(1)
        self.tb.connect(self.src, self.intlv, self.snk)
        self.tb.run ()

        # check data
        data_out = self.snk.data()
        self.assertFloatTuplesAlmostEqual(data_in, data_out)       
예제 #57
0
 def setup_test07(self):
     print "... benchmarking BPSK demapper"
     self.mode = 1
     bitspermode = [0.5,1,1.5,2,3,4,4.5,5,6]
     self.data_subcarriers = 200
     self.chunkdivisor = 2
     bitcount_vec = [(int)(self.data_subcarriers*10*bitspermode[self.mode-1])]
     dm_csi = [1]*self.data_subcarriers # TODO
     self.dm_csi = blocks.vector_source_f(dm_csi,True)
     
     self.blks = self.N*(10 + 1)
     self.tb = gr.top_block()
     
     self.bitcount_src = blocks.vector_source_i(bitcount_vec,True,1)
     self.depuncturing = depuncture_ff(self.data_subcarriers,0)
     bmaptrig_stream_puncturing = [1]+[0]*(10/2-1)
     self.bitmap_trigger_puncturing = blocks.vector_source_b(bmaptrig_stream_puncturing, True)
     self.data_decoder = ofdm.viterbi_combined_fb(self.fo,self.data_subcarriers,-1,-1,2,self.chunkdivisor,[-1,-1,-1,1,1,-1,1,1],ofdm.TRELLIS_EUCLIDEAN)
     if self.interleave:
         int_object=trellis.interleaver(2000,666)
         self.deinterlv = trellis.permutation(int_object.K(),int_object.DEINTER(),1,gr.sizeof_float)
         
     #self.bitmap = [self.nobits]*self.data_subcarriers
     self.demodulator = generic_softdemapper_vcf(self.data_subcarriers, 11, self.coding)
     #const =  self.demodulator.get_constellation( self.nobits )
     #assert( len( const ) == 2**self.nobits )
            
 
     self.bitdata = [random()+1j*random() for i in range(self.blks*self.data_subcarriers)]
     self.src = blocks.vector_source_c(self.bitdata,False, self.data_subcarriers)
     #self.src = symbol_random_src( const, self.data_subcarriers )
     
     self.bitmap = [self.mode]*self.data_subcarriers      
     self.bitmap_src = blocks.vector_source_b(self.bitmap,True, self.data_subcarriers)
     
     #self.bmaptrig_stream = [1, 2]+[0]*(11-2)
     #self.bitmap_trigger = blocks.vector_source_b(self.bmaptrig_stream, True)
     
     self.snk = blocks.null_sink(gr.sizeof_char)
     
     #Connect blocks     
     self.tb.connect(self.src,self.demodulator)
     if self.interleave:
         self.tb.connect(self.demodulator,self.deinterlv, self.depuncturing, self.data_decoder,self.snk)
     else:
         self.tb.connect(self.demodulator, self.depuncturing, self.data_decoder,self.snk)
     self.tb.connect(self.bitmap_src,(self.demodulator,1))
     self.tb.connect(self.dm_csi,blocks.stream_to_vector(gr.sizeof_float,self.data_subcarriers),(self.demodulator,2))
     self.tb.connect(self.bitmap_src,(self.depuncturing,1))
     self.tb.connect(self.bitmap_trigger_puncturing, (self.depuncturing,2))
     self.tb.connect(self.bitcount_src, ofdm.multiply_const_ii(1./self.chunkdivisor), (self.data_decoder,1))
예제 #58
0
    def test_002(self):

        src_data = [1,2,3,4]
        expected_result = [16777216, 33554432, 50331648, 67108864];

        src = blocks.vector_source_i(src_data)
        op = blocks.endian_swap(4)
        dst = blocks.vector_sink_i()

        self.tb.connect(src, op, dst)
        self.tb.run()
        result_data = list(dst.data())
    
        self.assertEqual(expected_result, result_data)