Chapter 3 Developing YourApplication
© National Instruments Corporation 3-11 NI-DNET User Manual
If you use two different applications on the same interface and open I/O
connections to different devices, you must set PollMode to either
Scanned or Individual. You cannot use PollMode of Automatic,
because that requires all I/O connections to be open prior to the first start
of communication.
Checking Status in LabVIEW
For applications written in LabVIEW, status checking is handled
automatically. For all NI-DNET functions, the lower left and right
terminals provide status information using LabVIEW Error Clusters.
LabVIEW Error Clusters are designed so that status information flows
from one function to the next, and function execution stops when an error
occurs. For more information, refer to the Error Handling section in the
LabVIEW online reference.
Within your LabVIEW block diagram, you wire the Error in and
Error out terminals of NI-DNET functions together in succession.
When an error is detected in an NI-DNET function (status field true),
all NI-DNET functions wired together are skipped except for
ncCloseObject. The ncCloseObject function executes regardless
ofw hether an error occurred, thus ensuring that all NI-DNET objects are
closed properly when execution stops due to an error. Depending on how
you want to handle errors, you can wire the Error in and Error out
terminals together per-object (group a single open/close pair), per-device
(group together Explicit Messaging and I/O Objects for a given device), or
per-network (group all functions for a given interface).
As with any other LabVIEW error cluster, you can view error descriptions
using built-in LabVIEW features such as Explain Error in the Help menu,
or the Simple Error Handler VI in your diagram.
Checking Status in C, C++, and Visual Basic
Each C language NI-DNET function returns a value that indicates the status
of the function call. This status value is zero for success, greater than zero
for a warning, and less than zero for an error.
After every call to an NI-DNET function, your program should check to see
if the return status is nonzero. If so, call the ncStatusToString function
to obtain an ASCII string which describes the error/warning. You can then
use standard C function, such as printf, to display this ASCII string.