TCPDevice

Defines an In-Sight spreadsheet cell as a TCP/IP device (client or server), which opens a connection between the In-Sight vision system and another TCP/IP device for sharing data over the network. Once a TCP/IP connection has been established, data is communicated using the ReadDevice, WriteDevice, and QueryDevice functions. For more information, see ReadDevice, WriteDevice and QueryDevice.

If the TCPDevice function initiates the communication with another TCP/IP device on the network, then the cell is the TCP/IP client. If the TCPDevice function waits for the communication to be received from another TCP/IP device on the network, then the cell is the TCP/IP server.

Note:
  • TCPDevice generates an event when it receives a packet; this updates the spreadsheet.
  • To establish a TCP/IP device connection between two In-Sight vision systems, both must be Online.

TCPDevice Inputs

Syntax: TCPDevice(Host Name,Port,Protocol,Packet Type,Timeout,Terminator)

   

Host Name

Specifies the name of the TCP/IP server device with which to establish a connection, if the cell containing the TCPDevice function will be the client.

Note:
  • The Host Name drop-down does not list Host Names of In-Sight vision systems and/or emulators on the network. Manually enter the host name or the IP address of the target vision system/emulator in the Host Name field.
  • If a Host Name is not specified (null-string is the default), then the cell will be a server device, waiting for a TCP/IP client to initiate communications.

Port

  • The port number of the TCP/IP server at which the connection will be established between TCP/IP devices. If a Host Name is specified, the Port number entered here must also be assigned on the server. If a Host Name is not specified (null-string), then this parameter assigns the TCP/IP port number to this device.
  • No two TCPDevice functions on the same host can share the same TCP/IP Port number assignment, or one of the devices will be unable to establish a TCP/IP connection. For example, if two cells in the same In-Sight spreadsheet contain TCPDevice functions which use the default Port number '3000', only one of the cells will be able to function as a TCP/IP device. Therefore, it is important to avoid duplication of Port number assignments.
Note: A valid Port assignment is any unused number between 1 and 65535, except for ports used for In-Sight communications. In-Sight Emulator users should always assign Port numbers 3000 (the default) and higher to prevent potential conflicts with ports reserved by services on the PC. For more information, see In-Sight Ports.

Protocol

The network protocol to use when communicating between an In-Sight vision system and other TCP/IP devices on the network. In-Sight vision systems currently only support the standard TCP/IP protocol.

  • 0 = TCP/IP

Packet Type

Defines the formatting of the data string communicated between an In-Sight vision system and another TCP/IP device.

0 = String CR+LF (default)

ASCII format. When an In-Sight vision system is sending, ASCII characters 13 (Carriage Return) and 10 (Line Feed) will be appended to the data string; when receiving, CR+LF will terminate the data string.

1 = String CR (13)

ASCII format. When an In-Sight vision system is sending, the ASCII character 13 (Carriage Return) will be appended to the data string; when receiving, CR will terminate the data string.

2 = String LF (10)

ASCII format. When an In-Sight vision system is sending, the ASCII character 10 (Line Feed) will be appended to the data string; when receiving, LF will terminate the data string.

3 = String Nullchar (0)

ASCII format. When an In-Sight vision system is sending, the ASCII character 0 (Nullchar) will be appended to the data string; when receiving, Nullchar will terminate the data string.

4 = Modbus

Binary format. The data string will adhere to the Modbus protocol. For more information, see Binary Text Functions.

6 = String with Custom Terminator

ASCII format. When an In-Sight vision system is sending, the specified Terminator will be appended to the data string; when receiving, the specified Terminator will terminate the data string.

7 = Binary with Custom Terminator

Binary format. When an In-Sight vision system is sending, the specified Terminator will be appended to the data string; when receiving, the specified Terminator will terminate the data string.

Note:
  • The Modbus parameter applies only when the In-Sight vision system acts as a Modbus client, as defined in the Open Modbus/TCP Specification (external link; requires Internet access. Published by Modicon). Also note that when Packet Type is set to Modbus, the Port should be set to 502, which is reserved by In-Sight communications.
  • Regardless of the Packet Type, when an In-Sight vision system is receiving data, the ASCII character 0 (Nullchar) will terminate the data string.

Timeout

The number of milliseconds (100 to 15000; default = 1000) to wait for a TCP/IP connection to be established before aborting the connection attempt. This parameter only applies when the TCPDevice function is in a cell defined as a TCP/IP client.

Terminator

Specifies the ASCII character (0 to 255) to be used when String with Customer Terminator or Binary with Customer Terminator is specified for the Packet Type.

TCPDevice Outputs

Returns

A Device data structure. Returns #ERR if any of the input parameters are invalid, or when the Timeout is exceeded.

Note: Up to 12 Device structures can be inserted into a single job.

Results

When the function is inserted into a cell, an additional function will be automatically inserted in the adjacent cell to the right:

  • WriteDevice if the function is a TCP/IP client.
  • ReadDevice if the function is a TCP/IP server.

TCPDevice Example

An In-Sight host vision system named SYSTEM0 is configured as follows:

A3=TCPDevice("SYSTEM1",3000,0,0,300)

B3=WriteDevice($A$0,A3,C3)

A second host system, named SYSTEM1, includes the TCP/IP server and is configured as follows:

A4=TCPDevice("",3000,0,0,300)

B4=ReadDevice(A4)

Both systems are Online. Whenever the default image in cell $A$0 on SYSTEM0 is acquired, the TCP/IP client in cell A3 will establish a connection with the TCP/IP server in cell A4 on SYSTEM1 at Port 3000. The WriteDevice function in cell B3 on SYSTEM0 will then export the data in cell C3 to the ReadDevice function in cell B4 on SYSTEM1.