Visa Library

class pyvisa.highlevel.VisaLibraryBase[source]

Base for VISA library classes.

A class derived from VisaLibraryBase library provides the low-level communication to the underlying devices providing Pythonic wrappers to VISA functions. But not all derived class must/will implement all methods. Even if methods are expected to return the status code they are expected to raise the appropriate exception when an error ocurred since this is more Pythonic.

The default VisaLibrary class is pyvisa.ctwrapper.highlevel.IVIVisaLibrary, which implements a ctypes wrapper around the IVI-VISA library. Certainly, IVI-VISA can be NI-VISA, Keysight VISA, R&S VISA, tekVISA etc.

In general, you should not instantiate it directly. The object exposed to the user is the pyvisa.highlevel.ResourceManager. If needed, you can access the VISA library from it:

>>> import pyvisa
>>> rm = pyvisa.ResourceManager("/path/to/my/libvisa.so.7")
>>> lib = rm.visalib
assert_interrupt_signal(session: NewType.<locals>.new_type, mode: pyvisa.constants.AssertSignalInterrupt, status_id: int) → pyvisa.constants.StatusCode[source]

Asserts the specified interrupt or signal.

Corresponds to viAssertIntrSignal function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • mode (constants.AssertSignalInterrupt) – How to assert the interrupt.
  • status_id (int) – Status value to be presented during an interrupt acknowledge cycle.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

assert_trigger(session: NewType.<locals>.new_type, protocol: pyvisa.constants.TriggerProtocol) → pyvisa.constants.StatusCode[source]

Assert software or hardware trigger.

Corresponds to viAssertTrigger function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • protocol (constants.TriggerProtocol) – Trigger protocol to use during assertion.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

assert_utility_signal(session: NewType.<locals>.new_type, line: pyvisa.constants.UtilityBusSignal) → pyvisa.constants.StatusCode[source]

Assert or deassert the specified utility bus signal.

Corresponds to viAssertUtilSignal function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • line (constants.UtilityBusSignal) – Specifies the utility bus signal to assert.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

buffer_read(session: NewType.<locals>.new_type, count: int) → Tuple[bytes, pyvisa.constants.StatusCode][source]

Reads data through the use of a formatted I/O read buffer.

The data can be read from a device or an interface.

Corresponds to viBufRead function of the VISA library.

Parameters:
  • session (VISASession Unique logical identifier to a session.) –
  • count (int) – Number of bytes to be read.
Returns:

  • dbytes – Data read
  • constants.StatusCode – Return value of the library call.

buffer_write(session: NewType.<locals>.new_type, data: bytes) → Tuple[int, pyvisa.constants.StatusCode][source]

Writes data to a formatted I/O write buffer synchronously.

Corresponds to viBufWrite function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • data (bytes) – Data to be written.
Returns:

  • int – number of written bytes
  • constants.StatusCode – return value of the library call.

clear(session: NewType.<locals>.new_type) → pyvisa.constants.StatusCode[source]

Clears a device.

Corresponds to viClear function of the VISA library.

Parameters:session (VISASession) – Unique logical identifier to a session.
Returns:Return value of the library call.
Return type:constants.StatusCode
close(session: Union[NewType.<locals>.new_type, NewType.<locals>.new_type, NewType.<locals>.new_type]) → pyvisa.constants.StatusCode[source]

Closes the specified session, event, or find list.

Corresponds to viClose function of the VISA library.

Parameters:session (Union[VISASession, VISAEventContext, VISARMSession]) – Unique logical identifier to a session, event, resource manager.
Returns:Return value of the library call.
Return type:constants.StatusCode
disable_event(session: NewType.<locals>.new_type, event_type: pyvisa.constants.EventType, mechanism: pyvisa.constants.EventMechanism) → pyvisa.constants.StatusCode[source]

Disable notification for an event type(s) via the specified mechanism(s).

Corresponds to viDisableEvent function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • event_type (constants.EventType) – Event type.
  • mechanism (constants.EventMechanism) – Event handling mechanisms to be disabled.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

discard_events(session: NewType.<locals>.new_type, event_type: pyvisa.constants.EventType, mechanism: pyvisa.constants.EventMechanism) → pyvisa.constants.StatusCode[source]

Discard event occurrences for a given type and mechanisms in a session.

Corresponds to viDiscardEvents function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • event_type (constans.EventType) – Logical event identifier.
  • mechanism (constants.EventMechanism) – Specifies event handling mechanisms to be discarded.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

enable_event(session: NewType.<locals>.new_type, event_type: pyvisa.constants.EventType, mechanism: pyvisa.constants.EventMechanism, context: None = None) → pyvisa.constants.StatusCode[source]

Enable event occurrences for specified event types and mechanisms in a session.

Corresponds to viEnableEvent function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • event_type (constants.EventType) – Logical event identifier.
  • mechanism (constants.EventMechanism) – Specifies event handling mechanisms to be enabled.
  • context (None, optional) – Unused parameter…
Returns:

Return value of the library call.

Return type:

constants.StatusCode

flush(session: NewType.<locals>.new_type, mask: pyvisa.constants.BufferOperation) → pyvisa.constants.StatusCode[source]

Flush the specified buffers.

The buffers can be associated with formatted I/O operations and/or serial communication.

Corresponds to viFlush function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • mask (constants.BufferOperation) – Specifies the action to be taken with flushing the buffer. The values can be combined using the | operator. However multiple operations on a single buffer cannot be combined.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

get_attribute(session: Union[NewType.<locals>.new_type, NewType.<locals>.new_type, NewType.<locals>.new_type], attribute: Union[pyvisa.constants.ResourceAttribute, pyvisa.constants.EventAttribute]) → Tuple[Any, pyvisa.constants.StatusCode][source]

Retrieves the state of an attribute.

Corresponds to viGetAttribute function of the VISA library.

