viSetBuf

NI-VISA 15.0 Help

Edition Date: June 2015

Part Number: 370131S-01

»View Product Info

Purpose

Sets the size for the formatted I/O and/or low-level I/O communication buffer(s).

C Syntax

ViStatus viSetBuf(ViSession vi, ViUInt16 mask, ViUInt32 size)

Visual Basic Syntax

viSetBuf&(ByVal vi&, ByVal mask%, ByVal size&)

Resource Classes

GPIB INSTR, GPIB INTFC, Serial INSTR, TCPIP INSTR, TCPIP SOCKET, VXI INSTR, VXI SERVANT

Parameters

Name Direction Description

vi

IN

Unique logical identifier to a session.

mask

IN

Specifies the type of buffer.

size

IN

The size to be set for the specified buffer(s).

Return Values

Completion Codes Description

VI_SUCCESS

Buffer size set successfully.

VI_WARN_NSUP_BUF

The specified buffer is not supported.

Error Codes Description

VI_ERROR_INV_OBJECT

The given session reference is invalid.

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_ALLOC

The system could not allocate the buffer(s) of the specified size because of insufficient resources.

VI_ERROR_INV_MASK

The system cannot set the buffer for the given mask.

Description

The viSetBuf() operation changes the buffer size of the read and/or write buffer for formatted I/O and/or serial communication. The mask parameter specifies the buffer for which to set the size. The mask parameter can specify multiple buffers by bit-ORing any of the following values together.

Flags Interpretation

VI_READ_BUF (1)

Formatted I/O read buffer.

VI_WRITE_BUF (2)

Formatted I/O write buffer.

VI_IO_IN_BUF (16)

Low-level I/O receive buffer.

VI_IO_OUT_BUF (32)

Low-level I/O transmit buffer.

A call to viSetBuf() flushes the session's related Read/Write buffer(s). Although you can explicitly flush the buffers by making a call to viFlush(), the buffers are flushed implicitly under some conditions. These conditions vary for the viPrintf() and viScanf() operations.

Since not all serial drivers support user-defined buffer sizes, it is possible that a specific implementation of VISA may not be able to control this feature. If an application requires a specific buffer size for performance reasons, but a specific implementation of VISA cannot guarantee that size, then it is recommended to use some form of handshaking to prevent overflow conditions.

In previous versions of VISA, VI_IO_IN_BUF was known as VI_ASRL_IN_BUF and VI_IO_OUT_BUF was known as VI_ASRL_OUT_BUF.


Related Topics

Automatically Flushing the Formatted I/O Buffers

Controlling the Serial 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

INSTR Resource

INTFC Resource

Manually Flushing the Formatted I/O Buffers

Recommendations for Using the VISA Buffers

SERVANT Resource

SOCKET Resource

VI_ATTR_RD_BUF_SIZE

VI_ATTR_WR_BUF_SIZE

viFlush

viPrintf

viScanf

WAS THIS ARTICLE HELPFUL?

Not Helpful