Week 1: Header File Template

This week’s theme has been the header file template. The contents of the header file are mainly the #include statements, the top block (or hier block) class declaration, and declarations of other things such as blocks and variables. This does not amount to much code in comparison to the source file, which will include everything else such as constructors, definitions, main() and so on. However, it’s a great starting point. This week’s work hasn’t exactly yielded much of an immediately visible profit, but this is due to the fact that all the blocks still are Python only and the generation code is more or less untouched at this point. The C++ output will come 🙂 There’s also a small practical change, from now on I will be pushing daily commits to a python3_dev branch and keeping the larger changes on the python3 branch.

 

The python3 branch from the main repository does not run without error right now, but I’ve gathered the steps necessary to get it running:

First, you’ll have to edit grc/scripts/gnuradio-companion at line 84:

def check_python_version():
         if sys.verion_info.major > 2:
                 die(RuntimeError(‘No python3 support yet.’), ‘Stay tuned…’)

The program will die here if you’re running it with Python 3, of course, so you’ll want to fix this.

Second, you’ll have to take a look at grc/core/generator/top_block.py at line 206 and 212:

def uses_var_id():
(…)
callbacks[var_id] = [callback for callback in callbacks_all if uses_var_id()]

This creates an error because callback is used within the uses_var_id() method. I suspect this is a Python 3 migration problem. This error will hinder GRC from generating any flow graph files. The fix is easy though:

def uses_var_id(callback):
(…)
callbacks[var_id] = [callback for callback in callbacks_all if uses_var_id(callback)]

So, with those fixes in place, you should be able to run GRC and generate the top block Python file.

EDIT: In fact, there are a couple more steps you’ll need to take to get it running:

To avoid getting the “domain not registered” errors, you’ll have to copy the YAML files stream.domain.yml and message.domain.yml from grc/blocks/ to your block cache. This is probably at ~/.cache/grc_gnuradio/

The next step is adding “generator” at the end of grc/CMakeLists.txt at line 152, like this:

DIRECTORY core gui generator

That’s it, you’re all set!

Leave a comment