DeviceNet NI-DNET User Manual

Chapter 3 Developing Your Application
© National Instruments Corporation 3-9 NI-DNET User Manual
2. Call the ncWaitForState function with the DesiredState
parameter set to
Read Available. This function waits for output
data to be transmitted and for new input data to be received. If your
application is multitasking, you might have other tasks to do in your
application while you wait for new input data. If so, use the
ncCreateNotification or ncCreateOccurrence function
instead of
ncWaitForState (refer to Step 2. Start Communication).
3. Call the
ncReadDnetIO function to read input data received from the
DeviceNet network.
4. Loop back to step 1 as needed.
Complete the following steps with an Explicit Messaging Object:
1. Call the
ncWaitForState function with the DesiredState
parameter set to
Established. This ensures that the explicit message
connection is established before you send the first explicit message
request.
2. To get an attribute from a remote DeviceNet device, call the
ncGetDnetAttribute function.
3. To set the value of an attribute in a remote DeviceNet device, call the
ncSetDnetAttribute function.
4. To invoke other explicit message services in a remote DeviceNet
device, use the
ncWriteDnetExplMsg function to write the service
request, the
ncWaitForState function to wait for the service
response, and the
ncReadDnetExplMsg function to read the service
response.
5. Loop back to step 2 as needed.
Addition of Slave Connections after
Communication Start
If you need to add I/O and Explicit Messaging connections after the
communication on the network has started, you can call
ncOpenDnetExplMsg and ncOpenDnetIO as long as the Interface
Object’s poll mode had been configured to
NC_POLL_SCAN (Scanned) or
NC_POLL_INDIV (Individual). Since the Automatic poll mode
(
NC_POLL_AUTO) calculates the expected packet rate (EPR) based on the
estimated network bandwidth, all the I/O connections have to be opened
before you start the communication if the Automatic mode is selected. The
EPR restrictions due to different values of the
PollMode parameter still
apply to the I/O objects. For details on these requirements, refer to
ncOpenDnetIO and ncOpenDnetIntf function descriptions in the
NI-DNET Programmer Reference Manual.