Block header parsing tool: GSoC’19

Arpit Gupta
4 min readAug 23, 2019

--

A python-based tool that can interact with GNU Radio block headers written in C++, to automatically parse and extract information about them such as which getters/setters they have, their I/O signatures, factory signatures, etc. The parsed information can be further used for creating YAML files for the GRC.

Introduction

GNU Radio is a free & open-source software development toolkit that provides signal processing blocks to implement software radios. It can be used with readily-available low-cost external RF hardware to create software-defined radios, or without hardware in a simulation-like environment.

For the last three months, I’ve been working with GNU Radio as a part of the Google Summer of Code program. It has been an amazing experience and I’ve learned a lot over the summers under the mentorship of Sebastian Koslowski and Nicolas Cuervo.

I started contributing to the GNU Radio project in Feb’19. Since then there have been a total of 12 PRs merged from me.

The task for the GSoC project was to create an entirely new tool that automatically parses the header files for the GNU Radio project and the OOT (Out-of-Tree Module) modules. An out-of-tree module is a GNU Radio component that does not live within the GNU Radio source tree. If you want to extend GNU Radio with your own functions and blocks, such a module is what you create.

The major pull request for the GSoC project includes most of the work excluding the commits to GNU Radio version 3.8.

Main Product

In the last 3 months, we have achieved the following major goals:-

Command Line Interface: With the Command Line Interface, any GNU Radio or OOT block header file can be parsed with just the file path as the input. A complete header directory can also be parsed with directory-path as the input. Parsed output can then be represented in the form of a YAML or a JSON format. Helper blocktool comments can also be automatically put in the header file from the header implementation file.

Blocktool from Command Line Interface

API: [Code] A python API has been exposed for the blocktool classes which have highly increased its scope and efficiency. Users have the liberty to instantiate an object of the Blocktool class and assign the necessary values. PyGCCXML has been used to parse the C++ header code. The API classes are equipped with proper validation of the passed parameters. Major future use of the API is to use it to generate YAML files which could be used by the GRC using runtime.

Integration of Blocktool with Modtool: Modtool is a script which aims to help with automatically editing makefiles, using templates, and doing as much work as possible for the developer. The makeyaml subcommand of the modtool has been extended to use the blocktool API to generate the YAML files for the GRC. The -b flag with the makeyaml subcommand of the modtool uses the blocktool API to generate the YAML else the modtool API is used for the same purpose.

Use of blocktool from modtool

Blocktool comments: Blocktool comments are quite useful to get the information from the implementation file in case the implementation file does not exist. If there is a conflict in any particular information, a warning will be generated. An exclamation mark is required to override the parsed information with the comment information.

Blocktool Comments for the header file agc2_cc.h

Developer View

Blocktool Tests: [Code] Proper unittests have also been added for the Blocktool class which makes the life of a blocktool developer much more simpler. Unittests ensures that the intended functionality is true as intended and also eases the refactoring process.

The split of python modules: The python modules for the gr-blocktool have been split into core, cli (single file), and tests which enhances the developer’s experience.

Independent API: The core blocktool API is completely independent of the rest of the tool.

Important Links

The commits for the most recent state of the gr-blocktool can be followed in my forked repository branch parser.

The specific details regarding the project are available in my blog posts as well as GitHub project.

The major pull request for the GSoC project.

Experience

It was a brilliant experience to work with the GNU Radio Community. The members of the community are highly supportive. I’m really looking forward to working more with the organization.

Thank You!

--

--

Arpit Gupta

Software engineer. Open Source, Image Processing and Web enthusiast. Electronics undergrad at IIT Roorkee.