I've wrote an application that have two flow graphs as follows: usrp2_source -> fir -> file_sink. The only difference between the two are the usrp2 frequency and decimation rate.
As you can see in the annexed code, I start the first flow graph, five seconds latter it stops and the second one starts. The problem is I'm not able to set the new frequency on the second flow graph. set_center_freq method returns None. I tried to use the same usrp2_source for the two graphs, but the problem persists. Can somebody give me a hint on how make this work? I'm using USRP2 with RFX2400 db and gnuradio rev 10780 Thanks
#!/usr/bin/env python from gnuradio import gr, gru, blks2 from gnuradio import usrp2 from gnuradio import eng_notation from gnuradio.eng_option import eng_option import gnuradio.gr.gr_threading as _threading from optparse import OptionParser import os, struct, sys, time, math, random, threading def get_fir_filter(): taps = [0.50, 0.25, 0.125, 0.0645] return gr.fir_filter_ccf(1, taps) class USRP2source: __instance = None def __init__(self, interface, mac_addr): if USRP2source.__instance: raise USRP2source.__instance USRP2source.__instance = self self.shared_usrp2_source32fc = usrp2.source_32fc(interface, mac_addr) def get_usrp2_sorce32fc(interface, mac_addr): try: instance = USRP2source(interface, mac_addr) except USRP2source, e: instance = e return instance.shared_usrp2_source32fc class test1(gr.top_block): def __init__(self): gr.top_block.__init__(self) #self.u = get_usrp2_sorce32fc("eth0", "") self.u = usrp2.source_32fc("eth0", "") self.fir = get_fir_filter() self.sink = gr.file_sink(gr.sizeof_gr_complex, "test1.dat") tr = self.u.set_center_freq(2.462e9) if tr == None: sys.stderr.write('Failed to set center frequency\n') raise SystemExit, 1 self.u.set_decim(16) self.connect(self.u, self.fir, self.sink) class test2(gr.top_block): def __init__(self): gr.top_block.__init__(self) #self.u = get_usrp2_sorce32fc("eth0", "") self.u = usrp2.source_32fc("eth0", "") self.fir = get_fir_filter() self.sink = gr.file_sink(gr.sizeof_gr_complex, "test2.dat") tr = self.u.set_center_freq(2.412e9) if tr == None: sys.stderr.write('Failed to set center frequency\n') raise SystemExit, 1 self.u.set_decim(14) self.connect(self.u, self.fir, self.sink) def main (): print "Running test 1" t1 = test1() t1.start() time.sleep(5) print "Stopping test1" t1.stop() t1.wait() print "Running test2" t2 = test2() t2.start() time.sleep(5) print "Stopping test2" t2.stop() if __name__ == '__main__': try: main() except KeyboardInterrupt: raise SystemExit
_______________________________________________ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org http://lists.gnu.org/mailman/listinfo/discuss-gnuradio