AttributeError: 'module' object has no attribute 'square3_ff'

Hello Everyone,

I’m getting an error while adding a new block to grc version
3.7.2git-110-gb8b9bff2.
I followed the tutorial at
http://gnuradio.org/redmine/projects/gnuradio/wiki/OutOfTreeModules

Also had to modify at some points as below.

  • in the test code it worked when I changed ;

from gnuradio import gr, gr_unittest into from gnuradio import gr,
gr_unittest, blocks

gr.vector_source_f(src_data) into blocks.vector_source_f(src_data)

gr.vector_sink_f() into gr.vector_sink_f()

All the tests pass too.
100% tests passed, 0 tests failed out of 2

I added 3 blocks using c++ for first 2 and python for the last as
explained
in the tutorial.
I can see the blocks in the grc block list and can add them into the
sketch.
It generates the python code without any error.
But the generated python code cannot be run and giving the error below:

Traceback (most recent call last):
File “top_block.py”, line 82, in
tb = top_block()
File “top_block.py”, line 48, in init
self.test_square3_ff_0 = test.square3_ff()
AttributeError: ‘module’ object has no attribute ‘square3_ff’

You can see the generated file from http://pastebin.com/nE4SFn8Y

test module is placed under /usr/lib/python2.7/site-packages/test
gnuradio is under /usr/lib/python2.7/site-packages/gnuradio

Is there any point in the tutorial that does not match with the current
version of gnuradio?

Thanks in advance

Tarik


Aydin Tarik Zengin

Hi Tarik,

On Tue, Oct 29, 2013 at 04:43:53PM +0200, Aydin Tarik Zengin wrote:

I’m getting an error while adding a new block to grc version
3.7.2git-110-gb8b9bff2.
I followed the tutorial at http://gnuradio.org/redmine/projects/gnuradio/wiki/
OutOfTreeModules

Also had to modify at some points as below.

  • in the test code it worked when I changed ;

from gnuradio import gr, gr_unittest into from gnuradio import gr, gr_unittest,
blocks

Thanks, there were some references to GNU Radio 3.6-style blocks. I’ve
updated the tutorial to reflect that.

All the tests pass too.
100% tests passed, 0 tests failed out of 2

Did you add a test for the Python block? (Perhaps there’s a problem
in the Python, which would show up here).

self.test_square3_ff_0 = test.square3_ff()

AttributeError: ‘module’ object has no attribute ‘square3_ff’

You can see the generated file from http://pastebin.com/nE4SFn8Y

test module is placed under /usr/lib/python2.7/site-packages/test
gnuradio is under /usr/lib/python2.7/site-packages/gnuradio

Is there any point in the tutorial that does not match with the current version
of gnuradio?

Yes there is, but I’m not sure that’s the problem. I couldn’t replicate
your problem, however.
Make sure

  • your Python block works correctly (unit test it)
  • the XML definition for the GRC block is correct
  • everything is installed correctly.

Perhaps you want to go over the tutorial with the updated info again.

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

Thanks Martin,

Now I’m able to add running blocks.
However, if I want to add a block written only in Python - there are no
C++
files -, I add it with gr_modtool,

gr_modtool add -t sync -l python square3_ff

Then it gives the following error,

You have called ADD_LIBRARY for library gnuradio-howto without any
source
files. This typically indicates a problem with your CMakeLists.txt file
CMake Error: CMake can not determine linker language for
target:gnuradio-howto
CMake Error: Cannot determine link language for target “gnuradio-howto”.

If I add a C++ block with

gr_modtool add -t general square_ff

then the error disappears.

What should I do if I want to add a block written only in Python?

And I’m looking for a pure Python block with file-input file-output
operations?
Does Gnuradio have such a block as reference?

Thanks in advance,

Tarik


Aydin Tarik Zengin

On Sun, Nov 03, 2013 at 03:58:47PM +0200, Aydin Tarik Zengin wrote:

Now I’m able to add running blocks.

Good :slight_smile:

CMake Error: Cannot determine link language for target “gnuradio-howto”.
The oot-module templates are not designed for not having C++ blocks.
The way the CMake templates are set up is that there is at least one C++
block.
You can always remove the ‘lib’ folder from your module (and the make
system); that should work if you only have Python blocks. If this is
generally considered a bug, we could add some checks in the CMake files
to catch this case.

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs