Ben Fitzpatrick | 19 Jun 21:45 2007

Function return types not getting set properly

Hi everyone,

We're seeing some unusual behavior as we try to use the vpp43 module directly to
access quite a complicated instrument. Fortunately, the problem we're seeing
appears relatively simple.

The symptom is that if, for example, we run the following code, where
"" is not a device on our network:

import pyvisa.vpp43 as visa
defaultrm = visa.open_default_resource_manager()
foo =, "TCPIP::")

What we get is:
foo = 0L
visa.visa_status = 0

Which is clearly incorrect. Since the device doesn't exist, we should have
thrown a Visa IO Exception.

We tracked this down to the following code:
                self.__lib.__getattr__(visa_function).restype = check_status

in vpp43. This code runs (we put in a print statement), but doesn't seem to have
an effect:
<class 'ctypes.c_long'>

but if we then say:
visa.visa_library._VisaLibrary__lib.viOpen.restype = visa.check_status

We get the following:, "TCPIP::")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python25\lib\site-packages\pyvisa\", line 746, in open
  File "C:\Python25\lib\site-packages\pyvisa\", line 391, in check_statu
    raise visa_exceptions.VisaIOError, status
pyvisa.visa_exceptions.VisaIOError: VI_ERROR_RSRC_NFOUND: Insufficient location
information or the requested device or resource is not present in the system.

Which appears to be correct. Any thoughts on how we could get that to work on
import, or at least without doing it manually?

This is a default install of Python2.5 (problem happens identically on
Python2.4), with only the PyVisa and Swig packages installed. Any help would be

This email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.