Beispiel #1
0
 def __init__(self, Np=32, P=128, L=2,
              filename=None, sample_type='complex', verbose=True):
     gr.top_block.__init__(self)
     if filename is None:
         src = analog.noise_source_c(analog.GR_GAUSSIAN, 1)
         if verbose:
             print "Using Gaussian noise source."
     else:
         if sample_type == 'complex':
             src = blocks.file_source(gr.sizeof_gr_complex, filename, True)
         else:
             fsrc = blocks.file_source(gr.sizeof_float, filename, True)
             src = blocks.float_to_complex()
             self.connect(fsrc, src)
         if verbose:
             print "Reading data from %s" % filename
     if verbose:
         print "FAM configuration:"
         print "N'   = %d" % Np
         print "P    = %d" % P
         print "L    = %d" % L
         #print "Δf   = %f" % asfd
     sink = blocks.null_sink(gr.sizeof_float * 2 * Np)
     self.cyclo_fam = specest.cyclo_fam(Np, P, L)
     self.connect(src, self.cyclo_fam, sink)
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 192e3

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_waterfallsink2_0_0 = waterfallsink2.waterfall_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	dynamic_range=100,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=512,
        	fft_rate=5,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        )
        self.Add(self.wxgui_waterfallsink2_0_0.win)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	dynamic_range=100,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=512,
        	fft_rate=5,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        )
        self.Add(self.wxgui_waterfallsink2_0.win)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_file_source_0_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/home/scorpii/CONSAT1/ground-config/GNURadio/kenwood_capture", True)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/home/scorpii/CONSAT1/ground-config/GNURadio/icom_capture", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.blocks_file_source_0_0, 0), (self.blocks_throttle_0_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_waterfallsink2_0, 0))    
        self.connect((self.blocks_throttle_0_0, 0), (self.wxgui_waterfallsink2_0_0, 0))    
Beispiel #3
0
 def test_001_t (self):
     src = blocks.file_source(gr.sizeof_gr_complex*1,"out.bin")
     thr = blocks.throttle(gr.sizeof_gr_complex*1, 100000)
     dst = liblte.pbch_ue()
     self.tb.connect(src, thr)
     self.tb.connect(thr, dst)
     self.tb.run()
Beispiel #4
0
    def __init__(self, options):
        gr.hier_block2.__init__(self, "ReadByteFile",
                                gr.io_signature(0, 0, 0),
                                gr.io_signature(1, 1, gr.sizeof_gr_complex))

        ##################################################
        # Blocks
        ##################################################
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, options.source, False)
        self.blocks_deinterleave_0 = blocks.deinterleave(gr.sizeof_char*1)
        self.blocks_uchar_to_float_1 = blocks.uchar_to_float()
        self.blocks_uchar_to_float_0 = blocks.uchar_to_float()
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((8e-3, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((8e-3, ))
        self.blocks_add_const_vxx_1 = blocks.add_const_vff((-127, ))
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-127, ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, options.rate, True)

        self.connect((self.blocks_file_source_0, 0), (self.blocks_deinterleave_0, 0))
        self.connect((self.blocks_deinterleave_0, 0), (self.blocks_uchar_to_float_0, 0))
        self.connect((self.blocks_deinterleave_0, 1), (self.blocks_uchar_to_float_1, 0))
        self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_uchar_to_float_1, 0), (self.blocks_add_const_vxx_1, 0))
        self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_add_const_vxx_1, 0), (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self, 0))
    def __init__(self, ifile, ofile, options):
        gr.top_block.__init__(self)

        SNR = 10.0 ** (options.snr / 10.0)
        time_offset = options.time_offset
        phase_offset = options.phase_offset * (math.pi / 180.0)

        # calculate noise voltage from SNR
        power_in_signal = abs(options.tx_amplitude) ** 2
        noise_power = power_in_signal / SNR
        noise_voltage = math.sqrt(noise_power)
        print "Noise voltage: ", noise_voltage

        frequency_offset = options.frequency_offset / options.fft_length

        self.src = blocks.file_source(gr.sizeof_gr_complex, ifile)
        # self.throttle = blocks.throttle(gr.sizeof_gr_complex, options.sample_rate)

        self.channel = filter.channel_model(
            noise_voltage, frequency_offset, time_offset, noise_seed=-random.randint(0, 100000)
        )
        self.phase = blocks.multiply_const_cc(complex(math.cos(phase_offset), math.sin(phase_offset)))
        self.snk = blocks.file_sink(gr.sizeof_gr_complex, ofile)

        self.connect(self.src, self.channel, self.phase, self.snk)
Beispiel #6
0
    def __init__(self, options):
        gr.top_block.__init__(self, "mhp")

        self.lfsr = lfsr.p25p2_lfsr(options.nac, options.sysid, options.wacn)
        xor_mask = ''
        for c in self.lfsr.xorsyms:
            xor_mask += chr(c)

        IN = blocks.file_source(gr.sizeof_char, options.input_file)

        slotid = options.tdma_slotid
        msgq = gr.msg_queue(2)
        do_msgq  = False

        wireshark_host = ''
        udp_port = 0
        verbosity = 100
        do_imbe = 1
        do_output = 1
        do_msgq = 0
        rx_q = gr.msg_queue(1)
        do_audio_output = 1
        phase2_tdma = 1
        
        FRAMER = op25_repeater.p25_frame_assembler(wireshark_host, udp_port, verbosity, do_imbe, do_output, do_msgq, rx_q, do_audio_output, phase2_tdma)
        FRAMER.set_xormask(xor_mask)

        S2F = blocks.short_to_float()
        M = blocks.multiply_const_ff(1.0 / 32767.0)

        SINK = audio.sink(8000, 'plughw:0,0')
        
        self.connect(IN, FRAMER, S2F, M, SINK)
Beispiel #7
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.tx_signal_dat = tx_signal_dat = "/home/uone/gnuradio/gnuradioworkspace/BackChannel/dataSet/waveform_all_zeros.dat"
        self.tx_ip_rx = tx_ip_rx = "192.168.10.2"
        self.samp_rate = samp_rate = 20e6

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		args='peak=0.003906',
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0.set_clock_source('internal', 0)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(1e9, 0)
        self.uhd_usrp_sink_0.set_gain(30, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.uhd_usrp_sink_0.set_bandwidth(1e5, 0)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, tx_signal_dat, True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0), (self.uhd_usrp_sink_0, 0))
Beispiel #8
0
    def __init__(self, demod_class, rx_callback, options):
        gr.top_block.__init__(self)
        self.rxpath = receive_path(demod_class, rx_callback, options)
        self.audio_tx = audio_tx(options.audio_output)

        if(options.rx_freq is not None):
            self.source = uhd_receiver(options.args, options.bitrate,
                                       options.samples_per_symbol,
                                       options.rx_freq, options.rx_gain,
                                       options.antenna, options.verbose)
            options.samples_per_symbol = self.source._sps

            audio_rate = self.audio_tx.sample_rate
            usrp_rate = self.source.get_sample_rate()
            rrate = audio_rate / usrp_rate
            self.resampler = filter.pfb.arb_resampler_ccf(rrate)
            
            self.connect(self.source, self.resampler, self.rxpath)

        elif(options.from_file is not None):
            self.thr = blocks.throttle(gr.sizeof_gr_complex, options.bitrate)
            self.source = blocks.file_source(gr.sizeof_gr_complex, options.from_file)
            self.connect(self.source, self.thr, self.rxpath)

        else:
            self.thr = blocks.throttle(gr.sizeof_gr_complex, 1e6)
            self.source = blocks.null_source(gr.sizeof_gr_complex)
            self.connect(self.source, self.thr, self.rxpath)

	self.connect(self.audio_tx)        
Beispiel #9
0
    def __init__(self, options):
        gr.top_block.__init__(self)

        if options.input_file is not None:
            src = blocks.file_source(gr.sizeof_gr_complex, options.filename, repeat=True)
        else:
            src = blocks.vector_source_c((.5,) * int(1e6) * 2, repeat=True)
        # Setup USRP
        self.u = uhd.usrp_sink(options.args, uhd.stream_args('fc32'), "packet_len")
        if(options.spec):
            self.u.set_subdev_spec(options.spec, 0)
        if(options.antenna):
            self.u.set_antenna(options.antenna, 0)
        self.u.set_samp_rate(options.rate)
        # Gain is set in the hopper block
        if options.gain is None:
            g = self.u.get_gain_range()
            options.gain = float(g.start()+g.stop())/2.0
        print "-- Setting gain to {} dB".format(options.gain)
        r = self.u.set_center_freq(options.freq)
        if not r:
            print '[ERROR] Failed to set base frequency.'
            raise SystemExit, 1
        hopper_block = FrequencyHopperSrc(
                options.num_bursts, options.num_channels,
                options.freq_delta, options.freq, options.dsp,
                options.samp_per_burst, 1.0, options.hop_time / 1000.,
                options.post_tuning,
                options.gain,
                options.verbose,
        )
        self.connect(src, hopper_block, self.u)
Beispiel #10
0
 def __init__(self, args):
     gr.top_block.__init__(self)
     if args.input_file is not None:
         src = blocks.file_source(gr.sizeof_gr_complex, args.filename, repeat=True)
     else:
         src = blocks.vector_source_c((.5,) * int(1e6) * 2, repeat=True)
     # Setup USRP
     self.usrp = uhd.usrp_sink(
         args.args,
         uhd.stream_args('fc32'),
         "packet_len"
     )
     if args.spec:
         self.usrp.set_subdev_spec(args.spec, 0)
     if args.antenna:
         self.usrp.set_antenna(args.antenna, 0)
     self.usrp.set_samp_rate(args.rate)
     # Gain is set in the hopper block
     if not args.gain:
         gain_range = self.usrp.get_gain_range()
         args.gain = float(gain_range.start() + gain_range.stop()) / 2.0
     print("-- Setting gain to {} dB".format(args.gain))
     if not self.usrp.set_center_freq(args.freq):
         print('[ERROR] Failed to set base frequency.')
         exit(1)
     hopper_block = FrequencyHopperSrc(
         args.num_bursts, args.num_channels,
         args.freq_delta, args.freq, args.dsp,
         args.samp_per_burst, 1.0, args.hop_time / 1000.,
         args.post_tuning,
         args.gain,
         args.verbose,
     )
     self.connect(src, hopper_block, self.usrp)
Beispiel #11
0
    def __init__(self):
        gr.top_block.__init__(self)

        ##################################################
        # Variables
        ##################################################
        self.sigma = sigma = 0.4
        self.max_iterations = max_iterations = 50
        self.alist_file = alist_file = "/home/manu/repos/ldpc/gr-ldpc/python/alist-files/96.3.963"
        self.samp_rate = samp_rate = 32000
        self.encoder = _encoder = ldpc_encoder_bf(alist_file)
        self.decoder = _decoder = ldpc_decoder_fb(alist_file, sigma, max_iterations)

        ##################################################
        # Blocks
        ##################################################
        self.generic_encoder_0 = fec.encoder(_encoder, gr.sizeof_char, gr.sizeof_float)
        self.generic_decoder_0 = fec.decoder(_decoder, gr.sizeof_float, gr.sizeof_char)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/manu/Downloads/in.flac", False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/manu/Downloads/out.flac")
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.analog_noise_source_x_0 = analog.noise_source_f(analog.GR_GAUSSIAN, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_file_source_0, 0), (self.generic_encoder_0, 0))
        self.connect((self.generic_encoder_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.generic_decoder_0, 0))
        self.connect((self.generic_decoder_0, 0), (self.blocks_file_sink_0, 0))
Beispiel #12
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 8
        self.fm_sensitivity = fm_sensitivity = 1.0
        self.center_freq = center_freq = 2400e6

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0.set_samp_rate(sps*1000000)
        self.uhd_usrp_sink_0.set_center_freq(center_freq, 0)
        self.uhd_usrp_sink_0.set_gain(70, 0)
        self.uhd_usrp_sink_0.set_bandwidth(1e6, 0)
        self.digital_gfsk_mod_0 = digital.gfsk_mod(
        	samples_per_symbol=sps,
        	sensitivity=fm_sensitivity,
        	bt=0.32,
        	verbose=False,
        	log=False,
        )
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.8, ))
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "sync3", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0), (self.digital_gfsk_mod_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0))    
        self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
Beispiel #13
0
    def __init__(self, options):
        gr.top_block.__init__(self)

        if(options.rx_freq is not None):
            if options.rx_ant == 1:
                self.source = uhd_receiver(options.args,
                                       options.bandwidth, options.rx_freq,
                                       options.lo_offset, options.rx_gain,
                                       options.spec, options.antenna,
                                       options.clock_source, options.time_source,options.verbose)
            else:
                self.source = uhd_mimo_receiver(options.args,
                                       options.bandwidth, options.rx_freq,
                                       options.lo_offset, options.rx_gain,
                                       options.spec, options.antenna,
                                       options.clock_source, options.time_source, options.verbose)
        elif(options.from_file is not None):
            self.source = blocks.file_source(gr.sizeof_gr_complex, options.from_file)
        else:
            self.source = blocks.null_source(gr.sizeof_gr_complex)
        if (options.rx_ant == 1):
            self._setup_rx_path(options)
            self._setup_rpc_manager()
            self.dst    = (self.rxpath,0)
            self.connect((self.source,0), self.dst)
        else:
            self._setup_rx_path(options)
            self._setup_rpc_manager()
            self.dst    = (self.rxpath,0)
            self.dst2     = (self.rxpath,1)
            self.connect((self.source,0), self.dst)
            self.connect((self.source,1), self.dst2)
Beispiel #14
0
    def __init__(self, samp_rate, src_filename, dest_filename):
        gr.top_block.__init__(self, "SAME Encoder")

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

        ##################################################
        # Blocks
        ##################################################
        self.msg_source = blocks.file_source(1, src_filename)
        self.packed_to_unpacked = blocks.packed_to_unpacked_bb(1, gr.GR_LSB_FIRST)
        self.repeat = blocks.repeat(4, 96)
        self.chunks_to_symbols = digital.chunks_to_symbols_bf(([-1, 1]), 1)
        self.freq_mod = analog.frequency_modulator_fc(3.14159265 / 96)
        # TODO: Make amplitude adjustable
        self.center_freq_src = analog.sig_source_c(50000, analog.GR_COS_WAVE, 1822.916666, 0.1, 0)
        self.freq_mult = blocks.multiply_vcc(1)
        self.rational_resampler = filter.rational_resampler_ccc(
            interpolation=samp_rate / 100, decimation=500, taps=None, fractional_bw=None
        )
        self.complex_to_float = blocks.complex_to_float()
        self.float_to_short = blocks.float_to_short(1, 32767)
        self.sink = blocks.file_sink(2, dest_filename)
        self.sink.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.msg_source, 0), (self.packed_to_unpacked, 0), (self.chunks_to_symbols, 0))
        self.connect((self.chunks_to_symbols, 0), (self.repeat, 0), (self.freq_mod, 0), (self.freq_mult, 0))
        self.connect((self.center_freq_src, 0), (self.freq_mult, 1))
        self.connect((self.freq_mult, 0), (self.rational_resampler, 0), (self.complex_to_float, 0))
        self.connect((self.complex_to_float, 0), (self.float_to_short, 0), (self.sink, 0))
