def test_001_t (self):
     src = ofdm.allocation_src(6,3,"tcp://*:3333")
     src.set_allocation([2]*6,[3]*6)
     #skiphead = blocks.skiphead( gr.sizeof_float, 8 )
     limit_id = blocks.head( gr.sizeof_short, 4 )
     limit_bitcount = blocks.head( gr.sizeof_int, 4 )
     limit_bitloading = blocks.head( gr.sizeof_char*6, 4 )
     limit_power = blocks.head( gr.sizeof_gr_complex*6, 4 )
     dst_id = blocks.vector_sink_s()
     dst_bitcount = blocks.vector_sink_i()
     dst_bitloading = blocks.vector_sink_b(6)
     dst_power = blocks.vector_sink_c(6)
     self.tb.connect((src,0),limit_id,dst_id)
     self.tb.connect((src,1),limit_bitcount,dst_bitcount)
     self.tb.connect((src,2),limit_bitloading,dst_bitloading)
     self.tb.connect((src,3),limit_power,dst_power)
     # set up fg
     self.tb.run ()
     # check data
     result_id = dst_id.data()
     result_bitcount = dst_bitcount.data()
     result_bitloading = dst_bitloading.data()
     result_power = dst_power.data()
     print "id", result_id
     print "bitcount", result_bitcount
     print "bitloading", result_bitloading
     print "power", result_power
    def __init__(self):
        gr.top_block.__init__(self)

	usage = "%prog: [options] filename"
        parser = OptionParser(option_class=eng_option, usage=usage)
        parser.add_option("-r", "--sample-rate", type="eng_float", default=48000,
                          help="set sample rate to RATE (48000)")
	parser.add_option("-N", "--samples", type="eng_float", default=None,
			  help="number of samples to record")
        (options, args) = parser.parse_args ()
        if len(args) != 1 or options.samples is None:
            parser.print_help()
            raise SystemExit, 1

        sample_rate = int(options.sample_rate)
        ampl = 0.1

        src0 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 350, ampl)
        src1 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 440, ampl)
	head0 = blocks.head(gr.sizeof_float, int(options.samples))
	head1 = blocks.head(gr.sizeof_float, int(options.samples))
	dst = blocks.wavfile_sink(args[0], 2, int(options.sample_rate), 16)

        self.connect(src0, head0, (dst, 0))
        self.connect(src1, head1, (dst, 1))
Beispiel #3
0
    def test_preamble (self):
        pream_len = 52
        pream = (mapper.preamble_generator(pream_len,511,1033)).get_preamble()
        
        rand_src    = blocks.vector_source_b(map(int, numpy.random.randint(0, 2, 1024)), True)
        head        = blocks.head(gr.sizeof_char*1, 1024)
        src_sink    = blocks.vector_sink_b(1)
        pream_inst  = mapper.preamble_insert_bb(pream_len*10, (pream))
        bit2symb    = mapper.mapper(mapper.BPSK, ([0,1]))
        pream_sync  = mapper.preamble_sync_cc(pream_len*10, (pream), mapper.BPSK, ([0,1]), .97, .90)
        symb2bit    = mapper.demapper(mapper.BPSK, ([0,1]))
        rec_sink    = blocks.vector_sink_b(1)

        self.tb.connect((rand_src, 0), (head, 0))
        self.tb.connect((head, 0), (pream_inst, 0))
        self.tb.connect((head, 0), (src_sink, 0))
        self.tb.connect((pream_inst, 0), (bit2symb, 0))
        self.tb.connect((bit2symb, 0), (pream_sync, 0))
        self.tb.connect((pream_sync, 0), (symb2bit, 0))
        self.tb.connect((symb2bit, 0), (rec_sink, 0))
        
        self.tb.start()
        sleep(1)
        self.tb.stop()
        
        data_space = pream_len*9
        sd = src_sink.data()
        rd = rec_sink.data()
        self.assertEqual(sd[0:data_space],rd[0:data_space])
	def test_001_t (self):
		# set up fg
		test_len = 1000
		packet_len = test_len
		pulse_send = (200,300,100)
		pulse_wait = (100,100)
		amplitude = 0.5
		
		num_skip = 5 # skip samples with skiphead
		num_xcorr = 300 # num of xcorrs to determine delay samples
		
		src = radar.signal_generator_sync_pulse_c(packet_len,pulse_send,pulse_wait,amplitude,"packet_len")
		head = blocks.head(8,test_len)
		skiphead = blocks.skiphead(8,num_skip)
		est = radar.estimator_sync_pulse_c(num_xcorr,"packet_len")
		res = radar.print_results()
		debug = blocks.message_debug()
		
		self.tb.connect(src,skiphead,head)
		self.tb.connect((head,0),(est,0)) # TX stream (undelayed but skiped)
		self.tb.connect((src,0),(est,1)) # RX stream (delayed but unskiped)
		self.tb.msg_connect(est,'Msg out',res,'Msg in')
		self.tb.msg_connect(est,'Msg out',debug,'store')
		self.tb.run ()
		
		# check data
		msg = debug.get_message(0)
		num_skip_est = pmt.to_long(pmt.nth(1,pmt.nth(1,msg)))
		self.assertEqual(num_skip_est,num_skip)
Beispiel #5
0
	def test_001_t (self):
		# set up fg
		samp_cw = 300
		samp_up = 200
		samp_down = 100
		
		mult = 3
		test_len = (samp_cw+samp_up+samp_down)*mult
		
		samp_rate = 2000
		len_key = "packet_len"
		packet_parts = (samp_cw, samp_up, samp_down)
		
		src = radar.signal_generator_fmcw_c(samp_rate, samp_up, samp_down, samp_cw, 500, 250, 1, len_key);
		head = blocks.head(8,test_len)
		split0 = radar.split_cc(0,packet_parts,len_key)
		split1 = radar.split_cc(1,packet_parts,len_key)
		split2 = radar.split_cc(2,packet_parts,len_key)
		snk0 = blocks.vector_sink_c()
		snk1 = blocks.vector_sink_c()
		snk2 = blocks.vector_sink_c()
		
		self.tb.connect(src,head)
		self.tb.connect(head,split0,snk0)
		self.tb.connect(head,split1,snk1)
		self.tb.connect(head,split2,snk2)
		self.tb.run ()
		
		# check data
		self.assertEqual(len(snk0.data()),mult*samp_cw) # check correct number of samples in every sink
		self.assertEqual(len(snk1.data()),mult*samp_up)
		self.assertEqual(len(snk2.data()),mult*samp_down)
Beispiel #6
0
    def __init__(self):
        gr.top_block.__init__(self)

        default_nsamples = 10e6
        parser = ArgumentParser()
        parser.add_argument("-p", "--npipelines", type=intx, default=1,
                          metavar="NPIPES", help="the number of pipelines to create (default=%(default)s)")
        parser.add_argument("-s", "--nstages", type=intx, default=1, metavar="NSTAGES",
                          help="the number of stages in each pipeline (default=%(default)s)")
        parser.add_argument("-N", "--nsamples", type=eng_float, default=default_nsamples,
                          help=("the number of samples to run through the graph (default=%s)" %
                                (eng_notation.num_to_str(default_nsamples))))
        parser.add_argument("-m", "--machine-readable", action="store_true", default=False,
                          help="enable machine readable output")

        args = parser.parse_args()

        self.npipes = args.npipelines
        self.nstages = args.nstages
        self.nsamples = args.nsamples
        self.machine_readable = args.machine_readable

        ntaps = 256

        # Something vaguely like floating point ops
        self.flop = 2 * ntaps * args.npipelines * args.nstages * args.nsamples

        src = blocks.null_source(gr.sizeof_float)
        head = blocks.head(gr.sizeof_float, int(args.nsamples))
        self.connect(src, head)

        for n in range(args.npipelines):
            self.connect(head, pipeline(args.nstages, ntaps))
