Chapter 4 NI-DNET Programming Techniques
© National Instruments Corporation 4-13 NI-DNET User Manual
easiest way to execute the Set Attribute Single service on a remote device
is to use the NI-DNET ncSetDnetAttribute function.
For a given attribute of a DeviceNet device, you need the following
information to use the ncGetDnetAttribute or ncSetDnetAttribute
function:
The class and instance identifiers for the object in which the attribute
is located
The attribute identifier
The attribute’s DeviceNet data type
You can normally find this information from the object specifications
contained in the DeviceNet Specification, but many DeviceNet device
vendors also provide this information in the device’s documentation.
For the C programming language, the attribute’s DeviceNet data type
determines the corresponding NI-DNET data type you use to declare a
variable for the attribute’s value. For example, if the attribute’s DeviceNet
data type is INT (16-bit signed integer), you should declare a C language
variable of type NCTYPE_INT16, then pass the address of that variable as
the Attr parameter of the ncGetDnetAttribute or
ncSetDnetAttribute function.
For LabVIEW, the attribute’s DeviceNet data type determines
thecorresponding LabVIEW data type to use with the
ncConvertForDnetWrite
or
ncConvertFromDnetRead
functions. The
ncConvertFromDnetRead
function converts a DeviceNet attribute read
using
ncGetDnetAttribute
into an appropriate LabVIEW data type. The
ncConvertForDnetWrite
function converts a LabVIEW data type into an
appropriate DeviceNet attribute to write using
ncSetDnetAttribute
. For
more information on these LabVIEW conversion functions, refer to the
Using I/O Data in Your Application
section.
Other Explicit Messaging Services
To execute services other than Get Attribute Single and Set Attribute Single,
use the following sequence of function calls:
ncWriteDnetExplMsg
,
ncWaitForState
,
ncReadDnetExplMsg
. The
ncWriteDnetExplMsg
function sends an explicit message request to a remote DeviceNet device.
The
ncWaitForState
function waits for the explicit message response,
and the
ncReadDnetExplMsg
function reads that response.
Use ncWriteDnetExplMsg for such DeviceNet services as Reset, Save,
Restore, Get Attributes All, and Set Attributes All. Although the DeviceNet