Attached is my file (messy) that I trimmed down and was working with.
It is really just usrp_siggen and usrp_oscope combined.

On 7/13/07, Jeffrey Karrels <[EMAIL PROTECTED]> wrote:
Is there any problem of connecting a usrp.source_c to an usrp.sink_c?
I reverted to try and simply connect the two in software when
something else I was trying was not working. When I start running my
script I see it attach to my subdevices (rfx1800_rx, lftx), but then
completes the script right away.  I was thinking I may need some delay
between establishing the source and sinking it, but that didn't seem
to help. Any suggestions

Thanks
Jeff

#!/usr/bin/env python

from gnuradio import gr, gru
from gnuradio import usrp
from gnuradio.eng_option import eng_option
from gnuradio import eng_notation
from optparse import OptionParser
import sys




class my_graph(gr.flow_graph):
    def __init__ (self):
        gr.flow_graph.__init__(self)
        
        # controllable values
        self.interp = 64
        self.waveform_ampl = 1000
        self.waveform_freq = 100.0e3
        self.waveform_offset = 0
        self._instantiate_blocks ()

    def usb_freq (self):
        return self.u.dac_freq() / self.interp

    def usb_throughput (self):
        return self.usb_freq () * 4
        

    def set_waveform_ampl (self, ampl):
        self.waveform_ampl = ampl


    def set_waveform_freq (self, freq):
        self.waveform_freq = freq

        
    def set_waveform_offset (self, offset):
        self.waveform_offset = offset


    def set_interpolator (self, interp):
        self.interp = interp
        self.u_sink.set_interp_rate (interp)
	self.u_source.set_decim_rate (interp)
	
    def _instantiate_blocks (self):
        self.u_source = usrp.source_c(0,decim_rate=self.interp)
        self.u_sink = usrp.sink_c (0, self.interp)
	
	# constant
	xcf = 150e3
	xtw = 50e3
	sps = 64e6/64
	self.xt = gr.firdes.low_pass(1.0, sps, xcf, xtw,gr.firdes.WIN_HAMMING)
	self.xf = gr.fir_filter_ccf(1, self.xt)

    def _configure_graph (self, type):
        was_running = self.is_running ()
        if was_running:
            self.stop ()
        self.disconnect_all ()

        self.connect (self.u_source, self.xf, self.u_sink)

        if was_running:
            self.start ()

	    
	    
	    

    def set_rx_freq(self, target_freq):
        rx = self.u_source.tune(self.subdev_rx._which, self.subdev_rx, target_freq)
        if rx:
            print "rx.baseband_freq =", eng_notation.num_to_str(rx.baseband_freq)
            print "rx.dxc_freq      =", eng_notation.num_to_str(rx.dxc_freq)
            print "rx.residual_freq =", eng_notation.num_to_str(rx.residual_freq)
            print "rx.inverted      =", rx.inverted
            return True

        return False

    def set_tx_freq(self, target_freq):
        tx = self.u_sink.tune(self.subdev_tx._which, self.subdev_tx, target_freq)
        if tx:
            print "tx.baseband_freq =", eng_notation.num_to_str(tx.baseband_freq)
            print "tx.dxc_freq      =", eng_notation.num_to_str(tx.dxc_freq)
            print "tx.residual_freq =", eng_notation.num_to_str(tx.residual_freq)
            print "tx.inverted      =", tx.inverted
            return True

        return False



def main ():
    parser = OptionParser (option_class=eng_option)
    parser.add_option ("-R", "--rx-subdev-spec", type="subdev", default=(0, 0),
                       help="select USRP Tx side A or B")    
    parser.add_option ("-T", "--tx-subdev-spec", type="subdev", default=(0, 0),
                       help="select USRP Tx side A or B")		       
    parser.add_option ("-f", "--rf-freq", type="eng_float", default=None,
                       help="set RF center frequency to FREQ")
    parser.add_option ("-i", "--interp", type="int", default=64,
                       help="set fgpa interpolation rate to INTERP [default=%default]")



    parser.add_option ("-w", "--waveform-freq", type="eng_float", default=100e3,
                       help="set waveform frequency to FREQ [default=%default]")
    parser.add_option ("-a", "--amplitude", type="eng_float", default=16e3,
                       help="set waveform amplitude to AMPLITUDE [default=%default]", metavar="AMPL")
    parser.add_option ("-o", "--offset", type="eng_float", default=0,
                       help="set waveform offset to OFFSET [default=%default]")
    (options, args) = parser.parse_args ()

    if len(args) != 0:
        parser.print_help()
        raise SystemExit

    if options.rf_freq is None:
        sys.stderr.write("usrp_siggen: must specify RF center frequency with -f RF_FREQ\n")
        parser.print_help()
        raise SystemExit

    fg = my_graph()
    fg.set_interpolator (options.interp)
    fg.set_waveform_freq (options.waveform_freq)
    fg.set_waveform_ampl (options.amplitude)
    fg.set_waveform_offset (options.offset)



    # determine the daughterboard subdevices we're using
    if options.rx_subdev_spec is None:
        options.rx_subdev_spec = usrp.pick_rx_subdevice(fg.u_source)
	    
    if options.tx_subdev_spec is None:
        options.tx_subdev_spec = usrp.pick_tx_subdevice(fg.u_sink)
	
    # determine mux settings
    m_rx = usrp.determine_rx_mux_value(fg.u_source, options.rx_subdev_spec)
    m_tx = usrp.determine_tx_mux_value(fg.u_sink, options.tx_subdev_spec)
 
    #Set mux
    fg.u_source.set_mux(m_rx)
    fg.u_sink.set_mux(m_tx)
    
    
    #select subdevice
    fg.subdev_rx = usrp.selected_subdev(fg.u_source, options.rx_subdev_spec)
    fg.subdev_tx = usrp.selected_subdev(fg.u_sink, options.tx_subdev_spec)
    
    
    #set gain
    fg.subdev_rx.set_gain(50)
    fg.subdev_tx.set_gain(fg.subdev_tx.gain_range()[1])    # set max Tx gain

    print "Using RX d'board %s" % (fg.subdev_rx.side_and_name(),)    
    if not fg.set_rx_freq(1955.0e6 - 5.7207e3):
	sys.stderr.write('Failed to set Rx frequency\n')
	raise SystemExit
    fg.subdev_rx.set_enable(True)



    print "\n\nUsing TX d'board %s" % (fg.subdev_tx.side_and_name(),)
    if not fg.set_tx_freq(options.rf_freq):
        sys.stderr.write('Failed to set Tx frequency\n')
        raise SystemExit    
    
    fg.subdev_tx.set_enable(True)

    try:
        fg.run()
    except KeyboardInterrupt:
        pass

if __name__ == '__main__':
    main ()
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to