I've an LXI instrument that I can connect to using the Agilent IO Suite using the same VISA address (see address used below) or through the instrument's webpage (an LXI instrument). However, when I try to connect to it through a C# application via VISA API call. I'd get:
"VI_ERROR_TMO: A timeout occurred VISA error code -1073807339 (0xBFFF0015), ErrorTimeout".
The instrument has an VISA address: TCPIP0::10.12.177.59::4446:OCKET
Snippet of the C# code:
resourceString = "TCPIP0::10.12.177.59::4446:OCKET";
TcpipSocket tcpSock = (TcpipSocket)ResourceManager.GetLocalManager().Open(resourceString);
if (tcpSession != null)
string str = tcpSock.Query("*IDN?"); // I got timeout exception here
This code works for other instrument that uses the inst0 remote address type and TcpipSession. Only the TcpipSocket has issue here.
Thanks for your help.
Solved! Go to Solution.
The Knowledge Base article Why do I Receive Timeout Error -1073807339 on VISA Read or Write? may help you trouble shoot your issue, as it directly addresses the error code you are getting.
Based on the doc, The inquiry can be timed out. I found from the NI-VISA documentation, the default VI_ATTR_TMO_VALUE is set to 2000 msecs. The *IDN? query is short. I used the Agilent IO Suite app and I can get the instrument's ID back through *IDN? query in split second - as soon as I pushed the "Identify Instrument" button. The Agilent IO Suite provide space to enter the IP address of the instrument and SOCKET#. (please see attached screenshot) So I don't think it's the timeout value issue.
I also ran the NI-VISA sample code from my PC (ni4882273.exe) installation, the
..\National Instruments\NI-VISA\Examples\DotNET3.5\SimpleReadWrite\cs\SimpleReadWrite.2008.csproj sample app which allows me to use IP address and a socket to communicate to the remote instrument. The sample app also yielded the same timeout error as an exception (see attached screenshot). There seems to be a common issue here.
Using NI-SPY, I saw that the *IDN? message (msg#17) went out, viRead actually read back the instrument's identification (msg#18). The problem is that this viRead came back with "Timeout expired before operation completed." error code "0xBFFF0015 (VI_ERROR_TMO)" hence the error I'm seeing. Now the TMO_VALUE has been set to 20sec (20000) seen on msg#16. This didn't do the trick. In fact, the viRead msg came back within split of a second after the *IDN? viWrite (please see the time stamps on the NI-SPY trace attached). I'm not sure why viRead was timing out. Thanks for your help.
Which instrument are you using and how are you connecting to it?
Yes, the read operation was looking for the "\n" terminator that it didn't find and timed out. I've to change the VISA MessageBasedSession.TerminationCharacterEnabled = true and it works. Thanks.