DioNotifyInterrupt


Function

Sets interrupt event factor.

Format

Ret = DioNotifyInterrupt ( Id , BitNo , Logic , hWnd )

Parameters

Id [ VB.NET: Short ] [ C, C++: short ] [ C#: short ] [ Python: ctypes.c_short ]
Specify the device ID retrieved from DioInit.

BitNo [ VB.NET: Short ] [ C, C++: short ] [ C#: short ] [ Python: ctypes.c_short ]
Specify logical input bit number. This bit number must be a bit available for interrupt on the hardware.

Logic [ VB.NET: Short ] [ C, C++: short ] [ C#: short ] [ Python: ctypes.c_short ]
Specify the interrupt logic by one of the following defined values.

Definition

Value

[Dec]

Description

DIO_INT_NONE

0

Interrupt mask

DIO_INT_RISE

1

Input value 0->1

DIO_INT_FALL

2

Input value 1->0

hWnd [ VB.NET: IntPtr ] [ C, C++: HWND ] [ C#: IntPtr ] [ Python: ctypes.wintypes.HANDLE ]
Specifies the window handle to receive the trigger message.
The window handle can be retrieved by m_hWnd in VC.
Specify it to 0 when you want to use callback function but not window message.

Return Value

Ret [ VB.NET: Integer ] [ C, C++: long ] [ C#: int ] [ Python: ctypes.c_long ]

Definition

Value

[Dec]

Description

DIO_ERR_SUCCESS

0

Normal completed.

DIO_ERR_SYS_RECOVERED_FROM_STANDBY

7

Execute DioResetDevice function because the device has recovered from standby mode.

DIO_ERR_DLL_INVALID_ID

10001

Invalid ID specified.

DIO_ERR_DLL_CALL_DRIVER

10002

Not call the driver (Failure on DEVICE I/O CONTROL).

DIO_ERR_DLL_CREATE_THREAD

10005

Not create the thread (Failure on CreateThread).

DIO_ERR_DLL_HWND

10200

Window handle beyond the limit.

DIO_ERR_SYS_NOT_SUPPORTED

20001

This board couldn't use this function.

DIO_ERR_SYS_USING_OTHER_PROCESS

20003

Other process is using the device, not execute.

DIO_ERR_SYS_BIT_NO

20102

Bit No. beyond the limit.

DIO_ERR_SYS_INT_BIT

20200

Interrupt bit beyond the limit.

DIO_ERR_SYS_INT_LOGIC

20201

Interrupt logic beyond the limit.

The others (See also: Details of Error Code)

Initial Value

The interrupt is masked.

Remarks

Specifies interrupt event to star or stop. The interrupt is the function that can detect rising edge or falling edge of input bit on the hardware and give notification.

The position and the number of input bits available for interrupt vary with the device. Refer to the hardware specifications of each device for details. Moreover, the interrupt logic is either the value of rising edge and falling edge.

Software parameters of DIO_INT_RISE and DIO_INT_FALL indicate input values of 0->1 and 1->0 respectively. Please note that for voltage level, the rising edge and falling edge are different depending on that the board is positive logic or negative logic.

The message ID is defined with DIOM_INTERRUPT = 1300H. When the interrupt occurs, the DIOM_INTERRUPT message is posted to the specified window handle through the PostMessage function.

LOWORD(wParam)=ID retrieved from DioInit
LOWORD(lParam)=Interrupt bit number
HIWORD(lParam)=Rising edge: 1, Falling edge: 2
* HIWORD indicates the high-order word. LOWORD indicates the low-order word.

For USB devices, only one process can accept interrupt events.
The message cannot be sent from the same device to two or more processes.
To use this function, hardware should support interrupt.

For details about message handling, please refer to the sample programs of each language.
To enable the interrupt for more than one bit, call this function for each corresponding bit.

For Ethernet devices
    If communication with the device is lost, the process will be unregistered and will no longer receive event notifications.
    If you want to perform event notification again, please make the settings again using this function.

     You can check the registration status of the current process using the DioGetNetCommunicationInfo function.

Example

Monitors the input change of 0->1 for logical bit 0.

VB.NET

Dim Ret As Integer
Ret = DioNotifyInterrupt ( Id , 0 , DIO_INT_RISE , Handle )
 

C, C++

long Ret;
Ret = DioNotifyInterrupt ( Id , 0 , DIO_INT_RISE , m_hWnd );
 

C#

int Ret;
Ret = dio.NotifyInterrupt ( Id , 0 , (short)CdioConst.DIO_INT_RISE , Handle );
 

Python

Ret = ctypes.c_long()
handle = ctypes.windll.user32.FindWindowW(0, "Interrupt")
Ret.value = cdio.DioNotifyInterrupt ( Id , 0 , cdio.DIO_INT_RISE , handle )
 

See Also

DioGetNetCommunicationInfo