Resource classes

Resources are high level abstractions to managing specific sessions. An instance of one of these classes is returned by the open_resource() depending on the resource type.

class pyvisa.resources.SerialInstrument(*args, **kwargs)[source]

Communicates with devices of type ASRL<board>[::INSTR]

Do not instantiate directly, use pyvisa.highlevel.ResourceManager.open_resource().

CR = u'\r'
LF = u'\n'
allow_dma
This attribute specifies whether I/O accesses should use DMA (VI_TRUE)
or Programmed I/O (VI_FALSE). In some implementations, this attribute may have global effects even though it is documented to be a local attribute. Since this affects performance and not functionality, that behavior is acceptable.
VISA Attribute:VI_ATTR_DMA_ALLOW_EN (1073676318)
Type:bool
allow_transmit
If set to VI_FALSE, it suspends transmission as if an XOFF character
has been received. If set to VI_TRUE, it resumes transmission as if an XON character has been received.
VISA Attribute:VI_ATTR_ASRL_ALLOW_TRANSMIT (1073676734)
Type:bool
assert_trigger()

Sends a software trigger to the device.

baud_rate
VI_ATTR_ASRL_BAUD is the baud rate of the interface. It is represented
as an unsigned 32-bit integer so that any baud rate can be used, but it usually requires a commonly used rate such as 300, 1200, 2400, or 9600 baud.
VISA Attribute:VI_ATTR_ASRL_BAUD (1073676321)
Type:int
Range:0 <= value <= 4294967295
before_close()

Called just before closing an instrument.

break_length
This controls the duration (in milliseconds) of the break signal
asserted when VI_ATTR_ASRL_END_OUT is set to VI_ASRL_END_BREAK. If you want to control the assertion state and length of a break signal manually, use the VI_ATTR_ASRL_BREAK_STATE attribute instead.
VISA Attribute:VI_ATTR_ASRL_BREAK_LEN (1073676733)
Type:int
Range:-32768 <= value <= 32767
break_state
If set to VI_STATE_ASSERTED, it suspends character transmission and
places the transmission line in a break state until this attribute is reset to VI_STATE_UNASSERTED. This attribute lets you manually control the assertion state and length of a break signal. If you want VISA to send a break signal after each write operation automatically, use the VI_ATTR_ASRL_BREAK_LEN and VI_ATTR_ASRL_END_OUT attributes instead.
VISA Attribute:VI_ATTR_ASRL_BREAK_STATE (1073676732)
Type::class:pyvisa.constants.LineState
bytes_in_buffer
VI_ATTR_ASRL_AVAIL_NUM shows the number of bytes available in the low-
level I/O receive buffer.
VISA Attribute:VI_ATTR_ASRL_AVAIL_NUM (1073676460)
Type:int
Range:0 <= value <= 4294967295
chunk_size = 20480
clear()

Clears this resource

close()

Closes the VISA session and marks the handle as invalid.

data_bits
VI_ATTR_ASRL_DATA_BITS is the number of data bits contained in each
frame (from 5 to 8). The data bits for each frame are located in the low-order bits of every byte stored in memory.
VISA Attribute:VI_ATTR_ASRL_DATA_BITS (1073676322)
Type:int
Range:5 <= value <= 8
discard_null
If set to VI_TRUE, NUL characters are discarded. Otherwise, they are
treated as normal data characters. For binary transfers, set this attribute to VI_FALSE.
VISA Attribute:VI_ATTR_ASRL_DISCARD_NULL (1073676464)
Type:bool
encoding

Encoding used for read and write operations.

end_input
VI_ATTR_ASRL_END_IN indicates the method used to terminate read
operations.
VISA Attribute:VI_ATTR_ASRL_END_IN (1073676467)
Type::class:pyvisa.constants.SerialTermination
flush(mask)[source]

Manually clears the specified buffers and cause the buffer data to be written to the device.

Parameters:mask – Specifies the action to be taken with flushing the buffer. (Constants.READ*, .WRITE*, .IO*)
get_visa_attribute(name)

Retrieves the state of an attribute in this resource.

Parameters:name – Resource attribute for which the state query is made (see Attributes.*)
Returns:The state of the queried attribute for a specified resource.
Return type:unicode (Py2) or str (Py3), list or other type
implementation_version
VI_ATTR_RSRC_IMPL_VERSION is the resource version that uniquely identifies
each of the different revisions or implementations of a resource. This attribute value is defined by the individual manufacturer and increments with each new revision. The format of the value has the upper 12 bits as the major number of the version, the next lower 12 bits as the minor number of the version, and the lowest 8 bits as the sub-minor number of the version.
VISA Attribute:VI_ATTR_RSRC_IMPL_VERSION (1073676291)
Type:int
Range:0 <= value <= 4294967295
install_handler(event_type, handler, user_handle=None)

Installs handlers for event callbacks in this resource.

Parameters:
  • event_type – Logical event identifier.
  • handler – Interpreted as a valid reference to a handler to be installed by a client application.
  • user_handle – A value specified by an application that can be used for identifying handlers uniquely for an event type.
Returns:

user handle (a ctypes object)

interface_number

VI_ATTR_INTF_NUM specifies the board number for the given interface.

VISA Attribute:VI_ATTR_INTF_NUM (1073676662)
Type:int
Range:0 <= value <= 65535
interface_type

The interface type of the resource as a number.

io_protocol
VI_ATTR_IO_PROT specifies which protocol to use. In VXI, you can
choose normal word serial or fast data channel (FDC). In GPIB, you can choose normal or high-speed (HS-488) transfers. In serial, TCPIP, or USB RAW, you can choose normal transfers or 488.2-defined strings. In USB INSTR, you can choose normal or vendor-specific transfers.
VISA Attribute:VI_ATTR_IO_PROT (1073676316)
Type:int
Range:0 <= value <= 65535
last_status

Last status code for this session.

Return type:pyvisa.constants.StatusCode
lock(timeout=None, requested_key=None)

Establish a shared lock to the resource.

Parameters:
  • timeout – Absolute time period (in milliseconds) that a resource waits to get unlocked by the locking session before returning an error. (Defaults to self.timeout)
  • requested_key – Access key used by another session with which you want your session to share a lock or None to generate a new shared access key.
Returns:

A new shared access key if requested_key is None, otherwise, same value as the requested_key

lock_state
VI_ATTR_RSRC_LOCK_STATE indicates the current locking state of the
resource. The resource can be unlocked, locked with an exclusive lock, or locked with a shared lock.
VISA Attribute:VI_ATTR_RSRC_LOCK_STATE (1073676292)
Type::class:pyvisa.constants.AccessModes
open(access_mode=<AccessModes.no_lock: 0>, open_timeout=5000)

Opens a session to the specified resource.

Parameters:
  • access_mode (pyvisa.constants.AccessModes) – Specifies the mode by which the resource is to be accessed.
  • open_timeout (int) – Milliseconds before the open operation times out.
parity
VI_ATTR_ASRL_PARITY is the parity used with every frame transmitted
and received.
VISA Attribute:VI_ATTR_ASRL_PARITY (1073676323)
Type::class:pyvisa.constants.Parity
query(message, delay=None)

A combination of write(message) and read()

Parameters:
  • message (str) – the message to send.
  • delay – delay in seconds between write and read operations. if None, defaults to self.query_delay
Returns:

the answer from the device.

Return type:

str

query_ascii_values(message, converter=u'f', separator=u', ', container=<type 'list'>, delay=None)

Query the device for values in ascii format returning an iterable of values.

Parameters:
  • message (str) – the message to send.
  • delay – delay in seconds between write and read operations. if None, defaults to self.query_delay
  • converter (callable) – function used to convert each element. Defaults to float
  • separator – a callable that split the str into individual elements. If a str is given, data.split(separator) is used.
  • container – container type to use for the output data.
Type:

separator: (str) -> collections.Iterable[int] | str

Returns:

the answer from the device.

Return type:

list

query_binary_values(message, datatype=u'f', is_big_endian=False, container=<type 'list'>, delay=None)

Converts an iterable of numbers into a block of data in the ieee format.

Parameters:
  • message – the message to send to the instrument.
  • datatype – the format string for a single element. See struct module.
  • is_big_endian – boolean indicating endianess. Defaults to False.
  • container – container type to use for the output data.
  • delay – delay in seconds between write and read operations. if None, defaults to self.query_delay
Return type:

bytes

query_delay = 0.0
query_values(message, delay=None)

Query the device for values returning an iterable of values.

The datatype expected is obtained from values_format

Parameters:
  • message (str) – the message to send.
  • delay – delay in seconds between write and read operations. if None, defaults to self.query_delay
Returns:

the answer from the device.

Return type:

list

read(termination=None, encoding=None)

Read a string from the device.

Reading stops when the device stops sending (e.g. by setting appropriate bus lines), or the termination characters sequence was detected. Attention: Only the last character of the termination characters is really used to stop reading, however, the whole sequence is compared to the ending of the read string message. If they don’t match, a warning is issued.

All line-ending characters are stripped from the end of the string.

Return type:str
read_raw(size=None)

Read the unmodified string sent from the instrument to the computer.

In contrast to read(), no termination characters are stripped.

Return type:bytes
read_stb()

Service request status register.

read_termination

Read termination character.

read_termination_context(*args, **kwds)
read_values(fmt=None, container=<type 'list'>)

Read a list of floating point values from the device.

Parameters:
  • fmt – the format of the values. If given, it overrides the class attribute “values_format”. Possible values are bitwise disjunctions of the above constants ascii, single, double, and big_endian. Default is ascii.
  • container – the output datatype
Returns:

the list of read values

Return type:

list

register(interface_type, resource_class)
replace_char
VI_ATTR_ASRL_REPLACE_CHAR specifies the character to be used to
replace incoming characters that arrive with errors (such as parity error).
VISA Attribute:VI_ATTR_ASRL_REPLACE_CHAR (1073676478)
Type:int
Range:0 <= value <= 255
resource_class
VI_ATTR_RSRC_CLASS specifies the resource class (for example, “INSTR”)
as defined by the canonical resource name.
VISA Attribute:VI_ATTR_RSRC_CLASS (3221159937)
resource_info

Get the extended information of this resource.

Parameters:resource_name – Unique symbolic name of a resource.
Return type:pyvisa.highlevel.ResourceInfo
resource_manufacturer_name
VI_ATTR_RSRC_MANF_NAME is a string that corresponds to the manufacturer

name of the vendor that implemented the VISA library. This attribute is not related to the device manufacturer attributes.

Note The value of this attribute is for display purposes only and not for programmatic decisions, as the value can differ between VISA implementations and/or revisions.

VISA Attribute:VI_ATTR_RSRC_MANF_NAME (3221160308)
resource_name
VI_ATTR_RSRC_MANF_NAME is a string that corresponds to the manufacturer

name of the vendor that implemented the VISA library. This attribute is not related to the device manufacturer attributes.

Note The value of this attribute is for display purposes only and not for programmatic decisions, as the value can differ between VISA implementations and/or revisions.

VISA Attribute:VI_ATTR_RSRC_NAME (3221159938)
send_end
VI_ATTR_SEND_END_EN specifies whether to assert END during the
transfer of the last byte of the buffer.
VISA Attribute:VI_ATTR_SEND_END_EN (1073676310)
Type:bool
session

Resource session handle.

Raises:pyvisa.errors.InvalidSession if session is closed.
set_visa_attribute(name, state)

Sets the state of an attribute.

Parameters:
  • name – Attribute for which the state is to be modified. (Attributes.*)
  • state – The state of the attribute to be set for the specified object.
spec_version
VI_ATTR_RSRC_SPEC_VERSION is the resource version that uniquely identifies
the version of the VISA specification to which the implementation is compliant. The format of the value has the upper 12 bits as the major number of the version, the next lower 12 bits as the minor number of the version, and the lowest 8 bits as the sub-minor number of the version. The current VISA specification defines the value to be 00300000h.
VISA Attribute:VI_ATTR_RSRC_SPEC_VERSION (1073676656)
Type:int
Range:0 <= value <= 4294967295
stb

Service request status register.

stop_bits
VI_ATTR_ASRL_STOP_BITS is the number of stop bits used to indicate the
end of a frame. The value VI_ASRL_STOP_ONE5 indicates one-and-one- half (1.5) stop bits.
VISA Attribute:VI_ATTR_ASRL_STOP_BITS (1073676324)
Type::class:pyvisa.constants.StopBits
timeout

The timeout in milliseconds for all resource I/O operations.

None is mapped to VI_TMO_INFINITE. A value less than 1 is mapped to VI_TMO_IMMEDIATE.

uninstall_handler(event_type, handler, user_handle=None)

Uninstalls handlers for events in this resource.

Parameters:
  • event_type – Logical event identifier.
  • handler – Interpreted as a valid reference to a handler to be uninstalled by a client application.
  • user_handle – A value specified by an application that can be used for identifying handlers uniquely in a session for an event.
unlock()

Relinquishes a lock for the specified resource.

values_format
write(message, termination=None, encoding=None)

Write a string message to the device.

The write_termination is always appended to it.

Parameters:message (unicode (Py2) or str (Py3)) – the message to be sent.
Returns:number of bytes written.
Return type:int
write_ascii_values(message, values, converter=u'f', separator=u', ', termination=None, encoding=None)

Write a string message to the device followed by values in ascii format.

The write_termination is always appended to it.

Parameters:
  • message (unicode (Py2) or str (Py3)) – the message to be sent.
  • values – data to be writen to the device.
  • converter (callable | str) – function used to convert each value. String formatting codes are also accepted. Defaults to str.
  • separator – a callable that split the str into individual elements. If a str is given, data.split(separator) is used.
Type:

separator: (collections.Iterable[T]) -> str | str

Returns:

number of bytes written.

Return type:

int

write_binary_values(message, values, datatype=u'f', is_big_endian=False, termination=None, encoding=None)

Write a string message to the device followed by values in binary format.

The write_termination is always appended to it.

Parameters:
  • message (unicode (Py2) or str (Py3)) – the message to be sent.
  • values – data to be writen to the device.
  • datatype – the format string for a single element. See struct module.
  • is_big_endian – boolean indicating endianess.
Returns:

number of bytes written.

Return type:

int

write_raw(message)

Write a byte message to the device.

Parameters:message (bytes) – the message to be sent.
Returns:number of bytes written.
Return type:int
write_termination

Writer termination character.

write_values(message, values, termination=None, encoding=None)
xoff_char
VI_ATTR_ASRL_XOFF_CHAR specifies the value of the XOFF character used
for XON/XOFF flow control (both directions). If XON/XOFF flow control (software handshaking) is not being used, the value of this attribute is ignored.
VISA Attribute:VI_ATTR_ASRL_XOFF_CHAR (1073676482)
Type:int
Range:0 <= value <= 255
xon_char
VI_ATTR_ASRL_XON_CHAR specifies the value of the XON character used
for XON/XOFF flow control (both directions). If XON/XOFF flow control (software handshaking) is not being used, the value of this attribute is ignored.
VISA Attribute:VI_ATTR_ASRL_XON_CHAR (1073676481)
Type:int
Range:0 <= value <= 255
class pyvisa.resources.TCPIPInstrument(*args, **kwargs)[source]

Communicates with to devices of type TCPIP::host address[::INSTR]

More complex resource names can be specified with the following grammar:
TCPIP[board]::host address[::LAN device name][::INSTR]

Do not instantiate directly, use pyvisa.highlevel.ResourceManager.open_resource().

CR = u'\r'
LF = u'\n'
allow_dma
This attribute specifies whether I/O accesses should use DMA (VI_TRUE)
or Programmed I/O (VI_FALSE). In some implementations, this attribute may have global effects even though it is documented to be a local attribute. Since this affects performance and not functionality, that behavior is acceptable.
VISA Attribute:VI_ATTR_DMA_ALLOW_EN (1073676318)
Type:bool
assert_trigger()

Sends a software trigger to the device.

before_close()

Called just before closing an instrument.

chunk_size = 20480
clear()

Clears this resource

close()

Closes the VISA session and marks the handle as invalid.

encoding

Encoding used for read and write operations.

get_visa_attribute(name)

Retrieves the state of an attribute in this resource.