Parameters:
  • session (Union[VISASession, VISAEventContext]) – Unique logical identifier to a session, event, or find list.
  • attribute (Union[constants.ResourceAttribute, constants.EventAttribute]) – Resource or event attribute for which the state query is made.
Returns:

  • Any – State of the queried attribute for a specified resource
  • constants.StatusCode – Return value of the library call.

get_buffer_from_id(job_id: NewType.<locals>.new_type) → Optional[SupportsBytes][source]

Retrieve the buffer associated with a job id created in read_asynchronously

Parameters:job_id (VISAJobID) – Id of the job for which to retrieve the buffer.
Returns:Buffer in which the data are stored or None if the job id is not associated with any job.
Return type:Optional[SupportsBytes]
static get_debug_info() → Union[Iterable[str], Dict[str, Union[str, Dict[str, Any]]]][source]

Override to return an iterable of lines with the backend debug details.

get_last_status_in_session(session: Union[NewType.<locals>.new_type, NewType.<locals>.new_type]) → pyvisa.constants.StatusCode[source]

Last status in session.

Helper function to be called by resources properties.

static get_library_paths() → Iterable[pyvisa.util.LibraryPath][source]

Override to list the possible library_paths if no path is specified.

gpib_command(session: NewType.<locals>.new_type, data: bytes) → Tuple[int, pyvisa.constants.StatusCode][source]

Write GPIB command bytes on the bus.

Corresponds to viGpibCommand function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • data (bytes) – Data to write.
Returns:

  • int – Number of written bytes
  • constants.StatusCode – Return value of the library call.

gpib_control_atn(session: NewType.<locals>.new_type, mode: pyvisa.constants.ATNLineOperation) → pyvisa.constants.StatusCode[source]

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

Corresponds to viGpibControlATN function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • mode (constants.ATNLineOperation) – State of the ATN line and optionally the local active controller state.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

gpib_control_ren(session: NewType.<locals>.new_type, mode: pyvisa.constants.RENLineOperation) → pyvisa.constants.StatusCode[source]

Controls the state of the GPIB Remote Enable (REN) interface line.

Optionally the remote/local state of the device can also be set.

Corresponds to viGpibControlREN function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • mode (constants.RENLineOperation) – State of the REN line and optionally the device remote/local state.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

gpib_pass_control(session: NewType.<locals>.new_type, primary_address: int, secondary_address: int) → pyvisa.constants.StatusCode[source]

Tell a GPIB device to become controller in charge (CIC).

Corresponds to viGpibPassControl function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • primary_address (int) – Primary address of the GPIB device to which you want to pass control.
  • secondary_address (int) – Secondary address of the targeted GPIB device. If the targeted device does not have a secondary address, this parameter should contain the value Constants.VI_NO_SEC_ADDR.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

gpib_send_ifc(session: NewType.<locals>.new_type) → pyvisa.constants.StatusCode[source]

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

Corresponds to viGpibSendIFC function of the VISA library.

Parameters:session (VISASession) – Unique logical identifier to a session.
Returns:Return value of the library call.
Return type:constants.StatusCode
handlers = None

Contains all installed event handlers. Its elements are tuples with four elements: The handler itself (a Python callable), the user handle (in any format making sense to the lower level implementation, ie as a ctypes object for the ctypes backend) and the handler again, this time in a format meaningful to the backend (ie as a ctypes object created with CFUNCTYPE for the ctypes backend) and the event type.

ignore_warning(session: Union[NewType.<locals>.new_type, NewType.<locals>.new_type], *warnings_constants) → Iterator[T_co][source]

Ignore warnings for a session for the duration of the context.

Parameters:
  • session (Union[VISASession, VISARMSession]) – Unique logical identifier to a session.
  • warnings_constants (constants.StatusCode) – Constants identifying the warnings to ignore.
in_16(session: NewType.<locals>.new_type, space: pyvisa.constants.AddressSpace, offset: int, extended: bool = False) → Tuple[int, pyvisa.constants.StatusCode][source]

Reads in an 16-bit value from the specified memory space and offset.

Corresponds to viIn16* function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • space (constants.AddressSpace) – Specifies the address space.
  • offset (int) – Offset (in bytes) of the address or register from which to read.
  • extended (bool, optional) – Use 64 bits offset independent of the platform, False by default.
Returns:

  • int – Data read from memory
  • constants.StatusCode – Return value of the library call.

in_32(session: NewType.<locals>.new_type, space: pyvisa.constants.AddressSpace, offset: int, extended: bool = False) → Tuple[int, pyvisa.constants.StatusCode][source]

Reads in an 32-bit value from the specified memory space and offset.

Corresponds to viIn32* function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • space (constants.AddressSpace) – Specifies the address space.
  • offset (int) – Offset (in bytes) of the address or register from which to read.
  • extended (bool, optional) – Use 64 bits offset independent of the platform, False by default.
Returns:

  • int – Data read from memory
  • constants.StatusCode – Return value of the library call.

in_64(session: NewType.<locals>.new_type, space: pyvisa.constants.AddressSpace, offset: int, extended: bool = False) → Tuple[int, pyvisa.constants.StatusCode][source]

Reads in an 64-bit value from the specified memory space and offset.

Corresponds to viIn64* function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • space (constants.AddressSpace) – Specifies the address space.
  • offset (int) – Offset (in bytes) of the address or register from which to read.
  • extended (bool, optional) – Use 64 bits offset independent of the platform, False by default.
Returns:

  • int – Data read from memory
  • constants.StatusCode – Return value of the library call.

in_8(session: NewType.<locals>.new_type, space: pyvisa.constants.AddressSpace, offset: int, extended: bool = False) → Tuple[int, pyvisa.constants.StatusCode][source]

Reads in an 8-bit value from the specified memory space and offset.

Corresponds to viIn8* function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • space (constants.AddressSpace) – Specifies the address space.
  • offset (int) – Offset (in bytes) of the address or register from which to read.
  • extended (bool, optional) – Use 64 bits offset independent of the platform, False by default.
