Example #1
0
	def __init__(self, options, rx_callback):
		phy_base.__init__(self, options, rx_callback)

		# Receive chain
		demod_class = phy_psk.DEMODS[options.psk_modulation]
		demod_kwargs = demod_class.extract_kwargs_from_options(options)
		self._rx_demod = blks2.demod_pkts(
				demod_class(**demod_kwargs),
				callback=self._rx_callback)
		sw_decim = 1
		self._rx_chan_filt = gr.fft_filter_ccc(
				sw_decim, 
				gr.firdes.low_pass (
					1.0,								# gain
					sw_decim * self._rx_demod._demodulator.samples_per_symbol(),	# sampling rate
					1.0,								# midpoint of trans. band
					0.5,								# width of trans. band
					gr.firdes.WIN_HANN))						# filter type
		self.connect(self, self._rx_chan_filt, self._rx_demod)

		# Trasmit chain
		mod_class = phy_psk.MODS[options.psk_modulation]
		mod_kwargs = mod_class.extract_kwargs_from_options(options)
		self._tx_mod = blks2.mod_pkts(
				mod_class(**mod_kwargs),
				pad_for_usrp=True)
		self.connect(self._tx_mod, gr.kludge_copy(gr.sizeof_gr_complex), self)
Example #2
0
    def __init__(self, outputfile, options):
        gr.top_block.__init__(self)

        if options.dsp:
            self.dst = audio.sink( options.dsp_sample_rate )
        else:
            self.dst = gr.wavfile_sink(outputfile, 2, options.wav_sample_rate, 16)

        self.c_to_iq = gr.complex_to_float()
        self.connect( (self.c_to_iq, 0), (self.dst, 0))
        self.connect( (self.c_to_iq, 1), (self.dst, 1))

        # settings for the modulator: /usr/local/lib/python2.5/site-packages/gnuradio/blks2impl/gmsk.py

        self.modulator = blks2.gmsk_mod(samples_per_symbol=options.samples_per_symbol)
        self.pkt_queue = blks2.mod_pkts( modulator=self.modulator )

        if options.carrier_frequency == 0:
            self.mixer = self.pkt_queue
        else:
            self.mixer   = gr.multiply_vcc(1)
            self.carrier = gr.sig_source_c( options.carrier_sample_rate, gr.GR_SIN_WAVE, options.carrier_frequency, 1.0 )
            self.lowpass = gr.fir_filter_ccf(1, firdes.low_pass(1, 48000, 48000/(2*options.samples_per_symbol)+500, 500, firdes.WIN_HAMMING, 6.76))
            self.connect(self.pkt_queue, self.lowpass, (self.mixer, 0) )
            self.connect(self.carrier,   (self.mixer, 1) )

        self.amp = gr.multiply_const_cc(1); self.amp.set_k(options.amp_amplitude)
        self.connect(self.mixer, self.amp, self.c_to_iq)

        if options.debug_wavs:
            from myblks import debugwav
            self._dpassw = debugwav("tx_passband", options)
            self._dprefw = debugwav("tx_prefband", options)
            self._dbasew = debugwav("tx_baseband", options)
            self.connect(self.amp, self._dpassw)
            self.connect(self.lowpass, self._dbasew)
            self.connect(self.pkt_queue, self._dprefw)

        if options.debug_files:
            self._dpassf = gr.file_sink(gr.sizeof_gr_complex*1, "debug_tx_passband.d_c")
            self._dpreff = gr.file_sink(gr.sizeof_gr_complex*1, "debug_tx_prefband.d_c")
            self._dbasef = gr.file_sink(gr.sizeof_gr_complex*1, "debug_tx_baseband.d_c")
            self.connect(self.amp, self._dpassf)
            self.connect(self.pkt_queue, self._dpreff)
            self.connect(self.lowpass, self._dbasef)
