0% found this document useful (0 votes)
316 views3 pages

OOT Tutorial

This document provides instructions for creating a custom module in GNU Radio Composer (GRC) using C++. The key steps are: 1. Use the gr_modtool script to generate files for an out-of-tree module called "howto". 2. Add a block called "square_ff" using gr_modtool. This generates C++ and Python files to implement the block. 3. Modify the generated files - edit the Python test file, implement the signal processing in the C++ file. 4. Build and test the module. Run 'make' and 'make test' in the build directory. 5. Generate the XML file to use the block in

Uploaded by

Chaeriah Wael
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
316 views3 pages

OOT Tutorial

This document provides instructions for creating a custom module in GNU Radio Composer (GRC) using C++. The key steps are: 1. Use the gr_modtool script to generate files for an out-of-tree module called "howto". 2. Add a block called "square_ff" using gr_modtool. This generates C++ and Python files to implement the block. 3. Modify the generated files - edit the Python test file, implement the signal processing in the C++ file. 4. Build and test the module. Run 'make' and 'make test' in the build directory. 5. Generate the XML file to use the block in

Uploaded by

Chaeriah Wael
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

How to create your own module in GRC :

A. Using C++
Referensi :
- https://gnuradio.org/redmine/projects/gnuradio/wiki/OutOfTreeModules
- https://www.youtube.com/watch?v=BW8o9ZgFJ5I

• Use Out of Tree module to create our own module gr-howto. gr_modtool script is used to
create files automatically.
• Use command in terminal to create module “gr-howto”
$ gr_modtool newmod howto
this is will create new directory called gr-howto

• to see created files, go to gr-howto directory and type ls command


$ cd gr-howto
gr-howto$ ls

• to create empty files for block, go to directory gr-howto and type the command below :
gr-howto$ gr_modtool add -t general square_ff

GNU Radio module name identified: howto


Language: C++
Block/code identifier: square_ff
Enter valid argument list, including default arguments:
Add Python QA code? [Y/n] y
Add C++ QA code? [y/N] n
Adding file 'square_ff_impl.h'...
Adding file 'square_ff_impl.cc'...
Adding file 'square_ff.h'...
Editing swig/howto_swig.i...
Adding file 'qa_square_ff.py'...
Editing python/CMakeLists.txt...
Adding file 'howto_square_ff.xml'...
Editing grc/CMakeLists.txt...

• open python/qa_square_ff.py and edit it accordingly :


gr-howto$ cd python
gr-howto/python$ ls
gr-howto/python$ sudo gedit qa_square_ff.py
gr-howto/python$ ls

• test_001_square_ff builds a small graph that contains three nodes.


◦ blocks.vector_source_f(scr_data) will source the elements of scr_data
◦ howto.square_ff is the block we're testing
◦ blocks.vector_sink_f gathers the output of howto.square_ff

• the run() method runs the graph until all the blocks indicate they are finished.
• Finally, we check that the result of executing square_ff on scr_data matches what we expect.
• Now we need to modify lib/square_ff_impl.cc
◦ gr_modtool hints at where you have to change code by adding <++> symbols
◦ open the file and modify it accordingly :
gr-howto/python$ cd ..
gr-howto$ cd lib
gr-howto/lib$ ls
gr-howto/lib$ sudo gedit square_ff_impl.cc
◦ input and output signature specifies min and max no of input and output ports along this
type of ports
◦ here we have only 1 input and 1 output port and that of type float.
◦ Forecast() is a function which tells the scheduler how many input items are required to
produce noutput_items output items.
◦ Here they are same and hence input_items_required[0] = noutput_items;
◦ the index 0 indicates that this is for the first port.
◦ general_work() is the method that does the actual signal processing
◦ let's modify it to get square of input value
• now lets build and compile our files using Cmake
◦ first go to directory gr-howto and type commands below :
r-howto$ mkdir build
r-howto$ cd build
r-howto/build$ cmake ../
r-howto/build$ make
◦ lets try running 'make test', type command below :
gr-howto/build$ make test
• lets try running 'make test', type command below :
gr-howto/build$ make test
• if everything is fine, then create XML code using gr_modtool script
◦ go to gr-howto directory and type below command :
gr-howto$ gr_modtool makexml square_ff
gr-howto$ gr_modtool makexml square_ff
GNU Radio module name identified: howto
Warning: This is an experimental feature. Don't expect any magic.
Searching for matching files in lib/:
Making GRC bindings for lib/square2_ff_impl.cc...
Overwrite existing GRC file? [y/N] y

◦ let's install the module for that type command in terminal


gr-howto$ cd build
gr-howto/build$ sudo make install
gr-howto/build$ sudo ldconfig
• That's it, the block is created. Let's try to use in GRC
B. Using Python
Referensi :
- https://gnuradio.org/redmine/projects/gnuradio/wiki/OutOfTreeModules

You might also like