CanNotifyEvent


Function

Enable received data notifications.

Format

Ret = CanNotifyEvent ( Id , ChannelNo , EventType , CallBackProc , Param)

Parameters

Id [ C: short ] [ Python: ctypes.c_short ]
Specify the device ID retrieved from CanInit.

ChannelNo [ C: unsigned short ] [ Python: ctypes.c_ushort ]
Specify the channel number.

EventType [ C: unsigned short ] [ Python: ctypes.c_ushort ]
Specify the event type.

Definition

Value
[Hex]

Description

CCAN_EVENT_RECEIVE

0x01

Reception event

CallBackProc [ C : PCAN_EVENT_CALLBACK ] [ Python: PCAN_EVENT_CALLBACK ]
Specify the pointer to callback function.
The callback function is specified by a function pointer, but please note that the method of specification varies depending on the language.

Param [ C: void * ] [ Python: ctypes.c_void_p ]
Specify additional parameters for the callback.

Return Value

Ret [ C: long ] [ Python: ctypes.c_long ]

Definition

Value
[Dec]

Description

CAN_ERR_SUCCESS

0

Normality completion

CAN_ERR_DLL_INVALID_ID

10001

Invalid ID was specified.

CAN_ERR_DLL_CALL_DRIVER

10002

Driver can't be called (Failed in the ioctl).

CAN_ERR_DLL_EVENT_TYPE

10300

Event type beyond the limit.

CAN_ERR_SYS_CH_NO

20101

Channel number is outside the settable range.

The others (See also: Details of Error Code)

Initial Value

None

Remarks

By registering a callback function using this function, the callback function will be called when an event occurs.

Example

Register the callback function that will be called when a message is received (CCAN_EVENT_RECEIVE) in ChannelNo = 1.

C

long Ret;
Ret = CanNotifyEvent ( Id , 1 , CCAN_EVENT_RECEIVE , CallBackProc , NULL );
 

Python

Ret = ctypes.long()
Ret.value = ccan.CanNotifyEvent ( Id , 1 , CCAN_EVENT_RECEIVE , CallBackProc , 0 )

See Also

CanStopNotifyEvent


PCAN_EVENT_CALLBACK

Function

This is the form of event notification callback.

Format

void CallBackProc ( Id , Message , wParam , lParam , Param )

Parameters

Id [ C: short ] [ Python: ctypes.c_short ]
Specify the device ID retrieved from CanInit. The device ID of the device that generated the event is passed from the driver.

Message [C:  short ] [ Python: ctypes.c_short ]
The message number that caused the callback function to be called is passed.

Definition

Value
[Dec]

Description

CCAN_EVENT_RECEIVE

0x01

Reception event

wParam [C: int] [Python: ctypes.c_int]
This parameter is passed from the driver. Not used at present.

lParam [C: int] [Python: ctypes.c_int]
The channel number on which the received data is located is passed.

Param [C: void *] [Python: ctypes.c_void_p]
The parameter specified by the CanNotifyEvent function is passed.
It will be NULL when the Param parameter was specified to NULL.

Return Value

None