WStringElement.ElementEquals (METH) ¶ METHOD ElementEquals : BOOL Returns true of this element and itfElement are equal. InOut: Scope Name Type Comment Return ElementEquals BOOL Input itfElement IElement The element to compare
WStringElement.ElementHashCode (METH) ¶ METHOD ElementHashCode : LINT Returns the hashcode of this element. InOut: Scope Name Type Return ElementHashCode LINT
ERROR (ENUM) ¶ TYPE ERROR : CIP Errors (0-255) and library specific errors (256-x) Attributes: qualified_only InOut: Name Initial Comment NO_ERROR 0 Service was successfully performed by the object specified. CONNECTION_FAILURE 16#1 A connection related service failed along the connection path. RESOURCE_UNAVAILABLE 16#2 Resources needed for the object to perform the requested service were unavailable INVALID_PARAM_VALUE 16#3 See Status Code 0x20, which is the preferred value to use for this condition. PATH_SEGMENT_ERROR 16#4 The path segment identifier or the segment syntax was not understood by the processing node. Path processing shall stop when a path segment error is encountered. PATH_DESTINATION_UNKNOWN 16#5 The path is referencing an object class, instance or structure element that is not known or is not contained in the processing node. Path processing shall stop when a path destination unknown error is encountered. PARTIAL_TRANSFER 16#6 Only part of the expected data was transferred. CONNECTION_LOST 16#7 The messaging connection was lost. SERVICE_NOT_SUPPORTED 16#8 The requested service was not implemented or was not defined for this Object Class/Instance. INVALID_ATTRIBUTE_VALUE 16#9 Invalid attribute data detected. ATTRIBUTE_LIST_ERROR 16#A An attribute in the Get_Attribute_List or Set_Attribute_List response has a non-zero status. ALREADY_IN_REQUEST_STATE 16#B The object is already in the mode/state being requested by the service OBJECT_STATE_ERROR 16#C The object cannot perform the requested service in its current mode/state. OBJECT_ALREADY_EXISTS 16#D The requested instance of object to be created already exists. ATTRIBUTE_NOT_SETTABLE 16#E A request to modify a nonmodifiable attribute was received. PRIVILEGE_VIOLATION 16#F A permission/privilege check failed DEVICE_STATE_ERROR 16#10 The device’s current mode/state prohibits the execution of the requested service. REPLY_DATA_TOO_LARGE 16#11 The data to be transmitted in the response buffer is larger than the allocated response buffer FRAGMENTATION_OF_VALUE 16#12 The service specified an operation that is going to fragment a primitive data value, i.e. half a REAL data type. NOT_ENOUGH_DATA 16#13 The service did not supply enough data to perform the specified operation. ATTRIBUTE_NOT_SUPPORTED 16#14 The attribute specified in the request is not supported. TOO_MUCH_DATA 16#15 The service supplied more data than was expected. OBJECT_DOES_NOT_EXIST 16#16 The object specified does not exist in the device. SERVICE_FRAGMENTATION_SEQUENCE_NOT_IN_PROGRESS 16#17 The fragmentation sequence for this service is not currently active for this data. NO_STORED_ATTRIBUTE_DATA 16#18 The attribute data of this object was not saved prior to the requested service. STORE_OPERATION_FAILURE 16#19 The attribute data of this object was not saved due to a failure during the attempt. ROUTING_FAILURE_REQUEST_PACKET_TOO_LARGE 16#1A The service request packet was too large for transmission on a network in the path to the destination. The routing device was forced to abort the service. ROUTING_FAILURE_RESPONSE_PACKET_TOO_LARGE 16#1B The service response packet was too large for transmission on a network in the path from the destination. The routing device was forced to abort the service. MISSING_ATTRIBUTE_LIST_ENTRY_DATA 16#1C The service did not supply an attribute in a list of attributes that was needed by the service to perform the requested behavior. INVALID_ATTRIBUTE_VALUE_LIST 16#1D The service is returning the list of attributes supplied with status information for those attributes that were invalid. EMBEDDED_SERVICE_ERROR 16#1E An embedded service resulted in an error. VENDOR_SPECIFIC_ERROR 16#1F A vendor specific error has been encountered. The Additional Code Field of the Error Response defines the particular error encountered. Use of this General Error Code should only be performed when none of the Error Codes presented in this table or within an Object Class definition accurately reflect the error. INVALID_PARAMETER 16#20 A parameter associated with the request was invalid. This code is used when a parameter does not meet the requirements of this specification and/or the requirements defined in an Application Object Specification. WRITE_ONEC_VALUE_OR_MEDIUM_ALREADY_WRITTEN 16#21 An attempt was made to write to a write-once medium (e.g. WORM drive, PROM) that has already been written, or to modify a value that cannot be changed once established. INVALID_REPLY_RECEIVED 16#22 An invalid reply is received (e.g. reply service code does not match the request service code, or reply message is shorter than the minimum expected reply size). This status code can serve for other causes of invalid replies. BUFFER_OVERFLOW 16#23 The message received is larger than the receiving buffer can handle. The entire message was discarded. MESSAGE_FORMAT_ERROR 16#24 The format of the received message is not supported by the server. KEY_FAILURE_IN_PATH 16#25 The Key Segment that was included as the first segment in the path does not match the destination module. The object specific status shall indicate which part of the key check failed. PATH_SIZE_INVALID 16#26 The size of the path which was sent with the Service Request is either not large enough to allow the Request to be routed to an object or too much routing data was included. UNEXPECTED_ATTRIBUTE_IN_LIST 16#27 An attempt was made to set an attribute that is not able to be set at this time. INVALID_MEMBER_ID 16#28 The Member ID specified in the request does not exist in the specified Class/Instance/Attribute MEMBER_NOT_SETTABLE 16#29 A request to modify a non-modifiable member was received GROUP_2_ONLY_SERVER_GENERAL_FAILURE 16#2A This error code may only be reported by DeviceNet Group 2 Only servers with 4K or less code space and only in place of Service not supported, Attribute not supported and Attribute not settable. UNKNOWN_MODBUS_ERROR 16#2B A CIP to Modbus translator received an unknown Modbus Exception Code. ATTRIBUTE_NOT_GETTABLE 16#2C A request to read a non-readable attribute was received INSTANCE_NOT_DELETABLE 16#2D The requested object instance cannot be deleted SERVICE_NOT_SUPPORTED_FOR_SPECIFIED_PATH 16#2E The object supports the service, but not for the designated application path (e.g. attribute). NOTE: Not to be used for any set service (use General Status Code 0x0E or 0x29 instead) TIME_OUT 16#100 Request timed out. INTERFACE_MISSING IEtherNetIPService is not implemented. REMOTE_CALL_FAILED No physical connection. NULL_POINTER Wrong input value NULL. INVALID_DATA_SIZE Size of data unacceptable. WRONG_INTERFACE_VERSION Version missmatch. Device implements not the same version of interface for the called method. NO_MEMORY Not enough memory UNKNOWN_ERROR An unknown error occured. ABORTED Service was aborted
Function Blocks ¶ Apply_Attributes (FunctionBlock) DataExchange Generic_Service (FunctionBlock) Get_Attribute_List (FunctionBlock) Get_Attribute_Single (FunctionBlock) Get_Attributes_All (FunctionBlock) Set_Attribute_List (FunctionBlock) Set_Attribute_Single (FunctionBlock) Set_Attributes_All (FunctionBlock) NOP (FunctionBlock) Reset (FunctionBlock) Start (FunctionBlock) Stop (FunctionBlock)
Apply_Attributes (FB) ¶ FUNCTION_BLOCK Apply_Attributes EXTENDS BaseService This function block is used for calling the “Apply_Attributes” service of a specific instance of a CIP object. As a result, the attributes that were previously set with “Get_Attribut_Single” or “Get_Attribut_All” are adopted and saved by the adapter. InOut: Scope Name Type Comment Inherited from Input xExecute BOOL Rising edge: Action starts Falling edge: Resets outputs If a falling edge occurs before the function block has completed its action, the outputs operate in the usual manner and are only reset if either the action is completed or in the event of an error. In this case, the corresponding output values ( xDone , xError ) are present at the outputs for exactly one cycle. ETrig Output xDone BOOL TRUE : Action successfully completed ETrig xBusy BOOL TRUE : Function block active ETrig xError BOOL TRUE : Error occurred, function block aborts action FALSE : No error ETrig Input itfEtherNetIPDevice IEtherNetIPService BaseService eClass CIPClass BaseService dwInstance DWORD BaseService tTimeOut TIME BaseService Output eError ERROR BaseService
DataExchange ¶ The byte order of EtherNet/IP is little endian/Intel. It is possible to send any service with this library, but the structure is unknown to the library so you have to swap your received data by yourself on big endian/Motorola platforms. One example would be, if you read a single more than one byte long value: PROGRAM PLC_PRG VAR vendorId : WORD ; getAttributeSingle : ENIP.Get_Attribute_Single ; udiReceivedData : UDINT ; END_VAR getAttributeSingle ( (* Read VendorID, which is 2 byte long *) xExecute := , itfEtherNetIPDevice := EtherNetIP_Adapter , (* instance of the device (instance is found in the I/O Mapping of the device) *) eClass := ENIP.CIPClass.IdentityObject , (* cip class which contains the desired attribute *) dwInstance := 1 , (* value of 0 is class level, range from 1..x is instance level *) wAttribute := 1 , (* attribute no. 6 of the tcp/ip interface object is the Hostname (CIP Spec. Vol.2 Chapter 5-3.3.2.6)*) pData := ADR ( vendorId ), (* data buffer *) udiDataSize := SIZEOF ( vendorId ), (* size of the data buffer *) xDone => , xBusy => , xError => , eError => , udiReceivedDataSize => udiReceivedData ); (* if the request was successful, udiReceivedData contains the number of bytes which have been received *) IF ( getAttributeSingle.xDone ) THEN (*swapping*) SysMem.SysMemSwap ( ADR ( vendorId ), SIZEOF ( vendorID ), 1 ); END_IF You could download this also to an Intel platform without changes, because it will be only swapped on Motorola platforms. Before you set an attribute, swap it once. If you are sending or receiving a whole structure, it´s necessary to swap each element: structure : DUT ; IF ( getAttributeSingle.xDone ) THEN SysMem.SysMemSwap ( ADR ( structure.d1 ), SIZEOF ( structure.d1 ), 1 ); SysMem.SysMemSwap ( ADR ( structure.d2 ), SIZEOF ( structure.d2 ), 1 ); SysMem.SysMemSwap ( ADR ( structure.d3 ), SIZEOF ( structure.d3 ), 1 ); SysMem.SysMemSwap ( ADR ( structure.d4 ), SIZEOF ( structure.d4 ), 1 ); END_IF Generic_Service (FunctionBlock) Get_Attribute_List (FunctionBlock) Get_Attribute_Single (FunctionBlock) Get_Attributes_All (FunctionBlock) Set_Attribute_List (FunctionBlock) Set_Attribute_Single (FunctionBlock) Set_Attributes_All (FunctionBlock)
Generic_Service (FB) ¶ FUNCTION_BLOCK Generic_Service EXTENDS BaseService This function block performs a generic service at an EtherNet/IP Adapter. The message will be sent as an unconnected explicit message request. Note Data received and send needs to be swapped. See parent folder. /// Force trigger to TRUE to activate. /// Example device used here is WAGO 750-352 FC ETHERNET. /// But you can adapt it, by using the services which are implemented by your prefered device. PROGRAM PLC_PRG VAR dut : ENIP.Generic_Service ; data : usint := 16#FF ; trigger : BOOL ; END_VAR dut.xExecute := trigger ; dut.itfEtherNetIPDevice := WAGO_750_352_FC_ETHERNET ; dut.eClass := 100 ; dut.dwInstance := 1 ; dut.wAttribute := 11 ; dut.eService := ENIP.CIPCommonService.SET_ATTRIBUTE_SINGLE ; dut.pWriteData := ADR ( data ); dut.udiWriteDataSize := 1 ; dut (); InOut: Scope Name Type Comment Inherited from Input xExecute BOOL Rising edge: Action starts Falling edge: Resets outputs If a falling edge occurs before the function block has completed its action, the outputs operate in the usual manner and are only reset if either the action is completed or in the event of an error. In this case, the corresponding output values ( xDone , xError ) are present at the outputs for exactly one cycle. ETrig Output xDone BOOL TRUE : Action successfully completed ETrig xBusy BOOL TRUE : Function block active ETrig xError BOOL TRUE : Error occurred, function block aborts action FALSE : No error ETrig Input itfEtherNetIPDevice IEtherNetIPService BaseService eClass CIPClass BaseService dwInstance DWORD BaseService tTimeOut TIME BaseService Output eError ERROR BaseService Input wAttribute WORD Attribute the services is addressed to. Leave 0 if this service does not address an attribute. eService CIPCommonService Choose one of the CIPCommonService members, or insert any vendor specific service code. pWriteData POINTER TO BYTE Data to write to the EtherNet/IP Adapter. Leave 0 if no data should be sent to the EtherNet/IP Adapter. udiWriteDataSize UDINT Size of data to write to the EtherNet/IP Adapter. Leave 0 if no data should be sent to the EtherNet/IP Adapter. pReadData POINTER TO BYTE Data expected to receive from the EtherNet/IP Adapter. Leave 0 if no data is expected to be received from the EtherNet/IP Adapter. udiReadDataSize UDINT Size of data expected to receive from the EtherNet/IP Adapter. Leave 0 if no data is expected to be received from the EtherNet/IP Adapter. Output udiReceivedDataSize UDINT Size of the received data
Get_Attribute_List (FB) ¶ FUNCTION_BLOCK Get_Attribute_List EXTENDS BaseService This function block returns the contents of the selected gettable attributes fo the specified CIP Object class or instance. Note Data received and send needs to be swapped. See parent folder. PROGRAM PLC_PRG VAR arData : ARRAY [0..5] OF BYTE ; getAttributeList : ENIP.Get_Attribute_List ; arResponse : ARRAY [0..11] OF BYTE ; END_VAR getAttributeList ( xExecute := , itfEtherNetIPDevice := EtherNetIP_Adapter , (* instance of the device (instance is found in the I/O Mapping of the device) *) eClass := ENIP.CIPClass.TCPIPInterfaceObject , (* cip class which contains the desired attribute *) dwInstance := 1 , (* value of 0 is class level, range from 1..x is instance level *) pRequestData := ADR ( arData ); (* data buffer *) udiRequestDataSize := SIZEOF ( arData ); (* size of the data buffer *) pResponseData := ADR ( arResponse ); (* data buffer from the response *) udiResponseDataSize := SIZEOF ( arResponse ); (* size of the data buffer from the response *) xDone => , xBusy => , xError => , eError => ); ; InOut: Scope Name Type Comment Inherited from Input xExecute BOOL Rising edge: Action starts Falling edge: Resets outputs If a falling edge occurs before the function block has completed its action, the outputs operate in the usual manner and are only reset if either the action is completed or in the event of an error. In this case, the corresponding output values ( xDone , xError ) are present at the outputs for exactly one cycle. ETrig Output xDone BOOL TRUE : Action successfully completed ETrig xBusy BOOL TRUE : Function block active ETrig xError BOOL TRUE : Error occurred, function block aborts action FALSE : No error ETrig Input itfEtherNetIPDevice IEtherNetIPService BaseService eClass CIPClass BaseService dwInstance DWORD BaseService tTimeOut TIME BaseService Output eError ERROR BaseService Input pRequestData POINTER TO BYTE udiRequestDataSize UDINT pResponseData POINTER TO BYTE udiResponseDataSize UDINT Output udiReceivedDataSize UDINT
Get_Attribute_Single (FB) ¶ FUNCTION_BLOCK Get_Attribute_Single EXTENDS BaseService Use this function block for querying the attribute of a specific instance of a CIP object. Note Data received and send needs to be swapped. See parent folder. (* CIP Data type for string with a length of max. 64 chars *) TYPE STRING64 : STRUCT uiLength : UINT ; sString : STRING ( 63 ); END_STRUCT END_TYPE PROGRAM PLC_PRG VAR strHostnameToGet : STRING64 ; getAttributeSingle : ENIP.Get_Attribute_Single ; udiReceivedData : UDINT ; END_VAR getAttributeSingle ( xExecute := , itfEtherNetIPDevice := EtherNetIP_Adapter , (* instance of the device (instance is found in the I/O Mapping of the device) *) eClass := ENIP.CIPClass.TCPIPInterfaceObject , (* cip class which contains the desired attribute *) dwInstance := 1 , (* value of 0 is class level, range from 1..x is instance level *) wAttribute := 6 , (* attribute no. 6 of the tcp/ip interface object is the Hostname (CIP Spec. Vol.2 Chapter 5-3.3.2.6)*) pData := ADR ( strHostnameToGet ), (* data buffer *) udiDataSize := SIZEOF ( strHostnameToGet ), (* size of the data buffer *) xDone => , xBusy => , xError => , eError => , udiReceivedDataSize => udiReceivedData ); (* if the request was successful, udiReceivedData contains the number of bytes which have been received *) ; InOut: Scope Name Type Comment Inherited from Input xExecute BOOL Rising edge: Action starts Falling edge: Resets outputs If a falling edge occurs before the function block has completed its action, the outputs operate in the usual manner and are only reset if either the action is completed or in the event of an error. In this case, the corresponding output values ( xDone , xError ) are present at the outputs for exactly one cycle. ETrig Output xDone BOOL TRUE : Action successfully completed ETrig xBusy BOOL TRUE : Function block active ETrig xError BOOL TRUE : Error occurred, function block aborts action FALSE : No error ETrig Input itfEtherNetIPDevice IEtherNetIPService BaseService eClass CIPClass BaseService dwInstance DWORD BaseService tTimeOut TIME BaseService Output eError ERROR BaseService Input wAttribute WORD pData POINTER TO BYTE udiDataSize UDINT Output udiReceivedDataSize UDINT
Get_Attributes_All (FB) ¶ FUNCTION_BLOCK Get_Attributes_All EXTENDS BaseService This function block is used for querying the attribute of a specific instance of a CIP object. Note Data received and send needs to be swapped. See parent folder. PROGRAM PLC_PRG VAR data : ARRAY [0..500] OF BYTE ; getAttributeAll : ENIP.Get_Attributes_All ; udiReceivedData : UDINT ; END_VAR getAttributeAll ( xExecute := , itfEtherNetIPDevice := EtherNetIP_Adapter , (* instance of the device (instance is found in the I/O Mapping of the device) *) eClass := ENIP.CIPClass.TCPIPInterfaceObject , (* cip class which contains the desired attribute *) dwInstance := 1 , (* value of 0 is class level, range from 1..x is instance level *) pData := ADR ( data ), (* data buffer *) udiDataSize := SIZEOF ( data ), (* size of the data buffer *) xDone => , xBusy => , xError => , eError => , udiReceivedDataSize => udiReceivedData ); (* if the request was successful, udiReceivedData contains the number of bytes which have been received *) ; InOut: Scope Name Type Comment Inherited from Input xExecute BOOL Rising edge: Action starts Falling edge: Resets outputs If a falling edge occurs before the function block has completed its action, the outputs operate in the usual manner and are only reset if either the action is completed or in the event of an error. In this case, the corresponding output values ( xDone , xError ) are present at the outputs for exactly one cycle. ETrig Output xDone BOOL TRUE : Action successfully completed ETrig xBusy BOOL TRUE : Function block active ETrig xError BOOL TRUE : Error occurred, function block aborts action FALSE : No error ETrig Input itfEtherNetIPDevice IEtherNetIPService BaseService eClass CIPClass BaseService dwInstance DWORD BaseService tTimeOut TIME BaseService Output eError ERROR BaseService Input pData POINTER TO BYTE udiDataSize UDINT Output udiReceivedDataSize UDINT