Beispiel #7
0
 def __init__(self, item_size, num_outputs, default_output):
     """
     Selector constructor.
     Args:
         item_size: the size of the gr data stream in bytes
         num_inputs: the number of inputs (integer)
         num_outputs: the number of outputs (integer)
         input_index: the index for the source data
         output_index: the index for the destination data
     """
     gr.hier_block2.__init__(
         self, 'selector',
         gr.io_signature(1, 1, item_size),
         gr.io_signature(num_outputs, num_outputs, item_size),
     )
     num_inputs = 1
     # Terminator blocks for unused inputs and outputs
     self.input_terminators = [blocks.null_sink(item_size) for i in range(num_inputs)]
     self.output_terminators = [blocks.head(item_size, 0) for i in range(num_outputs)]
     self.copy = blocks.copy(item_size)
     # Connections
     for i in range(num_inputs): self.connect((self, i), self.input_terminators[i])
     for i in range(num_outputs): self.connect(blocks.null_source(item_size), self.output_terminators[i], (self, i))
     # Set parameters
     self.num_outputs = num_outputs
     self.input_index = 0
     self.output_index = default_output
     # Register the message port
     self.message_port_register_hier_in("selection")
     self.mb = message_receiver(self);
     # Connect message port
     self.msg_connect(self, "selection", self.mb,"selection")
     # Connect default
     self._connect_current()
    def test_begin_tag_repeat(self):
        src_data = range(1000)
        expected_result = range(1000)
        expected_result.extend(range(1000))

        snk2 = blocks.vector_sink_f()

        with tempfile.NamedTemporaryFile() as temp:
            src = blocks.vector_source_f(src_data)
            snk = blocks.file_sink(gr.sizeof_float, temp.name)
            snk.set_unbuffered(True)

            src2 = blocks.file_source(gr.sizeof_float, temp.name, True)
            src2.set_begin_tag(pmt.string_to_symbol("file_begin"))
            hd = blocks.head(gr.sizeof_float, 2000)

            self.tb.connect(src, snk)
            self.tb.run()

            self.tb.disconnect(src, snk)
            self.tb.connect(src2, hd, snk2)
            self.tb.run()

        result_data = snk2.data()
        self.assertFloatTuplesAlmostEqual(expected_result, result_data)
        tags = snk2.tags()
        self.assertEqual(len(tags), 2)
        self.assertEqual(str(tags[0].key), "file_begin")
        self.assertEqual(str(tags[0].value), "0")
        self.assertEqual(tags[0].offset, 0)
        self.assertEqual(str(tags[1].key), "file_begin")
        self.assertEqual(str(tags[1].value), "1")
        self.assertEqual(tags[1].offset, 1000)
Beispiel #9
0
    def __init__(self):
        gr.top_block.__init__(self)

        usage="%prog: [options] output_filename"
        parser = OptionParser(option_class=eng_option, usage=usage)
        parser.add_option("-I", "--audio-input", type="string", default="",
                          help="pcm input device name.  E.g., hw:0,0 or /dev/dsp")
        parser.add_option("-r", "--sample-rate", type="eng_float", default=48000,
                          help="set sample rate to RATE (48000)")
        parser.add_option("-N", "--nsamples", type="eng_float", default=None,
                          help="number of samples to collect [default=+inf]")

        (options, args) = parser.parse_args ()
        if len(args) != 1:
            parser.print_help()
            raise( SystemExit, 1 )
        filename = args[0]

        sample_rate = int(options.sample_rate)
        src = audio.source (sample_rate, options.audio_input)
        dst = blocks.wavfile_sink (filename, 1, sample_rate)

        if options.nsamples is None:
            self.connect((src, 0), dst)
        else:
            head = blocks.head(gr.sizeof_float, int(options.nsamples))
            self.connect((src, 0), head, dst)
Beispiel #10
0
 def __init__(self, item_size, num_inputs, num_outputs, input_index, output_index):
     """
     Selector constructor.
     
     Args:
         item_size: the size of the gr data stream in bytes
         num_inputs: the number of inputs (integer)
         num_outputs: the number of outputs (integer)
         input_index: the index for the source data
         output_index: the index for the destination data
     """
     gr.hier_block2.__init__(
         self, 'selector',
         gr.io_signature(num_inputs, num_inputs, item_size),
         gr.io_signature(num_outputs, num_outputs, item_size),
     )
     #terminator blocks for unused inputs and outputs
     self.input_terminators = [blocks.null_sink(item_size) for i in range(num_inputs)]
     self.output_terminators = [blocks.head(item_size, 0) for i in range(num_outputs)]
     self.copy = blocks.copy(item_size)
     #connections
     for i in range(num_inputs): self.connect((self, i), self.input_terminators[i])
     for i in range(num_outputs): self.connect(blocks.null_source(item_size),
                                                       self.output_terminators[i], (self, i))
     self.item_size = item_size
     self.input_index = input_index
     self.output_index = output_index
     self.num_inputs = num_inputs
     self.num_outputs = num_outputs
     self._connect_current()
    def test_001_t (self):
        self.degree = 5
        self.length = 2**self.degree - 1
        expected_result = (self.length - 1)*[-1.0/self.length]+[1]

        # send a maximum length sequence with period 31
        src_real = digital.glfsr_source_f(self.degree, True, 0, 1)
        src_imag = blocks.null_source(gr.sizeof_float*1)
        f2c = blocks.float_to_complex(1)

        mls_correlator = channelsounder_swig.mls_correlator(self.degree, mask = 0, seed = 1)

        # keep only the samples of the first two autocorrelation periods
        head = blocks.head(gr.sizeof_gr_complex, 2*self.length)
        dest = blocks.vector_sink_c(1)

        self.tb.connect( src_real, (f2c, 0))
        self.tb.connect( src_imag, (f2c, 1))

        self.tb.connect( f2c, mls_correlator )
        self.tb.connect( mls_correlator, head, dest )
        # set up fg
        self.tb.run ()

        # check data

        result_data = dest.data()
        # discard the first period, since it is tainted by the zeros inserted
        # by set_history()
        result_data = result_data[self.length:]
        self.assertFloatTuplesAlmostEqual (expected_result, result_data, 6)
    def __init__(self, N, fs, bw0, bw1, tw, atten, D):
        gr.top_block.__init__(self)

        self._nsamps = N
        self._fs = fs
        self._bw0 = bw0
        self._bw1 = bw1
        self._tw = tw
        self._at = atten
        self._decim = D
        taps = filter.firdes.complex_band_pass_2(1, self._fs,
                                                 self._bw0, self._bw1,
                                                 self._tw, self._at)
        print "Num. Taps: ", len(taps)

        self.src  = analog.noise_source_c(analog.GR_GAUSSIAN, 1)
        self.head = blocks.head(gr.sizeof_gr_complex, self._nsamps)

        self.filt0 = filter.fft_filter_ccc(self._decim, taps)

        self.vsnk_src = blocks.vector_sink_c()
        self.vsnk_out = blocks.vector_sink_c()

        self.connect(self.src, self.head, self.vsnk_src)
        self.connect(self.head, self.filt0, self.vsnk_out)
	def test_003_t (self):
		# test cut frequency negative freq
		# set up fg
		test_len = 1000
		samp_rate = 2000
		freq1 = -200
		freq2 = -205
		ampl = 1
		packet_len = test_len
		threshold = -100
		samp_protect = 2
		
		src1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, freq1, ampl*0.2)
		src2 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, freq2, ampl)
		add = blocks.add_cc();
		head = blocks.head(8,test_len)
		s2ts = blocks.stream_to_tagged_stream(8,1,packet_len,"packet_len")
		fft = radar.ts_fft_cc(packet_len)
		peak = radar.find_max_peak_c(samp_rate, threshold, samp_protect, (-200,200), True)
		debug = blocks.message_debug()
		
		self.tb.connect((src1,0), (add,0))
		self.tb.connect((src2,0), (add,1))
		self.tb.connect(add,head,s2ts,fft,peak)
		self.tb.msg_connect(peak,"Msg out",debug,"store")
		#self.tb.msg_connect(peak,"Msg out",debug,"print")
		self.tb.start()
		sleep(0.5)
		self.tb.stop()
		self.tb.wait()
		
		# check frequency in os_cfar message with given one
		msg = debug.get_message(0)
		self.assertAlmostEqual(freq1,pmt.f32vector_ref(pmt.nth(1,pmt.nth(1,msg)),0),8)
Beispiel #14
0
    def test_004_es_source_pdus(self):
        print "test_004_es_source_pdus"       
        msg = pmt.cons( pmt.to_pmt( {"somekey":"val2", "somekey2":"someval2" } ), 
                        pmt.to_pmt( numpy.array( [0,1,2,3,4,5,6,7,8,9] , dtype=numpy.float32) ) );
        src = es.source([gr.sizeof_float], 8, 2);
        stb = blocks.message_strobe( msg, 100.0 );
        tb = gr.top_block();
        tb.msg_connect(stb, "strobe", src, "schedule_event");
        th = blocks.throttle(gr.sizeof_float, 1000*100);
        hd = blocks.head(gr.sizeof_float, 1000*100);
        snk = blocks.vector_sink_f();
        tb.connect(src,th,hd,snk);

        # TODO: this can not use run because it is 
        # subject to GNU Radio's shutdown msg block bug
        # for remaining upstream msg blocks ...
        #tb.run();

        # workaround
        tb.start();
        time.sleep(1);
        tb.stop();
        tb.wait();

        self.assertEqual( sum(snk.data())>0, True );
    def __init__(self):
        gr.top_block.__init__(self)

        self.qapp = QtGui.QApplication(sys.argv)

        data0  = 10*[0,] + 40*[1,0] + 10*[0,]
        data0 += 10*[0,] + 40*[0,1] + 10*[0,]
        data1 = 20*[0,] + [0,0,0,1,1,1,0,0,0,0] + 70*[0,]

        # Adjust these to change the layout of the plot.
        # Can be set to fractions.
        ncols = 100.25
        nrows = 100

        fs = 200
        src0 = blocks.vector_source_f(data0, True)
        src1 = blocks.vector_source_f(data1, True)
        thr = blocks.throttle(gr.sizeof_float, 50000)
        hed = blocks.head(gr.sizeof_float, 10000000)
        self.snk1 = qtgui.time_raster_sink_f(fs, nrows, ncols, [], [],
                                             "Float Time Raster Example", 2)

        self.connect(src0, thr, (self.snk1, 0))
        self.connect(src1, (self.snk1, 1))

        # Get the reference pointer to the SpectrumDisplayForm QWidget
        pyQt = self.snk1.pyqwidget()

        # Wrap the pointer as a PyQt SIP object
        # This can now be manipulated as a PyQt4.QtGui.QWidget
        pyWin = sip.wrapinstance(pyQt, QtGui.QWidget)

        self.main_box = dialog_box(pyWin)
        self.main_box.show()
