TLSContext (FB) ¶ FUNCTION_BLOCK PUBLIC FINAL TLSContext IMPLEMENTS ITLSContext , ITLSContext_Internal Encapsulates all the data neccecray to handle encrypted tcp connections Static initialization, as shown in the following code snippet. VAR commonName : STRING := 'MyRrasPi' ; ciCertInfo : NBS.CERT_INFO := ( psInfo := ADR ( commonName ), udiSize := LEN ( commonName )); myTLSContext : NBS.TLSContext := ( ePurpose := NBS.PURPOSE.CLIENT_SIDE , sUseCaseName := 'NBSTest' , sTLSVersion := '1.3' , ciCertInfo := ciCertInfo , udiVerificationMode := 2 ); END_VAR InOut: Scope Name Type Initial Comment Input Const sUseCaseName STRING A name to identify this context in the security manager ePurpose PURPOSE This context can be used on the server side or on the client side. sTLSVersion TLS_VERSION ‘1.2’ A string to select the correct protocol version sCipherList CIPHER_LIST STRUCT(psList := ADR(‘HIGH’), udiSize := 5) A string to select the correct encryption cipher suites. See for example: https://www.openssl.org/docs/man1.1.1/man1/ciphers.html#CIPHER-LIST-FORMAT sHostname HOSTNAME A hostname to select the correct certificate on the server side. udiVerificationMode UDINT 1 1 => No peer verification 2 => Active Peer verification (4) => 2+4 = 6 => Force termination, if no client certificate (8) => 2+8=10 or 2+4+8 = 14 => Request client certificate only whithin initial handshake ciCertInfo REFERENCE TO CERT_INFO A string to select the correct certificate in local certificate store itfCertVerifer ICertificateVerifier A callback for application specific cerificate verification Methods: SetInitialValue Structure: SetInitialValue (Method)
UDP ¶ UDP_Packet CreatePacket (Function) CreatePacketPool (Function) PacketPool (FunctionBlock) IPacketPool GetPacket (Method) SetInitialValue (Method) PacketQueue (FunctionBlock) IPacketQueue GetPacket (Method) PutPacket (Method) UDP_Peer (FunctionBlock) IOptionConsumer SetOptionProvider (Method) Receive (Method) Receive2 (Method) Send (Method) SetInitialValue (Method) UDP_Processor (FunctionBlock) IUDPProcessor ProcessPacket (Method) NonBlocking (Property) SetInitialValue (Method) UDP_Receive (FunctionBlock) UDP_Receiver (FunctionBlock) SetInitialValue (Method) UDP_Send (FunctionBlock) UDP_Sender (FunctionBlock) SetInitialValue (Method)
UDP_Packet ¶ CreatePacket (Function) CreatePacketPool (Function) PacketPool (FunctionBlock) IPacketPool GetPacket (Method) SetInitialValue (Method) PacketQueue (FunctionBlock) IPacketQueue GetPacket (Method) PutPacket (Method)
UDP_Peer (FB) ¶ FUNCTION_BLOCK PUBLIC FINAL UDP_Peer EXTENDS LConC IMPLEMENTS IPeer , IOptionConsumer This function block activates a Peer by setting xEnable to TRUE. A peer encapsulates all the necessary things for sending and receiving data over the UDP protocol. The output itfPeer can be contected with UDP_Receive , UDP_Receiver , UDP_Send and UDP_Sender . The Send and Receive methods can also be used as an alternative to the related traditional function blocks. Sending or receiving multicast telegrams is only possible if the input itfMulticast has been assigned accordingly with an IPAddressSet or IPv4Address . InOut: Scope Name Type Comment Inherited from Input xEnable BOOL TRUE : Activates the defined operation FALSE : Aborts/resets the defined operation LConC Output xBusy BOOL TRUE : Operation is running LConC xError BOOL TRUE : Error condition reached LConC eErrorID ERROR LConC Input Const itfAsyncProperty IAsyncProperty Input itfIPAddress IIPAddress IP Address of the specific Adpater for Receiving/Sending (The related Networkmask and Broadcast adresses for receiving will be calculated) uiPort UINT Receive Port itfMulticast IIPAddressSet One or more Multicast Groups (optional) Output xActive BOOL TRUE if the peer context is established itfPeer IPeer The established context of this peer Valid, as long xActive = TRUE Methods: Receive Receive2 Send SetInitialValue SetOptionProvider Structure: IOptionConsumer SetOptionProvider (Method) Receive (Method) Receive2 (Method) Send (Method) SetInitialValue (Method)
UDP_Processor (FB) ¶ FUNCTION_BLOCK PUBLIC ABSTRACT UDP_Processor EXTENDS LConC IMPLEMENTS IUDPProcessor Provides the ability to evaluate or manipulate the flow of packets between UDP_Receiver and UDP_Sender via the specific implementation of the AsyncAction method. InOut: Scope Name Type Comment Inherited from Input xEnable BOOL TRUE : Activates the defined operation FALSE : Aborts/resets the defined operation LConC Output xBusy BOOL TRUE : Operation is running LConC xError BOOL TRUE : Error condition reached LConC eErrorID ERROR LConC Input Const itfAsyncProperty IAsyncProperty itfPacketPool IPacketPool Input itfReceiver IPacketQueue Output itfSender IPacketQueue udiCount UDINT Properties: NonBlocking Methods: SetInitialValue ProcessPacket Structure: IUDPProcessor ProcessPacket (Method) NonBlocking (Property) SetInitialValue (Method)
PingRequest (FB) ¶ FUNCTION_BLOCK PUBLIC FINAL PingRequest EXTENDS ETrigTo Checks the availability of the communication partner with a ping request. The time out value specifies the time to wait until reply InOut: Scope Name Type Comment Inherited from Input xExecute BOOL Rising edge: Starts defined operation FALSE : Resets the defined operation after ready condition was reached ETrigTo udiTimeOut UDINT Max. operating time for executing [µs], 0: No operating time limit ETrigTo Output xDone BOOL Ready condition reached ETrigTo xBusy BOOL TRUE : Operation is running ETrigTo xError BOOL TRUE : Error condition reached ETrigTo eErrorID ERROR ETrigTo Input Const itfAsyncProperty IAsyncProperty Input itfIPAddress IIPAddress IP address of the communication partner Output udiReplyTime UDINT Average reply time of the ping request in milliseconds Methods: RequestPing SetInitialValue SampleAction Structure: IActionProvider SampleAction (Method) RequestPing (Method) SetInitialValue (Method)
ResolveHostname (FB) ¶ FUNCTION_BLOCK PUBLIC FINAL ResolveHostname EXTENDS ETrigTo Attempts to resolve the sHostname to an IIPAddress . If an IP address is already specified as a parameter, its format is checked. The time out value has no effect for this function block. Below is an example of how to handle the itfIPAddress parameter. It is necessary to assign an instance of NBS.IPv4Address to a variable of type NBS.IIPAddress . VAR myResolver : NBS.ResolveHostname ; sHostname : STRING := 'www.codesys.com' ; myIPAddress : NBS.IPv4Address ; itfIPAddress : NBS.IIPAddress := myIPAddress ; udiCount : UDINT ; sIPAddress : NBS.IPADDRESS ; END_VAR myResolver ( sHostname := sHostname , itfIPAddress := itfIPAddress , udiCount => udiCount ); IF myResolver.xExecute AND myResolver.xDone THEN sIPAddress := myIPAddress.CompressedIP ; myResolver.xExecute := FALSE ; END_IF InOut: Scope Name Type Initial Comment Inherited from Input xExecute BOOL Rising edge: Starts defined operation FALSE : Resets the defined operation after ready condition was reached ETrigTo udiTimeOut UDINT Max. operating time for executing [µs], 0: No operating time limit ETrigTo Output xDone BOOL Ready condition reached ETrigTo xBusy BOOL TRUE : Operation is running ETrigTo xError BOOL TRUE : Error condition reached ETrigTo eErrorID ERROR ETrigTo Input Const itfAsyncProperty IAsyncProperty Input sHostname REFERENCE TO STRING udiIndex UDINT 0 Select a specific item, if more then one interface per hostname is avaiable Inout itfIPAddress IIPAddress Output udiCount UDINT The number of possible IP addresses for the sHostname specified Methods: ResolveHostname SetInitialValue SampleAction Structure: IActionProvider SampleAction (Method) ResolveHostname (Method) SetInitialValue (Method)
TCP ¶ TCP_Client (FunctionBlock) IClient Read (Method) SetAdapter (Method) Upgrade (Method) Write (Method) IOptionConsumer SetOptionProvider (Method) SetInitialValue (Method) TCP_Connection (FunctionBlock) IConnection GetClientAddress (Method) Read (Method) Write (Method) TCP_Processor (FunctionBlock) ITCPProcessor ProcessStream (Method) NonBlocking (Property) SetInitialValue (Method) TCP_Read (FunctionBlock) TCP_Reader (FunctionBlock) SetInitialValue (Method) TCP_Server (FunctionBlock) IOptionConsumer SetOptionProvider (Method) SetInitialValue (Method) TCP_Stream CreateSegment (Function) CreateSegmentPool (Function) SegmentPool (FunctionBlock) IDisposable ObjectDispose (Method) ISegmentPool GetSegment (Method) SetInitialValue (Method) Stream (FunctionBlock) IStream Read (Method) Write (Method) TCP_Write (FunctionBlock) TCP_Writer (FunctionBlock) SetInitialValue (Method)
TCP_Client (FB) ¶ FUNCTION_BLOCK PUBLIC FINAL TCP_Client EXTENDS LCon IMPLEMENTS IClient , IOptionConsumer Implements a TCP Client. To connect to a TCP Server at the endpoint defined with itfIPAddress and uiPort the input xEnable should set to TRUE . While setup the connection xBusy is TRUE but xActive is FALSE . After the connection is established xActive and xBusy is TRUE and the itfConnection output is valid. After closing the connection from the server side xActive becomes FALSE itfConnection become invalid and xDone becomes TRUE . itfConnection can be used as input itfConnection for function blocks TCP_Write , TCP_Writer , TCP_Read and TCP_Reader . InOut: Scope Name Type Initial Comment Inherited from Input xEnable BOOL TRUE : Activates the defined operation FALSE : Aborts/resets the defined operation LCon Output xDone BOOL Ready condition reached LCon xBusy BOOL TRUE : Operation is running LCon xError BOOL TRUE : Error condition reached LCon eErrorID ERROR LCon Input Const itfAsyncProperty IAsyncProperty itfTLSContext ITLSContext itfTSNContext ITSNContext Input udiTimeOut UDINT 0 Defines the time (µs) after which the connection setup aborts with active xError . itfIPAddress IIPAddress The related server address (With ResolveHostname , the conversion from a hostname to an ip address is possible) uiPort UINT The related server port Output xActive BOOL TRUE if a Connection is established itfConnection IConnection The established connection to the related server Valid, as long xActive = TRUE Methods: SetInitialValue Read SetAdapter SetOptionProvider Upgrade Write Structure: IClient Read (Method) SetAdapter (Method) Upgrade (Method) Write (Method) IOptionConsumer SetOptionProvider (Method) SetInitialValue (Method)
TCP_Connection (FB) ¶ FUNCTION_BLOCK PUBLIC FINAL TCP_Connection EXTENDS LCon IMPLEMENTS IConnection , IConnection_Internal Encapsulates the connection between client and server The TCP_Server function block will activate a related TCP_Connection function block, if a client has successfully connected to its server. itfConnection can be used as input itfConnection for function blocks TCP_Write , TCP_Writer , TCP_Read and TCP_Reader . InOut: Scope Name Type Comment Inherited from Input xEnable BOOL TRUE : Activates the defined operation FALSE : Aborts/resets the defined operation LCon Output xDone BOOL Ready condition reached LCon xBusy BOOL TRUE : Operation is running LCon xError BOOL TRUE : Error condition reached LCon eErrorID ERROR LCon Input itfServer IServer The related TCP_Server function block (One server function block can manage more than one connection function block). Output xActive BOOL TRUE if a Connection is established itfConnection IConnection The established connection to the related client Valid, as long xActive = TRUE Methods: GetClientAddress Read Write Structure: IConnection GetClientAddress (Method) Read (Method) Write (Method)