discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] Changing the value of a Python Variable into a bl


From: Josh Blum
Subject: Re: [Discuss-gnuradio] Changing the value of a Python Variable into a block
Date: Tue, 24 Jan 2012 11:31:14 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111124 Thunderbird/8.0


On 01/24/2012 10:42 AM, André Selva wrote:
> Hello!
> 
> I'm developing a TV enconder, and I need to extract information from my
> input data, and this will be used to determine the parameters of other
> blocks on the flow graph.
> How can I change the value of a variable of the python (or grc) environment
> from the block general_work() method?
> 

Well, you generally cant call a python function from c++.... but heres a
few ways that may accomplish what you need:

1) Using swig directors is a possibility. Rather than figure out the
intricacies of directors, gnuradio already makes use of them in the
gr.feval_* class, which you can use to call into a python object. Your
general_work() calls the feval object in c++; and then feval object
(from python) directly calls into other variables in the python-domain
of your flow graph.

2) Another possibility is passing messages into a message queue object.
A python thread can pop the messages and act upon them.

3) A related possibility, depending upon how your block operates would
be to have a python thread periodically poll the getter methods of your
custom block and act upon those values. There is already a block in grc
that will poll another block's getter function and update a variable.

4) You could write the general work in python, which means all of the
parameter calculation and setting occurs entirely in python (this
functionality is not yet officially accepted).
http://gnuradio.org/redmine/projects/gnuradio/wiki/WriteBlocksInPython

5) And if thats not possible for performance reasons, you might consider
a hybrid approach where you write general work in python, but you call
into a function implemented in c++; where this function processes the
input data and returns the "determined parameters", which you can act on
in python.

-Josh



reply via email to

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