# How to register mods/demods

**URL:** <https://www.ruby-forum.com/t/how-to-register-mods-demods/226148>\
**Category:** GNU Radio\
**Created:** [December 15, 2010, 4:50am UTC](https://www.ruby-forum.com/t/how-to-register-mods-demods/226148 "2010-12-15T04:50:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kyle\_Z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/6f9a4e/32.png) [@Kyle\_Z](https://www.ruby-forum.com/u/Kyle_Z)\
**Post date:** [December 15, 2010, 4:50am UTC](https://www.ruby-forum.com/t/how-to-register-mods-demods/226148/1 "2010-12-15T04:50:19Z")

</div>

I am writing a custom modulator/demodulator and wanna add them to the  
modulation\_utils, such that modulation\_utils.type\_1\_mods() will include  
the custom made mod/demod. However, I could not figure out how to do  
that.

I notice mods/demods have something like

modulation\_utils.add\_type\_1\_mod(‘dbpsk’, dbpsk\_mod)  
modulation\_utils.add\_type\_1\_demod(‘dbpsk’, dbpsk\_demod)

to register themselves to the registry.

This is supposed to be run when mod/demod are loaded.

However, I am not quite sure how I can make them be loaded?  
I check the benchmark\_tx.py and find no code that results in mod/demod  
being loaded.

Help appreciated.  
Kyle

---

<div class="post-metadata">

**Author:** ![Kyle\_Z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/6f9a4e/32.png) [@Kyle\_Z](https://www.ruby-forum.com/u/Kyle_Z)\
**Post date:** [December 15, 2010, 7:26pm UTC](https://www.ruby-forum.com/t/how-to-register-mods-demods/226148/2 "2010-12-15T19:26:36Z")

</div>

When the file in which you define you mod/demod is imported the  
mod/demod will the registered so it’s just a case of making sure it  
gets imported somewhere.

The mod/demods that come with gnuradio are registered when  
gnuradio.blks2 is imported. This doesn’t happen explicitly in  
benchmark\_tx.py so presumably one of the modules the benchmark imports  
imports blks2.

To make sure your mod/demods get registered the easiest way would be  
to import the file where you define them directly into  
benchmark\_tx.py. Alternately you could place the file in the  
blks2impl directory (and the Makefile.am there) so that they will be  
imported with the ones that come with gnuradio.

Ben

---

<div class="post-metadata">

**Author:** ![Kyle\_Z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/6f9a4e/32.png) [@Kyle\_Z](https://www.ruby-forum.com/u/Kyle_Z)\
**Post date:** [December 15, 2010, 11:52pm UTC](https://www.ruby-forum.com/t/how-to-register-mods-demods/226148/3 "2010-12-15T23:52:16Z")

</div>

On 16/12/2010 5:23 AM, Ben R. wrote:

> to import the file where you define them directly into  
> benchmark\_tx.py. Alternately you could place the file in the  
> blks2impl directory (and the Makefile.am there) so that they will be  
> imported with the ones that come with gnuradio.
> 
> Ben

Thanks Ben for your detailed explanation.  
Yes, transmit\_path.py and receive\_path.py import blks2, which imports  
everything under blks2impl directory.  
Well, I think I will import my mod/demod directly in my top\_block.  
Thanks again  
Kyle

---

<div class="post-metadata">

**Author:** ![Kyle\_Z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/6f9a4e/32.png) [@Kyle\_Z](https://www.ruby-forum.com/u/Kyle_Z)\
**Post date:** [December 16, 2010, 2:06am UTC](https://www.ruby-forum.com/t/how-to-register-mods-demods/226148/4 "2010-12-16T02:06:31Z")

</div>

On Wed, Dec 15, 2010 at 5:50 PM, Kyle Z. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 
> 
> Yes, transmit\_path.py and receive\_path.py import blks2, which imports  
> everything under blks2impl directory.  
> Well, I think I will import my mod/demod directly in my top\_block.  
> Thanks again  
> Kyle

You can see what types of mods and demods are available with:  
print blks2.modulation\_utils.type\_1\_mods()  
print blks2.modulation\_utils.type\_1\_demods()

Tom