Returns:

  • int – Data read from memory
  • constants.StatusCode – Return value of the library call.

install_handler(session: NewType.<locals>.new_type, event_type: pyvisa.constants.EventType, handler: Callable[[NewType.<locals>.new_type, pyvisa.constants.EventType, NewType.<locals>.new_type, Any], None], user_handle: Any) → Tuple[Callable[[NewType.<locals>.new_type, pyvisa.constants.EventType, NewType.<locals>.new_type, Any], None], Any, Any, pyvisa.constants.StatusCode][source]

Install handlers for event callbacks.

Corresponds to viInstallHandler function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • event_type (constants.EventType) – Logical event identifier.
  • handler (VISAHandler) – Reference to a handler to be installed by a client application.
  • user_handle (Any) – Value specified by an application that can be used for identifying handlers uniquely for an event type.
Returns:

  • handler (VISAHandler) – Handler to be installed by a client application.
  • converted_user_handle – Converted user handle to match the underlying library. This version of the handle should be used in further call to the library.
  • converted_handler – Converted version of the handler satisfying to backend library.
  • status_code (constants.StatusCode) – Return value of the library call

install_visa_handler(session: NewType.<locals>.new_type, event_type: pyvisa.constants.EventType, handler: Callable[[NewType.<locals>.new_type, pyvisa.constants.EventType, NewType.<locals>.new_type, Any], None], user_handle: Any = None) → Any[source]

Installs handlers for event callbacks.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • event_type (constants.EventType,) – Logical event identifier.
  • handler (VISAHandler) – 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:

Converted user handle to match the underlying library. This version of the handle should be used in further call to the library.

Return type:

converted_user_handle

issue_warning_on = None

Set error codes on which to issue a warning.

last_status

Last return value of the library.

library_path = None

Path to the VISA library used by this instance

list_resources(session: NewType.<locals>.new_type, query: str = '?*::INSTR') → Tuple[str, ...][source]

Return a tuple of all connected devices matching query.

Parameters:
  • session (VISARMSession) – Unique logical identifier to the resource manager session.
  • query (str) – Regular expression used to match devices.
Returns:

Resource names of all the connected devices matching the query.

Return type:

Tuple[str, ..]

lock(session: NewType.<locals>.new_type, lock_type: pyvisa.constants.Lock, timeout: int, requested_key: Optional[str] = None) → Tuple[str, pyvisa.constants.StatusCode][source]

Establishes an access mode to the specified resources.

Corresponds to viLock function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • lock_type (constants.Lock) – Specifies the type of lock requested.
  • timeout (int) – Absolute time period (in milliseconds) that a resource waits to get unlocked by the locking session before returning an error.
  • requested_key (Optional[str], optional) – Requested locking key in the case of a shared lock. For an exclusive lock it should be None.
Returns:

  • Optional[str] – Key that can then be passed to other sessions to share the lock, or None for an exclusive lock.
  • constants.StatusCode – Return value of the library call.

map_address(session: NewType.<locals>.new_type, map_space: pyvisa.constants.AddressSpace, map_base: int, map_size: int, access: typing_extensions.Literal[False][False] = False, suggested: Optional[int] = None) → Tuple[int, pyvisa.constants.StatusCode][source]

Maps the specified memory space into the process’s address space.

Corresponds to viMapAddress function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • map_space (constants.AddressSpace) – Specifies the address space to map.
  • map_base (int) – Offset (in bytes) of the memory to be mapped.
  • map_size (int) – Amount of memory to map (in bytes).
  • access (False) – Unused parameter.
  • suggested (Optional[int], optional) – If not None, the operating system attempts to map the memory to the address specified. There is no guarantee, however, that the memory will be mapped to that address. This operation may map the memory into an address region different from the suggested one.
Returns:

  • int – Address in your process space where the memory was mapped
  • constants.StatusCode – Return value of the library call.

map_trigger(session: NewType.<locals>.new_type, trigger_source: pyvisa.constants.InputTriggerLine, trigger_destination: pyvisa.constants.OutputTriggerLine, mode: None = None) → pyvisa.constants.StatusCode[source]

Map the specified trigger source line to the specified destination line.

Corresponds to viMapTrigger function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • trigger_source (constants.InputTriggerLine) – Source line from which to map.
  • trigger_destination (constants.OutputTriggerLine) – Destination line to which to map.
  • mode (None, optional) – Always None for this version of the VISA specification.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

memory_allocation(session: NewType.<locals>.new_type, size: int, extended: bool = False) → Tuple[int, pyvisa.constants.StatusCode][source]

Allocate memory from a resource’s memory region.

Corresponds to viMemAlloc* functions of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • size (int) – Specifies the size of the allocation.
  • extended (bool, optional) – Use 64 bits offset independent of the platform.
Returns:

  • int – offset of the allocated memory
  • constants.StatusCode – Return value of the library call.

memory_free(session: NewType.<locals>.new_type, offset: int, extended: bool = False) → pyvisa.constants.StatusCode[source]

Frees memory previously allocated using the memory_allocation() operation.

Corresponds to viMemFree* function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • offset (int) – Offset of the memory to free.
  • extended (bool, optional) – Use 64 bits offset independent of the platform.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

move(session: NewType.<locals>.new_type, source_space: pyvisa.constants.AddressSpace, source_offset: int, source_width: pyvisa.constants.DataWidth, destination_space: pyvisa.constants.AddressSpace, destination_offset: int, destination_width: pyvisa.constants.DataWidth, length: int) → pyvisa.constants.StatusCode[source]

Moves a block of data.

Corresponds to viMove function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • source_space (constants.AddressSpace) – Specifies the address space of the source.
  • source_offset (int) – Offset of the starting address or register from which to read.
  • source_width (constants.DataWidth) – Specifies the data width of the source.
  • destination_space (constants.AddressSpace) – Specifies the address space of the destination.
  • destination_offset (int) – Offset of the starting address or register to which to write.
  • destination_width (constants.DataWidth) – Specifies the data width of the destination.
  • length (int) – Number of elements to transfer, where the data width of the elements to transfer is identical to the source data width.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

