summaryrefslogtreecommitdiff
path: root/pyvisa/highlevel.py
diff options
context:
space:
mode:
authorRuben Undheim <ruben.undheim@gmail.com>2018-08-05 21:12:22 +0200
committerRuben Undheim <ruben.undheim@gmail.com>2018-08-05 21:12:22 +0200
commit482f79d72e2e19442e33bc9db5b7b8b10661381e (patch)
tree9997d042e0a52ea77d42295d61e04d38b16dfb0f /pyvisa/highlevel.py
parent9d6aa78a663d203b62be3caf70e7f37696dc38df (diff)
New upstream version 1.9.0
Diffstat (limited to 'pyvisa/highlevel.py')
-rw-r--r--pyvisa/highlevel.py37
1 files changed, 24 insertions, 13 deletions
diff --git a/pyvisa/highlevel.py b/pyvisa/highlevel.py
index a07f34a..b6f610b 100644
--- a/pyvisa/highlevel.py
+++ b/pyvisa/highlevel.py
@@ -16,6 +16,7 @@ from __future__ import division, unicode_literals, print_function, absolute_impo
import contextlib
import collections
import pkgutil
+import os
from collections import defaultdict
from . import logger
@@ -246,7 +247,7 @@ class VisaLibraryBase(object):
raise ValueError('%s is not a valid size. Valid values are 8, 16, 32 or 64' % width)
def write_memory(self, session, space, offset, data, width, extended=False):
- """Write in an 8-bit, 16-bit, 32-bit, value to the specified memory space and offset.
+ """Write in an 8-bit, 16-bit, 32-bit, 64-bit value to the specified memory space and offset.
Corresponds to viOut* functions of the VISA library.
@@ -265,8 +266,10 @@ class VisaLibraryBase(object):
return self.out_16(session, space, offset, data, extended)
elif width == 32:
return self.out_32(session, space, offset, data, extended)
+ elif width == 64:
+ return self.out_64(session, space, offset, data, extended)
- raise ValueError('%s is not a valid size. Valid values are 8, 16 or 32' % width)
+ raise ValueError('%s is not a valid size. Valid values are 8, 16, 32, or 64' % width)
def move_in(self, session, space, offset, length, width, extended=False):
"""Moves a block of data to local memory from the specified address space and offset.
@@ -322,7 +325,7 @@ class VisaLibraryBase(object):
raise ValueError('%s is not a valid size. Valid values are 8, 16, 32 or 64' % width)
def peek(self, session, address, width):
- """Read an 8, 16 or 32-bit value from the specified address.
+ """Read an 8, 16, 32, or 64-bit value from the specified address.
Corresponds to viPeek* functions of the VISA library.
@@ -345,7 +348,7 @@ class VisaLibraryBase(object):
raise ValueError('%s is not a valid size. Valid values are 8, 16, 32 or 64' % width)
def poke(self, session, address, width, data):
- """Writes an 8, 16 or 32-bit value from the specified address.
+ """Writes an 8, 16, 32, or 64-bit value from the specified address.
Corresponds to viPoke* functions of the VISA library.
@@ -363,8 +366,10 @@ class VisaLibraryBase(object):
return self.poke_16(session, address, data)
elif width == 32:
return self.poke_32(session, address, data)
+ elif width == 64:
+ return self.poke_64(session, address, data)
- raise ValueError('%s is not a valid size. Valid values are 8, 16 or 32' % width)
+ raise ValueError('%s is not a valid size. Valid values are 8, 16, 32, or 64' % width)
# Methods that VISA Library implementations must implement
@@ -1035,7 +1040,8 @@ class VisaLibraryBase(object):
return (ResourceInfo(parsed.interface_type_const,
parsed.board,
- parsed.resource_class, None, None),
+ parsed.resource_class,
+ str(parsed), None),
constants.StatusCode.success)
except ValueError:
return 0, constants.StatusCode.error_invalid_resource_name
@@ -1411,7 +1417,7 @@ def list_backends():
:rtype: list
"""
return ['ni'] + [name for (loader, name, ispkg) in pkgutil.iter_modules()
- if name.startswith('pyvisa-')]
+ if name.startswith('pyvisa-') and not name.endswith('-script')]
#: Maps backend name to VisaLibraryBase derived class
@@ -1432,12 +1438,11 @@ def get_wrapper_class(backend_name):
_WRAPPERS['ni'] = NIVisaLibrary
return NIVisaLibrary
- for pkgname in list_backends():
- if pkgname.endswith('-' + backend_name):
- pkg = __import__(pkgname)
- _WRAPPERS[backend_name] = cls = pkg.WRAPPER_CLASS
- return cls
- else:
+ try:
+ pkg = __import__('pyvisa-' + backend_name)
+ _WRAPPERS[backend_name] = cls = pkg.WRAPPER_CLASS
+ return cls
+ except ImportError:
raise ValueError('Wrapper not found: No package named pyvisa-%s' % backend_name)
@@ -1448,6 +1453,12 @@ def open_visa_library(specification):
wrapper will be created automatically when you create a ResourceManager object.
"""
+ if not specification:
+ try:
+ specification = os.environ['PYVISA_LIBRARY']
+ except KeyError:
+ logger.debug('No visa libaray specified and environment variable PYVISA_LIBRARY is unset. Using NI library')
+
try:
argument, wrapper = specification.split('@')
except ValueError: