Documentation

This is machine translation

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

TCP/IP and UDP Interface

Communication using the TCP/IP clients and servers or UDP protocol

Use the TCP/IP and UDP interfaces for reading and writing both binary data and ASCII data. You use different functions for the different data types – fprintf and fscanf for ASCII operations, and fread and fwrite for binary data. You can also do asynchronous operations using other functions.

Functions

tcpip Create TCPIP object
udp Create UDP object
echotcpip Start or stop TCP/IP echo server
echoudp Start or stop UDP echo server
resolvehost Network name or network address
tmtool Open Test & Measurement Tool
fopen Connect interface object to instrument
fclose Disconnect interface object from instrument
fread Read binary data from instrument
fwrite Write binary data to instrument
fscanf Read data from instrument, and format as text
fprintf Write text to instrument
readasync Read data asynchronously from instrument
stopasync Stop asynchronous read and write operations
binblockread Read binblock data from instrument
binblockwrite Write binblock data to instrument
fgetl Read line of text from instrument and discard terminator
fgets Read line of text from instrument and include terminator
query Write text to instrument, and read data from instrument
scanstr Read data from instrument, format as text, and parse
clear Remove instrument objects from MATLAB workspace
delete Remove instrument objects from memory
instrhwinfo Information about available hardware
instrfind Read instrument objects from memory to MATLAB workspace
instrfindall Find visible and hidden instrument objects
instrreset Disconnect and delete all instrument objects
flushinput Remove data from input buffer
flushoutput Remove data from output buffer
instrcallback Display event information when event occurs

Blocks

Query Instrument Query or read instrument data
To Instrument Send simulation data to instrument
TCP/IP Receive Receive data over TCP/IP from specified remote machine
TCP/IP Send Send data over TCP/IP to specified remote machine
UDP Receive Receive data over UDP network from specified remote machine
UDP Send Send data over UDP network to specified remote machine

Examples and How To

TCP/IP Client Examples and How-to

Create a TCP/IP Object

Create a TCP/IP object to establish a connection between MATLAB® and the remote host.

TCP/IP Communication with a Remote Host

These are the minimum steps required to communicate with a remote host over TCP/IP.

Rules for Completing Read and Write Operations over TCP/IP and UDP

The rules for completing synchronous and asynchronous read and write operations are described here.

Basic Workflow to Read and Write Data over TCP/IP

This example illustrates how to use text and binary read and write operations with a TCP/IP object connected to a remote instrument.

Read and Write ASCII Data over TCP/IP

This section provides details and examples exploring ASCII read and write operations with a TCP/IP object.

Read and Write Binary Data over TCP/IP

This section provides details and examples exploring binary read and write operations with a TCP/IP object.

Asynchronous Read and Write Operations over TCP/IP

This section provides details and examples exploring asynchronous read and write operations with a TCP/IP object.

TCP/IP Server Examples and How-to

Communicate Using TCP/IP Server Sockets

Support for Server Sockets is available for a single remote connection. You can use this connection to communicate between a client and MATLAB, or between two instances of MATLAB.

UDP Examples and How-to

Create a UDP Object

Create a UDP object to establish a connection between MATLAB and the remote host.

UDP Communication Between Two Hosts

These are the minimum steps required to communicate between two hosts over UDP.

Rules for Completing Read and Write Operations over TCP/IP and UDP

The rules for completing synchronous and asynchronous read and write operations are described here.

Basic Workflow to Read and Write Data over UDP

This example shows the basic workflow of text read and write operations with a UDP object connected to a remote instrument.

Read and Write ASCII Data over UDP

This section provides details and examples exploring ASCII read and write operations with a UDP object.

Read and Write Binary Data over UDP

This section provides details and examples exploring binary read and write operations with a UDP object.

Asynchronous Read and Write Operations over UDP

This section provides details and examples exploring asynchronous read and write operations with a UDP object.

Concepts

TCP/IP and UDP Comparison

Transmission Control Protocol (TCP or TCP/IP) and User Datagram Protocol (UDP or UDP/IP) are both transport protocols layered on top of the Internet Protocol (IP). The two protocols are compared here.

Events and Callbacks

Enhance your instrument communication using events and callbacks.

Instrument Control Toolbox Properties

These properties are available in the toolbox.

Troubleshooting

Troubleshooting TCP/IP Interface

Try these tips if you have problems using the toolbox with the TCP/IP interface. Includes information about TCP/IP supported platforms, configuration and connection, and other interface-specific tips.

Troubleshooting UDP Interface

Try these tips if you have problems using the toolbox with the UDP interface. Includes information about UDP supported platforms and configuration and connection.

Was this topic helpful?