Updating old 802.15.4 code to latest release

Hi everyone,
I’m currently updating Thomas S.'s old 802.15.4 demodulation code.
It has been tested and works with at least revision 7596 of the
gnuradio trunk. I’ve been trying to update the code to work with the
latest release of Gnuradio (3.1). I’ve looked at examples converting
from hier_block to hier_block2 and flow_graph to top_block. I’ve
implemented those changes but still run into this error:

python: /usr/include/boost/shared_ptr.hpp:375: T*
boost::shared_ptr::operator->() const [with T = gr_basic_block]:
Assertion `px != 0’ failed.

Searches for this error on the list did not turn up much. I was
wondering if there was anything else that I missed. I’ve been banging
my head on the wall about this trying to figure out a fix. I jumped
into gdb and found that the code was crashing when trying to flatten
the flow_graph. I turned on debugging messages for
gr_hier_block2_detail.cc and here is the result of that:

connecting: ieee802_15_4_demod(3):0 -> sos_packet_sink(8):0
connect: src is hierarchical, setting parent to 0x89e3d00
connecting: usrp1_source_c(1):0 -> pwr_squelch_cc(9):0
connecting: pwr_squelch_cc(9):0 -> ieee802_15_4_demod_pkts(2):0
connect: dst is hierarchical, setting parent to 0x88bc270
start: entered
flattening top_block
Flattening edge usrp1_source_c(1):0->pwr_squelch_cc(9):0
Flattening edge pwr_squelch_cc(9):0->ieee802_15_4_demod_pkts(2):0
Resolving endpoint ieee802_15_4_demod_pkts(2):0 as an input, recursing
Resolving port 0 as an input of ieee802_15_4_demod_pkts
python: /usr/include/boost/shared_ptr.hpp:375: T*
boost::shared_ptr::operator->() const [with T = gr_basic_block]:
Assertion `px != 0’ failed.

I have attached a patch for anyone who wants to look further. If you’d
like to see all the code you can follow these steps to try it out
svn checkout svn://acert.ir.bbn.com/svn/gr-ucla
cd gr-ucla/trunk
(copy changes.diff to this directory)
patch -p0 -i changes.diff

Then build it all:
./bootstrap && ./configure && make
sudo make install

cd src/examples

If you have any comments or leads on something else that I should look
into I would really appreciate hearing it. Thanks for all your help!
-Leslie C.

Hi Leslie,

I have encountered the same problem in my RDS code
The error comes up because I have a top_block that creates a msg_queue
and passes it (as an argument) to a hier_block2.
This hier_block2 then outputs to the queue. I am receiving the same
error message (try running rds_scope_pll_test.py under src/python,
which calls rds_rx.py).
I haven’t yet had the time to look into this, because I resolved it by
integrating the hier_block2 functionality inside the top_block (look
at usrp_rds_scope_pll.py)

If you do find the source of the problem, I would appreciate it if you
pass it on to me

Kind regards, and good luck

Dimitris S.
“If you think you’re too small to make a difference, try sleeping with
a mosquito!” - Amnesty International

Hi Dimitris, I did find the source of the problem. I needed to add
“self” at the beginning (and sometimes end) of the argument list for
self.connect(). I looked through examples in the gnuradio codebase.
Jonathan offered this explanation as to why it is wired up that way
when I didn’t think it made much sense:

Is there a reason for having self be passed along the way it is in hier_block2?

Yes. “self” in the connect command refers to an external port of the
hierarchical block. Many hierarchical blocks are linear chains of
blocks internally, with a single external input port and a single
external output port. The shortcut method of wiring these is:

self.connect(self, …, …, …, …, self)

The non-shortcut way:

self.connect(self, 0, …, …)

self.connect(…, …, self. 0)

This means “connect external input port 0 to block …, input port …”
and “connect block …, output port … to external output port 0”.

I hope that helps you out! Let me know if that fixed the problem. Good

I gave it a shot, didn’t work though…
I was getting the error “ValueError: port number 0 exceeds max of

here’s my hier_block2:
and here’s my top_block:

Any other ideas?

Dimitris S.
“If you think you’re too small to make a difference, try sleeping with
a mosquito!” - Amnesty International

Hi Dimitris, I scanned over your code and think you just need to add
“self” to one statement. We add self only if there is an external
port. Your rds_rx block has an input but is a sink and therefore no
output. Therefore at line 102 rds_rx.py you may want to add something
self.connect(self, self.inpoint)

Since top_blocks do not have any input or output ports you don’t need
to add anything to those connect statements. I hope that makes sense!
Let me know if it works. Good luck!