How to instantiate uhd usrp sink in C++

Hi,

Can someone share an example of how to instantiate a uhd_usrp_sink in
C++?
Specifically

  1. What header file should I include?
  2. How do I declare the uhd sptr?
  3. What parameters should I pass to the make_uhd function?

(pls. forgive me for forgetting the exact names of classes and
functions)

Thanks.

On 05/13/2011 03:43 AM, [email protected] wrote:

Thanks.


Discuss-gnuradio mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

The UHD source code includes examples:

…uhd/host/examples

Perhaps my question was not too clear. I am looking for an example that
uses
gr-uhd in C++. I may be wrong but uhd/host/examples contain standalone
UHD
examples that do not use Gnuradio.

Thanks for your response. I am a new user and I appreciate your time
greatly.

R

On 05/13/2011 05:56 AM, [email protected] wrote:

Perhaps my question was not too clear. I am looking for an example that uses
gr-uhd in C++. I may be wrong but uhd/host/examples contain standalone UHD
examples that do not use Gnuradio.

Include gr_uhd_usrp_source.h or gr_uhd_usrp_sink.h, call the factory
function uhd_make_usrp_sink or uhd_make_usrp_source, and call functions
on that object.

http://gnuradio.org/cgit/gnuradio.git/tree/gr-uhd/include

-Josh

Hello again,

I am having trouble setting the io_type to the uhd_make_usrp_sink
function.
This is likely due to my unfamiliarity with C++.

The error printed on the screen:
“terminate called after throwing an instance of ‘std::invalid_argument’
what(): itemsize mismatch: sig_source_c(1):0 using 8, gr uhd usrp
sink(2):0 using 2
Aborted”

I am connecting the uhd_usrp_sink to a sig_source_c. Here is the
troublesome
code that I use to setup the uhd_usrp_sink:
uhd::device_addr_t addr; //I assume this defaults to “”
uhd::io_type_t type(2); //I want this to be COMPLEX_FLOAT32, but don’t
know
how to
gr_uhd_usrp_sink_sptr usrp_sink = uhd_make_usrp_sink(addr,type,1);

Thanks for your help.

Thanks – that did the trick. Cheers

On 05/13/2011 03:33 PM, [email protected] wrote:

I am connecting the uhd_usrp_sink to a sig_source_c. Here is the troublesome
code that I use to setup the uhd_usrp_sink:
uhd::device_addr_t addr; //I assume this defaults to “”
uhd::io_type_t type(2); //I want this to be COMPLEX_FLOAT32, but don’t know

Well thats the problem, there is no enum w/ value 2. Use one of the
build-in enums:
http://www.ettus.com/uhd_docs/doxygen/html/classuhd_1_1io__type__t.html

Also, you can pass uhd::io_type_t::COMPLEX_FLOAT32 directly as the
second argument.

-josh

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs