first thing:
The argtypes of ctypes WINFUCNTYPE or CFUNCTYPE should be a c_void_p
The argtypes of fucntion which you are defining should be py_object instead of a c_void_p
so that you can pass objects of structures and arrays as well.
then in the callback fucntion cast the void_p data as
ct.cast(userdata,ct.py_object).value
second thing:
code running only once: put a return value at bottom of the code.
return 1 or return TRUE
example:
CALLBACKFUNC = WINFUNCTYPE("returnvalue",c_int,c_void_p)
kvSetNotifyCallback.argtypes = [c_int,CALLBACKFUNC,py_object,c_uint]
then in the fucntion:
def can_rx(arg1,arg2):
arg3 = cast(arg2,py_object).value #yields object value
print arg1
print arg3
return 1 #for continuing execution
The CALLBACK FUNCTION can_rx should be called at CALLBACKFUNC(can_rx), the data to be passed along with arg1 should be passed at py_object position.
so you should call your callback as:
kvSetNotifyCallback(somevalue,CALLBACKFUC(can_rx),arg2,canNOTIFY_RX)
arg2 is the value to be passed to the callback func can_rx
can_rx can be defined as a global function also.