Fwd: Re: USING SET/GET_GAIN UHD USRP FUNCTION

-------- 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 [email protected]
To: Martin B. [email protected]

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.
[email protected]

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 :slight_smile:

Greetings,
Marcus