summaryrefslogtreecommitdiff
path: root/pyvisa/highlevel.py
diff options
context:
space:
mode:
authorHernan Grecco <hernan.grecco@gmail.com>2015-05-14 23:24:10 -0300
committerHernan Grecco <hernan.grecco@gmail.com>2015-05-14 23:24:10 -0300
commit69203fc89f8d5d95ffd3fe6b477374dab50b9d60 (patch)
treee6f6afd4c24fb812b6f0f450e6b370e1f269e2ea /pyvisa/highlevel.py
parentd552fd922b65eaf59bdfacc89099a7dd2909f195 (diff)
Changed VisaLibraryBase
Removed the following methods which are too low level and error prone - find_next - find_resources => Backend implementors should implement list_resources. Implmented the following methods using rname module - parse_resource - parse_resource_extended => Backend implementors can override them if necessary.
Diffstat (limited to 'pyvisa/highlevel.py')
-rw-r--r--pyvisa/highlevel.py36
1 files changed, 11 insertions, 25 deletions
diff --git a/pyvisa/highlevel.py b/pyvisa/highlevel.py
index e606a67..64611d5 100644
--- a/pyvisa/highlevel.py
+++ b/pyvisa/highlevel.py
@@ -21,6 +21,7 @@ from collections import defaultdict
from . import logger
from . import constants
from . import errors
+from . import rname
#: Resource extended information
#:
@@ -494,29 +495,6 @@ class VisaLibraryBase(object):
"""
raise NotImplementedError
- def find_next(self, find_list):
- """Returns the next resource from the list of resources found during a previous call to find_resources().
-
- Corresponds to viFindNext function of the VISA library.
-
- :param find_list: Describes a find list. This parameter must be created by find_resources().
- :return: Returns a string identifying the location of a device, return value of the library call.
- :rtype: unicode (Py2) or str (Py3), :class:`pyvisa.constants.StatusCode`
- """
- raise NotImplementedError
-
- def find_resources(self, session, query):
- """Queries a VISA system to locate the resources associated with a specified interface.
-
- Corresponds to viFindRsrc function of the VISA library.
-
- :param session: Unique logical identifier to a session (unused, just to uniform signatures).
- :param query: A regular expression followed by an optional logical expression. Use '?*' for all.
- :return: find_list, return_counter, instrument_description, return value of the library call.
- :rtype: ViFindList, int, unicode (Py2) or str (Py3), :class:`pyvisa.constants.StatusCode`
- """
- raise NotImplementedError
-
def flush(self, session, mask):
"""Manually flushes the specified buffers associated with formatted I/O operations and/or serial communication.
@@ -1039,7 +1017,7 @@ class VisaLibraryBase(object):
:return: Resource information with interface type and board number, return value of the library call.
:rtype: :class:`pyvisa.highlevel.ResourceInfo`, :class:`pyvisa.constants.StatusCode`
"""
- raise NotImplementedError
+ return self.parse_resource_extended(session, resource_name)
def parse_resource_extended(self, session, resource_name):
"""Parse a resource string to get extended interface information.
@@ -1052,7 +1030,15 @@ class VisaLibraryBase(object):
:return: Resource information, return value of the library call.
:rtype: :class:`pyvisa.highlevel.ResourceInfo`, :class:`pyvisa.constants.StatusCode`
"""
- raise NotImplementedError
+ try:
+ parsed = rname.parse_resource_name(resource_name)
+
+ return (ResourceInfo(parsed.interface_type_const,
+ parsed.board,
+ parsed.resource_class, None, None),
+ constants.StatusCode.success)
+ except ValueError:
+ return 0, constants.StatusCode.error_invalid_resource_name
def peek_8(self, session, address):
"""Read an 8-bit value from the specified address.