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)
UDP_Peer (FB) ¶ FUNCTION_BLOCK UDP_Peer EXTENDS CBM.LTrig This function block activates a Peer by setting xEnable to TRUE. InOut: Scope Name Type Initial 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 ipAddr IP_ADDR STRUCT(sAddr := ‘0.0.0.0’) ‘0.0.0.0’ => INADDR_ANY ‘127.0.0.1’ => INADDR_LOOPBACK ‘255.255.255.255’ => INADDR_NONE uiPort UINT ipMultiCast IP_ADDR STRUCT(sAddr := ‘255.255.255.255’) Multicast address. ‘255.255.255.255’ => INADDR_NONE Output eError ERROR xActive BOOL TRUE if the handle is valid hPeer CAA.HANDLE
UDP_Receive (FB) ¶ FUNCTION_BLOCK UDP_Receive EXTENDS CBM.LTrig This function block serves to receive data. The pointer pData specifies the memory area to write the read data to. szSize defines the max number of bytes to read. When data was read successfully, xReady is set to TRUE and szCount indicates the actually read number of bytes. ipFrom and uiPortFrom indicate the ip and port the data was received from. 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 hPeer CAA.HANDLE szSize CAA.SIZE pData CAA.PVOID Output eError ERROR xReady BOOL ipFrom IP_ADDR uiPortFrom UINT szCount CAA.SIZE
UDP_ReceiveBuffer (FB) ¶ FUNCTION_BLOCK UDP_ReceiveBuffer EXTENDS CBM.LTrig Like UDP_Receive this function block serves to receive data. The function block returns the handle of the buffer containing the data. As long as xReady is TRUE a new handle for the buffer can arrive. ipFrom and uiPortFrom indicate the ip and port the data was received from. The buffer is passed on and not copied like at UDP_Receive . 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 hPeer CAA.HANDLE Output eError ERROR xReady BOOL ipFrom IP_ADDR uiPortFrom UINT hBuffer CAA.HANDLE
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”