Parameters:name – Resource attribute for which the state query is made (see Attributes.*)
Returns:The state of the queried attribute for a specified resource.
Return type:unicode (Py2) or str (Py3), list or other type
implementation_version
VI_ATTR_RSRC_IMPL_VERSION is the resource version that uniquely identifies
each of the different revisions or implementations of a resource. This attribute value is defined by the individual manufacturer and increments with each new revision. The format of the value has the upper 12 bits as the major number of the version, the next lower 12 bits as the minor number of the version, and the lowest 8 bits as the sub-minor number of the version.
VISA Attribute:VI_ATTR_RSRC_IMPL_VERSION (1073676291)
Type:int
Range:0 <= value <= 4294967295
install_handler(event_type, handler, user_handle=None)

Installs handlers for event callbacks in this resource.

Parameters:
  • event_type – Logical event identifier.
  • handler – Interpreted as a valid reference to a handler to be installed by a client application.
  • user_handle – A value specified by an application that can be used for identifying handlers uniquely for an event type.
Returns:

user handle (a ctypes object)

interface_number

VI_ATTR_INTF_NUM specifies the board number for the given interface.

VISA Attribute:VI_ATTR_INTF_NUM (1073676662)
Type:int
Range:0 <= value <= 65535
interface_type

The interface type of the resource as a number.

last_status

Last status code for this session.

Return type:pyvisa.constants.StatusCode
lock(timeout=None, requested_key=None)

Establish a shared lock to the resource.

Parameters:
  • timeout – Absolute time period (in milliseconds) that a resource waits to get unlocked by the locking session before returning an error. (Defaults to self.timeout)
  • requested_key – Access key used by another session with which you want your session to share a lock or None to generate a new shared access key.
Returns:

A new shared access key if requested_key is None, otherwise, same value as the requested_key

lock_state
VI_ATTR_RSRC_LOCK_STATE indicates the current locking state of the
resource. The resource can be unlocked, locked with an exclusive lock, or locked with a shared lock.
VISA Attribute:VI_ATTR_RSRC_LOCK_STATE (1073676292)
Type::class:pyvisa.constants.AccessModes
open(access_mode=<AccessModes.no_lock: 0>, open_timeout=5000)

Opens a session to the specified resource.

Parameters:
  • access_mode (pyvisa.constants.AccessModes) – Specifies the mode by which the resource is to be accessed.
  • open_timeout (int) – Milliseconds before the open operation times out.
query(message, delay=None)

A combination of write(message) and read()

Parameters:
  • message (str) – the message to send.
  • delay – delay in seconds between write and read operations. if None, defaults to self.query_delay
Returns:

the answer from the device.

Return type:

str

query_ascii_values(message, converter=u'f', separator=u', ', container=<type 'list'>, delay=None)

Query the device for values in ascii format returning an iterable of values.

Parameters:
  • message (str) – the message to send.
  • delay – delay in seconds between write and read operations. if None, defaults to self.query_delay
  • converter (callable) – function used to convert each element. Defaults to float
  • separator – a callable that split the str into individual elements. If a str is given, data.split(separator) is used.
  • container – container type to use for the output data.
Type:

separator: (str) -> collections.Iterable[int] | str

Returns:

the answer from the device.

Return type:

list

query_binary_values(message, datatype=u'f', is_big_endian=False, container=<type 'list'>, delay=None)

Converts an iterable of numbers into a block of data in the ieee format.

Parameters:
  • message – the message to send to the instrument.
  • datatype – the format string for a single element. See struct module.
  • is_big_endian – boolean indicating endianess. Defaults to False.
  • container – container type to use for the output data.
  • delay – delay in seconds between write and read operations. if None, defaults to self.query_delay
Return type:

bytes

query_delay = 0.0
query_values(message, delay=None)

Query the device for values returning an iterable of values.

The datatype expected is obtained from values_format

Parameters:
  • message (str) – the message to send.
  • delay – delay in seconds between write and read operations. if None, defaults to self.query_delay
Returns:

the answer from the device.

Return type:

list

read(termination=None, encoding=None)

Read a string from the device.

Reading stops when the device stops sending (e.g. by setting appropriate bus lines), or the termination characters sequence was detected. Attention: Only the last character of the termination characters is really used to stop reading, however, the whole sequence is compared to the ending of the read string message. If they don’t match, a warning is issued.

All line-ending characters are stripped from the end of the string.

Return type:str
read_raw(size=None)

Read the unmodified string sent from the instrument to the computer.

In contrast to read(), no termination characters are stripped.

Return type:bytes
read_stb()

Service request status register.

read_termination

Read termination character.

read_termination_context(*args, **kwds)
read_values(fmt=None, container=<type 'list'>)

Read a list of floating point values from the device.

Parameters:
  • fmt – the format of the values. If given, it overrides the class attribute “values_format”. Possible values are bitwise disjunctions of the above constants ascii, single, double, and big_endian. Default is ascii.
  • container – the output datatype
Returns:

the list of read values

Return type:

list

register(interface_type, resource_class)
resource_class
VI_ATTR_RSRC_CLASS specifies the resource class (for example, “INSTR”)
as defined by the canonical resource name.
VISA Attribute:VI_ATTR_RSRC_CLASS (3221159937)
resource_info

Get the extended information of this resource.

Parameters:resource_name – Unique symbolic name of a resource.
Return type:pyvisa.highlevel.ResourceInfo
resource_manufacturer_name
VI_ATTR_RSRC_MANF_NAME is a string that corresponds to the manufacturer

name of the vendor that implemented the VISA library. This attribute is not related to the device manufacturer attributes.

Note The value of this attribute is for display purposes only and not for programmatic decisions, as the value can differ between VISA implementations and/or revisions.

VISA Attribute:VI_ATTR_RSRC_MANF_NAME (3221160308)
resource_name
VI_ATTR_RSRC_MANF_NAME is a string that corresponds to the manufacturer

name of the vendor that implemented the VISA library. This attribute is not related to the device manufacturer attributes.

Note The value of this attribute is for display purposes only and not for programmatic decisions, as the value can differ between VISA implementations and/or revisions.

VISA Attribute:VI_ATTR_RSRC_NAME (3221159938)
send_end
VI_ATTR_SEND_END_EN specifies whether to assert END during the
transfer of the last byte of the buffer.
VISA Attribute:VI_ATTR_SEND_END_EN (1073676310)
Type:bool
session

Resource session handle.

Raises:pyvisa.errors.InvalidSession if session is closed.
set_visa_attribute(name, state)

Sets the state of an attribute.

Parameters:
  • name – Attribute for which the state is to be modified. (Attributes.*)
  • state – The state of the attribute to be set for the specified object.
spec_version
VI_ATTR_RSRC_SPEC_VERSION is the resource version that uniquely identifies
the version of the VISA specification to which the implementation is compliant. The format of the value has the upper 12 bits as the major number of the version, the next lower 12 bits as the minor number of the version, and the lowest 8 bits as the sub-minor number of the version. The current VISA specification defines the value to be 00300000h.
VISA Attribute:VI_ATTR_RSRC_SPEC_VERSION (1073676656)
Type:int
Range:0 <= value <= 4294967295
stb

Service request status register.

timeout

The timeout in milliseconds for all resource I/O operations.

None is mapped to VI_TMO_INFINITE. A value less than 1 is mapped to VI_TMO_IMMEDIATE.

uninstall_handler(event_type, handler, user_handle=None)

Uninstalls handlers for events in this resource.

Parameters:
  • event_type – Logical event identifier.
  • handler – Interpreted as a valid reference to a handler to be uninstalled by a client application.
  • user_handle – A value specified by an application that can be used for identifying handlers uniquely in a session for an event.
unlock()

Relinquishes a lock for the specified resource.

values_format
write(message, termination=None, encoding=None)

Write a string message to the device.

The write_termination is always appended to it.

Parameters:message (unicode (Py2) or str (Py3)) – the message to be sent.
Returns:number of bytes written.
Return type:int
write_ascii_values(message, values, converter=u'f', separator=u', ', termination=None, encoding=None)

Write a string message to the device followed by values in ascii format.

The write_termination is always appended to it.

Parameters:
  • message (unicode (Py2) or str (Py3)) – the message to be sent.
  • values – data to be writen to the device.
  • converter (callable | str) – function used to convert each value. String formatting codes are also accepted. Defaults to str.
  • separator – a callable that split the str into individual elements. If a str is given, data.split(separator) is used.
Type:

separator: (collections.Iterable[T]) -> str | str

Returns:

number of bytes written.

Return type:

int

write_binary_values(message, values, datatype=u'f', is_big_endian=False, termination=None, encoding=None)

Write a string message to the device followed by values in binary format.

The write_termination is always appended to it.

Parameters:
  • message (unicode (Py2) or str (Py3)) – the message to be sent.
  • values – data to be writen to the device.
  • datatype – the format string for a single element. See struct module.
  • is_big_endian – boolean indicating endianess.
Returns:

number of bytes written.

Return type:

int

write_raw(message)

Write a byte message to the device.

Parameters:message (bytes) – the message to be sent.
Returns:number of bytes written.
Return type:int
write_termination

Writer termination character.

write_values(message, values, termination=None, encoding=None)
class pyvisa.resources.TCPIPSocket(*args, **kwargs)[source]

Communicates with to devices of type TCPIP::host address::port::SOCKET

More complex resource names can be specified with the following grammar:
TCPIP[board]::host address::port::SOCKET

Do not instantiate directly, use pyvisa.highlevel.ResourceManager.open_resource().

CR = u'\r'
LF = u'\n'
assert_trigger()

Sends a software trigger to the device.

before_close()

Called just before closing an instrument.

chunk_size = 20480
clear()

Clears this resource

close()

Closes the VISA session and marks the handle as invalid.

encoding

Encoding used for read and write operations.

get_visa_attribute(name)

Retrieves the state of an attribute in this resource.

Parameters:name – Resource attribute for which the state query is made (see Attributes.*)
Returns:The state of the queried attribute for a specified resource.
Return type:unicode (Py2) or str (Py3), list or other type
implementation_version
VI_ATTR_RSRC_IMPL_VERSION is the resource version that uniquely identifies
each of the different revisions or implementations of a resource. This attribute value is defined by the individual manufacturer and increments with each new revision. The format of the value has the upper 12 bits as the major number of the version, the next lower 12 bits as the minor number of the version, and the lowest 8 bits as the sub-minor number of the version.
VISA Attribute:VI_ATTR_RSRC_IMPL_VERSION (1073676291)
Type:int
Range:0 <= value <= 4294967295
install_handler(event_type, handler, user_handle=None)

Installs handlers for event callbacks in this resource.

Parameters:
  • event_type – Logical event identifier.
  • handler – Interpreted as a valid reference to a handler to be installed by a client application.
  • user_handle – A value specified by an application that can be used for identifying handlers uniquely for an event type.
Returns:

user handle (a ctypes object)

interface_number

VI_ATTR_INTF_NUM specifies the board number for the given interface.

VISA Attribute:VI_ATTR_INTF_NUM (1073676662)
Type:int
Range:0 <= value <= 65535
interface_type

The interface type of the resource as a number.

io_protocol
VI_ATTR_IO_PROT specifies which protocol to use. In VXI, you can
choose normal word serial or fast data channel (FDC). In GPIB, you can choose normal or high-speed (HS-488) transfers. In serial, TCPIP, or USB RAW, you can choose normal transfers or 488.2-defined strings. In USB INSTR, you can choose normal or vendor-specific transfers.
VISA Attribute:VI_ATTR_IO_PROT (1073676316)
Type:int
Range:0 <= value <= 65535
last_status

Last status code for this session.

Return type:pyvisa.constants.StatusCode
lock(timeout=None, requested_key=None)

Establish a shared lock to the resource.

Parameters:
  • timeout – Absolute time period (in milliseconds) that a resource waits to get unlocked by the locking session before returning an error. (Defaults to self.timeout)
  • requested_key – Access key used by another session with which you want your session to share a lock or None to generate a new shared access key.
Returns:

A new shared access key if requested_key is None, otherwise, same value as the requested_key

lock_state
VI_ATTR_RSRC_LOCK_STATE indicates the current locking state of the
resource. The resource can be unlocked, locked with an exclusive lock, or locked with a shared lock.
VISA Attribute:VI_ATTR_RSRC_LOCK_STATE (1073676292)
Type::class:pyvisa.constants.AccessModes
open(access_mode=<AccessModes.no_lock: 0>, open_timeout=5000)

Opens a session to the specified resource.

Parameters:
  • access_mode (pyvisa.constants.AccessModes) – Specifies the mode by which the resource is to be accessed.
  • open_timeout (int) – Milliseconds before the open operation times out.
query(message, delay=None)

A combination of write(message) and read()

Parameters:
  • message (str) – the message to send.
  • delay – delay in seconds between write and read operations. if None, defaults to self.query_delay
Returns:

the answer from the device.

Return type:

str

query_ascii_values(message, converter=u'f', separator=u', ', container=<type 'list'>, delay=None)

Query the device for values in ascii format returning an iterable of values.

Parameters:
  • message (str) – the message to send.
  • delay – delay in seconds between write and read operations. if None, defaults to self.query_delay
  • converter (callable) – function used to convert each element. Defaults to float
  • separator – a callable that split the str into individual elements. If a str is given, data.split(separator) is used.
  • container – container type to use for the output data.
Type:

separator: (str) -> collections.Iterable[int] | str

Returns:

the answer from the device.

Return type:

list

query_binary_values(message, datatype=u'f', is_big_endian=False, container=<type 'list'>, delay=None)

Converts an iterable of numbers into a block of data in the ieee format.

Parameters:
  • message – the message to send to the instrument.
  • datatype – the format string for a single element. See struct module.
  • is_big_endian – boolean indicating endianess. Defaults to False.
  • container – container type to use for the output data.
  • delay – delay in seconds between write and read operations. if None, defaults to self.query_delay
Return type:

bytes

query_delay = 0.0
query_values(message, delay=None)

Query the device for values returning an iterable of values.

The datatype expected is obtained from values_format

Parameters:
  • message (str) – the message to send.
  • delay – delay in seconds between write and read operations. if None, defaults to self.query_delay
Returns:

the answer from the device.

Return type:

list

read(termination=None, encoding=None)

Read a string from the device.

Reading stops when the device stops sending (e.g. by setting appropriate bus lines), or the termination characters sequence was detected. Attention: Only the last character of the termination characters is really used to stop reading, however, the whole sequence is compared to the ending of the read string message. If they don’t match, a warning is issued.

All line-ending characters are stripped from the end of the string.

Return type:str
read_raw(size=None)

Read the unmodified string sent from the instrument to the computer.

In contrast to read(), no termination characters are stripped.

Return type:bytes
read_stb()

Service request status register.

read_termination

Read termination character.

read_termination_context(*args, **kwds)
read_values(fmt=None, container=<type 'list'>)

Read a list of floating point values from the device.

Parameters:
  • fmt – the format of the values. If given, it overrides the class attribute “values_format”. Possible values are bitwise disjunctions of the above constants ascii, single, double, and big_endian. Default is ascii.
  • container – the output datatype
Returns:

the list of read values

Return type:

list

register(interface_type, resource_class)
resource_class
VI_ATTR_RSRC_CLASS specifies the resource class (for example, “INSTR”)
as defined by the canonical resource name.
VISA Attribute:VI_ATTR_RSRC_CLASS (3221159937)
resource_info

Get the extended information of this resource.

Parameters:resource_name – Unique symbolic name of a resource.
Return type:pyvisa.highlevel.ResourceInfo
resource_manufacturer_name
VI_ATTR_RSRC_MANF_NAME is a string that corresponds to the manufacturer

name of the vendor that implemented the VISA library. This attribute is not related to the device manufacturer attributes.

Note The value of this attribute is for display purposes only and not for programmatic decisions, as the value can differ between VISA implementations and/or revisions.

VISA Attribute:VI_ATTR_RSRC_MANF_NAME (3221160308)
resource_name
VI_ATTR_RSRC_MANF_NAME is a string that corresponds to the manufacturer

name of the vendor that implemented the VISA library. This attribute is not related to the device manufacturer attributes.

Note The value of this attribute is for display purposes only and not for programmatic decisions, as the value can differ between VISA implementations and/or revisions.

VISA Attribute:VI_ATTR_RSRC_NAME (3221159938)
session

Resource session handle.

Raises:pyvisa.errors.InvalidSession if session is closed.
set_visa_attribute(name, state)

Sets the state of an attribute.

Parameters:
  • name – Attribute for which the state is to be modified. (Attributes.*)
  • state – The state of the attribute to be set for the specified object.