Beispiel #15
0
    def __init__(self, options):
        gr.top_block.__init__(self, "GPS-SDR-SIM")

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink = uhd.usrp_sink(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink.set_samp_rate(options.sample_rate)
        self.uhd_usrp_sink.set_center_freq(options.frequency, 0)
        self.uhd_usrp_sink.set_gain(options.gain, 0)

        # a file source for the file generated by the gps-sdr-sim
        self.blocks_file_source = blocks.file_source(gr.sizeof_char*1, options.filename, True)

        # convert from signed bytes to short
        self.blocks_char_to_short = blocks.char_to_short(1)

        # convert from interleaved short to complex values
        self.blocks_interleaved_short_to_complex = blocks.interleaved_short_to_complex(False, False)

        # establish the connections
        self.connect((self.blocks_file_source, 0), (self.blocks_char_to_short, 0))
        self.connect((self.blocks_char_to_short, 0), (self.blocks_interleaved_short_to_complex, 0))
        self.connect((self.blocks_interleaved_short_to_complex, 0), (self.uhd_usrp_sink, 0))
Beispiel #16
0
    def __init__(self):
        gr.top_block.__init__(self, "Transmitter")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 250e3

        ##################################################
        # Blocks
        ##################################################
        self.olin_usrp11 = uhd.usrp_sink(
        	device_addr="",
        	stream_args=uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.olin_usrp11.set_samp_rate(samp_rate)
        self.olin_usrp11.set_center_freq(2.4855e9, 0)
        self.olin_usrp11.set_gain(20, 0)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/home/vpreston/Documents/WirelessComms/ofdm_olinpwc/transmitter.dat", False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0), (self.olin_usrp11, 0))
    def __init__(self, options):
        gr.top_block.__init__(self,in_sig  = [numpy.complex],
				   out_sig = [numpy.complex])

        if options.input_file is not None:
            src = blocks.file_source(gr.sizeof_gr_complex, options.filename, repeat=True)
        else:
            src = in_sig  
	#blocks.vector_source_c((.5,) * int(1e6) * 2, repeat=True)
        # Setup USRP
        #self.u = uhd.usrp_sink(options.args, uhd.stream_args(underflow_policy="next_burst",cpu_format="fc32",channels=range(1),),"packet_len")
        #if(options.spec):
        #   self.u.set_subdev_spec(options.spec, 0)
        #if(options.antenna):
        #    self.u.set_antenna(options.antenna, 0)
        #self.u.set_samp_rate(options.rate)
        # Gain is set in the hopper block
        #if options.gain is None:
        #    g = self.u.get_gain_range()
        #    options.gain = float(g.start()+g.stop())/2.0
        #print "-- Setting gain to {} dB".format(options.gain)
        #r = self.u.set_center_freq(options.freq)
        #if not r:
        #    print '[ERROR] Failed to set base frequency.'
        #    raise SystemExit, 1
        hopper_block = hopper(
                options.num_bursts, options.num_channels,
                options.freq_delta, options.freq, options.dsp,
                options.samp_per_burst, 1.0, options.hop_time,
                options.post_tuning,
                options.gain,
                options.verbose,
        )
        self.connect(src, hopper_block,out_sig)
Beispiel #18
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Vv034 Dtg016")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 8000000

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=429000000,
        	y_per_div=20,
        	y_divs=10,
        	ref_level=10,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        	size=(600,600),
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.dvbt2_pilotgenerator_cc_0 = dvbt2.pilotgenerator_cc(dvbt2.CARRIERS_NORMAL, dvbt2.FFTSIZE_4K, dvbt2.PILOT_PP5, dvbt2.GI_1_16, 500, dvbt2.PAPR_OFF, dvbt2.VERSION_111, dvbt2.PREAMBLE_T2_SISO, dvbt2.MISO_TX1, dvbt2.EQUALIZATION_OFF, dvbt2.BANDWIDTH_1_7_MHZ, 4096)
        self.dvbt2_p1insertion_cc_0 = dvbt2.p1insertion_cc(dvbt2.CARRIERS_NORMAL, dvbt2.FFTSIZE_4K, dvbt2.GI_1_16, 500, dvbt2.PREAMBLE_T2_SISO, dvbt2.SHOWLEVELS_OFF, 3.3)
        self.dvbt2_modulator_bc_0 = dvbt2.modulator_bc(dvbt2.FECFRAME_SHORT, dvbt2.MOD_QPSK, dvbt2.ROTATION_ON)
        self.dvbt2_ldpc_bb_0 = dvbt2.ldpc_bb(dvbt2.FECFRAME_SHORT, dvbt2.C4_5)
        self.dvbt2_interleaver_bb_0 = dvbt2.interleaver_bb(dvbt2.FECFRAME_SHORT, dvbt2.C4_5, dvbt2.MOD_QPSK)
        self.dvbt2_freqinterleaver_cc_0 = dvbt2.freqinterleaver_cc(dvbt2.CARRIERS_NORMAL, dvbt2.FFTSIZE_4K, dvbt2.PILOT_PP5, dvbt2.GI_1_16, 500, dvbt2.PAPR_OFF, dvbt2.VERSION_111, dvbt2.PREAMBLE_T2_SISO, )
        self.dvbt2_framemapper_cc_0 = dvbt2.framemapper_cc(dvbt2.FECFRAME_SHORT, dvbt2.C4_5, dvbt2.MOD_QPSK, dvbt2.ROTATION_ON, 204, 0, dvbt2.CARRIERS_NORMAL, dvbt2.FFTSIZE_4K, dvbt2.GI_1_16, dvbt2.L1_MOD_QPSK, dvbt2.PILOT_PP5, 2, 500, dvbt2.PAPR_OFF, dvbt2.VERSION_111, dvbt2.PREAMBLE_T2_SISO, dvbt2.INPUTMODE_NORMAL, dvbt2.RESERVED_OFF, dvbt2.L1_SCRAMBLED_OFF, dvbt2.INBAND_OFF)
        self.dvbt2_cellinterleaver_cc_0 = dvbt2.cellinterleaver_cc(dvbt2.FECFRAME_SHORT, dvbt2.MOD_QPSK, 204, 0)
        self.dvbt2_bch_bb_0 = dvbt2.bch_bb(dvbt2.FECFRAME_SHORT, dvbt2.C4_5)
        self.dvbt2_bbscrambler_bb_0 = dvbt2.bbscrambler_bb(dvbt2.FECFRAME_SHORT, dvbt2.C4_5)
        self.dvbt2_bbheader_bb_0 = dvbt2.bbheader_bb(dvbt2.FECFRAME_SHORT, dvbt2.C4_5, dvbt2.INPUTMODE_HIEFF, dvbt2.INBAND_OFF, 168, 4000000)
        self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(4096, 4096+4096/16, 0, "")
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/re/xfer/vv034.ts", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0), (self.dvbt2_bbheader_bb_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.dvbt2_p1insertion_cc_0, 0))    
        self.connect((self.dvbt2_bbheader_bb_0, 0), (self.dvbt2_bbscrambler_bb_0, 0))    
        self.connect((self.dvbt2_bbscrambler_bb_0, 0), (self.dvbt2_bch_bb_0, 0))    
        self.connect((self.dvbt2_bch_bb_0, 0), (self.dvbt2_ldpc_bb_0, 0))    
        self.connect((self.dvbt2_cellinterleaver_cc_0, 0), (self.dvbt2_framemapper_cc_0, 0))    
        self.connect((self.dvbt2_framemapper_cc_0, 0), (self.dvbt2_freqinterleaver_cc_0, 0))    
        self.connect((self.dvbt2_freqinterleaver_cc_0, 0), (self.dvbt2_pilotgenerator_cc_0, 0))    
        self.connect((self.dvbt2_interleaver_bb_0, 0), (self.dvbt2_modulator_bc_0, 0))    
        self.connect((self.dvbt2_ldpc_bb_0, 0), (self.dvbt2_interleaver_bb_0, 0))    
        self.connect((self.dvbt2_modulator_bc_0, 0), (self.dvbt2_cellinterleaver_cc_0, 0))    
        self.connect((self.dvbt2_p1insertion_cc_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.dvbt2_pilotgenerator_cc_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0))    
Beispiel #19
0
    def __init__(self):
        gr.top_block.__init__(self)
        parser = OptionParser(option_class=eng_option)

        parser.add_option("-c", "--calibration", type="eng_float", default=0, help="freq offset")
        parser.add_option("-g", "--gain", type="eng_float", default=1)
        parser.add_option("-i", "--input-file", type="string", default="in.dat", help="specify the input file")
        parser.add_option("-o", "--output-file", type="string", default="out.dat", help="specify the output file")
        parser.add_option("-r", "--new-sample-rate", type="int", default=96000, help="output sample rate")
        parser.add_option("-s", "--sample-rate", type="int", default=48000, help="input sample rate")
        (options, args) = parser.parse_args()
 
        sample_rate = options.sample_rate
        new_sample_rate = options.new_sample_rate

        IN = blocks.file_source(gr.sizeof_gr_complex, options.input_file)
        OUT = blocks.file_sink(gr.sizeof_gr_complex, options.output_file)

        LO = analog.sig_source_c(sample_rate, analog.GR_COS_WAVE, options.calibration, 1.0, 0)
        MIXER = blocks.multiply_cc()

        AMP = blocks.multiply_const_cc(options.gain)

        nphases = 32
        frac_bw = 0.05
        p1 = frac_bw
        p2 = frac_bw
        rs_taps = filter.firdes.low_pass(nphases, nphases, p1, p2)
        RESAMP = filter.pfb_arb_resampler_ccf(float(new_sample_rate) / float(sample_rate), (rs_taps), nphases, )

        self.connect(IN, (MIXER, 0))
        self.connect(LO, (MIXER, 1))

        self.connect(MIXER, AMP, RESAMP, OUT)
Beispiel #20
0
    def __init__(self, filename, lo_freq, audio_rate, if_rate):

        gr.hier_block2.__init__(self, "pipeline",
                                gr.io_signature(0, 0, 0),
                                gr.io_signature(1, 1, gr.sizeof_gr_complex))

        try:
            src = blocks.file_source (gr.sizeof_float, filename, True)
        except RuntimeError:
            sys.stderr.write(("\nError: Could not open file '%s'\n\n" % \
                                  filename))
            sys.exit(1)

        print audio_rate, if_rate
        fmtx = analog.nbfm_tx(audio_rate, if_rate, max_dev=5e3,
	                      tau=75e-6, fh=0.925*if_rate/2.0)

        # Local oscillator
        lo = analog.sig_source_c(if_rate,            # sample rate
                                 analog.GR_SIN_WAVE, # waveform type
                                 lo_freq,            # frequency
                                 1.0,                # amplitude
                                 0)                  # DC Offset
        mixer = blocks.multiply_cc()

        self.connect(src, fmtx, (mixer, 0))
        self.connect(lo, (mixer, 1))
        self.connect(mixer, self)
    def device_definition(options):
        """
        Definition of the devices used in the program.
        @param options
        """

        tb = OpERAFlow(name='US')

        the_source = blocks.file_source(gr.sizeof_gr_complex, "./%d_%d_%d_%d_noise.bin" % (options.fft_length, options.cp_length, options.ebn0, options.it), False)
        radio = RadioDevice(name="radio")

        det = Correlator()
        middle = gr.hier_block2(
                name='hier',
                input_signature  = gr.io_signature(1, 1, gr.sizeof_gr_complex),
                output_signature = gr.io_signature(1, 1, gr.sizeof_float * 1024),
        )
        middle.connect(middle, blocks.stream_to_vector(gr.sizeof_gr_complex, 1024), blocks.complex_to_mag(1024), middle)
        ed = EnergySSArch(1024, 1, EnergyDecision(th = options.threshold))

        radio.add_arch(source = the_source, arch = middle, sink =(det,0), uhd_device=the_source, name='estimator')
        radio.add_arch(source = the_source, arch = ed,     sink =(det,1), uhd_device=the_source, name = "ed")
        tb.add_radio(radio, "radio")

        return tb, radio, det
Beispiel #22
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 20e6

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=580.5 * 10e6,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex * 1, "/home/furonics/GNURadio/test", False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0), (self.wxgui_fftsink2_0, 0))
Beispiel #23
0
 def _setup_head(self):
     """ Sets up the input of the flow graph, i.e. determine which kind of file source
     is necessary. """
     if self.filename[-4:].lower() == '.wav':
         if self.options.verbose:
             print 'Reading data from a WAV file.'
         src = blocks.wavfile_source(self.filename, True)
         f2c = blocks.float_to_complex()
         self.connect((src, 0), (f2c, 0))
         if src.channels() == 2:
             self.connect((src, 1), (f2c, 1))
         self.connect(f2c, self.head)
     else:
         if self.options.verbose:
             print 'Reading data from a raw data file.'
         src = blocks.file_source(self.options.sample_size, self.filename, True)
         if self.options.sample_size == gr.sizeof_float:
             f2c = blocks.float_to_complex()
             self.connect(src, f2c, self.head)
             if self.options.verbose:
                 print '  Input data is considered real.'
         else:
             self.connect(src, self.head)
             if self.options.verbose:
                 print '  Input data is considered complex.'
Beispiel #24
0
    def __init__(self, filename=None, capture=None, verbose=False, freq_error=-0.0021875):
        gr.top_block.__init__(self) 
        self.verbose = verbose
        self.rx_chips_min = 16
        self.chip_error_threshold = 10

        if None != filename:
            self.source = blocks.file_source(gr.sizeof_gr_complex, filename)
        else:
            self.source = osmosdr.source()
            #print self.source.get_gain_range().to_pp_string()
            self.source.set_sample_rate(1.6e6)
            self.source.set_center_freq(868.95e6, 0)
            self.source.set_freq_corr(0, 0)
            self.source.set_gain_mode(0, 0)
            # -1.0 1.5 4.0 6.5 9.0 11.5 14.0 16.5 19.0 21.5 24.0 29.0 34.0 42.0
            self.source.set_gain(14, 0)
            self.source.set_if_gain(42, 0)

        if None != capture:
            self.sink = blocks.file_sink(gr.sizeof_gr_complex, capture)
        else:
            self.msgq = gr.msg_queue(4)
            self.sink = wmbus_phy1(msgq=self.msgq, verbose=verbose, freq_error=freq_error);
            self._watcher = _queue_watcher_thread(self.msgq, self.callback)
        
        self.connect(self.source, self.sink)
Beispiel #25
0
    def __init__(self, demodulator, rx_callback, options):
        gr.top_block.__init__(self)

        if(options.rx_freq is not None):
            # Work-around to get the modulation's bits_per_symbol
            args = demodulator.extract_kwargs_from_options(options)
            symbol_rate = options.bitrate / demodulator(**args).bits_per_symbol()

            self.source = uhd_receiver(options.args, symbol_rate,
                                       options.samples_per_symbol, options.rx_freq, 
                                       options.lo_offset, options.rx_gain,
                                       options.spec, options.antenna,
                                       options.clock_source, options.verbose)
            options.samples_per_symbol = self.source._sps

        elif(options.from_file is not None):
            sys.stderr.write(("Reading samples from '%s'.\n\n" % (options.from_file)))
            self.source = blocks.file_source(gr.sizeof_gr_complex, options.from_file)
        else:
            sys.stderr.write("No source defined, pulling samples from null source.\n\n")
            self.source = blocks.null_source(gr.sizeof_gr_complex)

        # Set up receive path
        # do this after for any adjustments to the options that may
        # occur in the sinks (specifically the UHD sink)
        self.rxpath = receive_path(demodulator, rx_callback, options) 

        self.connect(self.source, self.rxpath)
Beispiel #26
0
  def __init__(self):
    gr.top_block.__init__(self, "Top Block")

    options = get_options()
    self.input_file=options.input_file
    self.gr_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, self.input_file, True)

    symbol_rate = 18000
    sps = 2 # output rate will be 36,000
    out_sample_rate = symbol_rate * sps

    options.low_pass = options.low_pass / 2.0

    self.demod = cqpsk.cqpsk_demod(
        samples_per_symbol = sps,
        excess_bw=0.35,
        costas_alpha=0.03,
        gain_mu=0.05,
        mu=0.05,
        omega_relative_limit=0.05,
        log=options.log,
        verbose=options.verbose)

    self.output = gr.file_sink(gr.sizeof_float, options.output_file)

    self.connect(self.gr_file_source_0, self.demod, self.output)
    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 #28
0
	def __init__(self, options, filename):
		gr.top_block.__init__(self)

		inf_str = None
		symbol_rate = 152.34e3
		sample_rate = 1e6
		
		#if len(options) != 0:
		#	inf_str = args[0]

		squelch = analog.pwr_squelch_cc(float(options.squelch), 0.1, 0, True)
		demod = analog.quadrature_demod_cf(1.0)
		cr = digital.clock_recovery_mm_ff(sample_rate/symbol_rate, 0.00765625, 0, 0.175, 0.005)
		slicer = digital.binary_slicer_fb()
		corr = digital.correlate_access_code_bb(AC, 3)
		sink = sniffer()

		if False:
			print "Reading from: " + inf_str
			src = blocks.file_source(gr.sizeof_gr_complex, inf_str, False)
		
		else:
			freqs = {
				'AA':917.0e6, 'AB':913.0e6, 'AC':914.0e6, 'AD':915.0e6,
				'BA':916.0e6, 'BB':919.0e6, 'BC':920.0e6, 'BD':921.0e6,
				'CA':922.0e6, 'CB':923.0e6, 'CC':907.0e6, 'CD':908.0e6,
				'DA':905.5e6, 'DB':909.0e6, 'DC':911.0e6, 'DD':910.0e6}

			frequency = freqs[options.channel]
			print "Channel: " + options.channel + " (" + str(frequency/1e6) + "MHz)"

			# Create a UHD device source
			src = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32', "sc16", args=""))

			# Set the subdevice spec
			if(options.spec):
				src.set_subdev_spec(options.spec, 0)

			# Set the antenna
			if(options.antenna):
				src.set_antenna(options.antenna, 0)

			# Set receiver sample rate
			src.set_samp_rate(options.samp_rate)

			# Set receive daughterboard gain
			if options.gain is None:
				g = src.get_gain_range()
				options.gain = float(g.start()+g.stop())/2
				print "Using mid-point gain of", options.gain, "(", g.start(), "-", g.stop(), ")"
				src.set_gain(options.gain)

			# Set frequency (tune request takes lo_offset)
			treq = uhd.tune_request(frequency)
			tr = src.set_center_freq(treq)
			if tr == None:
				sys.stderr.write('Failed to set center frequency\n')
				raise SystemExit, 1

		self.connect(src, squelch, demod, cr, slicer, corr, sink)
Beispiel #29
0
def graph (args):

    print os.getpid()

    nargs = len (args)
    if nargs == 1:
	infile = args[0]
    else:
	sys.stderr.write('usage: interp.py input_file\n')
	sys.exit (1)

    tb = gr.top_block()

    srcf = blocks.file_source(gr.sizeof_short,infile)
    s2ss = blocks.stream_to_streams(gr.sizeof_short,2)
    s2f1 = blocks.short_to_float()
    s2f2 = blocks.short_to_float()
    src0 = blocks.float_to_complex()


    lp_coeffs = filter.firdes.low_pass(3, 19.2e6, 3.2e6, .5e6,
                                       filter.firdes.WIN_HAMMING)
    lp = filter.interp_fir_filter_ccf(3, lp_coeffs)

    file = blocks.file_sink(gr.sizeof_gr_complex,"/tmp/atsc_pipe_1")

    tb.connect( srcf, s2ss )
    tb.connect( (s2ss, 0), s2f1, (src0,0) )
    tb.connect( (s2ss, 1), s2f2, (src0,1) )
    tb.connect( src0, lp, file)

    tb.start()
    raw_input ('Head End: Press Enter to stop')
    tb.stop()
Beispiel #30
0
	def __init__(self):
		gr.top_block.__init__(self)
		
		usage = "%prog: [options] samples_file"
		parser = OptionParser(option_class=eng_option, usage=usage)
		(options, args) = parser.parse_args ()
		if len(args)<1:
			# print "using gaussian noise as source"
			# self.sigsrc = gr.noise_source_c(gr.GR_GAUSSIAN,10e6)
			print "using repeating random vector as source"
			self.sigsrc = blocks.vector_source_c([10e6*(random.random() + 1j*random.random()) for i in range(0,100000)],True)
			self.src = blocks.throttle( gr.sizeof_gr_complex,2048000)
			self.connect(self.sigsrc, self.src)
		else:
			filename = args[0]
			print "using samples from file " + filename
			self.src = blocks.file_source(gr.sizeof_gr_complex, filename, False)

		dp = parameters.dab_parameters(1)
		rp = parameters.receiver_parameters(1)
		self.sync_dab = ofdm_sync_dab(dp, rp, False)
		self.nop0 = blocks.nop(gr.sizeof_gr_complex)
		self.nop1 = blocks.nop(gr.sizeof_char)
		self.connect(self.src, self.sync_dab, self.nop0)
		self.connect((self.sync_dab,1), self.nop1)
Beispiel #31
0
    def __init__(self, param_samp_rate, param_freq, param_gain, address, address2):
        grc_wxgui.top_block_gui.__init__(self, title="UHD FFT")

        ##################################################
        # Parameters
        ##################################################
	param_freq = 5.792e9
	self.if_freq = 960e6
	self.square_freq = 4e6
	self.num_steps = 32
	self.lo_start_freq = 5.312e9
        self.param_samp_rate = param_samp_rate
        self.param_freq = param_freq
        self.param_gain = param_gain
        self.address = address
	self.address2 = address2

	self.offset_freq = 10e3


        ##################################################
        # Variables
        ##################################################
        self.chan0_lo_locked = chan0_lo_locked = uhd.sensor_value("", False, "")
        self.samp_rate = samp_rate = param_samp_rate
        self.lo_locked_probe = lo_locked_probe = chan0_lo_locked.to_bool()
        self.gain = gain = param_gain
        self.freq = freq = param_freq
        self.ant = ant = "J1"
	self.test = options.test
	self.tofile = options.tofile

        ##################################################
        # Blocks
        ##################################################
	if self.test == False:
	        self.source = uhd.usrp_source(
	        	device_addr=address,
	        	stream_args=uhd.stream_args(
	        		cpu_format="fc32",
	        		channels=range(2),
	        	),
	        )

		#Channel 0
		g = self.source.get_gain_range(0)
		print "rx gain range is (%f,%f)" % (g.start(),g.stop())
	        self.source.set_subdev_spec("A:0 B:0")
	        self.source.set_center_freq(self.if_freq, 0)
	        self.source.set_gain(g.stop(), 0)
	        self.source.set_bandwidth(64e6, 0)

		#Channel 1
		g = self.source.get_gain_range(1)
	        self.source.set_center_freq(self.if_freq, 1) #Mixer @ 4992 MHz
	        self.source.set_gain(g.stop(), 1)
	        self.source.set_bandwidth(64e6, 1)

	        self.source.set_samp_rate(samp_rate)

	        self.source2 = uhd.usrp_source(
	        	device_addr=address2,
	        	stream_args=uhd.stream_args(
	        		cpu_format="fc32",
	        		channels=range(2),
	        	),
	        )

		#Channel 0
		g = self.source2.get_gain_range(0)
		print "rx gain range is (%f,%f)" % (g.start(),g.stop())
	        self.source2.set_subdev_spec("A:0 B:0")
	        self.source2.set_center_freq(self.if_freq, 0)
	        self.source2.set_gain(g.stop(), 0)
	        self.source2.set_bandwidth(64e6, 0)

		#Channel 1
		g = self.source2.get_gain_range(1)
	        self.source2.set_center_freq(self.if_freq, 1) #Mixer @ 4992 MHz
	        self.source2.set_gain(g.stop(), 1)
	        self.source2.set_bandwidth(64e6, 1)

	        self.source2.set_samp_rate(samp_rate)


	else:
		self.source_pre = blocks.file_source(gr.sizeof_gr_complex, "test.dat", True)
		self.source = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate)
		self.connect(self.source_pre, self.source)
		self.source_freqs_pre = blocks.file_source(gr.sizeof_gr_complex, "test_freqs.dat", True)
		self.source_freqs = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate)
		self.connect(self.source_freqs_pre, self.source_freqs)


        ##################################################
        # Connections
        ##################################################

	#Actual demo code
	#self.stitcher = fast_square.freq_stitcher("cal.dat",14*4)

	if self.test == True:
		self.connect(self.source_freqs, self.stitcher)
	else:
		if self.tofile == True:
			self.logfile0 = blocks.file_sink(gr.sizeof_gr_complex, "usrp_chan0.dat")
			self.connect((self.source, 0), self.logfile0)
			self.logfile1 = blocks.file_sink(gr.sizeof_gr_complex, "usrp_chan1.dat")
			self.connect((self.source, 1), self.logfile1)
			self.logfile2 = blocks.file_sink(gr.sizeof_gr_complex, "usrp_chan2.dat")
			self.connect((self.source2, 0), self.logfile2)
			self.logfile3 = blocks.file_sink(gr.sizeof_gr_complex, "usrp_chan3.dat")
			self.connect((self.source2, 1), self.logfile3)
