Write command to remote host over TCP/IP and read response
writes the ASCII text
response = writeread(
command followed by the terminator to the remote
host specified by the TCP/IP client
t, then reads the ASCII text
returned from the remote host. You can use this function to query the remote host. The
function suspends MATLAB® execution until the specified
command is sent to the
remote host and a response is received.
Create a TCP/IP client connection to an instrument. In this example, the instrument connected to this network is a Keysight Technologies® (formerly Agilent Technologies®) X-Series Signal Analyzer (N9030A, PXA Signal Analyzer). The specified IP address and port are unique to this example.
t = tcpclient("172.31.165.102",5025)
t = tcpclient with properties: Address: '172.31.165.102' Port: 5025 NumBytesAvailable: 0 Show all properties, functions
Write an instrument identification SCPI command to the instrument and read the response.
ans = "Agilent Technologies,N9030A,US00071181,A.14.16"
The instrument response to the
*IDN? command identifies the name of the instrument.
t— TCP/IP client
TCP/IP client, specified as a
writeread(t,"*IDN?") sends an ASCII text command to the
command— ASCII text command to write to device
ASCII text command to write to device, specified as a character vector or string scalar.
writeread(t,"*IDN?") sends the ASCII command