Inserting code into top_block.py

Hey All,
I’m trying to figure out if what I want to do is possible in GNU Radio
Companion or if there’s a better way to achieve this functionality.
I have some code that I want to execute after all the blocks and
connections have been initialized in the top_block init()but before the
tb.Start(). Is there some way I can create a custom block that inserts
code
into top_block.py at that point or inserts the code at the end of the
init()? I currently have my code running in gnuradio-runtime, but I want
to
have this same functionality without altering the gnuradio trunk code,
hence why I’m thinking of a custom block that can insert the code where
I
want.
Thanks,
Ryan M.

You might be able to trick the ‘Variable’ block into doing what you
want.

M

The most straightforward way is to make a small Python program that
calls the class generated by GRC. Copy the autogenerated code after

if name == ‘main

into another file, and insert your logic before the tb.start() line.

  • Jeff

Shouldn’t he “cut” the code?

Vanush,

GRC will overwrite any changes you make to the generated Python file, so
you would want to do any custom programming outside that file. The
main’ code is only hit if you execute the file as the top level
program.

  • Jeff