move_asynchronously(session: NewType.<locals>.new_type, source_space: pyvisa.constants.AddressSpace, source_offset: int, source_width: pyvisa.constants.DataWidth, destination_space: pyvisa.constants.AddressSpace, destination_offset: int, destination_width: pyvisa.constants.DataWidth, length: int) → Tuple[NewType.<locals>.new_type, pyvisa.constants.StatusCode][source]

Moves a block of data asynchronously.

Corresponds to viMoveAsync function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • source_space (constants.AddressSpace) – Specifies the address space of the source.
  • source_offset (int) – Offset of the starting address or register from which to read.
  • source_width (constants.DataWidth) – Specifies the data width of the source.
  • destination_space (constants.AddressSpace) – Specifies the address space of the destination.
  • destination_offset (int) – Offset of the starting address or register to which to write.
  • destination_width (constants.DataWidth) – Specifies the data width of the destination.
  • length (int) – Number of elements to transfer, where the data width of the elements to transfer is identical to the source data width.
Returns:

  • VISAJobID – Job identifier of this asynchronous move operation
  • constants.StatusCode – Return value of the library call.

move_in(session: NewType.<locals>.new_type, space: pyvisa.constants.AddressSpace, offset: int, length: int, width: Union[typing_extensions.Literal[8, 16, 32, 64][8, 16, 32, 64], pyvisa.constants.DataWidth], extended: bool = False) → Tuple[List[int], pyvisa.constants.StatusCode][source]

Move a block of data to local memory from the given address space and offset.

Corresponds to viMoveIn* functions of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • space (constants.AddressSpace) – Address space from which to move the data.
  • offset (int) – Offset (in bytes) of the address or register from which to read.
  • length (int) – Number of elements to transfer, where the data width of the elements to transfer is identical to the source data width.
  • width (Union[Literal[8, 16, 32, 64], constants.DataWidth]) – Number of bits to read per element.
  • extended (bool, optional) – Use 64 bits offset independent of the platform, by default False.
Returns:

  • data (List[int]) – Data read from the bus
  • status_code (constants.StatusCode) – Return value of the library call.

Raises:

ValueError – Raised if an invalid width is specified.

move_in_16(session: NewType.<locals>.new_type, space: pyvisa.constants.AddressSpace, offset: int, length: int, extended: bool = False) → Tuple[List[int], pyvisa.constants.StatusCode][source]

Moves an 16-bit block of data to local memory.

Corresponds to viMoveIn816 functions of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • space (constants.AddressSpace) – Address space from which to move the data.
  • offset (int) – Offset (in bytes) of the address or register from which to read.
  • length (int) – Number of elements to transfer, where the data width of the elements to transfer is identical to the source data width.
  • extended (bool, optional) – Use 64 bits offset independent of the platform, by default False.
Returns:

  • data (List[int]) – Data read from the bus
  • status_code (constants.StatusCode) – Return value of the library call.

move_in_32(session: NewType.<locals>.new_type, space: pyvisa.constants.AddressSpace, offset: int, length: int, extended: bool = False) → Tuple[List[T]][source]

Moves an 32-bit block of data to local memory.

Corresponds to viMoveIn32* functions of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • space (constants.AddressSpace) – Address space from which to move the data.
  • offset (int) – Offset (in bytes) of the address or register from which to read.
  • length (int) – Number of elements to transfer, where the data width of the elements to transfer is identical to the source data width.
  • extended (bool, optional) – Use 64 bits offset independent of the platform, by default False.
Returns:

  • data (List[int]) – Data read from the bus
  • status_code (constants.StatusCode) – Return value of the library call.

move_in_64(session: NewType.<locals>.new_type, space: pyvisa.constants.AddressSpace, offset: int, length: int, extended: bool = False) → Tuple[List[int], pyvisa.constants.StatusCode][source]

Moves an 64-bit block of data to local memory.

Corresponds to viMoveIn8* functions of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • space (constants.AddressSpace) – Address space from which to move the data.
  • offset (int) – Offset (in bytes) of the address or register from which to read.
  • length (int) – Number of elements to transfer, where the data width of the elements to transfer is identical to the source data width.
  • extended (bool, optional) – Use 64 bits offset independent of the platform, by default False.
Returns:

  • data (List[int]) – Data read from the bus
  • status_code (constants.StatusCode) – Return value of the library call.

move_in_8(session: NewType.<locals>.new_type, space: pyvisa.constants.AddressSpace, offset: int, length: int, extended: bool = False) → Tuple[List[int], pyvisa.constants.StatusCode][source]

Moves an 8-bit block of data to local memory.

Corresponds to viMoveIn8* functions of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • space (constants.AddressSpace) – Address space from which to move the data.
  • offset (int) – Offset (in bytes) of the address or register from which to read.
  • length (int) – Number of elements to transfer, where the data width of the elements to transfer is identical to the source data width.
  • extended (bool, optional) – Use 64 bits offset independent of the platform, by default False.
Returns:

  • data (List[int]) – Data read from the bus
  • status_code (constants.StatusCode) – Return value of the library call.

move_out(session: NewType.<locals>.new_type, space: pyvisa.constants.AddressSpace, offset: int, length: int, data: Iterable[int], width: Union[typing_extensions.Literal[8, 16, 32, 64][8, 16, 32, 64], pyvisa.constants.DataWidth], extended: bool = False) → pyvisa.constants.StatusCode[source]

Move a block of data from local memory to the given address space and offset.

