viReadSTB

NI-VISA

viReadSTB

Purpose

Reads a status byte of the service request.

C Syntax

ViStatus viReadSTB(ViSession vi, ViPUInt16 status)

Visual Basic Syntax

viReadSTB&(ByVal vi&, status%)

Resource Classes

GPIB INSTR, GPIB-VXI INSTR, Serial INSTR, TCPIP INSTR, TCPIP SOCKET, USB INSTR, USB RAW, VXI INSTR

Parameters

Name Direction Description

vi

IN

Unique logical identifier to a session.

status

OUT

Service request status byte.

Return Values

Completion Codes Description

VI_SUCCESS

The operation completed successfully.

 

Error Codes Description

VI_ERROR_INV_OBJECT

The given session reference is invalid.

VI_ERROR_NSUP_OPER

The given vi does not support this operation.

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_SRQ_NOCCURRED

Service request has not been received for the session.

VI_ERROR_TMO

Timeout expired before operation completed.

VI_ERROR_RAW_WR_PROT_VIOL

Violation of raw write protocol occurred during transfer.

VI_ERROR_RAW_RD_PROT_VIOL

Violation of raw read protocol occurred during transfer.

VI_ERROR_BERR

Bus error occurred during transfer.

VI_ERROR_NCIC

The interface associated with the given vi is not currently the controller in charge.

VI_ERROR_NLISTENERS

No-listeners condition is detected (both NRFD and NDAC are unasserted).

VI_ERROR_INV_SETUP

Unable to start operation because setup is invalid (due to attributes being set to an inconsistent state).

VI_ERROR_CONN_LOST

The I/O connection for the given session has been lost.

Description

Status Bytes for 488.2 Instruments (GPIB, VXI, TCPIP, and USB)

This operation reads a service request status from a message-based device. The bus-specific details are:

  • For a GPIB device, the status is read by serial polling the device.
  • For a VXI device, VISA sends the Word Serial Read STB query.
  • For a USB device, this function sends the READ_STATUS_BYTE command on the control pipe.

Status Bytes for Non-488.2 Instruments (Serial INSTR, TCPIP SOCKET, and USB RAW)

A message is sent in response to a service request to retrieve status information. If VI_ATTR_IO_PROT is VI_PROT_4882_STRS, the device is sent the string "*STB?\n", and then the device's status byte is read; otherwise, this operation is not valid.

Although the status output is a 16-bit value, the upper 8 bits are always 0. The lower 8 bits contain the actual status byte. For 488.2 instruments, this is the 488.2-defined status byte.

The IEEE 488.2 standard defines several bit assignments in the status byte. For example, if bit 6 of the status is set, the device is requesting service. In addition to setting bit 6 when requesting service, 488.2 devices also use two other bits to specify their status. Bit 4, the Message Available bit (MAV), is set when the device is ready to send previously queried data. Bit 5, the Event Status bit (ESB), is set if one or more of the enabled 488.2 events occurs. These events include power-on, user request, command error, execution error, device dependent error, query error, request control, and operation complete. The device can assert SRQ when ESB or MAV are set, or when a manufacturer-defined condition occurs. Manufacturers of 488.2 devices use the remaining lower-order bits to communicate the reason for the service request or to summarize the device state.

Related Topics

INSTR Resource

SOCKET Resource

VI_ATTR_IO_PROT

VI_EVENT_SERVICE_REQ