summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Undheim <ruben.undheim@gmail.com>2018-08-19 22:12:30 +0200
committerRuben Undheim <ruben.undheim@gmail.com>2018-08-19 22:12:30 +0200
commit9c5924b696b7c9fa626464a294c5c235ed166bf8 (patch)
treed84d390f71a9ebacf7e300838c535bcfb26e9ecc
parent482f79d72e2e19442e33bc9db5b7b8b10661381e (diff)
New upstream version 1.9.1
-rw-r--r--CHANGES32
-rw-r--r--README41
-rw-r--r--docs/api/constants.rst4
-rw-r--r--docs/architecture.rst81
-rw-r--r--docs/backends.rst71
-rw-r--r--docs/conf.py2
-rw-r--r--docs/configuring.rst32
-rw-r--r--docs/faq.rst31
-rw-r--r--docs/getting.rst56
-rw-r--r--docs/getting_nivisa.rst44
-rw-r--r--docs/index.rst11
-rw-r--r--docs/rvalues.rst11
-rw-r--r--docs/tutorial.rst39
-rw-r--r--pyvisa/attributes.py9
-rw-r--r--pyvisa/ctwrapper/highlevel.py40
-rw-r--r--pyvisa/errors.py19
-rw-r--r--pyvisa/highlevel.py77
-rw-r--r--pyvisa/resources/messagebased.py20
-rw-r--r--pyvisa/rname.py4
-rw-r--r--pyvisa/testsuite/test_errors.py14
-rw-r--r--pyvisa/testsuite/test_rname.py18
-rw-r--r--setup.py15
22 files changed, 460 insertions, 211 deletions
diff --git a/CHANGES b/CHANGES
index 0c53b45..b2409e0 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,38 @@
PyVISA Changelog
================
+1.10 (unreleased)
+-----------------
+
+No changes yet
+
+
+1.9.1 (2018-08-13)
+------------------
+
+- Add expect_termination argument to read_binary_values and
+ query_binary_values. This allows to retain the behavior of these methods from
+ pyvisa 1.8, where the length of the block of values that is being read did
+ not include the very final read termination. For instruments omitting the
+ termination character when transferring binary data, visa library raises a
+ timeout exception in case pyvisa 1.9.0 is used. Note that the behavior is not
+ reverted completely to its pyvisa 1.8 state because for other instruments
+ (for example, Keysight PNA on Ethernet) the termination character is indeed
+ added at the end of the message, and is not counted in the declared length in
+ the header. Prior to 1.9, if the last character of the binary block is also
+ the termination character, the actual termination could be missed, which
+ leads to hard to debug bugs hence the choice to preserve 1.9 behavior by
+ default. PR #349
+- fix an encoding handling issue in setup.py PR #343
+- if installed use pyvisa-py backend if a binary VISA implementation is not
+ installed. PR #341
+- make custom exception hashable by removing __eq__. This should not impact
+ user code. PR #340
+- fix an issue with the default value for GPIB secondary address in rname.py
+ PR #336
+- ensure docstrings exist before manipulating them (attributes.py) PR #318
+- documentation improvements PR #320 #323
+
1.9 (2017-02-25)
----------------
diff --git a/README b/README
index 4d92397..72febd6 100644
--- a/README
+++ b/README
@@ -14,37 +14,48 @@ different protocols, sent over many different interfaces and bus systems
(GPIB, RS232, USB). For every programming language you want to use, you have to
find libraries that support both your device and its bus system.
-In order to ease this unfortunate situation, the Virtual Instrument Software Architecture
-(VISA_) specification was defined in the middle of the 90'. Today VISA is implemented on
-all significant operating systems. A couple of vendors offer VISA libraries, partly
-with free download. These libraries work together with arbitrary peripherical devices,
-although they may be limited to certain interface devices, such as the vendor’s GPIB card.
+In order to ease this unfortunate situation, the Virtual Instrument Software
+Architecture (VISA_) specification was defined in the middle of the 90'. Today
+VISA is implemented on all significant operating systems. A couple of vendors
+offer VISA libraries, partly with free download. These libraries work together
+with arbitrary peripheral devices, although they may be limited to certain
+interface devices, such as the vendor’s GPIB card.
+
+The VISA specification has explicit bindings to Visual Basic, C, and G
+(LabVIEW’s graphical language). Python can be used to call functions from a
+VISA shared library (`.dll`, `.so`, `.dylib`) allowing to directly leverage the
+standard implementations. In addition, Python can be used to directly access
+most bus systems used by instruments which is why one can envision to implement
+the VISA standard directly in Python (see the `PyVISA-Py` project for more
+details). PyVISA is both a Python wrapper for VISA shared libraries but
+can also serve as a front-end for other VISA implementation such as
+`PyVISA-Py`.
-The VISA specification has explicit bindings to Visual Basic, C, and G (LabVIEW’s graphical
-language. However, you can use VISA with any language capable of calling functions in a DLL.
-Python is such a language.
.. _VISA: http://www.ivifoundation.org/specifications/default.aspx
+.. _`PyVISA-Py`: http://pyvisa-py.readthedocs.io/en/latest/
VISA and Python
---------------
-Python has a couple of features that make it very interesting for measurement controlling:
+Python has a couple of features that make it very interesting for measurement
+controlling:
- Python is an easy-to-learn scripting language with short development cycles.
-- It represents a high abstraction level [2], which perfectly blends with the abstraction
- level of measurement programs.
-- It has a very rich set of native libraries, including numerical and plotting modules for
- data analysis and visualisation.
-- A large set of books (in many languages) and on-line publications is available.
+- It represents a high abstraction level [2], which perfectly blends with the
+ abstraction level of measurement programs.
+- It has a very rich set of native libraries, including numerical and plotting
+ modules for data analysis and visualisation.
+- A large set of books (in many languages) and on-line publications is
+ available.
Requirements
------------
-- VISA (tested with NI-VISA 3.2, WinXP, from www.ni.com/visa)
- Python (tested with 2.7 and 3.4+)
+- VISA (tested with NI-VISA 17.5, Win7, from www.ni.com/visa)
Installation
diff --git a/docs/api/constants.rst b/docs/api/constants.rst
index a3f14cb..398ad1c 100644
--- a/docs/api/constants.rst
+++ b/docs/api/constants.rst
@@ -1,10 +1,10 @@
.. _api_constants:
-.. py:module:: pyvisa.constants
-
Constants module
----------------
+.. py:module:: pyvisa.constants
+
Provides user-friendly naming to values used in different functions.
diff --git a/docs/architecture.rst b/docs/architecture.rst
index 3402a05..fafe3be 100644
--- a/docs/architecture.rst
+++ b/docs/architecture.rst
@@ -13,14 +13,18 @@ PyVISA implements convenient and Pythonic programming in three layers:
You will normally not need to access these functions directly. If you do,
it probably means that we need to improve layer 2.
- All level 1 functions are **static methods** of :class:`pyvisa.highlevel.VisaLibrary`.
+ All level 1 functions are **static methods** of
+ :class:`pyvisa.highlevel.VisaLibrary`.
- .. warning:: Notice however that low-level functions might not be present in all backends.
- For broader compatibility, do no use this layer. All the functionality should
- is available via the next layer.
+ .. warning::
+
+ Notice however that low-level functions might not be present in all
+ backends. For broader compatibility, do no use this layer. All the
+ functionality should is available via the next layer.
- 2. Middle-level: A wrapping Python function for each function of the shared visa library.
+ 2. Middle-level: A wrapping Python function for each function of the shared
+ visa library.
These functions call the low-level functions, adding some code to deal with
type conversions for functions that return values by reference.
@@ -30,27 +34,35 @@ PyVISA implements convenient and Pythonic programming in three layers:
aspects of the VISA library which are not implemented by the corresponding
resource class.
- All level 2 functions are **bound methods** of :class:`pyvisa.highlevel.VisaLibrary`.
+ All level 2 functions are **bound methods** of
+ :class:`pyvisa.highlevel.VisaLibrary`.
- 3. High-level: An object-oriented layer for :class:`pyvisa.highlevel.ResourceManager` and :class:`pyvisa.resources.Resource`
+ 3. High-level: An object-oriented layer for
+ :class:`pyvisa.highlevel.ResourceManager` and
+ :class:`pyvisa.resources.Resource`
- The ``ResourceManager`` implements methods to inspect connected resources. You also
- use this object to open other resources instantiating the appropriate ``Resource``
- derived classes.
+ The ``ResourceManager`` implements methods to inspect connected resources.
+ You also use this object to open other resources instantiating the
+ appropriate ``Resource`` derived classes.
- ``Resource`` and the derived classes implement functions and attributes access
- to the underlying resources in a Pythonic way.
+ ``Resource`` and the derived classes implement functions and attributes
+ access to the underlying resources in a Pythonic way.
-Most of the time you will only need to instantiate a ``ResourceManager``. For a given resource,
-you will use the :meth:`pyvisa.highlevel.ResourceManager.open_resource` method to obtain the appropriate object. If needed, you will
-be able to access the ``VisaLibrary`` object directly using the :attr:`pyvisa.highlevel.ResourceManager.visalib` attribute.
+Most of the time you will only need to instantiate a ``ResourceManager``. For a
+given resource, you will use the
+:meth:`pyvisa.highlevel.ResourceManager.open_resource` method to obtain the
+appropriate object. If needed, you will be able to access the ``VisaLibrary``
+object directly using the :attr:`pyvisa.highlevel.ResourceManager.visalib`
+attribute.
-The ``VisaLibrary`` does the low-level calls. In the default NI Backend, levels 1 and 2 are
-implemented in the same package called :mod:`pyvisa.ctwrapper` (which stands for ctypes wrapper).
-This package is included in PyVISA.
+The ``VisaLibrary`` does the low-level calls. In the default NI Backend,
+levels 1 and 2 are implemented in the same package called
+:mod:`pyvisa.ctwrapper` (which stands for ctypes wrapper). This package is
+included in PyVISA.
-Other backends can be used just by passing the name of the backend to ``ResourceManager``
-after the `@` symbol. See more information in :ref:`backends`.
+Other backends can be used just by passing the name of the backend to
+``ResourceManager`` after the `@` symbol. See more information in
+:ref:`backends`.
Calling middle- and low-level functions
@@ -61,17 +73,19 @@ After you have instantiated the ``ResourceManager``::
>>> import visa
>>> rm = visa.ResourceManager()
-you can access the corresponding ``VisaLibrary`` instance under the ``visalib`` attribute.
+you can access the corresponding ``VisaLibrary`` instance under the ``visalib``
+attribute.
-As an example, consider the VISA function ``viMapAddress``. It appears in the low-level
-layer as the static method ``viMapAddress`` of ``visalib`` attributed and also appears
-in the middle-level layer as ``map_address``.
+As an example, consider the VISA function ``viMapAddress``. It appears in the
+low-level layer as the static method ``viMapAddress`` of ``visalib`` attributed
+and also appears in the middle-level layer as ``map_address``.
-You can recognize low and middle-level functions by their names. Low-level functions
-carry the same name as in the shared library, and they are prefixed by **vi**.
-Middle-level functions have a friendlier, more pythonic but still recognizable name.
-Typically, camelCase names where stripped from the leading **vi** and changed to underscore
-separated lower case names. The docs about these methods is located here :ref:`api`.
+You can recognize low and middle-level functions by their names. Low-level
+functions carry the same name as in the shared library, and they are prefixed
+by **vi**. Middle-level functions have a friendlier, more pythonic but still
+recognizable name. Typically, camelCase names where stripped from the leading
+**vi** and changed to underscore separated lower case names. The docs about
+these methods is located here :ref:`api`.
Low-level
@@ -83,11 +97,12 @@ for example::
>>> rm.visalib.viMapAddress(<here goes the arguments>)
To call this functions you need to know the function declaration and how to
-interface it to python. To help you out, the ``VisaLibrary`` object also contains
-middle-level functions.
+interface it to python. To help you out, the ``VisaLibrary`` object also
+contains middle-level functions.
-It is very likely that you will need to access the VISA constants using these methods.
-You can find the information about these constants here :ref:`api_constants`
+It is very likely that you will need to access the VISA constants using these
+methods. You can find the information about these constants here
+:ref:`api_constants`
Middle-level
diff --git a/docs/backends.rst b/docs/backends.rst
index 53a7601..43b1b23 100644
--- a/docs/backends.rst
+++ b/docs/backends.rst
@@ -5,19 +5,20 @@ A frontend for multiple backends
================================
A small historical note might help to make this section clearer. So bear with
-with me for a couple of lines. Originally PyVISA was a Python wrapper to the VISA
-library. More specifically, it was :py:mod:`ctypes` wrapper around the NI-VISA.
-This approach worked fine but made it difficult to develop other ways to communicate
-with instruments in platforms where NI-VISA was not available. Users had to change
-their programs to use other packages with different API.
+with me for a couple of lines. Originally PyVISA was a Python wrapper to the
+VISA library. More specifically, it was :py:mod:`ctypes` wrapper around the
+NI-VISA. This approach worked fine but made it difficult to develop other ways
+to communicate with instruments in platforms where NI-VISA was not available.
+Users had to change their programs to use other packages with different API.
-Since 1.6, PyVISA is a frontend to VISA. It provides a nice, Pythonic API and can
-connect to multiple backends. Each backend exposes a class derived from VisaLibraryBase
-that implements the low-level communication. The ctypes wrapper around NI-VISA is the
-default backend (called **ni**) and is bundled with PyVISA for simplicity.
+Since 1.6, PyVISA is a frontend to VISA. It provides a nice, Pythonic API and
+can connect to multiple backends. Each backend exposes a class derived from
+VisaLibraryBase that implements the low-level communication. The ctypes wrapper
+around NI-VISA is the default backend (called **ni**) and is bundled with
+PyVISA for simplicity.
-You can specify the backend to use when you instantiate the resource manager using the
-``@`` symbol. Remembering that **ni** is the default, this::
+You can specify the backend to use when you instantiate the resource manager
+using the ``@`` symbol. Remembering that **ni** is the default, this::
>>> import visa
>>> rm = visa.ResourceManager()
@@ -32,20 +33,21 @@ You can still provide the path to the library if needed::
>>> import visa
>>> rm = visa.ResourceManager('/path/to/lib@ni')
-Under the hood, the :class:`pyvisa.highlevel.ResourceManager` looks for the requested backend and instantiate
-the VISA library that it provides.
+Under the hood, the :class:`pyvisa.highlevel.ResourceManager` looks for the
+requested backend and instantiate the VISA library that it provides.
PyVISA locates backends by name. If you do:
>>> import visa
>>> rm = visa.ResourceManager('@somename')
-PyVISA will try to import a package/module named ``pyvisa-somename`` which should be
-installed in your system. This is a loosly coupled configuration free method.
-PyVISA does not need to know about any backend out there until you actually
-try to use it.
+PyVISA will try to import a package/module named ``pyvisa-somename`` which
+should be installed in your system. This is a loosly coupled configuration free
+method. PyVISA does not need to know about any backend out there until you
+actually try to use it.
-You can list the installed backends by running the following code in the command line::
+You can list the installed backends by running the following code in the
+command line::
python -m visa info
@@ -62,8 +64,9 @@ What does a minimum backend looks like? Quite simple::
WRAPPER_CLASS = MyLibrary
-Additionally you can provide a staticmethod named get_debug_info` that should return a
-dictionary of debug information which is printed when you call ``python -m visa info``
+Additionally you can provide a staticmethod named get_debug_info` that should
+return a dictionary of debug information which is printed when you call
+``python -m visa info`` or ``pyvisa-info``
.. note::
@@ -72,24 +75,27 @@ dictionary of debug information which is printed when you call ``python -m visa
pyvisa will be named ``pyvisa-*-script`` and they are obviously not backends.
Examples are the ``pyvisa-shell`` and ``pyvisa-info`` scripts.
-An important aspect of developing a backend is knowing which VisaLibraryBase method to
-implement and what API to expose.
+An important aspect of developing a backend is knowing which VisaLibraryBase
+method to implement and what API to expose.
-A **complete** implementation of a VISA Library requires a lot of functions (basically almost
-all level 2 functions as described in :ref:`architecture` (there is also a complete list at the
-bottom of this page). But a working implementation does not require all of them.
+A **complete** implementation of a VISA Library requires a lot of functions
+(basically almost all level 2 functions as described in :ref:`architecture`
+(there is also a complete list at the bottom of this page). But a working
+implementation does not require all of them.
As a **very minimum** set you need:
- - **open_default_resource_manager**: returns a session to the Default Resource Manager resource.
+ - **open_default_resource_manager**: returns a session to the Default
+ Resource Manager resource.
- **open**: Opens a session to the specified resource.
- **close**: Closes the specified session, event, or find list.
- - **list_resources**: Returns a tuple of all connected devices matching query.
+ - **list_resources**: Returns a tuple of all connected devices matching
+ query.
(you can get the signature below or here :ref:`api_visalibrarybase`)
-But of course you cannot do anything interesting with just this. In general you will
-also need:
+But of course you cannot do anything interesting with just this. In general you
+will also need:
- **get_attribute**: Retrieves the state of an attribute.
- **set_atribute**: Sets the state of an attribute.
@@ -99,10 +105,11 @@ If you need to start sending bytes to MessageBased instruments you will require:
- **read**: Reads data from device or interface synchronously.
- **write**: Writes data to device or interface synchronously.
-For other usages or devices, you might need to implement other functions. Is really up to you
-and your needs.
+For other usages or devices, you might need to implement other functions. Is
+really up to you and your needs.
-These functions should raise a :class:`pyvisa.errors.VisaIOError` or emit a :class:`pyvisa.errors.VisaIOWarning` if necessary.
+These functions should raise a :class:`pyvisa.errors.VisaIOError` or emit a
+:class:`pyvisa.errors.VisaIOWarning` if necessary.
Complete list of level 2 functions to implement::
diff --git a/docs/conf.py b/docs/conf.py
index dd66e73..096e536 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -294,4 +294,4 @@ epub_copyright = copyright
# Example configuration for intersphinx: refer to the Python standard library.
-intersphinx_mapping = {'python': ('http://docs.python.org/2', None)}
+intersphinx_mapping = {'python': ('http://docs.python.org/3', None)}
diff --git a/docs/configuring.rst b/docs/configuring.rst
index 867722e..02bce68 100644
--- a/docs/configuring.rst
+++ b/docs/configuring.rst
@@ -2,27 +2,31 @@
Configuring the backend
============================
-Currently there are two backends available: The one included in pyvisa which
-uses the NI library. This is used by default and the configuration is described
-in the next chapter.
-And then there is pyvia-py a pure python implementation of the VISA libary.
-It can be selected by passing a parameter to the ResourceManager:
+
+Currently there are two backends available: The one included in pyvisa, which
+uses the NI library, and the backend provided by pyvisa-py, which is a pure python implementation of the VISA library.
+If no backend is specified, pyvisa uses the NI backend if the NI library has been installed (see next section for details). Failing that, it uses the pyvisa-py backend.
+
+You can also select a desired backend by passing a parameter to the ResourceManager, shown here for pyvisa-py:
>>> visa.ResourceManager('@py')
-Alternativly it can also be selected by setting the environment variable
+Alternatively it can also be selected by setting the environment variable
PYVISA_LIBRARY. It takes the same values as the ResourceManager constructor.
Configuring the NI backend
==========================
-.. note:: The NI backend requires that you install first the NI-VISA library. You can get
- info here: (:ref:`getting_nivisa`)
+.. note::
+
+ The NI backend requires that you install first the NI-VISA library. You can
+ get info here: (:ref:`getting_nivisa`)
-In most cases PyVISA will be able to find the location of the shared visa library.
-If this does not work or you want to use another one, you need to provide the library
-path to the :class:`pyvisa.highlevel.ResourceManager` constructor::
+In most cases PyVISA will be able to find the location of the shared visa
+library. If this does not work or you want to use another one, you need to
+provide the library path to the :class:`pyvisa.highlevel.ResourceManager`
+constructor::
>>> rm = ResourceManager('Path to library')
@@ -65,9 +69,9 @@ You can define a site-wide configuration file at
Under Windows, this file is usually placed at
:file:`c:\\Python27\\share\\pyvisa\\.pyvisarc`.
-If you encounter any problem, take a look at the :ref:`faq`. There you will find the
-solutions to common problem as well as useful debugging techniques. If everything fails,
-feel free to open an issue in our `issue tracker`_
+If you encounter any problem, take a look at the :ref:`faq`. There you will
+find the solutions to common problem as well as useful debugging techniques. If
+everything fails, feel free to open an issue in our `issue tracker`_
.. _`home directory`: http://en.wikipedia.org/wiki/Home_directory
.. _`issue tracker`: https://github.com/pyvisa/pyvisa/issues
diff --git a/docs/faq.rst b/docs/faq.rst
index 24df6df..b23146a 100644
--- a/docs/faq.rst
+++ b/docs/faq.rst
@@ -59,9 +59,9 @@ Check that the path provided to the constructor or in the configuration file
Error: Could not found VISA library
-----------------------------------
-This error occurs when you have not provided a path for the VISA library and PyVISA
-is not able to find it for you. You can solve it by providing the library path to the
-``VisaLibrary`` or ``ResourceManager`` constructor::
+This error occurs when you have not provided a path for the VISA library and
+PyVISA is not able to find it for you. You can solve it by providing the
+library path to the ``VisaLibrary`` or ``ResourceManager`` constructor::
>>> visalib = VisaLibrary('/path/to/library')
@@ -94,31 +94,34 @@ architecture.
Error while accessing /usr/local/vxipnp/linux/bin/libvisa.so.7:/usr/local/vxipnp/linux/bin/libvisa.so.7: wrong ELF class: ELFCLASS32
-First, determine the details of your installation with the help of the following debug command::
+First, determine the details of your installation with the help of the
+following debug command::
python -m visa info
-You will see the 'bitness' of the Python interpreter and at the end you will see the list of VISA
-libraries that PyVISA was able to find.
+You will see the 'bitness' of the Python interpreter and at the end you will
+see the list of VISA libraries that PyVISA was able to find.
The solution is to:
1. Install and use a VISA library matching your Python 'bitness'
- Download and install it from **National Instruments's VISA**. Run the debug
- command again to see if the new library was found by PyVISA. If not,
+ Download and install it from **National Instruments's VISA**. Run the
+ debug command again to see if the new library was found by PyVISA. If not,
create a configuration file as described in :ref:`configuring`.
- If there is no VISA library with the correct bitness available, try solution 2.
+ If there is no VISA library with the correct bitness available, try
+ solution 2.
or
2. Install and use a Python matching your VISA library 'bitness'
- In Windows and Linux: Download and install Python with the matching bitness.
- Run your script again using the new Python
+ In Windows and Linux: Download and install Python with the matching
+ bitness. Run your script again using the new Python
- In Mac OS X, Python is usually delivered as universal binary (32 and 64 bits).
+ In Mac OS X, Python is usually delivered as universal binary (32 and
+ 64 bits).
You can run it in 32 bit by running::
@@ -132,8 +135,8 @@ or
alias python32="arch -i386 python"
- into your .bashrc or .profile or ~/.bash_profile (or whatever file depending
- on which shell you are using.)
+ into your .bashrc or .profile or ~/.bash_profile (or whatever file
+ depending on which shell you are using.)
You can also create a `virtual environment`_ for this.
diff --git a/docs/getting.rst b/docs/getting.rst
index fda7fb7..e89baf1 100644
--- a/docs/getting.rst
+++ b/docs/getting.rst
@@ -10,46 +10,67 @@ You can install it using pip_::
$ pip install -U pyvisa
-NI Backend
-----------
-
-In order for PyVISA to work, you need to have a suitable backend. PyVISA includes
-a backend that wraps the `National Instruments's VISA`_ library. However, you need to download
-and install the library yourself (See :ref:`getting_nivisa`). There are multiple
-VISA implementations from different vendors. PyVISA is tested only against
+Backend
+-------
+
+In order for PyVISA to work, you need to have a suitable backend. PyVISA
+includes a backend that wraps the `National Instruments's VISA`_ library.
+However, you need to download and install the library yourself
+(See :ref:`getting_nivisa`). There are multiple VISA implementations from
+different vendors. PyVISA is tested only against
`National Instruments's VISA`_.
-.. warning:: PyVISA works with 32- and 64- bit Python and can deal with 32- and 64-bit VISA libraries without any extra configuration. What PyVISA cannot do is open a 32-bit VISA library while running in 64-bit Python (or the other way around).
+.. warning::
+
+ PyVISA works with 32- and 64- bit Python and can deal with 32- and 64-bit
+ VISA libraries without any extra configuration. What PyVISA cannot do is
+ open a 32-bit VISA library while running in 64-bit Python (or the other
+ way around).
+
+**You need to make sure that the Python and VISA library have the same bitness**
- **You need to make sure that the Python and VISA library have the same bitness**
+Alternatively, you can install `PyVISA-Py`_ which is a pure Python
+implementation of the VISA standard. You can install it using pip_::
+
+ $ pip install -U pyvisa-py
+
+.. note::
+
+ At the moment, `PyVISA-Py` implements only a limited subset of the VISA
+ standard and does not support all protocols on all bus systems. Please
+ refer to its documentation for more details.
Testing your installation
-------------------------
-That's all! You can check that PyVISA is correctly installed by starting up python, and creating a ResourceManager:
+That's all! You can check that PyVISA is correctly installed by starting up
+python, and creating a ResourceManager:
>>> import visa
>>> rm = visa.ResourceManager()
>>> print(rm.list_resources())
-If you encounter any problem, take a look at the :ref:`faq`. There you will find the
-solutions to common problem as well as useful debugging techniques. If everything fails,
-feel free to open an issue in our `issue tracker`_
+If you encounter any problem, take a look at the :ref:`faq`. There you will
+find the solutions to common problem as well as useful debugging techniques.
+If everything fails, feel free to open an issue in our `issue tracker`_
Using the development version
-----------------------------
-You can install the latest development version (at your own risk) directly form GitHub_::
+You can install the latest development version (at your own risk) directly
+form GitHub_::
$ pip install -U https://github.com/pyvisa/pyvisa/zipball/master
-.. note:: If you have an old system installation of Python and you don't want to
- mess with it, you can try `Anaconda CE`_. It is a free Python distribution by
- Continuum Analytics that includes many scientific packages.
+.. note::
+
+ If you have an old system installation of Python and you don't want to
+ mess with it, you can try `Anaconda CE`_. It is a free Python distribution
+ by Continuum Analytics that includes many scientific packages.
.. _easy_install: http://pypi.python.org/pypi/setuptools
@@ -60,3 +81,4 @@ You can install the latest development version (at your own risk) directly form
.. _GitHub: https://github.com/pyvisa/pyvisa
.. _`National Instruments's VISA`: http://ni.com/visa/
.. _`issue tracker`: https://github.com/pyvisa/pyvisa/issues
+.. _`PyVISA-Py`: http://pyvisa-py.readthedocs.io/en/latest/
diff --git a/docs/getting_nivisa.rst b/docs/getting_nivisa.rst
index 393f2eb..1661878 100644
--- a/docs/getting_nivisa.rst
+++ b/docs/getting_nivisa.rst
@@ -3,15 +3,25 @@
NI-VISA Installation
====================
-In every OS, the NI-VISA library bitness (i.e. 32- or 64-bit) has to match the Python bitness. So first you need to install a NI-VISA that works with your OS and then choose the Python version matching the installed NI-VISA bitness.
+In every OS, the NI-VISA library bitness (i.e. 32- or 64-bit) has to match the
+Python bitness. So first you need to install a NI-VISA that works with your OS
+and then choose the Python version matching the installed NI-VISA bitness.
-PyVISA includes a debugging command to help you troubleshoot this (and other things)::
+PyVISA includes a debugging command to help you troubleshoot this
+(and other things)::
python -m visa info
+
+or equivalently::
-According to National Instruments, NI VISA **5.4.1** is available for:
+ pyvisa-info
-.. note:: If NI-VISA is not available for your system, take a look at the :ref:`faq`.
+According to National Instruments, NI VISA **17.5** is available for the
+following platforms.
+
+.. note::
+
+ If NI-VISA is not available for your system, take a look at the :ref:`faq`.
Mac OS X
@@ -24,7 +34,9 @@ Supports:
- Mac OS X 10.7.x x86 and x86-64
- Mac OS X 10.8.x
-*64-bit VISA applications are supported for a limited set of instrumentation buses. The supported buses are ENET-Serial, USB, and TCPIP. Logging VISA operations in NI I/O Trace from 64-bit VISA applications is not supported.*
+*64-bit VISA applications are supported for a limited set of instrumentation
+buses. The supported buses are ENET-Serial, USB, and TCPIP. Logging VISA
+operations in NI I/O Trace from 64-bit VISA applications is not supported.*
Windows
-------
@@ -43,7 +55,8 @@ Suports:
- Windows Vista (32-bit version)
- Windows XP Service Pack 3
-*Support for Windows Server 2003 R2 may require disabling physical address extensions (PAE).*
+*Support for Windows Server 2003 R2 may require disabling physical address
+extensions (PAE).*
Linux
-----
@@ -59,10 +72,19 @@ Supports:
- Scientific Linux 6.x
- Scientific Linux 5.x
-*Currently, only 32-bit applications are supported on the x86-64 architecture.*
+More details details can be found in the `README`_ of the installer.
+
+.. note::
-.. note:: NI-VISA runs on other linux distros but the installation is more cumbersome.
+ NI-VISA runs on other linux distros but the installation is more
+ cumbersome. On Arch linux and related distributions, the AUR package
+ `ni-visa`_ (early development) is known to work for the USB and TCPIP
+ interfaces. Please note that you should restart after the installation for
+ things to work properly.
-.. _`NI-VISA for Mac OS X`: http://www.ni.com/download/ni-visa-14.0.2/5075/en/
-.. _`NI-VISA for Windows`: http://www.ni.com/download/ni-visa-5.4.1/4626/en/
-.. _`NI-VISA for Linux`: http://www.ni.com/download/ni-visa-5.4.1/4629/en/
+
+.. _`README`: http://download.ni.com/support/softlib//visa/NI-VISA/17.0/Linux/README.txt
+.. _`ni-visa`: https://aur.archlinux.org/packages/ni-visa/
+.. _`NI-VISA for Mac OS X`: http://www.ni.com/download/ni-visa-17.5/7224/en/
+.. _`NI-VISA for Windows`: http://www.ni.com/download/ni-visa-17.5/7220/en/
+.. _`NI-VISA for Linux`: http://www.ni.com/download/ni-visa-17.0/6700/en/
diff --git a/docs/index.rst b/docs/index.rst
index 874589a..a0dfb8c 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -47,9 +47,14 @@ work together with arbitrary peripherical devices, although they may be
limited to certain interface devices, such as the vendor's GPIB card.
The VISA specification has explicit bindings to Visual Basic, C, and G
-(LabVIEW's graphical language). However, you can use VISA with any language
-capable of calling functions in a shared library (`.dll`, `.so`, `.dylib`).
-PyVISA is Python wrapper for such shared library ... and more.
+(LabVIEW’s graphical language). Python can be used to call functions from a
+VISA shared library (`.dll`, `.so`, `.dylib`) allowing to directly leverage the
+standard implementations. In addition, Python can be used to directly access
+most bus systems used by instruments which is why one can envision to implement
+the VISA standard directly in Python (see the `PyVISA-Py` project for more
+details). PyVISA is both a Python wrapper for VISA shared libraries but
+can also serve as a front-end for other VISA implementation such as
+`PyVISA-Py`.
User guide
diff --git a/docs/rvalues.rst b/docs/rvalues.rst
index aecb6a6..a8b909e 100644
--- a/docs/rvalues.rst
+++ b/docs/rvalues.rst
@@ -82,6 +82,17 @@ the IEEE convention. If your instrument uses HP data block you can pass
``header_fmt='hp'`` to ``read_binary_values``. If your instrument does not use
any header for the data simply ``header_fmt='empty'``.
+By default PyVISA assumes, that the instrument will add the termination
+character at the end of the data block and actually makes sure it reads it to
+avoid issues. This behavior fits well a number of devices. However some devices
+omit the termination character, in which cases the operation will timeout.
+In this situation, first makes sure you can actually read from the instrument
+by reading the answer using the ``read_raw`` function (you may need to call it
+multiple time), and check that the advertized length of the block match what
+you get from your instrument (plus the header). If it is so, then you can
+safely pass ``expect_termination=False``, and PyVISA will not look for a
+termination character at the end of the message.
+
Writing ASCII values
--------------------
diff --git a/docs/tutorial.rst b/docs/tutorial.rst
index d099d57..b44cc6a 100644
--- a/docs/tutorial.rst
+++ b/docs/tutorial.rst
@@ -22,24 +22,30 @@ Let's go *in medias res* and have a look at a simple example::
This example already shows the two main design goals of PyVISA: preferring
simplicity over generality, and doing it the object-oriented way.
-After importing ``visa``, we create a ``ResourceManager`` object. If called without
-arguments, PyVISA will use the default backend (NI) which tries to find the
-VISA shared library for you. You can check, the location of the shared library
-used simply by:
+After importing ``visa``, we create a ``ResourceManager`` object. If called
+without arguments, PyVISA will use the default backend (NI) which tries to find
+the VISA shared library for you. You can check, the location of the shared
+library used simply by:
>>> print(rm)
<ResourceManager('/path/to/visa.so')>
-.. note:: In some cases, PyVISA is not able to find the library for you
- resulting in an ``OSError``. To fix it, find the library path
- yourself and pass it to the ResourceManager constructor.
- You can also specify it in a configuration file as discussed
- in :ref:`configuring`.
+.. note::
+
+ In some cases, PyVISA is not able to find the library for you resulting in
+ an ``OSError``. To fix it, find the library path yourself and pass it to
+ the ResourceManager constructor. You can also specify it in a configuration
+ file as discussed in :ref:`configuring`.
Once that you have a ``ResourceManager``, you can list the available resources
using the ``list_resources`` method. The output is a tuple listing the
-:ref:`resource_names`.
+:ref:`resource_names`. You can use a dedicated regular expression syntax to
+filter the instruments discovered by this method. The syntax is described in
+details in :py:meth:`~pyvisa.highlevel.ResourceManager.list_resources`. The
+default value is '?*::INSTR' which means that by default only instrument
+whose resource name ends with '::INSTR' (in particular USB RAW resources and
+TCPIP SOCKET resources are not listed).
In this case, there is a GPIB instrument with instrument number 14, so you ask
the ``ResourceManager`` to open "'GPIB0::14::INSTR'" and assign the returned
@@ -51,14 +57,15 @@ Notice ``open_resource`` has given you an instance of ``GPIBInstrument`` class
>>> print(my_instrument)
<GPIBInstrument('GPIB::14')>
-There many ``Resource`` subclasses representing the different types of resources, but
-you do not have to worry as the ``ResourceManager`` will provide you with the appropiate
-class. You can check the methods and attributes of each class in the :ref:`api_resources`
+There many ``Resource`` subclasses representing the different types of
+resources, but you do not have to worry as the ``ResourceManager`` will provide
+you with the appropriate class. You can check the methods and attributes of
+each class in the :ref:`api_resources`
Then, you query the device with the following message: ``'\*IDN?'``.
Which is the standard GPIB message for "what are you?" or -- in some cases --
-"what's on your display at the moment?". ``query`` is a short form for a ``write``
-operation to send a message, followed by a ``read``.
+"what's on your display at the moment?". ``query`` is a short form for a
+``write`` operation to send a message, followed by a ``read``.
So::
@@ -87,5 +94,3 @@ one ``query()`` call. Thus, the above source code is equivalent to::
print(itc4.query("V"))
It couldn't be simpler.
-
-
diff --git a/pyvisa/attributes.py b/pyvisa/attributes.py
index 80f8b9b..95e429d 100644
--- a/pyvisa/attributes.py
+++ b/pyvisa/attributes.py
@@ -41,7 +41,10 @@ class AttributeType(type):
if not name.startswith('AttrVI_'):
return
cls.attribute_id = getattr(constants, cls.visa_name)
- cls.redoc()
+ # Check that the docstring are populated before extending them
+ # Cover the case of running with Python with -OO option
+ if cls.__doc__ is not None:
+ cls.redoc()
if cls.resources is AllSessionTypes:
AttributesPerResource[AllSessionTypes].add(cls)
else:
@@ -181,7 +184,7 @@ class RangeAttribute(IntAttribute):
if not self.values:
raise ValueError('%r is an invalid value for attribute %s, '
'should be between %r and %r' % (
- value,
+ value,
self.visa_name,
self.min_value,
self.max_value))
@@ -190,7 +193,7 @@ class RangeAttribute(IntAttribute):
'should be between %r and %r or %r' % (
value,
self.visa_name,
- self.min_value,
+ self.min_value,
self.max_value,
self.values))
return value
diff --git a/pyvisa/ctwrapper/highlevel.py b/pyvisa/ctwrapper/highlevel.py
index 8269c41..8d51a71 100644
--- a/pyvisa/ctwrapper/highlevel.py
+++ b/pyvisa/ctwrapper/highlevel.py
@@ -196,7 +196,45 @@ class NIVisaLibrary(highlevel.VisaLibraryBase):
def list_resources(self, session, query='?*::INSTR'):
"""Returns a tuple of all connected devices matching query.
- :param query: regular expression used to match devices.
+ note: 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'.
+
+ :param query: a VISA Resource Regular Expression used to match devices.
"""
resources = []
diff --git a/pyvisa/errors.py b/pyvisa/errors.py
index b29534a..9c758fd 100644
--- a/pyvisa/errors.py
+++ b/pyvisa/errors.py
@@ -349,11 +349,7 @@ default_warnings = frozenset([VI_SUCCESS_MAX_CNT, VI_SUCCESS_DEV_NPRESENT,
class Error(Exception):
"""Abstract basic exception class for this module."""
- def __init__(self, description):
- super(Error, self).__init__(description)
-
- def __eq__(self, other):
- return self.__dict__ == other.__dict__
+ pass
class VisaIOError(Error):
@@ -371,7 +367,7 @@ class VisaIOError(Error):
self.error_code = error_code
self.abbreviation = abbreviation
self.description = description
-
+
def __reduce__(self):
return (VisaIOError, (self.error_code,))
@@ -390,12 +386,9 @@ class VisaIOWarning(Warning):
self.error_code = error_code
self.abbreviation = abbreviation
self.description = description
-
+
def __reduce__(self):
return (VisaIOWarning, (self.error_code,))
-
- def __eq__(self, other):
- return self.__dict__ == other.__dict__
class VisaTypeError(Error):
@@ -425,7 +418,7 @@ class UnknownHandler(Error):
self.event_type = event_type
self.handler = handler
self.user_handle = user_handle
-
+
def __reduce__(self):
return (UnknownHandler, (self.event_type, self.handler, self.user_handle))
@@ -435,7 +428,7 @@ class OSNotSupported(Error):
def __init__(self, os):
super(OSNotSupported, self).__init__(os + " is not yet supported by PyVISA")
self.os = os
-
+
def __reduce__(self):
return (OSNotSupported, (self.os,))
@@ -449,7 +442,7 @@ class InvalidBinaryFormat(Error):
self.description = description
def __reduce__(self):
- return (InvalidBinaryFormat, (self.description,))
+ return (InvalidBinaryFormat, (self.description,))
class InvalidSession(Error):
diff --git a/pyvisa/highlevel.py b/pyvisa/highlevel.py
index b6f610b..8b777c3 100644
--- a/pyvisa/highlevel.py
+++ b/pyvisa/highlevel.py
@@ -1446,6 +1446,30 @@ def get_wrapper_class(backend_name):
raise ValueError('Wrapper not found: No package named pyvisa-%s' % backend_name)
+def _get_default_wrapper():
+ """Return an available default VISA wrapper as a string ('ni' or 'py').
+
+ Use NI if the binary is found, else try to use pyvisa-py.
+ If neither can be found, raise a ValueError.
+ """
+
+ from .ctwrapper import NIVisaLibrary
+ ni_binary_found = bool(NIVisaLibrary.get_library_paths())
+ if ni_binary_found:
+ logger.debug('The NI implementation available')
+ return 'ni'
+ else:
+ logger.debug('Did not find NI binary')
+
+ try:
+ get_wrapper_class('py') # check for pyvisa-py availability
+ logger.debug('pyvisa-py is available.')
+ return 'py'
+ except ValueError:
+ logger.debug('Did not find pyvisa-py package')
+ raise ValueError('Could not locate a VISA implementation. Install either the NI binary or pyvisa-py.')
+
+
def open_visa_library(specification):
"""Helper function to create a VISA library wrapper.
@@ -1454,16 +1478,19 @@ def open_visa_library(specification):
"""
if not specification:
+ logger.debug('No visa library specified, trying to find alternatives.')
try:
specification = os.environ['PYVISA_LIBRARY']
except KeyError:
- logger.debug('No visa libaray specified and environment variable PYVISA_LIBRARY is unset. Using NI library')
+ logger.debug('Environment variable PYVISA_LIBRARY is unset.')
try:
argument, wrapper = specification.split('@')
except ValueError:
argument = specification
- wrapper = 'ni'
+ wrapper = None # Flag that we need a fallback, but avoid nested exceptions
+ if wrapper is None:
+ wrapper = _get_default_wrapper()
cls = get_wrapper_class(wrapper)
@@ -1565,7 +1592,46 @@ class ResourceManager(object):
def list_resources(self, query='?*::INSTR'):
"""Returns a tuple of all connected devices matching query.
- :param query: regular expression used to match devices.
+ note: 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'.
+
+ :param query: a VISA Resource Regular Expression used to match devices.
+
"""
return self.visalib.list_resources(self.session, query)
@@ -1573,8 +1639,11 @@ class ResourceManager(object):
def list_resources_info(self, query='?*::INSTR'):
"""Returns a dictionary mapping resource names to resource extended
information of all connected devices matching query.
+
+ For details of the VISA Resource Regular Expression syntax used in query,
+ refer to list_resources().
- :param query: regular expression used to match devices.
+ :param query: a VISA Resource Regular Expression used to match devices.
:return: Mapping of resource name to ResourceInfo
:rtype: dict[str, :class:`pyvisa.highlevel.ResourceInfo`]
"""
diff --git a/pyvisa/resources/messagebased.py b/pyvisa/resources/messagebased.py
index 588ed26..ca92fb1 100644
--- a/pyvisa/resources/messagebased.py
+++ b/pyvisa/resources/messagebased.py
@@ -449,7 +449,8 @@ class MessageBasedResource(Resource):
return util.from_ascii_block(block, converter, separator, container)
def read_binary_values(self, datatype='f', is_big_endian=False,
- container=list, header_fmt='ieee'):
+ container=list, header_fmt='ieee',
+ expect_termination=True):
"""Read values from the device in binary format returning an iterable
of values.
@@ -460,6 +461,10 @@ class MessageBasedResource(Resource):
:param container: container type to use for the output data.
:param header_fmt: format of the header prefixing the data. Possible
values are: 'ieee', 'hp', 'empty'
+ :param expect_termination: when set to False, the expected length of
+ the binary values block does not account
+ for the final termination character (the
+ read termination)
:returns: the answer from the device.
:rtype: type(container)
@@ -475,7 +480,7 @@ class MessageBasedResource(Resource):
is_big_endian)
expected_length = offset + data_length
- if self._read_termination is not None:
+ if expect_termination and self._read_termination is not None:
expected_length += len(self._read_termination)
while len(block) < expected_length:
@@ -492,7 +497,7 @@ class MessageBasedResource(Resource):
return util.from_binary_block(block, 0, None, datatype,
is_big_endian, container)
else:
- raise
+ raise ValueError('Unsupported binary block format.')
except ValueError as e:
raise errors.InvalidBinaryFormat(e.args)
@@ -624,7 +629,8 @@ class MessageBasedResource(Resource):
delay)
def query_binary_values(self, message, datatype='f', is_big_endian=False,
- container=list, delay=None, header_fmt='ieee'):
+ container=list, delay=None, header_fmt='ieee',
+ expect_termination=True):
"""Query the device for values in binary format returning an iterable
of values.
@@ -636,6 +642,10 @@ class MessageBasedResource(Resource):
:param container: container type to use for the output data.
:param delay: delay in seconds between write and read operations.
if None, defaults to self.query_delay
+ :param expect_termination: when set to False, the expected length of
+ the binary values block does not account
+ for the final termination character (the
+ read termination)
:returns: the answer from the device.
:rtype: list
"""
@@ -650,7 +660,7 @@ class MessageBasedResource(Resource):
time.sleep(delay)
return self.read_binary_values(datatype, is_big_endian, container,
- header_fmt)
+ header_fmt, expect_termination)
def ask_for_values(self, message, fmt=None, delay=None):
"""A combination of write(message) and read_values()
diff --git a/pyvisa/rname.py b/pyvisa/rname.py
index 4cb1a58..f11f6db 100644
--- a/pyvisa/rname.py
+++ b/pyvisa/rname.py
@@ -345,9 +345,11 @@ def build_rn_class(interface_type, resource_parts, resource_class,
# Build subclasses for each resource
+# Reference for the GPIB secondary address
+# https://www.mathworks.com/help/instrument/secondaryaddress.html
GPIBInstr = build_rn_class('GPIB',
(('board', '0'), ('primary address', None),
- ('secondary address', constants.VI_NO_SEC_ADDR)),
+ ('secondary address', '0')),
'INSTR')
GPIBIntfc = build_rn_class('GPIB', (('board', '0'), ), 'INTFC', False)
diff --git a/pyvisa/testsuite/test_errors.py b/pyvisa/testsuite/test_errors.py
index bcecdec..d5bb61b 100644
--- a/pyvisa/testsuite/test_errors.py
+++ b/pyvisa/testsuite/test_errors.py
@@ -14,22 +14,24 @@ class TestPicleUnpickle(BaseTestCase):
pickled = pickle.dumps(instance)
unpickled = pickle.loads(pickled)
self.assertIsInstance(unpickled, type(instance))
- self.assertEqual(instance, unpickled)
+ for attr in instance.__dict__:
+ self.assertEqual(getattr(instance, attr),
+ getattr(unpickled, attr))
def test_VisaIOError(self):
self._test_pickle_unpickle(errors.VisaIOError(0))
-
+
def test_VisaIOWarning(self):
self._test_pickle_unpickle(errors.VisaIOWarning(0))
-
+
def test_UnknownHandler(self):
self._test_pickle_unpickle(errors.UnknownHandler(0,0,0))
-
+
def test_OSNotSupported(self):
self._test_pickle_unpickle(errors.OSNotSupported(""))
-
+
def test_InvalidBinaryFormat(self):
self._test_pickle_unpickle(errors.InvalidBinaryFormat())
-
+
def InvalidSession(self):
self._test_pickle_unpickle(errors.InvalidSession())
diff --git a/pyvisa/testsuite/test_rname.py b/pyvisa/testsuite/test_rname.py
index 55193ba..8e77d9c 100644
--- a/pyvisa/testsuite/test_rname.py
+++ b/pyvisa/testsuite/test_rname.py
@@ -41,37 +41,37 @@ class TestParsers(BaseTestCase):
canonical_resource_name='ASRL1::INSTR')
def test_gpib_instr(self):
- self._parse_test('GPIB::1::0::INSTR',
+ self._parse_test('GPIB::1::1::INSTR',
interface_type='GPIB',
resource_class='INSTR',
board='0',
primary_address='1',
- secondary_address='0',
- canonical_resource_name='GPIB0::1::0::INSTR')
+ secondary_address='1',
+ canonical_resource_name='GPIB0::1::1::INSTR')
self._parse_test('GPIB::1::INSTR',
interface_type='GPIB',
resource_class='INSTR',
board='0',
primary_address='1',
- secondary_address=65535,
- canonical_resource_name='GPIB0::1::65535::INSTR')
+ secondary_address='0',
+ canonical_resource_name='GPIB0::1::0::INSTR')
self._parse_test('GPIB1::1::INSTR',
interface_type='GPIB',
resource_class='INSTR',
board='1',
primary_address='1',
- secondary_address=65535,
- canonical_resource_name='GPIB1::1::65535::INSTR')
+ secondary_address='0',
+ canonical_resource_name='GPIB1::1::0::INSTR')
self._parse_test('GPIB1::1',
interface_type='GPIB',
resource_class='INSTR',
board='1',
primary_address='1',
- secondary_address=65535,
- canonical_resource_name='GPIB1::1::65535::INSTR')
+ secondary_address='0',
+ canonical_resource_name='GPIB1::1::0::INSTR')
def test_gpib_intf(self):
self._parse_test('GPIB::INTFC',
diff --git a/setup.py b/setup.py
index a3d05a8..2086c01 100644
--- a/setup.py
+++ b/setup.py
@@ -1,12 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-try:
- import sys
- reload(sys).setdefaultencoding("UTF-8")
-except:
- pass
-
+import sys
try:
from setuptools import setup
@@ -16,8 +11,8 @@ except ImportError:
def read(filename):
- with open(filename, 'r') as f:
- return f.read()
+ with open(filename, 'rb') as f:
+ return f.read().decode('utf8')
long_description = '\n\n'.join([read('README'),
@@ -27,12 +22,12 @@ long_description = '\n\n'.join([read('README'),
__doc__ = long_description
requirements = []
-if sys.version_info < (3, 4):
+if sys.version_info < (3,):
requirements.append('enum34')
setup(name='PyVISA',
description='Python VISA bindings for GPIB, RS232, TCPIP and USB instruments',
- version='1.9.0',
+ version='1.9.1',
long_description=long_description,
author='Torsten Bronger, Gregor Thalhammer',
author_email='bronger@physik.rwth-aachen.de',