# How to access UHD from within my own OOT block?

**URL:** <https://www.ruby-forum.com/t/how-to-access-uhd-from-within-my-own-oot-block/232415>\
**Category:** GNU Radio\
**Created:** [October 8, 2014, 4:03pm UTC](https://www.ruby-forum.com/t/how-to-access-uhd-from-within-my-own-oot-block/232415 "2014-10-08T16:03:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [October 8, 2014, 4:03pm UTC](https://www.ruby-forum.com/t/how-to-access-uhd-from-within-my-own-oot-block/232415/1 "2014-10-08T16:03:20Z")

</div>

Dear all,

In the Companion GUI I use the UHD source- and sink-blocks, together  
with my own OOT blocks. Now I want to control the UHD blocks from within  
my own blocks, for example changing the center frequency. So in my own  
block I would like to write something like:

```
usrp->set_center_freq(whatever);

```

I there an easy interface/API available to do this? Or do I have to  
download the gr-uhd, modify it (maybe add a method to get a pointer to  
the USRP out of it?) and rebuild? Unfortunately I just could not find a  
starting point yet.

Regards,

```
  Jeroen

```

Dit bericht kan informatie bevatten die niet voor u is bestemd. Indien u  
niet de geadresseerde bent of dit bericht abusievelijk aan u is  
toegezonden, wordt u verzocht dat aan de afzender te melden en het  
bericht te verwijderen. TNO aanvaardt geen aansprakelijkheid voor de  
inhoud van deze e-mail, de wijze waarop u deze gebruikt en voor schade,  
van welke aard ook, die verband houdt met risico’s verbonden aan het  
elektronisch verzenden van berichten.

This message may contain information that is not intended for you. If  
you are not the addressee or if this message was sent to you by mistake,  
you are requested to inform the sender and delete the message. TNO  
accepts no liability for the content of this e-mail, for the manner in  
which you use it and for damage of any kind resulting from the risks  
inherent to the electronic transmission of messages.

---

<div class="post-metadata">

**Author:** ![BoschmaS\_J.JSSJero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8c91f0/32.png) [@BoschmaS\_J.JSSJero](https://www.ruby-forum.com/u/BoschmaS_J.JSSJero)\
**Post date:** [October 8, 2014, 4:12pm UTC](https://www.ruby-forum.com/t/how-to-access-uhd-from-within-my-own-oot-block/232415/2 "2014-10-08T16:12:05Z")

</div>

Hi Jeroen,

the usrp blocks have public methods to do exactly that. It really looks  
like what you’ve proposed 🙂

Not so long ago, Martin added support for doing things like that by  
sending messages or stream tags to the block, too.

As you haven’t found a starting point yet: Here’s GNU Radio’s official  
API documentation:  
[http://gnuradio.org/doc/doxygen/](http://gnuradio.org/doc/doxygen/)  
and the gr-uhd blocks are here:  
[http://gnuradio.org/doc/doxygen/group\_\_uhd\_\_blk.html](http://gnuradio.org/doc/doxygen/group __uhd__ blk.html)  
[http://gnuradio.org/doc/doxygen/namespacegr\_1\_1uhd.html](http://gnuradio.org/doc/doxygen/namespacegr_1_1uhd.html)

Quite straightforward 🙂

Greetings,  
Marcus

---

<div class="post-metadata">

**Author:** ![BoschmaS\_J.JSSJero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8c91f0/32.png) [@BoschmaS\_J.JSSJero](https://www.ruby-forum.com/u/BoschmaS_J.JSSJero)\
**Post date:** [October 8, 2014, 4:18pm UTC](https://www.ruby-forum.com/t/how-to-access-uhd-from-within-my-own-oot-block/232415/3 "2014-10-08T16:18:31Z")

</div>

Regardless of the application, UHD or otherwise, this is not what you  
should be doing. Use the message interface for this, it is described on  
the  
gr-uhd manual page.

M

---

<div class="post-metadata">

**Author:** ![BoschmaS\_J.JSSJero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8c91f0/32.png) [@BoschmaS\_J.JSSJero](https://www.ruby-forum.com/u/BoschmaS_J.JSSJero)\
**Post date:** [October 10, 2014, 4:40am UTC](https://www.ruby-forum.com/t/how-to-access-uhd-from-within-my-own-oot-block/232415/4 "2014-10-10T04:40:04Z")

</div>

Two things:

1. Martin was right, doing this using messages is cleaner!
2. GRC generates python files when you click the generate button. You  
can change these files to your heart’s delight; most C++ public  
functions are even exported to the encapsulating python class.  
Furthermore, you can write blocks in C++ and python, and you can write  
hierarchical and top\_blocks also in C++ and python, so calling public  
functions of blocks is really the easiest thing you will concern  
yourself with when doing GNU Radio development.

The GNU Radio website has new, exciting tutorials, and I encourage you  
to go through them. As it seems, the first few tutorials will can be  
done quickly with your experience!

Greetings,  
Marcus

---

<div class="post-metadata">

**Author:** ![BoschmaS\_J.JSSJero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8c91f0/32.png) [@BoschmaS\_J.JSSJero](https://www.ruby-forum.com/u/BoschmaS_J.JSSJero)\
**Post date:** [October 9, 2014, 10:17am UTC](https://www.ruby-forum.com/t/how-to-access-uhd-from-within-my-own-oot-block/232415/5 "2014-10-09T10:17:55Z")

</div>

Hi Jeroen,  
here a link where there is an example about how to use UHD class.

> **[USRP Hardware Driver and Device Manual: uhd::usrp::multi\_usrp Class Reference](https://files.ettus.com/manual/classuhd_1_1usrp_1_1multi__usrp.html)**

go in section “Detailed description”.  
Give me a feedback if you are able to use this class in our own block.  
Bests,  
Simone

On Wed, 8 Oct 2014 14:01:39 +0000, “Boschma, J.J. (Jeroen)”  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Dear all,
> 
> In the Companion GUI I use the UHD source- and sink-blocks, together with  
> my own OOT blocks. Now I want to control the UHD blocks from within my  
> own  
> blocks, for example changing the center frequency. So in my own block I  
> would like to write something like:
> 
> ```
> usrp->set_center_freq(whatever);
> 
> ```
> 
> I there an easy interface/API available to do this? Or do I have to  
> download the gr-uhd, modify it (maybe add a method to get a pointer to  
> the  
> niet de geadresseerde bent of dit bericht abusievelijk aan u is  
> toegezonden, wordt u verzocht dat aan de afzender te melden en het  
> bericht
