discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] how to stop the top_block and restart signal tran


From: Yan Nie
Subject: Re: [Discuss-gnuradio] how to stop the top_block and restart signal transmission
Date: Fri, 25 Feb 2011 13:10:29 -0500

Really appreciate your reply, Jason! I tried the approach recommended by using 
grc_usrp.simple_sink_s to take the place of usrp.sink_s. Then, I called the 
set_enable() function on simple_sink_s at the scheduler part to disable the 
transmitter after the top_block starts to run. An attributeError is given, 
which said 'gr_hier_block2' object has no attribute 'set_enable'. What's the 
problem would be? 

I really appreciate all of your help!

Thanks,
Yan

The code that I setup USRP sink is:

#!usr/bin/env python

from gnuradio import gr, usrp, eng_notation
from grc_gnuradio import usrp as grc_usrp;
n2s = eng_notation.num_to_str

_dac_rate = 128e6

class simple_sink_s(gr.hier_block2):

    def __init__(self, which=0, subdev_spec='A', if_rate=25e3, freq=0.0, 
verbose=False):
        gr.hier_block2.__init__(self,
                    "usrp_sink_c",
                    gr.io_signature(1,1,gr.sizeof_short),
                    gr.io_signature(0,0,0)
                                    )
        self._verbose = verbose
        self._u = grc_usrp.simple_usrp.simple_sink_s (which,side = 'A')
        #if self._verbose:
              # print 'DAC sample rate is', n2s(self._u.dac_rate()), "sps"
        self._u.set_auto_tr(True)
        self.set_if_rate(if_rate)
        self.tune(freq)
        self.connect(self,self._u)

    def set_if_rate(self, if_rate):
        if if_rate is None:
           self._interp = 512
        else:
           self._interp = int(_dac_rate/( if_rate)+0.5)
           self.if_rate = _dac_rate/self._interp
           self._u.set_interp_rate(self._interp)  

        if self._verbose:
        print "dac_rate is ", _dac_rate
        print "USRP interpolation rate is ", self._interp
        print "USRP IF rate is ", n2s(self.if_rate),"sps"

    def tune(self, freq):
        self._tune_result = self._u.set_frequency(freq)
        if self._tune_result:
        if self._verbose:
           print "Baseband frequence is ", 
n2s(self._tune_result.baseband_freq), "Hz"
           print "Center frequence is ", n2s(freq), "Hz"
           print "Residual frequence is ", 
n2s(self._tune_result.residual_freq), "Hz"
           return True

        return False

if __name__ == "__main__":
   sink = usrp_sink_c (verbose = True)

The scheduler part related to the enable/disable transmitter:

try:
   start_flag = 1
   payload_13barker = '\x01\x01\x01\x01\x01\x00\x00\x01\x01\x00\x01\x00\x01'
   while(start_flag == 1):
        msg_13bit = gr.message_from_string(payload_13barker)
        top_block._ls.msgq.insert_tail(msg_13bit)
        eof_msg = gr.message(1)
        top_block._ls.msgq.insert_tail(eof_msg)
        top_block._u.set_enable(False)
        time.sleep(0.005)
        top_block._u.set_enable(True)
        top_block.wait()
except KeyboardInterrupt:
       pass
         
> 
> > The version of GNUradio that I'm using is GNURadio 3.2svn
> >
> 
> I think there was some work in 3.3 for this sort of issue, but thats
> just from memory, as I mostly use UHD these days.
> 
> Things you might look for:
> python -c "from grc_gnuradio import usrp as grc_usrp;
> help(grc_usrp.simple_usrp.simple_sink_c)"
> 
> there should be a set_enable() function on simple_sink_c which to the
> best of my recollection would enable/disable the transmitter
> 
> Jason
> 

Attachment: ynie3.vcf
Description: Card for "Yan Nie" <ynie3@uwo.ca>


reply via email to

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