ncReadDnetIO (Read DeviceNet I/O)
Purpose
Read input data from an I/O Object.
Format
LabVIEW
C
NCTYPE_STATUS | ncReadDnetIO( NCTYPE_OBJH ObjHandle,
NCTYPE_UINT32 SizeofData,
NCTYPE_ANY_P Data); |
Input
ObjHandle | Object handle of an open I/O Object |
SizeofData | Size of Data buffer in bytes (C only) |
Output
Data | Input data |
Function Description
ncReadDnetIO reads input data from an NI-DNET I/O Object.
Since each I/O Object continuously acquires input data from the DeviceNet network, you normally wait for new input to become available prior to calling ncReadDnetIO. By waiting for new input data, your application can handle I/O data at the same rate as the DeviceNet I/O communication. You can use the function ncCreateNotification (C only) or ncWaitForState (C or LabVIEW) to wait for new input data.
ncReadDnetIO normally returns input data bytes obtained from the input assembly of a remote DeviceNet slave device. The format of this input assembly is normally documented either by the device vendor or within the DeviceNet Specification itself.
The bytes of a device's input assembly often consist of multiple data members rather than a single value. For C, you can often obtain each data member from the input bytes by using typecasting. For LabVIEW, you can often obtain each data member from the input bytes using the ncConvertFromDnetRead function. For more information on input assemblies and how to obtain individual data members, refer to the NI-DNET User Manual.
Parameter Descriptions
ObjHandle
Description | ObjHandle must contain an object handle returned from ncOpenDnetIO. In LabVIEW, ObjHandle passes through the VI as an output so that it can be used for subsequent function calls for the object. |
Values | The encoding of ObjHandle is internal to NI-DNET. |
SizeofData
Description | For C, SizeofData is the size of the buffer referenced by Data. Use it to verify that you have enough bytes available to store the input bytes. This size is normally obtained using the C language sizeof function and has no direct relation to the number of bytes received on the network. For LabVIEW, since the buffer for Data is allocated automatically by NI-DNET, this size is not needed. The actual number of bytes received on the I/O connection is determined by the InputLength parameter of ncOpenDnetIO and not this size. |
Values | sizeof (buffer referenced by Data) |
Data
Description | Input data. The format of these input bytes is specific to your DeviceNet device. |
Values | Input data bytes |
Examples
LabVIEW
Read 20 input bytes from an I/O Object.
C
Read 10 input bytes from the I/O Object referenced by objh.
NCTYPE_STATUS status;
NCTYPE_OBJH objh;
NCTYPE_UINT8 input[10];
status = ncReadDnetIO(objh, 10, input);