Re: How to instantiate uhd usrp sink in C++

Posted by Josh B. (Guest)
on 2011-05-14 00:40
[image: (Received via mailing list)]

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

how to
gr_uhd_usrp_sink_sptr usrp_sink = uhd_make_usrp_sink(addr,type,1);

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

Hi,
josh, I am also want to instantiate uhd usrp sink in C++, I google it
and
find your email.
My problem is when I use gr_uhd_usrp_sink_sptr usrp_sink =
uhd_make_usrp_sink(addr,type,1);
but its error information is:‘gr_uhd_usrp_sink_sptr’ was not declared in
this scope.
And I read the source code from the URL:
lib « gr-uhd - gnuradio.git - GNU Radio, the class
uhd_usrp_sink has many pure virtual functions and it inherited in
python,
in the source code uhd_swig.py, how can we directly instantiate
uhd_usrp_sink in C++?
Due to my unfamiliarity with C++ and maybe it looks a bit ridiculous,
Hey!
Thanks very much for your help in advance!

You may want to see the c++ examples here to see how to instantiate:
http://gnuradio.org/cgit/gnuradio.git/tree/gr-uhd/examples/c++/

-josh

Hi,
Josh, Thanks for your help very much!
I use the file sink in C++ to verify the flow graph, as follows:

tb = gr_make_top_block(“send”);
file_sink = gr_make_file_sink(sizeof(gr_complex), filenamein.c_str());
tb->connect(amp,0, file_sink,0);

it run fine. but if I use the usrp sink, as follows:

double freq= 2450e6;
int gain = 35;

boost::shared_ptr<uhd_usrp_sink> usrp_sink =
uhd_make_usrp_sink(device_addr,uhd::stream_args_t(“fc32”));
usrp_sink->set_center_freq(freq);
usrp_sink->set_gain(gain);
tb->connect(amp,0, usrp_sink,0);

Its error information is:
Uterminate called after throwing an instance of
'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injectorboost::math::rounding_error


what(): Error in function boost::math::round(d): Value inf can not
be
represented in the target integer type.
ѷ (core dumped)

I google it and someone said The value"inf" is usually due to a
divide-by-zero error somewhere in the chain.
from the URL:Uhd digital-bert script! - GNU Radio - Ruby-Forum

But I do not know how to correct it, so, Thanks very much for your help!
Best Regard!

2012/5/11 Josh B. [email protected]