Importing newly created C++ block

Hi all,

We created a new module called radar(gr-radar folder created) and a
block
called lfm_source_c. Eventually, this new block will create a chirp
style
signal. We are trying to use in a Python file. The Python code was
working
perfectly fine when we used the gr signal source to generate a square
wave.
The wave transmitted to a scope sink and to our USRP N210.

We successfully installed the new module with “make install”.

We added an “import radar” statement at the beginning of the file which
in
and of itself didn’t cause any errors. We got a whole list of errors
when
we tried to use the source in python.
src = radar.lfm_source_c (wave_freq,
pulse_width,
pulse_rep_int,
sample_rate,
2.0,
0)

gr-radar is in our home path, but not the GNU Radio path (which I think
is
correct). Can anyone give us any insight into this problem? This is the
first block we’ve created so don’t have any experience with this. I will
also include our error list below.

Thanks for any help you can give! Below is the terminal output:

Traceback (most recent call last):
File “chirp_test_gui.py”, line 82, in
main ()
File “chirp_test_gui.py”, line 78, in main
app = stdgui2.stdapp(tx_sink, “Transmitted Signal”, nstatus=1)
File
“/usr/local/lib/python2.7/dist-packages/gnuradio/wxgui/stdgui2.py”,
line 38, in init
wx.App.init (self, redirect=False)
File
“/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/_core.py”,
line 7981, in init
self._BootstrapApp()
File
“/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/_core.py”,
line 7555, in _BootstrapApp
return core.PyApp__BootstrapApp(*args, **kwargs)
File
“/usr/local/lib/python2.7/dist-packages/gnuradio/wxgui/stdgui2.py”,
line 42, in OnInit
self._max_noutput_items)
File
“/usr/local/lib/python2.7/dist-packages/gnuradio/wxgui/stdgui2.py”,
line 64, in init
self.panel = stdpanel (self, self, top_block_maker, max_nouts)
File
“/usr/local/lib/python2.7/dist-packages/gnuradio/wxgui/stdgui2.py”,
line 86, in init
self.top_block = top_block_maker (frame, self, vbox, sys.argv)
File “chirp_test_gui.py”, line 69, in init
sig0 =
tx_test(options.freq,options.pulse_width,options.pulse_rep_int,options.samp_rate)
File “chirp_test_gui.py”, line 26, in init
0) # DC Offset
File “/usr/local/lib/python2.7/dist-packages/radar/radar_swig.py”,
line
319, in init
def init(self, *args, **kwargs): raise AttributeError(“No
constructor defined”)
AttributeError: No constructor defined

On Wed, Feb 27, 2013 at 10:42 AM, Brooke H. [email protected]
wrote:

We added an “import radar” statement at the beginning of the file which in
gr-radar is in our home path, but not the GNU Radio path (which I think is
app = stdgui2.stdapp(tx_sink, “Transmitted Signal”, nstatus=1)
line 42, in OnInit
File “chirp_test_gui.py”, line 26, in init
0) # DC Offset
File “/usr/local/lib/python2.7/dist-packages/radar/radar_swig.py”, line
319, in init
def init(self, *args, **kwargs): raise AttributeError(“No
constructor defined”)
AttributeError: No constructor defined

Brooke,

How did you create the block? Was it using gr_modtool or did you roll
it yourself from scratch? It looks like something in the SWIG
interface is probably wrong. Do you have a separate interface (.i)
file for this block or are you just including the header file in a
“radar_swig.i” file? (The latter is the preferred way.)

So make sure you have a make function and that the block is properly
included in a SWIG interface file.

Tom

i am stucking to add code in places, i think i am forgetting someone
could
you write its steps, thank you.

2013/2/28 Tom R. [email protected]

i tried to do like Tom said but i had faild, could you help me!!

bynkln@ubuntu:~$ gr_modtool.py create qpsk
Module directory is “./gr-qpsk”.
Creating directory…
Copying howto example…
Unpacking…
Replacing occurences of ‘howto’ to ‘qpsk’… Done.
Use ‘gr_modtool add’ to add a new block to this currently empty module.
bynkln@ubuntu:~$ cd gr-qpsk/
bynkln@ubuntu:~/gr-qpsk$ gr_modtool add
GNU Radio module name identified: qpsk
Enter code type: hier
Language: C++
Enter name of block/code (without module name prefix): qpsk
Block/code identifier: qpsk
Enter valid argument list, including default arguments: int val1, double
val2=0
Add Python QA code? [Y/n] y
Add C++ QA code? [y/N] y
Adding file ‘qpsk_impl.h’…
Adding file ‘qpsk_impl.cc’…
Adding file ‘qpsk.h’…
Adding file ‘qa_qpsk.cc’…
Adding file ‘qa_qpsk.h’…
Editing swig/qpsk_swig.i…
Adding file ‘qa_qpsk.py’…
Editing python/CMakeLists.txt…
Adding file ‘qpsk_qpsk.xml’…
Editing grc/CMakeLists.txt…

