Ejemplo n.º 1
0
    def test_004_boost_time(self):
        self.tb = gr.top_block()
        start_time = 0.1
        sob_tag = gr.tag_utils.python_to_tag(
            (34, pmt.intern("SOB"), pmt.PMT_T, pmt.intern("src")))
        eob_tag = gr.tag_utils.python_to_tag(
            (34 + (8 * 31), pmt.intern("EOB"), pmt.PMT_T, pmt.intern("src")))
        vs = blocks.vector_source_s(range(350), False, 1, [sob_tag, eob_tag])
        t2p = pdu_utils.tags_to_pdu_s(pmt.intern('SOB'), pmt.intern('EOB'),
                                      1024, 512000, ([]), False, 0, start_time)
        t2p.enable_time_debug(True)
        t2p.set_eob_parameters(8, 0)
        dbg = blocks.message_debug()
        #td = pdu_utils.time_delta("TIME CHECKER")
        #td = timing_utils.time_delta("TIME CHECKER")

        self.tb.connect(vs, t2p)
        self.tb.msg_connect((t2p, 'pdu_out'), (dbg, 'store'))
        #self.tb.msg_connect((t2p, 'pdu_out'), (td, 'pdu_in'))
        expected_vec = pmt.init_s16vector((8 * 31), range(34, 34 + (8 * 31)))
        expected_time = start_time + (34 / 512000.0)
        ts = time.time()
        self.tb.run()

        self.assertEqual(dbg.num_messages(), 1)
        self.assertTrue(pmt.equal(pmt.cdr(dbg.get_message(0)), expected_vec))
        time_tuple1 = pmt.dict_ref(pmt.car(dbg.get_message(0)),
                                   pmt.intern("burst_time"), pmt.PMT_NIL)
        self.assertAlmostEqual(
            pmt.to_uint64(pmt.tuple_ref(time_tuple1, 0)) +
            pmt.to_double(pmt.tuple_ref(time_tuple1, 1)), expected_time)
        #wct = pmt.to_double(pmt.dict_ref(pmt.car(dbg.get_message(0)), pmt.intern("wall_clock_time"), pmt.PMT_NIL))
        #self.assertTrue((wct - ts) < 1.0)

        self.tb = None
Ejemplo n.º 2
0
    def test_002_secondSOB(self):
        self.tb = gr.top_block()
        start_time = 4.999999999
        sob_tag = gr.tag_utils.python_to_tag(
            (34, pmt.intern("SOB"), pmt.PMT_T, pmt.intern("src")))
        sob_tag2 = gr.tag_utils.python_to_tag(
            (51, pmt.intern("SOB"), pmt.PMT_T, pmt.intern("src")))
        eob_tag = gr.tag_utils.python_to_tag(
            (51 + (8 * 26), pmt.intern("EOB"), pmt.PMT_T, pmt.intern("src")))
        vs = blocks.vector_source_s(range(350), False, 1,
                                    [sob_tag, sob_tag2, eob_tag])
        t2p = pdu_utils.tags_to_pdu_s(pmt.intern('SOB'), pmt.intern('EOB'),
                                      1024, 460800, ([]), False, 0, start_time)
        t2p.set_eob_parameters(8, 0)
        dbg = blocks.message_debug()
        self.tb.connect(vs, t2p)
        self.tb.msg_connect((t2p, 'pdu_out'), (dbg, 'store'))
        expected_vec = pmt.init_s16vector((8 * 26), range(51, 51 + (8 * 26)))
        expected_time = start_time + (51 / 460800.0)

        self.tb.run()

        self.assertEqual(dbg.num_messages(), 1)
        self.assertTrue(pmt.equal(pmt.cdr(dbg.get_message(0)), expected_vec))
        time_tuple1 = pmt.dict_ref(pmt.car(dbg.get_message(0)),
                                   pmt.intern("burst_time"), pmt.PMT_NIL)
        self.assertAlmostEqual(
            pmt.to_uint64(pmt.tuple_ref(time_tuple1, 0)) +
            pmt.to_double(pmt.tuple_ref(time_tuple1, 1)), expected_time)

        self.tb = None
    def test_sc_tag(self):
        constA = [-3.0 + 1j, -1.0 - 1j, 1.0 + 1j, 3 - 1j]
        constB = [12.0 + 1j, -12.0 - 1j, 6.0 + 1j, -6 - 1j]
        src_data = (0, 1, 2, 3, 3, 2, 1, 0)
        expected_result = [
            -3 + 1j, -1 - 1j, 1 + 1j, 3 - 1j, -6 - 1j, 6 + 1j, -12 - 1j,
            12 + 1j
        ]
        first_tag = gr.tag_t()
        first_tag.key = pmt.intern("set_symbol_table")
        first_tag.value = pmt.init_c32vector(len(constA), constA)
        first_tag.offset = 0
        second_tag = gr.tag_t()
        second_tag.key = pmt.intern("set_symbol_table")
        second_tag.value = pmt.init_c32vector(len(constB), constB)
        second_tag.offset = 4

        src = blocks.vector_source_s(src_data, False, 1,
                                     [first_tag, second_tag])
        op = digital.chunks_to_symbols_sc(constB)

        dst = blocks.vector_sink_c()
        self.tb.connect(src, op)
        self.tb.connect(op, dst)
        self.tb.run()

        actual_result = dst.data()
        self.assertEqual(expected_result, actual_result)
