ncOpenObject

NI-CAN

ncOpenObject

Purpose

Open an object.

Format

NCTYPE_STATUS ncOpenObject(
NCTYPE_STRING ObjName,
NCTYPE_OBJH_P ObjHandlePtr)

Input

ObjName

ASCII name of the object to open.

Output

ObjHandlePtr

Pointer used to return the Object handle. Used with all subsequent NI-CAN function calls.

Return Value

Status of the function call, returned as a signed 32-bit integer. Zero means the function executed successfully. Negative specifies an error, meaning the function did not perform expected behavior. Positive specifies a warning, meaning the function performed as expected, but a condition arose that might require attention. For more information, refer to ncStatusToString.

Description

ncOpenObject takes the name of an object to open and returns a handle to that object that you use with subsequent NI-CAN function calls.

The Frame API and Channel API cannot use the same CAN network interface simultaneously. If the CAN network interface is already initialized in the Channel API, this function returns an error.

If ncOpenObject is successful, a handle to the newly opened object is returned. You use this object handle for all subsequent function calls for the object.

The following sections describe how to use ncOpenObject with the CAN or LIN Network Interface and CAN Object.

CAN Network Interface

ObjName is the name of the CAN Network Interface Object to configure. This string uses the syntax "CANx", where x is a decimal number starting at zero that indicates the CAN network interface (CAN0, CAN1, up to CAN63). CAN network interface names are associated with physical CAN ports using the Measurement & Automation Explorer (MAX).

The special interface values 256 and 257 refer to virtual interfaces. For more information on usage of virtual interfaces, refer to Frame to Channel Conversion.

LIN Network Interface Object

This name uses the syntax LINx, where x is a decimal number starting at zero that indicates the LIN network interface (LIN0, LIN1, up to LIN63), where CAN and LIN share the same range. LIN network interface names are associated with physical LIN ports using the Measurement & Automation Explorer (MAX).

CAN Object

ObjName is the name of the CAN Object to configure. This string uses the syntax "CANx::STDy" or "CANx::XTDy". CANx is the name of the CAN network interface that you used for the preceding ncConfig function. STD indicates that the CAN Object uses a standard (11-bit) arbitration ID. XTD indicates that the CAN Object uses an extended (29-bit) arbitration ID. The number y specifies the actual arbitration ID of the CAN Object. The number y is decimal by default, but you also can use hexadecimal by adding 0x to the beginning of the number. For example, CAN0::STD25 indicates standard ID 25 decimal on CAN0, and CAN1::XTD0x0000F652 indicates extended ID F652 hexadecimal on CAN1.

The special virtual interface names "CAN256" and "CAN257" are not supported for CAN Objects.