TCP_Read (FB) ¶ FUNCTION_BLOCK TCP_Read EXTENDS CBM.LTrig This function block serves to read data from the previously established connection given in hConnection . As long as xEnable is TRUE the handle of the connection is valid. The pointer pData specifies the memory area to write the read data to. szSize defines the max number of bytes to read. When the data was read successfully, xReady is set to TRUE and szCount indicates the actually read number of bytes. InOut: Scope Name Type Comment Inherited from Input xEnable BOOL TRUE : Action starts FALSE : Action stops, outputs xDone , xBusy , xError are resetted LTrig Output xDone BOOL TRUE : Action successfully completed LTrig xBusy BOOL TRUE : Function block active LTrig xError BOOL TRUE : Error occurred, function block aborts action FALSE : No error LTrig Input hConnection CAA.HANDLE szSize CAA.SIZE pData CAA.PVOID Output eError ERROR xReady BOOL szCount CAA.SIZE
TCP_ReadBuffer (FB) ¶ FUNCTION_BLOCK TCP_ReadBuffer EXTENDS CBM.LTrig Like TCP_Read this function block serves to read data from the previously established connection given in hConnection . As long as xEnable is TRUE the handle of the connection is valid. The function block returns the handle of the buffer containing the data. If xReady is TRUE , data has been read successfully and the handle of the buffer is valid. The buffer is passed on and not copied like at TCP_Read . InOut: Scope Name Type Comment Inherited from Input xEnable BOOL TRUE : Action starts FALSE : Action stops, outputs xDone , xBusy , xError are resetted LTrig Output xDone BOOL TRUE : Action successfully completed LTrig xBusy BOOL TRUE : Function block active LTrig xError BOOL TRUE : Error occurred, function block aborts action FALSE : No error LTrig Input hConnection CAA.HANDLE Output eError ERROR xReady BOOL hBuffer CAA.HANDLE
Decode (FUN) ¶ FUNCTION Decode : BOOL Function decodes “Source” (ARRAY OF BYTE) into “Destination” (ARRAY OF DWORD), meaning 4 BYTEs are decoded into 1 DWORD. Assumes “uiNumberOfBytes” is a multiple of 4, whereas if it is not “FALSE” will be returned. InOut: Scope Name Type Comment Return Decode BOOL function returns “TRUE” if decoding succeded Input pSource POINTER TO ARRAY [0..0] OF BYTE address of source memory pDestination POINTER TO ARRAY [0..0] OF DWORD address of destination memory uiNumberOfBytes UINT number of bytes to decode
Encode (FUN) ¶ FUNCTION Encode : BOOL Function encodes “Source” (ARRAY OF DWORD) into “Destination” (ARRAY OF BYTE), meaning 1 DWORD is split up into 4 BYTEs. Assumes “uiNumberOfBytes” is a multiple of 4, whereas if it is not “FALSE” is returned. InOut: Scope Name Type Comment Return Encode BOOL function returns “TRUE” if encoding succeeded Input pSource POINTER TO ARRAY [0..0] OF DWORD address of source memory pDestination POINTER TO ARRAY [0..0] OF BYTE address of destination memory uiNumberOfBytes UINT number of bytes to encode
MemFill (FUN) ¶ FUNCTION MemFill : BOOL Function fills all bytes of a memory block with the value “byFillValue”. In case of success, the function will return “TRUE”. Only if “MemoryBlock” is set to “0”, the initialization will not be carried out and the function will return “FALSE”. InOut: Scope Name Type Comment Return MemFill BOOL function returns “TRUE” if filling succeeded Input pMemoryBlock POINTER TO BYTE address of memory block uiLength UINT length of memory block in byte byFillValue BYTE Fill value for the memory block
MemMove (FUN) ¶ FUNCTION MemMove : BOOL The function copies the amount of “uiNumberOfBytes” of memory from memory area “Source” to “Destination”, wheras these memory areas are allowed to overlap! In case of success, the function will return “TRUE”. Only if “Source” or “Destination” are set to “0” the copying will not be carried out and the function will return “FALSE”. InOut: Scope Name Type Comment Return MemMove BOOL function return “TRUE” if the moving of bytes succeeded Input pSource POINTER TO BYTE address of source memory pDestination POINTER TO BYTE address of destination memory uiNumberOfBytes UINT number of bytes to move
Packing ¶ PackArrayOfBoolToArrayOfByte (Function) PackBitsToByte (Function) PackBitsToDword (Function) PackBitsToWord (Function) PackBytesToDword (Function) PackBytesToWord (Function) PackWordsToDword (Function) UnpackArrayOfByte (Function) UnpackByte (FunctionBlock) UnpackDWord (FunctionBlock) UnpackWord (FunctionBlock)
PackArrayOfBoolToArrayOfByte (FUN) ¶ FUNCTION PackArrayOfBoolToArrayOfByte : UINT The function packs an “ARRAY OF BOOL” into an “ARRAY OF BYTE”. axSource[0] -> abyDestination[0].0 axSource[1] -> abyDestination[0].1 … axSource[8] -> abyDestination[1].0 … axSource[15] -> abyDestination[1].7 … The function copies “uiNumberOfBits” from “axSource” to “abyDestination”. It will return the necessary number of bytes in “abyDestination”. Only if “paxSource”, “pabyDestination” or “uiNumberOfBits” are set to “0”, the copying will not be carried out and the function will return “0”. Example: axSource : ARRAY [0..9] OF BOOL := FALSE , TRUE , FALSE , FALSE , TRUE , TRUE , FALSE , FALSE , TRUE , FALSE ; abyDestination : ARRAY [0..2] OF BYTE ; uiNumberofBytes := MEM.PackArrayOfBool ( ADR ( abSource ), ADR ( abyDestination ), 10 ) ; -> uiNumberofBytes = 2 abyDestination [0] = 16#32 abyDestination [1] = 16#01 abyDestination [2] = 16#00 Note The size of the ARRAY “abyDestination” has to be adjusted to the amount of bits copied! Source and target may not overlap! InOut: Scope Name Type Comment Return PackArrayOfBoolToArrayOfByte UINT functon returns the necessary number of bytes in “abyDestination” Input paxSource POINTER TO BYTE address of ARRAY OF BOOL pabyDestination POINTER TO BYTE address of ARRAY OF BYTE uiNumberOfBits UINT number of bits to copy from “paxSource” to “pabyDestination”
PackBitsToByte (FUN) ¶ FUNCTION PackBitsToByte : BYTE Function packs 8 Bits “xBit0” .. “xBit7” into a BYTE. Example: PackBitsToByte ( FALSE , FALSE , FALSE , FALSE , FALSE , FALSE , FALSE , TRUE ) = 16#01 InOut: Scope Name Type Comment Return PackBitsToByte BYTE functions returns the BYTE defined by the BOOL inputs Input xBit7 BOOL Bit 7 of the Byte xBit6 BOOL Bit 6 of the Byte xBit5 BOOL Bit 5 of the Byte xBit4 BOOL Bit 4 of the Byte xBit3 BOOL Bit 3 of the Byte xBit2 BOOL Bit 2 of the Byte xBit1 BOOL Bit 1 of the Byte xBit0 BOOL Bit 0 of the Byte
PackBitsToDword (FUN) ¶ FUNCTION PackBitsToDword : DWORD Function packs 32 Bits “xBit0” .. “xBit31” into a DWORD. Example: PackBitsToDword ( FALSE , FALSE , FALSE , FALSE , FALSE , FALSE , FALSE , TRUE , FALSE , FALSE , FALSE , FALSE , FALSE , FALSE , TRUE , FALSE , FALSE , FALSE , FALSE , FALSE , FALSE , FALSE , TRUE , TRUE , FALSE , FALSE , FALSE , FALSE , FALSE , TRUE , FALSE , FALSE ) = 16#01020304 InOut: Scope Name Type Comment Return PackBitsToDword DWORD function returns the DWORD defined by the BOOL inputs Input xBit31 BOOL Bit 31 of the Dword xBit30 BOOL Bit 30 of the Dword xBit29 BOOL Bit 29 of the Dword xBit28 BOOL Bit 28 of the Dword xBit27 BOOL Bit 27 of the Dword xBit26 BOOL Bit 26 of the Dword xBit25 BOOL Bit 25 of the Dword xBit24 BOOL Bit 24 of the Dword xBit23 BOOL Bit 23 of the Dword xBit22 BOOL Bit 22 of the Dword xBit21 BOOL Bit 21 of the Dword xBit20 BOOL Bit 20 of the Dword xBit19 BOOL Bit 19 of the Dword xBit18 BOOL Bit 18 of the Dword xBit17 BOOL Bit 17 of the Dword xBit16 BOOL Bit 16 of the Dword xBit15 BOOL Bit 15 of the Dword xBit14 BOOL Bit 14 of the Dword xBit13 BOOL Bit 13 of the Dword xBit12 BOOL Bit 12 of the Dword xBit11 BOOL Bit 11 of the Dword xBit10 BOOL Bit 10 of the Dword xBit9 BOOL Bit 9 of the Dword xBit8 BOOL Bit 8 of the Dword xBit7 BOOL Bit 7 of the Dword xBit6 BOOL Bit 6 of the Dword xBit5 BOOL Bit 5 of the Dword xBit4 BOOL Bit 4 of the Dword xBit3 BOOL Bit 3 of the Dword xBit2 BOOL Bit 2 of the Dword xBit1 BOOL Bit 1 of the Dword xBit0 BOOL Bit 0 of the Dword