Hier block inside a hier block


#1

Hello all,

I am not sure whether this is strange behaviour or I am misunderstanding
what you can do with hier_blocks.

Problem is best described with an example:

from gnuradio import gr
class h_block(gr.hier_block2):
def init(self):
gr.hier_block2.init(self,
“h_block”,
gr.io_signature(1,1,gr.sizeof_float),
gr.io_signature(0,0,0))

    hblock2 = h_block2()
    self.connect(self, hblock2)

class h_block2(gr.hier_block2):
def init(self):
gr.hier_block2.init(self,
“h_block2”,
gr.io_signature(1,1,gr.sizeof_float),
gr.io_signature(0,0,0))
self.connect(self, gr.multiply_const_ff(1), gr.null_sink(4))

class temp(gr.top_block):
def init(self):
gr.top_block.init(self)
source = gr.null_source(4)
hblock = h_block()
self.connect(source, hblock)
self.start()

if name == “main”:
app = temp()

When I run the above example I get:

sdrts@sdrts:~/sdrts/test$ python gr3.2_test.py
Traceback (most recent call last):
File “gr3.2_test.py”, line 29, in
app = temp()
File “gr3.2_test.py”, line 26, in init
self.start()
File
“/opt/gnuradio/trunk//lib/python2.5/site-packages/gnuradio/gr/top_block.py”,
line 95, in start
self._tb.start()
File
“/opt/gnuradio/trunk//lib/python2.5/site-packages/gnuradio/gr/gnuradio_swig_py_runtime.py”,
line 1411, in start
return _gnuradio_swig_py_runtime.gr_top_block_sptr_start(*args,
**kwargs)
RuntimeError: multiply_const_ff(4): insufficient connected output ports
(1
needed, 0 connected)
sdrts@sdrts:~/sdrts/test$

There is no error if in h_block2 the connect line is just
self.connect(self,
gr.null_sink(4)).

I am running an ubuntu 8.10 server, same output on 3.1.3, 3.2 and trunk.
Thoughts?

Kieran


#2

On Thu, 2009-04-02 at 22:05 -0700, Josh B. wrote:

Im not sure if there is a ticket about this, maybe
http://gnuradio.org/trac/ticket/161 is related.

It is related, and the solution to 161 will fix this issue as well.

Johnathan


#3

On Thu, Apr 02, 2009 at 10:11:38PM -0700, Johnathan C. wrote:

On Thu, 2009-04-02 at 22:05 -0700, Josh B. wrote:

Im not sure if there is a ticket about this, maybe
http://gnuradio.org/trac/ticket/161 is related.

It is related, and the solution to 161 will fix this issue as well.

Johnathan

I just opened ticket:383 on this. I’m not sure that these are the
same problem. We definitely need more QA code for this area of the
code.

Eric


#4

Kieran B. wrote:

    gr.hier_block2.__init__(self,
        "h_block",
        gr.io_signature(1,1,gr.sizeof_float),
        gr.io_signature(0,0,0))

    hblock2 = h_block2()
    self.connect(self, hblock2)

i would change this last line to:
self.connect(self, gr.kludge_copy(gr.sizeof_float), hblock2)

hier blocks dont like to connect their virtualized inputs and outputs
directly to other hier blocks. They require something substantial
in-between. Thats is why we have kludge_copy, which just takes data from
the h_block and passes it to the h_block2 input, just so long as the two
h_blocks dont have to communicate directly!

Im not sure if there is a ticket about this, maybe
http://gnuradio.org/trac/ticket/161 is related.

-Josh