Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Troubleshooting TCP/IP Interface

Transmission Control Protocol (TCP) is a transport protocol layered on top of the Internet Protocol (IP) and is one of the most highly used networking protocols. With Instrument Control Toolbox™ you can use raw socket communication and connect to remote hosts to read and write data. For example, you could use it to acquire data from a remote weather station, and plot the data.

Supported Platforms

TCP/IP is supported on these platforms:

  • Linux® 64-bit

  • macOS 64-bit

  • Microsoft® Windows® 64-bit

The TCP/IP interface is supported on the same platforms as MATLAB®. For updates to the list of currently supported platforms, see http://www.mathworks.com/support/sysreq/current_release/.

Configuration and Connection

  1. Make sure that you have the correct instrument driver installed for your device. Refer to your device documentation and the vendor website.

  2. Make sure that your device is supported in Instrument Control Toolbox. See Is My Hardware Supported?.

  3. Make sure that Instrument Control Toolbox recognizes your device, by using the instrhwinfo function with the tcpip interface name. For example:

    instrhwinfo('tcpip')
    ans = 
    
     HardwareInfo with properties:
    
             LocalHost: {6x1 cell}
        JarFileVersion: 'Version 3.7'
  4. Make sure you can create your TCP/IP object. You create a TCP/IP object with the tcpip function, which requires the name of the remote host as an input argument. In most cases, you also need to specify the remote port value. If you do not specify the remote port, then 80 is used.

    Each TCP/IP object is associated with one instrument. For example, to create a TCP/IP object for a Sony/Tektronix® AWG520 Arbitrary Waveform Generator, you use the remote host name of the instrument and the port number, which can be found in the instrument’s documentation.

    t = tcpip('sonytekawg.yourdomain.com',4000);
  5. Make sure you can connect to the device, using the fopen function with the object name.

    fopen(t);

    If you do not get an error, the connection was made successfully. The fopen function errors if the socket connection cannot be made to the TCP/IP server. If fopen works, the computer and port number are correct and a TCP/IP server is running on the other end. If you do get an error, follow the steps in the error message and/or check the previous steps listed here.

  6. When you have connected, you can communicate with your device. If sending and receiving does not work, you can check the following:

    • Make sure the data is being sent in the format expected by the server.

    • If you connect to a web server, you may need to send HTTP get or post commands. You can also use the urlread or webread functions to communicate with web servers.

    • Many TCP/IP servers expect header information inside the TCP/IP packet.

    See TCP/IP Communication with a Remote Host for an example of communication over TCP/IP.

Other Troubleshooting Tips for TCP/IP

VISA

You can also use the visa interface with a VISA TCP/IP resource name instead of the tcpip interface for TCP/IP communication with instruments.

Incorrect Data

Make sure the correct data type – for example int16, uint16, double – is being used with fread and fwrite. You should use the same data type as the instrument uses.

If reading and writing data types other than uint8 or int8, make sure the ByteOrder is correct.

Was this topic helpful?