Beispiel #32
0
    def __init__(self):
        gr.top_block.__init__(self, "Dvbs2 Tx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Dvbs2 Tx")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "dvbs2_tx")

        if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
        else:
            self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.symbol_rate = symbol_rate = 5000000
        self.tx_gain = tx_gain = 0
        self.taps = taps = 100
        self.samp_rate = samp_rate = symbol_rate * 2
        self.rolloff = rolloff = 0.2
        self.qtgui_variable = qtgui_variable = '"labul'
        self.pilots = pilots = 0
        self.noise_type = noise_type = "Gaussian"
        self.noise = noise = 0.1
        self.code_rate_qpsk = code_rate_qpsk = "9/10"
        self.code_rate_8psk = code_rate_8psk = "9/10"
        self.code_rate_32apsk = code_rate_32apsk = "9/10"
        self.code_rate_16apsk = code_rate_16apsk = "9/10"
        self.center_freq = center_freq = 1280e6
        self.browse_button = browse_button = 0
        self.FEC_Frame_size = FEC_Frame_size = 'Normal'

        ##################################################
        # Blocks
        ##################################################
        self._tx_gain_range = Range(0, 89, 1, 0, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, 'TX Gain (dB)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._tx_gain_win, 1, 0, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rolloff_options = (0.2, 0.25, 0.35, )
        self._rolloff_labels = (str(self._rolloff_options[0]), str(self._rolloff_options[1]), str(self._rolloff_options[2]), )
        self._rolloff_tool_bar = Qt.QToolBar(self)
        self._rolloff_tool_bar.addWidget(Qt.QLabel('Rolloff'+": "))
        self._rolloff_combo_box = Qt.QComboBox()
        self._rolloff_tool_bar.addWidget(self._rolloff_combo_box)
        for label in self._rolloff_labels: self._rolloff_combo_box.addItem(label)
        self._rolloff_callback = lambda i: Qt.QMetaObject.invokeMethod(self._rolloff_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._rolloff_options.index(i)))
        self._rolloff_callback(self.rolloff)
        self._rolloff_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_rolloff(self._rolloff_options[i]))
        self.top_grid_layout.addWidget(self._rolloff_tool_bar, 0, 1, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.constellation_tab = Qt.QTabWidget()
        self.constellation_tab_widget_0 = Qt.QWidget()
        self.constellation_tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.constellation_tab_widget_0)
        self.constellation_tab_grid_layout_0 = Qt.QGridLayout()
        self.constellation_tab_layout_0.addLayout(self.constellation_tab_grid_layout_0)
        self.constellation_tab.addTab(self.constellation_tab_widget_0, 'QPSK')
        self.constellation_tab_widget_1 = Qt.QWidget()
        self.constellation_tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.constellation_tab_widget_1)
        self.constellation_tab_grid_layout_1 = Qt.QGridLayout()
        self.constellation_tab_layout_1.addLayout(self.constellation_tab_grid_layout_1)
        self.constellation_tab.addTab(self.constellation_tab_widget_1, '8PSK')
        self.constellation_tab_widget_2 = Qt.QWidget()
        self.constellation_tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.constellation_tab_widget_2)
        self.constellation_tab_grid_layout_2 = Qt.QGridLayout()
        self.constellation_tab_layout_2.addLayout(self.constellation_tab_grid_layout_2)
        self.constellation_tab.addTab(self.constellation_tab_widget_2, '16APSK')
        self.constellation_tab_widget_3 = Qt.QWidget()
        self.constellation_tab_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.constellation_tab_widget_3)
        self.constellation_tab_grid_layout_3 = Qt.QGridLayout()
        self.constellation_tab_layout_3.addLayout(self.constellation_tab_grid_layout_3)
        self.constellation_tab.addTab(self.constellation_tab_widget_3, '32APSK')
        self.top_grid_layout.addWidget(self.constellation_tab, 2, 0, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.uhd_usrp_sink = uhd.usrp_sink(
        	",".join(('', '')),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink.set_samp_rate(samp_rate)
        self.uhd_usrp_sink.set_center_freq(center_freq, 0)
        self.uhd_usrp_sink.set_gain(tx_gain, 0)
        self._qtgui_variable_tool_bar = Qt.QToolBar(self)

        if None:
          self._qtgui_variable_formatter = None
        else:
          self._qtgui_variable_formatter = lambda x: str(x)

        self._qtgui_variable_tool_bar.addWidget(Qt.QLabel('label'+": "))
        self._qtgui_variable_label = Qt.QLabel(str(self._qtgui_variable_formatter(self.qtgui_variable)))
        self._qtgui_variable_tool_bar.addWidget(self._qtgui_variable_label)
        self.top_grid_layout.addWidget(self._qtgui_variable_tool_bar, 3, 0, 1, 1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	center_freq, #fc
        	samp_rate, #bw
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink.set_update_time(0.10)
        self.qtgui_freq_sink.set_y_axis(-140, 10)
        self.qtgui_freq_sink.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink.enable_autoscale(False)
        self.qtgui_freq_sink.enable_grid(True)
        self.qtgui_freq_sink.set_fft_average(0.2)
        self.qtgui_freq_sink.enable_axis_labels(True)
        self.qtgui_freq_sink.enable_control_panel(False)

        if not True:
          self.qtgui_freq_sink.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink.set_plot_pos_half(not True)

        labels = ['DVB-S2', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink.set_line_label(i, labels[i])
            self.qtgui_freq_sink.set_line_width(i, widths[i])
            self.qtgui_freq_sink.set_line_color(i, colors[i])
            self.qtgui_freq_sink.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_win = sip.wrapinstance(self.qtgui_freq_sink.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_win, 4, 0, 1, 1)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._pilots_options = (1, 0, )
        self._pilots_labels = ("On", "Off", )
        self._pilots_group_box = Qt.QGroupBox('Pilots')
        self._pilots_box = Qt.QVBoxLayout()
        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)
            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)
        self._pilots_button_group = variable_chooser_button_group()
        self._pilots_group_box.setLayout(self._pilots_box)
        for i, label in enumerate(self._pilots_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._pilots_box.addWidget(radio_button)
        	self._pilots_button_group.addButton(radio_button, i)
        self._pilots_callback = lambda i: Qt.QMetaObject.invokeMethod(self._pilots_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._pilots_options.index(i)))
        self._pilots_callback(self.pilots)
        self._pilots_button_group.buttonClicked[int].connect(
        	lambda i: self.set_pilots(self._pilots_options[i]))
        self.top_grid_layout.addWidget(self._pilots_group_box, 3, 1, 1, 1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._noise_type_options = ("Uniform", "Gaussian", "Laplacian", "Impulse", )
        self._noise_type_labels = (str(self._noise_type_options[0]), str(self._noise_type_options[1]), str(self._noise_type_options[2]), str(self._noise_type_options[3]), )
        self._noise_type_tool_bar = Qt.QToolBar(self)
        self._noise_type_tool_bar.addWidget(Qt.QLabel('Noise Type'+": "))
        self._noise_type_combo_box = Qt.QComboBox()
        self._noise_type_tool_bar.addWidget(self._noise_type_combo_box)
        for label in self._noise_type_labels: self._noise_type_combo_box.addItem(label)
        self._noise_type_callback = lambda i: Qt.QMetaObject.invokeMethod(self._noise_type_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._noise_type_options.index(i)))
        self._noise_type_callback(self.noise_type)
        self._noise_type_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_noise_type(self._noise_type_options[i]))
        self.top_grid_layout.addWidget(self._noise_type_tool_bar, 1, 1, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.noise_source = analog.noise_source_c(analog.GR_GAUSSIAN, 0, 0)
        self._noise_range = Range(0, 1, 0.01, 0.1, 200)
        self._noise_win = RangeWidget(self._noise_range, self.set_noise, 'Noise', "counter", float)
        self.top_grid_layout.addWidget(self._noise_win, 2, 1, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.file_source = blocks.file_source(gr.sizeof_char*1, '/home/anisan/videos/The_Maker/900.ts', True)
        self.file_source.set_begin_tag(pmt.PMT_NIL)
        self.fft_filter = filter.fft_filter_ccc(1, (firdes.root_raised_cosine(1.0, samp_rate, samp_rate/2, rolloff, taps)), 1)
        self.fft_filter.declare_sample_delay(0)
        self.dvbs2_physical = dvbs2.physical_cc(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.MOD_16APSK, dvbs2.PILOTS_OFF, 0)
        self.dvbs2_modulator = dvbs2.modulator_bc(dvbs2.FECFRAME_NORMAL,
        dvbs2.C9_10, dvbs2.MOD_16APSK)
        self.dvbs2_ldpc = dvbs2.ldpc_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.MOD_OTHER)
        self.dvbs2_interleaver = dvbs2.interleaver_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.MOD_16APSK)
        self.dvbs2_bbscrambler = dvbs2.bbscrambler_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10)
        self.dvbs2_bbheader = dvbs2.bbheader_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.RO_0_20)
        self.dvb_bch = dtv.dvb_bch_bb(dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10)
        self._code_rate_qpsk_options = ["1/4", "1/3", "2/5", "1/2", "3/5", "2/3", "3/4", "4/5", "5/6", "8/9", "9/10"]
        self._code_rate_qpsk_labels = map(str, self._code_rate_qpsk_options)
        self._code_rate_qpsk_group_box = Qt.QGroupBox('Code Rate')
        self._code_rate_qpsk_box = Qt.QHBoxLayout()
        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)
            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)
        self._code_rate_qpsk_button_group = variable_chooser_button_group()
        self._code_rate_qpsk_group_box.setLayout(self._code_rate_qpsk_box)
        for i, label in enumerate(self._code_rate_qpsk_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._code_rate_qpsk_box.addWidget(radio_button)
        	self._code_rate_qpsk_button_group.addButton(radio_button, i)
        self._code_rate_qpsk_callback = lambda i: Qt.QMetaObject.invokeMethod(self._code_rate_qpsk_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._code_rate_qpsk_options.index(i)))
        self._code_rate_qpsk_callback(self.code_rate_qpsk)
        self._code_rate_qpsk_button_group.buttonClicked[int].connect(
        	lambda i: self.set_code_rate_qpsk(self._code_rate_qpsk_options[i]))
        self.constellation_tab_layout_0.addWidget(self._code_rate_qpsk_group_box)
        self._code_rate_8psk_options = ["3/5", "2/3", "3/4", "4/5", "5/6", "8/9", "9/10"]
        self._code_rate_8psk_labels = map(str, self._code_rate_8psk_options)
        self._code_rate_8psk_group_box = Qt.QGroupBox('Code Rate')
        self._code_rate_8psk_box = Qt.QHBoxLayout()
        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)
            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)
        self._code_rate_8psk_button_group = variable_chooser_button_group()
        self._code_rate_8psk_group_box.setLayout(self._code_rate_8psk_box)
        for i, label in enumerate(self._code_rate_8psk_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._code_rate_8psk_box.addWidget(radio_button)
        	self._code_rate_8psk_button_group.addButton(radio_button, i)
        self._code_rate_8psk_callback = lambda i: Qt.QMetaObject.invokeMethod(self._code_rate_8psk_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._code_rate_8psk_options.index(i)))
        self._code_rate_8psk_callback(self.code_rate_8psk)
        self._code_rate_8psk_button_group.buttonClicked[int].connect(
        	lambda i: self.set_code_rate_8psk(self._code_rate_8psk_options[i]))
        self.constellation_tab_layout_1.addWidget(self._code_rate_8psk_group_box)
        self._code_rate_32apsk_options = ["3/4", "4/5", "5/6", "8/9", "9/10"]
        self._code_rate_32apsk_labels = map(str, self._code_rate_32apsk_options)
        self._code_rate_32apsk_group_box = Qt.QGroupBox('Code Rate')
        self._code_rate_32apsk_box = Qt.QHBoxLayout()
        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)
            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)
        self._code_rate_32apsk_button_group = variable_chooser_button_group()
        self._code_rate_32apsk_group_box.setLayout(self._code_rate_32apsk_box)
        for i, label in enumerate(self._code_rate_32apsk_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._code_rate_32apsk_box.addWidget(radio_button)
        	self._code_rate_32apsk_button_group.addButton(radio_button, i)
        self._code_rate_32apsk_callback = lambda i: Qt.QMetaObject.invokeMethod(self._code_rate_32apsk_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._code_rate_32apsk_options.index(i)))
        self._code_rate_32apsk_callback(self.code_rate_32apsk)
        self._code_rate_32apsk_button_group.buttonClicked[int].connect(
        	lambda i: self.set_code_rate_32apsk(self._code_rate_32apsk_options[i]))
        self.constellation_tab_layout_3.addWidget(self._code_rate_32apsk_group_box)
        self._code_rate_16apsk_options = [ "2/3", "3/4", "4/5", "5/6", "8/9", "9/10"]
        self._code_rate_16apsk_labels = map(str, self._code_rate_16apsk_options)
        self._code_rate_16apsk_group_box = Qt.QGroupBox('Code Rate')
        self._code_rate_16apsk_box = Qt.QHBoxLayout()
        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)
            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)
        self._code_rate_16apsk_button_group = variable_chooser_button_group()
        self._code_rate_16apsk_group_box.setLayout(self._code_rate_16apsk_box)
        for i, label in enumerate(self._code_rate_16apsk_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._code_rate_16apsk_box.addWidget(radio_button)
        	self._code_rate_16apsk_button_group.addButton(radio_button, i)
        self._code_rate_16apsk_callback = lambda i: Qt.QMetaObject.invokeMethod(self._code_rate_16apsk_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._code_rate_16apsk_options.index(i)))
        self._code_rate_16apsk_callback(self.code_rate_16apsk)
        self._code_rate_16apsk_button_group.buttonClicked[int].connect(
        	lambda i: self.set_code_rate_16apsk(self._code_rate_16apsk_options[i]))
        self.constellation_tab_grid_layout_2.addWidget(self._code_rate_16apsk_group_box)
        _browse_button_push_button = Qt.QPushButton('Browse')
        self._browse_button_choices = {'Pressed': 1, 'Released': 0}
        _browse_button_push_button.pressed.connect(lambda: self.set_browse_button(self._browse_button_choices['Pressed']))
        _browse_button_push_button.released.connect(lambda: self.set_browse_button(self._browse_button_choices['Released']))
        self.top_grid_layout.addWidget(_browse_button_push_button, 0, 0, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.add_bloc = blocks.add_vcc(1)
        self._FEC_Frame_size_options = ('Normal', 'Short', )
        self._FEC_Frame_size_labels = (str(self._FEC_Frame_size_options[0]), str(self._FEC_Frame_size_options[1]), )
        self._FEC_Frame_size_group_box = Qt.QGroupBox('FEC Frame Size')
        self._FEC_Frame_size_box = Qt.QVBoxLayout()
        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)
            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)
        self._FEC_Frame_size_button_group = variable_chooser_button_group()
        self._FEC_Frame_size_group_box.setLayout(self._FEC_Frame_size_box)
        for i, label in enumerate(self._FEC_Frame_size_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._FEC_Frame_size_box.addWidget(radio_button)
        	self._FEC_Frame_size_button_group.addButton(radio_button, i)
        self._FEC_Frame_size_callback = lambda i: Qt.QMetaObject.invokeMethod(self._FEC_Frame_size_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._FEC_Frame_size_options.index(i)))
        self._FEC_Frame_size_callback(self.FEC_Frame_size)
        self._FEC_Frame_size_button_group.buttonClicked[int].connect(
        	lambda i: self.set_FEC_Frame_size(self._FEC_Frame_size_options[i]))
        self.top_grid_layout.addWidget(self._FEC_Frame_size_group_box, 4, 1, 1, 1)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.add_bloc, 0), (self.qtgui_freq_sink, 0))
        self.connect((self.dvb_bch, 0), (self.dvbs2_ldpc, 0))
        self.connect((self.dvbs2_bbheader, 0), (self.dvbs2_bbscrambler, 0))
        self.connect((self.dvbs2_bbscrambler, 0), (self.dvb_bch, 0))
        self.connect((self.dvbs2_interleaver, 0), (self.dvbs2_modulator, 0))
        self.connect((self.dvbs2_ldpc, 0), (self.dvbs2_interleaver, 0))
        self.connect((self.dvbs2_modulator, 0), (self.dvbs2_physical, 0))
        self.connect((self.dvbs2_physical, 0), (self.fft_filter, 0))
        self.connect((self.fft_filter, 0), (self.add_bloc, 0))
        self.connect((self.file_source, 0), (self.dvbs2_bbheader, 0))
        self.connect((self.noise_source, 0), (self.add_bloc, 1))
Beispiel #33
0
    def __init__(self):
        gr.top_block.__init__(self, "PSK Receiver")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("PSK Receiver")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "psk_rx")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(
                    self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.preamble_and_padding = preamble_and_padding = np.array(
            [255, 195, 204, 192], dtype=np.uint8)
        self.payload_size = payload_size = 28
        self.frame_size = frame_size = len(preamble_and_padding) + payload_size
        self.modulation = modulation = sksdr.QPSK
        self.frame_size_bits = frame_size_bits = frame_size * 8
        self.upsampling = upsampling = 4
        self.frame_size_symbols = frame_size_symbols = frame_size_bits // modulation.bits_per_symbol
        self.frame_size_samples_before_downsampling = frame_size_samples_before_downsampling = frame_size_symbols * upsampling
        self.downsampling = downsampling = 2
        self.samp_rate = samp_rate = 1.024e6
        self.rx_filter_sps = rx_filter_sps = int(upsampling / downsampling)
        self.rrc_coeffs = rrc_coeffs = sksdr.rrc(upsampling, 0.5, 10)
        self.msg_size = msg_size = 11 + 4
        self.mod_preamble = mod_preamble = np.array([
            -0.7071067811865477 - 0.7071067811865475j, -0.7071067811865477 -
            0.7071067811865475j, -0.7071067811865477 - 0.7071067811865475j,
            -0.7071067811865477 - 0.7071067811865475j, -0.7071067811865477 -
            0.7071067811865475j, 0.7071067811865476 + 0.7071067811865475j,
            0.7071067811865476 + 0.7071067811865475j, -0.7071067811865477 -
            0.7071067811865475j, -0.7071067811865477 - 0.7071067811865475j,
            0.7071067811865476 + 0.7071067811865475j, -0.7071067811865477 -
            0.7071067811865475j, 0.7071067811865476 + 0.7071067811865475j,
            -0.7071067811865477 - 0.7071067811865475j, 0.7071067811865476 +
            0.7071067811865475j, 0.7071067811865476 + 0.7071067811865475j,
            0.7071067811865476 + 0.7071067811865475j
        ])
        self.mod_phase_offset = mod_phase_offset = np.pi / 4
        self.mod_labels = mod_labels = [0, 1, 3, 2]
        self.mod_amplitude = mod_amplitude = 1
        self.freq_correction = freq_correction = 40
        self.freq = freq = 220e6
        self.frame_size_samples_after_downsampling = frame_size_samples_after_downsampling = frame_size_samples_before_downsampling // downsampling
        self.frac_resampling = frac_resampling = 5

        ##################################################
        # Blocks
        ##################################################
        self.stream_demux_stream_demux_0 = stream_demux_swig.stream_demux(
            gr.sizeof_char * 1, [len(preamble_and_padding), payload_size])
        self.grsksdr_symbol_sync_0 = grsksdr.symbol_sync(
            'sksdr.QPSK', rx_filter_sps, 1, 0.01, 1, 1 / np.sqrt(2))
        self.grsksdr_psk_demod_0 = grsksdr.psk_demod('sksdr.QPSK', mod_labels,
                                                     mod_amplitude,
                                                     mod_phase_offset)
        self.grsksdr_phase_offset_est_0 = grsksdr.phase_offset_est(
            mod_preamble, frame_size_symbols)
        self.grsksdr_freq_sync_0 = grsksdr.freq_sync('sksdr.QPSK',
                                                     rx_filter_sps, 1, 0.01)
        self.grsksdr_frame_sync_0 = grsksdr.frame_sync(mod_preamble, 8.0,
                                                       frame_size_symbols)
        self.grsksdr_fir_decimator_0 = grsksdr.fir_decimator(
            downsampling, rrc_coeffs)
        self.grsksdr_descrambler_0 = grsksdr.descrambler(
            [1, 0, 1, 1, 0, 1, 0, 1], [0, 3, 2, 2, 5, 1, 7])
        self.grsksdr_coarse_freq_comp_0 = grsksdr.coarse_freq_comp(
            modulation.order, samp_rate / 2, 1,
            frame_size_samples_after_downsampling)
        self.grsksdr_agc_1 = grsksdr.agc(
            0.25, 60, 0.01, frame_size_samples_before_downsampling)
        self.epy_block_0 = epy_block_0.blk(message_size=msg_size,
                                           payload_size=payload_size)
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(
            modulation.bits_per_symbol, gr.GR_MSB_FIRST)
        self.blocks_throttle_1 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_null_sink_0_0_1 = blocks.null_sink(gr.sizeof_gr_complex *
                                                       1)
        self.blocks_null_sink_0_0_0 = blocks.null_sink(gr.sizeof_gr_complex *
                                                       1)
        self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_char * 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 1)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1, 'test.iq', True, 0, 0)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_1, 0))
        self.connect((self.blocks_throttle_1, 0), (self.grsksdr_agc_1, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0),
                     (self.stream_demux_stream_demux_0, 0))
        self.connect((self.epy_block_0, 0), (self.blocks_null_sink_0_0, 0))
        self.connect((self.grsksdr_agc_1, 0),
                     (self.grsksdr_fir_decimator_0, 0))
        self.connect((self.grsksdr_coarse_freq_comp_0, 0),
                     (self.grsksdr_freq_sync_0, 0))
        self.connect((self.grsksdr_descrambler_0, 0), (self.epy_block_0, 0))
        self.connect((self.grsksdr_fir_decimator_0, 0),
                     (self.grsksdr_coarse_freq_comp_0, 0))
        self.connect((self.grsksdr_frame_sync_0, 0),
                     (self.blocks_null_sink_0_0_0, 0))
        self.connect((self.grsksdr_frame_sync_0, 0),
                     (self.grsksdr_phase_offset_est_0, 0))
        self.connect((self.grsksdr_freq_sync_0, 0),
                     (self.grsksdr_symbol_sync_0, 0))
        self.connect((self.grsksdr_phase_offset_est_0, 0),
                     (self.grsksdr_psk_demod_0, 0))
        self.connect((self.grsksdr_psk_demod_0, 0),
                     (self.blocks_unpacked_to_packed_xx_0, 0))
        self.connect((self.grsksdr_symbol_sync_0, 0),
                     (self.blocks_null_sink_0_0_1, 0))
        self.connect((self.grsksdr_symbol_sync_0, 0),
                     (self.grsksdr_frame_sync_0, 0))
        self.connect((self.stream_demux_stream_demux_0, 0),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.stream_demux_stream_demux_0, 1),
                     (self.grsksdr_descrambler_0, 0))
