<< Click to Display Table of Contents >> Navigation: Working with Docklight (Advanced) > Testing a TCP Server Device (Scripting) |
Preconditions
•The IP address of the device is known, and the device is accessible via the network from the computer running Docklight Scripting - i.e. a 'ping' to the device's IP address works.
•You know which TCP port you can connect to your device on.
•You know the protocol specification for the device, e.g. Modbus TCP, and the set of commands the device understands.
A) Setting the Communication Options
1. | Choose the menu Tools > Project Settings... |
2. | Choose communication mode Send/Receive |
3. | At Send/Receive on comm. channel, enter the IP address and TCP port number for connecting to the device, e.g. 192.0.0.1:10001. |
4. | Confirm the settings and close the dialog by clicking the OK button. |
TIP: If you want to connect to a server that runs on the same computer as Docklight, you can use the keyword LOCALHOST instead of the actual IP address of your computer (e.g. LOCALHOST:10001 for connecting to a server on port 10001 on the same computer). Using the loopback address 127.0.0.1 will have the same effect.
B) Defining the Send Sequences and Receive Sequences used:
Define all of the commands and responses required for your test, as described in Testing a Serial Device or a Protocol Implementation.
C) Running the test
Establish a connection by choosing Run > Start Communication.
Docklight Scripting now tries to connect to the TCP server device. After the connection is established, you can send one of your predefined Send Sequences using the Send button. Until the TCP server accepts the connection request, you will not see any TX (transmission) data appearing in the Communication Window.
NOTE: If the server closes the TCP session before you choose Run > Stop Communication in Docklight, you will receive the error message "TCP/IP connection closed by the remote computer", and the communication will be stopped.
NOTE: If you receive the error "IP Address / TCP port in use" when starting communications, check if another server or even another Docklight Scripting instance is blocking the port. Also try closing and restarting Docklight Scripting - sometimes the TCP driver layer used by Docklight Scripting does not release a TCP port until the application using it is closed.
NOTE: Even if there is no other server or client blocking a port, it may take up to 4 minutes until a port is actually released and available again. This is a restriction in the TCP driver layer used in Docklight Scripting, and unfortunately Docklight Scripting cannot control this.