# Fwd: Re: USING SET/GET\_GAIN UHD USRP FUNCTION

**URL:** <https://www.ruby-forum.com/t/fwd-re-using-set-get-gain-uhd-usrp-function/231819>\
**Category:** GNU Radio\
**Created:** [September 1, 2014, 3:29pm UTC](https://www.ruby-forum.com/t/fwd-re-using-set-get-gain-uhd-usrp-function/231819 "2014-09-01T15:29:16Z")\
**Posts on this page:** 2\
**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:** [September 1, 2014, 3:29pm UTC](https://www.ruby-forum.com/t/fwd-re-using-set-get-gain-uhd-usrp-function/231819/1 "2014-09-01T15:29:16Z")

</div>

-------- Original Message --------  
Subject: Re: [Discuss-gnuradio] USING SET/GET\_GAIN UHD USRP FUNCTION  
Date: Fri, 29 Aug 2014 11:33:03 +0200  
From: Simone Ciccia S210664 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: Martin B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Hi,  
thank you for the answer.  
I have created my own gnuradio block and linked the header that  
contains  
set/get\_gain function in the \_impl.cc by means of (#include  
\<gnuradio/uhd/usrp\_source.h\>).  
In the general work of \_impl.cc I call directly these functions as  
set/get\_gain(), but the compiler returns errors!  
Probably I’m forgetting to create the object that link this type of  
class  
in my code \_impl.cc

For example:

usrp\_source.h looks like this

namespace gr {  
namespace uhd {

```
class uhd_usrp_source;

class GR_UHD_API usrp_source : virtual public sync_block
{
public:
.................................

```

and in my code \_imple.cc I have defined the object now:

```
usrp_source object;
object->set_gain();

```

Anyway, it does not work…  
Do you know what I missing ? Probably this definition is wrong!

My best thanks for the help…  
Simone

On Thu, 28 Aug 2014 18:54:06 +0200, Martin B.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Simone\_Ciccia\_S2106](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e495f1/32.png) [@Simone\_Ciccia\_S2106](https://www.ruby-forum.com/u/Simone_Ciccia_S2106)\
**Post date:** [September 1, 2014, 3:51pm UTC](https://www.ruby-forum.com/t/fwd-re-using-set-get-gain-uhd-usrp-function/231819/2 "2014-09-01T15:51:52Z")

</div>

Hi Simone,

use the make function; you can’t directly instantiate a GNU Radio block  
for safety reasons, so the correct way to get one is doing

block\_name::sptr object\_pointer = block\_name::make(…);  
object\_pointer-\>method\_name()

(-\> is always a pointer dereference shortcut, ie.  
pointer\_to\_object-\>member is usually just a short form of  
(\*pointer\_to\_object).member; you can never use -\> on a non-pointer  
object, ie. classname object; object-\>member is always wrong).

Also, it’s always a good idea to include the compiler error, since that  
usually shows us what goes wrong, so we don’t have to guess 🙂

Greetings,  
Marcus
