Recommendations for Using the VISA Buffers

NI-VISA 15.0 Help

Edition Date: June 2015

Part Number: 370131S-01

»View Product Info

Unless you are dealing with large buffers, it is usually unnecessary to call viSetBuf to adjust the size of the VISA buffers.

Because the low-level I/O transmit buffer is rarely used, there is seldom, if ever, a need to call viSetBuf with the VI_IO_OUT_BUF flag. Even in the case of serial resources, changing the low-level I/O transmit buffer size may have no effect.

In general, calling viFlush with the VI_IO_OUT_BUF or VI_IO_OUT_BUF_DISCARD flags has no effect.

If you need to call viFlush on the low-level I/O receive buffer, the data is always discarded, regardless of whether you specify VI_IO_IN_BUF or VI_IO_IN_BUF_DISCARD.

When using formatted I/O, use viClear to discard the formatted I/O buffers, when possible, instead of viFlush. This ensures that both the read and write formatted I/O buffers, as well as the device's internal buffers, are cleared. Calling just viFlush to discard the formatted I/O buffers may leave unread data on the device, which leaves the device in an unknown state. In other words, further calls to viPrintf or viScanf may return unpredictable results.

In cases when you need to push the remaining formatted I/O write buffer contents to the device, call viFlush with the VI_WRITE_BUF flag. The formatted I/O write buffer is automatically flushed under certain conditions. For details on these conditions, refer to Automatically Flushing the Formatted I/O Buffers.

Related Topics

Automatically Flushing the Formatted I/O Buffers

Formatted I/O Read and Low-Level I/O Receive Buffers

Formatted I/O Write and Low-Level I/O Transmit Buffers

Manually Flushing the Formatted I/O Buffers






Not Helpful