spec_version
VI_ATTR_RSRC_SPEC_VERSION is the resource version that uniquely identifies
the version of the VISA specification to which the implementation is compliant. The format of the value has the upper 12 bits as the major number of the version, the next lower 12 bits as the minor number of the version, and the lowest 8 bits as the sub-minor number of the version. The current VISA specification defines the value to be 00300000h.
VISA Attribute:VI_ATTR_RSRC_SPEC_VERSION (1073676656)
Type:int
Range:0 <= value <= 4294967295
stb

Service request status register.

timeout

The timeout in milliseconds for all resource I/O operations.

None is mapped to VI_TMO_INFINITE. A value less than 1 is mapped to VI_TMO_IMMEDIATE.

uninstall_handler(event_type, handler, user_handle=None)

Uninstalls handlers for events in this resource.

Parameters:
  • event_type – Logical event identifier.
  • handler – Interpreted as a valid reference to a handler to be uninstalled by a client application.
  • user_handle – A value specified by an application that can be used for identifying handlers uniquely in a session for an event.
unlock()

Relinquishes a lock for the specified resource.

values_format
write(message, termination=None, encoding=None)

Write a string message to the device.

The write_termination is always appended to it.

Parameters:message (unicode (Py2) or str (Py3)) – the message to be sent.
Returns:number of bytes written.
Return type:int
write_ascii_values(message, values, converter=u'f', separator=u', ', termination=None, encoding=None)

Write a string message to the device followed by values in ascii format.

The write_termination is always appended to it.

Parameters:
  • message (unicode (Py2) or str (Py3)) – the message to be sent.
  • values – data to be writen to the device.
  • converter (callable | str) – function used to convert each value. String formatting codes are also accepted. Defaults to str.
  • separator – a callable that split the str into individual elements. If a str is given, data.split(separator) is used.
Type:

separator: (collections.Iterable[T]) -> str | str

Returns:

number of bytes written.

Return type:

int

write_binary_values(message, values, datatype=u'f', is_big_endian=False, termination=None, encoding=None)

Write a string message to the device followed by values in binary format.

The write_termination is always appended to it.

Parameters:
  • message (unicode (Py2) or str (Py3)) – the message to be sent.
  • values – data to be writen to the device.
  • datatype – the format string for a single element. See struct module.
  • is_big_endian – boolean indicating endianess.
Returns:

number of bytes written.

Return type:

int

write_raw(message)

Write a byte message to the device.

Parameters:message (bytes) – the message to be sent.
Returns:number of bytes written.
Return type:int
write_termination

Writer termination character.

write_values(message, values, termination=None, encoding=None)
class pyvisa.resources.USBInstrument(*args, **kwargs)[source]

Communicates with devices of type USB::manufacturer ID::model code::serial number

More complex resource names can be specified with the following grammar:
USB[board]::manufacturer ID::model code::serial number[::USB interface number][::INSTR]

Do not instantiate directly, use pyvisa.highlevel.ResourceManager.open_resource().

CR = u'\r'
LF = u'\n'
assert_trigger()

Sends a software trigger to the device.

before_close()

Called just before closing an instrument.

chunk_size = 20480
clear()

Clears this resource

close()

Closes the VISA session and marks the handle as invalid.

control_in(request_type_bitmap_field, request_id, request_value, index, length=0)[source]

Performs a USB control pipe transfer from the device.

Parameters:
  • request_type_bitmap_field – bmRequestType parameter of the setup stage of a USB control transfer.
  • request_id – bRequest parameter of the setup stage of a USB control transfer.
  • request_value – wValue parameter of the setup stage of a USB control transfer.
  • index – wIndex parameter of the setup stage of a USB control transfer. This is usually the index of the interface or endpoint.
  • length – wLength parameter of the setup stage of a USB control transfer. This value also specifies the size of the data buffer to receive the data from the optional data stage of the control transfer.
Returns:

The data buffer that receives the data from the optional data stage of the control transfer.

Return type:

bytes

encoding

Encoding used for read and write operations.

get_visa_attribute(name)

Retrieves the state of an attribute in this resource.

Parameters:name – Resource attribute for which the state query is made (see Attributes.*)
Returns:The state of the queried attribute for a specified resource.
Return type:unicode (Py2) or str (Py3), list or other type
implementation_version
VI_ATTR_RSRC_IMPL_VERSION is the resource version that uniquely identifies
each of the different revisions or implementations of a resource. This attribute value is defined by the individual manufacturer and increments with each new revision. The format of the value has the upper 12 bits as the major number of the version, the next lower 12 bits as the minor number of the version, and the lowest 8 bits as the sub-minor number of the version.
VISA Attribute:VI_ATTR_RSRC_IMPL_VERSION (1073676291)
Type:int
Range:0 <= value <= 4294967295
install_handler(event_type, handler, user_handle=None)

Installs handlers for event callbacks in this resource.

Parameters:
  • event_type – Logical event identifier.
  • handler – Interpreted as a valid reference to a handler to be installed by a client application.
  • user_handle – A value specified by an application that can be used for identifying handlers uniquely for an event type.
Returns:

user handle (a ctypes object)

interface_number
VI_ATTR_USB_INTFC_NUM specifies the USB interface number used by the
given session.
VISA Attribute:VI_ATTR_USB_INTFC_NUM (1073676705)
Type:int
Range:0 <= value <= 254
interface_type

The interface type of the resource as a number.

io_protocol
VI_ATTR_IO_PROT specifies which protocol to use. In VXI, you can
choose normal word serial or fast data channel (FDC). In GPIB, you can choose normal or high-speed (HS-488) transfers. In serial, TCPIP, or USB RAW, you can choose normal transfers or 488.2-defined strings. In USB INSTR, you can choose normal or vendor-specific transfers.
VISA Attribute:VI_ATTR_IO_PROT (1073676316)
Type:int
Range:0 <= value <= 65535
is_4882_compliant
VI_ATTR_4882_COMPLIANT specifies whether the device is 488.2
compliant.
VISA Attribute:VI_ATTR_4882_COMPLIANT (1073676703)
Type:bool
last_status

Last status code for this session.

Return type:pyvisa.constants.StatusCode
lock(timeout=None, requested_key=None)

Establish a shared lock to the resource.

Parameters:
  • timeout – Absolute time period (in milliseconds) that a resource waits to get unlocked by the locking session before returning an error. (Defaults to self.timeout)
  • requested_key – Access key used by another session with which you want your session to share a lock or None to generate a new shared access key.
Returns:

A new shared access key if requested_key is None, otherwise, same value as the requested_key

lock_state
VI_ATTR_RSRC_LOCK_STATE indicates the current locking state of the
resource. The resource can be unlocked, locked with an exclusive lock, or locked with a shared lock.
VISA Attribute:VI_ATTR_RSRC_LOCK_STATE (1073676292)
Type::class:pyvisa.constants.AccessModes
manufacturer_id
VI_ATTR_MANF_ID is the manufacturer identification number of the
device.
VISA Attribute:VI_ATTR_MANF_ID (1073676505)
Type:int
Range:0 <= value <= 65535
manufacturer_name

This string attribute is the manufacturer name.

VISA Attribute:VI_ATTR_MANF_NAME (3221160050)
maximum_interrupt_size
VI_ATTR_USB_MAX_INTR_SIZE specifies the maximum size of data that will
be stored by any given USB interrupt. If a USB interrupt contains more data than this size, the data in excess of this size will be lost.
VISA Attribute:VI_ATTR_USB_MAX_INTR_SIZE (1073676719)
Type:int
Range:0 <= value <= 65535
model_code

VI_ATTR_MODEL_CODE specifies the model code for the device.

VISA Attribute:VI_ATTR_MODEL_CODE (1073676511)
Type:int
Range:0 <= value <= 65535
model_name

This string attribute is the model name of the device.

VISA Attribute:VI_ATTR_MODEL_NAME (3221160055)
open(access_mode=<AccessModes.no_lock: 0>, open_timeout=5000)

Opens a session to the specified resource.

Parameters:
  • access_mode (pyvisa.constants.AccessModes) – Specifies the mode by which the resource is to be accessed.
  • open_timeout (int) – Milliseconds before the open operation times out.
query(message, delay=None)

A combination of write(message) and read()

Parameters:
  • message (str) – the message to send.
  • delay – delay in seconds between write and read operations. if None, defaults to self.query_delay
Returns:

the answer from the device.

Return type:

str

query_ascii_values(message, converter=u'f', separator=u', ', container=<type 'list'>, delay=None)

Query the device for values in ascii format returning an iterable of values.

Parameters:
  • message (str) – the message to send.
  • delay – delay in seconds between write and read operations. if None, defaults to self.query_delay
  • converter (callable) – function used to convert each element. Defaults to float
  • separator – a callable that split the str into individual elements. If a str is given, data.split(separator) is used.
  • container – container type to use for the output data.
Type:

separator: (str) -> collections.Iterable[int] | str

Returns:

the answer from the device.

Return type:

list

query_binary_values(message, datatype=u'f', is_big_endian=False, container=<type 'list'>, delay=None)

Converts an iterable of numbers into a block of data in the ieee format.

Parameters:
  • message – the message to send to the instrument.
  • datatype – the format string for a single element. See struct module.
  • is_big_endian – boolean indicating endianess. Defaults to False.
  • container – container type to use for the output data.
  • delay – delay in seconds between write and read operations. if None, defaults to self.query_delay
Return type:

bytes

query_delay = 0.0
query_values(message, delay=None)

Query the device for values returning an iterable of values.

The datatype expected is obtained from values_format

Parameters:
  • message (str) – the message to send.
  • delay – delay in seconds between write and read operations. if None, defaults to self.query_delay
Returns:

the answer from the device.

Return type:

list

read(termination=None, encoding=None)

Read a string from the device.

Reading stops when the device stops sending (e.g. by setting appropriate bus lines), or the termination characters sequence was detected. Attention: Only the last character of the termination characters is really used to stop reading, however, the whole sequence is compared to the ending of the read string message. If they don’t match, a warning is issued.

All line-ending characters are stripped from the end of the string.

Return type:str
read_raw(size=None)

Read the unmodified string sent from the instrument to the computer.

In contrast to read(), no termination characters are stripped.

Return type:bytes
read_stb()

Service request status register.

read_termination

Read termination character.

read_termination_context(*args, **kwds)
read_values(fmt=None, container=<type 'list'>)

Read a list of floating point values from the device.

Parameters:
  • fmt – the format of the values. If given, it overrides the class attribute “values_format”. Possible values are bitwise disjunctions of the above constants ascii, single, double, and big_endian. Default is ascii.
  • container – the output datatype
Returns:

the list of read values

Return type:

list

register(interface_type, resource_class)
resource_class
VI_ATTR_RSRC_CLASS specifies the resource class (for example, “INSTR”)
as defined by the canonical resource name.
VISA Attribute:VI_ATTR_RSRC_CLASS (3221159937)
resource_info

Get the extended information of this resource.

Parameters:resource_name – Unique symbolic name of a resource.
Return type:pyvisa.highlevel.ResourceInfo
resource_manufacturer_name
VI_ATTR_RSRC_MANF_NAME is a string that corresponds to the manufacturer

name of the vendor that implemented the VISA library. This attribute is not related to the device manufacturer attributes.

Note The value of this attribute is for display purposes only and not for programmatic decisions, as the value can differ between VISA implementations and/or revisions.

VISA Attribute:VI_ATTR_RSRC_MANF_NAME (3221160308)
resource_name
VI_ATTR_RSRC_MANF_NAME is a string that corresponds to the manufacturer

name of the vendor that implemented the VISA library. This attribute is not related to the device manufacturer attributes.

Note The value of this attribute is for display purposes only and not for programmatic decisions, as the value can differ between VISA implementations and/or revisions.

VISA Attribute:VI_ATTR_RSRC_NAME (3221159938)
send_end
VI_ATTR_SEND_END_EN specifies whether to assert END during the
transfer of the last byte of the buffer.
VISA Attribute:VI_ATTR_SEND_END_EN (1073676310)
Type:bool
serial_number

VI_ATTR_USB_SERIAL_NUM specifies the USB serial number of this device.

VISA Attribute:VI_ATTR_USB_SERIAL_NUM (3221160352)
session

Resource session handle.

Raises:pyvisa.errors.InvalidSession if session is closed.
set_visa_attribute(name, state)

Sets the state of an attribute.

Parameters:
  • name – Attribute for which the state is to be modified. (Attributes.*)
  • state – The state of the attribute to be set for the specified object.
spec_version
VI_ATTR_RSRC_SPEC_VERSION is the resource version that uniquely identifies
the version of the VISA specification to which the implementation is compliant. The format of the value has the upper 12 bits as the major number of the version, the next lower 12 bits as the minor number of the version, and the lowest 8 bits as the sub-minor number of the version. The current VISA specification defines the value to be 00300000h.
VISA Attribute:VI_ATTR_RSRC_SPEC_VERSION (1073676656)
Type:int
Range:0 <= value <= 4294967295
stb

Service request status register.

timeout

The timeout in milliseconds for all resource I/O operations.

None is mapped to VI_TMO_INFINITE. A value less than 1 is mapped to VI_TMO_IMMEDIATE.

uninstall_handler(event_type, handler, user_handle=None)

Uninstalls handlers for events in this resource.

Parameters:
  • event_type – Logical event identifier.
  • handler – Interpreted as a valid reference to a handler to be uninstalled by a client application.
  • user_handle – A value specified by an application that can be used for identifying handlers uniquely in a session for an event.
unlock()

Relinquishes a lock for the specified resource.

usb_control_out(request_type_bitmap_field, request_id, request_value, index, data=u'')[source]

Performs a USB control pipe transfer to the device.

Parameters:
  • request_type_bitmap_field – bmRequestType parameter of the setup stage of a USB control transfer.
  • request_id – bRequest parameter of the setup stage of a USB control transfer.
  • request_value – wValue parameter of the setup stage of a USB control transfer.
  • index – wIndex parameter of the setup stage of a USB control transfer. This is usually the index of the interface or endpoint.
  • data – The data buffer that sends the data in the optional data stage of the control transfer.
usb_protocol
VI_ATTR_USB_PROTOCOL specifies the USB protocol used by this USB
interface.
VISA Attribute:VI_ATTR_USB_PROTOCOL (1073676711)
Type:int
Range:0 <= value <= 255
values_format
write(message, termination=None, encoding=None)

Write a string message to the device.

The write_termination is always appended to it.

Parameters:message (unicode (Py2) or str (Py3)) – the message to be sent.
Returns:number of bytes written.
Return type:int
write_ascii_values(message, values, converter=u'f', separator=u', ', termination=None, encoding=None)

Write a string message to the device followed by values in ascii format.

The write_termination is always appended to it.

Parameters:
  • message (unicode (Py2) or str (Py3)) – the message to be sent.
  • values – data to be writen to the device.
  • converter (callable | str) – function used to convert each value. String formatting codes are also accepted. Defaults to str.
  • separator – a callable that split the str into individual elements. If a str is given, data.split(separator) is used.
Type:

separator: (collections.Iterable[T]) -> str | str

Returns:

number of bytes written.

Return type:

int

write_binary_values(message, values, datatype=u'f', is_big_endian=False, termination=None, encoding=None)

Write a string message to the device followed by values in binary format.

The write_termination is always appended to it.

Parameters:
  • message (unicode (Py2) or str (Py3)) – the message to be sent.
  • values – data to be writen to the device.
  • datatype – the format string for a single element. See struct module.
  • is_big_endian – boolean indicating endianess.
Returns:

number of bytes written.

Return type:

int

write_raw(message)

Write a byte message to the device.

Parameters:message (bytes) – the message to be sent.
Returns:number of bytes written.
Return type:int
write_termination

Writer termination character.

write_values(message, values, termination=None, encoding=None)
class pyvisa.resources.USBRaw(*args, **kwargs)[source]

Communicates with to devices of type USB::manufacturer ID::model code::serial number::RAW

More complex resource names can be specified with the following grammar:
USB[board]::manufacturer ID::model code::serial number[::USB interface number]::RAW

Do not instantiate directly, use pyvisa.highlevel.ResourceManager.open_resource().

CR = u'\r'
LF = u'\n'
assert_trigger()

Sends a software trigger to the device.

before_close()

Called just before closing an instrument.

chunk_size = 20480
clear()

Clears this resource

close()

Closes the VISA session and marks the handle as invalid.

encoding

Encoding used for read and write operations.

get_visa_attribute(name)

Retrieves the state of an attribute in this resource.

Parameters:name – Resource attribute for which the state query is made (see Attributes.*)
Returns:The state of the queried attribute for a specified resource.
Return type:unicode (Py2) or str (Py3), list or other type
implementation_version
VI_ATTR_RSRC_IMPL_VERSION is the resource version that uniquely identifies
each of the different revisions or implementations of a resource. This attribute value is defined by the individual manufacturer and increments with each new revision. The format of the value has the upper 12 bits as the major number of the version, the next lower 12 bits as the minor number of the version, and the lowest 8 bits as the sub-minor number of the version.
VISA Attribute:VI_ATTR_RSRC_IMPL_VERSION (1073676291)
Type:int
Range:0 <= value <= 4294967295
install_handler(event_type, handler, user_handle=None)

Installs handlers for event callbacks in this resource.

Parameters:
  • event_type – Logical event identifier.
  • handler – Interpreted as a valid reference to a handler to be installed by a client application.
  • user_handle – A value specified by an application that can be used for identifying handlers uniquely for an event type.
Returns:

user handle (a ctypes object)

interface_number
VI_ATTR_USB_INTFC_NUM specifies the USB interface number used by the
given session.
VISA Attribute:VI_ATTR_USB_INTFC_NUM (1073676705)
Type:int
Range:0 <= value <= 254
interface_type

The interface type of the resource as a number.

io_protocol
VI_ATTR_IO_PROT specifies which protocol to use. In VXI, you can
choose normal word serial or fast data channel (FDC). In GPIB, you can choose normal or high-speed (HS-488) transfers. In serial, TCPIP, or USB RAW, you can choose normal transfers or 488.2-defined strings. In USB INSTR, you can choose normal or vendor-specific transfers.
VISA Attribute:VI_ATTR_IO_PROT (1073676316)
Type:int
Range:0 <= value <= 65535
last_status

Last status code for this session.

Return type:pyvisa.constants.StatusCode
lock(timeout=None, requested_key=None)

Establish a shared lock to the resource.

Parameters:
  • timeout – Absolute time period (in milliseconds) that a resource waits to get unlocked by the locking session before returning an error. (Defaults to self.timeout)
  • requested_key – Access key used by another session with which you want your session to share a lock or None to generate a new shared access key.
Returns:

A new shared access key if requested_key is None, otherwise, same value as the requested_key

lock_state
VI_ATTR_RSRC_LOCK_STATE indicates the current locking state of the
resource. The resource can be unlocked, locked with an exclusive lock, or locked with a shared lock.
VISA Attribute:VI_ATTR_RSRC_LOCK_STATE (1073676292)
Type::class:pyvisa.constants.AccessModes
manufacturer_id
VI_ATTR_MANF_ID is the manufacturer identification number of the
device.
VISA Attribute:VI_ATTR_MANF_ID (1073676505)
Type:int
Range:0 <= value <= 65535
manufacturer_name

This string attribute is the manufacturer name.

VISA Attribute:VI_ATTR_MANF_NAME (3221160050)
maximum_interrupt_size
VI_ATTR_USB_MAX_INTR_SIZE specifies the maximum size of data that will
be stored by any given USB interrupt. If a USB interrupt contains more data than this size, the data in excess of this size will be lost.
VISA Attribute:VI_ATTR_USB_MAX_INTR_SIZE (1073676719)
Type:int
Range:0 <= value <= 65535
model_code

VI_ATTR_MODEL_CODE specifies the model code for the device.

VISA Attribute:VI_ATTR_MODEL_CODE (1073676511)
Type:int
Range:0 <= value <= 65535
model_name

This string attribute is the model name of the device.

VISA Attribute:VI_ATTR_MODEL_NAME (3221160055)
open(access_mode=<AccessModes.no_lock: 0>, open_timeout=5000)

Opens a session to the specified resource.

Parameters:
  • access_mode (pyvisa.constants.AccessModes) – Specifies the mode by which the resource is to be accessed.
  • open_timeout (int) – Milliseconds before the open operation times out.
query(message, delay=None)

A combination of write(message) and read()

Parameters:
  • message (str) – the message to send.
  • delay – delay in seconds between write and read operations. if None, defaults to self.query_delay
Returns:

the answer from the device.

Return type:

str

query_ascii_values(message, converter=u'f', separator=u', ', container=<type 'list'>, delay=None)

Query the device for values in ascii format returning an iterable of values.

Parameters:
  • message (str) – the message to send.
  • delay – delay in seconds between write and read operations. if None, defaults to self.query_delay
  • converter (callable) – function used to convert each element. Defaults to float
  • separator – a callable that split the str into individual elements. If a str is given, data.split(separator) is used.
  • container – container type to use for the output data.
Type:

separator: (str) -> collections.Iterable[int] | str

Returns:

the answer from the device.

Return type:

list

query_binary_values(message, datatype=u'f', is_big_endian=False, container=<type 'list'>, delay=None)

Converts an iterable of numbers into a block of data in the ieee format.

Parameters:
  • message – the message to send to the instrument.
  • datatype – the format string for a single element. See struct module.
  • is_big_endian – boolean indicating endianess. Defaults to False.
  • container – container type to use for the output data.
  • delay – delay in seconds between write and read operations. if None, defaults to self.query_delay
Return type:

bytes

query_delay = 0.0
query_values(message, delay=None)

Query the device for values returning an iterable of values.

The datatype expected is obtained from values_format

Parameters:
  • message (str) – the message to send.
  • delay – delay in seconds between write and read operations. if None, defaults to self.query_delay
Returns:

the answer from the device.

Return type:

list

read(termination=None, encoding=None)

Read a string from the device.

Reading stops when the device stops sending (e.g. by setting appropriate bus lines), or the termination characters sequence was detected. Attention: Only the last character of the termination characters is really used to stop reading, however, the whole sequence is compared to the ending of the read string message. If they don’t match, a warning is issued.

All line-ending characters are stripped from the end of the string.

Return type:str
read_raw(size=None)

Read the unmodified string sent from the instrument to the computer.

In contrast to read(), no termination characters are stripped.

Return type:bytes
read_stb()

Service request status register.

read_termination

Read termination character.

read_termination_context(*args, **kwds)
read_values(fmt=None, container=<type 'list'>)

Read a list of floating point values from the device.

Parameters:
  • fmt – the format of the values. If given, it overrides the class attribute “values_format”. Possible values are bitwise disjunctions of the above constants ascii, single, double, and big_endian. Default is ascii.
  • container – the output datatype
Returns:

the list of read values

Return type:

list

register(interface_type, resource_class)
resource_class
VI_ATTR_RSRC_CLASS specifies the resource class (for example, “INSTR”)
as defined by the canonical resource name.
VISA Attribute:VI_ATTR_RSRC_CLASS (3221159937)
resource_info

Get the extended information of this resource.

Parameters:resource_name – Unique symbolic name of a resource.
Return type:pyvisa.highlevel.ResourceInfo
resource_manufacturer_name
VI_ATTR_RSRC_MANF_NAME is a string that corresponds to the manufacturer

name of the vendor that implemented the VISA library. This attribute is not related to the device manufacturer attributes.

Note The value of this attribute is for display purposes only and not for programmatic decisions, as the value can differ between VISA implementations and/or revisions.

VISA Attribute:VI_ATTR_RSRC_MANF_NAME (3221160308)
resource_name
VI_ATTR_RSRC_MANF_NAME is a string that corresponds to the manufacturer

name of the vendor that implemented the VISA library. This attribute is not related to the device manufacturer attributes.

Note The value of this attribute is for display purposes only and not for programmatic decisions, as the value can differ between VISA implementations and/or revisions.

VISA Attribute:VI_ATTR_RSRC_NAME (3221159938)
serial_number

VI_ATTR_USB_SERIAL_NUM specifies the USB serial number of this device.

VISA Attribute:VI_ATTR_USB_SERIAL_NUM (3221160352)
session

Resource session handle.

Raises:pyvisa.errors.InvalidSession if session is closed.
set_visa_attribute(name, state)

Sets the state of an attribute.

Parameters:
  • name – Attribute for which the state is to be modified. (Attributes.*)
  • state – The state of the attribute to be set for the specified object.
spec_version
VI_ATTR_RSRC_SPEC_VERSION is the resource version that uniquely identifies
the version of the VISA specification to which the implementation is compliant. The format of the value has the upper 12 bits as the major number of the version, the next lower 12 bits as the minor number of the version, and the lowest 8 bits as the sub-minor number of the version. The current VISA specification defines the value to be 00300000h.
VISA Attribute:VI_ATTR_RSRC_SPEC_VERSION (1073676656)
Type:int
Range:0 <= value <= 4294967295
stb

Service request status register.

timeout

The timeout in milliseconds for all resource I/O operations.

None is mapped to VI_TMO_INFINITE. A value less than 1 is mapped to VI_TMO_IMMEDIATE.

uninstall_handler(event_type, handler, user_handle=None)

Uninstalls handlers for events in this resource.

Parameters:
  • event_type – Logical event identifier.
  • handler – Interpreted as a valid reference to a handler to be uninstalled by a client application.
  • user_handle – A value specified by an application that can be used for identifying handlers uniquely in a session for an event.
unlock()

Relinquishes a lock for the specified resource.

usb_protocol
VI_ATTR_USB_PROTOCOL specifies the USB protocol used by this USB
interface.
VISA Attribute:VI_ATTR_USB_PROTOCOL (1073676711)
Type:int
Range:0 <= value <= 255
values_format
write(message, termination=None, encoding=None)

Write a string message to the device.

The write_termination is always appended to it.

Parameters:message (unicode (Py2) or str (Py3)) – the message to be sent.
Returns:number of bytes written.
Return type:int
write_ascii_values(message, values, converter=u'f', separator=u', ', termination=None, encoding=None)

Write a string message to the device followed by values in ascii format.

The write_termination is always appended to it.

Parameters:
  • message (unicode (Py2) or str (Py3)) – the message to be sent.
  • values – data to be writen to the device.
  • converter (callable | str) – function used to convert each value. String formatting codes are also accepted. Defaults to str.
  • separator – a callable that split the str into individual elements. If a str is given, data.split(separator) is used.
Type:

separator: (collections.Iterable[T]) -> str | str

Returns:

number of bytes written.

Return type:

int

write_binary_values(message, values, datatype=u'f', is_big_endian=False, termination=None, encoding=None)

Write a string message to the device followed by values in binary format.

The write_termination is always appended to it.

Parameters:
  • message (unicode (Py2) or str (Py3)) – the message to be sent.
  • values – data to be writen to the device.
  • datatype – the format string for a single element. See struct module.
  • is_big_endian – boolean indicating endianess.
Returns:

number of bytes written.

Return type:

int

write_raw(message)

Write a byte message to the device.

Parameters:message (bytes) – the message to be sent.
Returns:number of bytes written.
Return type:int
write_termination

Writer termination character.

write_values(message, values, termination=None, encoding=None)
class pyvisa.resources.GPIBInstrument(*args, **kwargs)[source]

Communicates with to devices of type GPIB::<primary address>[::INSTR]

More complex resource names can be specified with the following grammar:
GPIB[board]::primary address[::secondary address][::INSTR]

Do not instantiate directly, use pyvisa.highlevel.ResourceManager.open_resource().

CR = u'\r'
LF = u'\n'
allow_dma
This attribute specifies whether I/O accesses should use DMA (VI_TRUE)
or Programmed I/O (VI_FALSE). In some implementations, this attribute may have global effects even though it is documented to be a local attribute. Since this affects performance and not functionality, that behavior is acceptable.
VISA Attribute:VI_ATTR_DMA_ALLOW_EN (1073676318)
Type:bool
assert_trigger()

Sends a software trigger to the device.

before_close()[source]
chunk_size = 20480
clear()

Clears this resource

close()

Closes the VISA session and marks the handle as invalid.

control_atn(mode)

Specifies the state of the ATN line and the local active controller state.

Corresponds to viGpibControlATN function of the VISA library.

Parameters:mode – Specifies the state of the ATN line and optionally the local active controller state. (Constants.GPIB_ATN*)
Returns:return value of the library call.
Return type:VISAStatus
control_ren(mode)

Controls the state of the GPIB Remote Enable (REN) interface line, and optionally the remote/local state of the device.

Corresponds to viGpibControlREN function of the VISA library.

Parameters:mode – Specifies the state of the REN line and optionally the device remote/local state. (Constants.GPIB_REN*)
Returns:return value of the library call.
Return type:VISAStatus
enable_repeat_addressing
VI_ATTR_GPIB_READDR_EN specifies whether to use repeat addressing
before each read or write operation.
VISA Attribute:VI_ATTR_GPIB_READDR_EN (1073676315)
Type:bool
enable_unaddressing
VI_ATTR_GPIB_UNADDR_EN specifies whether to unaddress the device (UNT
and UNL) after each read or write operation.
VISA Attribute:VI_ATTR_GPIB_UNADDR_EN (1073676676)
Type:bool
encoding

Encoding used for read and write operations.

get_visa_attribute(name)

Retrieves the state of an attribute in this resource.

Parameters:name – Resource attribute for which the state query is made (see Attributes.*)
Returns:The state of the queried attribute for a specified resource.
Return type:unicode (Py2) or str (Py3), list or other type
implementation_version
VI_ATTR_RSRC_IMPL_VERSION is the resource version that uniquely identifies
each of the different revisions or implementations of a resource. This attribute value is defined by the individual manufacturer and increments with each new revision. The format of the value has the upper 12 bits as the major number of the version, the next lower 12 bits as the minor number of the version, and the lowest 8 bits as the sub-minor number of the version.
VISA Attribute:VI_ATTR_RSRC_IMPL_VERSION (1073676291)
Type:int
Range:0 <= value <= 4294967295
install_handler(event_type, handler, user_handle=None)

Installs handlers for event callbacks in this resource.

Parameters:
  • event_type – Logical event identifier.
  • handler – Interpreted as a valid reference to a handler to be installed by a client application.
  • user_handle – A value specified by an application that can be used for identifying handlers uniquely for an event type.
Returns:

user handle (a ctypes object)

interface_number

VI_ATTR_INTF_NUM specifies the board number for the given interface.

VISA Attribute:VI_ATTR_INTF_NUM (1073676662)
Type:int
Range:0 <= value <= 65535
interface_type

The interface type of the resource as a number.

io_protocol
VI_ATTR_IO_PROT specifies which protocol to use. In VXI, you can
choose normal word serial or fast data channel (FDC). In GPIB, you can choose normal or high-speed (HS-488) transfers. In serial, TCPIP, or USB RAW, you can choose normal transfers or 488.2-defined strings. In USB INSTR, you can choose normal or vendor-specific transfers.
VISA Attribute:VI_ATTR_IO_PROT (1073676316)
Type:int
Range:0 <= value <= 65535
last_status

Last status code for this session.

Return type:pyvisa.constants.StatusCode
lock(timeout=None, requested_key=None)

Establish a shared lock to the resource.

Parameters:
  • timeout – Absolute time period (in milliseconds) that a resource waits to get unlocked by the locking session before returning an error. (Defaults to self.timeout)
  • requested_key – Access key used by another session with which you want your session to share a lock or None to generate a new shared access key.
Returns:

A new shared access key if requested_key is None, otherwise, same value as the requested_key

lock_state
VI_ATTR_RSRC_LOCK_STATE indicates the current locking state of the
resource. The resource can be unlocked, locked with an exclusive lock, or locked with a shared lock.
VISA Attribute:VI_ATTR_RSRC_LOCK_STATE (1073676292)
Type::class:pyvisa.constants.AccessModes
open(access_mode=<AccessModes.no_lock: 0>, open_timeout=5000)

Opens a session to the specified resource.

Parameters:
  • access_mode (pyvisa.constants.AccessModes) – Specifies the mode by which the resource is to be accessed.
  • open_timeout (int) – Milliseconds before the open operation times out.
pass_control(primary_address, secondary_address)

Tell the GPIB device at the specified address to become controller in charge (CIC).

Corresponds to viGpibPassControl function of the VISA library.

Parameters:
  • primary_address – Primary address of the GPIB device to which you want to pass control.
  • secondary_address – Secondary address of the targeted GPIB device. If the targeted device does not have a secondary address, this parameter should contain the value Constants.NO_SEC_ADDR.
Returns:

return value of the library call.

Return type:

VISAStatus

