Instrument Control tcp_write Fails

Hi All,
I am trying to connect to an Agilent DMM using the instrument-control package.

I enter following command into the GUI:

dmm =

TCP Client Object TCP-
Port: 80

It looks like the port is connected however the tcp_write fails:

ret = tcp_write(dmm,’*IDN?’)
error: Invalid call to tcp_write. Correct usage is:

– Loadable Function: N = tcp_write (TCP, DATA)

Additional help for built-in functions and operators is
available in the online version of the manual. Use the command
'doc ’ to search the manual index.

Help and information about Octave is also available on the WWW
at and via the
mailing list.

I am guessing that I don’t have the correct port identified for the TCP Client and I copied port ‘80’ from the online examples. How can I verify that port connection? Any other reasons that the connection fails?

Note: I can access the DMM webpage using the IP address so I know the IP address is correct and the hardware is functioning.

“80” is a web page (http) port, I suspect it uses telnet (port 23) for commands.

Looking at the source repository, I see that tcp_write expects a tcp object not a tcpclient object as first argument, hence the invalid call error. So you should either build a tcp object to use with tcp_write, or use tcpclient_write.

There are 2 tcp classes in instrument control.

  1. the old tcp class

  2. the newer tcpclient which attempts to be closer to the current matlab class of the same name.

The older tcp class have functons tcp_xxxx that will work with it as well as read, write, fread etc.

The newer tcpclient does not have any tcpxxxxx functions, just read and write.

See List of Functions for the 'instrument-control' package for list of functions available.

Hi Dasergatskov,

I switched the port number to 23 and received an error:
딳߿>> dmm=tcpclient(“”,23)
error: tcpclient: error on connect : 10061 -

Do you know how I can identify the correct port number?


Hi Pantxo & lostbard

I tried using the tcp command along with the tcp_write as well as the tcpclient along with the write command and I still receive bad results.

Trial1: tcp w/ write

dmm =

TCP Object TCP-
type: tcp
status: open
remoteport: 80
localport: 0

ret = -1

Trial 2: tcpclient /tcp

dmm =

TCP Client Object TCP-
Port: 80

ret = 5

ret = -1

I appreciate everyone’s suggestions!

Im guessing that port 80 is using the web interface to the device.
Try connecting using a webbrowser to
if that shows a webpage, then you are trying to send non HTTP commands to a webserver.

There will likely be another port that allows communication the command set you are trying to use - port 5025 ?
You maybe also need to send the ‘\n’ as part of the command.

Hi All,

Thank you for the advice!

The original port setting of 80 was indeed incorrect. After doing some digging I was able to confirm that the suggested port setting of 5025 will work with the Agilent instruments that I am trying to program. I was able to successfully establish a connection.

Admittedly, through my debugging I found that I cannot use Ethernet. Some of the PCs that need to support the script do not have Ethernet port. I will need to migrate to USB and it appears that the USBTMC is not supported with Windows.

Nonetheless, I appreciate everyone’s help to get me to this point!


1 Like