# Contributing to GNU Radio -- FAQ¶

GNU Radio is an Open Source project, and as such contributions from the community are welcome. If you have some code or other things such as documentation you would like to share with the rest, please have a look at this FAQ before submitting.

## How can I help?¶

The easiest way to help is to simply use GNU Radio. The more you use it, the more likely you will perhaps find a bug, or miss a particular feature. Tell us about it on the mailing list, or, even better, fix it yourself and submit the code. The most rewarding way to go is probably to actually write a radio system, e.g. a receiver for a digital standard.

If you want to get involved in the development process, here's some suggestions where to start:
• Documentation
• Missing test cases
• Bug fixes

The main place to look is the issue tracker. Also, look at the results posted by our Jenkins continuous integration service: http://jenkins.gnuradio.org/jenkins/job/GNURadio-master. It tracks warnings, TODO's, FIXME's, and unit tests. Any warnings or FIXME fixes are useful as well as any more unit tests to exercise the validity of the signal processing or runtime code.

We also use Coverity for static code analysis. You can find our project at https://scan.coverity.com/projects. Here, you can find small things to change and fix (a lot of these are so small you don't even need an FSF copyright assignment).

There's also the possibility to donate to our project. The Free Software Foundation provides the infrastructure to do so, and can provide a receipt for US tax payers, who can deduct a donation.

## Development Style¶

When writing new code, we have a few general rules for where and how things go in. We follow that standard Git workflows concept in our Git branch structure. We have two main branches used in development, the 'master' and the 'next.' Here are a few rules to go by when working on new code or fixing old code in GNU Radio.

• Make sure any changes in 'master' do not break the API (even if there is an error)
• Additions to the API are fine
• Deprecating code by outputting a message is done here
• Removing code or changing API names or calling conventions MUST be done in 'next'
• Work in 'master' for as much as possible unless you are going to change the API

Following these simple rules will help get your code merged in faster and with less hassle.

When working in code, there may be additions or things you might not know how to do just yet. It is appropriate in these instances to make a comment about it. The convention for this is to use the following keywords to indicate where you have left something for later:
• Use TODO comments for low-priority fixes
• Use FIXME comments for high-priority fixes
For all kinds of modifications and changes, try and make sure the following points are observed:
• For patches, the diff contains the minimal but related incremental changes, for all the files needing modification to implement the change. In other words, the diff should take a working GNU Radio source tree and modify it to become a working GNU Radio source tree with the feature implemented.
• Diffs are made from the GNU Radio tree root, and are based on an recent master branch.
• use git format-patch to create your patches.
• Minor bug fixes should be applied to the maint branch
• Addon's and features should be applied to the master branch
• Changes to the structure, API, or other surgery to the code should be applied to the next branch
• After applying your changes or building your branch, the command 'make test' must pass.
• There should be no additional compiler warnings to what already occurs.
• No gratuitous whitespace changes.

### Quality Assurance (QA) Code¶

Every block should have a QA file to test the validity of the code. Most current blocks have QA code that tests that the code runs and produces repeatable, testable results on all platforms. If this code fails, it is an indication of a problem, error, or unexpected change in the code. It is an easy way to verify the validity of the code. This can be a difficult concept in some signal processing codes (such as a phase lock loop that has to settle), but the current QA tests that are there can offer guidance and hints as to how to test a new block.

Any block that is currently without a QA testing program should be fixed to have one.

## I've found a bug, but I don't have the skill/time/whatever to fix it... now what?¶

No problem. If it's really an unfixed bug, you're perhaps the first to stumble upon it. Write an email to the mailing list explaining what's wrong and, ideally, providing a test case so the developers can reproduce the error.

If it's a confirmed bug, you should add a ticket to the bug tracker (http://gnuradio.org/redmine/projects/gnuradio/issues) by following these steps:

1. You'll need to login to the website, first, and then click New Issue.
2. Set if this Issue is a bug or perhaps a new feature.
3. Provide an appropriate subject to explain the Issue.
4. Provide a comprehensive description of the Issue. Provide links, code, and any examples here. It's much easier for us to understand a bug if we have a simple test case that demonstrates the issue such as a GRC file or Python program. Feel free to upload attachments using the Files button.
5. The rest of the attributes of the Issue should be left alone. The GNU Radio development team will handle assignment of the bug and any other relevant attributes.