primary_address
VI_ATTR_GPIB_PRIMARY_ADDR specifies the primary address of the GPIB
device used by the given session. For the GPIB INTFC Resource, this attribute is Read-Write.
VISA Attribute:VI_ATTR_GPIB_PRIMARY_ADDR (1073676658)
Type:int
Range:0 <= value <= 30
query(message, delay=None)

A combination of write(message) and read()

Parameters:
  • message (str) – the message to send.
  • delay – delay in seconds between write and read operations. if None, defaults to self.query_delay
Returns:

the answer from the device.

Return type:

str

query_ascii_values(message, converter=u'f', separator=u', ', container=<type 'list'>, delay=None)

Query the device for values in ascii format returning an iterable of values.

Parameters:
  • message (str) – the message to send.
  • delay – delay in seconds between write and read operations. if None, defaults to self.query_delay
  • converter (callable) – function used to convert each element. Defaults to float
  • separator – a callable that split the str into individual elements. If a str is given, data.split(separator) is used.
  • container – container type to use for the output data.
Type:

separator: (str) -> collections.Iterable[int] | str

Returns:

the answer from the device.

Return type:

list

query_binary_values(message, datatype=u'f', is_big_endian=False, container=<type 'list'>, delay=None)

Converts an iterable of numbers into a block of data in the ieee format.

Parameters:
  • message – the message to send to the instrument.
  • datatype – the format string for a single element. See struct module.
  • is_big_endian – boolean indicating endianess. Defaults to False.
  • container – container type to use for the output data.
  • delay – delay in seconds between write and read operations. if None, defaults to self.query_delay
Return type:

bytes

query_delay = 0.0
query_values(message, delay=None)

Query the device for values returning an iterable of values.

The datatype expected is obtained from values_format

Parameters:
  • message (str) – the message to send.
  • delay – delay in seconds between write and read operations. if None, defaults to self.query_delay
Returns:

the answer from the device.

Return type:

list

read(termination=None, encoding=None)

Read a string from the device.

Reading stops when the device stops sending (e.g. by setting appropriate bus lines), or the termination characters sequence was detected. Attention: Only the last character of the termination characters is really used to stop reading, however, the whole sequence is compared to the ending of the read string message. If they don’t match, a warning is issued.

All line-ending characters are stripped from the end of the string.

Return type:str
read_raw(size=None)

Read the unmodified string sent from the instrument to the computer.

In contrast to read(), no termination characters are stripped.

Return type:bytes
read_stb()

Service request status register.

read_termination

Read termination character.

read_termination_context(*args, **kwds)
read_values(fmt=None, container=<type 'list'>)

Read a list of floating point values from the device.

Parameters:
  • fmt – the format of the values. If given, it overrides the class attribute “values_format”. Possible values are bitwise disjunctions of the above constants ascii, single, double, and big_endian. Default is ascii.
  • container – the output datatype
Returns:

the list of read values

Return type:

list

register(interface_type, resource_class)
remote_enabled
VI_ATTR_GPIB_REN_STATE returns the current state of the GPIB REN
(Remote ENable) interface line.
VISA Attribute:VI_ATTR_GPIB_REN_STATE (1073676673)
Type::class:pyvisa.constants.LineState
resource_class
VI_ATTR_RSRC_CLASS specifies the resource class (for example, “INSTR”)
as defined by the canonical resource name.
VISA Attribute:VI_ATTR_RSRC_CLASS (3221159937)
resource_info

Get the extended information of this resource.

Parameters:resource_name – Unique symbolic name of a resource.
Return type:pyvisa.highlevel.ResourceInfo
resource_manufacturer_name
VI_ATTR_RSRC_MANF_NAME is a string that corresponds to the manufacturer

name of the vendor that implemented the VISA library. This attribute is not related to the device manufacturer attributes.

Note The value of this attribute is for display purposes only and not for programmatic decisions, as the value can differ between VISA implementations and/or revisions.

VISA Attribute:VI_ATTR_RSRC_MANF_NAME (3221160308)
resource_name
VI_ATTR_RSRC_MANF_NAME is a string that corresponds to the manufacturer

name of the vendor that implemented the VISA library. This attribute is not related to the device manufacturer attributes.

Note The value of this attribute is for display purposes only and not for programmatic decisions, as the value can differ between VISA implementations and/or revisions.

VISA Attribute:VI_ATTR_RSRC_NAME (3221159938)
secondary_address
VI_ATTR_GPIB_SECONDARY_ADDR specifies the secondary address of the
GPIB device used by the given session. For the GPIB INTFC Resource, this attribute is Read-Write.
VISA Attribute:VI_ATTR_GPIB_SECONDARY_ADDR (1073676659)
Type:int
Range:0 <= value <= 30 or in [65535]
send_command(data)

Write GPIB command bytes on the bus.

Corresponds to viGpibCommand function of the VISA library.

Parameters:data (bytes) – data tor write.
Returns:Number of written bytes, return value of the library call.
Return type:int, VISAStatus
send_end
VI_ATTR_SEND_END_EN specifies whether to assert END during the
transfer of the last byte of the buffer.
VISA Attribute:VI_ATTR_SEND_END_EN (1073676310)
Type:bool
send_ifc()

Pulse the interface clear line (IFC) for at least 100 microseconds.

Corresponds to viGpibSendIFC function of the VISA library.

Returns:return value of the library call.
Return type:VISAStatus
session

Resource session handle.

Raises:pyvisa.errors.InvalidSession if session is closed.
set_visa_attribute(name, state)

Sets the state of an attribute.

Parameters:
  • name – Attribute for which the state is to be modified. (Attributes.*)
  • state – The state of the attribute to be set for the specified object.
spec_version
VI_ATTR_RSRC_SPEC_VERSION is the resource version that uniquely identifies
the version of the VISA specification to which the implementation is compliant. The format of the value has the upper 12 bits as the major number of the version, the next lower 12 bits as the minor number of the version, and the lowest 8 bits as the sub-minor number of the version. The current VISA specification defines the value to be 00300000h.
VISA Attribute:VI_ATTR_RSRC_SPEC_VERSION (1073676656)
Type:int
Range:0 <= value <= 4294967295
stb

Service request status register.

timeout

The timeout in milliseconds for all resource I/O operations.

None is mapped to VI_TMO_INFINITE. A value less than 1 is mapped to VI_TMO_IMMEDIATE.

uninstall_handler(event_type, handler, user_handle=None)

Uninstalls handlers for events in this resource.

Parameters:
  • event_type – Logical event identifier.
  • handler – Interpreted as a valid reference to a handler to be uninstalled by a client application.
  • user_handle – A value specified by an application that can be used for identifying handlers uniquely in a session for an event.
unlock()

Relinquishes a lock for the specified resource.

values_format
wait_for_srq(timeout=25000)[source]

Wait for a serial request (SRQ) coming from the instrument.

Note that this method is not ended when another instrument signals an SRQ, only this instrument.

Parameters:timeout – the maximum waiting time in milliseconds. Defaul: 25000 (seconds). None means waiting forever if necessary.
write(message, termination=None, encoding=None)

Write a string message to the device.

The write_termination is always appended to it.

Parameters:message (unicode (Py2) or str (Py3)) – the message to be sent.
Returns:number of bytes written.
Return type:int
write_ascii_values(message, values, converter=u'f', separator=u', ', termination=None, encoding=None)

Write a string message to the device followed by values in ascii format.

The write_termination is always appended to it.

Parameters:
  • message (unicode (Py2) or str (Py3)) – the message to be sent.
  • values – data to be writen to the device.
  • converter (callable | str) – function used to convert each value. String formatting codes are also accepted. Defaults to str.
  • separator – a callable that split the str into individual elements. If a str is given, data.split(separator) is used.
Type:

separator: (collections.Iterable[T]) -> str | str

Returns:

number of bytes written.

Return type:

int

write_binary_values(message, values, datatype=u'f', is_big_endian=False, termination=None, encoding=None)

Write a string message to the device followed by values in binary format.

The write_termination is always appended to it.

Parameters:
  • message (unicode (Py2) or str (Py3)) – the message to be sent.
  • values – data to be writen to the device.
  • datatype – the format string for a single element. See struct module.
  • is_big_endian – boolean indicating endianess.
Returns:

number of bytes written.

Return type:

int

write_raw(message)

Write a byte message to the device.

Parameters:message (bytes) – the message to be sent.
Returns:number of bytes written.
Return type:int
write_termination

Writer termination character.

write_values(message, values, termination=None, encoding=None)
class pyvisa.resources.GPIBInterface(resource_manager, resource_name)[source]

Communicates with to devices of type GPIB::INTFC

More complex resource names can be specified with the following grammar:
GPIB[board]::INTFC

Do not instantiate directly, use pyvisa.highlevel.ResourceManager.open_resource().

address_state
This attribute shows whether the specified GPIB interface is currently
addressed to talk or listen, or is not addressed.
VISA Attribute:VI_ATTR_GPIB_ADDR_STATE (1073676380)
Type::class:pyvisa.constants.AddressState
allow_dma
This attribute specifies whether I/O accesses should use DMA (VI_TRUE)
or Programmed I/O (VI_FALSE). In some implementations, this attribute may have global effects even though it is documented to be a local attribute. Since this affects performance and not functionality, that behavior is acceptable.
VISA Attribute:VI_ATTR_DMA_ALLOW_EN (1073676318)
Type:bool
assert_trigger()

Sends a software trigger to the device.

atn_state
This attribute shows the current state of the GPIB ATN (ATtentioN)
interface line.
VISA Attribute:VI_ATTR_GPIB_ATN_STATE (1073676375)
Type::class:pyvisa.constants.LineState
before_close()

Called just before closing an instrument.

clear()

Clears this resource

close()

Closes the VISA session and marks the handle as invalid.

control_atn(mode)

Specifies the state of the ATN line and the local active controller state.

Corresponds to viGpibControlATN function of the VISA library.

Parameters:mode – Specifies the state of the ATN line and optionally the local active controller state. (Constants.GPIB_ATN*)
Returns:return value of the library call.
Return type:VISAStatus
control_ren(mode)

Controls the state of the GPIB Remote Enable (REN) interface line, and optionally the remote/local state of the device.

Corresponds to viGpibControlREN function of the VISA library.

Parameters:mode – Specifies the state of the REN line and optionally the device remote/local state. (Constants.GPIB_REN*)
Returns:return value of the library call.
Return type:VISAStatus
get_visa_attribute(name)

Retrieves the state of an attribute in this resource.

Parameters:name – Resource attribute for which the state query is made (see Attributes.*)
Returns:The state of the queried attribute for a specified resource.
Return type:unicode (Py2) or str (Py3), list or other type
group_execute_trigger(*resources)[source]
implementation_version
VI_ATTR_RSRC_IMPL_VERSION is the resource version that uniquely identifies
each of the different revisions or implementations of a resource. This attribute value is defined by the individual manufacturer and increments with each new revision. The format of the value has the upper 12 bits as the major number of the version, the next lower 12 bits as the minor number of the version, and the lowest 8 bits as the sub-minor number of the version.
VISA Attribute:VI_ATTR_RSRC_IMPL_VERSION (1073676291)
Type:int
Range:0 <= value <= 4294967295
install_handler(event_type, handler, user_handle=None)

Installs handlers for event callbacks in this resource.

Parameters:
  • event_type – Logical event identifier.
  • handler – Interpreted as a valid reference to a handler to be installed by a client application.
  • user_handle – A value specified by an application that can be used for identifying handlers uniquely for an event type.
Returns:

user handle (a ctypes object)

interface_number

VI_ATTR_INTF_NUM specifies the board number for the given interface.

VISA Attribute:VI_ATTR_INTF_NUM (1073676662)
Type:int
Range:0 <= value <= 65535
interface_type

The interface type of the resource as a number.

io_protocol
VI_ATTR_IO_PROT specifies which protocol to use. In VXI, you can
choose normal word serial or fast data channel (FDC). In GPIB, you can choose normal or high-speed (HS-488) transfers. In serial, TCPIP, or USB RAW, you can choose normal transfers or 488.2-defined strings. In USB INSTR, you can choose normal or vendor-specific transfers.
VISA Attribute:VI_ATTR_IO_PROT (1073676316)
Type:int
Range:0 <= value <= 65535
is_controller_in_charge
This attribute shows whether the specified GPIB interface is currently
CIC (Controller In Charge).
VISA Attribute:VI_ATTR_GPIB_CIC_STATE (1073676382)
Type:bool
is_system_controller
This attribute shows whether the specified GPIB interface is currently
the system controller. In some implementations, this attribute may be modified only through a configuration utility. On these systems this attribute is read-only (RO).
VISA Attribute:VI_ATTR_GPIB_SYS_CNTRL_STATE (1073676392)
Type:bool
last_status

Last status code for this session.

Return type:pyvisa.constants.StatusCode
lock(timeout=None, requested_key=None)

Establish a shared lock to the resource.

Parameters:
  • timeout – Absolute time period (in milliseconds) that a resource waits to get unlocked by the locking session before returning an error. (Defaults to self.timeout)
  • requested_key – Access key used by another session with which you want your session to share a lock or None to generate a new shared access key.
Returns:

A new shared access key if requested_key is None, otherwise, same value as the requested_key

lock_state
VI_ATTR_RSRC_LOCK_STATE indicates the current locking state of the
resource. The resource can be unlocked, locked with an exclusive lock, or locked with a shared lock.
VISA Attribute:VI_ATTR_RSRC_LOCK_STATE (1073676292)
Type::class:pyvisa.constants.AccessModes
ndac_state
This attribute shows the current state of the GPIB NDAC (Not Data
ACcepted) interface line.
VISA Attribute:VI_ATTR_GPIB_NDAC_STATE (1073676386)
Type::class:pyvisa.constants.LineState
open(access_mode=<AccessModes.no_lock: 0>, open_timeout=5000)

Opens a session to the specified resource.

Parameters:
  • access_mode (pyvisa.constants.AccessModes) – Specifies the mode by which the resource is to be accessed.
  • open_timeout (int) – Milliseconds before the open operation times out.
pass_control(primary_address, secondary_address)

Tell the GPIB device at the specified address to become controller in charge (CIC).

Corresponds to viGpibPassControl function of the VISA library.

Parameters:
  • primary_address – Primary address of the GPIB device to which you want to pass control.
  • secondary_address – Secondary address of the targeted GPIB device. If the targeted device does not have a secondary address, this parameter should contain the value Constants.NO_SEC_ADDR.
Returns:

return value of the library call.

Return type:

VISAStatus

primary_address
VI_ATTR_GPIB_PRIMARY_ADDR specifies the primary address of the GPIB
device used by the given session. For the GPIB INTFC Resource, this attribute is Read-Write.
VISA Attribute:VI_ATTR_GPIB_PRIMARY_ADDR (1073676658)
Type:int
Range:0 <= value <= 30
register(interface_type, resource_class)
remote_enabled
VI_ATTR_GPIB_REN_STATE returns the current state of the GPIB REN
(Remote ENable) interface line.
VISA Attribute:VI_ATTR_GPIB_REN_STATE (1073676673)
Type::class:pyvisa.constants.LineState
resource_class
VI_ATTR_RSRC_CLASS specifies the resource class (for example, “INSTR”)
as defined by the canonical resource name.
VISA Attribute:VI_ATTR_RSRC_CLASS (3221159937)
resource_info

Get the extended information of this resource.

Parameters:resource_name – Unique symbolic name of a resource.
Return type:pyvisa.highlevel.ResourceInfo
resource_manufacturer_name
VI_ATTR_RSRC_MANF_NAME is a string that corresponds to the manufacturer

name of the vendor that implemented the VISA library. This attribute is not related to the device manufacturer attributes.

Note The value of this attribute is for display purposes only and not for programmatic decisions, as the value can differ between VISA implementations and/or revisions.

VISA Attribute:VI_ATTR_RSRC_MANF_NAME (3221160308)
resource_name
VI_ATTR_RSRC_MANF_NAME is a string that corresponds to the manufacturer

name of the vendor that implemented the VISA library. This attribute is not related to the device manufacturer attributes.

Note The value of this attribute is for display purposes only and not for programmatic decisions, as the value can differ between VISA implementations and/or revisions.

VISA Attribute:VI_ATTR_RSRC_NAME (3221159938)
secondary_address
VI_ATTR_GPIB_SECONDARY_ADDR specifies the secondary address of the
GPIB device used by the given session. For the GPIB INTFC Resource, this attribute is Read-Write.
VISA Attribute:VI_ATTR_GPIB_SECONDARY_ADDR (1073676659)
Type:int
Range:0 <= value <= 30 or in [65535]
send_command(data)