Example #3
0
    def __init__(self, modulator_class, options):
        '''
        See below for what options should hold
        '''
        gr.hier_block2.__init__(
            self,
            "transmit_path",
            gr.io_signature(0, 0, 0),  # Input signature
            gr.io_signature(1, 1, gr.sizeof_gr_complex))  # Output signature

        options = copy.copy(
            options)  # make a copy so we can destructively modify

        self._verbose = options.verbose
        self._tx_amplitude = options.tx_amplitude  # digital amplitude sent to USRP
        self._bitrate = options.bitrate  # desired bit rate
        self._samples_per_symbol = options.samples_per_symbol  # desired samples/baud

        self._modulator_class = modulator_class  # the modulator_class we are using

        # Get mod_kwargs
        mod_kwargs = self._modulator_class.extract_kwargs_from_options(options)

        # transmitter
        modulator = self._modulator_class(**mod_kwargs)
        self.packet_transmitter = \
            blks2.mod_pkts(modulator,
                           access_code=None,
                           msgq_limit=4,
                           pad_for_usrp=True)

        self.amp = gr.multiply_const_cc(1)
        self.set_tx_amplitude(self._tx_amplitude)

        # Display some information about the setup
        if self._verbose:
            self._print_verbage()

        # Connect components in the flowgraph
        self.connect(self.packet_transmitter, self.amp, self)
    def __init__(self, modulator_class, options):
        '''
        See below for what options should hold
        '''
	gr.hier_block2.__init__(self, "transmit_path",
				gr.io_signature(0, 0, 0),                    # Input signature
				gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature
        
        options = copy.copy(options)    # make a copy so we can destructively modify

        self._verbose            = options.verbose
        self._tx_amplitude       = options.tx_amplitude    # digital amplitude sent to USRP
        self._bitrate            = options.bitrate         # desired bit rate
        self._samples_per_symbol = options.samples_per_symbol  # desired samples/baud

        self._modulator_class = modulator_class         # the modulator_class we are using

        # Get mod_kwargs
        mod_kwargs = self._modulator_class.extract_kwargs_from_options(options)
    
        # transmitter
	print self._modulator_class
	print mod_kwargs
	modulator = self._modulator_class(**mod_kwargs)
        self.packet_transmitter = \
            blks2.mod_pkts(modulator,
                           access_code=None,
                           msgq_limit=4,
                           pad_for_usrp=True)

        self.amp = gr.multiply_const_cc(1)
        self.set_tx_amplitude(self._tx_amplitude)

        # Display some information about the setup
        if self._verbose:
            self._print_verbage()

        # Connect components in the flowgraph
        self.connect(self.packet_transmitter, self.amp, self)
Example #5
0
    def __init__(self, modulator, demodulator, access_code=None, hint="addr=192.168.10.2"):
        gr.hier_block2.__init__(self, "Physical Layer", gr.io_signature(0, 0, 0), gr.io_signature(0, 0, 0))
        if access_code is "master":
            self.rx_offset = 8e6
            access_code = None
        elif access_code is "slave":
            self.rx_offset = -8e6
            access_code = None
        else:
            self.rx_offset = 0

        # create TX/RX
        self.u_tx = uhd.single_usrp_sink(hint, io_type=uhd.io_type_t.COMPLEX_FLOAT32, num_channels=1)
        self.u_rx = uhd.single_usrp_source(hint, io_type=uhd.io_type_t.COMPLEX_FLOAT32, num_channels=1)

        self.access_code = access_code

        # create packetmods
        self.pkt_mod = blks2.mod_pkts(modulator, pad_for_usrp=True, access_code=self.access_code)
        self.pkt_demod = blks2.demod_pkts(demodulator, callback=self.rx_callback, access_code=self.access_code)

        self.connect(self.u_rx, self.pkt_demod)
        self.connect(self.pkt_mod, self.u_tx)
    def __init__(self, modulator_class, options):
        '''
        See below for what options should hold
        '''
	gr.hier_block2.__init__(self, "transmit_path",
                                gr.io_signature(0, 0, 0), # Input signature
                                gr.io_signature(0, 0, 0)) # Output signature

        options = copy.copy(options)    # make a copy so we can destructively modify

        self._verbose            = options.verbose
        self._tx_freq            = options.tx_freq         # tranmitter's center frequency
        self._tx_amplitude       = options.tx_amplitude    # digital amplitude sent to USRP
        self._tx_subdev_spec     = options.tx_subdev_spec  # daughterboard to use
        self._bitrate            = options.bitrate         # desired bit rate
        self._interp             = options.interp          # interpolating rate for the USRP (prelim)
        self._samples_per_symbol = options.samples_per_symbol  # desired samples/baud
        self._fusb_block_size    = options.fusb_block_size # usb info for USRP
        self._fusb_nblocks       = options.fusb_nblocks    # usb info for USRP
        self._use_whitener_offset = options.use_whitener_offset # increment start of whitener XOR data
        
        self._modulator_class = modulator_class         # the modulator_class we are using
    
        if self._tx_freq is None:
            sys.stderr.write("-f FREQ or --freq FREQ or --tx-freq FREQ must be specified\n")
            raise SystemExit

        # Set up USRP sink; also adjusts interp, samples_per_symbol, and bitrate
        self._setup_usrp_sink()

        # copy the final answers back into options for use by modulator
        options.samples_per_symbol = self._samples_per_symbol
        options.bitrate = self._bitrate
        options.interp = self._interp

        # Get mod_kwargs
        mod_kwargs = self._modulator_class.extract_kwargs_from_options(options)

        # Set center frequency of USRP
        ok = self.set_freq(self._tx_freq)
        if not ok:
            print "Failed to set Tx frequency to %s" % (eng_notation.num_to_str(self._tx_freq),)
            raise ValueError
    
        # transmitter
        self.packet_transmitter = \
            blks2.mod_pkts(self._modulator_class(**mod_kwargs),
                           access_code=None,
                           msgq_limit=4,
                           pad_for_usrp=True,
                           use_whitener_offset=options.use_whitener_offset)


        # Set the USRP for maximum transmit gain
        # (Note that on the RFX cards this is a nop.)
        self.set_gain(self.subdev.gain_range()[1])

        self.amp = gr.multiply_const_cc(1)
        self.set_tx_amplitude(self._tx_amplitude)

        # enable Auto Transmit/Receive switching
        self.set_auto_tr(True)

        # Display some information about the setup
        if self._verbose:
            self._print_verbage()

        # Create and setup transmit path flow graph
        self.connect(self.packet_transmitter, self.amp, self.u)