Beispiel #16
0
    def run_fir_filters_fff(self):
        self.blocks = []
        self.tb = gr.top_block()
        self.blocks.append(blocks.null_source(gr.sizeof_float))
        self.blocks.append(blocks.head(gr.sizeof_float, self.N))

        # First filter is much larger than others
        taps = numpy.random.random(self.mult*self.ntaps)
        self.blocks.append(filter.fir_filter_fff(1, taps))
        self.blocks[0].set_processor_affinity([0,])

        # Set up rest of mfirs filters with new taps for each filter
        for m in xrange(1, self.mfirs):
            taps = numpy.random.random(self.ntaps)
            self.blocks.append(filter.fir_filter_fff(1, taps))
        #self.blocks[m].set_processor_affinity([1,])
        #self.blocks[m].set_processor_affinity([1,])
        #self.blocks[m].set_processor_affinity([1,])
        #self.blocks[m].set_processor_affinity([1,])
        #self.blocks[m].set_processor_affinity([1,])
        #self.blocks[m].set_processor_affinity([1,])
        #self.blocks[m].set_processor_affinity([1,])

        # Add a null sink
        self.blocks.append(blocks.null_sink(gr.sizeof_float))

        # Connect the blocks and run
        self.tb.connect(*self.blocks)
        self.tb.run()
def run_test (f,Kb,bitspersymbol,K,dimensionality,tot_constellation,N0,seed):
    tb = gr.top_block ()

    # TX
    src = blocks.lfsr_32k_source_s()
    src_head = blocks.head (gr.sizeof_short,Kb/16) # packet size in shorts
    s2fsmi = blocks.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the FSM input cardinality
    enc = trellis.encoder_ss(f,0) # initial state = 0
    # essentially here we implement the combination of modulation and channel as a memoryless modulation (the memory induced by the channel is hidden in the FSM)
    mod = digital.chunks_to_symbols_sf(tot_constellation,dimensionality)

    # CHANNEL
    add = blocks.add_ff()
    noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed)

    # RX
    metrics = trellis.metrics_f(f.O(),dimensionality,tot_constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for Viterbi
    va = trellis.viterbi_s(f,K,0,-1) # Put -1 if the Initial/Final states are not set.
    fsmi2s = blocks.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts
    dst = blocks.check_lfsr_32k_s();

    tb.connect (src,src_head,s2fsmi,enc,mod)
    tb.connect (mod,(add,0))
    tb.connect (noise,(add,1))
    tb.connect (add,metrics)
    tb.connect (metrics,va,fsmi2s,dst)

    tb.run()

    ntotal = dst.ntotal ()
    nright = dst.nright ()
    runlength = dst.runlength ()
    #print ntotal,nright,runlength

    return (ntotal,ntotal-nright)
Beispiel #18
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

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

        ##################################################
        # Blocks
        ##################################################
        self.digital_crc32_bb_0 = digital.crc32_bb(False, "packet_len")
        self.blocks_tag_debug_1 = blocks.tag_debug(gr.sizeof_char*1, "Pre-CRC", ""); self.blocks_tag_debug_1.set_display(True)
        self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char*1, "Post-CRC", ""); self.blocks_tag_debug_0.set_display(True)
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, 100, "packet_len")
        self.blocks_head_0 = blocks.head(gr.sizeof_char*1, 100*5)
        self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 255, 1000)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0), (self.blocks_head_0, 0))
        self.connect((self.blocks_head_0, 0), (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_crc32_bb_0, 0))
        self.connect((self.digital_crc32_bb_0, 0), (self.blocks_tag_debug_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tag_debug_1, 0))
Beispiel #19
0
def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation,Es,N0,IT,seed):
    tb = gr.top_block ()

    # TX
    src = blocks.lfsr_32k_source_s()
    src_head = blocks.head(gr.sizeof_short,Kb/16) # packet size in shorts
    s2fsmi = blocks.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the outer FSM input cardinality
    enc = trellis.sccc_encoder_ss(fo,0,fi,0,interleaver,K)
    mod = digital.chunks_to_symbols_sf(constellation,dimensionality)

    # CHANNEL
    add = blocks.add_ff()
    noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed)

    # RX
    dec = trellis.sccc_decoder_combined_fs(fo,0,-1,fi,0,-1,interleaver,K,IT,trellis.TRELLIS_MIN_SUM,dimensionality,constellation,digital.TRELLIS_EUCLIDEAN,1.0)
    fsmi2s = blocks.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts
    dst = blocks.check_lfsr_32k_s()

    #tb.connect (src,src_head,s2fsmi,enc_out,inter,enc_in,mod)
    tb.connect (src,src_head,s2fsmi,enc,mod)
    tb.connect (mod,(add,0))
    tb.connect (noise,(add,1))
    #tb.connect (add,head)
    #tb.connect (tail,fsmi2s,dst)
    tb.connect (add,dec,fsmi2s,dst)

    tb.run()

    #print enc_out.ST(), enc_in.ST()

    ntotal = dst.ntotal ()
    nright = dst.nright ()
    runlength = dst.runlength ()
    return (ntotal,ntotal-nright)
	def test_001_t (self):
		# test on positive frequencies
		# set up fg
		test_len = 1000
		samp_rate = 2000
		freq = 200
		ampl = 1
		packet_len = test_len
		threshold = -100
		samp_protect = 2
		
		src = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, freq, ampl)
		head = blocks.head(8,test_len)
		s2ts = blocks.stream_to_tagged_stream(8,1,packet_len,"packet_len")
		fft = radar.ts_fft_cc(packet_len)
		peak = radar.find_max_peak_c(samp_rate, threshold, samp_protect, (0,0), False)
		debug = blocks.message_debug()
		
		self.tb.connect(src,head,s2ts,fft,peak)
		self.tb.msg_connect(peak,"Msg out",debug,"store")
		#self.tb.msg_connect(peak,"Msg out",debug,"print")
		self.tb.start()
		sleep(0.5)
		self.tb.stop()
		self.tb.wait()
		
		# check frequency in os_cfar message with given one
		msg = debug.get_message(0)
		self.assertAlmostEqual(freq,pmt.f32vector_ref(pmt.nth(1,pmt.nth(1,msg)),0),8)
	def test_001_t (self):
		# set up fg
		test_len = 1000
		
		packet_len = 1024
		samp_rate = 32000
		frequency = (500, 500)
		amplitude = 1
		
		test = radar.signal_generator_cw_c(packet_len, samp_rate, frequency, amplitude)
		head = blocks.head(8,test_len)
		sink = blocks.vector_sink_c()
		
		self.tb.connect(test,head,sink)
		self.tb.run ()
		
		# create reference data
		ref_data = [0]*test_len
		phase = 0
		for i in range(test_len):
			ref_data[i] = amplitude*np.exp(1j*phase)
			phase = phase + 2*np.pi*frequency[0]/samp_rate
			#phase = np.modf(phase,2*np.pi)
		
		ref_data = [0]*test_len
		phase = 0
		for i in range(test_len):
			ref_data[i] = amplitude*np.exp(1j*phase)
			phase = phase+2*np.pi*frequency[0]/samp_rate
		
		# check data
		out_data = sink.data()
		
		self.assertEqual(len(out_data),test_len) # check out_data length
		self.assertComplexTuplesAlmostEqual(out_data,ref_data,2) # check out_data with ref_data