Write GPIB command bytes on the bus.

Corresponds to viGpibCommand function of the VISA library.

Parameters:data (bytes) – data tor write.
Returns:Number of written bytes, return value of the library call.
Return type:int, VISAStatus
send_end
VI_ATTR_SEND_END_EN specifies whether to assert END during the
transfer of the last byte of the buffer.
VISA Attribute:VI_ATTR_SEND_END_EN (1073676310)
Type:bool
send_ifc()

Pulse the interface clear line (IFC) for at least 100 microseconds.

Corresponds to viGpibSendIFC function of the VISA library.

Returns:return value of the library call.
Return type:VISAStatus
session

Resource session handle.

Raises:pyvisa.errors.InvalidSession if session is closed.
set_visa_attribute(name, state)

Sets the state of an attribute.

Parameters:
  • name – Attribute for which the state is to be modified. (Attributes.*)
  • state – The state of the attribute to be set for the specified object.
spec_version
VI_ATTR_RSRC_SPEC_VERSION is the resource version that uniquely identifies
the version of the VISA specification to which the implementation is compliant. The format of the value has the upper 12 bits as the major number of the version, the next lower 12 bits as the minor number of the version, and the lowest 8 bits as the sub-minor number of the version. The current VISA specification defines the value to be 00300000h.
VISA Attribute:VI_ATTR_RSRC_SPEC_VERSION (1073676656)
Type:int
Range:0 <= value <= 4294967295
timeout

The timeout in milliseconds for all resource I/O operations.

None is mapped to VI_TMO_INFINITE. A value less than 1 is mapped to VI_TMO_IMMEDIATE.

uninstall_handler(event_type, handler, user_handle=None)

Uninstalls handlers for events in this resource.

Parameters:
  • event_type – Logical event identifier.
  • handler – Interpreted as a valid reference to a handler to be uninstalled by a client application.
  • user_handle – A value specified by an application that can be used for identifying handlers uniquely in a session for an event.
unlock()

Relinquishes a lock for the specified resource.

class pyvisa.resources.FirewireInstrument(resource_manager, resource_name)[source]

Communicates with to devices of type VXI::VXI logical address[::INSTR]

More complex resource names can be specified with the following grammar:
VXI[board]::VXI logical address[::INSTR]

Do not instantiate directly, use pyvisa.highlevel.ResourceManager.open_resource().

before_close()

Called just before closing an instrument.

clear()

Clears this resource

close()

Closes the VISA session and marks the handle as invalid.

get_visa_attribute(name)

Retrieves the state of an attribute in this resource.

Parameters:name – Resource attribute for which the state query is made (see Attributes.*)
Returns:The state of the queried attribute for a specified resource.
Return type:unicode (Py2) or str (Py3), list or other type
implementation_version
VI_ATTR_RSRC_IMPL_VERSION is the resource version that uniquely identifies
each of the different revisions or implementations of a resource. This attribute value is defined by the individual manufacturer and increments with each new revision. The format of the value has the upper 12 bits as the major number of the version, the next lower 12 bits as the minor number of the version, and the lowest 8 bits as the sub-minor number of the version.
VISA Attribute:VI_ATTR_RSRC_IMPL_VERSION (1073676291)
Type:int
Range:0 <= value <= 4294967295
install_handler(event_type, handler, user_handle=None)

Installs handlers for event callbacks in this resource.

Parameters:
  • event_type – Logical event identifier.
  • handler – Interpreted as a valid reference to a handler to be installed by a client application.
  • user_handle – A value specified by an application that can be used for identifying handlers uniquely for an event type.
Returns:

user handle (a ctypes object)

interface_number

VI_ATTR_INTF_NUM specifies the board number for the given interface.

VISA Attribute:VI_ATTR_INTF_NUM (1073676662)
Type:int
Range:0 <= value <= 65535
interface_type

The interface type of the resource as a number.

last_status

Last status code for this session.

Return type:pyvisa.constants.StatusCode
lock(timeout=None, requested_key=None)

Establish a shared lock to the resource.

Parameters:
  • timeout – Absolute time period (in milliseconds) that a resource waits to get unlocked by the locking session before returning an error. (Defaults to self.timeout)
  • requested_key – Access key used by another session with which you want your session to share a lock or None to generate a new shared access key.
Returns:

A new shared access key if requested_key is None, otherwise, same value as the requested_key

lock_state
VI_ATTR_RSRC_LOCK_STATE indicates the current locking state of the
resource. The resource can be unlocked, locked with an exclusive lock, or locked with a shared lock.
VISA Attribute:VI_ATTR_RSRC_LOCK_STATE (1073676292)
Type::class:pyvisa.constants.AccessModes
move_in(space, offset, length, width, extended=False)

Moves a block of data to local memory from the specified address space and offset.

Parameters:
  • space – Specifies the address space. (Constants.*SPACE*)
  • offset – Offset (in bytes) of the address or register from which to read.
  • length – Number of elements to transfer, where the data width of the elements to transfer is identical to the source data width.
  • width – Number of bits to read per element.
  • extended – Use 64 bits offset independent of the platform.
move_out(space, offset, length, data, width, extended=False)

Moves a block of data from local memory to the specified address space and offset.

Parameters:
  • space – Specifies the address space. (Constants.*SPACE*)
  • offset – Offset (in bytes) of the address or register from which to read.
  • length – Number of elements to transfer, where the data width of the elements to transfer is identical to the source data width.
  • data – Data to write to bus.
  • width – Number of bits to read per element.
  • extended – Use 64 bits offset independent of the platform.
open(access_mode=<AccessModes.no_lock: 0>, open_timeout=5000)

Opens a session to the specified resource.

Parameters:
  • access_mode (pyvisa.constants.AccessModes) – Specifies the mode by which the resource is to be accessed.
  • open_timeout (int) – Milliseconds before the open operation times out.
read_memory(space, offset, width, extended=False)

Reads in an 8-bit, 16-bit, 32-bit, or 64-bit value from the specified memory space and offset.

Parameters:
  • space – Specifies the address space. (Constants.*SPACE*)
  • offset – Offset (in bytes) of the address or register from which to read.
  • width – Number of bits to read.
  • extended – Use 64 bits offset independent of the platform.
Returns:

Data read from memory.

Corresponds to viIn* functions of the visa library.

register(interface_type, resource_class)
resource_class
VI_ATTR_RSRC_CLASS specifies the resource class (for example, “INSTR”)
as defined by the canonical resource name.
VISA Attribute:VI_ATTR_RSRC_CLASS (3221159937)
resource_info

Get the extended information of this resource.

Parameters:resource_name – Unique symbolic name of a resource.
Return type:pyvisa.highlevel.ResourceInfo
resource_manufacturer_name
VI_ATTR_RSRC_MANF_NAME is a string that corresponds to the manufacturer

name of the vendor that implemented the VISA library. This attribute is not related to the device manufacturer attributes.

Note The value of this attribute is for display purposes only and not for programmatic decisions, as the value can differ between VISA implementations and/or revisions.

VISA Attribute:VI_ATTR_RSRC_MANF_NAME (3221160308)
resource_name
VI_ATTR_RSRC_MANF_NAME is a string that corresponds to the manufacturer

name of the vendor that implemented the VISA library. This attribute is not related to the device manufacturer attributes.

Note The value of this attribute is for display purposes only and not for programmatic decisions, as the value can differ between VISA implementations and/or revisions.

VISA Attribute:VI_ATTR_RSRC_NAME (3221159938)
session

Resource session handle.

Raises:pyvisa.errors.InvalidSession if session is closed.
set_visa_attribute(name, state)

Sets the state of an attribute.

Parameters:
  • name – Attribute for which the state is to be modified. (Attributes.*)
  • state – The state of the attribute to be set for the specified object.
spec_version
VI_ATTR_RSRC_SPEC_VERSION is the resource version that uniquely identifies
the version of the VISA specification to which the implementation is compliant. The format of the value has the upper 12 bits as the major number of the version, the next lower 12 bits as the minor number of the version, and the lowest 8 bits as the sub-minor number of the version. The current VISA specification defines the value to be 00300000h.
VISA Attribute:VI_ATTR_RSRC_SPEC_VERSION (1073676656)
Type:int
Range:0 <= value <= 4294967295
timeout

The timeout in milliseconds for all resource I/O operations.

None is mapped to VI_TMO_INFINITE. A value less than 1 is mapped to VI_TMO_IMMEDIATE.

uninstall_handler(event_type, handler, user_handle=None)

Uninstalls handlers for events in this resource.

Parameters:
  • event_type – Logical event identifier.
  • handler – Interpreted as a valid reference to a handler to be uninstalled by a client application.
  • user_handle – A value specified by an application that can be used for identifying handlers uniquely in a session for an event.
unlock()

Relinquishes a lock for the specified resource.

write_memory(space, offset, data, width, extended=False)

Write in an 8-bit, 16-bit, 32-bit, value to the specified memory space and offset.

Parameters:
  • space – Specifies the address space. (Constants.*SPACE*)
  • offset – Offset (in bytes) of the address or register from which to read.
  • data – Data to write to bus.
  • width – Number of bits to read.
  • extended – Use 64 bits offset independent of the platform.

Corresponds to viOut* functions of the visa library.

class pyvisa.resources.PXIInstrument(resource_manager, resource_name)[source]

Communicates with to devices of type PXI::<device>[::INSTR]

More complex resource names can be specified with the following grammar:
PXI[bus]::device[::function][::INSTR]
or:
PXI[interface]::bus-device[.function][::INSTR]
or:
PXI[interface]::CHASSISchassis number::SLOTslot number[::FUNCfunction][::INSTR]

Do not instantiate directly, use pyvisa.highlevel.ResourceManager.open_resource().

allow_dma
This attribute specifies whether I/O accesses should use DMA (VI_TRUE)
or Programmed I/O (VI_FALSE). In some implementations, this attribute may have global effects even though it is documented to be a local attribute. Since this affects performance and not functionality, that behavior is acceptable.
VISA Attribute:VI_ATTR_DMA_ALLOW_EN (1073676318)
Type:bool
before_close()

Called just before closing an instrument.

clear()

Clears this resource

close()

Closes the VISA session and marks the handle as invalid.

destination_increment
VI_ATTR_DEST_INCREMENT is used in the viMoveOutXX() operations to
specify by how many elements the destination offset is to be incremented after every transfer. The default value of this attribute is 1 (that is, the destination address will be incremented by 1 after each transfer), and the viMoveOutXX() operations move into consecutive elements. If this attribute is set to 0, the viMoveOutXX() operations will always write to the same element, essentially treating the destination as a FIFO register.
VISA Attribute:VI_ATTR_DEST_INCREMENT (1073676353)
Type:int
Range:0 <= value <= 1
get_visa_attribute(name)

Retrieves the state of an attribute in this resource.

Parameters:name – Resource attribute for which the state query is made (see Attributes.*)
Returns:The state of the queried attribute for a specified resource.
Return type:unicode (Py2) or str (Py3), list or other type
implementation_version
VI_ATTR_RSRC_IMPL_VERSION is the resource version that uniquely identifies
each of the different revisions or implementations of a resource. This attribute value is defined by the individual manufacturer and increments with each new revision. The format of the value has the upper 12 bits as the major number of the version, the next lower 12 bits as the minor number of the version, and the lowest 8 bits as the sub-minor number of the version.
VISA Attribute:VI_ATTR_RSRC_IMPL_VERSION (1073676291)
Type:int
Range:0 <= value <= 4294967295
install_handler(event_type, handler, user_handle=None)

Installs handlers for event callbacks in this resource.

Parameters:
  • event_type – Logical event identifier.
  • handler – Interpreted as a valid reference to a handler to be installed by a client application.
  • user_handle – A value specified by an application that can be used for identifying handlers uniquely for an event type.
Returns:

user handle (a ctypes object)

interface_number

VI_ATTR_INTF_NUM specifies the board number for the given interface.

VISA Attribute:VI_ATTR_INTF_NUM (1073676662)
Type:int
Range:0 <= value <= 65535
interface_type

The interface type of the resource as a number.

last_status

Last status code for this session.

Return type:pyvisa.constants.StatusCode
lock(timeout=None, requested_key=None)

Establish a shared lock to the resource.

Parameters:
  • timeout – Absolute time period (in milliseconds) that a resource waits to get unlocked by the locking session before returning an error. (Defaults to self.timeout)
  • requested_key – Access key used by another session with which you want your session to share a lock or None to generate a new shared access key.
Returns:

A new shared access key if requested_key is None, otherwise, same value as the requested_key

lock_state
VI_ATTR_RSRC_LOCK_STATE indicates the current locking state of the
resource. The resource can be unlocked, locked with an exclusive lock, or locked with a shared lock.
VISA Attribute:VI_ATTR_RSRC_LOCK_STATE (1073676292)
Type::class:pyvisa.constants.AccessModes
manufacturer_id
VI_ATTR_MANF_ID is the manufacturer identification number of the
device.
VISA Attribute:VI_ATTR_MANF_ID (1073676505)
Type:int
Range:0 <= value <= 65535
manufacturer_name

This string attribute is the manufacturer name.

VISA Attribute:VI_ATTR_MANF_NAME (3221160050)
model_code

VI_ATTR_MODEL_CODE specifies the model code for the device.

VISA Attribute:VI_ATTR_MODEL_CODE (1073676511)
Type:int
Range:0 <= value <= 65535
model_name

This string attribute is the model name of the device.

VISA Attribute:VI_ATTR_MODEL_NAME (3221160055)
move_in(space, offset, length, width, extended=False)

Moves a block of data to local memory from the specified address space and offset.

Parameters:
  • space – Specifies the address space. (Constants.*SPACE*)
  • offset – Offset (in bytes) of the address or register from which to read.
  • length – Number of elements to transfer, where the data width of the elements to transfer is identical to the source data width.
  • width – Number of bits to read per element.
  • extended – Use 64 bits offset independent of the platform.
move_out(space, offset, length, data, width, extended=False)

Moves a block of data from local memory to the specified address space and offset.

Parameters:
  • space – Specifies the address space. (Constants.*SPACE*)
  • offset – Offset (in bytes) of the address or register from which to read.
  • length – Number of elements to transfer, where the data width of the elements to transfer is identical to the source data width.
  • data – Data to write to bus.
  • width – Number of bits to read per element.
  • extended – Use 64 bits offset independent of the platform.
open(access_mode=<AccessModes.no_lock: 0>, open_timeout=5000)

Opens a session to the specified resource.

Parameters:
  • access_mode (pyvisa.constants.AccessModes) – Specifies the mode by which the resource is to be accessed.
  • open_timeout (int) – Milliseconds before the open operation times out.
read_memory(space, offset, width, extended=False)

Reads in an 8-bit, 16-bit, 32-bit, or 64-bit value from the specified memory space and offset.

Parameters:
  • space – Specifies the address space. (Constants.*SPACE*)
  • offset – Offset (in bytes) of the address or register from which to read.
  • width – Number of bits to read.
  • extended – Use 64 bits offset independent of the platform.
Returns:

Data read from memory.

Corresponds to viIn* functions of the visa library.

register(interface_type, resource_class)
resource_class
VI_ATTR_RSRC_CLASS specifies the resource class (for example, “INSTR”)
as defined by the canonical resource name.
VISA Attribute:VI_ATTR_RSRC_CLASS (3221159937)
resource_info

Get the extended information of this resource.

Parameters:resource_name – Unique symbolic name of a resource.
Return type:pyvisa.highlevel.ResourceInfo
resource_manufacturer_name
VI_ATTR_RSRC_MANF_NAME is a string that corresponds to the manufacturer

name of the vendor that implemented the VISA library. This attribute is not related to the device manufacturer attributes.

Note The value of this attribute is for display purposes only and not for programmatic decisions, as the value can differ between VISA implementations and/or revisions.

VISA Attribute:VI_ATTR_RSRC_MANF_NAME (3221160308)
resource_name
VI_ATTR_RSRC_MANF_NAME is a string that corresponds to the manufacturer

name of the vendor that implemented the VISA library. This attribute is not related to the device manufacturer attributes.

Note The value of this attribute is for display purposes only and not for programmatic decisions, as the value can differ between VISA implementations and/or revisions.

VISA Attribute:VI_ATTR_RSRC_NAME (3221159938)
session

