| Using VISA.NET > Formatted I/O > Buffering I/O |
When you use Raw I/O for message-based sessions, there is no message buffering in the VISA.NET layer. The Raw I/O Read method reads characters into the buffer output parameter until a specified number of characters is read or an end is received. The Raw I/O Write method writes the contents of the buffer parameter to the instrument immediately. In both cases, your program is responsible for understanding or formatting the content of the buffer parameter.
In contrast, when sending and receiving messages from an instrument, Formatted I/O methods use special Formatted I/O buffers that are managed by the VISA.NET Formatted I/O implementation.
Formatted I/O Write and Printf methods place output data in the output buffer until it is flushed, at which time the data in the buffer is sent to the instrument. If the buffer fills before it is explicitly flushed (for example, when the program is sending a large data array to the instrument), Formatted I/O sends the buffer to the instrument, clears it, and starts filling it again, until an explicit flush is indicated.
Formatted I/O Read and Scanf methods read characters into the input buffer until the buffer is full or an end is received, and then consume the buffer as the input is parsed and returned. If the buffer fills before an end is received, Formatted I/O waits until the buffer has been processed, empties it, and then reads again until the buffer is full or an end is received, and so on.
Formatted I/O buffering makes it possible to easily create complete instrument commands and to identify and process complete responses without having to manage the equivalent buffering functionality in the client program.
![]() |
Because Formatted I/O maintains its own buffers while delegating I/O to Raw I/O, trying to use both Formatted I/O and Raw I/O at the same time to communicate with an instrument will almost certainly result in errors or wrong results. Use one or the other. |