Ejemplo n.º 4
0
    def test_005_two_sobs_misaligned (self):
        # Two SOB tags and the SOB-to-EOB length is not aligned
        self.tb = gr.top_block ()
        start_time = 0.1
        sob_tag = gr.tag_utils.python_to_tag((34, pmt.intern("SOB"), pmt.PMT_T, pmt.intern("src")))
        sob_tag2 = gr.tag_utils.python_to_tag((35, pmt.intern("SOB"), pmt.PMT_T, pmt.intern("src")))
        eob_tag = gr.tag_utils.python_to_tag((34+(8*31), pmt.intern("EOB"), pmt.PMT_T, pmt.intern("src")))
        vs = blocks.vector_source_s(range(1350), False, 1, [sob_tag, sob_tag2, eob_tag])
        #vs = blocks.vector_source_s(range(350), False, 1, [sob_tag, eob_tag])
        t2p = pdu_utils.tags_to_pdu_s(pmt.intern('SOB'), pmt.intern('EOB'), 1024, 512000, ([]), False, 0, start_time)
        t2p.set_eob_parameters(8, 0)
        dbg = blocks.message_debug()
        self.tb.connect(vs, t2p)
        self.tb.msg_connect((t2p, 'pdu_out'), (dbg, 'store'))
        expected_vec = pmt.init_s16vector((8*31), list(range(35,34+(8*31))) + [0])
        expected_time = start_time + (35 / 512000.0)

        self.tb.run ()

        self.assertEqual(dbg.num_messages(), 1)
        #print "got ", dbg.get_message(0)
        #print "expected", expected_vec
        #print "len is {}".format(len(pmt.to_python(pmt.cdr(dbg.get_message(0)))))
        self.assertTrue(pmt.equal(pmt.cdr(dbg.get_message(0)), expected_vec))
        time_tuple1 = pmt.dict_ref(pmt.car(dbg.get_message(0)), pmt.intern("burst_time"), pmt.PMT_NIL)
        self.assertAlmostEqual(pmt.to_uint64(pmt.tuple_ref(time_tuple1,0)) + pmt.to_double(pmt.tuple_ref(time_tuple1,1)), expected_time)

        self.tb = None
 def test_fir_filter_scc_002(self):
     self.generate_scc_source()
     expected_data = ((-0.0080680437386-0.00158522999845j),
                      (-0.0037795654498+0.00733159901574j),
                      (0.00842926371843+0.00777021236718j),
                      (0.0112090632319-0.00249325321056j),
                      (-0.0027476802934-0.0115710813552j),
                      (-0.0158688724041-0.00715934624895j),
                      (-0.00802888441831+0.00620818417519j),
                      (0.0131985172629+0.0149175003171j),
                      (0.0190298333764+0.00956719089299j),
                      (-0.00112380902283-0.00936658866704j),
                      (-0.0204226914793-0.0333464704454j),
                      (-0.00695514678955-0.0437445007265j),
                      (0.0314490310848-0.0207983348519j),
                      (0.0529675260186+0.0302227605134j),
                      (0.0317338332534+0.0667510479689j),
                      (-0.00775565672666+0.0437112376094j),
                      (-0.024347923696-0.0303014591336j),
                      (-0.0108893103898-0.0875638127327j),
                      (0.00204296782613-0.0721434056759j),
                      (-0.00527479872108-0.00698097236454j))
     src = blocks.vector_source_s(self.src_data)
     op  = filter.freq_xlating_fir_filter_scc(4, self.taps, self.fc, self.fs)
     dst = blocks.vector_sink_c()
     self.tb.connect(src, op, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertComplexTuplesAlmostEqual(expected_data, result_data[-20:], 5)
 def test_fir_filter_scf_002(self):
     self.generate_scf_source()
     expected_data = ((0.00824625696987-1.50158575707e-05j),
                      (0.0020101047121-0.0116540221497j),
                      (-0.0126378880814-0.00259830290452j),
                      (-0.00363933457993+0.00837504956871j),
                      (0.00107023562305+0.00915473792702j),
                      (0.0169738996774+0.00422182958573j),
                      (0.00630031805485-0.025423232466j),
                      (-0.0283014029264+0.00104465708137j),
                      (0.00890890974551+0.0115978596732j),
                      (-0.0142687577754+0.00306978379376j),
                      (0.02845691517+0.0331163145602j),
                      (0.0538152232766-0.0908300876617j),
                      (-0.0843691527843-0.0956566259265j),
                      (0.0476895272732+0.0747984498739j),
                      (0.0898786485195+0.082478672266j),
                      (-0.0330070182681+0.101965606213j),
                      (0.0574697069824-0.0350842289627j),
                      (-0.0770940706134-0.230615705252j),
                      (-0.103762261569-0.0382265634835j),
                      (0.11808334291+0.104863762856j))
     src = blocks.vector_source_s(self.src_data)
     op  = filter.freq_xlating_fir_filter_scf(4, self.taps, self.fc, self.fs)
     dst = blocks.vector_sink_c()
     self.tb.connect(src, op, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertComplexTuplesAlmostEqual(expected_data, result_data[-20:], 5)
 def test_fir_filter_scc_001(self):
     self.generate_scc_source()
     expected_data = ((-0.00775564694777+0.0437113791704j),
                      (0.0108830630779+0.0433648750186j),
                      (0.015553932637-0.0133284125477j),
                      (-0.0264905355871-0.0403266139328j),
                      (-0.0243480335921-0.03030154109j),
                      (-0.000327925226884-0.069333948195j),
                      (-0.0306392069906-0.107313856483j),
                      (-0.0452371090651-0.0854917764664j),
                      (-0.0108894333243-0.0875641107559j),
                      (-0.0182112380862-0.118961036205j),
                      (-0.0447825863957-0.0922874584794j),
                      (-0.0147479763255-0.0572904124856j),
                      (0.00204290449619-0.0721436738968j),
                      (-0.027713002637-0.0548989400268j),
                      (-0.0149045493454-0.00210141134448j),
                      (0.0176361314952-0.00149522523861j),
                      (-0.00527482619509-0.00698099425063j),
                      (-0.0151527002454+0.036265052855j),
                      (0.0199296213686+0.0452499426901j),
                      (0.0122985243797+0.0143278446048j))
     src = blocks.vector_source_s(self.src_data)
     op  = filter.freq_xlating_fir_filter_scc(1, self.taps, self.fc, self.fs)
     dst = blocks.vector_sink_c()
     self.tb.connect(src, op, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertComplexTuplesAlmostEqual(expected_data, result_data[-20:], 5)
 def test_fir_filter_scf_001(self):
     self.generate_scf_source()
     expected_data = ((-0.0330070219934+0.101965591311j),
                      (-0.0484239049256+0.0872343629599j),
                      (-0.0214109234512+0.102555386722j),
                      (0.0484058149159+0.0557125210762j),
                      (0.0574690811336-0.0350844524801j),
                      (0.0365394353867-0.0802438184619j),
                      (0.0453781634569-0.130992040038j),
                      (0.00801951438189-0.214278846979j),
                      (-0.0770946145058-0.230616629124j),
                      (-0.105601429939-0.190731987357j),
                      (-0.105361394584-0.177761554718j),
                      (-0.131518915296-0.136102750897j),
                      (-0.103761836886-0.0382263250649j),
                      (-0.0167790111154+0.0152206514031j),
                      (0.0277570039034+0.0300403907895j),
                      (0.056065287441+0.0806603953242j),
                      (0.118084669113+0.104863211513j),
                      (0.128281414509+0.0677760615945j),
                      (0.0748447552323+0.0619902014732j),
                      (0.0512856245041+0.0775099247694j))
     src = blocks.vector_source_s(self.src_data)
     op  = filter.freq_xlating_fir_filter_scf(1, self.taps, self.fc, self.fs)
     dst = blocks.vector_sink_c()
     self.tb.connect(src, op, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertComplexTuplesAlmostEqual(expected_data, result_data[-20:], 5)
Ejemplo n.º 9
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))
Ejemplo n.º 10
0
    def test_sc_tag(self):
        constA = [-3.0+1j, -1.0-1j, 1.0+1j, 3-1j]
        constB = [12.0+1j, -12.0-1j, 6.0+1j, -6-1j]
        src_data = (0, 1, 2, 3, 3, 2, 1, 0)
        expected_result = (-3+1j, -1-1j, 1+1j, 3-1j,
                            -6-1j, 6+1j, -12-1j, 12+1j)
        first_tag = gr.tag_t()
        first_tag.key = pmt.intern("set_symbol_table")
        first_tag.value = pmt.init_c32vector(len(constA), constA)
        first_tag.offset = 0
        second_tag = gr.tag_t()
        second_tag.key = pmt.intern("set_symbol_table")
        second_tag.value = pmt.init_c32vector(len(constB), constB)
        second_tag.offset = 4

        src = blocks.vector_source_s(src_data, False, 1, [first_tag, second_tag])
        op = digital.chunks_to_symbols_sc(constB)

        dst = blocks.vector_sink_c()
        self.tb.connect(src, op)
        self.tb.connect(op, dst)
        self.tb.run()

        actual_result = dst.data()
        self.assertEqual(expected_result, actual_result)
Ejemplo n.º 11
0
 def test001_module_load(self):
     data = 20 * (100, 200, 300, 400, 500, 600, 700, 800)
     expected_data = (0, 0, 360, 304, 256, 720, 600, 504, 200, 144, 128,
                      464, 376, 384, 680, 576, 440, 264, 176, 176, 640, 520,
                      480, 464, 384, 288, 432, 296, 328, 760, 624, 504, 176,
                      96, 96, 416, 312, 360, 808, 672, 216, 104, 136, 504,
                      376, 448, 720, 608, 296, 304, 176, 336, 576, 456, 560,
                      512, 320, 216, 344, 264, 456, 672, 576, 488, 192, 80,
                      152, 424, 368, 552, 688, 560, 280, 200, 104, 256, 520,
                      464, 608, 488, 184, 104, 16, 472, 456, 360, 696, 568,
                      208, 136, 88, 376, 480, 456, 616, 472, 232, 224, 264,
                      320, 512, 624, 632, 520, 176, 80, 192, 304, 400, 592,
                      664, 552, 248, 152, 144, 336, 440, 520, 616, 664, 304,
                      176, 80, 536, 448, 376, 680, 600, 240, 168, 112, 408,
                      488, 472, 608, 480, 240, 232, 208, 288, 480, 600, 616,
                      520, 176, 88, 184, 296, 392, 584, 656, 552, 248, 160,
                      144, 336, 432, 512, 608, 664)
     src = blocks.vector_source_s(data)
     enc = vocoder.gsm_fr_encode_sp()
     dec = vocoder.gsm_fr_decode_ps()
     snk = blocks.vector_sink_s()
     self.tb.connect(src, enc, dec, snk)
     self.tb.run()
     actual_result = snk.data()
     self.assertEqual(expected_data, actual_result)
Ejemplo n.º 12
0
 def test_fir_filter_scf_002(self):
     self.generate_scf_source()
     expected_data = ((0.00824625696987 - 1.50158575707e-05j),
                      (0.0020101047121 - 0.0116540221497j),
                      (-0.0126378880814 - 0.00259830290452j),
                      (-0.00363933457993 + 0.00837504956871j),
                      (0.00107023562305 + 0.00915473792702j),
                      (0.0169738996774 + 0.00422182958573j),
                      (0.00630031805485 - 0.025423232466j),
                      (-0.0283014029264 + 0.00104465708137j),
                      (0.00890890974551 + 0.0115978596732j),
                      (-0.0142687577754 + 0.00306978379376j),
                      (0.02845691517 + 0.0331163145602j),
                      (0.0538152232766 - 0.0908300876617j),
                      (-0.0843691527843 - 0.0956566259265j),
                      (0.0476895272732 + 0.0747984498739j),
                      (0.0898786485195 + 0.082478672266j),
                      (-0.0330070182681 + 0.101965606213j),
                      (0.0574697069824 - 0.0350842289627j),
                      (-0.0770940706134 - 0.230615705252j),
                      (-0.103762261569 -
                       0.0382265634835j), (0.11808334291 + 0.104863762856j))
     src = blocks.vector_source_s(self.src_data)
     op = filter.freq_xlating_fir_filter_scf(4, self.taps, self.fc, self.fs)
     dst = blocks.vector_sink_c()
     self.tb.connect(src, op, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertComplexTuplesAlmostEqual(expected_data, result_data[-20:],
                                         5)
Ejemplo n.º 13
0
    def test_003_double_eob_rej_tt_update (self):
        self.tb = gr.top_block ()
        start_time = 0.0
        sob_tag = gr.tag_utils.python_to_tag((51, pmt.intern("SOB"), pmt.PMT_T, pmt.intern("src")))
        eob_tag = gr.tag_utils.python_to_tag((51+(8*11), pmt.intern("EOB"), pmt.PMT_T, pmt.intern("src")))
        time_tuple = pmt.make_tuple(pmt.from_uint64(4), pmt.from_double(0.125), pmt.from_uint64(10000000), pmt.from_double(4000000.0))
        time_tag = gr.tag_utils.python_to_tag((360, pmt.intern("rx_time"), time_tuple, pmt.intern("src")))
        sob_tag2 = gr.tag_utils.python_to_tag((400, pmt.intern("SOB"), pmt.PMT_T, pmt.intern("src")))
        eob_tag2e = gr.tag_utils.python_to_tag((409, pmt.intern("EOB"), pmt.PMT_T, pmt.intern("src")))
        eob_tag2 = gr.tag_utils.python_to_tag((416, pmt.intern("EOB"), pmt.PMT_T, pmt.intern("src")))
        vs = blocks.vector_source_s(range(500), False, 1, [sob_tag, eob_tag, time_tag, sob_tag2, eob_tag2e, eob_tag2])
        t2p = pdu_utils.tags_to_pdu_s(pmt.intern('SOB'), pmt.intern('EOB'), 1024, 1000000, ([]), False, 0, start_time)
        t2p.set_eob_parameters(8, 0)
        dbg = blocks.message_debug()
        self.tb.connect(vs, t2p)
        self.tb.msg_connect((t2p, 'pdu_out'), (dbg, 'store'))
        expected_vec1 = pmt.init_s16vector((8*11), range(51,51+(8*11)))
        expected_vec2 = pmt.init_s16vector(16, list(range(400,409)) + [0]*7)
        expected_time1 = start_time + (51 / 1000000.0)
        expected_time2 = 4.125 + ((400-360) / 1000000.0)

        self.tb.run ()

        self.assertEqual(dbg.num_messages(), 2)
        self.assertTrue(pmt.equal(pmt.cdr(dbg.get_message(0)), expected_vec1))
        self.assertTrue(pmt.equal(pmt.cdr(dbg.get_message(1)), expected_vec2))
        time_tuple1 = pmt.dict_ref(pmt.car(dbg.get_message(0)), pmt.intern("burst_time"), pmt.PMT_NIL)
        time_tuple2 = pmt.dict_ref(pmt.car(dbg.get_message(1)), pmt.intern("burst_time"), pmt.PMT_NIL)
        self.assertAlmostEqual(pmt.to_uint64(pmt.tuple_ref(time_tuple1,0)) + pmt.to_double(pmt.tuple_ref(time_tuple1,1)), expected_time1)
        self.assertAlmostEqual(pmt.to_uint64(pmt.tuple_ref(time_tuple2,0)) + pmt.to_double(pmt.tuple_ref(time_tuple2,1)), expected_time2)

        self.tb = None
    def test_004(self):
        data = range(1,9)

        self.src = blocks.vector_source_s(data, True)
        self.probe = blocks.ctrlport_probe2_s("samples","Shorts",
                                              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()
Ejemplo n.º 15
0
 def test001_module_load(self):
     data = 20 * (100, 200, 300, 400, 500, 600, 700, 800)
     expected_data = (0, 0, 0, 3, 2, 0, 1, 5, 6, 7, 1, -1, 0, -5, -11, -10,
                      -20, -22, -20, -20, -27, -26, -36, -48, -59, -24, 5,
                      -7, -12, -27, -22, -22, -16, 13, 20, 39, 23, 25, 8,
                      -6, 15, 44, 97, 135, 145, 125, 94, 102, 126, 129, 165,
                      192, 180, 132, 99, 79, 73, 83, 72, 47, 40, 0, -32,
                      -46, -67, -99, -123, -114, -87, -108, -131, -152,
                      -181, -245, -348, -294, -101, -71, -85, -26, 99, 123,
                      15, 2, 77, 13, -117, -145, -105, -39, -50, -89, -59,
                      -77, -134, -95, -51, -22, 17, -19, -59, -74, -103,
                      -78, 4, 77, 113, 60, 18, 13, -67, -49, 24, 88, 179,
                      190, 89, 18, -90, -102, -50, -5, 123, 135, 57, 31,
                      -82, -98, -51, 6, 93, 104, 44, -5, -84, -107, -44, 45,
                      102, 104, 15, -47, -107, -126, -87, -11, 89, 93, 13,
                      -95, -136, -187, -70, -167, 216, -70, -103, 175, -284,
                      -486)
     src = blocks.vector_source_s(data)
     enc = vocoder.codec2_encode_sp()
     dec = vocoder.codec2_decode_ps()
     snk = blocks.vector_sink_s()
     self.tb.connect(src, enc, dec, snk)
     self.tb.run()
     actual_result = snk.data()
     self.assertEqual(expected_data, actual_result)
Ejemplo n.º 16
0
 def __init__(self, data):
     gr.hier_block2.__init__(self, "shorts_to_floats",
                             gr.io_signature(0, 0, 0),
                             gr.io_signature(1, 1, gr.sizeof_float))
     self.src = blocks.vector_source_s(data)
     self.cvt = blocks.short_to_float()
     self.connect(self.src, self.cvt, self)
Ejemplo n.º 17
0
 def test_fir_filter_scc_002(self):
     self.generate_scc_source()
     expected_data = (
         (-0.0080680437386 - 0.00158522999845j),
         (-0.0037795654498 + 0.00733159901574j),
         (0.00842926371843 + 0.00777021236718j), (0.0112090632319 -
                                                  0.00249325321056j),
         (-0.0027476802934 - 0.0115710813552j), (-0.0158688724041 -
                                                 0.00715934624895j),
         (-0.00802888441831 + 0.00620818417519j), (0.0131985172629 +
                                                   0.0149175003171j),
         (0.0190298333764 + 0.00956719089299j), (-0.00112380902283 -
                                                 0.00936658866704j),
         (-0.0204226914793 - 0.0333464704454j), (-0.00695514678955 -
                                                 0.0437445007265j),
         (0.0314490310848 - 0.0207983348519j), (0.0529675260186 +
                                                0.0302227605134j),
         (0.0317338332534 + 0.0667510479689j), (-0.00775565672666 +
                                                0.0437112376094j),
         (-0.024347923696 - 0.0303014591336j), (-0.0108893103898 -
                                                0.0875638127327j),
         (0.00204296782613 - 0.0721434056759j), (-0.00527479872108 -
                                                 0.00698097236454j))
     src = blocks.vector_source_s(self.src_data)
     op = filter.freq_xlating_fir_filter_scc(4, self.taps, self.fc, self.fs)
     dst = blocks.vector_sink_c()
     self.tb.connect(src, op, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertComplexTuplesAlmostEqual(expected_data, result_data[-20:],
                                         5)
Ejemplo n.º 18
0
    def __init__(self, data):
	gr.hier_block2.__init__(self, "shorts_to_floats",
				gr.io_signature(0, 0, 0),
				gr.io_signature(1, 1, gr.sizeof_float))
        self.src = blocks.vector_source_s(data)
        self.cvt = blocks.short_to_float()
        self.connect(self.src, self.cvt, self)
Ejemplo n.º 19
0
 def test_fir_filter_scc_001(self):
     self.generate_scc_source()
     expected_data = (
         (-0.00775564694777 + 0.0437113791704j),
         (0.0108830630779 + 0.0433648750186j),
         (0.015553932637 - 0.0133284125477j), (-0.0264905355871 -
                                               0.0403266139328j),
         (-0.0243480335921 - 0.03030154109j), (-0.000327925226884 -
                                               0.069333948195j),
         (-0.0306392069906 - 0.107313856483j), (-0.0452371090651 -
                                                0.0854917764664j),
         (-0.0108894333243 - 0.0875641107559j), (-0.0182112380862 -
                                                 0.118961036205j),
         (-0.0447825863957 - 0.0922874584794j), (-0.0147479763255 -
                                                 0.0572904124856j),
         (0.00204290449619 - 0.0721436738968j), (-0.027713002637 -
                                                 0.0548989400268j),
         (-0.0149045493454 - 0.00210141134448j), (0.0176361314952 -
                                                  0.00149522523861j),
         (-0.00527482619509 - 0.00698099425063j), (-0.0151527002454 +
                                                   0.036265052855j),
         (0.0199296213686 + 0.0452499426901j), (0.0122985243797 +
                                                0.0143278446048j))
     src = blocks.vector_source_s(self.src_data)
     op = filter.freq_xlating_fir_filter_scc(1, self.taps, self.fc, self.fs)
     dst = blocks.vector_sink_c()
     self.tb.connect(src, op, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertComplexTuplesAlmostEqual(expected_data, result_data[-20:],
                                         5)
Ejemplo n.º 20
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))
Ejemplo n.º 21
0
 def test_fir_filter_scf_001(self):
     self.generate_scf_source()
     expected_data = (
         (-0.0330070219934 + 0.101965591311j),
         (-0.0484239049256 + 0.0872343629599j),
         (-0.0214109234512 + 0.102555386722j), (0.0484058149159 +
                                                0.0557125210762j),
         (0.0574690811336 - 0.0350844524801j), (0.0365394353867 -
                                                0.0802438184619j),
         (0.0453781634569 - 0.130992040038j), (0.00801951438189 -
                                               0.214278846979j),
         (-0.0770946145058 - 0.230616629124j), (-0.105601429939 -
                                                0.190731987357j),
         (-0.105361394584 - 0.177761554718j), (-0.131518915296 -
                                               0.136102750897j),
         (-0.103761836886 - 0.0382263250649j), (-0.0167790111154 +
                                                0.0152206514031j),
         (0.0277570039034 + 0.0300403907895j), (0.056065287441 +
                                                0.0806603953242j),
         (0.118084669113 + 0.104863211513j), (0.128281414509 +
                                              0.0677760615945j),
         (0.0748447552323 + 0.0619902014732j), (0.0512856245041 +
                                                0.0775099247694j))
     src = blocks.vector_source_s(self.src_data)
     op = filter.freq_xlating_fir_filter_scf(1, self.taps, self.fc, self.fs)
     dst = blocks.vector_sink_c()
     self.tb.connect(src, op, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertComplexTuplesAlmostEqual(expected_data, result_data[-20:],
                                         5)
Ejemplo n.º 22
0
    def test_007_max_pdu_size_SOBs (self):
        # two SOB tags exactly max_pdu_size samples apart
        self.tb = gr.top_block ()
        start_time = 0.1
        max_size = 100
        sob_tag = gr.tag_utils.python_to_tag((10, pmt.intern("SOB"), pmt.PMT_T, pmt.intern("src")))
        sob_tag3 = gr.tag_utils.python_to_tag((10+max_size, pmt.intern("SOB"), pmt.PMT_T, pmt.intern("src")))

        vs = blocks.vector_source_s(range(1350), False, 1, [sob_tag, sob_tag3])
        t2p = pdu_utils.tags_to_pdu_s(pmt.intern('SOB'), pmt.intern('EOB'), 1024, 512000, ([]), False, 0, start_time)
        t2p.set_eob_parameters(10, 0)
        t2p.set_max_pdu_size(max_size)

        dbg = blocks.message_debug()
        self.tb.connect(vs, t2p)
        self.tb.msg_connect((t2p, 'pdu_out'), (dbg, 'store'))
        expected_vec = pmt.init_s16vector((max_size), range(10,10+max_size))
        expected_time = start_time + (10 / 512000.0)

        self.tb.run ()

        # assertions for the first PDU only, second PDU will exist
        self.assertEqual(dbg.num_messages(), 2)
        #print "got ", dbg.get_message(0)
        #print "expected", expected_vec
        self.assertTrue(pmt.equal(pmt.cdr(dbg.get_message(0)), expected_vec))
        time_tuple1 = pmt.dict_ref(pmt.car(dbg.get_message(0)), pmt.intern("burst_time"), pmt.PMT_NIL)
        self.assertAlmostEqual(pmt.to_uint64(pmt.tuple_ref(time_tuple1,0)) + pmt.to_double(pmt.tuple_ref(time_tuple1,1)), expected_time)

        self.tb = None
Ejemplo n.º 23
0
    def stest_s003(self):
        src_data0 = (0, 2, -3, 0, 12, 0)
        src_data1 = (1, 1, 1, 1, 1, 1)

        expected_result = [max(x, y) for x, y in zip(src_data0, src_data1)]

        src0 = blocks.vector_source_s(src_data0)
        src1 = blocks.vector_source_s(src_data1)
        op = blocks.max_ss(1)
        dst = blocks.vector_sink_s()

        self.tb.connect(src0, (op, 0))
        self.tb.connect(src1, (op, 1))
        self.tb.connect(op, dst)
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(expected_result, result_data)
Ejemplo n.º 24
0
    def __init__(self, options):
        config = station_configuration()
        dsubc = config.data_subcarriers

        gr.hier_block2.__init__(
            self,
            "static_tx_control",
            gr.io_signature(0, 0, 0),
            gr.io_signaturev(
                4,
                -1,
                [
                    gr.sizeof_short,  # ID
                    gr.sizeof_short,  # Multiplex control stream
                    gr.sizeof_char * dsubc,  # Bit Map
                    gr.sizeof_float * dsubc,  # Power Map
                    gr.sizeof_int
                ]))  # Bit count per frame

        self.control = ctrl = static_control(dsubc, config.frame_id_blocks,
                                             config.frame_data_blocks, options)

        id_out = (self, 0)
        mux_out = (self, 1)
        bitmap_out = (self, 2)
        powmap_out = (self, 3)

        self.cur_port = 4

        ## ID Source (root)
        id_src = self._id_source = blocks.vector_source_s([ctrl.static_id],
                                                          True)
        self.connect(id_src, id_out)

        ## Multiplex Source
        mux_src = self._multiplex_source = blocks.vector_source_s(
            ctrl.mux_stream, True)
        self.connect(mux_src, mux_out)

        ## Map Source
        map_src = blocks.vector_source_b(ctrl.rmod_stream, True, dsubc)
        self.connect(map_src, bitmap_out)

        ## Power Allocation Source
        pa_src = blocks.vector_source_f(ctrl.pow_stream, True, dsubc)
        self.connect(pa_src, powmap_out)
Ejemplo n.º 25
0
    def stest_s003(self):
        src_data0 = (0, 2, -3, 0, 12, 0)
        src_data1 = (1, 1,  1, 1,  1, 1)

        expected_result = [min(x,y) for x,y in zip(src_data0, src_data1)]

        src0 = blocks.vector_source_s(src_data0)
        src1 = blocks.vector_source_s(src_data1)
        op = blocks.min_ss(1)
        dst = blocks.vector_sink_s()

        self.tb.connect(src0, (op, 0))
        self.tb.connect(src1, (op, 1))
        self.tb.connect(op, dst)
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(expected_result, result_data)
Ejemplo n.º 26
0
 def do(self, data_src, data_exp, test_block):
     src = blocks.vector_source_s(data_src, vlen=240)
     self.tb.connect(src, test_block)
     dst = blocks.vector_sink_s(vlen=240)
     self.tb.connect(test_block, dst)
     self.tb.run()
     result_data = tuple([int(x) for x in dst.data()])
     self.assertEqual(data_exp, result_data)
 def do(self, data_src, data_exp, test_block):
     src = blocks.vector_source_s(data_src)
     self.tb.connect(src, test_block)
     dst = blocks.vector_sink_s(vlen=240)
     self.tb.connect(test_block, dst)
     self.tb.run()
     result_data = tuple([int(x) for x in dst.data()])
     self.assertEqual(data_exp, result_data)
Ejemplo n.º 28
0
    def __init__(self, uhd_address, options):

        gr.top_block.__init__(self)

        self.uhd_addr = uhd_address
        self.freq = options.freq
        self.samp_rate = options.samp_rate
        self.gain = options.gain
        self.threshold = options.threshold
        self.trigger = options.trigger

        self.uhd_src = uhd.single_usrp_source(
            device_addr=self.uhd_addr,
            stream_args=uhd.stream_args('fc32'))

        self.uhd_src.set_samp_rate(self.samp_rate)
        self.uhd_src.set_center_freq(self.freq, 0)
        self.uhd_src.set_gain(self.gain, 0)

        taps = firdes.low_pass_2(1, 1, 0.4, 0.1, 60)
        self.chanfilt = filter.fir_filter_ccc(10, taps)
        self.tagger = blocks.burst_tagger(gr.sizeof_gr_complex)

        # Dummy signaler to collect a burst on known periods
        data = 1000 * [0, ] + 1000 * [1, ]
        self.signal = blocks.vector_source_s(data, True)

        # Energy detector to get signal burst
        # use squelch to detect energy
        self.det = analog.simple_squelch_cc(self.threshold, 0.01)
        # convert to mag squared (float)
        self.c2m = blocks.complex_to_mag_squared()
        # average to debounce
        self.avg = filter.single_pole_iir_filter_ff(0.01)
        # rescale signal for conversion to short
        self.scale = blocks.multiply_const_ff(2**16)
        # signal input uses shorts
        self.f2s = blocks.float_to_short()

        # Use file sink burst tagger to capture bursts
        self.fsnk = blocks.tagged_file_sink(
            gr.sizeof_gr_complex, self.samp_rate)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.uhd_src, 0), (self.tagger, 0))
        self.connect((self.tagger, 0), (self.fsnk, 0))

        if self.trigger:
            # Connect a dummy signaler to the burst tagger
            self.connect((self.signal, 0), (self.tagger, 1))

        else:
            # Connect an energy detector signaler to the burst tagger
            self.connect(self.uhd_src, self.det)
            self.connect(self.det, self.c2m, self.avg, self.scale, self.f2s)
            self.connect(self.f2s, (self.tagger, 1))
Ejemplo n.º 29
0
    def __init__(self, uhd_address, options):

        gr.top_block.__init__(self)

        self.uhd_addr = uhd_address
        self.freq = options.freq
        self.samp_rate = options.samp_rate
        self.gain = options.gain
        self.threshold = options.threshold
        self.trigger = options.trigger

        self.uhd_src = uhd.single_usrp_source(
            device_addr=self.uhd_addr,
            stream_args=uhd.stream_args('fc32'))

        self.uhd_src.set_samp_rate(self.samp_rate)
        self.uhd_src.set_center_freq(self.freq, 0)
        self.uhd_src.set_gain(self.gain, 0)

        taps = firdes.low_pass_2(1, 1, 0.4, 0.1, 60)
        self.chanfilt = filter.fir_filter_ccc(10, taps)
        self.tagger = blocks.burst_tagger(gr.sizeof_gr_complex)

        # Dummy signaler to collect a burst on known periods
        data = 1000*[0,] + 1000*[1,]
        self.signal = blocks.vector_source_s(data, True)

        # Energy detector to get signal burst
        ## use squelch to detect energy
        self.det  = analog.simple_squelch_cc(self.threshold, 0.01)
        ## convert to mag squared (float)
        self.c2m = blocks.complex_to_mag_squared()
        ## average to debounce
        self.avg = filter.single_pole_iir_filter_ff(0.01)
        ## rescale signal for conversion to short
        self.scale = blocks.multiply_const_ff(2**16)
        ## signal input uses shorts
        self.f2s = blocks.float_to_short()

        # Use file sink burst tagger to capture bursts
        self.fsnk = blocks.tagged_file_sink(gr.sizeof_gr_complex, self.samp_rate)


        ##################################################
        # Connections
        ##################################################
        self.connect((self.uhd_src, 0), (self.tagger, 0))
        self.connect((self.tagger, 0), (self.fsnk, 0))

        if self.trigger:
            # Connect a dummy signaler to the burst tagger
            self.connect((self.signal, 0), (self.tagger, 1))

        else:
            # Connect an energy detector signaler to the burst tagger
            self.connect(self.uhd_src, self.det)
            self.connect(self.det, self.c2m, self.avg, self.scale, self.f2s)
            self.connect(self.f2s, (self.tagger, 1))
Ejemplo n.º 30
0
 def test_interleaved_short_to_complex(self):
     src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
     expected_data = (1 + 2j, 3 + 4j, 5 + 6j, 7 + 8j, 9 + 10j)
     src = blocks.vector_source_s(src_data)
     op = blocks.interleaved_short_to_complex()
     dst = blocks.vector_sink_c()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertEqual(expected_data, dst.data())
Ejemplo n.º 31
0
 def test_short_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_s(src_data)
     op = blocks.short_to_float()
     dst = blocks.vector_sink_f()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertEqual(expected_data, dst.data())
Ejemplo n.º 32
0
 def test_short_to_float_scale(self):
     src_data = (5, 10, 15, 20, 25)
     expected_data = (1.0, 2.0, 3.0, 4.0, 5.0)
     src = blocks.vector_source_s(src_data)
     op = blocks.short_to_float(1, 5)
     dst = blocks.vector_sink_f()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertEqual(expected_data, dst.data())
Ejemplo n.º 33
0
 def help_ss(self, src_data, exp_data, op):
     for s in zip(list(range(len(src_data))), src_data):
         src = blocks.vector_source_s(s[1])
         self.tb.connect(src, (op, s[0]))
     dst = blocks.vector_sink_s()
     self.tb.connect(op, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertEqual(exp_data, result_data)
Ejemplo n.º 34
0
    def test_000_ss(self):
	src_data = (1, 2, 3, 4, 5, 6)
	dst_data = (6, 15)
	src = blocks.vector_source_s(src_data)
	itg = blocks.integrate_ss(3)
	dst = blocks.vector_sink_s()
	self.tb.connect(src, itg, dst)
	self.tb.run()
	self.assertEqual(dst_data, dst.data())
Ejemplo n.º 35
0
 def test_000_ss(self):
     src_data = (1, 2, 3, 4, 5, 6)
     dst_data = (6, 15)
     src = blocks.vector_source_s(src_data)
     itg = blocks.integrate_ss(3)
     dst = blocks.vector_sink_s()
     self.tb.connect(src, itg, dst)
     self.tb.run()
     self.assertEqual(dst_data, dst.data())
Ejemplo n.º 36
0
 def help_ss (self, src_data, exp_data, op):
     for s in zip (range (len (src_data)), src_data):
         src = blocks.vector_source_s (s[1])
         self.tb.connect (src, (op, s[0]))
     dst = blocks.vector_sink_s ()
     self.tb.connect (op, dst)
     self.tb.run ()
     result_data = dst.data ()
     self.assertEqual (exp_data, result_data)
Ejemplo n.º 37
0
 def test_and_const_ss (self):
     src_data =        (1,  2,  3,  0x5004,   0x1150)
     expected_result = (0,  2,  2,  0x5000,   0x1100)
     src = blocks.vector_source_s(src_data)
     op = blocks.and_const_ss (0x55AA)
     dst = blocks.vector_sink_s()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertEqual(dst.data(), expected_result)
Ejemplo n.º 38
0
    def help_const_ss(self, src_data, exp_data, op):
	src = blocks.vector_source_s(src_data)
	srcv = blocks.stream_to_vector(gr.sizeof_short, len(src_data))
	rhs = blocks.vector_to_stream(gr.sizeof_short, len(src_data))
        dst = blocks.vector_sink_s()
        self.tb.connect(src, srcv, op, rhs, dst)
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(exp_data, result_data)
Ejemplo n.º 39
0
 def test_short_to_char(self):
     src_data = (256, 512, 768, 1024, 1280)
     expected_data = (1, 2, 3, 4, 5)
     src = blocks.vector_source_s(src_data)
     op = blocks.short_to_char()
     dst = blocks.vector_sink_b()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertEqual(expected_data, dst.data())
Ejemplo n.º 40
0
 def test_and_const_ss(self):
     src_data = [1, 2, 3, 0x5004, 0x1150]
     expected_result = [0, 2, 2, 0x5000, 0x1100]
     src = blocks.vector_source_s(src_data)
     op = blocks.and_const_ss(0x55AA)
     dst = blocks.vector_sink_s()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertEqual(dst.data(), expected_result)
Ejemplo n.º 41
0
 def test_short_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_s(src_data)
     op = blocks.short_to_float()
     dst = blocks.vector_sink_f()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertEqual(expected_data, dst.data())
Ejemplo n.º 42
0
 def test_short_to_float_scale(self):
     src_data = (5, 10, 15, 20, 25)
     expected_data = (1.0, 2.0, 3.0, 4.0, 5.0)
     src = blocks.vector_source_s(src_data)
     op = blocks.short_to_float(1, 5)
     dst = blocks.vector_sink_f()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertEqual(expected_data, dst.data())
Ejemplo n.º 43
0
 def help_const_ss(self, src_data, exp_data, op):
     src = blocks.vector_source_s(src_data)
     srcv = blocks.stream_to_vector(gr.sizeof_short, len(src_data))
     rhs = blocks.vector_to_stream(gr.sizeof_short, len(src_data))
     dst = blocks.vector_sink_s()
     self.tb.connect(src, srcv, op, rhs, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertEqual(exp_data, result_data)
Ejemplo n.º 44
0
 def test_short_to_char(self):
     src_data = (256, 512, 768, 1024, 1280)
     expected_data = (1, 2, 3, 4, 5)
     src = blocks.vector_source_s(src_data)
     op = blocks.short_to_char()
     dst = blocks.vector_sink_b()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertEqual(expected_data, dst.data())
Ejemplo n.º 45
0
 def test_interleaved_short_to_complex(self):
     src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
     expected_data = (1+2j, 3+4j, 5+6j, 7+8j, 9+10j)
     src = blocks.vector_source_s(src_data)
     op = blocks.interleaved_short_to_complex()
     dst = blocks.vector_sink_c()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertEqual(expected_data, dst.data())
Ejemplo n.º 46
0
 def test001_module_load (self):
     data = (0,16,36,40,68,104,148,220,320,512)
     src = blocks.vector_source_s(data)
     enc = vocoder.g723_24_encode_sb()
     dec = vocoder.g723_24_decode_bs()
     snk = blocks.vector_sink_s()
     self.tb.connect(src, enc, dec, snk)
     self.tb.run()
     actual_result = snk.data()
     self.assertEqual(data, actual_result)
Ejemplo n.º 47
0
 def help_ss(self, src_data, exp_data, op):
     for s in zip(list(range(len(src_data))), src_data):
         src = blocks.vector_source_s(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_s()
     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)
Ejemplo n.º 48
0
 def test_004_ss_vec(self):
     src_data = [1, 2, 3, 4, 5, 6]
     dst_data = [9, 12]
     vlen = 2
     src = blocks.vector_source_s(src_data, False, vlen)
     itg = blocks.integrate_ss(3, vlen)
     dst = blocks.vector_sink_s(vlen)
     self.tb.connect(src, itg, dst)
     self.tb.run()
     self.assertEqual(dst_data, dst.data())
Ejemplo n.º 49
0
 def test001_module_load (self):
     data = (0,8,36,72,100,152,228,316,404,528)
     src = blocks.vector_source_s(data)
     enc = vocoder.g723_40_encode_sb()
     dec = vocoder.g723_40_decode_bs()
     snk = blocks.vector_sink_s()
     self.tb.connect(src, enc, dec, snk)
     self.tb.run()
     actual_result = snk.data()
     self.assertEqual(data, actual_result)
Ejemplo n.º 50
0
def main():
    data = scipy.arange(0, 32000, 1).tolist()
    trig = 100*[0,] + 100*[1,]

    src = blocks.vector_source_s(data, True)
    trigger = blocks.vector_source_s(trig, True)

    thr = blocks.throttle(gr.sizeof_short, 10e3)
    ann = blocks.annotator_alltoall(1000000, gr.sizeof_short)
    tagger = blocks.burst_tagger(gr.sizeof_short)

    fsnk = blocks.tagged_file_sink(gr.sizeof_short, 1)

    tb = gr.top_block()
    tb.connect(src, thr, (tagger, 0))
    tb.connect(trigger, (tagger, 1))
    tb.connect(tagger, fsnk)

    tb.run()
Ejemplo n.º 51
0
 def test001_module_load(self):
     data = (0, 16, 36, 40, 68, 104, 148, 220, 320, 512)
     src = blocks.vector_source_s(data)
     enc = vocoder.g723_24_encode_sb()
     dec = vocoder.g723_24_decode_bs()
     snk = blocks.vector_sink_s()
     self.tb.connect(src, enc, dec, snk)
     self.tb.run()
     actual_result = snk.data()
     self.assertEqual(list(data), actual_result)
Ejemplo n.º 52
0
    def test_004_ss_vec(self):
	src_data = (1, 2, 3, 4, 5, 6)
	dst_data = (9, 12)
	vlen = 2
	src = blocks.vector_source_s(src_data, False, vlen)
	itg = blocks.integrate_ss(3, vlen)
	dst = blocks.vector_sink_s(vlen)
	self.tb.connect(src, itg, dst)
	self.tb.run()
	self.assertEqual(dst_data, dst.data())
Ejemplo n.º 53
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_s(src_data)
     sqr = howtogen.square_ss()
     dst = blocks.vector_sink_s()
     self.tb.connect(src, sqr)
     self.tb.connect(sqr, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertFloatTuplesAlmostEqual(expected_result, result_data, 6)
Ejemplo n.º 54
0
 def test001_module_load (self):
     data = (8,24,36,52,56,64,76,88,104,124,132,148,172,
             196,220,244,280,320,372,416,468,524,580,648)
     src = blocks.vector_source_s(data)
     enc = vocoder.g721_encode_sb()
     dec = vocoder.g721_decode_bs()
     snk = blocks.vector_sink_s()
     self.tb.connect(src, enc, dec, snk)
     self.tb.run()
     actual_result = snk.data()
     self.assertEqual(data, actual_result)
Ejemplo n.º 55
0
 def test001_module_load (self):
     data = (8,24,40,56,72,88,104,120,132,148,164,180,
             196,212,228,244,260,276,292,308,324,340)
     src = blocks.vector_source_s(data)
     enc = vocoder.ulaw_encode_sb()
     dec = vocoder.ulaw_decode_bs()
     snk = blocks.vector_sink_s()
     self.tb.connect(src, enc, dec, snk)
     self.tb.run()
     actual_result = snk.data()
     self.assertEqual(data, actual_result)
Ejemplo n.º 56
0
 def test001_module_load (self):
     data = (8,24,40,56,72,88,104,120,136,152,168,184,
             200,216,232,248,264,280,296,312,328,344)
     src = blocks.vector_source_s(data)
     enc = vocoder.alaw_encode_sb()
     dec = vocoder.alaw_decode_bs()
     snk = blocks.vector_sink_s()
     self.tb.connect(src, enc, dec, snk)
     self.tb.run()
     actual_result = snk.data()
     self.assertEqual(data, actual_result)
Ejemplo n.º 57
0
    def test_sub_ss1(self):
        src1_data = (1, 2, 3, 4, 5)
        expected_result = (1, 2, 3, 4, 5)

        src = blocks.vector_source_s(src1_data)
        op = blocks.sub_ss()
        dst = blocks.vector_sink_s()
        self.tb.connect(src, op, dst)
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(expected_result, result_data)
Ejemplo n.º 58
0
  def __init__(self, options):
    config = station_configuration()
    dsubc = config.data_subcarriers

    gr.hier_block2.__init__(self, "static_tx_control",
      gr.io_signature (0,0,0),
      gr.io_signaturev(4,-1,[gr.sizeof_short,         # ID
                             gr.sizeof_short,         # Multiplex control stream
                             gr.sizeof_char*dsubc,    # Bit Map
                             gr.sizeof_float*dsubc,   # Power Map
                             gr.sizeof_int ]))        # Bit count per frame

    self.control = ctrl = static_control(dsubc,config.frame_id_blocks,
                                  config.frame_data_blocks,options)

    id_out = (self,0)
    mux_out = (self,1)
    bitmap_out = (self,2)
    powmap_out = (self,3)

    self.cur_port = 4


    ## ID Source (root)
    id_src = self._id_source = blocks.vector_source_s([ctrl.static_id],True)
    self.connect(id_src,id_out)


    ## Multiplex Source
    mux_src = self._multiplex_source = blocks.vector_source_s(ctrl.mux_stream,True)
    self.connect(mux_src,mux_out)


    ## Map Source
    map_src = blocks.vector_source_b(ctrl.rmod_stream, True, dsubc)
    self.connect(map_src,bitmap_out)


    ## Power Allocation Source
    pa_src = blocks.vector_source_f(ctrl.pow_stream,True,dsubc)
    self.connect(pa_src,powmap_out)
Ejemplo n.º 59
0
Archivo: app2.py Proyecto: WiLab/gr-iio
 def __init__(self):
     gr.top_block.__init__(self)
     test = (1,2,3)
     test_src = blocks.vector_source_s(test)
     src = iio.fmcomms_source()
     sink = blocks.vector_sink_s()
     self.connect(src,sink)
     self.start()
     sleep(0.05)
     self.stop()
     result = sink.data()
     print(result)