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