Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Read (Error BFF0015)

Solved!
Go to solution

Hello all,

 

I am using VISA COM library and C# to communication with my instrument via TCPIP.

I add referrence "VISA COM 3.0 Library Type" to my C# project and try to establish the communication by using the following codes:

 

*********************************

Ivi.Visa.Interop.ResourceManager ResMsg = new Ivi.Visa.Interop.ResourceManager();
Ivi.Visa.Interop.FormattedIO488Class ioClass = new Ivi.Visa.Interop.FormattedIO488Class();

Ivi.Visa.Interop.IMessage Imsg = (ResMsg.Open("TCPIP0::192.168.0.170::10001::SOCKET", Ivi.Visa.Interop.AccessMode.NO_LOCK, 8000, "") as IMessage);
ioClass.IO = Imsg;

 

ioClass.WriteString("*RST", true);

ioClass.WriteString("*IDN?", true);

String ret = ioClass.ReadString();

 

Console.WriteLine("ID: " + ret);

**********************************

 

I could write "*RST" command to the device without errors. And I could see the device really performed a reset by the command.

But when I send "*IDN?" and read the response, I always get a TIME_OUT error. Even though I add "\r\n" at the end of the command and increase the timeout value, I still can the same error. Not only "*IDN?" but also other read command like "*STB?", they all can the same timeout error.

But when I use the VISA-ReadSTB function, it returns the correct data.

I also tried to use Labview VISA-Open, VISA-Write, VISA-Read to do the same test. I also get a error (BFF0015) after VISA-Read.

I also use a IO Monitor programm to see the data. I find out that I could see the response but still I got a timeout error. Currently I could only successfully read the response by Agilent IO control.

 

I am using C# 2008, Labview 8.2.1, VISA 5.0.3,

 

 

Any advice will be really appreciated!

 

Regards,

 

 

 

 

 

 

 

 

 

 

 

0 Kudos
Message 1 of 4
(6,538 Views)
Solution
Accepted by topic author 0049

Please have a look at this KB. Maybe this can help you to fix your problem.

 

Why do I Receive Timeout Error -1073807339 on VISA Read or Write?

http://digital.ni.com/public.nsf/allkb/874B379E24C0A0D686256FCF007A6EA0?OpenDocument

 

Cheers

0 Kudos
Message 2 of 4
(6,523 Views)

When using TCP/IP SOCKET resource, you need:

(1)explicitly add an LF character ("\n") for each command string

(2)set TerminationCharacterEnabled property to TRUE

 

0 Kudos
Message 3 of 4
(6,516 Views)

Thanks!

 

I've found the error. The trick is I have to set the BytesToRead to a proper value. Unlike RS232, there is no BytesAtPort property for TCP/IP Socket. So I need to read byte by byte until I read "\n".Otherwise, I have to know in advance how many bytes I expected and set the proper timeout value to get all the bytes before timeout.

 

Regards,

0 Kudos
Message 4 of 4
(6,512 Views)