Beispiel #22
0
    def __init__(self, fs_in, fs_out, fc, N=10000):
        gr.top_block.__init__(self)

        rerate = float(fs_out) / float(fs_in)
        print "Resampling from %f to %f by %f " %(fs_in, fs_out, rerate)

        # Creating our own taps
        taps = filter.firdes.low_pass_2(32, 32, 0.25, 0.1, 80)

        self.src = analog.sig_source_c(fs_in, analog.GR_SIN_WAVE, fc, 1)
        #self.src = analog.noise_source_c(analog.GR_GAUSSIAN, 1)
        self.head = blocks.head(gr.sizeof_gr_complex, N)

        # A resampler with our taps
        self.resamp_0 = filter.pfb.arb_resampler_ccf(rerate, taps,
                                                     flt_size=32)

        # A resampler that just needs a resampling rate.
        # Filter is created for us and designed to cover
        # entire bandwidth of the input signal.
        # An optional atten=XX rate can be used here to
        # specify the out-of-band rejection (default=80).
        self.resamp_1 = filter.pfb.arb_resampler_ccf(rerate)

        self.snk_in = blocks.vector_sink_c()
        self.snk_0 = blocks.vector_sink_c()
        self.snk_1 = blocks.vector_sink_c()

        self.connect(self.src, self.head, self.snk_in)
        self.connect(self.head, self.resamp_0, self.snk_0)
        self.connect(self.head, self.resamp_1, self.snk_1)
Beispiel #23
0
    def __init__(self):
        gr.top_block.__init__(self, "USRP_TCP")

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="sc16",
        		otw_format="sc16",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_time_source("gpsdo", 0)
        self.uhd_usrp_source_0.set_samp_rate(4e6)
        self.uhd_usrp_source_0.set_center_freq(1575.42e6, 0)
        self.uhd_usrp_source_0.set_gain(30, 0)
        self.uhd_usrp_source_0.set_antenna("RX2", 0)
        (self.uhd_usrp_source_0).set_min_output_buffer(100)
        (self.uhd_usrp_source_0).set_max_output_buffer(200)
        self.blocks_head_0 = blocks.head(gr.sizeof_short*2, 1024)
        self.ASPIN_Async_TCP_Client_0 = ASPIN.Async_TCP_Client("192.168.10.10", 25565, 1472, 1000000)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_head_0, 0), (self.ASPIN_Async_TCP_Client_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_head_0, 0))    
Beispiel #24
0
 def setUp (self):
     self.tb = gr.top_block ()
     self.tp = drm.transm_params(1, 3, False, 0, False, 1, 0, 1, 1, 0, False, 24000, "station label", "text message")
     self.src = drm.generate_sdc_b(self.tp)
     self.head = blocks.head(self.tp.sdc().L(), 1)
     self.snk = blocks.vector_sink_b(self.tp.sdc().L())
     self.tb.connect(self.src, self.head, self.snk)
Beispiel #25
0
	def test_002_t (self):
		# set up fg
		test_len = 2**15
		samp_rate = 250000
		freq = -2000
		ampl = 1
		packet_len = test_len
		min_output_buffer = 2*packet_len
		compare_sample = 5
		protect_sample = 0
		rel_threshold = 0.78
		mult_threshold = 10
		
		src = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, freq, ampl)
		src.set_min_output_buffer(min_output_buffer)
		head = blocks.head(8,test_len)
		head.set_min_output_buffer(min_output_buffer)
		s2ts = blocks.stream_to_tagged_stream(8,1,packet_len,"packet_len")
		s2ts.set_min_output_buffer(min_output_buffer)
		fft = radar.ts_fft_cc(packet_len)
		fft.set_min_output_buffer(min_output_buffer)
		cfar = radar.os_cfar_c(samp_rate, compare_sample, protect_sample, rel_threshold, mult_threshold)
		debug = blocks.message_debug()
		
		self.tb.connect(src,head,s2ts,fft,cfar)
		self.tb.msg_connect(cfar,"Msg out",debug,"store")
		self.tb.msg_connect(cfar,"Msg out",debug,"print")
		self.tb.start()
		sleep(0.5)
		self.tb.stop()
		self.tb.wait()
		
		# check frequency in os_cfar message with given one
		msg = debug.get_message(0)
		self.assertAlmostEqual(freq/pmt.f32vector_ref(pmt.nth(1,pmt.nth(1,msg)),0),1,2)
Beispiel #26
0
    def test_001_t (self):

        # Setup parameters of the System
        fsm = fsm_args["awgn1o2_16"]
        os = numpy.array(fsm[4], dtype=int) 
        data = numpy.array([-5,-5,-5,-5,5,5,-5,5,5,-5])
        expected_data = numpy.array([0,0,0,0,1,1,0,1,1,0])
        print data

        data_src = blocks.vector_source_f(map(float, data))

        # Set up TX
        src_head = blocks.head(gr.sizeof_float*1, 10)
        
        shuffle = numpy.array([0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,], dtype=int)
        # Setup RX
        max_log_map_cel = celec.max_log_map_f(2, 4, 10, 0, -1, shuffle, os)
        conv = blocks.float_to_char()
        rx_sink = blocks.vector_sink_f(1)


        self.tb.connect(data_src, src_head, max_log_map_cel, rx_sink)

        # set up fg
        self.tb.run ()

        print rx_sink.data()
Beispiel #27
0
	def test_003_t (self):
		# test fft against gnuradio fft
		# set up fg
		test_len = 1024*2

		packet_len = test_len
		samp_rate = 2000
		frequency = (100,100)
		amplitude = 1

		src = radar.signal_generator_cw_c(packet_len,samp_rate,frequency,amplitude)
		head = blocks.head(8,test_len)
		tsfft = radar.ts_fft_cc(packet_len)
		snk1 = blocks.vector_sink_c()
		self.tb.connect(src,head,tsfft,snk1)

		s2v = blocks.stream_to_vector(8, packet_len)
		fft_inbuild = fft.fft_vcc(test_len,True,fft.window_rectangular(0))
		snk2 = blocks.vector_sink_c()
		v2s = blocks.vector_to_stream(8, packet_len);
		self.tb.connect(head,s2v,fft_inbuild,v2s,snk2)

		self.tb.run()

		# compaire ffts
		data_tsfft = snk1.data()
		data_fft_inbuild = snk2.data()

		self.assertComplexTuplesAlmostEqual(data_tsfft,data_fft_inbuild,2) # compare inbuild fft and fft from block
Beispiel #28
0
	def test_002_t (self):
		# set up fg
		# purpse is testing fft on high sample rates
		test_len = 2**19

		packet_len = 2**17
		min_output_buffer = packet_len*2
		samp_rate = 10000000
		frequency = 200000
		amplitude = 1

		src = radar.signal_generator_cw_c(packet_len,samp_rate,(frequency,frequency),amplitude)
		src.set_min_output_buffer(min_output_buffer)

		head = blocks.head(8,test_len)
		head.set_min_output_buffer(min_output_buffer)

		fft1 = radar.ts_fft_cc(packet_len)
		fft1.set_min_output_buffer(min_output_buffer)
		fft2 = radar.ts_fft_cc(packet_len)
		fft2.set_min_output_buffer(min_output_buffer)

		snk1 = blocks.vector_sink_c()
		snk2 = blocks.vector_sink_c()

		self.tb.connect(src,head,fft1,snk1)
		self.tb.connect(head,fft2,snk2)
		self.tb.run ()

		# check both ffts
		self.assertComplexTuplesAlmostEqual(snk1.data(),snk2.data(),2) # compare both ffts
Beispiel #29
0
    def test_003 (self):
        # Test that block stops when interacting with streaming interface
        port = str(random.Random().randint(0, 30000) + 10000)
        srcdata = (0x73, 0x75, 0x63, 0x68, 0x74, 0x65, 0x73, 0x74, 0x76, 0x65, 0x72, 0x79, 0x70, 0x61, 0x73, 0x73)
        tag_dict = {"offset": 0}
        tag_dict["key"] = pmt.intern("len")
        tag_dict["value"] = pmt.from_long(8)
        tag1 = gr.python_to_tag(tag_dict)
        tag_dict["offset"] = 8
        tag2 = gr.python_to_tag(tag_dict)
        tags = [tag1, tag2]

        src = blocks.vector_source_b(srcdata, False, 1, tags)
        ts_to_pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "len")
        pdu_send = blocks.socket_pdu("UDP_CLIENT", "localhost", "4141")
        #pdu_recv = blocks.socket_pdu("UDP_SERVER", "localhost", port)
        pdu_to_ts = blocks.pdu_to_tagged_stream(blocks.byte_t, "len")
        head = blocks.head(gr.sizeof_char, 10)
        sink = blocks.vector_sink_b(1)

        self.tb.connect(src, ts_to_pdu)
        self.tb.msg_connect(ts_to_pdu, "pdus", pdu_send, "pdus")
        # a UDP socket connects pdu_send to pdu_recv
        # TODO: test that the recv socket can be destroyed from downstream
        # that signals DONE. Also that we get the PDUs we sent
        #self.tb.msg_connect(pdu_recv, "pdus", pdu_to_ts, "pdus")
        #self.tb.connect(pdu_to_ts, head, sink)
        self.tb.run()
