discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss-gnuradio] Simple program to transmit on the USRP2


From: hjaffer
Subject: [Discuss-gnuradio] Simple program to transmit on the USRP2
Date: Tue, 28 Apr 2009 10:07:54 -0700 (PDT)

Hello all,

I'm trying to create a simple transmit file example with the USRP2. There
already is a provided example program that records data to a file, but there
isn't any program that transmits the same file. 

The program below is what I have (relevant parts shown). Does anybody know
what's wrong with it? 

I appreciate any help anybody can provide. 

Hafeez




#!/usr/bin/env python

"""
Read samples from file (e.g. something captured with usrp_rx_cfile.py) and
transmit via USRP2
input single precision complex float values or complex short values
(interleaved 16 bit signed short integers).

"""

from gnuradio import gr, eng_notation
from gnuradio import audio
from gnuradio import usrp2
from gnuradio.eng_option import eng_option
from optparse import OptionParser
import sys

n2s = eng_notation.num_to_str

class rx_cfile_block(gr.top_block):
    def set_freq(self, target_freq):
        """
        Set the center frequency we're interested in.
        @param target_freq: frequency in Hz
        @rypte: bool
        Tuning is a two step process.  First we ask the front-end to
        tune as close to the desired frequency as it can.  Then we use
        the result of that operation and our target_frequency to
        determine the value for the digital up converter.  Finally, we feed
        any residual_freq to the s/w freq translater.
        """
        tr = self.u.set_center_freq(target_freq)
        if tr == None:
           sys.stderr.write('Failed to set center frequency\n')
           raise SystemExit, 1
        return tr

    def set_gain(self, gain):
        self.gain = gain
        self.u.set_gain(gain)

    def spb(self):
        return self._spb


    def interp(self):
        return self._interp


    def __init__(self, options, filename):
        gr.top_block.__init__(self)

        # Create a USRP2 source
        if options.input_shorts:
            self._u = usrp2.source_16sc(options.interface, options.mac_addr)
            self._sink = gr.file_sink(gr.sizeof_short*2, filename)
            self.src = gr.file_sink(gr.sizeof_short*2, filename)
        else:
            self._u = usrp2.source_32fc(options.interface, options.mac_addr)
            self._sink = gr.file_sink(gr.sizeof_gr_complex, filename)
            self.src = gr.file_sink(gr.sizeof_gr_complex, filename)

        # sink
        if options.input_shorts:
           self.u = usrp2.sink_16sc(options.interface, self._u.mac_addr())
        else:
           self.u = usrp2.sink_32fc(options.interface, self._u.mac_addr())
        dac_rate = self.u.dac_rate();
        self._spb = options.spb
        self._interp=int(options.interp)
        self.u.set_interp(self._interp)

        # build the graph
        #tb = my_graph(options.interp, options.spb, options.barker,
options.interface, options.mac_addr)

        tr = self.set_freq(options.freq)

        usrp = self.u

        # start flow graph
        #self.start()

        # build the graph
        self.amp = gr.multiply_const_cc(10.0 ** (options.gain / 20.0))
        if options.bandwidth is None:
            self.connect(self.src, self.amp, self._u)

-- 
View this message in context: 
http://www.nabble.com/Simple-program-to-transmit-on-the-USRP2-tp23162069p23162069.html
Sent from the GnuRadio mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]