Using Can Objects - National Instruments NI-CAN User Manual

Table of Contents

Advertisement

© National Instruments Corporation
You can read and write CAN frames for access to configuration
settings within a device. Because such settings generally are not
accessed during normal device operation, a dedicated CAN Object is
not appropriate.
For higher level protocols based on CAN, you can use sequences of
write/read transactions to initialize communication with a device. In
these protocols, specific sequences of CAN frames often need to be
exchanged before you can access the data from a device. In such cases,
you can use the CAN Network Interface Object to set up
communication, then use CAN Objects for actual data transfer with the
device.
In general, you use CAN Network Interface Objects for situations in which
you need to transfer arbitrary CAN frames.

Using CAN Objects

When a network frame is transmitted on a CAN based network, it always
begins with what is called the arbitration ID. This arbitration ID is
primarily used for collision resolution when more than one frame is
transmitted simultaneously, but you can also use it as a simple mechanism
to identify data. The CAN Object encapsulates a specific CAN arbitration
ID and its associated data.
Every CAN Object is always associated with a specific CAN Network
Interface Object, used to identify the physical interface on which the CAN
Object is located. Your application can use multiple CAN Objects in
conjunction with their associated CAN Network Interface Object.
The CAN Object provides high level access to a specific arbitration ID. You
can configure each CAN Object for different forms of background access.
For example, you can configure a CAN Object to transmit a data frame
every 100 milliseconds, or to periodically poll for data by transmitting a
remote frame and receiving the data frame response. The arbitration ID,
direction of data transfer, data length, and when data transfer occurs
(periodic or unsolicited) are all preconfigured for the CAN Object. When
you have configured and opened the CAN Object, data transfer is handled
in the background using read and write queues. For example, if the CAN
Object periodically polls for data, the NI-CAN driver automatically
handles the periodic transmission of remote frames, and stores incoming
data in the read queue of the CAN Object for later retrieval by the
function. For CAN Objects that receive data frames, the
provides a timestamp of when the data frame arrived, and the data bytes of
Chapter 2
2-5
Developing Your Application
ncRead
function
ncRead
NI-CAN User Manual

Advertisement

Table of Contents
loading

Table of Contents