Beispiel #30
0
    def test_003_es_sink (self):
        print "test_003_es_sink"
        iv = [0,1,2,3,4,5,6,7,8,9];
        src = blocks.vector_source_f(iv, repeat=True);
        hd = blocks.head(gr.sizeof_float, 10000);
        snk = es.sink([gr.sizeof_float], 8);
        t = es.trigger_sample_timer(gr.sizeof_float, 10, 5, 10, 10);
        tb = gr.top_block();
        pduh = es.es_make_handler_pdu(es.es_handler_print.TYPE_F32);
        msgdb = blocks.message_debug()
        tb.connect(src, hd, t, snk);   
        tb.msg_connect( t, "which_stream", snk, "schedule_event" )
        tb.msg_connect( t, "sample_timer_event", pduh, "handle_event" )
        tb.msg_connect( pduh, "pdus_out", msgdb, "store" )
        tb.run();
 
        # expected output of each event in the periodic sequence   
        sv = numpy.array( iv[5:] + iv[:5], dtype=numpy.float32 );

        # verify each received message
        nm = msgdb.num_messages();
        print "nm = %d"%(nm);
        for i in range(0, nm):
            m = msgdb.get_message(i);
            mp = pmt.to_python(pmt.cdr(m));
            print mp;
            self.assertEqual( sv.all(), mp.all() );
Beispiel #31
0
 def test_sqr_f(self):
     tb = self.tb
     expected_result = (0, 0, 0, 0, 1, 1, 1, 1, 0)
     src1 = analog.sig_source_f(8, analog.GR_SQR_WAVE, 1.0, 1.0)
     op = blocks.head(gr.sizeof_float, 9)
     dst1 = blocks.vector_sink_f()
     tb.connect(src1, op)
     tb.connect(op, dst1)
     tb.run()
     dst_data = dst1.data()
     self.assertEqual(expected_result, dst_data)
Beispiel #32
0
    def __init__(self,
                 options,
                 rec_len=3,
                 sample_rate=2e6,
                 carrier_frequency=939e6,
                 ppm=0,
                 args=""):

        gr.top_block.__init__(self, "Wideband Scanner")

        self.rec_len = rec_len
        self.sample_rate = sample_rate
        self.carrier_frequency = carrier_frequency
        self.ppm = ppm

        # if no file name is given process data from rtl_sdr source
        print "Args=", args
        self.rtlsdr_source = osmosdr.source(args="numchan=" + str(1) + " " +
                                            args)

        self.rtlsdr_source.set_sample_rate(sample_rate)

        # capture half of GSM channel lower than channel center (-0.1MHz)
        # this is needed when even number of channels is captured in order to process full captured bandwidth

        self.rtlsdr_source.set_center_freq(carrier_frequency - 0.1e6, 0)

        # correction of central frequency
        # if the receiver has large frequency offset
        # the value of this variable should be set close to that offset in ppm
        self.rtlsdr_source.set_freq_corr(options.ppm, 0)

        self.rtlsdr_source.set_dc_offset_mode(2, 0)
        self.rtlsdr_source.set_iq_balance_mode(0, 0)
        self.rtlsdr_source.set_gain_mode(True, 0)
        self.rtlsdr_source.set_bandwidth(sample_rate, 0)

        self.head = blocks.head(gr.sizeof_gr_complex * 1,
                                int(rec_len * sample_rate))

        # shift again by -0.1MHz in order to align channel center in 0Hz
        self.blocks_rotator_cc = blocks.rotator_cc(-2 * pi * 0.1e6 /
                                                   options.samp_rate)

        self.wideband_receiver = wideband_receiver(OSR=4,
                                                   fc=carrier_frequency,
                                                   samp_rate=sample_rate)
        self.gsm_extract_system_info = grgsm.extract_system_info()

        self.connect((self.rtlsdr_source, 0), (self.head, 0))
        self.connect((self.head, 0), (self.blocks_rotator_cc, 0))
        self.connect((self.blocks_rotator_cc, 0), (self.wideband_receiver, 0))
        self.msg_connect(self.wideband_receiver, 'msgs',
                         self.gsm_extract_system_info, 'msgs')
Beispiel #33
0
 def test_tri_f(self):
     tb = self.tb
     expected_result = (1, .75, .5, .25, 0, .25, .5, .75, 1)
     src1 = analog.sig_source_f(8, analog.GR_TRI_WAVE, 1.0, 1.0)
     op = blocks.head(gr.sizeof_float, 9)
     dst1 = blocks.vector_sink_f()
     tb.connect(src1, op)
     tb.connect(op, dst1)
     tb.run()
     dst_data = dst1.data()
     self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 5)
    def __init__(self, dtype="discrete", limit=10000, randomize=False):
        if (dtype == "discrete"):
            gr.hier_block2.__init__(self, "source_alphabet",
                                    gr.io_signature(0, 0, 0),
                                    gr.io_signature(1, 1, gr.sizeof_char))
            self.src = blocks.file_source(
                gr.sizeof_char, "source_material/gutenberg_shakespeare.txt")
            self.convert = blocks.packed_to_unpacked_bb(1, gr.GR_LSB_FIRST)
            #self.convert = blocks.packed_to_unpacked_bb(8, gr.GR_LSB_FIRST);
            self.limit = blocks.head(gr.sizeof_char, limit)
            self.connect(self.src, self.convert)
            last = self.convert

            # whiten our sequence with a random block scrambler (optionally)
            if randomize:
                rand_len = 256
                rand_bits = np.random.randint(2, size=rand_len)
                self.randsrc = blocks.vector_source_b(rand_bits, True)
                self.xor = blocks.xor_bb()
                self.connect(self.randsrc, (self.xor, 1))
                self.connect(last, self.xor)
                last = self.xor

        else:  # "type_continuous"
            gr.hier_block2.__init__(self, "source_alphabet",
                                    gr.io_signature(0, 0, 0),
                                    gr.io_signature(1, 1, gr.sizeof_float))
            self.src = mediatools.audiosource_s(
                ["source_material/serial-s01-e01.mp3"])
            self.convert2 = blocks.interleaved_short_to_complex()
            self.convert3 = blocks.multiply_const_cc(1.0 / 65535)
            self.convert = blocks.complex_to_float()
            self.limit = blocks.head(gr.sizeof_float, limit)
            self.connect(self.src, self.convert2, self.convert3, self.convert)
            last = self.convert

        # connect head or not, and connect to output
        if limit == None:
            self.connect(last, self)
        else:
            self.connect(last, self.limit, self)
    def test_qpsk_3tap_lms_training(self):
        # set up fg
        gain = 0.01  # LMS gain
        num_taps = 16
        num_samp = 2000
        num_test = 500
        cons = digital.constellation_qpsk().base()
        rxmod = digital.generic_mod(cons, False, self.sps, True, self.eb,
                                    False, False)
        modulated_sync_word_pre = digital.modulate_vector_bc(
            rxmod.to_basic_block(), self.preamble + self.preamble, [1])
        modulated_sync_word = modulated_sync_word_pre[86:(
            512 + 86)]  # compensate for the RRC filter delay
        corr_max = numpy.abs(
            numpy.dot(modulated_sync_word, numpy.conj(modulated_sync_word)))
        corr_calc = self.corr_thresh / (corr_max * corr_max)
        preamble_symbols = self.map_symbols_to_constellation(
            self.unpack_values(self.preamble, 8, 2), cons)

        alg = digital.adaptive_algorithm_lms(cons, gain).base()
        evm = digital.meas_evm_cc(cons, digital.evm_measurement_t.EVM_PERCENT)
        leq = digital.linear_equalizer(num_taps, self.sps, alg, False,
                                       preamble_symbols, 'corr_est')
        correst = digital.corr_est_cc(modulated_sync_word, self.sps, 12,
                                      corr_calc, digital.THRESHOLD_ABSOLUTE)
        constmod = digital.generic_mod(constellation=cons,
                                       differential=False,
                                       samples_per_symbol=4,
                                       pre_diff_code=True,
                                       excess_bw=0.35,
                                       verbose=False,
                                       log=False)
        chan = channels.channel_model(noise_voltage=0.0,
                                      frequency_offset=0.0,
                                      epsilon=1.0,
                                      taps=(1.0 + 1.0j, 0.63 - .22j,
                                            -.1 + .07j),
                                      noise_seed=0,
                                      block_tags=False)
        vso = blocks.vector_source_b(self.preamble + self.data, True, 1, [])
        head = blocks.head(gr.sizeof_float * 1, num_samp)
        vsi = blocks.vector_sink_f()

        self.tb.connect(vso, constmod, chan, correst, leq, evm, head, vsi)
        self.tb.run()

        # look at the last 1000 samples, should converge quickly, below 5% EVM
        upper_bound = list(20.0 * numpy.ones((num_test, )))
        lower_bound = list(0.0 * numpy.zeros((num_test, )))
        output_data = vsi.data()
        output_data = output_data[-num_test:]
        self.assertLess(output_data, upper_bound)
        self.assertGreater(output_data, lower_bound)
