| Using VISA.NET > Formatted I/O |
VISA.NET Formatted I/O automates the more difficult aspects of instrument I/O. When writing to an instrument, Formatted I/O makes it possible to easily send complete and correct instrument commands. When reading from an instrument, Formatted I/O makes it possible to easily read and parse complete responses. Formatted I/O performs the following functions:
You can access Formatted I/O via the& IMessageBasedSession.FormattedIO property, which is available from any message-based session. The FormattedIO property returns a reference to the interface IMessageBasedFormattedIO.
The Formatted I/O implementation used by Keysight VISA.NET is provided by the IVI Foundation and defined in the Ivi.Visa namespace. The Formatted I/O implementation delegates the actual device I/O to the Keysight Raw I/O, but handles all of the formatting and parsing itself. A standard Formatted I/O implementation facilitates the goal of having the details of formatting and parsing handled identically across different VISA.NET implementations.
Formatted I/O formatting and buffer management are highly optimized, so in most cases Formatted I/O performs as well as Raw I/O or better.
Note that VISA.NET implementations are allowed to create custom implementations of IMessageBasedFormattedIO, although this is not recommended by the IVI Foundation. If you need to write code that is portable to other VISA.NET implementations, never cast the IMessageBasedSession.FormattedIO property to the implementing class. In addition to the portability issues, IntelliSense for the IVI class is not as good as for the interface. Keysight VISA.NET does not have a custom implementation of IMessageBasedFormattedIO.