Using NI-CAN
- Updated2023-09-14
- 3 minute(s) read
Using NI-CAN
NI-CAN is the legacy application programming interface (API) for National Instruments CAN hardware. Generally speaking, NI-CAN is associated with the legacy CAN hardware, and NI-XNET is associated with the new NI-XNET hardware.
If you are starting a new application, you typically use NI-XNET (not NI-CAN).
Compatibility
If you have an existing application that uses NI-CAN, a compatibility library is provided so that you can reuse that code with a new NI-XNET CAN product. Because the features of the compatibility library apply to the NI-CAN API and not NI-XNET, it is described in the NI-CAN documentation. For more information, refer to the NI-CAN Manual.
NI-XNET CAN Products
in MAX
When the compatibility library is installed, NI-XNET CAN products also are visible in the NI-CANbranch under Devices and Interfaces. Here you can configure the devices for use with the NI-CAN API. This configuration is independent from the configuration of the same device for NI-XNET under the root of Devices and Interfaces. The following figure shows the same NI-XNET device, the NI PCI-8513, configured for use with the NI-XNET API (interfaces CAN1 and CAN2) and with the NI-CAN API (interfaces CAN3 and CAN4).
Transition
If you have an existing application that uses NI-CAN and intend to use only new NI-XNET hardware from now on, you may want to transition your code to NI-XNET.
NI-XNET unifies many concepts of the earlier NI-CAN API, but the key features are similar.
The following table lists NI-CAN terms and analogous NI-XNET terms.
NI-CAN Term | NI-XNET Term | Comment |
---|---|---|
CANdb file | Database | NI-XNET supports more database file formats than the NI-CAN Channel API, including the FIBEX, AUTOSAR, and LDF formats. |
Message | Frame | The term Frame is the industry convention for the bits that transfer on the bus. This term is used in standards such as CAN. |
Channel | Signal | The term Signal is the industry convention. This term is used in standards such as FIBEX and AUTOSAR. |
Channel API Task | Session (Signal I/O) | Unlike NI-CAN, NI-XNET supports simultaneous use of channel (signal) I/O and frame I/O. |
Frame API CAN Object (Queue Length Zero) | Session (Frame I/O Single-Point) | The NI-CAN CAN Object provided both input (read) and output (write) in one object. NI-XNET provides a different object for each direction, for better control. If the NI-CAN queue length for a direction is zero, that is analogous to NI-XNET Frame I/O Single-Point. |
Frame API CAN Object (Queue Length Nonzero) | Session (Frame I/O Queued) | If the NI-CAN queue length for a direction is nonzero, that is analogous to NI-XNET Frame I/O Queued. |
Frame API Network Interface Object | Session (Frame I/O Stream) | The NI-CAN Network Interface Object provided both input (read) and output (write) in one object. NI-XNET provides a different object for each direction, for better control. |
Interface | Interface | NI-CAN started interface names at CAN0, but NI-XNET starts at CAN1 (or FlexRay1 ). |