Corresponds to viMoveOut* functions of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • space (constants.AddressSpace) – Address space into which move the data.
  • offset (int) – Offset (in bytes) of the address or register from which to read.
  • length (int) – Number of elements to transfer, where the data width of the elements to transfer is identical to the source data width.
  • data (Iterable[int]) – Data to write to bus.
  • width (Union[Literal[8, 16, 32, 64], constants.DataWidth]) – Number of bits to per element.
  • extended (bool, optional) – Use 64 bits offset independent of the platform, by default False.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

Raises:

ValueError – Raised if an invalid width is specified.

move_out_16(session: NewType.<locals>.new_type, space: pyvisa.constants.AddressSpace, offset: int, length: int, data: Iterable[int], extended: bool = False) → pyvisa.constants.StatusCode[source]

Moves an 16-bit block of data from local memory.

Corresponds to viMoveOut16* functions of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • space (constants.AddressSpace) – Address space into which move the data.
  • offset (int) – Offset (in bytes) of the address or register from which to read.
  • length (int) – Number of elements to transfer, where the data width of the elements to transfer is identical to the source data width.
  • data (Iterable[int]) – Data to write to bus.
  • extended (bool, optional) – Use 64 bits offset independent of the platform, by default False.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

move_out_32(session: NewType.<locals>.new_type, space: pyvisa.constants.AddressSpace, offset: int, length: int, data: Iterable[int], extended: bool = False) → pyvisa.constants.StatusCode[source]

Moves an 32-bit block of data from local memory.

Corresponds to viMoveOut32* functions of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • space (constants.AddressSpace) – Address space into which move the data.
  • offset (int) – Offset (in bytes) of the address or register from which to read.
  • length (int) – Number of elements to transfer, where the data width of the elements to transfer is identical to the source data width.
  • data (Iterable[int]) – Data to write to bus.
  • extended (bool, optional) – Use 64 bits offset independent of the platform, by default False.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

move_out_64(session: NewType.<locals>.new_type, space: pyvisa.constants.AddressSpace, offset: int, length: int, data: Iterable[int], extended: bool = False) → pyvisa.constants.StatusCode[source]

Moves an 64-bit block of data from local memory.

Corresponds to viMoveOut64* functions of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • space (constants.AddressSpace) – Address space into which move the data.
  • offset (int) – Offset (in bytes) of the address or register from which to read.
  • length (int) – Number of elements to transfer, where the data width of the elements to transfer is identical to the source data width.
  • data (Iterable[int]) – Data to write to bus.
  • extended (bool, optional) – Use 64 bits offset independent of the platform, by default False.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

move_out_8(session: NewType.<locals>.new_type, space: pyvisa.constants.AddressSpace, offset: int, length: int, data: Iterable[int], extended: bool = False) → pyvisa.constants.StatusCode[source]

Moves an 8-bit block of data from local memory.

Corresponds to viMoveOut8* functions of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • space (constants.AddressSpace) – Address space into which move the data.
  • offset (int) – Offset (in bytes) of the address or register from which to read.
  • length (int) – Number of elements to transfer, where the data width of the elements to transfer is identical to the source data width.
  • data (Iterable[int]) – Data to write to bus.
  • extended (bool, optional) – Use 64 bits offset independent of the platform, by default False.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

open(session: NewType.<locals>.new_type, resource_name: str, access_mode: pyvisa.constants.AccessModes = <AccessModes.no_lock: 0>, open_timeout: int = 0) → Tuple[NewType.<locals>.new_type, pyvisa.constants.StatusCode][source]

Opens a session to the specified resource.

Corresponds to viOpen function of the VISA library.

Parameters:
  • session (VISARMSession) – Resource Manager session (should always be a session returned from open_default_resource_manager()).
  • resource_name (str) – Unique symbolic name of a resource.
  • access_mode (constants.AccessModes, optional) – Specifies the mode by which the resource is to be accessed.
  • open_timeout (int) – If the access_mode parameter requests a lock, then this parameter specifies the absolute time period (in milliseconds) that the resource waits to get unlocked before this operation returns an error.
Returns:

  • VISASession – Unique logical identifier reference to a session
  • constants.StatusCode – Return value of the library call.

open_default_resource_manager() → Tuple[NewType.<locals>.new_type, pyvisa.constants.StatusCode][source]

This function returns a session to the Default Resource Manager resource.

Corresponds to viOpenDefaultRM function of the VISA library.

Returns:
  • VISARMSession – Unique logical identifier to a Default Resource Manager session
  • constants.StatusCode – Return value of the library call.
out_16(session: NewType.<locals>.new_type, space: pyvisa.constants.AddressSpace, offset: int, data: int, extended: bool = False) → pyvisa.constants.StatusCode[source]

Write a 16-bit value to the specified memory space and offset.

Corresponds to viOut16* functions of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • space (constants.AddressSpace) – Address space into which to write.
  • offset (int) – Offset (in bytes) of the address or register from which to read.
  • data (int) – Data to write to bus.
  • extended (bool, optional) – Use 64 bits offset independent of the platform.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

out_32(session: NewType.<locals>.new_type, space: pyvisa.constants.AddressSpace, offset: int, data: Iterable[int], extended: bool = False) → pyvisa.constants.StatusCode[source]

Write a 32-bit value to the specified memory space and offset.

Corresponds to viOut32* functions of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • space (constants.AddressSpace) – Address space into which to write.
  • offset (int) – Offset (in bytes) of the address or register from which to read.
  • data (int) – Data to write to bus.
  • extended (bool, optional) – Use 64 bits offset independent of the platform.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

out_64(session: NewType.<locals>.new_type, space: pyvisa.constants.AddressSpace, offset: int, data: Iterable[int], extended: bool = False) → pyvisa.constants.StatusCode[source]

Write a 64-bit value to the specified memory space and offset.

Corresponds to viOut64* functions of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • space (constants.AddressSpace) – Address space into which to write.
  • offset (int) – Offset (in bytes) of the address or register from which to read.
  • data (int) – Data to write to bus.
  • extended (bool, optional) – Use 64 bits offset independent of the platform.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

