Function Block - Ethernet/IP explicit messaging - read single attribute.

This function block sends an explicit message (UCMM) to an Ethernet/IP adapter, for reading a single CIP attribute.

The CIP instance number can be 16 bits [1...65535].

Inputs

Input

Data type

Description

Snd

BOOL

A rising edge on this input start the exchange. The DONE output will signal the end of exchange.

SrvIP

STRING

A rising edge on this input start the exchange. The DONE output will signal the end of exchange.

Class

UINT

Class identifier of the CIP object.

Inst

UINT

Instance identifier of the CIP object.

Attr

UINT

Identifier of the CIP attribute.

Data

array of USINT

Buffer where to store the received data. If the actual attribute length is greater than the size of this array, value will be truncated when read.

Outputs

Output

Data type

Description

Done

BOOL

This output is TRUE during one cycle when the exchange is finished, whatever the exchange succeeded or failed. Warning, this output can be TRUE just after the call to block when starting a new exchange in case of invalid parameters.

RevSize

UINT

Actual size of the CIP attribute answered by the server. If this size if greater than the size of the DATA input array, it indicates that the value was truncated.

Err

UINT

Main error report. Can be one of the following values:

0 = no error
1 = invalid input arguments
2 = system is busy (see remarks)
3 = timeout waiting for the answer (the timeout value is 3 seconds
4 = UCMM error was returned by the server
others = internal errors (reserved for technical support)

EmErr

UINT

In case of a UCMM error, this is the CIP general status error code.

EmErrExt

UINT

In case of a UCMM error, this is the CIP extended status error code.

Remarks

The servers (adapters) accessed by this block must be configured in the "Ethernet/IP Scanner" fieldbus configuration.

Only one explicit message (read or write) can be sent at one time to the same server. If another message is pending then you will get the error report 3 (busy) after calling the block to start a new exchange.

Consider SERIALIZEIN and SERIALIZEOUT functions for extracting data from the read buffer.

Example

// used variables

// Inst_eipReadAttr : eipReadAttr ;

// bRead : BOOL ; (* request for READ *)

// DataRead : ARRAY [0 .. 15] OF USINT ; (* read data *)

// Server identification and CIP things

#define SRVIP '192.168.33.21'

#define CLASSID UINT#100

#define INSTID_READ UINT#1

#define ATTRID UINT#3

/////////////////////////////////////////////////////////////////////////////////////////

// requested READ command

if bRead then

Inst_eipReadAttr (bRead, SRVIP, CLASSID, INSTID_READ, ATTRID, DataRead);

end_if;

// READ answer here ?

if Inst_eipReadAttr.Done then

// check answer - if OK answered data is in DataRead array

if Inst_eipReadAttr.Err = 0 then

printf ('READ ok - size = %lu bytes',

any_to_dint (Inst_eipReadAttr.RcvSize));

else

printf ('READ Error %lu (UCMM Error %lu, %lu)',

any_to_dint (Inst_eipReadAttr.Err),

any_to_dint (Inst_eipReadAttr.EmErr),

any_to_dint (Inst_eipReadAttr.EmErrExt));

end_if;

// reset READ command and block input

Inst_eipReadAttr (false, SRVIP, CLASSID, INSTID_READ, ATTRID, DataRead);

bRead := false;

end_if;


Created with the Personal Edition of HelpNDoc: Streamline your documentation process with HelpNDoc's WinHelp HLP to CHM conversion feature