VISA Library Terminator Character Issues

VISA XOP is an Igor plug-in that allows you to communicate with instruments using serial ports, GPIB ports, and ethernet. It requires installation of a VISA library such as NI-VISA.

When reading data, by default the VISA library stops reading when it encounters a terminator character. The terminator character defaults to linefeed (decimal value 10).

This may cause problems with the viRead function and the VISARead, VISAReadWave, VISAReadBinary, and VISAReadBinaryWave operations. Problems are most likely with the VISAReadBinary and VISAReadBinaryWave.

This default behavior causes a problem if you read binary data using VISAReadBinary or VISAReadBinaryWave. If the binary data happens to contain a byte with decimal value 10, the VISA library stops reading.

To fix this, you need to set two attributes, like this:

viSetAttribute(session, VI_ATTR_TERMCHAR_EN, 0)    // Disable terminator character detection
viSetAttribute(session, VI_ATTR_ASRL_END_IN, 0)    // Disable terminator character detection for serial ports

The VI_ATTR_TERMCHAR_EN attribute works for all types of I/O except for serial port I/O. The VI_ATTR_ASRL_END_IN attribute works for serial port I/O. This is explained at here - see "Termination Character Enabled" (VI_ATTR_TERMCHAR_EN) and "Serial End Modes for Reads" (VI_ATTR_ASRL_END_IN).

We recommending setting both of the attributes as shown above so that terminator character detection will be disabled regardless of the type of instrument you are communicating with.

This problem also affects the viRead function and the VISARead and VISAReadWave operations.
In the case of viRead, it always terminates on a terminator character unless you use the commands above to disable terminator character detection. If you intend to read a certain number of bytes regardless of what they might be, use the commands above.

In the case of VISARead and VISAReadWave, if you omit /T=termStr or specify something other than "" for termStr, these operations read bytes one-at-a-time and the VISA library treatment of terminator characters does not come into play. However, if you specify /T="", they read the number of bytes specified by /N=n in one call to the VISA library. In this case, the presence of a terminator character stops reading before n bytes have been read unless you set the attributes shown above. If you use /T="" with VISARead or VISAReadWave, use the commands above to disable terminator character detection.

I am attaching a new version of the "VISA XOP Help.ihf" file which includes discussion of these issues. This new version of the help file will ship with the next release of Igor Pro 8, whenever that occurs.

VISA XOP Help.ihf

Forum

Support

Gallery

Igor Pro 9

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More