Python

Flow of Registering Callback Routine Function

・Checking function prototype definition of callback routine
・Creating callback routine
・Setting callback routine
 

The following explains how to use the callback function for Interrupt Input.
Please refer to the sample program for these specific coding contents.

For the callback function of Trigger Monitor, please refer to the description in the cdio.py file and read the prototype function as a reference.
 

Checking function prototype definition of callback function

To deal with callback functions in Python, we need to define a function prototype.
Function prototype declarations for each callback routine are in the cdio.py file.
Please check the contents of the function prototype.

For Interrupt Input

PDIO_INT_CALLBACK = ctypes.WINFUNCTYPE(None,
                                       ctypes.c_short, ctypes.wintypes.WPARAM,
                                       ctypes.wintypes.LPARAM, ctypes.c_void_p)
 

Creating Callback Function

A callback function has the following format. The function name is arbitrary.

For Interrupt Input

def int_callback(dev_id, wparam, lparam, param):
    ・・・・・
    retrun
 
pint_callback = cdio.PDIO_INT_CALLBACK(int_callback)
 

Setting Callback Function

Use the dio_id retrieved from DioInit function and set the created callback routine as follows.

For Interrupt Input

lret = cdio.DioSetInterruptCallBackProc(dio_id, pint_callback, 0)