Resizing the Formatted I/O Buffers

NI-VISA

Resizing the Formatted I/O Buffers

The read and write buffers, as mentioned previously, can be dynamically resized using the viSetBuf() operation. Remember that this operation automatically flushes the buffers, so it is best to set the size of the buffers before beginning the actual I/O calls. You specify which buffer you want to modify and then the size of the buffer you require. It is important to check the return code of this operation because you may be requesting a buffer beyond the size that the system can allocate at the time. If this occurs, the buffer size is not changed.

For example, to set both the read and write buffers to 8 KB, use the following code.

status = viSetBuf(instr, VI_READ_BUF | VI_WRITE_BUF, 8192);