Python call c pass a callback function on Linux
Jason Qian
jqian at tibco.com
Wed Jan 24 22:19:21 EST 2018
HI Dennis,
Thanks for the help, After changing WINFUNCTYPE to CFUNCTYPE, the call
back function works on the Linux :)
Thanks again,
Jason
On Wed, Jan 24, 2018 at 6:15 PM, Dennis Lee Bieber <wlfraed at ix.netcom.com>
wrote:
> On Wed, 24 Jan 2018 17:16:22 -0500, Jason Qian via Python-list
> <python-list at python.org> declaimed the following:
>
> >Hi,
> >
> > I have following code that works fine on windows.
> >
> You have not provided a minimal functional example...
>
> >InvocationCB=WINFUNCTYPE(None, c_char_p, c_int)
> >submit = lib.submit
>
> Where did lib.submit come from? No import statements are shown.
>
> >submit.argtypes = [ctypes.c_void_p, c_void_p,InvocationCB]
> >submit.restype = ctypes.c_int
> >
>
> You are setting things on the name submit yet...
>
> >def handleResponse(message, code):
> > print('--- handleResponse ---')
> > print(message)
> > print(code)
> >
> >class GSPythonDriver(object):
> > def submif(self,methodname)
>
> Is that a typo for submit?
>
> > invm_fn = InvocationCB(handleResponse)
> > lib.submit(self.obj,methodname,invm_fn)
>
> ... down here you are referring back to the full lib.submit (which may be
> the same object)
>
>
> No example instance of GSPythonDriver is created, and thereby
> nothing
> defined within it is invoked...
>
> However, the one thing that stands out is that WINFUNCTYPE is
> Windows
> "stdcall" specific, and ctypes defines CFUNCTYPE for the more global C
> calling conventions. But from there? You have to specify the proper library
> containing the functions you are invoking... Is that library (or
> equivalent) even available on your proposed target OS?
>
>
> --
> Wulfraed Dennis Lee Bieber AF6VN
> wlfraed at ix.netcom.com HTTP://wlfraed.home.netcom.com/
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list