viFlush
Syntax
viFlush(ViSession vi, ViUInt16 mask);
Description
Manually flush the specified buffers associated with formatted I/O operations and/or serial communication. The values for the mask parameter are:
Mask Values |
Interpretation |
---|---|
VI_IO_IN_BUF |
Discard receive buffer contents (same as VI_IO_IN_BUF_DISCARD). |
VI_IO_IN_BUF_DISCARD |
Discard receive buffer contents (does not perform an I/O to the device). |
VI_IO_OUT_BUF |
Flush the transmit buffer by writing all buffered data to the device. |
VI_IO_OUT_BUF_DISCARD |
Discard transmit buffer contents (does not perform any I/O to the device). |
VI_READ_BUF |
Discard the read buffer contents and, if data was present in the read buffer and no END-indicator was present, read from the device until encountering an END indicator (which causes the loss of data). This action resynchronizes the next viScanf call to read a <TERMINATED RESPONSE MESSAGE>. (See the IEEE 488.2 standard.) |
VI_READ_BUF_DISCARD |
Discard read buffer contents (does not perform any I/O to the device). |
VI_WRITE_BUF |
Flush the write buffer by writing all buffered data to the device. |
VI_WRITE_BUF_DISCARD |
Discard write buffer contents (does not perform any I/O to the device). |
It is possible to combine any of these read flags and write flags for different buffers by ORing the flags. However, combining two flags for the same buffer in the same call to viFlush is illegal.
When using formatted I/O operations with a serial device, a flush of the formatted I/O buffers also causes the corresponding serial communication buffers to be flushed.
For example, calling viFlush with VI_WRITE_BUF also flushes the VI_IO_OUT_BUF. For backward compatibility, VI_IO_IN_BUF is the same as VI_ASRL_IN_BUF, VI_IO_IN_BUF_DISCARD is the same as VI_ASRL_IN_BUF_DISCARD, VI_IO_OUT_BUF is the same as VI_ASRL_OUT_BUF, and VI_IO_OUT_BUF_DISCARD is the same as VI_ASRL_OUT_BUF_DISCARD.
Parameters
Name |
Dir |
Type |
Description |
---|---|---|---|
vi |
IN |
ViSession |
Unique logical identifier to a session. |
mask |
IN |
ViUInt16 |
Specifies the action to be taken with flushing the buffer. (See the "Description" section for details.) |
Return Values
Type ViStatus |
This is the function return status. It returns either a completion code or an error code as follows. |
Completion Code |
Description |
---|---|
VI_SUCCESS |
Buffers flushed successfully. |
Error Code |
Description |
VI_ERROR_INV_MASK |
The specified mask does not specify a valid flush function on read/write resource. |
VI_ERROR_INV_SESSION |
The given session or object reference is invalid (both are the same value). |
VI_ERROR_IO |
Could not perform read/write function because of I/O error. |
VI_ERROR_RSRC_LOCKED |
Specified operation could not be performed because the resource identified by vi has been locked for this kind of access. |
VI_ERROR_TMO |
The read/write function was aborted because timeout expired while function was in progress. |