Beispiel #34
0
    def __init__(self):
        gr.top_block.__init__(self, "OFDM Tx")

        ##################################################
        # Variables
        ##################################################
        self.occupied_carriers = occupied_carriers = (
            range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) +
            range(8, 21) + range(22, 27), )
        self.length_tag_key = length_tag_key = "packet_len"
        self.transistion = transistion = 500
        self.sync_word2 = sync_word2 = [
            0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1,
            1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1,
            1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1,
            -1, 0, 0, 0, 0, 0
        ]
        self.sync_word1 = sync_word1 = [
            0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0.,
            -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            0., 0., 0., 0., 0.
        ]
        self.sideband_rx = sideband_rx = 1000
        self.sideband = sideband = 1000
        self.samp_rate = samp_rate = 48000
        self.rolloff = rolloff = 0
        self.pilot_symbols = pilot_symbols = ((
            1,
            1,
            1,
            -1,
        ), )
        self.pilot_carriers = pilot_carriers = ((
            -21,
            -7,
            7,
            21,
        ), )
        self.payload_mod = payload_mod = digital.constellation_qpsk()
        self.packet_len = packet_len = 4
        self.interpolation = interpolation = 2250
        self.header_mod = header_mod = digital.constellation_bpsk()
        self.header_formatter = header_formatter = digital.packet_header_ofdm(
            occupied_carriers, 1, length_tag_key)
        self.fft_len = fft_len = 64
        self.carrier = carrier = 10000

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=interpolation,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (firdes.band_pass(0.5, samp_rate, carrier - sideband,
                                 carrier + sideband, transistion)), -carrier,
            samp_rate)
        self.fft_vxx_0 = fft.fft_vcc(fft_len, False, (()), True, 1)
        self.digital_packet_headergenerator_bb_0 = digital.packet_headergenerator_bb(
            header_formatter.formatter(), "packet_len")
        self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(
            fft_len, fft_len + fft_len / 4, rolloff, length_tag_key)
        self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc(
            fft_len, occupied_carriers, pilot_carriers, pilot_symbols,
            (sync_word1, sync_word2), length_tag_key)
        self.digital_crc32_bb_0 = digital.crc32_bb(False, length_tag_key, True)
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(
            (payload_mod.points()), 1)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            (header_mod.points()), 1)
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink(
            "OFDM_output.wav", 1, samp_rate, 16)
        self.blocks_unpack_k_bits_bb_0_0 = blocks.unpack_k_bits_bb(8)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(
            gr.sizeof_gr_complex * 1, length_tag_key, 0)
        self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1,
                                                 False)
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, packet_len, length_tag_key)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            8, payload_mod.bits_per_symbol(), length_tag_key, False,
            gr.GR_LSB_FIRST)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((0.1, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, ))
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1,
                                                       "TestData2", False)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                     "inputBinary", False)
        self.blocks_file_sink_0_0.set_unbuffered(False)
        self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_real_0_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_unpack_k_bits_bb_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_tag_gate_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_wavfile_sink_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0),
                     (self.digital_crc32_bb_0, 0))
        self.connect((self.blocks_tag_gate_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0),
                     (self.digital_ofdm_carrier_allocator_cvc_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0_0, 0),
                     (self.blocks_file_sink_0_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.blocks_tagged_stream_mux_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0),
                     (self.blocks_tagged_stream_mux_0, 1))
        self.connect((self.digital_crc32_bb_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.digital_crc32_bb_0, 0),
                     (self.digital_packet_headergenerator_bb_0, 0))
        self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0),
                     (self.fft_vxx_0, 0))
        self.connect((self.digital_ofdm_cyclic_prefixer_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.digital_packet_headergenerator_bb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.digital_ofdm_cyclic_prefixer_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.blocks_complex_to_real_0_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 2
        self.samp_rate = samp_rate = int(1e6)

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("addr=192.168.90.2", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(int(450e6), 0)
        self.uhd_usrp_sink_0.set_gain(32, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.uhd_usrp_sink_0.set_bandwidth(samp_rate, 0)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "TX",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
            samples_per_symbol=2,
            bt=0.35,
            verbose=False,
            log=False,
        )
        self.blocks_file_source_0_0 = blocks.file_source(
            gr.sizeof_char * 1,
            '/home/gill/Desktop/WPI Test Demo/Video Streaming/Source/video1.ts',
            True)
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(
            grc_blks2.packet_encoder(
                samples_per_symbol=sps,
                bits_per_symbol=1,
                preamble='',
                access_code='',
                pad_for_usrp=True,
            ),
            payload_length=0,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_packet_encoder_0, 0),
                     (self.digital_gmsk_mod_0, 0))
        self.connect((self.blocks_file_source_0_0, 0),
                     (self.blks2_packet_encoder_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0), (self.uhd_usrp_sink_0, 0))
Beispiel #36
0
  def _setup_source(self, options):
    if options.source == "uhd":
      #UHD source by default
      from gnuradio import uhd
      self._u = uhd.usrp_source(
          options.args,
          uhd.stream_args(
              cpu_format="fc32",
              channels=range(1),
          ),
      )

      if(options.subdev):
        self._u.set_subdev_spec(options.subdev, 0)

      if not self._u.set_center_freq(options.freq):
        print("Failed to set initial frequency")

      #check for GPSDO
      #if you have a GPSDO, UHD will automatically set the timestamp to UTC time
      #as well as automatically set the clock to lock to GPSDO.
      if self._u.get_time_source(0) != 'gpsdo':
        self._u.set_time_now(uhd.time_spec(0.0))

      if options.antenna is not None:
        self._u.set_antenna(options.antenna)

      self._u.set_samp_rate(options.rate)
      options.rate = int(self._u.get_samp_rate()) #retrieve actual

      if options.gain is None: #set to halfway
        g = self._u.get_gain_range()
        options.gain = (g.start()+g.stop()) / 2.0

      print("Setting gain to %i" % options.gain)
      self._u.set_gain(options.gain)
      print("Gain is %i" % self._u.get_gain())

    #TODO: detect if you're using an RTLSDR or Jawbreaker
    #and set up accordingly.
    elif options.source == "osmocom": #RTLSDR dongle or HackRF Jawbreaker
        import osmosdr
        self._u = osmosdr.source(options.args)
#        self._u.set_sample_rate(3.2e6) #fixed for RTL dongles
        self._u.set_sample_rate(options.rate)
        if not self._u.set_center_freq(options.freq):
            print("Failed to set initial frequency")

#        self._u.set_gain_mode(0) #manual gain mode
        if options.gain is None:
            options.gain = 34
        self._u.set_gain(options.gain)
        print("Gain is %i" % self._u.get_gain())

        #Note: this should only come into play if using an RTLSDR.
#        lpfiltcoeffs = gr.firdes.low_pass(1, 5*3.2e6, 1.6e6, 300e3)
#        self._resample = filter.rational_resampler_ccf(interpolation=5, decimation=4, taps=lpfiltcoeffs)

    else:
      #semantically detect whether it's ip.ip.ip.ip:port or filename
      if ':' in options.source:
        try:
          ip, port = re.search("(.*)\:(\d{1,5})", options.source).groups()
        except:
          raise Exception("Please input UDP source e.g. 192.168.10.1:12345")
        self._u = blocks.udp_source(gr.sizeof_gr_complex, ip, int(port))
        print("Using UDP source %s:%s" % (ip, port))
      else:
        self._u = blocks.file_source(gr.sizeof_gr_complex, options.source)
        print("Using file source %s" % options.source)

    print("Rate is %i" % (options.rate,))
    def __init__(self, puncpat='11'):
        gr.top_block.__init__(self, "Tx Send No Gui")

        ##################################################
        # Parameters
        ##################################################
        self.puncpat = puncpat

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.nfilts = nfilts = 32
        self.eb = eb = 0.22

        self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0, eb, 5 * sps * nfilts)

        self.taps_per_filt = taps_per_filt = len(tx_rrc_taps) / nfilts
        self.samp_rate_array_MCR = samp_rate_array_MCR = [
            7500000, 5000000, 3750000, 3000000, 2500000, 2000000, 1500000,
            1000000, 937500, 882352, 833333, 714285, 533333, 500000, 421052,
            400000, 380952
        ]
        self.vector = vector = [int(random.random() * 4) for i in range(49600)]
        self.variable_qtgui_range_0 = variable_qtgui_range_0 = 50
        self.samp_rate = samp_rate = samp_rate_array_MCR[0]
        self.rate = rate = 2
        self.polys = polys = [109, 79]
        self.pld_const = pld_const = digital.constellation_rect(([
            0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j
        ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.pld_const.gen_soft_dec_lut(8)
        self.k = k = 7
        self.frequencia_usrp = frequencia_usrp = 484e6
        self.filt_delay = filt_delay = 1 + (taps_per_filt - 1) / 2
        self.MCR = MCR = "master_clock_rate=60e6"

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0_0 = uhd.usrp_sink(
            ",".join(("serial=F5EAE1", MCR)),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0_0.set_center_freq(frequencia_usrp, 0)
        self.uhd_usrp_sink_0_0.set_gain(variable_qtgui_range_0, 0)
        self.uhd_usrp_sink_0_0.set_antenna('TX/RX', 0)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
            sps, taps=(tx_rrc_taps), flt_size=nfilts)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(filt_delay)

        self.insert_vec_cpp_new_vec_0 = insert_vec_cpp.new_vec((vector))
        self.digital_map_bb_1_0 = digital.map_bb((pld_const.pre_diff_code()))
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(4)
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(
            (pld_const.points()), 1)
        self.blocks_stream_mux_0_1_0 = blocks.stream_mux(
            gr.sizeof_char * 1, (96, 896))
        self.blocks_repack_bits_bb_1_0_0_0 = blocks.repack_bits_bb(
            1, 2, '', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            8, 1, '', False, gr.GR_MSB_FIRST)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.7, ))
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1, '/home/andre/Desktop/TX_TEMP.txt', False)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.acode_1104 = blocks.vector_source_b([
            0x1, 0x0, 0x1, 0x0, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x0, 0x1, 0x1,
            0x1, 0x0, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1,
            0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1,
            0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0,
            0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0,
            0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0,
            0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1,
            0x1, 0x0, 0x0, 0x0, 0x0
        ], True, 1, [])

        ##################################################
        # Connections
        ##################################################
        self.connect((self.acode_1104, 0), (self.blocks_stream_mux_0_1_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.uhd_usrp_sink_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.blocks_stream_mux_0_1_0, 1))
        self.connect((self.blocks_repack_bits_bb_1_0_0_0, 0),
                     (self.insert_vec_cpp_new_vec_0, 0))
        self.connect((self.blocks_stream_mux_0_1_0, 0),
                     (self.blocks_repack_bits_bb_1_0_0_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.digital_diff_encoder_bb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.digital_map_bb_1_0, 0),
                     (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.insert_vec_cpp_new_vec_0, 0),
                     (self.digital_map_bb_1_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
Beispiel #38
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2600000
        self.rf_tx = rf_tx = 0
        self.noise_amp = noise_amp = 0
        self.noise = noise = 0
        self.if_tx = if_tx = 30
        self.freq = freq = 1575420000

        ##################################################
        # Blocks
        ##################################################
        _rf_tx_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rf_tx_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rf_tx_sizer,
            value=self.rf_tx,
            callback=self.set_rf_tx,
            label='RF_AMP',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rf_tx_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rf_tx_sizer,
            value=self.rf_tx,
            callback=self.set_rf_tx,
            minimum=0,
            maximum=14,
            num_steps=14,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_rf_tx_sizer)
        _if_tx_sizer = wx.BoxSizer(wx.VERTICAL)
        self._if_tx_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_if_tx_sizer,
            value=self.if_tx,
            callback=self.set_if_tx,
            label='IF_AMP',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._if_tx_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_if_tx_sizer,
            value=self.if_tx,
            callback=self.set_if_tx,
            minimum=0,
            maximum=47,
            num_steps=47,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_if_tx_sizer)
        self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " +
                                           "serial=F4C33C")
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(freq, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(rf_tx, 0)
        self.osmosdr_sink_0.set_if_gain(if_tx, 0)
        self.osmosdr_sink_0.set_bb_gain(20, 0)
        self.osmosdr_sink_0.set_antenna('', 0)
        self.osmosdr_sink_0.set_bandwidth(2.5e6, 0)

        _noise_amp_sizer = wx.BoxSizer(wx.VERTICAL)
        self._noise_amp_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_noise_amp_sizer,
            value=self.noise_amp,
            callback=self.set_noise_amp,
            label='Noise',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._noise_amp_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_noise_amp_sizer,
            value=self.noise_amp,
            callback=self.set_noise_amp,
            minimum=0,
            maximum=10,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_noise_amp_sizer)
        self._noise_check_box = forms.check_box(
            parent=self.GetWin(),
            value=self.noise,
            callback=self.set_noise,
            label='noise',
            true=1,
            false=0,
        )
        self.Add(self._noise_check_box)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_short * 1, '/home/james/Downloads/circle_hackrf.bin',
            True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_short_to_float_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.osmosdr_sink_0, 0))
        self.connect((self.blocks_short_to_float_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_short_to_float_0, 0),
                     (self.blocks_float_to_complex_0, 0))
    def __init__(self, puncpat='11'):
        gr.top_block.__init__(self, "Tx No Gui")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Tx No Gui")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Parameters
        ##################################################
        self.puncpat = puncpat

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.samp_rate_array_MCR = samp_rate_array_MCR = [
            7500000, 5000000, 3750000, 3000000, 2500000, 2000000, 1500000,
            1000000, 937500, 882352, 833333, 714285, 533333, 500000, 421052,
            400000, 380952, 200000, 100000, 50000
        ]
        self.nfilts = nfilts = 32
        self.eb = eb = 0.22
        self.H = H = fec.ldpc_H_matrix(
            '/usr/local/share/gnuradio/fec/ldpc/n_1100_k_0442_gap_24.alist',
            24)
        self.vector = vector = [
            int(random.random() * 4) for i in range(198400)
        ]
        self.variable_qtgui_range_0_0 = variable_qtgui_range_0_0 = 43

        self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0, eb, 11 * sps * nfilts)

        self.samp_rate = samp_rate = samp_rate_array_MCR[15]

        self.pld_enc = pld_enc = map(
            (lambda a: fec.ldpc_par_mtrx_encoder_make_H(H)), range(0, 4))
        self.pld_const = pld_const = digital.constellation_rect(([
            0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j
        ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.pld_const.gen_soft_dec_lut(8)
        self.frequencia_usrp = frequencia_usrp = 484e6
        self.MCR = MCR = "master_clock_rate=60e6"

        ##################################################
        # Blocks
        ##################################################
        self._variable_qtgui_range_0_0_range = Range(0, 90, 1, 43, 200)
        self._variable_qtgui_range_0_0_win = RangeWidget(
            self._variable_qtgui_range_0_0_range,
            self.set_variable_qtgui_range_0_0, 'Gain_TX', "counter_slider",
            float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_0_win, 0,
                                       2, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.uhd_usrp_sink_0_0 = uhd.usrp_sink(
            ",".join(("serial=F5EAE1", MCR)),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0_0.set_center_freq(frequencia_usrp, 0)
        self.uhd_usrp_sink_0_0.set_gain(variable_qtgui_range_0_0, 0)
        self.uhd_usrp_sink_0_0.set_antenna('TX/RX', 0)
        self.scrambler_cpp_additive_scrambler_0 = scrambler_cpp.additive_scrambler(
            0x8A, 0x7F, 7, 440 - 8)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "TX USRP",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_1.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_1.enable_tags(-1, True)
        self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_1.enable_autoscale(False)
        self.qtgui_time_sink_x_1.enable_grid(False)
        self.qtgui_time_sink_x_1.enable_axis_labels(True)
        self.qtgui_time_sink_x_1.enable_control_panel(False)
        self.qtgui_time_sink_x_1.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_1.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2):
            if len(labels[i]) == 0:
                if (i % 2 == 0):
                    self.qtgui_time_sink_x_1.set_line_label(
                        i, "Re{{Data {0}}}".format(i / 2))
                else:
                    self.qtgui_time_sink_x_1.set_line_label(
                        i, "Im{{Data {0}}}".format(i / 2))
            else:
                self.qtgui_time_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win, 1, 3, 1,
                                       1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 3, 1,
                                       1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0_0_0_0 = qtgui.const_sink_c(
            1024,  #size
            "TX Const",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_0.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0_0_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "red", "red", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0_0_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0_0_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0_0_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0_0_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0_0_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0_0_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_0_win, 1,
                                       2, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
            sps, taps=(tx_rrc_taps), flt_size=nfilts)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.insert_vec_cpp_new_vec_0 = insert_vec_cpp.new_vec((vector))
        self.fec_extended_encoder_0 = fec.extended_encoder(
            encoder_obj_list=pld_enc, threading='capillary', puncpat=puncpat)
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(
            pld_const.arity())
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(
            (pld_const.points()), 1)
        self.blocks_vector_source_x_0_0_0 = blocks.vector_source_b([0], True,
                                                                   1, [])
        self.blocks_vector_source_x_0_0 = blocks.vector_source_b([0], True, 1,
                                                                 [])
        self.blocks_vector_source_x_0 = blocks.vector_source_b([
            0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1,
            0x1, 0x1, 0x0, 0x1, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1,
            0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x1, 0x0, 0x0,
            0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1, 0x0,
            0x1, 0x0, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x0, 0x1, 0x1, 0x1, 0x0,
            0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0,
            0x0, 0x0, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1, 0x0, 0x1,
            0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0,
            0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0,
            0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0,
            0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1,
            0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
        ], True, 1, [])
        self.blocks_stream_mux_0_1_0_0 = blocks.stream_mux(
            gr.sizeof_char * 1, (155, 1104))
        self.blocks_stream_mux_0_0_0 = blocks.stream_mux(
            gr.sizeof_char * 1, (1100, 4))
        self.blocks_stream_mux_0_0 = blocks.stream_mux(gr.sizeof_char * 1,
                                                       (440, 2))
        self.blocks_repack_bits_bb_1_0_0_1 = blocks.repack_bits_bb(
            8, 1, '', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_1_0_0_0 = blocks.repack_bits_bb(
            1, pld_const.bits_per_symbol(), '', False, gr.GR_MSB_FIRST)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.7, ))
        self.blocks_file_source_0_0_1_0_0_0_1 = blocks.file_source(
            gr.sizeof_char * 1,
            '/home/andre/Dropbox/Investiga\xc3\xa7\xc3\xa3o_Metricas_Sync/Testes_C_Scrambler/Test_Additive_54bytes/sequence54_100000.txt',
            False)
        self.blocks_file_source_0_0_1_0_0_0_1.set_begin_tag(pmt.PMT_NIL)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0_0_1_0_0_0_1, 0),
                     (self.blocks_repack_bits_bb_1_0_0_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.qtgui_const_sink_x_0_0_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.qtgui_time_sink_x_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.uhd_usrp_sink_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_1_0_0_0, 0),
                     (self.insert_vec_cpp_new_vec_0, 0))
        self.connect((self.blocks_repack_bits_bb_1_0_0_1, 0),
                     (self.scrambler_cpp_additive_scrambler_0, 0))
        self.connect((self.blocks_stream_mux_0_0, 0),
                     (self.fec_extended_encoder_0, 0))
        self.connect((self.blocks_stream_mux_0_0_0, 0),
                     (self.blocks_stream_mux_0_1_0_0, 1))
        self.connect((self.blocks_stream_mux_0_1_0_0, 0),
                     (self.blocks_repack_bits_bb_1_0_0_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_stream_mux_0_1_0_0, 0))
        self.connect((self.blocks_vector_source_x_0_0, 0),
                     (self.blocks_stream_mux_0_0, 1))
        self.connect((self.blocks_vector_source_x_0_0_0, 0),
                     (self.blocks_stream_mux_0_0_0, 1))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.digital_diff_encoder_bb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.fec_extended_encoder_0, 0),
                     (self.blocks_stream_mux_0_0_0, 0))
        self.connect((self.insert_vec_cpp_new_vec_0, 0),
                     (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.scrambler_cpp_additive_scrambler_0, 0),
                     (self.blocks_stream_mux_0_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Tutorial")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Tutorial")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.nfilts = nfilts = 32
        self.eb = eb = 0.22

        self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0, eb, 11 * sps * nfilts)

        self.taps_per_filt = taps_per_filt = len(tx_rrc_taps) / nfilts
        self.vector = vector = [int(random.random() * 4) for i in range(49600)]
        self.time_offset = time_offset = 1.0
        self.taps = taps = [1.0, 0.25 - 0.25j, 0.50 + 0.10j, -0.3 + 0.2j]
        self.samp_rate = samp_rate = 5000000

        self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts * sps, 1.0, eb, 11 * sps * nfilts)

        self.pld_const = pld_const = digital.constellation_rect(([
            0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j
        ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.pld_const.gen_soft_dec_lut(8)
        self.noise = noise = 0.0
        self.freq_offset = freq_offset = 0
        self.filt_delay = filt_delay = 1 + (taps_per_filt - 1) / 2

        ##################################################
        # Blocks
        ##################################################
        self._time_offset_range = Range(0.99, 1.01, 0.00001, 1.0, 200)
        self._time_offset_win = RangeWidget(self._time_offset_range,
                                            self.set_time_offset,
                                            'Time Offset', "counter_slider",
                                            float)
        self.top_grid_layout.addWidget(self._time_offset_win, 0, 3, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._noise_range = Range(0, 5, 0.01, 0.0, 200)
        self._noise_win = RangeWidget(self._noise_range, self.set_noise,
                                      'Noise Amp', "counter_slider", float)
        self.top_grid_layout.addWidget(self._noise_win, 0, 1, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._freq_offset_range = Range(-0.5, 0.5, 0.0001, 0, 200)
        self._freq_offset_win = RangeWidget(self._freq_offset_range,
                                            self.set_freq_offset,
                                            'Freq. Offset', "counter_slider",
                                            float)
        self.top_grid_layout.addWidget(self._freq_offset_win, 0, 2, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f(
            100 * 2,  #size
            samp_rate,  #samp_rate
            'Rx Data',  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_1.set_update_time(0.10)
        self.qtgui_time_sink_x_0_1.set_y_axis(-1, 256)

        self.qtgui_time_sink_x_0_1.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0_1.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                    qtgui.TRIG_SLOPE_POS, 0.0,
                                                    0, 0,
                                                    'packet_length_tag_key')
        self.qtgui_time_sink_x_0_1.enable_autoscale(True)
        self.qtgui_time_sink_x_0_1.enable_grid(True)
        self.qtgui_time_sink_x_0_1.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_1.enable_control_panel(False)
        self.qtgui_time_sink_x_0_1.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0_1.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_win, 2, 3,
                                       1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            100 * 2,  #size
            samp_rate,  #samp_rate
            'Tx Data',  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 256)

        self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                    qtgui.TRIG_SLOPE_POS, 0.0,
                                                    0, 0,
                                                    'packet_length_tag_key')
        self.qtgui_time_sink_x_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0_0.enable_grid(True)
        self.qtgui_time_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 1, 1,
                                       1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0_0_0_1_0 = qtgui.const_sink_c(
            1024,  #size
            "RX Treated Constellation",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0_1_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0_1_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_1_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_1_0.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0_1_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0_1_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0_1_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0_0_1_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "red", "red", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0_0_0_1_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0_0_1_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0_0_1_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0_0_1_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0_0_1_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0_0_1_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0_0_1_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_0_1_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_1_0_win,
                                       2, 2, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0_0_0_1 = qtgui.const_sink_c(
            1024,  #size
            "RX Constellation",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0_1.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_1.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_1.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0_1.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0_1.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0_1.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0_0_1.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "red", "red", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0_0_0_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0_0_1.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_0_1_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_1_win, 2,
                                       1, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0_0_0_0 = qtgui.const_sink_c(
            1024,  #size
            "TX Constellation",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_0.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0_0_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "red", "red", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0_0_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0_0_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0_0_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0_0_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0_0_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0_0_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_0_win, 1,
                                       2, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
            sps, taps=(tx_rrc_taps), flt_size=nfilts)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(filt_delay)

        self.insert_vec_cpp_new_vec_0 = insert_vec_cpp.new_vec((vector))
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, 6.28 / 100.0, (rx_rrc_taps), nfilts, nfilts / 2, 1.5, 2)
        self.digital_map_bb_0_0 = digital.map_bb((pld_const.pre_diff_code()))
        self.digital_map_bb_0 = digital.map_bb((pld_const.pre_diff_code()))
        self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(
            6.28 / 200.0, pld_const.arity(), False)
        self.digital_correlate_access_code_xx_ts_0_0 = digital.correlate_access_code_bb_ts(
            digital.packet_utils.default_access_code, 1, 'packet_len')
        self.digital_constellation_decoder_cb_0_0 = digital.constellation_decoder_cb(
            pld_const)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(
            15, 1, 0.01, 2)
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(
            (pld_const.points()), 1)
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=noise,
            frequency_offset=freq_offset,
            epsilon=time_offset,
            taps=(taps),
            noise_seed=0,
            block_tags=True)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                   samp_rate, True)
        self.blocks_stream_mux_0_1_0 = blocks.stream_mux(
            gr.sizeof_char * 1, (96, 896))
        self.blocks_repack_bits_bb_1_0_0_1 = blocks.repack_bits_bb(
            8, 1, '', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0_1 = blocks.repack_bits_bb(
            1, pld_const.bits_per_symbol(), '', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(
            1, 8, '', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            pld_const.bits_per_symbol(), 1, '', False, gr.GR_MSB_FIRST)
        self.blocks_file_source_0_0_1_0 = blocks.file_source(
            gr.sizeof_char * 1,
            '/home/andre/Desktop/Files_To_Transmit/trasmit_10_mb.txt', False)
        self.blocks_file_source_0_0_1_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_0_0_0_2 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/andre/Desktop/Trasmited/depois.txt',
            False)
        self.blocks_file_sink_0_0_0_2.set_unbuffered(False)
        self.blocks_char_to_float_1_0_1 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_1_0_0 = blocks.char_to_float(1, 1)
        self.acode_1104 = blocks.vector_source_b([
            0x1, 0x0, 0x1, 0x0, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x0, 0x1, 0x1,
            0x1, 0x0, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1,
            0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1,
            0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0,
            0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0,
            0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0,
            0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1,
            0x1, 0x0, 0x0, 0x0, 0x0
        ], True, 1, [])

        ##################################################
        # Connections
        ##################################################
        self.connect((self.acode_1104, 0), (self.blocks_stream_mux_0_1_0, 0))
        self.connect((self.blocks_char_to_float_1_0_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_char_to_float_1_0_1, 0),
                     (self.qtgui_time_sink_x_0_1, 0))
        self.connect((self.blocks_file_source_0_0_1_0, 0),
                     (self.blocks_char_to_float_1_0_0, 0))
        self.connect((self.blocks_file_source_0_0_1_0, 0),
                     (self.blocks_repack_bits_bb_1_0_0_1, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.digital_correlate_access_code_xx_ts_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0),
                     (self.blocks_char_to_float_1_0_1, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0),
                     (self.blocks_file_sink_0_0_0_2, 0))
        self.connect((self.blocks_repack_bits_bb_0_1, 0),
                     (self.insert_vec_cpp_new_vec_0, 0))
        self.connect((self.blocks_repack_bits_bb_1_0_0_1, 0),
                     (self.blocks_stream_mux_0_1_0, 1))
        self.connect((self.blocks_stream_mux_0_1_0, 0),
                     (self.blocks_repack_bits_bb_0_1, 0))
        self.connect((self.blocks_throttle_0_0, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.blocks_throttle_0_0, 0),
                     (self.qtgui_const_sink_x_0_0_0_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.qtgui_const_sink_x_0_0_0_1, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0),
                     (self.digital_costas_loop_cc_0_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0_0, 0),
                     (self.digital_map_bb_0_0, 0))
        self.connect((self.digital_correlate_access_code_xx_ts_0_0, 0),
                     (self.blocks_repack_bits_bb_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.digital_constellation_decoder_cb_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.qtgui_const_sink_x_0_0_0_1_0, 0))
        self.connect((self.digital_map_bb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.digital_map_bb_0_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_cma_equalizer_cc_0, 0))
        self.connect((self.insert_vec_cpp_new_vec_0, 0),
                     (self.digital_map_bb_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.blocks_throttle_0_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Usrp Txrx Psk Spectrum")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Usrp Txrx Psk Spectrum")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.variable_function_probe_0_1 = variable_function_probe_0_1 = 0
        self.variable_function_probe_0_0_0 = variable_function_probe_0_0_0 = 0
        self.variable_function_probe_0_0 = variable_function_probe_0_0 = 0
        self.variable_function_probe_0 = variable_function_probe_0 = 0
        self.usrp_addr = usrp_addr = "type=usrp2"
        self.tx_gain = tx_gain = 0
        self.samp_rate = samp_rate = 10e6
        self.rx_gain = rx_gain = 0
        self.phase_code = phase_code = 120
        self.freq = freq = 900e6
        self.file_usrp_out = file_usrp_out = "usrp_out"
        self.file_usrp_in = file_usrp_in = "usrp_in"
        self.att_code = att_code = 32

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join((usrp_addr, "")),
            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(freq, 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join((usrp_addr, "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(freq, 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)

        def _variable_function_probe_0_1_probe():
            while True:
                val = self.uhd_usrp_source_0.set_time_now(uhd.time_spec_t(0.0))
                try:
                    self.set_variable_function_probe_0_1(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (1e-9))

        _variable_function_probe_0_1_thread = threading.Thread(
            target=_variable_function_probe_0_1_probe)
        _variable_function_probe_0_1_thread.daemon = True
        _variable_function_probe_0_1_thread.start()

        def _variable_function_probe_0_0_0_probe():
            while True:
                val = self.uhd_usrp_source_0.set_start_time(
                    uhd.time_spec_t(0.5))
                try:
                    self.set_variable_function_probe_0_0_0(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (1e-9))

        _variable_function_probe_0_0_0_thread = threading.Thread(
            target=_variable_function_probe_0_0_0_probe)
        _variable_function_probe_0_0_0_thread.daemon = True
        _variable_function_probe_0_0_0_thread.start()

        def _variable_function_probe_0_0_probe():
            while True:
                val = self.uhd_usrp_sink_0.set_start_time(uhd.time_spec_t(0.5))
                try:
                    self.set_variable_function_probe_0_0(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (1e-9))

        _variable_function_probe_0_0_thread = threading.Thread(
            target=_variable_function_probe_0_0_probe)
        _variable_function_probe_0_0_thread.daemon = True
        _variable_function_probe_0_0_thread.start()

        def _variable_function_probe_0_probe():
            while True:
                val = self.uhd_usrp_sink_0.set_time_now(uhd.time_spec_t(0.0))
                try:
                    self.set_variable_function_probe_0(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (1e-9))

        _variable_function_probe_0_thread = threading.Thread(
            target=_variable_function_probe_0_probe)
        _variable_function_probe_0_thread.daemon = True
        _variable_function_probe_0_thread.start()

        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self._phase_code_range = Range(0, 255, 1, 120, 200)
        self._phase_code_win = RangeWidget(self._phase_code_range,
                                           self.set_phase_code, "phase_code",
                                           "counter_slider", float)
        self.top_layout.addWidget(self._phase_code_win)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((10, ))
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1, file_usrp_in, True)
        self._att_code_range = Range(0, 127, 1, 32, 200)
        self._att_code_win = RangeWidget(self._att_code_range,
                                         self.set_att_code, "att_code",
                                         "counter_slider", float)
        self.top_layout.addWidget(self._att_code_win)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
Beispiel #42
0
    def __init__(self):
        gr.top_block.__init__(self, "atcs")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("atcs")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "atcs")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.symbol_rate = symbol_rate = 10762200
        self.samp_rate = samp_rate = 32000
        self.center_freq = center_freq = 429000000

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024, #size
            firdes.WIN_BLACKMAN_hARRIS, #wintype
            center_freq, #fc
            samp_rate, #bw
            "", #name
            1
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)



        labels = ['', '', '', '', '',
            '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
            1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
            "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
            1.0, 1.0, 1.0, 1.0, 1.0]

        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.fft_filter_xxx_0 = filter.fft_filter_ccf(1, firdes.root_raised_cosine(0.11, symbol_rate, symbol_rate/2, 0.1152, 200), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.dtv_dvbs2_modulator_bc_0 = dtv.dvbs2_modulator_bc(
            dtv.FECFRAME_NORMAL,
            dtv.C1_4,
            dtv.MOD_8VSB,
            dtv.INTERPOLATION_OFF)
        self.dtv_atsc_trellis_encoder_0 = dtv.atsc_trellis_encoder()
        self.dtv_atsc_rs_encoder_0 = dtv.atsc_rs_encoder()
        self.dtv_atsc_randomizer_0 = dtv.atsc_randomizer()
        self.dtv_atsc_pad_0 = dtv.atsc_pad()
        self.dtv_atsc_interleaver_0 = dtv.atsc_interleaver()
        self.dtv_atsc_field_sync_mux_0 = dtv.atsc_field_sync_mux()
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_char*1, 1024)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, symbol_rate,True)
        self.blocks_rotator_cc_0 = blocks.rotator_cc(-1.5708)
        self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(gr.sizeof_char, 832, 1024, 0)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, '/home/supernode/Downloads/Glen.ts', True, 0, 0)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, '/home/supernode/Work/microwave_experiments/signal_block/mantap.ts', False)
        self.blocks_file_sink_0.set_unbuffered(False)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0), (self.dtv_atsc_pad_0, 0))
        self.connect((self.blocks_keep_m_in_n_0, 0), (self.dtv_dvbs2_modulator_bc_0, 0))
        self.connect((self.blocks_rotator_cc_0, 0), (self.fft_filter_xxx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_keep_m_in_n_0, 0))
        self.connect((self.dtv_atsc_field_sync_mux_0, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.dtv_atsc_interleaver_0, 0), (self.dtv_atsc_trellis_encoder_0, 0))
        self.connect((self.dtv_atsc_pad_0, 0), (self.dtv_atsc_randomizer_0, 0))
        self.connect((self.dtv_atsc_randomizer_0, 0), (self.dtv_atsc_rs_encoder_0, 0))
        self.connect((self.dtv_atsc_rs_encoder_0, 0), (self.dtv_atsc_interleaver_0, 0))
        self.connect((self.dtv_atsc_trellis_encoder_0, 0), (self.dtv_atsc_field_sync_mux_0, 0))
        self.connect((self.dtv_dvbs2_modulator_bc_0, 0), (self.blocks_rotator_cc_0, 0))
        self.connect((self.fft_filter_xxx_0, 0), (self.blocks_throttle_0, 0))