Beispiel #36
0
    def run_fastnoise_source_i(self):
        ntype = analog.GR_GAUSSIAN
        ampl = 10
        seed = 0

        self.blocks = []
        self.tb = gr.top_block()
        self.blocks.append(analog.fastnoise_source_i(ntype, ampl, seed))
        self.blocks.append(blocks.head(gr.sizeof_int, self.N))
        self.blocks.append(blocks.null_sink(gr.sizeof_int))
        self.tb.connect(*self.blocks)
        self.tb.run()
Beispiel #37
0
    def run_noise_source_c(self):
        ntype = analog.GR_GAUSSIAN
        ampl = 10
        seed = 0

        self.blocks = []
        self.tb = gr.top_block()
        self.blocks.append(analog.noise_source_c(ntype, ampl, seed))
        self.blocks.append(blocks.head(gr.sizeof_gr_complex, self.N))
        self.blocks.append(blocks.null_sink(gr.sizeof_gr_complex))
        self.tb.connect(*self.blocks)
        self.tb.run()
Beispiel #38
0
    def run_sig_source_s(self):
        fs = 1
        ntype = analog.GR_SIN_WAVE
        freq = 10
        ampl = 1

        self.tb = gr.top_block()
        self.op = analog.sig_source_s(fs, ntype, freq, ampl)
        self.head = blocks.head(gr.sizeof_short, self.N)
        self.snk = blocks.null_sink(gr.sizeof_short)
        self.tb.connect(self.op, self.head, self.snk)
        self.tb.run()
    def test_packet_insert (self):


        # set up test limits

        # only collect 20 samples
        sample_lim = 20
        samp_rate = 1e6

        block_start_s = 100
        block_start_ps = 5* int(1e12/samp_rate)

        # set up input packet struct
        num_samps = 5
        packet_start_time = (100, 10* int(1e12/samp_rate))

        iq_pkt_dict = {
            "meta":{
                "timestamp_s":packet_start_time,
                "packet_len":num_samps
            },
            "data":list(np.array(range(num_samps), dtype=np.complex))
        }

        iq_pkt = dict_to_iq_packet(iq_pkt_dict)

        # set up our expected output
        expected = np.concatenate( (np.array( [0,]*5, dtype=np.complex ),
                                    np.array(range(num_samps), dtype=np.complex),
                                    np.array( [0,]*10, dtype=np.complex)) )

        # set up flowgraph blocks
        op = envsim.envsim_source(samp_rate)
        head = blocks.head(gr.sizeof_gr_complex*1, sample_lim)
        dst = blocks.vector_sink_c()

        # make connections
        self.tb.connect(op,head,dst)

        # set source block's time
        op.set_start_time(block_start_s, block_start_ps)

        # publish our pmt message before the flowgraph starts to
        # avoid a race condition

        op.to_basic_block()._post(pmt.intern("packets"), iq_pkt)

        self.tb.run ()
        # check data

        result = dst.data()

        self.assertListEqual(list(expected), list(result))
 def test_001_correlate(self):
     degree = 10
     length = 2**degree-1
     src = digital.glfsr_source_f(degree)
     head = blocks.head(gr.sizeof_float, length*length)
     f2c = blocks.float_to_complex()
     corr = digital.pn_correlator_cc(degree)
     dst = blocks.vector_sink_c()
     self.tb.connect(src, head, f2c, corr, dst)
     self.tb.run()
     data = dst.data()
     self.assertEqual(data[-1], (1.0+0j))
Beispiel #41
0
 def test_saw_c(self):
     tb = self.tb
     expected_result = (.5+.25j, .625+.375j, .75+.5j, .875+.625j,
                         0+.75j, .125+.875j, .25+1j, .375+.125j, .5+.25j)
     src1 = analog.sig_source_c(8, analog.GR_SAW_WAVE, 1.0, 1.0)
     op = blocks.head(gr.sizeof_gr_complex, 9)
     dst1 = blocks.vector_sink_c()
     tb.connect(src1, op)
     tb.connect(op, dst1)
     tb.run()
     dst_data = dst1.data()
     self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 5)
Beispiel #42
0
 def test_001_t(self):
     src = dab.fib_source_b_make(1, 1, 'Galaxy_News', 'Wasteland_Radio',
                                 'Country_Mix', 0x09, [0], [8])
     fib_unpacked_to_packed = blocks.unpacked_to_packed_bb(
         1, gr.GR_MSB_FIRST)
     s2v = blocks.stream_to_vector(gr.sizeof_char, 32)
     crc16 = dab.crc16_bb(32, 0x1021, 0xffff)
     fibsink = dab.fib_sink_vb()
     self.tb.connect(src, fib_unpacked_to_packed,
                     blocks.head(gr.sizeof_char, 300), s2v, crc16, fibsink)
     self.tb.run()
     pass
Beispiel #43
0
    def test_freq_msg(self):
        src = analog.sig_source_c(8, analog.GR_SIN_WAVE, 1.0, 1.0)
        op = blocks.head(gr.sizeof_gr_complex, 9)
        snk = blocks.vector_sink_c()
        self.tb.connect(src, op, snk)
        self.assertAlmostEqual(src.frequency(), 1.0)

        frequency = 3.0
        src._post(pmt.to_pmt('freq'), pmt.from_double(frequency))
        self.tb.run()

        self.assertAlmostEqual(src.frequency(), frequency)
    def test_001_t(self):
        # set up fg
        test_len = 1024

        packet_len = test_len
        samp_rate = 2000

        center_freq = 1e9
        velocity = 15

        src = radar.signal_generator_cw_c(packet_len, samp_rate, (0, 0), 1)
        head = blocks.head(8, test_len)
        sim = radar.static_target_simulator_cc(
            (10, 10), (velocity, velocity), (1e9, 1e9), (0, 0), (0, ),
            samp_rate, center_freq, 1, True, False)
        mult = blocks.multiply_cc()
        fft = radar.ts_fft_cc(packet_len)
        cfar = radar.os_cfar_c(samp_rate, 5, 0, 0.78, 10, True)
        est = radar.estimator_cw(center_freq)
        res = radar.print_results()
        debug = blocks.message_debug()

        self.tb.connect(src, head, (mult, 1))
        self.tb.connect(head, sim, (mult, 0))
        self.tb.connect(mult, fft, cfar)
        self.tb.msg_connect(cfar, 'Msg out', est, 'Msg in')
        self.tb.msg_connect(est, 'Msg out', res, 'Msg in')
        self.tb.msg_connect(est, 'Msg out', debug, 'store')
        #self.tb.msg_connect(est,'Msg out',debug,'print')

        self.tb.start()
        sleep(0.5)
        self.tb.stop()
        self.tb.wait()

        # check data
        msg = debug.get_message(0)
        self.assertEqual("rx_time",
                         pmt.symbol_to_string(pmt.nth(0, (pmt.nth(
                             0, msg)))))  # check rx_time message part (symbol)
        self.assertEqual(0,
                         pmt.to_uint64(
                             pmt.tuple_ref(pmt.nth(1, (pmt.nth(0, msg))),
                                           0)))  # check rx_time value
        self.assertEqual(
            0.0, pmt.to_double(pmt.tuple_ref(pmt.nth(1, (pmt.nth(0, msg))),
                                             1)))
        self.assertEqual(
            "velocity", pmt.symbol_to_string(pmt.nth(
                0, (pmt.nth(1, msg)))))  # check velocity message part (symbol)
        self.assertAlmostEqual(
            1, velocity / pmt.f32vector_ref(pmt.nth(1, (pmt.nth(1, msg))), 0),
            2)  # check velocity value
Beispiel #45
0
 def test_sine_f(self):
     tb = self.tb
     sqrt2 = math.sqrt(2) / 2
     expected_result = (0, sqrt2, 1, sqrt2, 0, -sqrt2, -1, -sqrt2, 0)
     src1 = analog.sig_source_f(8, analog.GR_SIN_WAVE, 1.0, 1.0)
     op = blocks.head(gr.sizeof_float, 9)
     dst1 = blocks.vector_sink_f()
     tb.connect(src1, op)
     tb.connect(op, dst1)
     tb.run()
     dst_data = dst1.data()
     self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 5)
