Skip to content

Commit

Permalink
Merge pull request #112 from Galvant/pyvisa_fix
Browse files Browse the repository at this point in the history
Pyvisa version check fix
  • Loading branch information
scasagrande committed May 1, 2016
2 parents 26a882b + adebb8a commit ab379d7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion instruments/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
# In keeping with PEP-396, we define a version number of the form
# {major}.{minor}[.{postrelease}]{prerelease-tag}

__version__ = "0.0.2"
__version__ = "0.0.3"

__title__ = "instrumentkit"
__description__ = "Test and measurement communication library"
Expand Down
9 changes: 7 additions & 2 deletions instruments/abstract_instruments/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import collections
import socket

from builtins import map

from future.standard_library import install_aliases
import numpy as np

Expand Down Expand Up @@ -525,10 +527,13 @@ def open_visa(cls, resource_name):
if visa is None:
raise ImportError("PyVISA is required for loading VISA "
"instruments.")
if int(visa.__version__.replace(".", "")) >= 160:
version = list(map(int, visa.__version__.split(".")))
while len(version) < 3:
version += [0]
if version[0] >= 1 and version[1] >= 6:
ins = visa.ResourceManager().open_resource(resource_name)
else:
ins = visa.instrument(resource_name)
ins = visa.instrument(resource_name) #pylint: disable=no-member
return cls(VisaCommunicator(ins))

@classmethod
Expand Down

0 comments on commit ab379d7

Please sign in to comment.