Resource session handle.

Raises:pyvisa.errors.InvalidSession if session is closed.
set_visa_attribute(name, state)

Sets the state of an attribute.

Parameters:
  • name – Attribute for which the state is to be modified. (Attributes.*)
  • state – The state of the attribute to be set for the specified object.
source_increment
VI_ATTR_SRC_INCREMENT is used in the viMoveInXX() operations to
specify by how many elements the source offset is to be incremented after every transfer. The default value of this attribute is 1 (that is, the source address will be incremented by 1 after each transfer), and the viMoveInXX() operations move from consecutive elements. If this attribute is set to 0, the viMoveInXX() operations will always read from the same element, essentially treating the source as a FIFO register.
VISA Attribute:VI_ATTR_SRC_INCREMENT (1073676352)
Type:int
Range:0 <= value <= 1
spec_version
VI_ATTR_RSRC_SPEC_VERSION is the resource version that uniquely identifies
the version of the VISA specification to which the implementation is compliant. The format of the value has the upper 12 bits as the major number of the version, the next lower 12 bits as the minor number of the version, and the lowest 8 bits as the sub-minor number of the version. The current VISA specification defines the value to be 00300000h.
VISA Attribute:VI_ATTR_RSRC_SPEC_VERSION (1073676656)
Type:int
Range:0 <= value <= 4294967295
timeout

The timeout in milliseconds for all resource I/O operations.

None is mapped to VI_TMO_INFINITE. A value less than 1 is mapped to VI_TMO_IMMEDIATE.

uninstall_handler(event_type, handler, user_handle=None)

Uninstalls handlers for events in this resource.

Parameters:
  • event_type – Logical event identifier.
  • handler – Interpreted as a valid reference to a handler to be uninstalled by a client application.
  • user_handle – A value specified by an application that can be used for identifying handlers uniquely in a session for an event.
unlock()

Relinquishes a lock for the specified resource.

write_memory(space, offset, data, width, extended=False)

Write in an 8-bit, 16-bit, 32-bit, value to the specified memory space and offset.

Parameters:
  • space – Specifies the address space. (Constants.*SPACE*)
  • offset – Offset (in bytes) of the address or register from which to read.
  • data – Data to write to bus.
  • width – Number of bits to read.
  • extended – Use 64 bits offset independent of the platform.

Corresponds to viOut* functions of the visa library.

class pyvisa.resources.PXIMemory(resource_manager, resource_name)[source]

Communicates with to devices of type PXI[interface]::MEMACC

Do not instantiate directly, use pyvisa.highlevel.ResourceManager.open_resource().

before_close()

Called just before closing an instrument.

clear()

Clears this resource

close()

Closes the VISA session and marks the handle as invalid.

destination_increment
VI_ATTR_DEST_INCREMENT is used in the viMoveOutXX() operations to
specify by how many elements the destination offset is to be incremented after every transfer. The default value of this attribute is 1 (that is, the destination address will be incremented by 1 after each transfer), and the viMoveOutXX() operations move into consecutive elements. If this attribute is set to 0, the viMoveOutXX() operations will always write to the same element, essentially treating the destination as a FIFO register.
VISA Attribute:VI_ATTR_DEST_INCREMENT (1073676353)
Type:int
Range:0 <= value <= 1
get_visa_attribute(name)

Retrieves the state of an attribute in this resource.

Parameters:name – Resource attribute for which the state query is made (see Attributes.*)
Returns:The state of the queried attribute for a specified resource.
Return type:unicode (Py2) or str (Py3), list or other type
implementation_version
VI_ATTR_RSRC_IMPL_VERSION is the resource version that uniquely identifies
each of the different revisions or implementations of a resource. This attribute value is defined by the individual manufacturer and increments with each new revision. The format of the value has the upper 12 bits as the major number of the version, the next lower 12 bits as the minor number of the version, and the lowest 8 bits as the sub-minor number of the version.
VISA Attribute:VI_ATTR_RSRC_IMPL_VERSION (1073676291)
Type:int
Range:0 <= value <= 4294967295
install_handler(event_type, handler, user_handle=None)

Installs handlers for event callbacks in this resource.

Parameters:
  • event_type – Logical event identifier.
  • handler – Interpreted as a valid reference to a handler to be installed by a client application.
  • user_handle – A value specified by an application that can be used for identifying handlers uniquely for an event type.
Returns:

user handle (a ctypes object)

interface_number

VI_ATTR_INTF_NUM specifies the board number for the given interface.

VISA Attribute:VI_ATTR_INTF_NUM (1073676662)
Type:int
Range:0 <= value <= 65535
interface_type

The interface type of the resource as a number.

last_status

Last status code for this session.

Return type:pyvisa.constants.StatusCode
lock(timeout=None, requested_key=None)

Establish a shared lock to the resource.

Parameters:
  • timeout – Absolute time period (in milliseconds) that a resource waits to get unlocked by the locking session before returning an error. (Defaults to self.timeout)
  • requested_key – Access key used by another session with which you want your session to share a lock or None to generate a new shared access key.
Returns:

A new shared access key if requested_key is None, otherwise, same value as the requested_key

lock_state
VI_ATTR_RSRC_LOCK_STATE indicates the current locking state of the
resource. The resource can be unlocked, locked with an exclusive lock, or locked with a shared lock.
VISA Attribute:VI_ATTR_RSRC_LOCK_STATE (1073676292)
Type::class:pyvisa.constants.AccessModes
move_in(space, offset, length, width, extended=False)

Moves a block of data to local memory from the specified address space and offset.

Parameters:
  • space – Specifies the address space. (Constants.*SPACE*)
  • offset – Offset (in bytes) of the address or register from which to read.
  • length – Number of elements to transfer, where the data width of the elements to transfer is identical to the source data width.
  • width – Number of bits to read per element.
  • extended – Use 64 bits offset independent of the platform.
move_out(space, offset, length, data, width, extended=False)

Moves a block of data from local memory to the specified address space and offset.

Parameters:
  • space – Specifies the address space. (Constants.*SPACE*)
  • offset – Offset (in bytes) of the address or register from which to read.
  • length – Number of elements to transfer, where the data width of the elements to transfer is identical to the source data width.
  • data – Data to write to bus.
  • width – Number of bits to read per element.
  • extended – Use 64 bits offset independent of the platform.
open(access_mode=<AccessModes.no_lock: 0>, open_timeout=5000)

Opens a session to the specified resource.

Parameters:
  • access_mode (pyvisa.constants.AccessModes) – Specifies the mode by which the resource is to be accessed.
  • open_timeout (int) – Milliseconds before the open operation times out.
read_memory(space, offset, width, extended=False)

Reads in an 8-bit, 16-bit, 32-bit, or 64-bit value from the specified memory space and offset.

Parameters:
  • space – Specifies the address space. (Constants.*SPACE*)
  • offset – Offset (in bytes) of the address or register from which to read.
  • width – Number of bits to read.
  • extended – Use 64 bits offset independent of the platform.
Returns:

Data read from memory.

Corresponds to viIn* functions of the visa library.

register(interface_type, resource_class)
resource_class
VI_ATTR_RSRC_CLASS specifies the resource class (for example, “INSTR”)
as defined by the canonical resource name.
VISA Attribute:VI_ATTR_RSRC_CLASS (3221159937)
resource_info

Get the extended information of this resource.

Parameters:resource_name – Unique symbolic name of a resource.
Return type:pyvisa.highlevel.ResourceInfo
resource_manufacturer_name
VI_ATTR_RSRC_MANF_NAME is a string that corresponds to the manufacturer

name of the vendor that implemented the VISA library. This attribute is not related to the device manufacturer attributes.

Note The value of this attribute is for display purposes only and not for programmatic decisions, as the value can differ between VISA implementations and/or revisions.

VISA Attribute:VI_ATTR_RSRC_MANF_NAME (3221160308)
resource_name
VI_ATTR_RSRC_MANF_NAME is a string that corresponds to the manufacturer

name of the vendor that implemented the VISA library. This attribute is not related to the device manufacturer attributes.

Note The value of this attribute is for display purposes only and not for programmatic decisions, as the value can differ between VISA implementations and/or revisions.

VISA Attribute:VI_ATTR_RSRC_NAME (3221159938)
session

Resource session handle.

Raises:pyvisa.errors.InvalidSession if session is closed.
set_visa_attribute(name, state)

Sets the state of an attribute.

Parameters:
  • name – Attribute for which the state is to be modified. (Attributes.*)
  • state – The state of the attribute to be set for the specified object.
source_increment
VI_ATTR_SRC_INCREMENT is used in the viMoveInXX() operations to
specify by how many elements the source offset is to be incremented after every transfer. The default value of this attribute is 1 (that is, the source address will be incremented by 1 after each transfer), and the viMoveInXX() operations move from consecutive elements. If this attribute is set to 0, the viMoveInXX() operations will always read from the same element, essentially treating the source as a FIFO register.
VISA Attribute:VI_ATTR_SRC_INCREMENT (1073676352)
Type:int
Range:0 <= value <= 1
spec_version
VI_ATTR_RSRC_SPEC_VERSION is the resource version that uniquely identifies
the version of the VISA specification to which the implementation is compliant. The format of the value has the upper 12 bits as the major number of the version, the next lower 12 bits as the minor number of the version, and the lowest 8 bits as the sub-minor number of the version. The current VISA specification defines the value to be 00300000h.
VISA Attribute:VI_ATTR_RSRC_SPEC_VERSION (1073676656)
Type:int
Range:0 <= value <= 4294967295
timeout

The timeout in milliseconds for all resource I/O operations.

None is mapped to VI_TMO_INFINITE. A value less than 1 is mapped to VI_TMO_IMMEDIATE.

uninstall_handler(event_type, handler, user_handle=None)

Uninstalls handlers for events in this resource.

Parameters:
  • event_type – Logical event identifier.
  • handler – Interpreted as a valid reference to a handler to be uninstalled by a client application.
  • user_handle – A value specified by an application that can be used for identifying handlers uniquely in a session for an event.
unlock()

Relinquishes a lock for the specified resource.

write_memory(space, offset, data, width, extended=False)

Write in an 8-bit, 16-bit, 32-bit, value to the specified memory space and offset.

Parameters:
  • space – Specifies the address space. (Constants.*SPACE*)
  • offset – Offset (in bytes) of the address or register from which to read.
  • data – Data to write to bus.
  • width – Number of bits to read.
  • extended – Use 64 bits offset independent of the platform.

Corresponds to viOut* functions of the visa library.

class pyvisa.resources.VXIInstrument(resource_manager, resource_name)[source]

Communicates with to devices of type VXI::VXI logical address[::INSTR]

More complex resource names can be specified with the following grammar:
VXI[board]::VXI logical address[::INSTR]

Do not instantiate directly, use pyvisa.highlevel.ResourceManager.open_resource().

allow_dma
This attribute specifies whether I/O accesses should use DMA (VI_TRUE)
or Programmed I/O (VI_FALSE). In some implementations, this attribute may have global effects even though it is documented to be a local attribute. Since this affects performance and not functionality, that behavior is acceptable.
VISA Attribute:VI_ATTR_DMA_ALLOW_EN (1073676318)
Type:bool
before_close()

Called just before closing an instrument.

clear()

Clears this resource

close()

Closes the VISA session and marks the handle as invalid.

destination_increment
VI_ATTR_DEST_INCREMENT is used in the viMoveOutXX() operations to
specify by how many elements the destination offset is to be incremented after every transfer. The default value of this attribute is 1 (that is, the destination address will be incremented by 1 after each transfer), and the viMoveOutXX() operations move into consecutive elements. If this attribute is set to 0, the viMoveOutXX() operations will always write to the same element, essentially treating the destination as a FIFO register.
VISA Attribute:VI_ATTR_DEST_INCREMENT (1073676353)
Type:int
Range:0 <= value <= 1
get_visa_attribute(name)

Retrieves the state of an attribute in this resource.

Parameters:name – Resource attribute for which the state query is made (see Attributes.*)
Returns:The state of the queried attribute for a specified resource.
Return type:unicode (Py2) or str (Py3), list or other type
implementation_version
VI_ATTR_RSRC_IMPL_VERSION is the resource version that uniquely identifies
each of the different revisions or implementations of a resource. This attribute value is defined by the individual manufacturer and increments with each new revision. The format of the value has the upper 12 bits as the major number of the version, the next lower 12 bits as the minor number of the version, and the lowest 8 bits as the sub-minor number of the version.
VISA Attribute:VI_ATTR_RSRC_IMPL_VERSION (1073676291)
Type:int
Range:0 <= value <= 4294967295
install_handler(event_type, handler, user_handle=None)

Installs handlers for event callbacks in this resource.

Parameters:
  • event_type – Logical event identifier.
  • handler – Interpreted as a valid reference to a handler to be installed by a client application.
  • user_handle – A value specified by an application that can be used for identifying handlers uniquely for an event type.
Returns:

user handle (a ctypes object)

interface_number

VI_ATTR_INTF_NUM specifies the board number for the given interface.

VISA Attribute:VI_ATTR_INTF_NUM (1073676662)
Type:int
Range:0 <= value <= 65535
interface_type

The interface type of the resource as a number.

io_protocol
VI_ATTR_IO_PROT specifies which protocol to use. In VXI, you can
choose normal word serial or fast data channel (FDC). In GPIB, you can choose normal or high-speed (HS-488) transfers. In serial, TCPIP, or USB RAW, you can choose normal transfers or 488.2-defined strings. In USB INSTR, you can choose normal or vendor-specific transfers.
VISA Attribute:VI_ATTR_IO_PROT (1073676316)
Type:int
Range:0 <= value <= 65535
is_4882_compliant
VI_ATTR_4882_COMPLIANT specifies whether the device is 488.2
compliant.
VISA Attribute:VI_ATTR_4882_COMPLIANT (1073676703)
Type:bool
last_status

Last status code for this session.

Return type:pyvisa.constants.StatusCode
lock(timeout=None, requested_key=None)

Establish a shared lock to the resource.

Parameters:
  • timeout – Absolute time period (in milliseconds) that a resource waits to get unlocked by the locking session before returning an error. (Defaults to self.timeout)
  • requested_key – Access key used by another session with which you want your session to share a lock or None to generate a new shared access key.
Returns:

A new shared access key if requested_key is None, otherwise, same value as the requested_key

lock_state
VI_ATTR_RSRC_LOCK_STATE indicates the current locking state of the
resource. The resource can be unlocked, locked with an exclusive lock, or locked with a shared lock.
VISA Attribute:VI_ATTR_RSRC_LOCK_STATE (1073676292)
Type::class:pyvisa.constants.AccessModes
manufacturer_id
VI_ATTR_MANF_ID is the manufacturer identification number of the
device.
VISA Attribute:VI_ATTR_MANF_ID (1073676505)
Type:int
Range:0 <= value <= 65535
manufacturer_name

This string attribute is the manufacturer name.

VISA Attribute:VI_ATTR_MANF_NAME (3221160050)
model_code

VI_ATTR_MODEL_CODE specifies the model code for the device.

VISA Attribute:VI_ATTR_MODEL_CODE (1073676511)
Type:int
Range:0 <= value <= 65535
model_name

This string attribute is the model name of the device.

VISA Attribute:VI_ATTR_MODEL_NAME (3221160055)
open(access_mode=<AccessModes.no_lock: 0>, open_timeout=5000)

Opens a session to the specified resource.

Parameters:
  • access_mode (pyvisa.constants.AccessModes) – Specifies the mode by which the resource is to be accessed.
  • open_timeout (int) – Milliseconds before the open operation times out.
register(interface_type, resource_class)
resource_class
VI_ATTR_RSRC_CLASS specifies the resource class (for example, “INSTR”)
as defined by the canonical resource name.
VISA Attribute:VI_ATTR_RSRC_CLASS (3221159937)
resource_info

Get the extended information of this resource.

Parameters:resource_name – Unique symbolic name of a resource.
Return type:pyvisa.highlevel.ResourceInfo
resource_manufacturer_name
VI_ATTR_RSRC_MANF_NAME is a string that corresponds to the manufacturer

name of the vendor that implemented the VISA library. This attribute is not related to the device manufacturer attributes.

Note The value of this attribute is for display purposes only and not for programmatic decisions, as the value can differ between VISA implementations and/or revisions.

