I recently wrote a blog post about the Nutaq demo at SDR WInnComm 2014. To recap, here’s a block diagram of the demo:

In the demo, a wireless video transmission is made at a specific frequency between the transmitter and the receiver. At the same time, an interferer is transmitting a tone at another specific frequency. The frequency of the interferer can be changed from the GNU Radio model on the embedded CPU. If the interferer’s frequency is changed to be near the frequency used by the transmitter and receiver, the receiver and the transmitter are reconfigured to a different frequency, one that is further from the interferer. The specific ‘cognitive’ portion of the demo is actually a simple state machine:

  • S0: Configure TX/RX radios at 453 MHz. Wait for noise to go lower than low_threshold. After, go to S1.
  • S1: If noise is higher than high_threshold, go to S2.
  • S2: Configure TX/RX radios at 433 MHz. Wait for noise to go lower than low_threshold. After, go to S3.
  • S3: If noise is higher than high_threshold, go back to S0.

As you can see, this is a basic state machine and is simple to design in any coding language. I tried initially to make this happen with the default GNU Radio block library but was unable to do so.

But, if a block doesn’t exist that does want you want, make your own!

Our custom block creation journey starts with the out-of-tree modules tutorial (http://gnuradio.org/redmine/projects/gnuradio/wiki/OutOfTreeModules) from on the GNU Radio website. This tutorial is a very good starting place for anyone who wants to learn the basics, under either C++ or Python. This blog is intended to fast-track the creation of an out-of-tree module in C++.

The first step is to use the gr_modtool command. This command, installed with GNU Radio, creates all the files necessary to implement a new module. It’s a simple process: just point your command line wherever you want your new module directory to go (note that this should be outside the GNU Radio source tree):

% gr_modtool newmod my_module
Creating out-of-tree module in ./gr-my_module… Done.
Use ‘gr_modtool add’ to add a new block to this currently empty module.

If all went well, you now have a new directory called gr-my_module. If the gr_modtool command isn’t recognized, you probably just need to configure your environment variables correctly. In my project, I needed to run the following commands before gr_modtool was recognized:

export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig/
export PYTHONPATH=$PYTHONPATH:/usr/local/lib64/python2.7/site-packages

Now, assuming that everything went well, let’s look at the created directory:

gr-my_module % ls
apps  cmake  CMakeLists.txt  docs  examples  grc  include  lib  python  swig

There are several directories here but the only one we are interested in is the lib folder. There is where all the C++ code we have is to write will be stored. If we used Python, we’d only be interested in the python folder. Please refer to the official out-of-tree tutorial for information about the other folders.

For those interested in our continued block creation journey, stay tuned for the second part of this blog series!