Choose Which API To Use

NI-CAN

Choose Which API To Use

For a given NI-CAN interface such as CAN0, you can use only one API at a time. Therefore, for new application development, you need to decide which API to use.

For example, if you have one application that uses the Channel API and another application that uses the Frame API, you cannot use CAN0 with both at the same time. As an alternative, you can connect CAN0 and CAN1 to the same network, then use CAN0 with one application and CAN1 with the other, if you have a 2-port CAN card. As another alternative, you can use CAN0 in both applications, but run each application at a different time (not simultaneously).

Because the Channel API provides access to the CAN network in easy-to-use physical units, it is recommended over the Frame API for customers who are getting started with NI-CAN. You also need to use the Channel API if you want to utilize CAN messages or channels that are defined in CAN database files.

Nevertheless, because the Frame API provides lower-level access to the CAN network, there are a few reasons why you might want to use it over the Channel API:

  • You are continuing with an application developed with NI-CAN version 1.6 or earlier. The Frame API is compatible with such code.
  • You need to implement a command/response protocol in which you send a command to the device, and then the device replies by sending a response. Command/response protocols typically use a fixed pair of IDs for each device, and the ID does not determine the meaning of the data bytes.
  • The devices require use of remote frames. The Channel API does not provide support for remote frames, but the Frame API has extensive features to transmit and receive remote frames. For more information, refer to Remote Frames.
  • The Frame API provides RTSI features that are lower level than the synchronization features of the Channel API. If you have advanced requirements for synchronizing CAN and DAQ cards, you may need to use the Frame API. For more information, refer to RTSI.
  • The USB-847x is supported only by the Frame API. In addition, the USB-847x hardware uses the Network Interface, not CAN objects.

In some cases, applications might require the ability to convert CAN data between a CAN frame and a CAN channel. For information on frame to channel conversion, channel to frame conversion, and virtual interfaces, refer to Frame to Channel Conversion.