Beispiel #43
0
    def test_000(self):
        infile = ts_in_file
        outfile = "vv.cfile"
        testfile = complex_out_file
        file_source = blocks.file_source(gr.sizeof_char * 1, infile, False, 0,
                                         0)
        file_source.set_begin_tag(pmt.PMT_NIL)
        bbheader = dtv.dvb_bbheader_bb(dtv.STANDARD_DVBT2, dtv.FECFRAME_NORMAL,
                                       dtv.C2_3, dtv.RO_0_35,
                                       dtv.INPUTMODE_NORMAL, dtv.INBAND_OFF,
                                       168, 4000000)
        bbscrambler = dtv.dvb_bbscrambler_bb(dtv.STANDARD_DVBT2,
                                             dtv.FECFRAME_NORMAL, dtv.C2_3)
        bch = dtv.dvb_bch_bb(dtv.STANDARD_DVBT2, dtv.FECFRAME_NORMAL, dtv.C2_3)
        ldpc = dtv.dvb_ldpc_bb(dtv.STANDARD_DVBT2, dtv.FECFRAME_NORMAL,
                               dtv.C2_3, dtv.MOD_OTHER)
        interleaver = dtv.dvbt2_interleaver_bb(dtv.FECFRAME_NORMAL, dtv.C2_3,
                                               dtv.MOD_64QAM)
        modulator = dtv.dvbt2_modulator_bc(dtv.FECFRAME_NORMAL, dtv.MOD_64QAM,
                                           dtv.ROTATION_ON)
        cellinterleaver = dtv.dvbt2_cellinterleaver_cc(dtv.FECFRAME_NORMAL,
                                                       dtv.MOD_64QAM, 2, 3)
        framemapper = dtv.dvbt2_framemapper_cc(
            dtv.FECFRAME_NORMAL, dtv.C2_3, dtv.MOD_64QAM, dtv.ROTATION_ON, 2,
            3, dtv.CARRIERS_NORMAL, dtv.FFTSIZE_4K, dtv.GI_1_32,
            dtv.L1_MOD_16QAM, dtv.PILOT_PP7, 2, 7, dtv.PAPR_TR,
            dtv.VERSION_111, dtv.PREAMBLE_T2_SISO, dtv.INPUTMODE_NORMAL,
            dtv.RESERVED_OFF, dtv.L1_SCRAMBLED_OFF, dtv.INBAND_OFF)
        freqinterleaver = dtv.dvbt2_freqinterleaver_cc(
            dtv.CARRIERS_NORMAL, dtv.FFTSIZE_4K, dtv.PILOT_PP7, dtv.GI_1_32, 7,
            dtv.PAPR_TR, dtv.VERSION_111, dtv.PREAMBLE_T2_SISO)
        pilotgenerator = dtv.dvbt2_pilotgenerator_cc(
            dtv.CARRIERS_NORMAL, dtv.FFTSIZE_4K, dtv.PILOT_PP7, dtv.GI_1_32, 7,
            dtv.PAPR_TR, dtv.VERSION_111, dtv.PREAMBLE_T2_SISO, dtv.MISO_TX1,
            dtv.EQUALIZATION_OFF, dtv.BANDWIDTH_8_0_MHZ, 4096)
        paprtr = dtv.dvbt2_paprtr_cc(dtv.CARRIERS_NORMAL, dtv.FFTSIZE_4K,
                                     dtv.PILOT_PP7, dtv.GI_1_32, 7,
                                     dtv.PAPR_TR, dtv.VERSION_111, 3.0, 10,
                                     4096)
        ofdm_cyclic_prefixer = digital.ofdm_cyclic_prefixer(
            4096, 4096 + 4096 // 32, 0, '')
        p1insertion = dtv.dvbt2_p1insertion_cc(dtv.CARRIERS_NORMAL,
                                               dtv.FFTSIZE_4K, dtv.GI_1_32, 7,
                                               dtv.PREAMBLE_T2_SISO,
                                               dtv.SHOWLEVELS_OFF, 3.01)
        file_sink = blocks.file_sink(gr.sizeof_gr_complex * 1, outfile, False)
        file_sink.set_unbuffered(True)
        self.tb.connect(file_source, bbheader, bbscrambler, bch, ldpc,
                        interleaver, modulator, cellinterleaver, framemapper,
                        freqinterleaver, pilotgenerator, paprtr,
                        ofdm_cyclic_prefixer, p1insertion, file_sink)
        self.tb.run()
        file_sink.close()

        self.assertEqual(getsize(outfile), getsize(testfile))

        out_data = np.fromfile(outfile, dtype=np.float32)
        expected_data = np.fromfile(testfile, dtype=np.float32)
        os.remove(outfile)

        self.assertFloatTuplesAlmostEqual(out_data, expected_data, 5)
        pass
Beispiel #44
0
    def __init__(self,
                 gs_name='VTGS',
                 ip='0.0.0.0',
                 meta_rate=.1,
                 port='52003',
                 record_iq=0,
                 record_rfo=0,
                 record_snr=0,
                 tx_freq=1265e6,
                 tx_offset=250e3):
        gr.top_block.__init__(self, "VTGS Rocksat-X 2017 Transceiver v2.0")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("VTGS Rocksat-X 2017 Transceiver v2.0")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Parameters
        ##################################################
        self.gs_name = gs_name
        self.ip = ip
        self.meta_rate = meta_rate
        self.port = port
        self.record_iq = record_iq
        self.record_rfo = record_rfo
        self.record_snr = record_snr
        self.tx_freq = tx_freq
        self.tx_offset = tx_offset

        ##################################################
        # Variables
        ##################################################
        self.ts_str = ts_str = dt.strftime(dt.utcnow(),
                                           "%Y%m%d_%H%M%S.%f") + '_UTC'
        self.samp_rate = samp_rate = 500e3
        self.baud = baud = 125e3
        self.snr_fn = snr_fn = "{:s}_{:s}.snr".format(gs_name, ts_str)
        self.samps_per_symb = samps_per_symb = int(samp_rate / baud)
        self.rx_freq = rx_freq = 2395e6
        self.rfo_fn = rfo_fn = "{:s}_{:s}.rfo".format(gs_name, ts_str)
        self.iq_fn = iq_fn = "{:s}_{:s}_{:s}k.fc32".format(
            gs_name, ts_str, str(int(samp_rate) / 1000))
        self.alpha = alpha = 0.5
        self.uplink_label = uplink_label = ''
        self.tx_gain = tx_gain = 25
        self.tx_correct = tx_correct = 2000
        self.snr_fp = snr_fp = "/captures/rocksat/{:s}".format(snr_fn)
        self.rx_offset = rx_offset = 250e3
        self.rx_gain = rx_gain = 1
        self.rx_freq_lbl = rx_freq_lbl = "{:4.3f}".format(rx_freq / 1e6)

        self.rrc_filter_taps = rrc_filter_taps = firdes.root_raised_cosine(
            32, 1.0, 1.0 / (samps_per_symb * 32), alpha, samps_per_symb * 32)

        self.rfo_fp = rfo_fp = "/captures/rocksat/{:s}".format(rfo_fn)
        self.mult = mult = (samp_rate) / 2 / 3.141593

        self.lpf_taps = lpf_taps = firdes.low_pass(1.0, samp_rate,
                                                   samp_rate / 2, 1000,
                                                   firdes.WIN_HAMMING, 6.76)

        self.lo = lo = 1833e6
        self.khz_offset = khz_offset = 0
        self.iq_fp = iq_fp = "/captures/rocksat/{:s}".format(iq_fn)
        self.bb_gain = bb_gain = .75

        ##################################################
        # Blocks
        ##################################################
        self._khz_offset_range = Range(-150, 150, 1, 0, 200)
        self._khz_offset_win = RangeWidget(self._khz_offset_range,
                                           self.set_khz_offset, 'Offset [kHz]',
                                           "counter_slider", float)
        self.top_grid_layout.addWidget(self._khz_offset_win, 4, 8, 1, 4)
        self._bb_gain_range = Range(0, 1, .01, .75, 200)
        self._bb_gain_win = RangeWidget(self._bb_gain_range, self.set_bb_gain,
                                        'bb_gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._bb_gain_win, 11, 8, 1, 4)
        self.vtgs_mult_descrambler_0 = vtgs.mult_descrambler(17, 0x3FFFF)
        self.vtgs_ao40_decoder_0_0 = vtgs.ao40_decoder()
        self._uplink_label_tool_bar = Qt.QToolBar(self)

        if None:
            self._uplink_label_formatter = None
        else:
            self._uplink_label_formatter = lambda x: str(x)

        self._uplink_label_tool_bar.addWidget(Qt.QLabel('TX MSG' + ": "))
        self._uplink_label_label = Qt.QLabel(
            str(self._uplink_label_formatter(self.uplink_label)))
        self._uplink_label_tool_bar.addWidget(self._uplink_label_label)
        self.top_grid_layout.addWidget(self._uplink_label_tool_bar, 9, 8, 1, 1)

        self._tx_gain_range = Range(0, 86, 1, 25, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain,
                                        'TX Gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._tx_gain_win, 10, 8, 1, 4)
        self._tx_correct_range = Range(-10000, 10000, 1, 2000, 200)
        self._tx_correct_win = RangeWidget(self._tx_correct_range,
                                           self.set_tx_correct, "tx_correct",
                                           "counter_slider", float)
        self.top_grid_layout.addWidget(self._tx_correct_win, 12, 8, 1, 4)
        self._rx_gain_range = Range(0, 86, 1, 1, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        'RX Gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._rx_gain_win, 3, 8, 1, 4)
        self._rx_freq_lbl_tool_bar = Qt.QToolBar(self)

        if None:
            self._rx_freq_lbl_formatter = None
        else:
            self._rx_freq_lbl_formatter = lambda x: str(x)

        self._rx_freq_lbl_tool_bar.addWidget(Qt.QLabel('RX Freq [MHz]' + ": "))
        self._rx_freq_lbl_label = Qt.QLabel(
            str(self._rx_freq_lbl_formatter(self.rx_freq_lbl)))
        self._rx_freq_lbl_tool_bar.addWidget(self._rx_freq_lbl_label)
        self.top_grid_layout.addWidget(self._rx_freq_lbl_tool_bar, 0, 10, 1, 2)

        self.rational_resampler_xxx_2 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=10,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=8,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=8,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            4096,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            '',  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.010)
        self.qtgui_waterfall_sink_x_0.enable_grid(True)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not False:
            self.qtgui_waterfall_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)

        labels = ['pre-d', 'post', '', '', '', '', '', '', '', '']
        colors = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-130, -20)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 5,
                                       0, 4, 8)
        self.qtgui_number_sink_2 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_HORIZ, 1)
        self.qtgui_number_sink_2.set_update_time(0.10)
        self.qtgui_number_sink_2.set_title("")

        labels = ['EVM', '', '', '', '', '', '', '', '', '']
        units = ['', '', '', '', '', '', '', '', '', '']
        colors = [("blue", "red"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        for i in xrange(1):
            self.qtgui_number_sink_2.set_min(i, -1)
            self.qtgui_number_sink_2.set_max(i, 1)
            self.qtgui_number_sink_2.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_2.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_2.set_label(i, labels[i])
            self.qtgui_number_sink_2.set_unit(i, units[i])
            self.qtgui_number_sink_2.set_factor(i, factor[i])

        self.qtgui_number_sink_2.enable_autoscale(False)
        self._qtgui_number_sink_2_win = sip.wrapinstance(
            self.qtgui_number_sink_2.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_2_win, 2, 8, 1,
                                       4)
        self.qtgui_number_sink_0_0_0_0 = qtgui.number_sink(
            gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1)
        self.qtgui_number_sink_0_0_0_0.set_update_time(0.10)
        self.qtgui_number_sink_0_0_0_0.set_title("")

        labels = ['SNR', '', '', '', '', '', '', '', '', '']
        units = ['dB', '', '', '', '', '', '', '', '', '']
        colors = [("blue", "red"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        for i in xrange(1):
            self.qtgui_number_sink_0_0_0_0.set_min(i, 0)
            self.qtgui_number_sink_0_0_0_0.set_max(i, 30)
            self.qtgui_number_sink_0_0_0_0.set_color(i, colors[i][0],
                                                     colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0_0_0_0.set_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0_0_0_0.set_label(i, labels[i])
            self.qtgui_number_sink_0_0_0_0.set_unit(i, units[i])
            self.qtgui_number_sink_0_0_0_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0_0_0_0.enable_autoscale(False)
        self._qtgui_number_sink_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_0_win, 1,
                                       8, 1, 4)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_NONE, 1)
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("")

        labels = ['RX Freq Offset', 'SNR', '', '', '', '', '', '', '', '']
        units = ['Hz', 'dB', '', '', '', '', '', '', '', '']
        colors = [("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        for i in xrange(1):
            self.qtgui_number_sink_0.set_min(i, -1)
            self.qtgui_number_sink_0.set_max(i, 1)
            self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0.set_label(i, labels[i])
            self.qtgui_number_sink_0.set_unit(i, units[i])
            self.qtgui_number_sink_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 0, 8, 1,
                                       2)
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / 10,  #bw
            "TX Spectrum",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_1.set_update_time(0.10)
        self.qtgui_freq_sink_x_1.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_1.enable_autoscale(True)
        self.qtgui_freq_sink_x_1.enable_grid(False)
        self.qtgui_freq_sink_x_1.set_fft_average(1.0)
        self.qtgui_freq_sink_x_1.enable_axis_labels(True)
        self.qtgui_freq_sink_x_1.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_1.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_1.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_1_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 9, 0, 4,
                                       8)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024 * 4,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            2  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.0010)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, -20)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['pre-d', 'post', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 5,
                                       8)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            1024,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-1, 1)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                   qtgui.TRIG_SLOPE_POS, 0.0,
                                                   0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(True)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "red", "red", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 5, 8, 4,
                                       4)
        self.pyqt_text_input_0 = pyqt.text_input()
        self._pyqt_text_input_0_win = self.pyqt_text_input_0
        self.top_grid_layout.addWidget(self._pyqt_text_input_0_win, 9, 9, 1, 3)
        self.mapper_demapper_soft_0 = mapper.demapper_soft(
            mapper.BPSK, ([0, 1]))
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, (baud * (1 + alpha)) / 2, 1000,
                            firdes.WIN_HAMMING, 6.76))
        self.kiss_hdlc_framer_0 = kiss.hdlc_framer(preamble_bytes=64,
                                                   postamble_bytes=16)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (lpf_taps), khz_offset * 1000, samp_rate)
        self.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x0, 16)
        self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf(
            samps_per_symb, math.pi * 2 / 100, (rrc_filter_taps), 32, 16, 1.5,
            1)
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
            samples_per_symbol=50,
            bt=alpha,
            verbose=False,
            log=False,
        )
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(
            math.pi * 2 / 100, 2, False)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            math.pi * 2 / 100, 2, False)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_socket_pdu_0_2 = blocks.socket_pdu("UDP_SERVER", ip,
                                                       '52002', 1024, False)
        self.blocks_socket_pdu_0_1 = blocks.socket_pdu("TCP_SERVER", ip, port,
                                                       1024, False)
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'packet_len')
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8)
        self.blocks_null_sink_0_0_0 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_nlog10_ff_0_1 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc(
            (bb_gain, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((mult, ))
        self.blocks_moving_average_xx_0_0_1 = blocks.moving_average_ff(
            100000, 0.00001, 4000)
        self.blocks_moving_average_xx_0_0 = blocks.moving_average_ff(
            1000, 0.001, 4000)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            100000, 0.00001, 4000)
        self.blocks_keep_one_in_n_0_0 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, int(samp_rate * meta_rate))
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, int(samp_rate / 8 * meta_rate))
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            '/captures/rocksat/testing/trimmed_500k.fc32', True)
        self.blocks_file_sink_1_0 = blocks.file_sink(gr.sizeof_float * 1,
                                                     rfo_fp, False)
        self.blocks_file_sink_1_0.set_unbuffered(False)
        self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_float * 1, snr_fp,
                                                   False)
        self.blocks_file_sink_1.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1,
                                                   iq_fp, False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared(
            1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, ))
        self.blks2_selector_0_0_0 = grc_blks2.selector(
            item_size=gr.sizeof_float * 1,
            num_inputs=1,
            num_outputs=2,
            input_index=0,
            output_index=int(record_snr),
        )
        self.blks2_selector_0_0 = grc_blks2.selector(
            item_size=gr.sizeof_float * 1,
            num_inputs=1,
            num_outputs=2,
            input_index=0,
            output_index=int(record_rfo),
        )
        self.blks2_selector_0 = grc_blks2.selector(
            item_size=gr.sizeof_gr_complex * 1,
            num_inputs=1,
            num_outputs=2,
            input_index=0,
            output_index=int(record_iq),
        )
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 125e3, 1, 0)
        self.analog_agc2_xx_0_0 = analog.agc2_cc(1e-3, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0_1, 'pdus'),
                         (self.kiss_hdlc_framer_0, 'in'))
        self.msg_connect((self.blocks_socket_pdu_0_2, 'pdus'),
                         (self.kiss_hdlc_framer_0, 'in'))
        self.msg_connect((self.kiss_hdlc_framer_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.msg_connect((self.pyqt_text_input_0, 'pdus'),
                         (self.kiss_hdlc_framer_0, 'in'))
        self.msg_connect((self.vtgs_ao40_decoder_0_0, 'valid_frames'),
                         (self.blocks_socket_pdu_0_1, 'pdus'))
        self.connect((self.analog_agc2_xx_0_0, 0),
                     (self.digital_costas_loop_cc_0_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blks2_selector_0, 1), (self.blocks_file_sink_0, 0))
        self.connect((self.blks2_selector_0, 0), (self.blocks_null_sink_0, 0))
        self.connect((self.blks2_selector_0_0, 1),
                     (self.blocks_file_sink_1_0, 0))
        self.connect((self.blks2_selector_0_0, 0),
                     (self.blocks_null_sink_0_0, 0))
        self.connect((self.blks2_selector_0_0_0, 1),
                     (self.blocks_file_sink_1, 0))
        self.connect((self.blks2_selector_0_0_0, 0),
                     (self.blocks_null_sink_0_0_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.qtgui_number_sink_2, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_moving_average_xx_0_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_divide_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_0, 0),
                     (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.blocks_nlog10_ff_0_1, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0),
                     (self.blks2_selector_0_0_0, 0))
        self.connect((self.blocks_keep_one_in_n_0_0, 0),
                     (self.blks2_selector_0_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_keep_one_in_n_0_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_moving_average_xx_0_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_moving_average_xx_0_0_1, 0),
                     (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.blocks_moving_average_xx_0_0_1, 0),
                     (self.qtgui_number_sink_0_0_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.rational_resampler_xxx_2, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.blocks_nlog10_ff_0_1, 0),
                     (self.blocks_moving_average_xx_0_0_1, 0))
        self.connect((self.blocks_pack_k_bits_bb_0, 0),
                     (self.digital_gmsk_mod_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0),
                     (self.digital_scrambler_bb_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blks2_selector_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.mapper_demapper_soft_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 1),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.vtgs_mult_descrambler_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_scrambler_bb_0, 0),
                     (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_agc2_xx_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.qtgui_freq_sink_x_0, 1))
        self.connect((self.mapper_demapper_soft_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.blocks_complex_to_mag_squared_0_0, 0))
        self.connect((self.rational_resampler_xxx_2, 0),
                     (self.qtgui_freq_sink_x_1, 0))
        self.connect((self.vtgs_mult_descrambler_0, 0),
                     (self.vtgs_ao40_decoder_0_0, 0))
Beispiel #45
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 3
        self.nfilts = nfilts = 32
        self.ntaps = ntaps = 11 * nfilts * sps
        self.excess_bw = excess_bw = 0.4
        self.tx_taps = tx_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0, excess_bw, ntaps)
        self.timing_bw = timing_bw = 2 * pi / 100
        self.samp_rate_0 = samp_rate_0 = 20000 * sps
        self.samp_rate = samp_rate = 20000
        self.rx_taps = rx_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0, excess_bw, ntaps)
        self.freq_bw = freq_bw = 2 * pi / 100
        self.fll_ntaps = fll_ntaps = 55
        self.const_points = const_points = 4

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccf(
            interpolation=3,
            decimation=25,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=25,
            decimation=3,
            taps=None,
            fractional_bw=None,
        )
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(sps,
                                                             taps=(tx_taps),
                                                             flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.low_pass_filter_0_0 = filter.fir_filter_fff(
            1, firdes.low_pass(1, 500e3, 50e3, 10e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_fff(
            1, firdes.low_pass(1, 500e3, 50e3, 10e3, firdes.WIN_HAMMING, 6.76))
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, timing_bw, (rx_taps), nfilts, 16, 1.5, 1)
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(4)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            (((-1 - 1j) / sqrt(2), (-1 + 1j) / sqrt(2), (1 - 1j) / sqrt(2),
              (1 + 1j) / sqrt(2))), 1)
        self.blocks_unpack_k_bits_bb_1 = blocks.unpack_k_bits_bb(2)
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                   20e3, True)
        self.blocks_threshold_ff_0_0 = blocks.threshold_ff(-0.001, 0.001, 0)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(-0.001, 0.001, 0)
        self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_char * 1, 6)
        self.blocks_pack_k_bits_bb_2 = blocks.pack_k_bits_bb(2)
        self.blocks_pack_k_bits_bb_1 = blocks.pack_k_bits_bb(2)
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8)
        self.blocks_multiply_xx_0_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((-1, ))
        self.blocks_interleave_0 = blocks.interleave(gr.sizeof_float * 1, 1)
        self.blocks_float_to_uchar_0 = blocks.float_to_uchar()
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1,
            '/media/aaronjs/New Volume/IITB_Files/Annual_Academic_Files/Year_3/Semester_5/EE340/Labwork/P10/Original_Text.txt',
            False)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/media/aaronjs/New Volume/IITB_Files/Annual_Academic_Files/Year_3/Semester_5/EE340/Labwork/P10/P10_3_ModDemod_Text.txt',
            False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            500e3, analog.GR_COS_WAVE, 100e3, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_multiply_xx_0_1, 1))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.blocks_threshold_ff_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_multiply_xx_0_1, 0))
        self.connect((self.blocks_complex_to_real_0_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.blocks_float_to_uchar_0, 0),
                     (self.blocks_skiphead_0, 0))
        self.connect((self.blocks_interleave_0, 0),
                     (self.blocks_float_to_uchar_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.blocks_multiply_xx_0_1, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_1, 0),
                     (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_2, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.blocks_skiphead_0, 0),
                     (self.blocks_pack_k_bits_bb_2, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_interleave_0, 0))
        self.connect((self.blocks_threshold_ff_0_0, 0),
                     (self.blocks_interleave_0, 1))
        self.connect((self.blocks_throttle_0_0, 0),
                     (self.blocks_complex_to_imag_0, 0))
        self.connect((self.blocks_throttle_0_0, 0),
                     (self.blocks_complex_to_real_0_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0),
                     (self.blocks_pack_k_bits_bb_1, 0))
        self.connect((self.blocks_unpack_k_bits_bb_1, 0),
                     (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blocks_unpack_k_bits_bb_1, 0))
        self.connect((self.digital_diff_encoder_bb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_throttle_0_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "AM_transmit tutorial")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("AM_transmit tutorial")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.volume = volume = 1.2
        self.samp_rate = samp_rate = 768e3

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_pub_sink_0 = zeromq.pub_sink(gr.sizeof_float, 1,
                                                 "tcp://127.0.0.1:50001", 100,
                                                 False, -1)
        self._volume_range = Range(0, 10, 100e-3, 1.2, 200)
        self._volume_win = RangeWidget(self._volume_range, self.set_volume,
                                       "Audio_gain", "counter_slider", float)
        self.top_layout.addWidget(self._volume_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            4096,  #size
            samp_rate,  #samp_rate
            "",  #name
            2  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label("Amplitude", "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ["", "", "", "", "", "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float * 1, 16)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1.2, ))
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_float * 1,
            "/home/hypersonic/Downloads/around_the_world-atc.wav", True)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((1, ))
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, 48e3, 500e-3, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_file_source_0, 0), (self.blocks_repeat_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.zeromq_pub_sink_0, 0))
        self.connect((self.blocks_repeat_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
Beispiel #47
0
    def __init__(self):
        gr.top_block.__init__(self, "Pure Noise")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Pure Noise")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "pure_noise")

        if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
        else:
            self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = float(d_txdb)
        self.samp = samp = 4
        self.rx_gain = rx_gain = float(d_rxdb)
        self.freq = freq = float(d_freq)
        self.buf = buf = 0x8000
        self.bits = bits = 16
        self.haven = haven = 0x100000
        
        ##################################################
        # Blocks
        ##################################################
        self._tx_gain_range = Range(-20, 64, 0.01, float(d_txdb), 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, "tx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._tx_gain_win)
        self._rx_gain_range = Range(0, 72, 0.01, float(d_rxdb), 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, "rx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._rx_gain_win)
        self._freq_options = [2450000000, 915000000, 430000000]
        self._freq_labels = ['2.45GHz', '915MHz', '430MHz']
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel('Channel'+": "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for label in self._freq_labels: self._freq_combo_box.addItem(label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_freq(self._freq_options[i]))
        self.top_layout.addWidget(self._freq_tool_bar)
        self.qtgui_number_sink_0 = qtgui.number_sink(
            gr.sizeof_float,
            0,
            qtgui.NUM_GRAPH_HORIZ,
            1
        )
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("")

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        units = ['', '', '', '', '',
                 '', '', '', '', '']
        colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")]
        factor = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        for i in xrange(1):
            self.qtgui_number_sink_0.set_min(i, -1)
            self.qtgui_number_sink_0.set_max(i, 1)
            self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0.set_label(i, labels[i])
            self.qtgui_number_sink_0.set_unit(i, units[i])
            self.qtgui_number_sink_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0.enable_autoscale(True)
        self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_number_sink_0_win)
        self.pluto_source_0 = iio.pluto_source(d_rxid, int(freq), int(4e6), int(20000000), buf*16, True, True, True, "manual", rx_gain, '', True)
        self.pluto_sink_0_0 = iio.pluto_sink(d_txid, int(freq), int(4e6), int(20000000), buf, False, tx_gain, '', True)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_moving_average_xx_1 = blocks.moving_average_ff(haven/32, 1, 4000)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(haven/32, 1, 4000)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_float*1, '/home/hrbenitez/Desktop/just_sig.bin', False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*1, d_dir + '/snr_pure.bin', False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.analog_const_source_x_0 = analog.sig_source_c(0, analog.GR_CONST_WAVE, 0, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0), (self.pluto_sink_0_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_moving_average_xx_1, 0))
        self.connect((self.blocks_divide_xx_0, 0), (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_file_source_0, 0), (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_divide_xx_0, 0))
        self.connect((self.blocks_moving_average_xx_1, 0), (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0), (self.qtgui_number_sink_0, 0))
        self.connect((self.pluto_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0))
Beispiel #48
0
    def __init__(self,
                 channels,
                 resamp_rate,
                 fc,
                 band,
                 samp_rate,
                 input_file,
                 dest_dir,
                 data_type="complex"):
        gr.top_block.__init__(self, "grgsm_channelize")

        ##################################################
        # Parameters
        ##################################################
        self.channels = channels
        self.resamp_rate = resamp_rate
        self.fc = fc
        self.band = band
        self.samp_rate = samp_rate
        self.blocks_resamplers = {}
        self.blocks_rotators = {}
        self.blocks_file_sinks = {}

        ##################################################
        # Blocks and connections
        ##################################################
        self.source = None
        if data_type == "ishort":
            self.blocks_file_source = blocks.file_source(
                gr.sizeof_short, input_file, False)
            self.source = blocks.interleaved_short_to_complex(False, False)
            self.connect((self.blocks_file_source, 0), (self.source, 0))
        elif data_type == "complex":
            self.source = blocks.file_source(gr.sizeof_gr_complex, input_file,
                                             False)

        fc_str = eng_notation.num_to_str(fc)
        print(
            "Extracting channels %s, given that the center frequency is at %s"
            % (str(channels), eng_notation.num_to_str(fc)))

        for channel in channels:
            channel_freq = arfcn.arfcn2downlink(channel, band)
            if channel_freq is None:
                print("Warning: invalid ARFCN %d for band %s" %
                      (channel, band))
                continue
            freq_diff = channel_freq - fc
            freq_diff_str = "+" if 0 <= freq_diff else ""
            freq_diff_str += eng_notation.num_to_str(freq_diff)
            print("ARFCN %d is at %sHz %sHz" %
                  (channel, fc_str, freq_diff_str))

            self.blocks_resamplers[channel] = pfb.arb_resampler_ccf(
                resamp_rate, taps=None, flt_size=32)
            self.blocks_rotators[channel] = blocks.rotator_cc(
                -2 * math.pi * (freq_diff) / samp_rate)
            self.connect((self.source, 0), (self.blocks_rotators[channel], 0))
            self.connect((self.blocks_rotators[channel], 0),
                         (self.blocks_resamplers[channel], 0))

            self.blocks_file_sinks[channel] = blocks.file_sink(
                gr.sizeof_gr_complex,
                dest_dir + "/out_" + str(channel) + ".cfile", False)
            self.blocks_file_sinks[channel].set_unbuffered(False)
            self.connect((self.blocks_resamplers[channel], 0),
                         (self.blocks_file_sinks[channel], 0))
Beispiel #49
0
 def __set_rx_from_file(self, filename, capture_rate):
     file = blocks.file_source(gr.sizeof_gr_complex, filename, True)
     gain = blocks.multiply_const_cc(self.options.gain)
     throttle = blocks.throttle(gr.sizeof_gr_complex, capture_rate)
     self.__connect([[file, gain, throttle]])
     self.__build_graph(throttle, capture_rate)
Beispiel #50
0
    def __init__(self):
        gr.top_block.__init__(self, "OFDM Tx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("OFDM Tx")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.occupied_carriers = occupied_carriers = (range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27),)
        self.length_tag_key = length_tag_key = "packet_len"
        self.sync_word2 = sync_word2 = [0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0] 
        self.sync_word1 = sync_word1 = [0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0.]
        self.samp_rate = samp_rate = 100000
        self.rolloff = rolloff = 0
        self.pilot_symbols = pilot_symbols = ((1, 1, 1, -1,),)
        self.pilot_carriers = pilot_carriers = ((-21, -7, 7, 21,),)
        self.payload_mod = payload_mod = digital.constellation_qpsk()
        self.packet_len = packet_len = 96
        self.header_mod = header_mod = digital.constellation_bpsk()
        self.header_formatter = header_formatter = digital.packet_header_ofdm(occupied_carriers, 1, length_tag_key)
        self.freq = freq = 4033e6
        self.fft_len = fft_len = 64

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
        	1024, #size
        	samp_rate, #samp_rate
        	"Scope Plot", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)
        
        self.qtgui_time_sink_x_0.set_y_label("Amplitude", "")
        
        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_0.disable_legend()
        
        labels = ["Scope Plot", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(2*1):
            if len(labels[i]) == 0:
                if(i % 2 == 0):
                    self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2))
                else:
                    self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"FFT Plot", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(True)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_freq_sink_x_0.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(freq, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(40, 0)
        self.osmosdr_sink_0.set_if_gain(80, 0)
        self.osmosdr_sink_0.set_bb_gain(80, 0)
        self.osmosdr_sink_0.set_antenna("", 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)
          
        self.fft_vxx_0 = fft.fft_vcc(fft_len, False, (()), True, 1)
        self.digital_packet_headergenerator_bb_0 = digital.packet_headergenerator_bb(header_formatter.formatter(), "packet_len")
        self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(fft_len, fft_len+fft_len/4, rolloff, length_tag_key)
        self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (sync_word1, sync_word2), length_tag_key)
        self.digital_crc32_bb_0 = digital.crc32_bb(False, length_tag_key, True)
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc((payload_mod.points()), 1)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((header_mod.points()), 1)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, length_tag_key, 0)
        self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False)
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, packet_len, length_tag_key)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(8, payload_mod.bits_per_symbol(), length_tag_key, False, gr.GR_LSB_FIRST)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, ))
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/bkbilly/Desktop/input_File", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_to_tagged_stream_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_tag_gate_0, 0))    
        self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0))    
        self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_crc32_bb_0, 0))    
        self.connect((self.blocks_tag_gate_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.blocks_tag_gate_0, 0), (self.osmosdr_sink_0, 0))    
        self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_0, 0))    
        self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0))    
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_tagged_stream_mux_0, 1))    
        self.connect((self.digital_crc32_bb_0, 0), (self.blocks_repack_bits_bb_0, 0))    
        self.connect((self.digital_crc32_bb_0, 0), (self.digital_packet_headergenerator_bb_0, 0))    
        self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0), (self.fft_vxx_0, 0))    
        self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.digital_packet_headergenerator_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))    
        self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0))    
