Breaking the Ice

From MyLabWiki
Revision as of 18:26, 2 April 2013 by Alex (Talk | contribs)

Jump to: navigation, search

Tips & tricks about creating a custom client to gr-ctrlport enabled flow graph.

Enable gr-ctrlport

Add to ~/.gnuradio/config.conf

 on = True
 edges_list = False
 config = /home/directory/.gnuradio/ctrlport.conf

Next, create ~/.gnuradio/ctrlport.conf (based on PREFIX/etc/gnuradio/ctrlport.conf.example):

 ControlPort.Endpoints = tcp -t 300 -h -p 43243

Test that gr-ctrlport is working properly by running the gr-blocks/examples/ctrlport/pfb_sync_test-qt.grc application in the source tree and the PREFIX/bin/gr-ctrlport-monitor python application (started automatically by pfb_sync_test-qt).

Hello gr-ctrlport

The Ice Manual contains a Hello World application that we can use as template. Read that chapter and try the example.

Translate gnuradio-runtime/lib/ to C++ code:

 $ slice2cpp

This will generate a gnuradio.h and gnuradio.cpp file.

Create a client.cpp file that can connect to gnuradio:

 #include <Ice/Ice.h>
 #include <gnuradio.h>
 using namespace std;
 using namespace GNURadio;
 int main(int argc, char* argv[])
     int status = 0;
     Ice::CommunicatorPtr ic;
     try {
         ic = Ice::initialize(argc, argv);
         Ice::ObjectPrx base = ic->stringToProxy("gnuradio:tcp -h localhost -p 43243");
         ControlPortPrx ctrlport = ControlPortPrx::checkedCast(base);
         if (!ctrlport)
             throw "Invalid proxy";
     } catch (const Ice::Exception& ex) {
         cerr << ex << endl;
         status = 1;
     } catch (const char* msg) {
         cerr << msg << endl;
         status = 1;
     if (ic)
     return status;

The above code will do nothing except establish a connection.

You can put the code below into a script for easy compilation of the client.cpp:

 c++ -I. -I$ICE_HOME/include -c gnuradio.cpp client.cpp
 c++ -o client gnuradio.o client.o -L$ICE_HOME/lib -lIce -lIceUtil