Hi,
I’m using an older version as this is what that came when I downloaded
GR a
few months ago and I haven’t seen a need to change what I have
installed.
I’m new to GR, Linux and Python so I’m more eager to debug what I have
without introducing even newer stuff.
Anyway, the earlier problem was due to a C++ bug affecting another
thread.
This has been fixed. Now there’s a problem with passing the packets
created
in the C++ extension, called sm, to Python.
The following describes what I do, which is setting the callback, and
then
calling the callback.
SETTING THE CALLBACK POINTER IN THE C++ EXTENSION
The Python call that is to receive the packet from the C++ extension is
inherited from null_mac class and is named self.fg.send_pkt(). It is
passed
from a sub-class of null_mac in Python to the extension with:
sm.settx2llecallback(self.fg.send_pkt)
The corresponding C++ call is:
static PyObjects_pcTxDnCallback=0;
…
static
PyObjectsm_settx2llecallback(PyObjecta_pcSelf,PyObjecta_pcArgs)
{…
PyObject*l_pcCallback=0;
…
if(PyArg_ParseTuple(a_pcArgs,“O:set_callback”,&l_pcCallback))
{
if(PyCallable_Check(l_pcCallback))
{…
Py_XINCREF(l_pcCallback);
s_pcTxDnCallback=l_pcCallback;
…
}
When the above executes, PyCallable_Check() seems to run with no error.
PASSING PACKETS FROM THE EXTENSION TO PYTHON CODE
Later, a packet is created in the C++ extension in the form of an
unsigned
char array. To pass it to the Python IP tunneling code, I do the
following:
BOOL Tx2PyLle(unsigned chardata,UINT16 len)
{
…
PyObjectl_pcArgs=0;
…
l_pcArgs=Py_BuildValue(“(s#)”,reinterpret_cast<char*>(data),static_cast(len));
if(l_pcArgs )
{…
assert(s_pcTxDnCallback);
…;
PyObject*l_pcRet=PyEval_CallObject(s_pcTxDnCallback,l_pcArgs);
…
}
This function above has a segmentation fault at PyEval_CallObject().
My queries are:
-
Is the callback to Python passed and set correctly in the extension?
-
Is it right to assume that in Python, the packets are Python strings?
Thanks a lot,
Jeremy
----- Original Message -----
From: “Eric B.” [email protected]
To: “Jeremy Chew” [email protected]
Cc: [email protected]
Sent: Tuesday, November 28, 2006 2:53 AM
Subject: Re: [Discuss-gnuradio] Problem with my modified IP tunnelling
example