Beispiel #51
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Dvbs Tx")

        ##################################################
        # Variables
        ##################################################
        self.symbol_rate = symbol_rate = 4500000
        self.samp_rate = samp_rate = symbol_rate * 2
        self.rrc_taps = rrc_taps = 20

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=435000000,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=True,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.trellis_encoder_xx_0 = trellis.encoder_bb(trellis.fsm(1, 2, (0171, 0133)), 0)
        self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(435e6, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(2, 0)
        self.osmosdr_sink_0.set_if_gain(0, 0)
        self.osmosdr_sink_0.set_bb_gain(-4, 0)
        self.osmosdr_sink_0.set_antenna("", 0)
        self.osmosdr_sink_0.set_bandwidth(6000000, 0)
          
        self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(2, (firdes.root_raised_cosine(1.79, samp_rate, samp_rate/2, 0.35, rrc_taps)))
        self.interp_fir_filter_xxx_0.declare_sample_delay(0)
        self.dvbs_reed_solomon_enc_bb_0 = dvbs.reed_solomon_enc_bb()
        self.dvbs_randomizer_bb_0 = dvbs.randomizer_bb()
        self.dvbs_puncture_bb_0 = dvbs.puncture_bb(dvbs.C1_2)
        self.dvbs_interleaver_bb_0 = dvbs.interleaver_bb()
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(([complex(0.70710678,0.70710678), complex(0.70710678,-0.70710678), complex(-0.70710678,0.70710678), complex(-0.70710678,-0.70710678)]), 1)
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(2)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/re/xfer/adv.ts", False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0), (self.dvbs_randomizer_bb_0, 0))
        self.connect((self.dvbs_randomizer_bb_0, 0), (self.dvbs_reed_solomon_enc_bb_0, 0))
        self.connect((self.dvbs_reed_solomon_enc_bb_0, 0), (self.dvbs_interleaver_bb_0, 0))
        self.connect((self.dvbs_interleaver_bb_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.trellis_encoder_xx_0, 0))
        self.connect((self.interp_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.interp_fir_filter_xxx_0, 0), (self.osmosdr_sink_0, 0))
        self.connect((self.trellis_encoder_xx_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.dvbs_puncture_bb_0, 0))
        self.connect((self.dvbs_puncture_bb_0, 0), (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.interp_fir_filter_xxx_0, 0))
Beispiel #52
0
    def __init__(self, args):
        gr.top_block.__init__(self, "File Atsc Rx", catch_exceptions=True)

        ##################################################
        # Variables
        ##################################################
        self.symbol_rate = symbol_rate = 4500000.0 / 286 * 684
        self.sps = sps = 1.1
        self.atsc_sym_rate = atsc_sym_rate = 4.5e6 / 286 * 684
        self.sample_rate = sample_rate = atsc_sym_rate * sps
        self.pilot_freq = pilot_freq = (6000000.0 - (symbol_rate / 2)) / 2
        self.oversampled_rate = oversampled_rate = atsc_sym_rate * sps
        self.center_freq = center_freq = 429e6
        self.capt_sample_rate = capt_sample_rate = 20e6

        ##################################################
        # Blocks
        ##################################################
        self.filter_fft_rrc_filter_0 = filter.fft_filter_ccc(
            1,
            firdes.root_raised_cosine(1, sample_rate, atsc_sym_rate / 2.0,
                                      0.1152, 50), 1)
        self.dtv_atsc_viterbi_decoder_0 = dtv.atsc_viterbi_decoder()
        # self.dtv_atsc_viterbi_decoder_0.set_processor_affinity([2])
        self.dtv_atsc_sync_0 = dtv.atsc_sync(oversampled_rate)
        self.dtv_atsc_rs_decoder_0 = dtv.atsc_rs_decoder()
        self.dtv_atsc_fs_checker_0 = dtv.atsc_fs_checker()
        self.dtv_atsc_fpll_0 = dtv.atsc_fpll(oversampled_rate)
        # self.dtv_atsc_fpll_0.set_processor_affinity([0])
        self.dtv_atsc_equalizer_0 = dtv.atsc_equalizer()
        self.dtv_atsc_derandomizer_0 = dtv.atsc_derandomizer()
        self.dtv_atsc_depad_0 = dtv.atsc_depad()
        self.dtv_atsc_deinterleaver_0 = dtv.atsc_deinterleaver()
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(4096, True)
        # self.dc_blocker_xx_0.set_processor_affinity([1])
        self.blocks_interleaved_short_to_complex_0_0 = blocks.interleaved_short_to_complex(
            False, False, 32768)
        self.blocks_file_source_0_0 = blocks.file_source(
            gr.sizeof_short * 1, args.infile, False, 0, 0)
        self.blocks_file_source_0_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                     args.outfile, False)
        self.blocks_file_sink_0_0.set_unbuffered(False)
        self.agc = analog.agc_ff(1e-5, 4.0, 1.0)
        self.agc.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.agc, 0), (self.dtv_atsc_sync_0, 0))
        self.connect((self.blocks_file_source_0_0, 0),
                     (self.blocks_interleaved_short_to_complex_0_0, 0))
        self.connect((self.blocks_interleaved_short_to_complex_0_0, 0),
                     (self.filter_fft_rrc_filter_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.agc, 0))
        self.connect((self.dtv_atsc_deinterleaver_0, 0),
                     (self.dtv_atsc_rs_decoder_0, 0))
        self.connect((self.dtv_atsc_depad_0, 0),
                     (self.blocks_file_sink_0_0, 0))
        self.connect((self.dtv_atsc_derandomizer_0, 0),
                     (self.dtv_atsc_depad_0, 0))
        self.connect((self.dtv_atsc_equalizer_0, 0),
                     (self.dtv_atsc_viterbi_decoder_0, 0))
        self.connect((self.dtv_atsc_fpll_0, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.dtv_atsc_fs_checker_0, 0),
                     (self.dtv_atsc_equalizer_0, 0))
        self.connect((self.dtv_atsc_rs_decoder_0, 0),
                     (self.dtv_atsc_derandomizer_0, 0))
        self.connect((self.dtv_atsc_sync_0, 0),
                     (self.dtv_atsc_fs_checker_0, 0))
        self.connect((self.dtv_atsc_viterbi_decoder_0, 0),
                     (self.dtv_atsc_deinterleaver_0, 0))
        self.connect((self.filter_fft_rrc_filter_0, 0),
                     (self.dtv_atsc_fpll_0, 0))
