CanInit


Function

Retrieves the device ID, then the device can be accessed.

Format

Ret = CanInit ( DeviceName , Id )

Parameters

DeviceName [ C: char * ] [ Python: ctypes.c_char_p ]
Specify the device name set with the setup tool(config). Device name is maximum 50 characters(NULL is included).

Id [ C: short * ] [ Python: ctypes.POINTER(ctypes.c_short) ]
A device ID is returned. By using this device ID, you can access the device in the following functions.

Return Value

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

Definition

Value
[Dec]

Description

CAN_ERR_SUCCESS

0

Normality completion

CAN_ERR_INI_MEMORY

3

Failed in the allocation of the memory.

CAN_ERR_INI_REGISTRY

4

Failed in the access of setting file.

CAN_ERR_DLL_DEVICE_NAME

10000

Device name which isn't registered in setting file is specified.

CAN_ERR_DLL_CALL_DRIVER

10002

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

CAN_ERR_DLL_CREATE_FILE

10003

Failed in the creation of the file (Failed in open).

CAN_ERR_INFO_INVALID_DEVICE

10050

Specified device name is not found. Please check spelling.

CAN_ERR_INFO_NOT_FIND_DEVICE

10051

Not found the available device.

The others (See also: Details of Error Code)

Initial Value

None

Remarks

Retrieves the device ID, then the device can be accessed.
By using this device ID, you can access the device in the following functions.
When accessing more than one device, please prepare corresponding variables to store the IDs.
After CanInit completed normally, and before CanExit is called, every function can be used.

Only one process can access one device.

Example

Initializes the device "CAN000" and retrieves the Id.

C

long Ret;
short Id;
Ret = CanInit ( "CAN000" , &Id );
 

Python

Ret = ctypes.c_long()

Id = ctypes.c_short()
Ret.value = ccan.CanInit("CAN000",ctypes.byref(Id))
 

See Also

CanExit