Controlling the Serial I/O Buffers
- Updated2025-01-24
- 2 minute(s) read
Controlling the Serial I/O Buffers
The viFlush() and viSetBuf() operations also provide a control mechanism for the low-level serial driver buffers. The default size of these buffers is 0, which guarantees that all I/O is flushed on every access. To improve performance, you can alter the size of the low-level I/O transmit buffer or low-level I/O receive buffer by invoking the viSetBuf() operation with the VI_IO_OUT_BUF or VI_IO_IN_BUF flag, respectively. When the buffer size is non-zero, I/O to serial devices is not automatically flushed. You can force the low-level I/O transmit buffer to be flushed by invoking the viFlush() operation with VI_IO_OUT_BUF. Alternatively, you can call viFlush() with VI_IO_OUT_BUF_DISCARD to empty the low-level I/O transmit buffer without sending any remaining data to the device. You can also call viFlush() with either VI_IO_IN_BUF or VI_IO_IN_BUF_DISCARD to empty the low-level I/O receive buffer (both flags have the same effect and are provided only for API consistency).
When using formatted I/O in conjunction with serial devices, calling viFlush() on a formatted I/O buffer has the same effect on the corresponding serial buffer. For example, invoking viFlush() with VI_WRITE_BUF flushes the formatted I/O output buffer first, and then the low-level I/O transmit buffer. Similarly, VI_WRITE_BUF_DISCARD empties the contents of both the formatted I/O and low-level I/O transmit buffers.