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

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
Sent from the GnuRadio mailing list archive at Nabble.com.

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’)
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

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
Sent from the GnuRadio mailing list archive at Nabble.com.

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