Beispiel #53
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1024000
        self.decimation = decimation = 10
        self.symbol_rate = symbol_rate = 38400
        self.input_rate = input_rate = samp_rate / decimation
        self.window_symbols = window_symbols = 1
        self.symbol_taps_length = symbol_taps_length = int(
            (float(input_rate) / symbol_rate))
        self.samples_per_symbol = samples_per_symbol = float(
            input_rate) / symbol_rate
        self.grab_freq = grab_freq = 868200000
        self.symbol_taps = symbol_taps = (1, ) * symbol_taps_length
        self.offset_sign2 = offset_sign2 = (-34780 * grab_freq) / 868200000
        self.offset_sign1 = offset_sign1 = (11600 * grab_freq) / 868200000
        self.gain_mu = gain_mu = 0.4 / samples_per_symbol
        self.fsk_deviation_hz = fsk_deviation_hz = 5200
        self.average_window = average_window = int(
            (input_rate * window_symbols / symbol_rate))

        ##################################################
        # Blocks
        ##################################################
        self.urmetEasyRead_urmetEasyRead_0 = urmetEasyRead.urmetEasyRead()
        self.digital_correlate_access_code_bb_0 = digital.correlate_access_code_bb(
            '11010011100100011101001110010001', 1)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            samples_per_symbol, 0.25 * gain_mu * gain_mu, 0.5, gain_mu, 0.02)
        self.digital_binary_slicer_fb_0_0 = digital.binary_slicer_fb()
        self.cc1111_cc1111_packet_decoder_0 = cc1111.cc1111_packet_decoder(
            gr.msg_queue(1), False, True, True, True)
        self.blocks_uchar_to_float_0 = blocks.uchar_to_float()
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_char * 1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1,
            '/home/fraschi/rpiRadio/buoni/500k/g005_868.283M_500k.cu8-20171222_132343.data',
            False)
        self.blocks_deinterleave_0 = blocks.deinterleave(
            gr.sizeof_float * 1, 1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vcc((-128 - 128j, ))
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(40, 1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1)
        self.FXFIR1 = filter.freq_xlating_fir_filter_ccc(
            decimation, (1, ), -14e3, samp_rate)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.FXFIR1, 0), (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_deinterleave_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_deinterleave_0, 1),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_uchar_to_float_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.FXFIR1, 0))
        self.connect((self.blocks_uchar_to_float_0, 0),
                     (self.blocks_deinterleave_0, 0))
        self.connect((self.cc1111_cc1111_packet_decoder_0, 0),
                     (self.urmetEasyRead_urmetEasyRead_0, 0))
        self.connect((self.digital_binary_slicer_fb_0_0, 0),
                     (self.digital_correlate_access_code_bb_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0_0, 0))
        self.connect((self.digital_correlate_access_code_bb_0, 0),
                     (self.cc1111_cc1111_packet_decoder_0, 0))
        self.connect((self.urmetEasyRead_urmetEasyRead_0, 0),
                     (self.blocks_null_sink_1, 0))
