discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] How do I use the Gnuradio GRC XML RPC client or s


From: Marcus Müller
Subject: Re: [Discuss-gnuradio] How do I use the Gnuradio GRC XML RPC client or server components?
Date: Thu, 23 Apr 2015 09:36:03 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0

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:
        commanddict[command](valuestring)
    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

On 04/23/2015 05:05 AM, numeric wrote:
> 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.
>
> _______________________________________________
> Discuss-gnuradio mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio




reply via email to

[Prev in Thread] Current Thread [Next in Thread]