[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Discuss-gnuradio] Python function processing block
From: |
Johnathan Corgan |
Subject: |
Re: [Discuss-gnuradio] Python function processing block |
Date: |
Mon, 02 Oct 2006 09:08:00 -0700 |
User-agent: |
Thunderbird 1.5.0.7 (X11/20060918) |
Marcus Leech wrote:
> There was discussion on the list a few months ago about adding the
> ability to hook a python function
> into the processing chain. I don't remember what the conclusion of
> that discussion was.
>
> I have a need to be able to hook a user-defined Python code snippet into
> the processing chain, near the end
> where the sample rate is very low (1Hz). Is this easily done, and if
> so, how?
Take a look at gr.feval_xx class:
http://gnuradio.org/trac/browser/gnuradio/trunk/gnuradio-core/src/lib/general/gr_feval.h
It defines a function 'eval' that can be called either from C++ or from
Python. In Python you can subclass this and override the eval function
with whatever you want. When the function is called from C++, control
flow passes to the Python interpreter to evaluate the function and return.
I haven't used it myself, but you can get a good feel for what is
possible by looking at the QA code for the block at:
http://gnuradio.org/trac/browser/gnuradio/trunk/gnuradio-core/src/python/gnuradio/gr/qa_feval.py
Johnathan Corgan, AE6HO
address@hidden