# How do I use the Gnuradio GRC XML RPC client or server components?

**URL:** <https://www.ruby-forum.com/t/how-do-i-use-the-gnuradio-grc-xml-rpc-client-or-server-components/241677>\
**Category:** GNU Radio\
**Created:** [April 23, 2015, 5:22am UTC](https://www.ruby-forum.com/t/how-do-i-use-the-gnuradio-grc-xml-rpc-client-or-server-components/241677 "2015-04-23T05:22:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [April 23, 2015, 5:22am UTC](https://www.ruby-forum.com/t/how-do-i-use-the-gnuradio-grc-xml-rpc-client-or-server-components/241677/1 "2015-04-23T05:22:34Z")

</div>

Please understand, I know nothing about networking, client, server, rpc,  
marshaling, sockets, Python and all newer programming environments.  
However;  
I do know C,C++ and understand Windows messaging, wait for single  
object,  
wait for multiple objects and similar Windows API stuff. Not sure if  
there  
is a counterpart in Linux.  
I want to use an external program, written in Pascal, running on the  
same  
machine and independent from Gnuradio, to control variables on the GRC  
flow  
graph. Specifically, I want to control the frequency, gain and more as  
needed of an Ettus B200 SDR. The Pascal program runs natively, on Ubuntu  
Linux; it does not require wine or any other Windows emulation. I know  
this  
may be difficult, as most examples are scripted in Python.  
Any help is greatly appreciated.

–  
View this message in context:  
[http://gnuradio.4.n7.nabble.com/How-do-I-use-the-Gnuradio-GRC-XML-RPC-client-or-server-components-tp53427.html](http://gnuradio.4.n7.nabble.com/How-do-I-use-the-Gnuradio-GRC-XML-RPC-client-or-server-components-tp53427.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![robredford](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7ea924/32.png) [@robredford](https://www.ruby-forum.com/u/robredford)\
**Post date:** [April 23, 2015, 9:38am UTC](https://www.ruby-forum.com/t/how-do-i-use-the-gnuradio-grc-xml-rpc-client-or-server-components/241677/2 "2015-04-23T09:38:05Z")

</div>

Hi numeric,

bad news first: considerable amount of work goes into making GNU Radio,  
which, at its core, is a C++ library, work with python, up to the point  
that you can actually use python classes inside the GNU Radio framework.  
The same level of integration won’t (without massive effort) be  
attainable for pascal.

However, the xmlrpc blocks just use standard-conforming XML-RPC calls,  
so maybe this “official recommendations” document is of interest to you  
[1].

Now, for almost any language out there exist XML-RPC implementations, I  
guess – however, if that is the case for Pascal (I guess you’re using  
freepascal?), I don’t know. Maybe you’ll have to swallow the pill and  
either write a “Pascal-writes-stuff-into-a-pipe” to XML-RPC converter in  
your language of choice (in python, that would be but this much code,  
approximately, untested:

#!/usr/bin/python2  
import xmlrpclib  
s = xmlrpclib.Server(‘[http://localhost:8080](http://localhost:8080)’)  
commanddict = { “frequency”: lambda x: s.set\_freq(float(x)) ,  
“gain”: lambda x: s.set\_gain(float(x)),  
“taps”: lambda x:  
s.set\_filtertaps(list(map(float,x.split(“,”)))),  
“stop”: lambda x: s.stop()  
}  
inputfile = open(“/path/to/the/fifo”, “r”)  
while True:  
line = inputfile.readline()  
if line.lower().startswith(“exit”):  
break  
command, valuestring = line.split(“:”)  
#now, get command from dictionary and apply it to string  
try:  
commanddictcommand  
except: #this happens if the command is not in the dict, or  
something went wrong doing RPC  
pass # don’t do anything, just wait for the next command

Now, of you’ll need to  
mkfifo /path/to/the/fifo

and have your pascal program write lines of the scheme

gain:34  
taps:1,2,3,4.0  
stop:nowtheflowgraphdiesandthiscommandjustneedsaparameter  
exit

to that filename.

I assume things are equally easy in C++, but I’ve never tried XML-RPC  
from C++, and all the string-juggling really gets easy in python, imho.

Best regards,  
Marcus

---

<div class="post-metadata">

**Author:** ![robredford](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7ea924/32.png) [@robredford](https://www.ruby-forum.com/u/robredford)\
**Post date:** [April 25, 2015, 8:21am UTC](https://www.ruby-forum.com/t/how-do-i-use-the-gnuradio-grc-xml-rpc-client-or-server-components/241677/3 "2015-04-25T08:21:20Z")

</div>

Thank you Marcus for your reply.

Yes; to answer your question. The Linux version is Freepascal with the  
Lazarus IDE. It is very much like Delphi with a useful exception. No BDE  
(Borland Database Engine) is required.

You have given me an idea for a plan to solve my question. If the XMLPRC  
is  
a DLL then freepascal can directly import the DLL and gain access to  
it’s  
functions. No need to pipe the string to a convertor.  
Today my USB drive got messed up. I have to re-load Linux, gnuradio and  
Lazarus to continue the effort. A day or two should complete the  
restoration; the "BOSS " (not the boss at work) permitting.

Rob

Marcus Müller-3 wrote

> while True:
> 
> to that filename.
> 
> I assume things are equally easy in C++, but I’ve never tried XML-RPC  
> from C++, and all the string-juggling really gets easy in python, imho.
> 
> Best regards,  
> Marcus

–  
View this message in context:  
[http://gnuradio.4.n7.nabble.com/How-do-I-use-the-Gnuradio-GRC-XML-RPC-client-or-server-components-tp53427p53471.html](http://gnuradio.4.n7.nabble.com/How-do-I-use-the-Gnuradio-GRC-XML-RPC-client-or-server-components-tp53427p53471.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).