out_8(session: NewType.<locals>.new_type, space: pyvisa.constants.AddressSpace, offset: int, data: int, extended: bool = False) → pyvisa.constants.StatusCode[source]

Write an 8-bit value to the specified memory space and offset.

Corresponds to viOut8* functions of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • space (constants.AddressSpace) – Address space into which to write.
  • offset (int) – Offset (in bytes) of the address or register from which to read.
  • data (int) – Data to write to bus.
  • extended (bool, optional) – Use 64 bits offset independent of the platform.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

parse_resource(session: NewType.<locals>.new_type, resource_name: str) → Tuple[pyvisa.highlevel.ResourceInfo, pyvisa.constants.StatusCode][source]

Parse a resource string to get the interface information.

Corresponds to viParseRsrc function of the VISA library.

Parameters:
  • session (VISARMSession) – Resource Manager session (should always be the Default Resource Manager for VISA returned from open_default_resource_manager()).
  • resource_name (str) – Unique symbolic name of a resource.
Returns:

  • ResourceInfo – Resource information with interface type and board number
  • constants.StatusCode – Return value of the library call.

parse_resource_extended(session: NewType.<locals>.new_type, resource_name: str) → Tuple[pyvisa.highlevel.ResourceInfo, pyvisa.constants.StatusCode][source]

Parse a resource string to get extended interface information.

Corresponds to viParseRsrcEx function of the VISA library.

Parameters:
  • session (VISARMSession) – Resource Manager session (should always be the Default Resource Manager for VISA returned from open_default_resource_manager()).
  • resource_name (str) – Unique symbolic name of a resource.
Returns:

  • ResourceInfo – Resource information with interface type and board number
  • constants.StatusCode – Return value of the library call.

peek(session: NewType.<locals>.new_type, address: NewType.<locals>.new_type, width: Union[typing_extensions.Literal[8, 16, 32, 64][8, 16, 32, 64], pyvisa.constants.DataWidth]) → Tuple[int, pyvisa.constants.StatusCode][source]

Read an 8, 16, 32, or 64-bit value from the specified address.

Corresponds to viPeek* functions of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • address (VISAMemoryAddress) – Source address to read the value.
  • width (Union[Literal[8, 16, 32, 64], constants.DataWidth]) – Number of bits to read.
Returns:

  • data (int) – Data read from bus
  • status_code (constants.StatusCode) – Return value of the library call.

Raises:

ValueError – Raised if an invalid width is specified.

peek_16(session: NewType.<locals>.new_type, address: NewType.<locals>.new_type) → Tuple[int, pyvisa.constants.StatusCode][source]

Read an 16-bit value from the specified address.

Corresponds to viPeek16 function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • address (VISAMemoryAddress) – Source address to read the value.
Returns:

  • int – Data read from bus
  • constants.StatusCode – Return value of the library call.

peek_32(session: NewType.<locals>.new_type, address: NewType.<locals>.new_type) → Tuple[int, pyvisa.constants.StatusCode][source]

Read an 32-bit value from the specified address.

Corresponds to viPeek32 function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • address (VISAMemoryAddress) – Source address to read the value.
Returns:

  • int – Data read from bus
  • constants.StatusCode – Return value of the library call.

peek_64(session: NewType.<locals>.new_type, address: NewType.<locals>.new_type) → Tuple[int, pyvisa.constants.StatusCode][source]

Read an 64-bit value from the specified address.

Corresponds to viPeek64 function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • address (VISAMemoryAddress) – Source address to read the value.
Returns:

  • int – Data read from bus
  • constants.StatusCode – Return value of the library call.

peek_8(session: NewType.<locals>.new_type, address: NewType.<locals>.new_type) → Tuple[int, pyvisa.constants.StatusCode][source]

Read an 8-bit value from the specified address.

Corresponds to viPeek8 function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • address (VISAMemoryAddress) – Source address to read the value.
Returns:

  • int – Data read from bus
  • constants.StatusCode – Return value of the library call.

poke(session: NewType.<locals>.new_type, address: NewType.<locals>.new_type, width: Union[typing_extensions.Literal[8, 16, 32, 64][8, 16, 32, 64], pyvisa.constants.DataWidth], data: int) → pyvisa.constants.StatusCode[source]

Writes an 8, 16, 32, or 64-bit value from the specified address.

Corresponds to viPoke* functions of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • address (VISAMemoryAddress) – Source address to read the value.
  • width (Union[Literal[8, 16, 32, 64], constants.DataWidth]) – Number of bits to read.
  • data (int) – Data to write to the bus
Returns:

status_code – Return value of the library call.

Return type:

constants.StatusCode

Raises:

ValueError – Raised if an invalid width is specified.

poke_16(session: NewType.<locals>.new_type, address: NewType.<locals>.new_type, data: int) → pyvisa.constants.StatusCode[source]

Write an 16-bit value to the specified address.

Corresponds to viPoke16 function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • address (VISAMemoryAddress) – Source address to read the value.
  • data (int) – Data to write.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

poke_32(session: NewType.<locals>.new_type, address: NewType.<locals>.new_type, data: int) → pyvisa.constants.StatusCode[source]

Write an 32-bit value to the specified address.

Corresponds to viPoke32 function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • address (VISAMemoryAddress) – Source address to read the value.
  • data (int) – Data to write.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

poke_64(session: NewType.<locals>.new_type, address: NewType.<locals>.new_type, data: int) → pyvisa.constants.StatusCode[source]

Write an 64-bit value to the specified address.

Corresponds to viPoke64 function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • address (VISAMemoryAddress) – Source address to read the value.
  • data (int) – Data to write.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

poke_8(session: NewType.<locals>.new_type, address: NewType.<locals>.new_type, data: int) → pyvisa.constants.StatusCode[source]

Write an 8-bit value to the specified address.

Corresponds to viPoke8 function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • address (VISAMemoryAddress) – Source address to read the value.
  • data (int) – Data to write.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

