Interface IFormattedIO488

Description

The IFormattedIO488 interface provides basic formatted I/O functionality.  It is associated with the Basic Formatted I/O component.  You may find it easier to use your development environment's formatted I/O facilities, but using this component provides some advantages:

  • Transparent buffer management: The formatted I/O object manages the read and write buffers, hiding the complexity from the client.
  • Not affected by localization: Variants, the fundamental data type in a number of development environments, dynamically change the string-to-numeric and numeric-to-string conversion algorithms based on the locale of the system.  Since instruments always use a US English locale (radix 10, representing the fraction placeholder with a period '.' character, etc.), programs that use Variant formatted I/O without taking locale into account will work on some systems and fail on others.  The component that implements the IFormattedIO488 interface always performs US English conversions.
  • Same interface across development environments: Different development environments have different formatted I/O facilities.  If transfer of learning from one development environment to another is important to your project or company, you may find the IFormattedIO488 interface preferable to native formatted I/O facilities.
  • Designed for most common data formats in 488.2/SCPI instruments: The IFormattedIO488 interface is designed to work best with 488.2/SCPI-style instruments.  You may find the list and binary block facilities much more useful "out of the box" than the native formatted I/O facilities of your development environment.
  • Present in all VISA COM implementations: The Basic Formatted I/O component is a Global Shared Component owned by the VXIplug&play Systems Alliance.  All VISA COM I/O implementations will ship with this component.  If you cannot guarantee the presence of a vendor-specific formatted I/O facility, you may wish to use the native formatted I/O facilities of your development environment or to use this component.  You may find this interface the best way to communicate via COM with instruments for which there is no IVI driver. 

See Using Formatted I/O for information on using the Basic Formatted I/O Component and the IFormattedIO488 Interface.

Methods

WriteString

Appends a string to the formatted I/O object's write buffer.  If the flushAndEND parameter is true, the buffer will be flushed before this method returns.

WriteNumber

Appends a number (in ASCII string format) to the write buffer.  If the flushAndEND parameter is true, the buffer will be flushed before this method returns.

WriteList

Appends an array of arguments to the write buffer in an ASCII list format.  The WriteList method can force the elements to a particular data type. The list separator token defaults to the comma ',' character, but can be changed to another ASCII character.  If the flushAndEND parameter is true, the buffer will be flushed before this method returns.

WriteIEEEBlock

Appends an ASCII string followed by an IEEE 488.2 definite binary block to the write buffer.  If the flushAndEND parameter is true, the buffer will be flushed before this method returns.

ReadString

Reads from the read buffer until an end condition is reached (termination character, END signal, etc), and returns the data in a string.

ReadNumber

Reads from the read buffer, converting its contents into a numeric value, until an unparsable character is received or an end condition occurs.  If the flushToEND parameter is true, the method will discard all data in the I/O buffer and not return until an end condition occurs in the I/O stream.

ReadList

Reads from the read buffer until an end condition occurs, interpreting the data as an ASCII list of values.  The list elements are interpreted as and returned in the format specified by the type argument.  If the listSeparator argument is provided, it is interpreted as a list of one-character tokens, each treated as a separator.

ReadIEEEBlock

Reads an IEEE 488.2 Definite Binary Block from the read buffer.  If the seekToBlock argument is true, the method will look for the hash '#' character, the binary block header character, discarding data until it is found; otherwise it expects the hash to be the first character in the buffer.  If the flushToEND argument is true, the method will continue to read from the buffer after the IEEE Block, discarding the data, until an end condition is reached.  The data is interpreted and returned in the format specified by the type argument.

FlushWrite

Flushes the contents of the write buffer.  If the sendEND parameter is true, the method will also assert the end condition.  It is illegal to send an end on an empty buffer.

FlushRead

Flushes the contents of the read buffer until an end condition is reached.

SetBufferSize

Sets the size of the read, write, or both formatted I/O buffers.

Properties

IO

The VISA COM resource session.  This property must be set to begin using the IFormattedIO488 interface.  Setting this property again after it is first set causes the formatted I/O component to flush the buffers of the current VISA COM resource session attached to the I/O property and to attach the new session object.

InstrumentBigEndian

Affects the behavior of the Read/WriteIEEEBlock methods:These methods interpret the binary data as Big-Endian or Little-Endian based on this property.

See Also

Diagram of VISA COM Interfaces