Callback from C++ to Python Passing gr_message_sptr

Hi,

I’m working on a C++ extension.

How can we use SWIG to program a callback from C++ to Python that passes
a
gr_message_sptr? I’m trying to avoid polling the C++ module from Python
code.

Rgds,
Jeremy

On Wed, Jan 03, 2007 at 04:19:24PM +0800, Jeremy Chew wrote:

Hi,

I’m working on a C++ extension.

How can we use SWIG to program a callback from C++ to Python that passes a
gr_message_sptr? I’m trying to avoid polling the C++ module from Python
code.

Rgds,
Jeremy

Look at the code in gr_feval.{h,cc,i}, and the test code in qa_feval.py.
It currently supports callbacks from C++ to python using double,
complex, long and void. Passing a gr_message_sptr is completely
analogous.

Eric

It seems that gr_feval is called from Python and returns to Python, or
is
called from C and returns to C, if I’m not mistaken.

What I need to do is connect a pre-existing C++ MAC module with Python.
Packets go in and out at the top and bottom of the MAC layer. Each
packet
does not go in and out of the MAC all within a single synchronous call.
With
the MAC working this way, how do we use gr_feval* without having the
Python
program poll the MAC?

Jeremy
----- Original Message -----
From: “Eric B.” [email protected]
To: “Jeremy Chew” [email protected]
Cc: [email protected]
Sent: Wednesday, January 03, 2007 4:57 PM
Subject: Re: [Discuss-gnuradio] Callback from C++ to Python Passing
gr_message_sptr

On Wed, Jan 03, 2007 at 09:39:31PM +0800, Jeremy Chew wrote:

It seems that gr_feval is called from Python and returns to Python, or is
called from C and returns to C, if I’m not mistaken.

You are mistaken.

Eric

I’ve been looking at swig.org and gnu.org. What else would be good to
look
at?

I suppose to implement the callback from C++ to Python, I declare a new
class in Python that inherits from gr_feval.

I wonder how we specify in C++ the call to the new class in Python. And
how
do we pass the gr_message_sptr from C++ to Python code? The example I
see
shows only simple calls, all from Python.

I’m really feeling lost so some inputs would help.

Jeremy

----- Original Message -----
From: “Eric B.” [email protected]
To: “Jeremy Chew” [email protected]
Cc: [email protected]
Sent: Wednesday, January 03, 2007 10:06 PM
Subject: Re: [Discuss-gnuradio] Callback from C++ to Python Passing
gr_message_sptr