![National Instruments NI-CAN User Manual Download Page 41](http://html1.mh-extra.com/html/national-instruments/ni-can/ni-can_user-manual_3506864041.webp)
Chapter 3
NI-CAN Programming Techniques
3-2
ni.com
the data from the previous call to
ncRead
is returned again, along with the
NC_ERR_OLD_DATA
warning. If no data item has yet arrived for the read
queue, a default data item is returned, which consists of all zeros. You
should generally wait for
NC_ST_READ_AVAIL
prior to the first call to
ncRead
.
Full Queues
For both read and write queues, the behavior for writing a full queue
is similar. When you write a full queue, NI-CAN returns the
NC_ERR_OVERFLOW
status codes. For example, if you write too many
data items to a write queue, the
ncWrite
function eventually returns the
overflow error.
Disabling Queues
If you do not need a complete history of all data items, you may prefer to
disable the read queue and/or write queue by setting its length to zero.
Using zero length queues generally saves memory, and often results in
better performance. When a new data item arrives for a zero length queue,
it overwrites the previous item without indicating an overflow. The
NC_ST_READ_AVAIL
and
NC_ST_WRITE_SUCCESS
states still behave as
usual, but you can ignore them if you want only the most recent data. For
example, when NI-CAN writes a new data item to the read buffer, the
NC_ST_READ_AVAIL
state becomes true until the data item is read. If you
only want the most recent data, you can ignore the
NC_ST_READ_AVAIL
state, as well as the
NC_ERR_OLD_DATA
warning returned by
ncRead
.
Using the CAN Network Interface Object
with CAN Objects
For many applications, it is desirable to use a CAN Network Interface
Object in conjunction with higher level CAN Objects. For example, many
CAN devices require a specific sequence of CAN frames to initialize for
data transfer. For such devices, you can use the CAN Network Interface
Object to transmit and receive frames required for initialization, then use
CAN Objects for data transfer (such as transmitting a periodic request for
data). For more information on the different uses of NI-CAN objects, refer
to the
Choosing Which NI-CAN Objects to Use
.
When one or more CAN Objects are open, the CAN Network Interface
Object cannot receive frames which would normally be handled by the