Beispiel #54
0
    def __init__(self, frame, panel, vbox, argv):
        stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)

        # station is the frequency to be received
        station = parseargs(argv[1:])

        adc_rate = 64e6  #output sample rate of the ADC, 64Ms/s
        usrp_decim = 250
        usrp_rate = adc_rate / usrp_decim  # output sample rate of the usrp, 256 ks/s
        lpf_decim = 4
        lpf_rate = usrp_rate / lpf_decim  # 64 kHz

        # usrp is data source
        # tells which usrp board is used and what the dec rate is
        #src = usrp.source_c (0, usrp_decim)

        #Tell USRP what daughter board to use and displays name
        #(1,0) means side B, 1st channel - picks daughterboard
        #rx_subdev_spec = (1,0)
        #src.set_mux(usrp.determine_rx_mux_value(src,rx_subdev_spec))
        #subdev = usrp.selected_subdev(src,rx_subdev_spec)
        #print "Using daughterboard",subdev.name()

        #sets the shift frequency of the ddc (on FPGA) Note: must be minus or FFT display is reversed JF 08-08-08
        #src.set_rx_freq (0, -station)

        #Turn up USRP gain to maximum
        #g = subdev.gain_range()
        #subdev.set_gain(float(g[1]))

        # checks the actual shift frequency
        #actual_shift_freq =src.rx_freq(0)

        #this line is to allow playback without usrp
        actual_shift_freq = -710000

        #print "Actual DDC shift frequency", actual_shift_freq
        #print "USRP gain ", float(g[1])

        # set gain on USRP
        #src.set_pga(0,20)

        #defines a file to collect usrp output
        #am_usrp_sink = gr.file_sink(gr.sizeof_gr_complex, "am_usrp710.dat")
        #self.connect(src, am_usrp_sink)

        #defines the file to playback the usrp data from
        am_usrp_source = blocks.file_source(gr.sizeof_gr_complex,
                                            "am_usrp710.dat")

        # computes taps for LPF and creates channel filter with those taps
        channel_coeffs = optfir.low_pass(
            1.0,  # gain
            usrp_rate,  # sampling rate
            4.5e3,  # low pass cutoff freq
            5e3,  # width of trans. band
            0.1,  #passband ripple
            60)  #stopband attenuation

        #set frequency shift for picking up other signals
        offset = 0

        chan_filter = filter.freq_xlating_fir_filter_ccf(
            lpf_decim, channel_coeffs, offset, usrp_rate)

        # define a file to collect channel filter output and connect
        #chan_sink = gr.file_sink(gr.sizeof_gr_complex, "chan.dat")
        #self.connect(chan_filter, chan_sink)

        #create an automatic gain control (AGC) block with 1 second time constant decay .1 attack.
        my_agc = analog.agc2_cc(1.5e-4, 1.5e-5, 10, 1)

        # create a block to take the magnitude (envelope) of the AM Signal
        magblock = blocks.complex_to_mag()

        # define and connect a sink of collect the output of the magnitude block
        #mag_sink = gr.file_sink(gr.sizeof_float, "mag.dat")
        #self.connect(magblock, mag_sink)

        #create a volume control and collect data into a file
        volumecontrol = blocks.multiply_const_ff(.04)
        #volcont_sink = gr.file_sink(gr.sizeof_float, "volcont.dat")
        #self.connect(volumecontrol, volcont_sink)

        # compute FIR filter taps for audio filter
        audio_coeffs = optfir.low_pass(
            1.0,  # gain
            lpf_rate,  # sampling rate
            4.5e3,  # edge of passband
            5e3,  # edge of stopband,
            0.1,  #passband ripple
            60)  # stopband ripple

        # create audio filter and a file for its output
        audio_filter = filter.fir_filter_fff(1, audio_coeffs)

        #audio_filt_sink = gr.file_sink(gr.sizeof_float, "audio_filt.dat")
        #self.connect(audio_filter, audio_filt_sink)

        # create a resampler to bring 64ks/s rate to 48ks/s for audio card and data file
        rsamp = filter.rational_resampler_fff(3, 4)
        #rsamp_sink = gr.file_sink(gr.sizeof_float, "rsamp.dat")
        #self.connect(rsamp, rsamp_sink)

        #create a sink representing the audio card
        audio_sink = audio.sink(int(48000))

        # now wire it all together
        #use this line to receive from usrp
        #self.connect (src,chan_filter)
        #use this line to playback recorded data
        self.connect(am_usrp_source, chan_filter)
        self.connect(chan_filter, my_agc)
        self.connect(my_agc, magblock)
        self.connect(magblock, volumecontrol)
        self.connect(volumecontrol, audio_filter)
        self.connect(audio_filter, rsamp)
        self.connect(rsamp, (audio_sink, 0))

        if 1:
            pre_demod = fftsink2.fft_sink_c(panel,
                                            title="USRP Output",
                                            ref_level=70,
                                            fft_size=512,
                                            sample_rate=usrp_rate)
            self.connect(am_usrp_source, pre_demod)
            vbox.Add(pre_demod.win, 1, wx.EXPAND)
            #Sets offset for floating pointer in FFT window
            pre_demod.win.set_baseband_freq(-actual_shift_freq)

        if False:
            post_demod = fftsink2.fft_sink_c(panel,
                                             title="Post Channel Filter",
                                             fft_size=256,
                                             sample_rate=lpf_rate)
            self.connect(chan_filter, post_demod)
            vbox.Add(post_demod.win, 1, wx.EXPAND)

        if False:
            post_filt = fftsink2.fft_sink_f(panel,
                                            title="Post Envelope Detector",
                                            fft_size=512,
                                            sample_rate=lpf_rate)
            self.connect(magblock, post_filt)
            vbox.Add(post_filt.win, 1, wx.EXPAND)
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 8
        self.nfilts = nfilts = 128
        self.timing_loop_bandwidth = timing_loop_bandwidth = .063
        self.samp_rate = samp_rate = 10000000
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 45*nfilts)
        self.noise_voltage = noise_voltage = .063
        self.freq_offset = freq_offset = 0
        self.code2 = code2 = '11011010110111011000110011110101100010010011110111'
        self.code1 = code1 = '010110011011101100010101011111101001001110001011010001101010001'
        
        self.QPSK = QPSK = digital.constellation_calcdist(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 1).base()
        

        ##################################################
        # Blocks
        ##################################################
        self._timing_loop_bandwidth_range = Range(.001, .2, .001, .063, 200)
        self._timing_loop_bandwidth_win = RangeWidget(self._timing_loop_bandwidth_range, self.set_timing_loop_bandwidth, "timing_loop_bandwidth", "counter_slider", float)
        self.top_grid_layout.addWidget(self._timing_loop_bandwidth_win, 0,0,1,1)
        self._noise_voltage_range = Range(0.0, 1, .001, .063, 200)
        self._noise_voltage_win = RangeWidget(self._noise_voltage_range, self.set_noise_voltage, "noise_voltage", "counter_slider", float)
        self.top_grid_layout.addWidget(self._noise_voltage_win, 0,1,1,1)
        self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f(
        	15, #size
        	samp_rate, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0_0.set_y_axis(-1, 1)
        
        self.qtgui_time_sink_x_0_0_0.set_y_label('Amplitude', "")
        
        self.qtgui_time_sink_x_0_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0_0_0.enable_grid(True)
        self.qtgui_time_sink_x_0_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_0_0_0.disable_legend()
        
        labels = ['Real part', 'Imaginary Part', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [0, 0, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [0, 0, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_win, 2,1, 1, 1)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c(
        	15, #size
        	samp_rate, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)
        
        self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "")
        
        self.qtgui_time_sink_x_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0_0.enable_grid(True)
        self.qtgui_time_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_0_0.disable_legend()
        
        labels = ['Real part', 'Imaginary Part', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [0, 0, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [0, 0, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(2*1):
            if len(labels[i]) == 0:
                if(i % 2 == 0):
                    self.qtgui_time_sink_x_0_0.set_line_label(i, "Re{{Data {0}}}".format(i/2))
                else:
                    self.qtgui_time_sink_x_0_0.set_line_label(i, "Im{{Data {0}}}".format(i/2))
            else:
                self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 1, 1, 1, 1)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
        	1024, #size
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(True)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)
        
        if not True:
          self.qtgui_const_sink_x_0.disable_legend()
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "red", "red", "red",
                  "red", "red", "red", "red", "red"]
        styles = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0,
                   0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 1,0,1,1)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bandwidth, (rrc_taps), nfilts, nfilts/2, 1.5, 1)
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_constellation_modulator_0 = digital.generic_mod(
          constellation=QPSK,
          differential=False,
          samples_per_symbol=sps,
          pre_diff_code=True,
          excess_bw=0.35,
          verbose=False,
          log=False,
          )
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(QPSK)
        self.channels_channel_model_0 = channels.channel_model(
        	noise_voltage=noise_voltage,
        	frequency_offset=freq_offset/samp_rate,
        	epsilon=1.0,
        	taps=(1, ),
        	noise_seed=0,
        	block_tags=False
        )
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 1)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, '/Users/ampoulog/Documents/gnuradio/Wireless-communication-systems-Lab/Lab3/example6/cat.png', True)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, '/Users/ampoulog/Documents/gnuradio/Wireless-communication-systems-Lab/Lab3/example10/hello_out.png', False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.blks2_packet_encoder_0_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder(
        		samples_per_symbol=1,
        		bits_per_symbol=1,
        		preamble='',
        		access_code=code1,
        		pad_for_usrp=False,
        	),
        	payload_length=4,
        )
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder(
        		access_code=code1,
        		threshold=-1,
        		callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload),
        	),
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.blks2_packet_encoder_0_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0))    
        self.connect((self.blocks_char_to_float_0, 0), (self.blocks_float_to_char_0, 0))    
        self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0_0_0, 0))    
        self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0_0, 0))    
        self.connect((self.blocks_float_to_char_0, 0), (self.digital_diff_decoder_bb_0, 0))    
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_diff_encoder_bb_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.digital_constellation_modulator_0, 0))    
        self.connect((self.blocks_throttle_0_0, 0), (self.blks2_packet_encoder_0_0, 0))    
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.channels_channel_model_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))    
        self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_char_to_float_0, 0))    
        self.connect((self.digital_constellation_modulator_0, 0), (self.channels_channel_model_0, 0))    
        self.connect((self.digital_diff_decoder_bb_0, 0), (self.blks2_packet_decoder_0, 0))    
        self.connect((self.digital_diff_encoder_bb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0))    
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_constellation_decoder_cb_0, 0))    
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_const_sink_x_0, 0))    
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_time_sink_x_0_0, 0))    
Beispiel #56
0
    def __init__(self, baud=20000, deviation=25000, frequency_shift=0, read_file='', write_file='', interpolate=1):
        gr.top_block.__init__(self, "Tpms Fsk")

        ##################################################
        # Parameters
        ##################################################
        self.baud = baud
        self.deviation = deviation
        self.frequency_shift = frequency_shift
        self.read_file = read_file
        self.write_file = write_file
        self.interpolate = interpolate

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2.5e5
        self.sensivity = sensivity = deviation/(samp_rate*0.16)
        self.samp_per_symbol = samp_per_symbol = samp_rate/baud

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=interpolate,
                decimation=1,
                taps=None,
                fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (1, ), frequency_shift, samp_rate)
        self.blocks_uchar_to_float_0 = blocks.uchar_to_float()
        self.blocks_streams_to_stream_0 = blocks.streams_to_stream(gr.sizeof_char*1, 2)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, int(samp_per_symbol))
        self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff((127, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((127, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1.0/127, ))
        self.blocks_float_to_uchar_0_0 = blocks.float_to_uchar()
        self.blocks_float_to_uchar_0 = blocks.float_to_uchar()
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, read_file, False)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, write_file, False)
        self.blocks_file_sink_0_0.set_unbuffered(False)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_add_const_vxx_1_0 = blocks.add_const_vff((1, ))
        self.blocks_add_const_vxx_1 = blocks.add_const_vff((1, ))
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, ))
        self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(sensivity)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_frequency_modulator_fc_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_repeat_0, 0))
        self.connect((self.blocks_add_const_vxx_1, 0), (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_add_const_vxx_1_0, 0), (self.blocks_multiply_const_vxx_1_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_add_const_vxx_1, 0))
        self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_add_const_vxx_1_0, 0))
        self.connect((self.blocks_file_source_0, 0), (self.blocks_uchar_to_float_0, 0))
        self.connect((self.blocks_float_to_uchar_0, 0), (self.blocks_streams_to_stream_0, 0))
        self.connect((self.blocks_float_to_uchar_0_0, 0), (self.blocks_streams_to_stream_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_float_to_uchar_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blocks_float_to_uchar_0_0, 0))
        self.connect((self.blocks_repeat_0, 0), (self.analog_frequency_modulator_fc_0, 0))
        self.connect((self.blocks_streams_to_stream_0, 0), (self.blocks_file_sink_0_0, 0))
        self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_complex_to_float_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 20e6
        self.freq = freq = 2400e6
        self.bandwidth = bandwidth = 1.5e6

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_1 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               "bladerf=179")
        self.osmosdr_source_1.set_sample_rate(samp_rate)
        self.osmosdr_source_1.set_center_freq(freq, 0)
        self.osmosdr_source_1.set_freq_corr(0, 0)
        self.osmosdr_source_1.set_dc_offset_mode(0, 0)
        self.osmosdr_source_1.set_iq_balance_mode(0, 0)
        self.osmosdr_source_1.set_gain_mode(True, 0)
        self.osmosdr_source_1.set_gain(15, 0)
        self.osmosdr_source_1.set_if_gain(0, 0)
        self.osmosdr_source_1.set_bb_gain(0, 0)
        self.osmosdr_source_1.set_antenna('RX', 0)
        self.osmosdr_source_1.set_bandwidth(bandwidth, 0)

        self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " +
                                           "bladerf=32a")
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(freq, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(25, 0)
        self.osmosdr_sink_0.set_if_gain(0, 0)
        self.osmosdr_sink_0.set_bb_gain(0, 0)
        self.osmosdr_sink_0.set_antenna('TX', 0)
        self.osmosdr_sink_0.set_bandwidth(bandwidth, 0)

        self.correctiq_correctiq_0 = correctiq.correctiq()
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_source_0_0 = blocks.file_source(
            gr.sizeof_float * 1, '/dev/shm/QPulse.dat', True)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_float * 1,
                                                       '/dev/shm/IPulse.dat',
                                                       True)
        self.blocks_file_sink_0_0_0_0_0_0 = blocks.file_sink(
            gr.sizeof_float * 1, '/dev/shm/ruidoR.dat', False)
        self.blocks_file_sink_0_0_0_0_0_0.set_unbuffered(True)
        self.blocks_file_sink_0_0_0_0_0 = blocks.file_sink(
            gr.sizeof_float * 1, '/dev/shm/ruidoI.dat', False)
        self.blocks_file_sink_0_0_0_0_0.set_unbuffered(True)
        self.blocks_file_sink_0_0_0 = blocks.file_sink(gr.sizeof_float * 1,
                                                       '/dev/shm/dataI.dat',
                                                       False)
        self.blocks_file_sink_0_0_0.set_unbuffered(True)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_float * 1,
                                                     '/dev/shm/dataR.dat',
                                                     False)
        self.blocks_file_sink_0_0.set_unbuffered(True)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_file_sink_0_0_0_0_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_file_sink_0_0_0_0_0_0, 0))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.blocks_file_sink_0_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_file_sink_0_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_file_source_0_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.osmosdr_sink_0, 0))
        self.connect((self.correctiq_correctiq_0, 0),
                     (self.blocks_complex_to_imag_0, 0))
        self.connect((self.correctiq_correctiq_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.osmosdr_source_1, 0),
                     (self.correctiq_correctiq_0, 0))
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Dvbs2 Tx")

        ##################################################
        # Variables
        ##################################################
        self.symbol_rate = symbol_rate = 5000000
        self.taps = taps = 100
        self.samp_rate = samp_rate = symbol_rate * 2
        self.rolloff = rolloff = 0.2
        self.frequency = frequency = 1280e6

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=frequency,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=True,
            avg_alpha=0.13333,
            title="FFT Plot",
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.fft_filter_xxx_0 = filter.fft_filter_ccc(
            1, (firdes.root_raised_cosine(1.0, samp_rate, samp_rate / 2,
                                          rolloff, taps)), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.dtv_dvbs2_physical_cc_0 = dtv.dvbs2_physical_cc(
            dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.MOD_16APSK, dtv.PILOTS_ON, 0)
        self.dtv_dvbs2_modulator_bc_0 = dtv.dvbs2_modulator_bc(
            dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.MOD_16APSK,
            dtv.INTERPOLATION_OFF)
        self.dtv_dvbs2_interleaver_bb_0 = dtv.dvbs2_interleaver_bb(
            dtv.FECFRAME_NORMAL, dtv.C_OTHER, dtv.MOD_16APSK)
        self.dtv_dvb_ldpc_bb_0 = dtv.dvb_ldpc_bb(dtv.STANDARD_DVBS2,
                                                 dtv.FECFRAME_NORMAL,
                                                 dtv.C9_10, dtv.MOD_OTHER)
        self.dtv_dvb_bch_bb_0 = dtv.dvb_bch_bb(
            dtv.STANDARD_DVBS2,
            dtv.FECFRAME_NORMAL,
            dtv.C9_10,
        )
        self.dtv_dvb_bbscrambler_bb_0 = dtv.dvb_bbscrambler_bb(
            dtv.STANDARD_DVBS2,
            dtv.FECFRAME_NORMAL,
            dtv.C9_10,
        )
        self.dtv_dvb_bbheader_bb_0 = dtv.dvb_bbheader_bb(
            dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.RO_0_20,
            dtv.INPUTMODE_NORMAL, dtv.INBAND_OFF, 168, 4000000)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1, "/Volumes/work/run/shm/adv16apsk910.ts", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0),
                     (self.dtv_dvb_bbheader_bb_0, 0))
        self.connect((self.dtv_dvb_bbheader_bb_0, 0),
                     (self.dtv_dvb_bbscrambler_bb_0, 0))
        self.connect((self.dtv_dvb_bbscrambler_bb_0, 0),
                     (self.dtv_dvb_bch_bb_0, 0))
        self.connect((self.dtv_dvb_bch_bb_0, 0), (self.dtv_dvb_ldpc_bb_0, 0))
        self.connect((self.dtv_dvb_ldpc_bb_0, 0),
                     (self.dtv_dvbs2_interleaver_bb_0, 0))
        self.connect((self.dtv_dvbs2_interleaver_bb_0, 0),
                     (self.dtv_dvbs2_modulator_bc_0, 0))
        self.connect((self.dtv_dvbs2_modulator_bc_0, 0),
                     (self.dtv_dvbs2_physical_cc_0, 0))
        self.connect((self.dtv_dvbs2_physical_cc_0, 0),
                     (self.fft_filter_xxx_0, 0))
        self.connect((self.fft_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0))
Beispiel #59
0
    def run(self, suites_to_run, pause=False):
        for test_suite in self.test_suites:
            # Skip test suites that we don't want to run
            if suites_to_run != [] and (not test_suite in suites_to_run):
                continue

            print("[+] Testing suite: '%s'" % test_suite)
            summary = TestSummary(suite=test_suite, pause=pause)

            # Get all metadata files associated with the suite
            get_mtime = lambda f: os.stat(
                os.path.join(self.test_suites_directory, test_suite, f)
            ).st_mtime
            metadata_files = [
                os.path.join(self.test_suites_directory, test_suite, x)
                for x in sorted(os.listdir(
                    os.path.join(self.test_suites_directory, test_suite)),
                                key=get_mtime) if x.endswith('.sigmf-meta')
            ]

            # Parse metadata files
            for metadata_file in metadata_files:
                print("[+] %s" % metadata_file)
                data_file = os.path.splitext(metadata_file)[0] + '.sigmf-data'
                # Load sigmf data TODO abstract
                f = open(metadata_file, 'r')
                sigmf = SigMFFile(metadata=f.read())
                if not sigmf.validate():
                    raise Exception("Invalid SigMF format")
                global_meta = sigmf.get_global_info()
                capture_meta = sigmf.get_capture_info(0)
                f.close()

                # Initialize test parameters
                sample_rate = global_meta["core:sample_rate"]

                # Get LoRa configuration
                capture_freq = capture_meta["core:frequency"]
                if "lora:frequency_offset" in capture_meta:
                    frequency_offset = capture_meta["lora:frequency_offset"]
                else:
                    frequency_offset = 0
                transmit_freq = capture_meta["lora:frequency"]
                sf = capture_meta["lora:sf"]
                cr = capture_meta["lora:cr"]
                bw = capture_meta["lora:bw"]
                prlen = capture_meta["lora:prlen"]
                crc = capture_meta["lora:crc"]
                implicit = capture_meta["lora:implicit"]
                lora_config = LoRaConfig(transmit_freq, sf, cr, bw, prlen, crc,
                                         implicit)

                # Get test case configuration
                payload = capture_meta["test:expected"]
                times = capture_meta["test:times"]
                test = Test(payload, times)

                # Build flowgraph
                tb = gr.top_block()
                file_source = blocks.file_source(gr.sizeof_gr_complex,
                                                 data_file, False)
                lora_receiver = lora.lora_receiver(sample_rate, capture_freq,
                                                   [868100000], sf, 1000000,
                                                   False, 4, True)
                throttle = blocks.throttle(gr.sizeof_gr_complex, sample_rate,
                                           True)
                message_socket_sink = lora.message_socket_sink(
                    "127.0.0.1", 40868, False, False)
                freq_xlating_fir_filter = filter.freq_xlating_fir_filter_ccc(
                    1, (firdes.low_pass(1, sample_rate, 200000, 100000,
                                        firdes.WIN_HAMMING, 6.67)),
                    frequency_offset, sample_rate)

                # Make connections
                tb.connect((file_source, 0), (throttle, 0))
                tb.connect((throttle, 0), (freq_xlating_fir_filter, 0))
                tb.connect((freq_xlating_fir_filter, 0), (lora_receiver, 0))
                tb.msg_connect((lora_receiver, 'frames'),
                               (message_socket_sink, 'in'))
                tb.start()
                tb.wait()

                decoded_data = self.get_payloads(
                    times)  # Output from the flowgraph
                summary.add(TestResult(decoded_data=decoded_data,
                                       lora_config=lora_config,
                                       test=test),
                            print_intermediate=True)
            # Finally, export the result for the suite
            summary.export_summary(path=self.reports_directory)
Beispiel #60
0
 def open_ifile2(self, capture_rate, file_name):
     source = blocks.file_source(gr.sizeof_gr_complex, file_name, False)
     throttle = blocks.throttle(gr.sizeof_gr_complex, capture_rate)
     self.connect(source, throttle)
     self.__build_graph(throttle, capture_rate)