©
National Instruments Corporation
3-1
3
NI-CAN Programming
Techniques
This chapter describes techniques for using the NI-CAN functions in your
application.
For more detailed information about each NI-CAN function, refer to the
NI-CAN Programmer Reference Manual
.
Using Queues
To maintain an ordered history of data transfers, NI-CAN supports the use
of queues, also known as FIFO (first-in-first-out) buffers. The basic
behavior of such queues is common to all NI-CAN objects.
There are two basic types of NI-CAN queues: the read queue and the write
queue. NI-CAN uses the read queue to store incoming network data items
in the order they arrive. You access the read queue using
ncRead
to obtain
the data. NI-CAN uses the write queue to transmit network frames one at a
time using the network interface hardware. You access the write queue
using
ncWrite
to store network data items for transmission.
State Transitions
The
NC_ST_READ_AVAIL
state transitions from false to true when NI-CAN
places a new data item into an empty read queue, and remains true until you
read the last data item from the queue and the queue is empty.
The
NC_ST_WRITE_SUCCESS
state transitions from false to true when the
write queue is empty and NI-CAN has successfully transmitted the last data
item onto the network. The
NC_ST_WRITE_SUCCESS
state remains true
until you write another data item into the write queue.
Empty Queues
For both read and write queues, the behavior for reading an empty queue is
similar. When you read an empty queue, the previous data item is returned
again. For example, if you call
ncRead
when
NC_ST_READ_AVAIL
is false,