Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Bad WriteString using VisaCom

Hello,

 

I have a problem to send a string buffer to an instrument using VisaCom library. The buffer is cutted and all the characters aren't sent. It seem to be cut when a CR char is encontred. With an old 32 bits library using ibwrt(Desc,buf), it is working fine. But now, i need to use a 64 bits library to compile my project in 64 bits.

 

Private ResMan As Ivi.Visa.Interop.ResourceManager

Private FIO As Ivi.Visa.Interop.FormattedIO488

Private CGPIB As Ivi.Visa.Interop.IGpib

ResMan = New Ivi.Visa.Interop.ResourceManager()

FIO = New Ivi.Visa.Interop.FormattedIO488

 

FIO.IO = CType(ResMan.Open("GPIB0::" & CStr(Adr), Ivi.Visa.Interop.AccessMode.NO_LOCK, 10000), Ivi.Visa.Interop.IMessage)

 

CGPIB = CType(FIO.IO, Ivi.Visa.Interop.IGpib)

 

FIO.WriteString("RCF" & Buf)

 

CGPIB.ControlREN(Ivi.Visa.Interop.RENControlConst.GPIB_REN_GTL)

 

The buffer length is 4096 characters and add to "RCF" string (4099 charracters). Only 12 characters are sent. I try to change some properties : buffer length, terminate character, ..

but nothing works.

Is there a bug in this function ?

 

Regards

 

 

0 Kudos
Message 1 of 3
(2,058 Views)

Hello)

If the problem still exist, I'll suggest you another method for communicating with your instruments using formatted I/O functions is using the formatted I/O buffer functions:

viSPrintf().viSScanf(), viBufRead(), and viBufWrite(). You can use these functions to manipulate a buffer that you will send or receive from an instrument.
For example, you may want to bring information from a device into a buffer and then manipulate it yourself. To do this, first call viBufRead(), which reads the string from the instrument into a user-specified buffer. Then use viSScanf() to extract information from the buffer. Similarly, you can format a buffer with viSPrintf() and then use viBufWrite() to send it to an instrument.
As you can see, the formatted I/O approach is the simplest way to get the job done. Because of the variety of modifiers you can use in the format string, this section does not go into any more detail on these operations.
Please refer either to the NI-VISA online help or to Chapter 5, Operations,
in the NI-VISA Programmer Reference Manual for more information.

 

Regards,

Meri

0 Kudos
Message 2 of 3
(1,817 Views)

If the problem still exist, I'll suggest you another method for communicating with your instruments using formatted I/O functions is using the formatted I/O buffer functions:

viSPrintf().viSScanf(), viBufRead(), and viBufWrite(). You can use these functions to manipulate a buffer that you will send or receive from an instrument.


I don't think there is any difference between viWrite and viBufWrite (as well as between viRead and viBufRead) regarding the handling of termination characters, at least I'm not aware of and the dll manual does not tell otherwise (www.ni.com/pdf/manuals/370132c.pdf). Anyway for Gpib the termination characters are not used in the default Visa configuration (the EOI line asserted with the last data byte is used to terminate transfers) so it should not matter whether buffered or non-buffered IO is used. But all this is for the good old Visa shared library (Visa32.dll, Visa64.dll), the COM version may have changed things (although it should essentially be a COM wrapper around the old library ?) but I couldn't find the full documentation of the WriteString function. BTW. I already noticed that some people complain about reliability problems with Visa-COM and prefer to directly interface to these old-style dlls  (like me).

0 Kudos
Message 3 of 3
(1,800 Views)