Either you can use tb.start() + tb.wait() OR you can use tb.run() OR you can use tb.start() + tb.wait() + tb.stop()
If you have to do collect finite amount of data then you need to make a gr.head()
Generally the run method doesn't have stop.. you can see it in uhd_rx_cfile
In order to stop in such case, a gr.head() is created with finite number of samples so that the flow graph stops by itself.
All these start(), stop(), run(), wait() are boost library threads. Need to find out more by reading there.
run() = start() + wait() i.e. a call to tb.run() calls both tb.start() and tb.wait()
If you use run(), the flowgraph will not only stop, but will end its lifetime. Once run() has returned, the flowgraph is no longer usable, or as we like to say, further operations on it are "undefined."
The run() method on a top block is really just a convenient way of telling GNU Radio your application has nothing else to do until the flowgraph exits.
So if you want the flow graph to continue use start() and then wait()and after that stop() to stop the flow graph
Details on all of the methods can be found in gr_top_block.h as well as gr
Here is the link to important discussions :
http://gnuradio.4.n7.nabble.com/Reg-start-method-in-gr-top-block-h-tt37915.html
http://gnuradio.4.n7.nabble.com/Reg-start-wait-stop-and-run-tt37916.html
Sample example :
Try-1 :
def main():
t = my_top_block()
t.start()
t.wait()
t.stop()
print t.c2mag.level() #print power
time.sleep(3)
m = my_top_block()
m.start()
m.wait()
m.stop()
print m.c2mag.level() #print power
time.sleep(3)
n = my_top_block()
n.start()
n.wait()
n.stop()
print n.c2mag.level() #print power
time.sleep(3)
r = my_top_block()
r.start()
r.wait()
r.stop()
print r.c2mag.level() #print power
time.sleep(3)
If you have to do collect finite amount of data then you need to make a gr.head()
Generally the run method doesn't have stop.. you can see it in uhd_rx_cfile
In order to stop in such case, a gr.head() is created with finite number of samples so that the flow graph stops by itself.
All these start(), stop(), run(), wait() are boost library threads. Need to find out more by reading there.
run() = start() + wait() i.e. a call to tb.run() calls both tb.start() and tb.wait()
If you use run(), the flowgraph will not only stop, but will end its lifetime. Once run() has returned, the flowgraph is no longer usable, or as we like to say, further operations on it are "undefined."
The run() method on a top block is really just a convenient way of telling GNU Radio your application has nothing else to do until the flowgraph exits.
So if you want the flow graph to continue use start() and then wait()and after that stop() to stop the flow graph
Details on all of the methods can be found in gr_top_block.h as well as gr
Here is the link to important discussions :
http://gnuradio.4.n7.nabble.com/Reg-start-method-in-gr-top-block-h-tt37915.html
http://gnuradio.4.n7.nabble.com/Reg-start-wait-stop-and-run-tt37916.html
Sample example :
Try-1 :
def main():
t = my_top_block()
t.start()
t.wait()
t.stop()
print t.c2mag.level() #print power
time.sleep(3)
m = my_top_block()
m.start()
m.wait()
m.stop()
print m.c2mag.level() #print power
time.sleep(3)
n = my_top_block()
n.start()
n.wait()
n.stop()
print n.c2mag.level() #print power
time.sleep(3)
r = my_top_block()
r.start()
r.wait()
r.stop()
print r.c2mag.level() #print power
time.sleep(3)
Great blog! Very useful and informative.
ReplyDelete//I am trying to pass two different parameters to my top_block class
ReplyDeleteI m not able to do this pls help
tb=top_block(options,0.8)
tb.start()
tb.wait()
tb.stop()
sleep(5)
print "I AM BACK"
tb1=top_block(options,0.4)
tb1.start()
tb1.wait()
tb1.stop()
sleep()
hmm.. should work.. can u send me your code
DeleteThis comment has been removed by the author.
ReplyDelete