TCP Drivers

This driver communicates via TCP or UDP. A TCP connection and a UDP connection can be configured both separately as well as both together. Each of these connections is indicated via a "Communication Reference" brief kr, which is specified in the config file. For TCP and UDP a server and a client have to be configured.

The connection only works if the server is started before the client. Data can exclusively be transmitted from the client to the server.

Set Up Server

Configure the address panel:

  1. Copy the files userPara.ctl and userDrivers.ctl into the script directory of your project.
  2. Copy the panel address_tcp.pnl into the directory panels/para of your project.

Config Settings

The entries are specified in the sections [tcp] and/or [tcp_<num>].

In the section [tcp_1] the settings for the server are specified and the client is configured in the section [tcp_2]. The section [tcp]where the entries for both the server and the client are specified, is not used for the TCP driver.

Configuration of the Server (the Driver with the -num 1 is the Server):

tcpServerSocket

[tcp_1]
tcpServerSocket = 4242

tcpServerSocket is the port number where the TCP client has to connect to the TCP server.

udpServerSocket

[tcp_1]
udpServerSocket = 4241

udpServerSocket is the port number where the UDP client has to connect to the UDP server.

host

Syntax:

host = kr "IP address:0" "protocol"
[tcp_1]
host = 1 "192.168.0.151:0" "TCP"
host = 2 "127.0.0.1:0"     "UDP"

The entry host is used to specify which IP addresses are accepted by the TCP or the UDP server.

  • Argument 1: kr --- represents a synonym for a connection and facilitates the internal processing.
  • Argument 2: IP address (or the host name)

Example

"192.168.0.151:0"

"127.0.0.1:0" local IP address of the own computer

"localhost:0" Host name of the own computer

The indication: 0 can also be omitted

  • Argument 3: Protocol notation "TCP" or "UDP"

Configuration of the Client (the Driver with -num 2 is the Client):

host

Syntax:

host = kr "IP address:Server port" "protocol"
[tcp_2]
host = 1 "192.168.0.151:4242" "TCP"
host = 2 "127.0.0.1:4241"     "UDP"
  • Argument 1: kr --- This number has to correspond to the corresponding entry in [tcp_1] (server settings). If the same number is specified more than once for kr, the driver is stopped.
  • Argument 2: IP address (not the IP name)

Example

"192.168.0.151:4242"

"127.0.0.1:4241" local IP address of the own computer

"localhost:1764" host name of the own computer

The IP address or the host name has to correspond to the indication in the server configuration.

"Serverport" is the port number that is used by the client to connect. It has to exist and has to correspond to the tcpServerSocket or udpServerSocket.

  • Argument 3: Protocol notation "TCP" or "UDP"

This has to correspond to the indication in the server configuration.

Configuration

For the configuration at least 1 driver has to run (it can also be the simulation driver).

The config file is provided with the following entries. Thus, the communication connections are defined. All members (server and client) are located on the same computer.

[tcp_1]
tcpServerSocket  = 4242
udpServerSocket = 4241
host = 1     "127.0.0.1:0"               "TCP"
host = 2     "127.0.0.1:0"               "UDP"
[tcp_2]
host = 1     "localhost:4242"         "TCP"
host = 2     "127.0.0.1:4241"        "UDP"

After creating an address config the driver type has to be selected. In case of the TCP driver it is the sample TCP driver.

Figure 1. Configure the sample TCP driver

After pressing the Configure... button, fill in the fields as follows:

Reference:

z.B. 1.67

1 = kr

67 = ix

  • The driver with the -num 1 is the server and thus the recipient of the data.
  • ix (can be interpreted as memory address in the target hardware) is an arbitrary number that has to be same in the sent as well as in the received data point.

Direction: Indication of the transmission direction. For the direction input also low level/old/new comparison can be configured.

Data type : the data types bool, integer, float and string are supported.

Driver number : in the example, 1 is set for inputs (server) and 2 for outputs (client).

Figure 2. Configure the sample TCP driver