pyvisa / pyvisa-py

A pure python PyVISA backend
https://pyvisa-py.readthedocs.io
MIT License
282 stars 120 forks source link

Centos 7 - pyvisa-py returns VI_ERROR_TMO while linux-gpib native python wrappers works fine #162

Closed LastStarDust closed 6 years ago

LastStarDust commented 6 years ago

The linux-gpib native python wrapper (Gpib.py) seems to work fine (after much tinkering) but I cannot get pyvisa + pyvisa-py to work. If there is additional info that I could report please let me know.

[***@*** ~]$ sudo python
[sudo] password for ***: 
Python 2.7.5 (default, Jul 13 2018, 13:06:57) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import visa
>>> rm = visa.ResourceManager('@py')
>>> rm.list_resources()
(u'GPIB0::24::INSTR',)
>>> inst = rm.open_resource('GPIB0::24::INSTR')
>>> print(inst.query("*IDN?"))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/pyvisa/resources/messagebased.py", line 563, in query
    self.write(message)
  File "/usr/lib/python2.7/site-packages/pyvisa/resources/messagebased.py", line 223, in write
    count = self.write_raw(message.encode(enco))
  File "/usr/lib/python2.7/site-packages/pyvisa/resources/messagebased.py", line 201, in write_raw
    return self.visalib.write(self.session, message)
  File "/usr/lib/python2.7/site-packages/pyvisa-py/highlevel.py", line 373, in write
    raise errors.VisaIOError(ret[1])
pyvisa.errors.VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.
>>> import Gpib
>>> inst = Gpib.Gpib(0,24)
>>> inst.write("*IDN?")
>>> inst.read(100)
'KEITHLEY INSTRUMENTS INC.,MODEL 2400,4302945,C33   Mar 31 2015 09:32:39/A02  /V/M\n'

PS Is there a way to use the GPIB device without sudo?

LastStarDust commented 6 years ago

Nevermind. After some time the query command started to work. Maybe the timeout was too short.