Functions in the ctypes wrapper module

pyvisa.wrapper.functions

Defines VPP 4.3.2 wrapping functions, adding signatures to the library.

This file is part of PyVISA.

copyright:2014 by PyVISA Authors, see AUTHORS for more details.
license:MIT, see LICENSE for more details.
pyvisa.ctwrapper.functions.set_signatures(library, errcheck=None)[source]

Set the signatures of most visa functions in the library.

All instrumentation related functions are specified here. String related functions such as viPrintf require a cdecl calling convention even in windows and therefore are require a CDLL object. See set_cdecl_signatures.

Parameters:
  • library (ctypes.WinDLL or ctypes.CDLL) – the visa library wrapped by ctypes.
  • errcheck – error checking callable used for visa functions that return ViStatus. It should be take three areguments (result, func, arguments). See errcheck in ctypes.
pyvisa.ctwrapper.functions.set_cdecl_signatures(clibrary, errcheck=None)[source]

Set the signatures of visa functions requiring a cdecl calling convention.

Parameters:
  • clibrary (ctypes.CDLL) – the visa library wrapped by ctypes.
  • errcheck – error checking callable used for visa functions that return ViStatus. It should be take three areguments (result, func, arguments). See errcheck in ctypes.
pyvisa.ctwrapper.functions.assert_interrupt_signal(library, session, mode, status_id)[source]

Asserts the specified interrupt or signal.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • mode – How to assert the interrupt. (Constants.ASSERT*)
  • status_id – This is the status value to be presented during an interrupt acknowledge cycle.
pyvisa.ctwrapper.functions.assert_trigger(library, session, protocol)[source]

Asserts software or hardware trigger.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • protocol – Trigger protocol to use during assertion. (Constants.PROT*)
pyvisa.ctwrapper.functions.assert_utility_signal(library, session, line)[source]

Asserts or deasserts the specified utility bus signal.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • line – specifies the utility bus signal to assert. (Constants.UTIL_ASSERT*)
pyvisa.ctwrapper.functions.buffer_read(library, session, count)[source]

Reads data from device or interface through the use of a formatted I/O read buffer.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • count – Number of bytes to be read.
Returns:

data read.

Return type:

bytes

pyvisa.ctwrapper.functions.buffer_write(library, session, data)[source]

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

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • data (bytes) – data to be written.
Returns:

number of written bytes.

pyvisa.ctwrapper.functions.clear(library, session)[source]

Clears a device.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
pyvisa.ctwrapper.functions.close(library, session)[source]

Closes the specified session, event, or find list.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session, event, or find list.
pyvisa.ctwrapper.functions.disable_event(library, session, event_type, mechanism)[source]

Disables notification of the specified event type(s) via the specified mechanism(s).

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • event_type – Logical event identifier.
  • mechanism – Specifies event handling mechanisms to be disabled. (Constants.QUEUE, .Handler, .SUSPEND_HNDLR, .ALL_MECH)
pyvisa.ctwrapper.functions.discard_events(library, session, event_type, mechanism)[source]

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

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • event_type – Logical event identifier.
  • mechanism – Specifies event handling mechanisms to be disabled. (Constants.QUEUE, .Handler, .SUSPEND_HNDLR, .ALL_MECH)
pyvisa.ctwrapper.functions.enable_event(library, session, event_type, mechanism, context=0)[source]

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

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • event_type – Logical event identifier.
  • mechanism – Specifies event handling mechanisms to be disabled. (Constants.QUEUE, .Handler, .SUSPEND_HNDLR)
  • context
pyvisa.ctwrapper.functions.find_next(library, find_list)[source]

Returns the next resource from the list of resources found during a previous call to find_resources().

Parameters:
  • library – the visa library wrapped by ctypes.
  • find_list – Describes a find list. This parameter must be created by find_resources().
Returns:

Returns a string identifying the location of a device.

Return type:

unicode (Py2) or str (Py3)

pyvisa.ctwrapper.functions.find_resources(library, session, query)[source]

Queries a VISA system to locate the resources associated with a specified interface.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session (unused, just to uniform signatures).
  • query – A regular expression followed by an optional logical expression. Use ‘?*’ for all.
Returns:

find_list, return_counter, instrument_description

Return type:

ViFindList, int, unicode (Py2) or str (Py3)

pyvisa.ctwrapper.functions.flush(library, session, mask)[source]

Manually flushes the specified buffers associated with formatted I/O operations and/or serial communication.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • mask – Specifies the action to be taken with flushing the buffer. (Constants.READ*, .WRITE*, .IO*)
pyvisa.ctwrapper.functions.get_attribute(library, session, attribute)[source]

Retrieves the state of an attribute.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session, event, or find list.
  • attribute – 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

pyvisa.ctwrapper.functions.get_default_resource_manager(library)

A deprecated alias. See VPP-4.3, rule 4.3.5 and observation 4.3.2.

pyvisa.ctwrapper.functions.gpib_command(library, session, data)[source]

Write GPIB command bytes on the bus.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • data (bytes) – data tor write.
Returns:

Number of written bytes.

pyvisa.ctwrapper.functions.gpib_control_atn(library, session, mode)[source]

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

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • mode – Specifies the state of the ATN line and optionally the local active controller state. (Constants.GPIB_ATN*)
pyvisa.ctwrapper.functions.gpib_control_ren(library, session, mode)[source]

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

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • mode – Specifies the state of the REN line and optionally the device remote/local state. (Constants.GPIB_REN*)
pyvisa.ctwrapper.functions.gpib_pass_control(library, session, primary_address, secondary_address)[source]

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

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • 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.
pyvisa.ctwrapper.functions.gpib_send_ifc(library, session)[source]

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

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
pyvisa.ctwrapper.functions.in_16(library, session, space, offset, extended=False)[source]

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

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • space – Specifies the address space. (Constants.*SPACE*)
  • offset – Offset (in bytes) of the address or register from which to read.
  • extended – Use 64 bits offset independent of the platform.
Returns:

Data read from memory.

pyvisa.ctwrapper.functions.in_32(library, session, space, offset, extended=False)[source]

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

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • space – Specifies the address space. (Constants.*SPACE*)
  • offset – Offset (in bytes) of the address or register from which to read.
  • extended – Use 64 bits offset independent of the platform.
Returns:

Data read from memory.

pyvisa.ctwrapper.functions.in_8(library, session, space, offset, extended=False)[source]

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

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • space – Specifies the address space. (Constants.*SPACE*)
  • offset – Offset (in bytes) of the address or register from which to read.
  • extended – Use 64 bits offset independent of the platform.
Returns:

Data read from memory.

pyvisa.ctwrapper.functions.install_handler(library, session, event_type, handler, user_handle)[source]

Installs handlers for event callbacks.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • 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:

a handler descriptor which consists of three elements: - handler (a python callable) - user handle (a ctypes object) - ctypes handler (ctypes object wrapping handler)

pyvisa.ctwrapper.functions.lock(library, session, lock_type, timeout, requested_key=None)[source]

Establishes an access mode to the specified resources.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • lock_type – Specifies the type of lock requested, either Constants.EXCLUSIVE_LOCK or Constants.SHARED_LOCK.
  • timeout – Absolute time period (in milliseconds) that a resource waits to get unlocked by the locking session before returning an error.
  • requested_key – This parameter is not used and should be set to VI_NULL when lockType is VI_EXCLUSIVE_LOCK.
Returns:

access_key that can then be passed to other sessions to share the lock.

pyvisa.ctwrapper.functions.map_address(library, session, map_space, map_base, map_size, access=0, suggested=0)[source]

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

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • map_space – Specifies the address space to map. (Constants.*SPACE*)
  • map_base – Offset (in bytes) of the memory to be mapped.
  • map_size – Amount of memory to map (in bytes).
  • access
  • suggested – If not Constants.NULL (0), the operating system attempts to map the memory to the address specified in suggested. 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 suggested.
Returns:

Address in your process space where the memory was mapped.