Beispiel #46
0
    def __init__(self, c_freq, int_time, samp_rate, fftsize, username, config):
        gr.top_block.__init__(self, "Salsa Receiver")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate
        self.outfile = outfile = config.get(
            'USRP', 'tmpdir') + "/SALSA_" + username + ".tmp"
        self.int_time = int_time
        self.gain = gain = config.getfloat('USRP', 'usrp_gain')
        self.fftsize = fftsize
        self.c_freq = c_freq

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
            device_addr="addr=" + config.get('USRP', 'host'),
            stream_args=uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(c_freq, 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.fft_vxx_0 = fft.fft_vcc(fftsize, True,
                                     (window.blackmanharris(fftsize)), True, 1)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, fftsize)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, fftsize)
        self.blocks_head_0 = blocks.head(gr.sizeof_float * 1,
                                         int(int_time * samp_rate))
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float * 1,
                                                   outfile, False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_head_0, 0))
        self.connect((self.blocks_head_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
Beispiel #47
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1E6
        self.gain = gain = 0
        self.f0 = f0 = 3.625E9
        self.bandwidth = bandwidth = 5

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_1 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_1.set_samp_rate(samp_rate)
        self.uhd_usrp_source_1.set_center_freq(f0, 0)
        self.uhd_usrp_source_1.set_gain(gain, 0)
        self.uhd_usrp_source_1.set_antenna("TX/RX", 0)
        self.uhd_usrp_source_1.set_bandwidth(bandwidth, 0)
        self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_gr_complex * 1, 20)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex * 1, 1000)
        self.blocks_file_sink_1 = blocks.file_sink(
            gr.sizeof_float * 1,
            "/home/odroid/Documents/2ndRF/calibration/Power", False)
        self.blocks_file_sink_1.set_unbuffered(False)
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_conjugate_cc_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_head_0, 0), (self.blocks_conjugate_cc_0, 0))
        self.connect((self.blocks_head_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.blocks_file_sink_1, 0))
        self.connect((self.blocks_skiphead_0, 0), (self.blocks_head_0, 0))
        self.connect((self.uhd_usrp_source_1, 0), (self.blocks_skiphead_0, 0))
Beispiel #48
0
def run_flowgraph(filename):

    samp_rate = 32000

    head = blocks.head(gr.sizeof_float * 1, samp_rate)
    source = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0)
    sigmf_sink = sigmf.sink("rf32_le", filename)

    tb = gr.top_block()
    tb.connect(source, head)
    tb.connect(head, sigmf_sink)
    tb.run()
    tb.wait()
Beispiel #49
0
 def test_symbol_src ( self, arity ):
   vlen = 1
   N = int( 1e7 )
   
   demapper = ofdm.generic_demapper_vcb( vlen )
   const = demapper.get_constellation( arity )
   assert( len( const ) == 2**arity )
   
   symsrc = ofdm.symbol_random_src( const, vlen )
   # tx = transmitter_hier_bc(M=M,K=K,qam_size=qam_size,syms_per_frame=syms_per_frame,theta_sel=theta_sel,exclude_preamble=exclude_preamble,sel_preamble=None)
   acc = ofdm.accumulator_cc()
   skiphead = blocks.skiphead( gr.sizeof_gr_complex, N-1 )
   limit = blocks.head( gr.sizeof_gr_complex, 1 )
   dst = blocks.vector_sink_c()
   
   c2mag = blocks.complex_to_mag_squared()
   acc_c2m = ofdm.accumulator_ff()
   skiphead_c2m = blocks.skiphead( gr.sizeof_float, N-1 )
   limit_c2m = blocks.head( gr.sizeof_float, 1 )
   dst_c2m = blocks.vector_sink_f()
   
   tb = gr.top_block ( "test__block" )
   tb.connect( symsrc, acc, skiphead, limit, dst )
   tb.connect( symsrc, c2mag, acc_c2m, skiphead_c2m, limit_c2m, dst_c2m )
   tb.run()
   
   data = numpy.array( dst.data() )
   data_c2m = numpy.array( dst_c2m.data() )
   
   m = data / N
   av_pow = data_c2m / N
   
   assert( abs( m ) < 0.01 )
   assert( abs( 1.0 - av_pow ) < 0.5  )
   
   print "Uniform distributed random symbol source has"
   print "\tno offset for N=%d, relative error: %f" % (arity, abs( m ) )
   print "\tAverage signal power equal 1.0, relative error: %f\t\tOK" \
          % ( abs( 1.0 - av_pow ) )
Beispiel #50
0
    def setUp(self):
        self.tb = gr.top_block()
        self.src = blocks.vector_source_b((1, 2, 3, 4, 5, 6, 7, 8, 9), 1, 9)
        self.demux = drm.partitioning_vbvb(9, (2, 3, 4))
        self.head = blocks.head(9, 2)
        self.snk1 = blocks.vector_sink_b(2)
        self.snk2 = blocks.vector_sink_b(3)
        self.snk3 = blocks.vector_sink_b(4)

        self.tb.connect(self.src, self.head, self.demux)
        self.tb.connect((self.demux, 0), self.snk1)
        self.tb.connect((self.demux, 1), self.snk2)
        self.tb.connect((self.demux, 2), self.snk3)
Beispiel #51
0
 def test_jammer_sg_f (self):
     tb = self.tb
     sqrt2 = math.sqrt(2)/2
     exp_res = (1, sqrt2, 0, -sqrt2, -1, -sqrt2, 0, sqrt2, 1)
     src = jammer.jammer_sg_f(8,1,1,0) #1 Hz frequency cosine sampled @ 8 Hz
     op = blocks.head(gr.sizeof_float, 9) #Limits to 9 samples of the input
     dst = blocks.vector_sink_f() #sink for the signal
     tb.connect(src, op) #connect source to head
     tb.connect(op,dst) #connect head to sink
     self.tb.run () #run flowgraph
     # check data
     dst_data = dst.data()
     self.assertFloatTuplesAlmostEqual(exp_res, dst_data, 5)
Beispiel #52
0
    def test_002(self):
        # Confirm that we can instantiate and run an FM deemphasis block
        tb = self.tb

        src = analog.sig_source_f(48000, analog.GR_COS_WAVE, 5000.0, 1.0)
        op = analog.fm_deemph(fs=48000, tau=75e-6)
        head = blocks.head(gr.sizeof_float, 100)
        dst = blocks.vector_sink_f()

        tb.connect(src, op)
        tb.connect(op, head)
        tb.connect(head, dst)
        tb.run()
Beispiel #53
0
 def test_cosine_c(self):
     tb = self.tb
     sqrt2 = math.sqrt(2) / 2
     sqrt2j = 1j * math.sqrt(2) / 2
     expected_result = (1, sqrt2 + sqrt2j, 1j, -sqrt2 + sqrt2j, -1, -sqrt2 - sqrt2j, -1j, sqrt2 - sqrt2j, 1)
     src1 = analog.sig_source_c(8, analog.GR_COS_WAVE, 1.0, 1.0)
     op = blocks.head(gr.sizeof_gr_complex, 9)
     dst1 = blocks.vector_sink_c()
     tb.connect(src1, op)
     tb.connect(op, dst1)
     tb.run()
     dst_data = dst1.data()
     self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 5)
Beispiel #54
0
 def test_with_noise(self):
     # set up fg
     noise = analog.fastnoise_source_c(analog.GR_GAUSSIAN, 1, 0, 8192)
     head = blocks.head(gr.sizeof_gr_complex * 1, 2048)
     rcvr = flex_receiver(0, 50e3)
     msgsink = blocks.message_debug()
     self.tb.connect((noise, 0), (head, 0))
     self.tb.connect((head, 0), (rcvr, 0))
     self.tb.msg_connect((rcvr, 'pages'), (msgsink, 'store'))
     self.tb.run()
     # No data is expected to be output, this merely tests that a noise source won't crash any
     # of the pieces which are knit together with the flex_receiver heir block.
     self.assertEqual(0, msgsink.num_messages())
Beispiel #55
0
    def __init__(self):
        gr.top_block.__init__(self)

        parser = OptionParser(option_class=eng_option)
        (options, args) = parser.parse_args()
        if len(args) != 0:
            parser.print_help()
            raise SystemExit, 1

        src = blocks.lfsr_32k_source_s()
        head = blocks.head(gr.sizeof_short, 2048)
        self.dst = blocks.vector_sink_s()
        self.connect(src, head, self.dst)
    def test_003_t(self):
        """test_003_t: two set function after 1 second and 2 seconds"""

        tb = self.tb

        samp_rate = 4096  #under 4096 does not work so fast.
        items = samp_rate * 3  # 3 seconds of simulation

        debug = flaress.debug_func_probe(gr.sizeof_float * 1)

        def _probe_func_probe():
            time.sleep(1)
            try:
                debug.debug_nitems()
            except AttributeError:
                pass
            time.sleep(1)
            try:
                debug.debug_nitems()
            except AttributeError:
                pass

        _probe_func_thread = threading.Thread(target=_probe_func_probe)
        _probe_func_thread.daemon = True

        src = analog.sig_source_f(samp_rate, analog.GR_CONST_WAVE, 0, 0, 0)
        throttle = blocks.throttle(gr.sizeof_float * 1, samp_rate, True)
        head = blocks.head(gr.sizeof_float, int(items))

        # throttle.set_max_noutput_items (samp_rate)
        # throttle.set_min_noutput_items (samp_rate)

        tb.connect(src, throttle)
        tb.connect(throttle, head)
        tb.connect(head, debug)

        _probe_func_thread.start()
        tb.run()

        data = debug.data()

        self.assertEqual(len(data), 2)
        self.assertLessEqual(data[0], samp_rate * 2)
        self.assertGreaterEqual(data[0], samp_rate)
        self.assertLessEqual(data[1], samp_rate * 3)
        self.assertGreaterEqual(data[1], samp_rate * 2)

        print("-Set function received at the moment: %f s." %
              (data[0] * (1.0 / samp_rate)))
        print("-Set function received at the moment: %f s." %
              (data[1] * (1.0 / samp_rate)))
Beispiel #57
0
def test_sine(self, param):
    """this function run the defined test, for easier understanding"""

    tb = self.tb
    data_agc = namedtuple('data_agc', 'src out')

    src_sine = analog.sig_source_c(param.samp_rate, analog.GR_SIN_WAVE,
                                   param.freq_sine, 1)

    src_square = analog.sig_source_f(
        param.samp_rate, analog.GR_SQR_WAVE, param.freq_square,
        ((param.input_amplitude_max - param.input_amplitude_min) /
         math.sqrt(2)), (param.input_amplitude_min / math.sqrt(2)))
    src_noise = analog.noise_source_c(analog.GR_GAUSSIAN, param.noise, 0)

    adder = blocks.add_vcc(1)

    multiply_const = blocks.multiply_const_ff(-1)
    multiply_complex = blocks.multiply_cc()

    dst_agc = blocks.vector_sink_c()
    dst_source = blocks.vector_sink_c()

    float_to_complex = blocks.float_to_complex()

    head = blocks.head(gr.sizeof_gr_complex, int(param.N))

    agc = ecss.agc_cc(param.settling_time, param.reference, 1.0, 65536.0,
                      param.samp_rate)

    tb.connect(src_square, (float_to_complex, 0))
    tb.connect(src_square, multiply_const)
    tb.connect(multiply_const, (float_to_complex, 1))

    tb.connect(src_sine, (adder, 0))
    tb.connect(src_noise, (adder, 1))

    tb.connect(adder, (multiply_complex, 0))
    tb.connect(float_to_complex, (multiply_complex, 1))

    tb.connect(multiply_complex, head)
    tb.connect(head, agc)
    tb.connect(agc, dst_agc)

    tb.connect(head, dst_source)

    self.tb.run()

    data_agc.src = dst_source.data()
    data_agc.out = dst_agc.data()
    return data_agc
Beispiel #58
0
    def __init__(self, n_samples, n_offset_samples, n_prbs, linear_gain,
                 pad_interval, mcs, frequency_offset):
        super(GrLTETracesFlowgraph, self).__init__()
        self.subcarrier_spacing = 15000

        # params
        self.n_samples = n_samples
        self.n_prbs = n_prbs
        self.linear_gain = linear_gain
        self.mcs = mcs

        # derived params
        self.fft_size = GrLTETracesFlowgraph.prb_mapping[self.n_prbs]
        self.samp_rate = float(self.fft_size * self.subcarrier_spacing)
        n_prbs_str = "%02d" % (self.n_prbs, )
        mcs_str = "%02d" % (self.mcs)
        fname = '{}/lte_dump_prb_{}_mcs_{}.32fc'.format(
            frames_path, n_prbs_str, mcs_str)
        self.expected_bw = GrLTETracesFlowgraph.fftsize_mapping[self.fft_size]
        self.resamp_ratio = 20.0e6 / self.samp_rate
        self.n_samples_per_frame = int(10.0e-3 * self.samp_rate)
        self.n_offset_samples = int(
            lf.random_generator.load_value(n_offset_samples))
        randgen = lf.random_generator.load_generator(pad_interval)
        # scale by sampling rate
        new_params = tuple(
            [int(v / self.resamp_ratio) for v in randgen.params])
        randgen.params = new_params
        if isinstance(frequency_offset, tuple):
            assert frequency_offset[0] == 'uniform'
            self.frequency_offset = frequency_offset[1]
        else:  # it is just a value
            self.frequency_offset = [frequency_offset]

        # blocks
        self.file_reader = blocks.file_source(gr.sizeof_gr_complex, fname,
                                              True)
        self.tagger = blocks.stream_to_tagged_stream(gr.sizeof_gr_complex, 1,
                                                     self.n_samples_per_frame,
                                                     "packet_len")
        self.burst_shaper = specmonitor.random_burst_shaper_cc(
            randgen.dynrandom(), 0, self.frequency_offset, "packet_len")
        # self.resampler = filter.rational_resampler_base_ccc(interp,decim,taps)
        self.resampler = filter.fractional_resampler_cc(
            0, 1 / self.resamp_ratio)
        self.skiphead = blocks.skiphead(gr.sizeof_gr_complex,
                                        self.n_offset_samples)
        self.head = blocks.head(gr.sizeof_gr_complex, self.n_samples)
        self.dst = blocks.vector_sink_c()

        self.setup_flowgraph()
Beispiel #59
0
    def __init__(self):
        gr.top_block.__init__(self)

        default_nsamples = 10e6
        parser = ArgumentParser()
        parser.add_argument(
            "-p",
            "--npipelines",
            type=intx,
            default=1,
            metavar="NPIPES",
            help="the number of pipelines to create (default=%(default)s)")
        parser.add_argument(
            "-s",
            "--nstages",
            type=intx,
            default=1,
            metavar="NSTAGES",
            help="the number of stages in each pipeline (default=%(default)s)")
        parser.add_argument(
            "-N",
            "--nsamples",
            type=eng_float,
            default=default_nsamples,
            help=(
                "the number of samples to run through the graph (default=%s)" %
                (eng_notation.num_to_str(default_nsamples))))
        parser.add_argument("-m",
                            "--machine-readable",
                            action="store_true",
                            default=False,
                            help="enable machine readable output")

        args = parser.parse_args()

        self.npipes = args.npipelines
        self.nstages = args.nstages
        self.nsamples = args.nsamples
        self.machine_readable = args.machine_readable

        ntaps = 256

        # Something vaguely like floating point ops
        self.flop = 2 * ntaps * args.npipelines * args.nstages * args.nsamples

        src = blocks.null_source(gr.sizeof_float)
        head = blocks.head(gr.sizeof_float, int(args.nsamples))
        self.connect(src, head)

        for n in range(args.npipelines):
            self.connect(head, pipeline(args.nstages, ntaps))
    def __init__(self, snr_db=10, num_symbols=1024, taps=[]):
        gr.top_block.__init__(self, "CMA Watterson Experiment")

        ##################################################
        # Variables
        ##################################################
        self.snr_db = snr_db
        self.samp_rate = samp_rate = 1000000
        self.num_symbols = num_symbols
        self.taps = taps

        self.const = const = digital.constellation_8psk().base()

        ##################################################
        # Blocks
        ##################################################
        #self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_ccc(2, (firdes.low_pass_2(1, 1, .25, .1, 80)))
        #self.interp_fir_filter_xxx_0_0.declare_sample_delay(0)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(
            4, 1, .01, 2)
        self.digital_chunks_to_symbols_xx_1 = digital.chunks_to_symbols_bc(
            (const.points()), 1)
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=10**(-self.snr_db / 20.0) / numpy.sqrt(2),
            frequency_offset=0.0,
            epsilon=1.0,
            taps=self.taps,
            noise_seed=0,
            block_tags=False)
        self.blocks_vector_sink_x_0 = blocks.vector_sink_c(1)
        self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex * 1, num_symbols)
        self.analog_random_source_x_1 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, const.arity(), 1000)), True)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex * 1, 2)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_1, 0),
                     (self.digital_chunks_to_symbols_xx_1, 0))
        self.connect((self.blocks_head_0, 0), (self.blocks_vector_sink_x_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.digital_cma_equalizer_cc_0, 0))
        #self.connect((self.digital_chunks_to_symbols_xx_1, 0), (self.interp_fir_filter_xxx_0_0, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0),
                     (self.blocks_head_0, 0))
        #self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.channels_channel_model_0, 0))
        self.connect((self.blocks_repeat_0, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_1, 0),
                     (self.blocks_repeat_0, 0))