read(session: NewType.<locals>.new_type, count: int) → Tuple[bytes, pyvisa.constants.StatusCode][source]

Reads data from device or interface synchronously.

Corresponds to viRead function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • count (int) – Number of bytes to be read.
Returns:

  • bytes – Date read
  • constants.StatusCode – Return value of the library call.

read_asynchronously(session: NewType.<locals>.new_type, count: int) → Tuple[SupportsBytes, NewType.<locals>.new_type, pyvisa.constants.StatusCode][source]

Reads data from device or interface asynchronously.

Corresponds to viReadAsync function of the VISA library. Since the asynchronous operation may complete before the function call return implementation should make sure that get_buffer_from_id will be able to return the proper buffer before this method returns.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • count (int) – Number of bytes to be read.
Returns:

  • SupportsBytes – Buffer that will be filled during the asynchronous operation.
  • VISAJobID – Id of the asynchronous job
  • constants.StatusCode – Return value of the library call.

read_memory(session: NewType.<locals>.new_type, space: pyvisa.constants.AddressSpace, offset: int, width: Union[typing_extensions.Literal[8, 16, 32, 64][8, 16, 32, 64], pyvisa.constants.DataWidth], extended: bool = False) → Tuple[int, pyvisa.constants.StatusCode][source]

Read a value from the specified memory space and offset.

Corresponds to viIn* functions of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • space (constants.AddressSpace) – Specifies the address space from which to read.
  • offset (int) – Offset (in bytes) of the address or register from which to read.
  • width (Union[Literal[8, 16, 32, 64], constants.DataWidth]) – Number of bits to read (8, 16, 32 or 64).
  • extended (bool, optional) – Use 64 bits offset independent of the platform.
Returns:

  • data (int) – Data read from memory
  • status_code (constants.StatusCode) – Return value of the library call.

Raises:

ValueError – Raised if an invalid width is specified.

read_stb(session: NewType.<locals>.new_type) → Tuple[int, pyvisa.constants.StatusCode][source]

Reads a status byte of the service request.

Corresponds to viReadSTB function of the VISA library.

Parameters:session (VISASession) – Unique logical identifier to a session.
Returns:
  • int – Service request status byte
  • constants.StatusCode – Return value of the library call.
read_to_file(session: NewType.<locals>.new_type, filename: str, count: int) → Tuple[int, pyvisa.constants.StatusCode][source]

Read data synchronously, and store the transferred data in a file.

Corresponds to viReadToFile function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • filename (str) – Name of file to which data will be written.
  • count (int) – Number of bytes to be read.
Returns:

  • int – Number of bytes actually transferred
  • constants.StatusCode – Return value of the library call.

resource_manager = None

Default ResourceManager instance for this library.

set_attribute(session: NewType.<locals>.new_type, attribute: pyvisa.constants.ResourceAttribute, attribute_state: Any) → pyvisa.constants.StatusCode[source]

Set the state of an attribute.

Corresponds to viSetAttribute function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • attribute (constants.ResourceAttribute) – Attribute for which the state is to be modified.
  • attribute_state (Any) – The state of the attribute to be set for the specified object.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

set_buffer(session: NewType.<locals>.new_type, mask: pyvisa.constants.BufferType, size: int) → pyvisa.constants.StatusCode[source]

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

Corresponds to viSetBuf function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • mask (constants.BufferType) – Specifies the type of buffer.
  • size (int) – The size to be set for the specified buffer(s).
Returns:

Return value of the library call.

Return type:

constants.StatusCode

status_description(session: NewType.<locals>.new_type, status: pyvisa.constants.StatusCode) → Tuple[str, pyvisa.constants.StatusCode][source]

Return a user-readable description of the status code passed to the operation.

Corresponds to viStatusDesc function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • status (constants.StatusCode) – Status code to interpret.
Returns:

  • str – User-readable string interpretation of the status code.
  • constants.StatusCode – Return value of the library call.

terminate(session: NewType.<locals>.new_type, degree: None, job_id: NewType.<locals>.new_type) → pyvisa.constants.StatusCode[source]

Request a VISA session to terminate normal execution of an operation.

Corresponds to viTerminate function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • degree (None) – Not used in this version of the VISA specification.
  • job_id (VISAJobId) – Specifies an operation identifier. If a user passes None as the job_id value to viTerminate(), a VISA implementation should abort any calls in the current process executing on the specified vi. Any call that is terminated this way should return VI_ERROR_ABORT.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

uninstall_all_visa_handlers(session: Optional[NewType.<locals>.new_type]) → None[source]

Uninstalls all previously installed handlers for a particular session.

Parameters:session (VISASession | None) – Unique logical identifier to a session. If None, operates on all sessions.
uninstall_handler(session: NewType.<locals>.new_type, event_type: pyvisa.constants.EventType, handler: Callable[[NewType.<locals>.new_type, pyvisa.constants.EventType, NewType.<locals>.new_type, Any], None], user_handle: Any = None) → pyvisa.constants.StatusCode[source]

Uninstall handlers for events.

Corresponds to viUninstallHandler function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • event_type (constants.EventType) – Logical event identifier.
  • handler (VISAHandler) – 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. The modified value of the user_handle as returned by install_handler should be used instead of the original value.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

uninstall_visa_handler(session: NewType.<locals>.new_type, event_type: pyvisa.constants.EventType, handler: Callable[[NewType.<locals>.new_type, pyvisa.constants.EventType, NewType.<locals>.new_type, Any], None], user_handle: Any = None) → None[source]

Uninstalls handlers for events.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • event_type (constants.EventType) – Logical event identifier.
  • handler (VISAHandler) – Handler to be uninstalled by a client application.
  • user_handle – The user handle returned by install_visa_handler.
unlock(session: NewType.<locals>.new_type) → pyvisa.constants.StatusCode[source]

Relinquish a lock for the specified resource.

Corresponds to viUnlock function of the VISA library.

Parameters:session (VISASession) – Unique logical identifier to a session.
Returns:Return value of the library call.
Return type:constants.StatusCode
unmap_address(session: NewType.<locals>.new_type) → pyvisa.constants.StatusCode[source]

Unmap memory space previously mapped by map_address().

Corresponds to viUnmapAddress function of the VISA library.

Parameters:session (VISASession) – Unique logical identifier to a session.
Returns:Return value of the library call.
Return type:constants.StatusCode
unmap_trigger(session: NewType.<locals>.new_type, trigger_source: pyvisa.constants.InputTriggerLine, trigger_destination: pyvisa.constants.OutputTriggerLine) → pyvisa.constants.StatusCode[source]

Undo a previous map between a trigger source line and a destination line.

Corresponds to viUnmapTrigger function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • trigger_source (constants.InputTriggerLine) – Source line used in previous map.
  • trigger_destination (constants.OutputTriggerLine) – Destination line used in previous map.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

usb_control_in(session: NewType.<locals>.new_type, request_type_bitmap_field: int, request_id: int, request_value: int, index: int, length: int = 0) → Tuple[bytes, pyvisa.constants.StatusCode][source]

Perform a USB control pipe transfer from the device.

Corresponds to viUsbControlIn function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • request_type_bitmap_field (int) – bmRequestType parameter of the setup stage of a USB control transfer.
  • request_id (int) – bRequest parameter of the setup stage of a USB control transfer.
  • request_value (int) – wValue parameter of the setup stage of a USB control transfer.
  • index (int) – wIndex parameter of the setup stage of a USB control transfer. This is usually the index of the interface or endpoint.
  • length (int, optional) – 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:

  • bytes – The data buffer that receives the data from the optional data stage of the control transfer
  • constants.StatusCode – Return value of the library call.

usb_control_out(session: NewType.<locals>.new_type, request_type_bitmap_field: int, request_id: int, request_value: int, index: int, data: bytes = b'') → pyvisa.constants.StatusCode[source]

Perform a USB control pipe transfer to the device.

Corresponds to viUsbControlOut function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • request_type_bitmap_field (int) – bmRequestType parameter of the setup stage of a USB control transfer.
  • request_id (int) – bRequest parameter of the setup stage of a USB control transfer.
  • request_value (int) – wValue parameter of the setup stage of a USB control transfer.
  • index (int) – wIndex parameter of the setup stage of a USB control transfer. This is usually the index of the interface or endpoint.
  • data (bytes, optional) – The data buffer that sends the data in the optional data stage of the control transfer.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

vxi_command_query(session: NewType.<locals>.new_type, mode: pyvisa.constants.VXICommands, command: int) → Tuple[int, pyvisa.constants.StatusCode][source]

Send the device a miscellaneous command or query and/or retrieves the response to a previous query.

Corresponds to viVxiCommandQuery function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • mode (constants.VXICommands) – Specifies whether to issue a command and/or retrieve a response.
  • command (int) – The miscellaneous command to send.
Returns:

  • int – The response retrieved from the device
  • constants.StatusCode – Return value of the library call.

wait_on_event(session: NewType.<locals>.new_type, in_event_type: pyvisa.constants.EventType, timeout: int) → Tuple[pyvisa.constants.EventType, NewType.<locals>.new_type, pyvisa.constants.StatusCode][source]

Wait for an occurrence of the specified event for a given session.

Corresponds to viWaitOnEvent function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • in_event_type (constants.EventType) – Logical identifier of the event(s) to wait for.
  • timeout (int) – Absolute time period in time units that the resource shall wait for a specified event to occur before returning the time elapsed error. The time unit is in milliseconds.
Returns:

  • constants.EventType – Logical identifier of the event actually received
  • VISAEventContext – A handle specifying the unique occurrence of an event
  • constants.StatusCode – Return value of the library call.

write(session: NewType.<locals>.new_type, data: bytes) → Tuple[int, pyvisa.constants.StatusCode][source]

Write data to device or interface synchronously.

Corresponds to viWrite function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • data (bytes) – Data to be written.
Returns:

  • int – Number of bytes actually transferred
  • constants.StatusCode – Return value of the library call.

write_asynchronously(session: NewType.<locals>.new_type, data: bytes) → Tuple[NewType.<locals>.new_type, pyvisa.constants.StatusCode][source]

Write data to device or interface asynchronously.

Corresponds to viWriteAsync function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • data (bytes) – Data to be written.
Returns:

  • VISAJobID – Job ID of this asynchronous write operation
  • constants.StatusCode – Return value of the library call.

write_from_file(session: NewType.<locals>.new_type, filename: str, count: int) → Tuple[int, pyvisa.constants.StatusCode][source]

Take data from a file and write it out synchronously.

Corresponds to viWriteFromFile function of the VISA library.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • filename (str) – Name of file from which data will be read.
  • count (int) – Number of bytes to be written.
Returns:

  • int – Number of bytes actually transferred
  • constants.StatusCode – Return value of the library call.

write_memory(session: NewType.<locals>.new_type, space: pyvisa.constants.AddressSpace, offset: int, data: int, width: Union[typing_extensions.Literal[8, 16, 32, 64][8, 16, 32, 64], pyvisa.constants.DataWidth], extended: bool = False) → pyvisa.constants.StatusCode[source]

Write a value to the specified memory space and offset.

Parameters:
  • session (VISASession) – Unique logical identifier to a session.
  • space (constants.AddressSpace) – Specifies the address space.
  • offset (int) – Offset (in bytes) of the address or register from which to read.
  • data (int) – Data to write to bus.
  • width (Union[Literal[8, 16, 32, 64], constants.DataWidth]) – Number of bits to read.
  • extended (bool, optional) – Use 64 bits offset independent of the platform, by default False.
Returns:

Return value of the library call.

Return type:

constants.StatusCode

Raises:

ValueError – Raised if an invalid width is specified.