Open rmax7 opened 7 years ago
I was able to figure it out with help of a good friend.
scope.timeout = 5000
didn't work because of the following: You can see that, for the object "scope" here, after several layers of inheritance the base class is ivi.
But ivi actually creates the instrument object through pyvisa.py wrapper which in turn uses the open_resource method as required by PyVISA.
Here is the snippet from ivi.py
if 'pyvisa' in globals():
# connect with PyVISA
self._interface = pyvisa.PyVisaInstrument(resource)
and the snippet from pyvisa.py
# New style PyVISA
visa_rm = visa.ResourceManager()
visa_instrument_opener = visa_rm.open_resource
class PyVisaInstrument:
"PyVisa wrapper instrument interface client"
def __init__(self, resource, *args, **kwargs):
if type(resource) is str:
self.instrument = visa_instrument_opener(resource, *args, **kwargs)
So, in order to access the timeout attribute correctly, you have to use the following:
scope._interface.instrument.timeout = 5000
@rmax7 Thank you for posting this. I was getting crazy with this issue lately...
The default timeout is currently 2000 msec. But I need it to be higher (~ 5000 msec) in order to fetch screenshot from oscilloscope. But the PyVisaInstrument class in the pyvisa.py wrapper does not provide a method to set timeout.
I was able to fetch the screenshot successfully when I add the following method to ivi/interface/pyvisa.py
I was hoping I would be able to do it from my instrument object instead of modifying the ivi library source. For example like,
But it didn't work. Am I missing something?