Interfacing to USRP2 with C++


#1

Hi,
I am currently trying to write a C++ program that interfaces to
USRP2. I was able to successfully complete the tutorial found at
http://www.gnuradio.org/trac/wiki/UsrpFAQ/CppInterface for interfacing
to the USRP1 despite the example code being a little outdated. What
changes with interfacing with USRP2? Is there a similar tutorial for
the USRP2?

Thanks in advance!

Jon Peck


#2

On Tue, Feb 03, 2009 at 04:29:12PM -0500, Jonathan Peck wrote:

Hi,
I am currently trying to write a C++ program that interfaces to
USRP2. I was able to successfully complete the tutorial found at
http://www.gnuradio.org/trac/wiki/UsrpFAQ/CppInterface for interfacing
to the USRP1 despite the example code being a little outdated. What
changes with interfacing with USRP2? Is there a similar tutorial for
the USRP2?

Thanks in advance!
Jon Peck

There’s no tutorial.

Have you looked at usrp2/host/include/usrp2/usrp2.h?

Eric


#3

On Wed, 2009-02-04 at 08:59 -0500, Jonathan Peck wrote:

g++ Output:
jpeck@LT14:~/usrp2-demo/usrp2-getdata$ g++ usrp2_demo.cc -o usrp2demo -lusrp2
/usr/local/lib/libusrp2.so: undefined reference to
gruel::sys_pri::usrp2_backend()' /usr/local/lib/libusrp2.so: undefined reference togruel::enable_realtime_scheduling(gruel::rt_sched_param)’
collect2: ld returned 1 exit status

You need to also link in the libgruel and omnithreads library. An easy
way to do this is to use the pkg-config command. To compile and link in
one step your single .cc file:

g++ -o usrp_demo pkg-config --cflags --libs usrp2 usrp_demo.cc

The pkg-config utility will use our supplied configuration files and
create the proper compiler and linker flags for you.

Johnathan


#4

Eric,
Yes, I have looked at that header file. I wrote a small program to
try using the usrp2 class and tried to compile it without success.

Code usrp_demo.cc:
#include <usrp2/usrp2.h>

int main()
{
const char *interface = “eth0”;
const char *mac_addr_str = “00:05:2c:85:30:a7”;

usrp2::usrp2::sptr u2 = usrp2::usrp2::make(interface, mac_addr_str);

/* do stuff here */

return 0;
}

g++ Output:
jpeck@LT14:~/usrp2-demo/usrp2-getdata$ g++ usrp2_demo.cc -o usrp2demo
-lusrp2
/usr/local/lib/libusrp2.so: undefined reference to
gruel::sys_pri::usrp2_backend()' /usr/local/lib/libusrp2.so: undefined reference togruel::enable_realtime_scheduling(gruel::rt_sched_param)’
collect2: ld returned 1 exit status

Any idea on what I’m doing wrong?

-Jon