Step 1. open objects, Step 2. start communication, Step 3. run your devicenet application – National Instruments NI-DNET User Manual
Page 27

Chapter 3
Developing Your Application
3-8
ni.com
Step 1. Open Objects
Before you use an NI-DNET object in your application, you must configure
and open it using either
ncOpenDnetIntf
,
ncOpenDnetExplMsg
, or
ncOpenDnetIO
. These open functions return a handle for use in all
subsequent NI-DNET calls for that object.
The
ncOpenDnetIntf
function configures and opens an Interface Object.
Your NI-DNET application uses this Interface Object to start and stop
communication. The Interface Object must be the first NI-DNET object
opened by your application.
The
ncOpenDnetExplMsg
function configures and opens an Explicit
Messaging Object, and the
ncOpenDnetIO
function configures and opens
an I/O Object.
Step 2. Start Communication
Start communication to initialize DeviceNet connections to remote
devices. Use the Interface Object to call the
ncOperateDnetIntf
function with the
Opcode
parameter set to
Start
.
The following optional steps can be done before you start communication:
•
For an I/O Object, if it is not acceptable to send output data of all zeros,
call
ncWriteDnetIO
to provide valid output values for the initial
transmission.
•
For an I/O Object, if your application is multitasking, call the
ncCreateNotification
or
ncCreateOccurrence
function with
the
DesiredState
parameter set to
Read Available
. This notifies
your application when new input data is received from the remote
device.
•
For any NI-DNET object, if any of the Driver attributes needs to be
changed, call
ncSetDriverAttr
with the attribute Id and attribute
value. The
ncSetDriverAttr
function cannot be called after the
communication has started.
Step 3. Run Your DeviceNet Application
After you open your NI-DNET objects and start communication, you are
ready to interact with the DeviceNet network.
Complete the following steps with an I/O Object:
1.
Call the
ncWriteDnetIO
function to write output data for subsequent
transmission on the DeviceNet network.