VISA Attribute:VI_ATTR_RSRC_MANF_NAME (3221160308)
resource_name
VI_ATTR_RSRC_MANF_NAME is a string that corresponds to the manufacturer

name of the vendor that implemented the VISA library. This attribute is not related to the device manufacturer attributes.

Note The value of this attribute is for display purposes only and not for programmatic decisions, as the value can differ between VISA implementations and/or revisions.

VISA Attribute:VI_ATTR_RSRC_NAME (3221159938)
send_end
VI_ATTR_SEND_END_EN specifies whether to assert END during the
transfer of the last byte of the buffer.
VISA Attribute:VI_ATTR_SEND_END_EN (1073676310)
Type:bool
session

Resource session handle.

Raises:pyvisa.errors.InvalidSession if session is closed.
set_visa_attribute(name, state)

Sets the state of an attribute.

Parameters:
  • name – Attribute for which the state is to be modified. (Attributes.*)
  • state – The state of the attribute to be set for the specified object.
source_increment
VI_ATTR_SRC_INCREMENT is used in the viMoveInXX() operations to
specify by how many elements the source offset is to be incremented after every transfer. The default value of this attribute is 1 (that is, the source address will be incremented by 1 after each transfer), and the viMoveInXX() operations move from consecutive elements. If this attribute is set to 0, the viMoveInXX() operations will always read from the same element, essentially treating the source as a FIFO register.
VISA Attribute:VI_ATTR_SRC_INCREMENT (1073676352)
Type:int
Range:0 <= value <= 1
spec_version
VI_ATTR_RSRC_SPEC_VERSION is the resource version that uniquely identifies
the version of the VISA specification to which the implementation is compliant. The format of the value has the upper 12 bits as the major number of the version, the next lower 12 bits as the minor number of the version, and the lowest 8 bits as the sub-minor number of the version. The current VISA specification defines the value to be 00300000h.
VISA Attribute:VI_ATTR_RSRC_SPEC_VERSION (1073676656)
Type:int
Range:0 <= value <= 4294967295
timeout

The timeout in milliseconds for all resource I/O operations.

None is mapped to VI_TMO_INFINITE. A value less than 1 is mapped to VI_TMO_IMMEDIATE.

uninstall_handler(event_type, handler, user_handle=None)

Uninstalls handlers for events in this resource.

Parameters:
  • event_type – Logical event identifier.
  • handler – Interpreted as a valid reference to a handler to be uninstalled by a client application.
  • user_handle – A value specified by an application that can be used for identifying handlers uniquely in a session for an event.
unlock()

Relinquishes a lock for the specified resource.

class pyvisa.resources.VXIMemory(resource_manager, resource_name)[source]

Communicates with to devices of type VXI[board]::MEMACC

More complex resource names can be specified with the following grammar:
VXI[board]::MEMACC

Do not instantiate directly, use pyvisa.highlevel.ResourceManager.open_resource().

allow_dma
This attribute specifies whether I/O accesses should use DMA (VI_TRUE)
or Programmed I/O (VI_FALSE). In some implementations, this attribute may have global effects even though it is documented to be a local attribute. Since this affects performance and not functionality, that behavior is acceptable.
VISA Attribute:VI_ATTR_DMA_ALLOW_EN (1073676318)
Type:bool
before_close()

Called just before closing an instrument.

clear()

Clears this resource

close()

Closes the VISA session and marks the handle as invalid.

destination_increment
VI_ATTR_DEST_INCREMENT is used in the viMoveOutXX() operations to
specify by how many elements the destination offset is to be incremented after every transfer. The default value of this attribute is 1 (that is, the destination address will be incremented by 1 after each transfer), and the viMoveOutXX() operations move into consecutive elements. If this attribute is set to 0, the viMoveOutXX() operations will always write to the same element, essentially treating the destination as a FIFO register.
VISA Attribute:VI_ATTR_DEST_INCREMENT (1073676353)
Type:int
Range:0 <= value <= 1
get_visa_attribute(name)

Retrieves the state of an attribute in this resource.

Parameters:name – Resource attribute for which the state query is made (see Attributes.*)
Returns:The state of the queried attribute for a specified resource.
Return type:unicode (Py2) or str (Py3), list or other type
implementation_version
VI_ATTR_RSRC_IMPL_VERSION is the resource version that uniquely identifies
each of the different revisions or implementations of a resource. This attribute value is defined by the individual manufacturer and increments with each new revision. The format of the value has the upper 12 bits as the major number of the version, the next lower 12 bits as the minor number of the version, and the lowest 8 bits as the sub-minor number of the version.
VISA Attribute:VI_ATTR_RSRC_IMPL_VERSION (1073676291)
Type:int
Range:0 <= value <= 4294967295
install_handler(event_type, handler, user_handle=None)

Installs handlers for event callbacks in this resource.

Parameters:
  • event_type – Logical event identifier.
  • handler – Interpreted as a valid reference to a handler to be installed by a client application.
  • user_handle – A value specified by an application that can be used for identifying handlers uniquely for an event type.
Returns:

user handle (a ctypes object)

interface_number

VI_ATTR_INTF_NUM specifies the board number for the given interface.

VISA Attribute:VI_ATTR_INTF_NUM (1073676662)
Type:int
Range:0 <= value <= 65535
interface_type

The interface type of the resource as a number.

last_status

Last status code for this session.

Return type:pyvisa.constants.StatusCode
lock(timeout=None, requested_key=None)

Establish a shared lock to the resource.

Parameters:
  • timeout – Absolute time period (in milliseconds) that a resource waits to get unlocked by the locking session before returning an error. (Defaults to self.timeout)
  • requested_key – Access key used by another session with which you want your session to share a lock or None to generate a new shared access key.
Returns:

A new shared access key if requested_key is None, otherwise, same value as the requested_key

lock_state
VI_ATTR_RSRC_LOCK_STATE indicates the current locking state of the
resource. The resource can be unlocked, locked with an exclusive lock, or locked with a shared lock.
VISA Attribute:VI_ATTR_RSRC_LOCK_STATE (1073676292)
Type::class:pyvisa.constants.AccessModes
move_in(space, offset, length, width, extended=False)

Moves a block of data to local memory from the specified address space and offset.

Parameters:
  • space – Specifies the address space. (Constants.*SPACE*)
  • offset – Offset (in bytes) of the address or register from which to read.
  • length – Number of elements to transfer, where the data width of the elements to transfer is identical to the source data width.
  • width – Number of bits to read per element.
  • extended – Use 64 bits offset independent of the platform.
move_out(space, offset, length, data, width, extended=False)

Moves a block of data from local memory to the specified address space and offset.

Parameters:
  • space – Specifies the address space. (Constants.*SPACE*)
  • offset – Offset (in bytes) of the address or register from which to read.
  • length – Number of elements to transfer, where the data width of the elements to transfer is identical to the source data width.
  • data – Data to write to bus.
  • width – Number of bits to read per element.
  • extended – Use 64 bits offset independent of the platform.
open(access_mode=<AccessModes.no_lock: 0>, open_timeout=5000)

Opens a session to the specified resource.

Parameters:
  • access_mode (pyvisa.constants.AccessModes) – Specifies the mode by which the resource is to be accessed.
  • open_timeout (int) – Milliseconds before the open operation times out.
read_memory(space, offset, width, extended=False)

Reads in an 8-bit, 16-bit, 32-bit, or 64-bit value from the specified memory space and offset.

Parameters:
  • space – Specifies the address space. (Constants.*SPACE*)
  • offset – Offset (in bytes) of the address or register from which to read.
  • width – Number of bits to read.
  • extended – Use 64 bits offset independent of the platform.
Returns:

Data read from memory.

Corresponds to viIn* functions of the visa library.

register(interface_type, resource_class)
resource_class
VI_ATTR_RSRC_CLASS specifies the resource class (for example, “INSTR”)
as defined by the canonical resource name.
VISA Attribute:VI_ATTR_RSRC_CLASS (3221159937)
resource_info

Get the extended information of this resource.

Parameters:resource_name – Unique symbolic name of a resource.
Return type:pyvisa.highlevel.ResourceInfo
resource_manufacturer_name
VI_ATTR_RSRC_MANF_NAME is a string that corresponds to the manufacturer

name of the vendor that implemented the VISA library. This attribute is not related to the device manufacturer attributes.

Note The value of this attribute is for display purposes only and not for programmatic decisions, as the value can differ between VISA implementations and/or revisions.

VISA Attribute:VI_ATTR_RSRC_MANF_NAME (3221160308)
resource_name
VI_ATTR_RSRC_MANF_NAME is a string that corresponds to the manufacturer

name of the vendor that implemented the VISA library. This attribute is not related to the device manufacturer attributes.

Note The value of this attribute is for display purposes only and not for programmatic decisions, as the value can differ between VISA implementations and/or revisions.

VISA Attribute:VI_ATTR_RSRC_NAME (3221159938)
session

Resource session handle.

Raises:pyvisa.errors.InvalidSession if session is closed.
set_visa_attribute(name, state)

Sets the state of an attribute.

Parameters:
  • name – Attribute for which the state is to be modified. (Attributes.*)
  • state – The state of the attribute to be set for the specified object.
source_increment
VI_ATTR_SRC_INCREMENT is used in the viMoveInXX() operations to
specify by how many elements the source offset is to be incremented after every transfer. The default value of this attribute is 1 (that is, the source address will be incremented by 1 after each transfer), and the viMoveInXX() operations move from consecutive elements. If this attribute is set to 0, the viMoveInXX() operations will always read from the same element, essentially treating the source as a FIFO register.
VISA Attribute:VI_ATTR_SRC_INCREMENT (1073676352)
Type:int
Range:0 <= value <= 1
spec_version
VI_ATTR_RSRC_SPEC_VERSION is the resource version that uniquely identifies
the version of the VISA specification to which the implementation is compliant. The format of the value has the upper 12 bits as the major number of the version, the next lower 12 bits as the minor number of the version, and the lowest 8 bits as the sub-minor number of the version. The current VISA specification defines the value to be 00300000h.
VISA Attribute:VI_ATTR_RSRC_SPEC_VERSION (1073676656)
Type:int
Range:0 <= value <= 4294967295
timeout

The timeout in milliseconds for all resource I/O operations.

None is mapped to VI_TMO_INFINITE. A value less than 1 is mapped to VI_TMO_IMMEDIATE.

uninstall_handler(event_type, handler, user_handle=None)

Uninstalls handlers for events in this resource.

Parameters:
  • event_type – Logical event identifier.
  • handler – Interpreted as a valid reference to a handler to be uninstalled by a client application.
  • user_handle – A value specified by an application that can be used for identifying handlers uniquely in a session for an event.
unlock()

Relinquishes a lock for the specified resource.

write_memory(space, offset, data, width, extended=False)

Write in an 8-bit, 16-bit, 32-bit, value to the specified memory space and offset.

Parameters:
  • space – Specifies the address space. (Constants.*SPACE*)
  • offset – Offset (in bytes) of the address or register from which to read.
  • data – Data to write to bus.
  • width – Number of bits to read.
  • extended – Use 64 bits offset independent of the platform.

Corresponds to viOut* functions of the visa library.

class pyvisa.resources.VXIBackplane(resource_manager, resource_name)[source]

Communicates with to devices of type VXI::BACKPLANE

More complex resource names can be specified with the following grammar:
VXI[board][::VXI logical address]::BACKPLANE

Do not instantiate directly, use pyvisa.highlevel.ResourceManager.open_resource().

before_close()

Called just before closing an instrument.

clear()

Clears this resource

close()

Closes the VISA session and marks the handle as invalid.

get_visa_attribute(name)

Retrieves the state of an attribute in this resource.

Parameters:name – Resource attribute for which the state query is made (see Attributes.*)
Returns:The state of the queried attribute for a specified resource.
Return type:unicode (Py2) or str (Py3), list or other type
implementation_version
VI_ATTR_RSRC_IMPL_VERSION is the resource version that uniquely identifies
each of the different revisions or implementations of a resource. This attribute value is defined by the individual manufacturer and increments with each new revision. The format of the value has the upper 12 bits as the major number of the version, the next lower 12 bits as the minor number of the version, and the lowest 8 bits as the sub-minor number of the version.
VISA Attribute:VI_ATTR_RSRC_IMPL_VERSION (1073676291)
Type:int
Range:0 <= value <= 4294967295
install_handler(event_type, handler, user_handle=None)

Installs handlers for event callbacks in this resource.

Parameters:
  • event_type – Logical event identifier.
  • handler – Interpreted as a valid reference to a handler to be installed by a client application.
  • user_handle – A value specified by an application that can be used for identifying handlers uniquely for an event type.
Returns:

user handle (a ctypes object)

interface_number

VI_ATTR_INTF_NUM specifies the board number for the given interface.

VISA Attribute:VI_ATTR_INTF_NUM (1073676662)
Type:int
Range:0 <= value <= 65535
interface_type

The interface type of the resource as a number.

last_status

Last status code for this session.

Return type:pyvisa.constants.StatusCode
lock(timeout=None, requested_key=None)

Establish a shared lock to the resource.

Parameters:
  • timeout – Absolute time period (in milliseconds) that a resource waits to get unlocked by the locking session before returning an error. (Defaults to self.timeout)
  • requested_key – Access key used by another session with which you want your session to share a lock or None to generate a new shared access key.
Returns:

A new shared access key if requested_key is None, otherwise, same value as the requested_key

lock_state
VI_ATTR_RSRC_LOCK_STATE indicates the current locking state of the
resource. The resource can be unlocked, locked with an exclusive lock, or locked with a shared lock.
VISA Attribute:VI_ATTR_RSRC_LOCK_STATE (1073676292)
Type::class:pyvisa.constants.AccessModes
open(access_mode=<AccessModes.no_lock: 0>, open_timeout=5000)

Opens a session to the specified resource.

Parameters:
  • access_mode (pyvisa.constants.AccessModes) – Specifies the mode by which the resource is to be accessed.
  • open_timeout (int) – Milliseconds before the open operation times out.
register(interface_type, resource_class)
resource_class
VI_ATTR_RSRC_CLASS specifies the resource class (for example, “INSTR”)
as defined by the canonical resource name.
VISA Attribute:VI_ATTR_RSRC_CLASS (3221159937)
resource_info

Get the extended information of this resource.

Parameters:resource_name – Unique symbolic name of a resource.
Return type:pyvisa.highlevel.ResourceInfo
resource_manufacturer_name
VI_ATTR_RSRC_MANF_NAME is a string that corresponds to the manufacturer

name of the vendor that implemented the VISA library. This attribute is not related to the device manufacturer attributes.

Note The value of this attribute is for display purposes only and not for programmatic decisions, as the value can differ between VISA implementations and/or revisions.

VISA Attribute:VI_ATTR_RSRC_MANF_NAME (3221160308)
resource_name
VI_ATTR_RSRC_MANF_NAME is a string that corresponds to the manufacturer

name of the vendor that implemented the VISA library. This attribute is not related to the device manufacturer attributes.

Note The value of this attribute is for display purposes only and not for programmatic decisions, as the value can differ between VISA implementations and/or revisions.

VISA Attribute:VI_ATTR_RSRC_NAME (3221159938)
session

Resource session handle.

Raises:pyvisa.errors.InvalidSession if session is closed.
set_visa_attribute(name, state)

Sets the state of an attribute.

Parameters:
  • name – Attribute for which the state is to be modified. (Attributes.*)
  • state – The state of the attribute to be set for the specified object.
spec_version
VI_ATTR_RSRC_SPEC_VERSION is the resource version that uniquely identifies
the version of the VISA specification to which the implementation is compliant. The format of the value has the upper 12 bits as the major number of the version, the next lower 12 bits as the minor number of the version, and the lowest 8 bits as the sub-minor number of the version. The current VISA specification defines the value to be 00300000h.
VISA Attribute:VI_ATTR_RSRC_SPEC_VERSION (1073676656)
Type:int
Range:0 <= value <= 4294967295
timeout

The timeout in milliseconds for all resource I/O operations.

None is mapped to VI_TMO_INFINITE. A value less than 1 is mapped to VI_TMO_IMMEDIATE.

uninstall_handler(event_type, handler, user_handle=None)

Uninstalls handlers for events in this resource.

Parameters:
  • event_type – Logical event identifier.
  • handler – Interpreted as a valid reference to a handler to be uninstalled by a client application.
  • user_handle – A value specified by an application that can be used for identifying handlers uniquely in a session for an event.
unlock()

Relinquishes a lock for the specified resource.