Public method in out of tree module

Hello,

I am trying to create a block that has a publicly accessible method and
am
having trouble accessing the method from within Python. Here is a
simple
example of my process.

First, I boot Gnuradio Live DVD, Ubutnu 12.04, Gnuradio 3.7.2

Second, i create a new module according to:
http://gnuradio.org/redmine/projects/gnuradio/wiki/OutOfTreeModules

gr_modtool newmod testmod
cd gr-testmod
gr_modtool add -t general testblock (empty argument list, default answers)
vim lib/testblock_impl.cc (Edit this to the same as the square_ff.cc code
from the example)
mkdir build
cd build
cmake …/
make
sudo make install
sudo ldconfig

This works fine, I can verify the block is working correctly.

Then I edit the public header file to add a pure virtual method pub()

vim include/testmod/testblock.h


public:
virtual int pub() = 0;

Then I edit the private header file to implement the method


public:
int pub(){ return 1; }

If I build this, it will make and install just fine. The only problem
comes when I run python like so

import testmod
b = testmod.testblock()
b.pub()

I get the following error:

AttributeError: ‘testblock_sptr’ object has no attribute ‘pub’

I’ve tried following the examples of in tree blocks, but just cannot
seem
to be able to access pub() from python. Am I missing an include, or
something?

Thank you,

Dirk

On Fri, Nov 22, 2013 at 10:51:22AM -0500, Dirk Van Bruggen wrote:

I’ve tried following the examples of in tree blocks, but just cannot seem
to be able to access pub() from python. Am I missing an include, or
something?

Just to make sure, did you rebuild everything (including SWIG bindings)?
Are you accessing pub() from QA code? If not, did you reinstall
afterwards?

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

On 11/22/2013 07:51 AM, Dirk Van Bruggen wrote:

I’ve tried following the examples of in tree blocks, but just cannot
seem to be able to access pub() from python. Am I missing an include,
or something?

There is an bug in the OOT build system where, after having compiled
once, changes to public header files don’t result in remaking the
dependent SWIG library. A workaround is to do make clean, then make
again.