-

C# code to exchange data between a PC and an iC9200 using TLS function blocks over TCP protocol

Version Number Description
1.0 Initial version



This application note shows how to exchange data between a PC and an iC9200 using TLS function blocks using TCP protocol.

1. Supported Components

Component Name Version
iC9200 series ≥ 2024.3
iCube Engineer ≥ 2024.3
VisualStudio 2022

2. Solution Details

2.1. Code on iC9200 (server) written in iCubeEngineer

Create a socket. A valid handle will get created when a client connects to the server successfully.

Image


The data being sent to the PC is an array of 256 bytes. In the example below, the last element of the array is incremented every scan. If the same instance of the TLS_SEND_2 function block is used as shown below, one can guarantee that data will be sent every scan from the iC9200.

Image
The data being received by the server (iC9200) is an array of size 256 bytes as shown below.
Image

2.2. C# code running on PC (TCP client)

In a new Visual Studio 2022 console project, include the following libraries.

Image

Code below is used to read a byte array of size 256 from the iC9200 and send a byte array of 256 bytes. The iC9200 is at IP address 192.168.207187 and communicating over port 8000.

Image

2.3. Execution Sequence

  • Start the execution of the project on the iC9200. The iC9200 waits for a connection from the client.
  • Run the C# application.
  • When the PC client makes a connection with the iC9200 server, a handle is created in the iC9200 and the code on the iC9200 starts sending the array of size 256 and receives an array of 256 bytes.
  • The C# code stops executing if the user presses any key. When the code is executing, the code reads data sent from the iC9200 and prints the last element of the array.

Image

  • This value is stuffed into the first element of the array sent back to the iC9200.
  • The value coming back from the PC into the iC9200 can be read as the first element of the array in the iC9200.

Image

  • The C# code stops executing if the user presses any key. The client connection is closed and the communication stops.
  • In order to restart communication, the TLS_SOCKET FB on the iC9200 will have to be activated again.
Note: The C# example provided above is one way in which TCP data can be transferred. There could be other classes in C# that could be used to exchange data. Data transfer is also dependent on the hardware used on the network. Traffic on the switch is a contributing factor to update rates. Ports on the PC that are used to transfer data need to be accessible easily for data transfer. If the ports are blocked, data flow in one or both directions may be restricted. There are no guarantees of time determinism or data integrity in the example provided.

 


This help information is valid for iCube Engineer Online Help 2025.6

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