at this level i had added qpsk.py to into /gr-qpsk/init.py at #
import any pure python here

than i had changed <+ YOUR COMPANY NAME +> to <+BYNKLN+> for all
component that includes after that:

bynkln@ubuntu:~/gr-qpsk$ mkdir build
bynkln@ubuntu:~/gr-qpsk$ cd build
bynkln@ubuntu:~/gr-qpsk/build$ cmake …/
– The CXX compiler identification is GNU 4.7.2
– The C compiler identification is GNU 4.7.2
– Check for working CXX compiler: /usr/bin/c++
– Check for working CXX compiler: /usr/bin/c++ – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Check for working C compiler: /usr/bin/gcc
– Check for working C compiler: /usr/bin/gcc – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Build type not specified: defaulting to release.
– Boost version: 1.49.0
– Found the following Boost libraries:
– filesystem
– system
– Found PkgConfig: /usr/bin/pkg-config (found version “0.26”)
– checking for module ‘gruel’
– found gruel, version 3.6.4
– Found GRUEL: /usr/local/lib/libgruel.so
– checking for module ‘gnuradio-core’
– found gnuradio-core, version 3.6.4
– Found GNURADIO_CORE: /usr/local/lib/libgnuradio-core.so
– checking for module ‘cppunit’
– found cppunit, version 1.12.1
– Found CPPUNIT: /usr/lib/libcppunit.so;dl
– Found SWIG: /usr/bin/swig2.0 (found version “2.0.7”)
– Found PythonLibs: /usr/lib/python3.2/config/libpython3.2.so (found
version “2.7.3”)
– Found PythonInterp: /usr/bin/python (found version “2.7.3”)
– Found Doxygen: /usr/bin/doxygen (found version “1.8.1.2”)
– Configuring done
– Generating done
– Build files have been written to: /home/bynkln/gr-qpsk/build
bynkln@ubuntu:~/gr-qpsk/build$ make
Scanning dependencies of target gnuradio-qpsk
[ 5%] Building CXX object
lib/CMakeFiles/gnuradio-qpsk.dir/qpsk_impl.cc.o
/home/bynkln/gr-qpsk/lib/qpsk_impl.cc: In constructor
‘gr::qpsk::qpsk_impl::qpsk_impl(int, double)’:
/home/bynkln/gr-qpsk/lib/qpsk_impl.cc:42:30: error: expected
primary-expression before ‘<’ token
/home/bynkln/gr-qpsk/lib/qpsk_impl.cc:42:32: error: ‘MIN_IN’ was not
declared in this scope
/home/bynkln/gr-qpsk/lib/qpsk_impl.cc:42:39: error: expected
primary-expression before ‘>’ token
/home/bynkln/gr-qpsk/lib/qpsk_impl.cc:42:40: error: expected
primary-expression before ‘,’ token
/home/bynkln/gr-qpsk/lib/qpsk_impl.cc:42:42: error: expected
primary-expression before ‘<’ token
/home/bynkln/gr-qpsk/lib/qpsk_impl.cc:42:44: error: ‘MAX_IN’ was not
declared in this scope
/home/bynkln/gr-qpsk/lib/qpsk_impl.cc:42:51: error: expected
primary-expression before ‘>’ token
/home/bynkln/gr-qpsk/lib/qpsk_impl.cc:42:52: error: expected
primary-expression before ‘,’ token
/home/bynkln/gr-qpsk/lib/qpsk_impl.cc:42:62: error: expected
primary-expression before ‘<’ token
/home/bynkln/gr-qpsk/lib/qpsk_impl.cc:42:64: error: expected
primary-expression before ‘float’
/home/bynkln/gr-qpsk/lib/qpsk_impl.cc:42:64: error: expected ‘)’ before
‘float’
/home/bynkln/gr-qpsk/lib/qpsk_impl.cc:58:3: error: expected ‘{’ before
‘}’ token
make[2]: *** [lib/CMakeFiles/gnuradio-qpsk.dir/qpsk_impl.cc.o] Error 1
make[1]: *** [lib/CMakeFiles/gnuradio-qpsk.dir/all] Error 2
make: *** [all] Error 2
bynkln@ubuntu:~/gr-qpsk/build$

it faild again, could any body to help …

I did as you said i think, but i stuck same problem goes… Please, i
know it is too much to request that, could you explain to create a new
block(i did it) and adding python code(may be i have problem here) than
what i shoul change at the created block after that how to make it
avaible to grc as a block. I need them to make it happen step by step if
you do it for us…

28 Şub 2013 tarihinde 01:16 saatinde, Tom R. [email protected]
şunları yazdı: