Resource Manager
- class pyvisa.highlevel.ResourceInfo(interface_type, interface_board_number, resource_class, resource_name, alias)
Resource extended information
Named tuple with information about a resource. Returned by some
ResourceManager
methods.- Interface_type:
Interface type of the given resource string.
pyvisa.constants.InterfaceType
- Interface_board_number:
Board number of the interface of the given resource string. We allow None since serial resources may not sometimes be easily described by a single number in particular on Linux system.
- Resource_class:
Specifies the resource class (for example, “INSTR”) of the given resource string.
- Resource_name:
This is the expanded version of the given resource string. The format should be similar to the VISA-defined canonical resource name.
- Alias:
Specifies the user-defined alias for the given resource string.
- class pyvisa.highlevel.ResourceManager(visa_library: str | VisaLibraryBase = '')[source]
VISA Resource Manager.
- close() None [source]
Close the resource manager session.
Notes
Since the resource manager session is shared between instances this will also terminate connections obtained from other ResourceManager instances.
- property last_status: StatusCode
Last status code returned for an operation with this Resource Manager.
- list_resources(query: str = '?*::INSTR') Tuple[str, ...] [source]
Return a tuple of all connected devices matching query.
Notes
The query uses the VISA Resource Regular Expression syntax - which is not the same as the Python regular expression syntax. (see below)
The VISA Resource Regular Expression syntax is defined in the VISA Library specification: http://www.ivifoundation.org/docs/vpp43.pdf
Symbol Meaning ———- ———-
? Matches any one character.
- Makes the character that follows it an ordinary character
instead of special character. For example, when a question mark follows a backslash (?), it matches the ? character instead of any one character.
- [list] Matches any one character from the enclosed list. You can
use a hyphen to match a range of characters.
- [^list] Matches any character not in the enclosed list. You can use
a hyphen to match a range of characters.
Matches 0 or more occurrences of the preceding character or expression.
Matches 1 or more occurrences of the preceding character or expression.
- Exp|exp Matches either the preceding or following expression. The or
operator | matches the entire expression that precedes or follows it and not just the character that precedes or follows it. For example, VXI|GPIB means (VXI)|(GPIB), not VX(I|G)PIB.
(exp) Grouping characters or expressions.
Thus the default query, ‘?*::INSTR’, matches any sequences of characters ending ending with ‘::INSTR’.
On some platforms, devices that are already open are not returned.
- list_resources_info(query: str = '?*::INSTR') Dict[str, ResourceInfo] [source]
Get extended information about all connected devices matching query.
For details of the VISA Resource Regular Expression syntax used in query, refer to list_resources().
- Returns:
Mapping of resource name to ResourceInfo
- Return type:
Dict[str, ResourceInfo]
- open_bare_resource(resource_name: str, access_mode: AccessModes = AccessModes.no_lock, open_timeout: int = 0) Tuple[VISASession, StatusCode] [source]
Open the specified resource without wrapping into a class.
- Parameters:
resource_name (str) – Name or alias of the resource to open.
access_mode (constants.AccessModes, optional) – Specifies the mode by which the resource is to be accessed, by default constants.AccessModes.no_lock
open_timeout (int, optional) – 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, by default constants.VI_TMO_IMMEDIATE.
- Returns:
VISASession – Unique logical identifier reference to a session.
StatusCode – Return value of the library call.
- open_resource(resource_name: str, access_mode: AccessModes = AccessModes.no_lock, open_timeout: int = 0, resource_pyclass: Type[Resource] | None = None, **kwargs: Any) Resource [source]
Return an instrument for the resource name.
- Parameters:
resource_name (str) – Name or alias of the resource to open.
access_mode (constants.AccessModes, optional) – Specifies the mode by which the resource is to be accessed, by default constants.AccessModes.no_lock
open_timeout (int, optional) – 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, by default constants.VI_TMO_IMMEDIATE.resource_pyclass (Optional[Type[Resource]], optional) – Resource Python class to use to instantiate the Resource. Defaults to None: select based on the resource name.
kwargs (Any) – Keyword arguments to be used to change instrument attributes after construction.
- Returns:
Subclass of Resource matching the resource.
- Return type:
- resource_info(resource_name: str, extended: bool = True) ResourceInfo [source]
Get the (extended) information of a particular resource.
- property session: VISARMSession
Resource Manager session handle.
- Raises:
errors.InvalidSession – Raised if the session is closed.