### I've fixed and Issue! What do I do now?¶

That's fantastic! Thanks! To help us provide a consistent experience resolving and fixing issues, please follow these steps.

1. Create a patch. See the next set of instructions on "How do I submit patches?". If you have a patch file, you can attach it to the Issue directly or use a pull request through github.com.
2. Update the Issue that you're addressing by setting the Issue status to Feedback and a description of the update, such as the github branch or pull request number.
3. Set the Resolution field to Fixed.

The GNU Radio development team will take the issue from here. We will handle applying or merging the fix and updating the issue from there. We will set the Status to Resolved and set the target version it belongs to. After a week or so without incident, we will close the Issue.

## How do I submit patches?¶

This depends on the size of the patch. If it is a small patch, e.g. a bug fix which only consists of a few lines, you can just create a diff and attach that to the entry to the issue tracker. Please include a description of the bug and how your patch fixes this bug (see above on obtaining permissions to create bug tracker entries.)

Another easy, very useful (for both you and us) way is to go through github and send us a pull request (See: How can I use github? below).

In most cases, these are the commands you will enter:

# You've just finished editing the patch
$git add FILE1 FILE2... # Put all the patch-relevant files here$ git commit -m 'filter: re-snazzled the frombobulator (was zingamawonking)'
\$ git format-patch HEAD~ # This will turn the latest commit into a patch file


Note that the commit message should be prefixed with the component you changed (core, filter, audio, ...). Read the previous commit logs for examples (you can get them with 'git log').

The last command creates a file, usually starting with '0001', which contains the patch. Simply upload this to the issue tracker.

For larger patches (e.g. several commits), it is probably better to upload a modified version of the git repository, e.g. to github (see below).

For bug fixes, the least friction is caused if you branch of the 'maint' branch. Anything that goes into 'maint' is automatically rolled up-stream into 'master' and 'next'.

First of all, you should ask yourself if your code really belongs into the GNU Radio core. If you are developing a GNU Radio module which can exist completely separate of the GNU Radio code, it might be worth uploading it to CGRAN, where you can maintain the code yourself and don't have to go through the process of re-submitting patches.

Of course some features (say, new modulators or filters) belong into the core GNU Radio repository. In this case, sending a patch to the mailing list is a bit too bulky. Instead, upload your code to a world-readable git repository, and then post a 'Feature' on our issue tracker. This is explained greater detail here .

Before submitting, go through the following check list:
• Does the code include documentation? GNU Radio uses Doxygen for automatic doc generation, so be aware of this when documenting classes.
• Are there unit tests? Are they sensible unit tests, i.e. do they cover the most common errors?
• Does the patch maintain compatibility with the existing code base?
• Is the code based on the latest GNU Radio revision?
• Is the code nicely portable?
• Do you have a copyright assignment on file with the FSF?

If you're having any trouble with this, don't hesitate to ask on the mailing list.

## How can I use github to submit patches/features/changes?¶

Here's the easiest way:
• Make sure it compiles, works, and passes QA
• Wait for us to process that

## Which kind of patches are accepted into GNU Radio?¶

There is no definitive answer to this. Bug fixes and missing QA codes are of course always welcome.

Ultimately, the decision lies with the maintainers. If in doubt, consult the mailing list.

## How long does it take for my patch to become part of GNU Radio?¶

Again, there is no definitive answer to this. It depends on many things: the complexity and size of the patch, the current situation of development and the relevance of the patch.

However, the following things are guaranteed to delay acceptance:

## What if my patch works for master, but not for next?¶

Ideally, you do this:

1. Create a branch off master, say foo-master
2. Implement feature or fix on foo-master
3. Create a branch off next called foo-next
4. Merge foo-master into foo-next, fix up breakage
5. Implement feature or fix on foo-next (this might have been done or partially done as a result of getting through #4)
6. Tell us about foo-master and foo-next

Then we:

1. Merge foo-master into master. No problems since foo-master is branched from master.
2. Merge foo-next into next. No problems since #4 above already dealt with merge breakage
3. Merge master into next. This should end up being a null merge, but it maintains the master->next linkage

## What's this CGRAN?¶

The Comprehensive GNU Radio Archive Network (CGRAN) is a free open source repository for 3rd party GNU Radio applications that are not officially supported by the GNU Radio project''. In other words, it is a place for anybody to upload and publish extensions and modifications of and for GNU Radio.

If you are developing a GNU Radio project which works separately from the GNU Radio core, you might want to submit it to CGRAN rather than to the GNU Radio core. This way, you keep the write access to your published code and can maintain it independently from the core.

## Which coding conventions apply?¶

All contributions should conform to the GNU Coding Standards as modified for C++ in README.hacking

Also, you should check out The GNU Radio Coding Style Guide.

## How is the code documented?¶

GNU Radio uses Doxygen to document the source code. Any new block should use Doxygen markup structure to add to the Doxygen manual. Also, we use a list of groups to categorize all of the blocks, so when a new block is created, add this block to one or more of the available groups, a list of which can be found in docs/doxygen/other/group_defs.dox. Below is an example of a marked-up header file.

/*!
* \brief A new block that does something.
* \ingroup some_group
* \ingroup another_group
*
* Detailed description of what this block does.
* Quoting papers or textbooks is a good idea, too.
*/
class MODNAME_API new_block : public gr::block
{
private:
new_block(int param1, double param2);

public:
typedef boost::shared_ptr<glfw_sink_c> sptr;

/*!
* \brief Description of public_function()
* \param foo Describe foo
* \param bar Describe bar
*/
virtual int public_function(int foo, float bar) = 0;

/*!
* \param param1 Describe param1
* \param param2 Describe param2
*/
static sptr make(int param1, double param2);

};


Starting in GNU Radio 3.5, we have been moving to new top level blocks, like gr-vocoder, gr-audio, gr-digital, etc. Each of these is getting its own group along with any specific group the block should be included in. These groups each have their own page to describe the group as a main description of the blocks and how to use the package. These pages are all linked from the Doxygen manual's front page, which is found in docs/doxygen/other/main_page.dox.

The top level blocks are all described inside that blocks doc directory in a .dox files named or the component. For example, in the component gr-digital, the manual page describing this component is in gr-digital/doc/digital.dox. This page should provide any detail that can help users add and use these packages and their blocks. As these components are developed, used, and added to, any more details that can go into this Doxygen page should be added for the benefit of anyone else.

The component's doc directory will also contain a README.package that gives a brief description of the package. This file should contain the most basic necessary information and point to the Doxygen files for more detail.

### Doxygen Markup for Formulas¶

When inserting formulas into the header to be part of the documentation, we want to have the best representation possible, which means making Latex style formulas. This is done in Doxygen using the "\f{" to begin and "\f}" to end the formula section. However, these do not properly show up in the XML documents used in the Python help files. So we have to make the formula twice, once formatted for the HTML manual and another for the XML. It will look like this:

This is some text in the header...
\f{html}{
enter Latex formula here -> will only show up in the HTML document.
}

\xmlonly
Same Latex formula, but this will not be processed; will only be the raw Latex formula.
\endxmlonly

And here's some following text to the formulas.


Note that the spacing between sections is important to get the best output format. Furthermore, there are certain Doxygen markups that will cause a problem in the XML representation, like use the of \frac in Latex to create a fraction will not parse properly. There is likely a better way to handle this (PLEASE UPDATE IF YOU KNOW IT), but for now, we just add a space between them as "\ f".

Before we can accept non-trivial code contributions from you, we need a copyright assignment on file with the FSF. A description of the process is available here. Basically, this guarantees the FSF (who is copyright holder of GNU Radio) does not run into any legal trouble somewhere down the road.

This boils down to the following instructions:
• If you've developed some addition or patch to GNU Radio that you would like to contribute, you should send an email to the mailing list, or to one of the GNU Radio maintainers asking for an appropriate form. We might ask you for some more information at this point.
• You will be sent a short form by email which you should fill in and email back to the FSF.
• Once the FSF have received this email, they will send you a paper copy of the full copyright assignment papers for you to sign and post back to them.
• As soon as the signed paperwork is filed at the FSF we can accept your changes into the source tree.
• Individual small changes (fewer than 10 lines of code) can, however, be accepted without a copyright assignment form on file.

In order to get the process rolling, please email "tom AT trondeau" for a form to start the copyright process.