Instrument Control Toolbox    

Example: Server Drops the Connection

This example shows what happens when a TCP/IP object loses its connection with a remote server. The server is a Sony/Tektronix AWG520 Arbitrary Waveform Generator (AWG). Its address is sonytekawg.mathworks.com and its port is 4000. The AWG's host IP address is 192.168.1.10 and is user configurable in the instrument. The associated host name is given by your network administrator. The port number is fixed and is found in the instrument's documentation.

The AWG can drop the connection because it is taken off line, it is powered down, and so on.

  1. Create an instrument object -- Create a TCP/IP object for the AWG.
  2. Connect to the instrument -- Connect to the remote instrument.
  3. Write and read data -- Write a command to the instrument and read back the result.
  1. Assume that the server drops the connection. If you attempt to read from the instrument, a timeout occurs and a warning is displayed.

    At this point, the object and the instrument are still connected.

    If you attempt to write to the instrument again, an error message is returned and the connection is automatically closed.

    Note that if the TCP/IP object is connected to the local host, the warning message is not displayed. Instead, the error message is displayed following the next read operation after the connection is dropped.

  1. Disconnect and clean up -- When you no longer need t, you should disconnect it from the host, and remove it from memory and from the MATLAB workspace.

  The TCP/IP Object Display Creating a UDP Object