pyvisa.ctwrapper.functions.map_trigger(library, session, trigger_source, trigger_destination, mode)[source]

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

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • trigger_source – Source line from which to map. (Constants.TRIG*)
  • trigger_destination – Destination line to which to map. (Constants.TRIG*)
  • mode
pyvisa.ctwrapper.functions.memory_allocation(library, session, size, extended=False)[source]

Allocates memory from a resource’s memory region.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • size – Specifies the size of the allocation.
  • extended – Use 64 bits offset independent of the platform.
Returns:

Returns the offset of the allocated memory.

pyvisa.ctwrapper.functions.memory_free(library, session, offset, extended=False)[source]

Frees memory previously allocated using the memory_allocation() operation.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • offset – Offset of the memory to free.
  • extended – Use 64 bits offset independent of the platform.
pyvisa.ctwrapper.functions.move(library, session, source_space, source_offset, source_width, destination_space, destination_offset, destination_width, length)[source]

Moves a block of data.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • source_space – Specifies the address space of the source.
  • source_offset – Offset of the starting address or register from which to read.
  • source_width – Specifies the data width of the source.
  • destination_space – Specifies the address space of the destination.
  • destination_offset – Offset of the starting address or register to which to write.
  • destination_width – Specifies the data width of the destination.
  • length – Number of elements to transfer, where the data width of the elements to transfer is identical to the source data width.
pyvisa.ctwrapper.functions.move_asynchronously(library, session, source_space, source_offset, source_width, destination_space, destination_offset, destination_width, length)[source]

Moves a block of data asynchronously.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • source_space – Specifies the address space of the source.
  • source_offset – Offset of the starting address or register from which to read.
  • source_width – Specifies the data width of the source.
  • destination_space – Specifies the address space of the destination.
  • destination_offset – Offset of the starting address or register to which to write.
  • destination_width – Specifies the data width of the destination.
  • length – Number of elements to transfer, where the data width of the elements to transfer is identical to the source data width.
Returns:

Job identifier of this asynchronous move operation.

pyvisa.ctwrapper.functions.move_in_16(library, session, space, offset, length, extended=False)[source]

Moves an 16-bit block of data from the specified address space and offset to local memory.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • 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.
  • extended – Use 64 bits offset independent of the platform.
Returns:

Data read from bus.

Corresponds to viMoveIn16 functions of the visa library.

pyvisa.ctwrapper.functions.move_in_32(library, session, space, offset, length, extended=False)[source]

Moves an 32-bit block of data from the specified address space and offset to local memory.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • 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.
  • extended – Use 64 bits offset independent of the platform.
Returns:

Data read from bus.

Corresponds to viMoveIn32 functions of the visa library.

pyvisa.ctwrapper.functions.move_in_8(library, session, space, offset, length, extended=False)[source]

Moves an 8-bit block of data from the specified address space and offset to local memory.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • 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.
  • extended – Use 64 bits offset independent of the platform.
Returns:

Data read from bus.

Corresponds to viMoveIn8 functions of the visa library.

pyvisa.ctwrapper.functions.move_out_16(library, session, space, offset, length, data, extended=False)[source]

Moves an 16-bit block of data from local memory to the specified address space and offset.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • 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.
  • extended – Use 64 bits offset independent of the platform.

Corresponds to viMoveOut16 functions of the visa library.

pyvisa.ctwrapper.functions.move_out_32(library, session, space, offset, length, data, extended=False)[source]

Moves an 32-bit block of data from local memory to the specified address space and offset.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • 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.
  • extended – Use 64 bits offset independent of the platform.

Corresponds to viMoveOut32 functions of the visa library.

pyvisa.ctwrapper.functions.move_out_8(library, session, space, offset, length, data, extended=False)[source]

Moves an 8-bit block of data from local memory to the specified address space and offset.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • 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.
  • extended – Use 64 bits offset independent of the platform.

Corresponds to viMoveOut8 functions of the visa library.

pyvisa.ctwrapper.functions.open(library, session, resource_name, access_mode=0, open_timeout=0)[source]

Opens a session to the specified resource.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Resource Manager session (should always be a session returned from open_default_resource_manager()).
  • resource_name – Unique symbolic name of a resource.
  • access_mode – Specifies the mode by which the resource is to be accessed. (Constants.NULL or Constants.*LOCK*)
  • open_timeout – Specifies the maximum time period (in milliseconds) that this operation waits before returning an error.
Returns:

Unique logical identifier reference to a session.

pyvisa.ctwrapper.functions.open_default_resource_manager(library)[source]

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

Parameters:library – the visa library wrapped by ctypes.
Returns:Unique logical identifier to a Default Resource Manager session.
pyvisa.ctwrapper.functions.out_16(library, session, space, offset, data, extended=False)[source]

Write in an 16-bit value from the specified memory space and offset. :param library: the visa library wrapped by ctypes. :param session: Unique logical identifier to a session. :param space: Specifies the address space. (Constants.*SPACE*) :param offset: Offset (in bytes) of the address or register from which to read. :param data: Data to write to bus. :param extended: Use 64 bits offset independent of the platform.

Corresponds to viOut16 functions of the visa library.

pyvisa.ctwrapper.functions.out_32(library, session, space, offset, data, extended=False)[source]

Write in an 32-bit value from the specified memory space and offset. :param library: the visa library wrapped by ctypes. :param session: Unique logical identifier to a session. :param space: Specifies the address space. (Constants.*SPACE*) :param offset: Offset (in bytes) of the address or register from which to read. :param data: Data to write to bus. :param extended: Use 64 bits offset independent of the platform.

Corresponds to viOut32 functions of the visa library.

pyvisa.ctwrapper.functions.out_8(library, session, space, offset, data, extended=False)[source]

Write in an 8-bit value from the specified memory space and offset. :param library: the visa library wrapped by ctypes. :param session: Unique logical identifier to a session. :param space: Specifies the address space. (Constants.*SPACE*) :param offset: Offset (in bytes) of the address or register from which to read. :param data: Data to write to bus. :param extended: Use 64 bits offset independent of the platform.

Corresponds to viOut8 functions of the visa library.

pyvisa.ctwrapper.functions.parse_resource(library, session, resource_name)[source]

Parse a resource string to get the interface information.

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

Resource information with interface type and board number.

Return type:

:class:ResourceInfo

pyvisa.ctwrapper.functions.parse_resource_extended(library, session, resource_name)[source]

Parse a resource string to get extended interface information.

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

Resource information.

Return type:

:class:ResourceInfo

pyvisa.ctwrapper.functions.peek_16(library, session, address)[source]

Read an 16-bit value from the specified address.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • address – Source address to read the value.
Returns:

Data read from bus.

Return type:

bytes

pyvisa.ctwrapper.functions.peek_32(library, session, address)[source]

Read an 32-bit value from the specified address.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • address – Source address to read the value.
Returns:

Data read from bus.

Return type:

bytes

pyvisa.ctwrapper.functions.peek_8(library, session, address)[source]

Read an 8-bit value from the specified address.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • address – Source address to read the value.
Returns:

Data read from bus.

Return type:

bytes

pyvisa.ctwrapper.functions.poke_16(library, session, address, data)[source]

Write an 16-bit value from the specified address.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • address – Source address to read the value.
  • data – value to be written to the bus.
Returns:

Data read from bus.

pyvisa.ctwrapper.functions.poke_32(library, session, address, data)[source]

Write an 32-bit value from the specified address.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • address – Source address to read the value.
  • data – value to be written to the bus.
Returns:

Data read from bus.

pyvisa.ctwrapper.functions.poke_8(library, session, address, data)[source]

Write an 8-bit value from the specified address.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • address – Source address to read the value.
  • data – value to be written to the bus.
Returns:

Data read from bus.

pyvisa.ctwrapper.functions.read(library, session, count)[source]

Reads data from device or interface synchronously.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • count – Number of bytes to be read.
Returns:

data read.

Return type:

bytes

pyvisa.ctwrapper.functions.read_asynchronously(library, session, count)[source]

Reads data from device or interface asynchronously.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • count – Number of bytes to be read.
Returns:

(ctypes buffer with result, jobid)

pyvisa.ctwrapper.functions.read_to_file(library, session, filename, count)[source]

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

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • filename – Name of file to which data will be written.
  • count – Number of bytes to be read.
Returns:

Number of bytes actually transferred.

pyvisa.ctwrapper.functions.read_stb(library, session)[source]

Reads a status byte of the service request.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
Returns:

Service request status byte.

pyvisa.ctwrapper.functions.set_attribute(library, session, attribute, attribute_state)[source]

Sets the state of an attribute.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • attribute – Attribute for which the state is to be modified. (Attributes.*)
  • attribute_state – The state of the attribute to be set for the specified object.
pyvisa.ctwrapper.functions.set_buffer(library, session, mask, size)[source]

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

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • mask – Specifies the type of buffer. (Constants.READ_BUF, .WRITE_BUF, .IO_IN_BUF, .IO_OUT_BUF)
  • size – The size to be set for the specified buffer(s).
pyvisa.ctwrapper.functions.status_description(library, session, status)[source]

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

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • status – Status code to interpret.
Returns:

The user-readable string interpretation of the status code passed to the operation.

Return type:

unicode (Py2) or str (Py3)

pyvisa.ctwrapper.functions.terminate(library, session, degree, job_id)[source]

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

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • degree – Constants.NULL
  • job_id – Specifies an operation identifier.
pyvisa.ctwrapper.functions.uninstall_handler(library, session, event_type, handler, user_handle=None)[source]

Uninstalls handlers for events.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • 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.
pyvisa.ctwrapper.functions.unlock(library, session)[source]

Relinquishes a lock for the specified resource.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
pyvisa.ctwrapper.functions.unmap_address(library, session)[source]

Unmaps memory space previously mapped by map_address().

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
pyvisa.ctwrapper.functions.unmap_trigger(library, session, trigger_source, trigger_destination)[source]

Undo a previous map from the specified trigger source line to the specified destination line.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • trigger_source – Source line used in previous map. (Constants.TRIG*)
  • trigger_destination – Destination line used in previous map. (Constants.TRIG*)
pyvisa.ctwrapper.functions.usb_control_in(library, session, request_type_bitmap_field, request_id, request_value, index, length=0)[source]

Performs a USB control pipe transfer from the device.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • 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

pyvisa.ctwrapper.functions.usb_control_out(library, session, request_type_bitmap_field, request_id, request_value, index, data=u'')[source]

Performs a USB control pipe transfer to the device.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • 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.
pyvisa.ctwrapper.functions.vxi_command_query(library, session, mode, command)[source]

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

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • mode – Specifies whether to issue a command and/or retrieve a response. (Constants.VXI_CMD*, .VXI_RESP*)
  • command – The miscellaneous command to send.
Returns:

The response retrieved from the device.

pyvisa.ctwrapper.functions.wait_on_event(library, session, in_event_type, timeout)[source]

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

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • in_event_type – Logical identifier of the event(s) to wait for.
  • timeout – 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:

Logical identifier of the event actually received, A handle specifying the unique occurrence of an event.

pyvisa.ctwrapper.functions.write(library, session, data)[source]

Writes data to device or interface synchronously.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • data (str) – data to be written.
Returns:

Number of bytes actually transferred.

pyvisa.ctwrapper.functions.write_asynchronously(library, session, data)[source]

Writes data to device or interface asynchronously.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • data – data to be written.
Returns:

Job ID of this asynchronous write operation.

pyvisa.ctwrapper.functions.write_from_file(library, session, filename, count)[source]

Take data from a file and write it out synchronously.

Parameters:
  • library – the visa library wrapped by ctypes.
  • session – Unique logical identifier to a session.
  • filename – Name of file from which data will be read.
  • count – Number of bytes to be written.
Returns:

Number of bytes actually transferred.