Muliple top_block()

Hi all,
I wanted to know that whether one can have multiple gr.top_block() or
not?
for example
tb1=gr.top_block()
tb2=gr.top_block()
tb1.run()
tb2.run()
and have them running at the same time.

Regards
Smith

try tb1.start() and tb2.start(). That should run them in separate
threads.

Mike

On Mon, Jun 20, 2011 at 03:59, Mike C. [email protected]
wrote:

try tb1.start() and tb2.start(). That should run them in separate threads.

The start() function kicks off the GNU Radio thread scheduler for a
flowgraph top block, but immediately returns to the foreground thread.
You’ll be able to do other things in your application while GNU Radio
runs
“in the background.” Typically this is used even for a single top block
in
GUI programs to start GNU Radio running and then enter the GUI library
event
loop in the foreground thread.

However, you’ll need at some point to call tb1.stop(), tb2.stop(),
tb1.wait(), tb2.wait() before the program exits, in order to properly
clean
up GNU Radio created resources.

Finally, depending on the application, you might need to hook SIGINT so
you
can do the above as part of a proper shutdown if the user hits ^C or
otherwise kills the process.

Martin’s suggestion of placing the flowgraphs each into their own
port-less
hierarchical block and then putting those into a single top block makes
sense if the two flowgraphs must always be started and stopped together.
It
used to be the only way to do it, but as of 3.3 you could run multiple,
independent top blocks in a single process via the start()/stop()/wait()
sequence on each instead of run().

Johnathan

On Mon, Jun 20, 2011 at 03:34:55PM +0500, smith mark wrote:

tb1.run()

tb2.run()

and have them running at the same time.

This definitely works:
Create several hier_blocks, each containing a full flow graph (w/ zero
input and output signatures), then put each of these into one top_block.

For an example, see usrp_nbfm_ptt.py.

Cheers,
MB


Karlsruhe Institute of Technology (KIT)
Communications Engineering Lab (CEL)

Dipl.-Ing. Martin B.
Research Associate

Kaiserstraße 12
Building 05.01
76131 Karlsruhe

Phone: +49 721 608-43790
Fax: +49 721 608-46071
www.cel.kit.edu

KIT – University of the State of Baden-Württemberg and
National Laboratory of the Helmholtz Association