-

Y_CO_CommunicationChannel

Image
The Y_CO_CommunicationChannel function block is designed to manage an input stream of data from a TCP socket communication interface. It collects portions of data read in a cycle, and adds it to a circular buffer for further analysis. The Yt_CO_CommStruct structure must be initialized by the user to configure the necessary communication parameters.

Parameters

* Parameter Data Type Description Default
VAR_IN_OUT
V CircularByteBuffer Yt_CO_CircularBufferStruct Structure containing a data buffer and other operational information required to manage the CircularByteBuffer.
V CommConfig Yt_CO_CommStruct Structure containing information to be used in establishing socket or serial communication.
VAR_INPUT
V Enable BOOL The function will continue to execute every scan while Enable is held high and there are no errors. FALSE
V ClearBuffer BOOL Resets the StorePointer and UsePointer, which logically clears the contents of the circular buffer, but any existing data is not actually cleared. FALSE
V Timeout TIME This input is used only for fixed mode Command Type specified in Yt_CO_CommStruct. If the specified packet sizes does not arrive within the timeout specified , a packet size error is generated. The timeout period starts only after a successful connection is established. TIME#0s
VAR_OUTPUT
V Valid BOOL Indicates that the function is operating normally and the outputs of the function are valid.
V Busy BOOL Set high upon the rising edge of the Execute input, and reset when Done, CommandAborted, or Error is true. In the case of a function block with an Enable input, a Busy output indicates the function is operating, but not ready to provide Valid information. (No Error)
V Error BOOL Set high if an error has occurred during the execution of the function block. This output is cleared when 'Execute' or 'Enable' goes low.
V ErrorID UINT If Error is true, this output provides the Error ID. This output is reset when 'Execute' or 'Enable' goes low.
V Socket DINT File handle to be used when writing to device connected to the socket. Only valid when non-zero.
  • A non zero value means that a socket has been opened and a successful connection with a client has been established.
  • If the socket value goes from a non zero value to zero, it means that there is no active socket connection from the client. The client may have closed the connection.
V PacketCount UDINT Total packet count since this function block was enabled.
V BytesReceived UDINT Total bytes received since this function was enabled.
V BytesPerSec DINT Bytes received per second.

Notes

Error Description

See the Function Block ErrorID List.

Example 1

The example below shows how to use Y_CO_CommunicationChannel function block for variable length packets. Initialize the CommConfig structure of Y_CO_CommunicationChannel with the following example values.

Image

Set the datatype of the 'TransmitionData' variable to a Yt_CO_CircularBufferStruct. Set the enable input high on the CommunicationChannel Function Block.


Image

We use the same iC9200 as the sender (client device) in this example. Add the following additional function blocks to the same project. The TLS_Socket FB creates a handle from the client side that will be used to send data to the port used by the Y_CO_CommunicationChannel FB (server). The Destination port on the client side will be the local port on the server side. The TLS_SEND FB is used to send data using the handle created by the TLS_SOCKET FB.


Image

Populate the "TransmitData" variable using the watch window as shown below.


Image

Activate the TLS_Socket FB and then set the Request input on the TLS_Send FB.

Image

If the data is sent successfully by the TLS_SEND FB, the data will appear in the 'TransmitionData' circular buffer variable on the Y_CO_CommunicationChannel FB.


Image

Example 2

The example below shows how to use Y_CO_CommunicationChannel function block for fixed length packets. Initialize the CommConfig structure of Y_CO_CommunicationChannel with the following example values.


Image


Set the "TransmitData" Datatype toByteArray40 and Populate the "TransmitData" variable using the Init Value Configuration window as shown below. Then Write and Warm

Image


Set the datatype of the 'TransmitionData' variable to a CircularByteBuffer.Set the enable input high on the CommunicationChannel Function Block.

Set the Timeout input to 30s. This specifies that the correct data needs to be received every "30s" otherwise and error will occur.


Image

We use the same iC9200 as the sender (client device). Add the following additional function blocks to the same project. The TLS_Socket FB creates a handle from the client side that will be used to send data to the port used by the Y_CO_CommunicationChannel FB (server). The Destination port on the client side will be the local port on the server side. The TLS_SEND FB is used to send data using the handle created by the TLS_SOCKET FB.


Image

Activate the TLS_Socket FB and then set the Request input on the TLS_Send FB.

Image

If the data is sent successfully by the TLS_SEND FB, the data will appear in the 'TransmitionData' circular buffer variable on the Y_CO_CommunicationChannel FB.


Image
------------------------------------------------------------------------------------------------------------------------------
Image
After 30s of no data transfer the following PacketSize error will occur on the CommunicationChannel function block.
Image

 


This help information is valid for iCube Engineer Online Help 2025.6

Copyright © 2025 YASKAWA EUROPE GmbH and © 2025 YASKAWA America, Inc.