TCP_Write (FB) ¶ FUNCTION_BLOCK TCP_Write EXTENDS CBM.ETrigTo This function block serves to write data to the previously established connection given in hConnection . The content of the memory area indicated by pointer pData contains the data to be written. szSize defines the number of bytes to be written. When xDone is set to TRUE the data was written successfully. The time out value has no effect at this function block. 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. ETrigTo udiTimeOut UDINT Defines the time (µs) after which an FB (e.g. requiring an external acknowledgement) aborts operation due to a timeout with error message. ETrigTo Output xDone BOOL TRUE : Action successfully completed ETrigTo xBusy BOOL TRUE : Function block active ETrigTo xError BOOL TRUE : Error occurred, function block aborts action FALSE : No error ETrigTo Input hConnection CAA.HANDLE szSize CAA.SIZE pData CAA.PVOID Output eError ERROR
TCP_WriteBuffer (FB) ¶ FUNCTION_BLOCK TCP_WriteBuffer EXTENDS CBM.ETrigTo Like TCP_Write this function block serves to write data to the previously established connection given in hConnection . Instead of a pointer to the data, this function block expects a handle of the buffer containing the data to be written. The buffer is passed on and not copied like at TCP_Write . The time out value has no effect at this function block. 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. ETrigTo udiTimeOut UDINT Defines the time (µs) after which an FB (e.g. requiring an external acknowledgement) aborts operation due to a timeout with error message. ETrigTo Output xDone BOOL TRUE : Action successfully completed ETrigTo xBusy BOOL TRUE : Function block active ETrigTo xError BOOL TRUE : Error occurred, function block aborts action FALSE : No error ETrigTo Input hConnection CAA.HANDLE hBuffer CAA.HANDLE Output eError ERROR
UDP ¶ UDP_Peer (FunctionBlock) UDP_Receive (FunctionBlock) UDP_ReceiveBuffer (FunctionBlock) UDP_Send (FunctionBlock) UDP_SendBuffer (FunctionBlock)
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