无法使用PyVISA查询仪器

时间:2015-05-20 20:59:35

标签: python visa

我正在努力控制Rohde&使用PyVISA的Schwarz信号发生器

PyVISA详细信息如下。

C:\Python27\lib\site-packages\pyvisa\ctwrapper\functions.py:1222: VisaIOWarning: VI_WARN_CONFIG_NLOADED (1073676407): The specified configuration either does not exist or could not be loaded. VISA-specified defaults will be used.
  ret = library.viOpenDefaultRM(byref(session))
Machine Details:
   Platform ID:    Windows-8-6.2.9200
   Processor:      Intel64 Family 6 Model 61 Stepping 4, GenuineIntel

Python:
   Implementation: CPython
   Executable:     C:\Python27\python.exe
   Version:        2.7.9
   Compiler:       MSC v.1500 32 bit (Intel)
   Bits:           32bit
   Build:          Dec 10 2014 12:24:55 (#default)
   Unicode:        UCS2

PyVISA Version: 1.7

Backends:
   ni:
      Version: 1.7 (bundled with PyVISA)
      #1: C:\Windows\system32\visa32.dll:
         found by: auto
         bitness: 32
         Vendor: National Instruments
         Impl. Version: 5243905
         Spec. Version: 5243136
      #2: C:\Windows\system32\visa32.dll:
         found by: auto
         bitness: 32
         Vendor: National Instruments
         Impl. Version: 5243905
         Spec. Version: 5243136

NI-VISA版本为5.4.1。 这是我运行以下代码时得到的结果

>>> import visa
>>> rm = visa.ResourceManager()
C:\Python27\lib\site-packages\pyvisa\ctwrapper\functions.py:1222: VisaIOWarning: VI_WARN_CONFIG_NLOADED (1073676407): The specified configuration either does not exist or could not be loaded. VISA-specified defaults will be used.
  ret = library.viOpenDefaultRM(byref(session))
>>> RAS = rm.open_resource('TCPIP::10.8.9.16::5025::SOCKET')
>>> RAS.ask("*idn?")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\pyvisa\resources\messagebased.py", line 387, in query
    return self.read()
  File "C:\Python27\lib\site-packages\pyvisa\resources\messagebased.py", line 312, in read
    message = self.read_raw().decode(enco)
  File "C:\Python27\lib\site-packages\pyvisa\resources\messagebased.py", line 286, in read_raw
    chunk, status = self.visalib.read(self.session, size)
  File "C:\Python27\lib\site-packages\pyvisa\ctwrapper\functions.py", line 1582, in read
    ret = library.viRead(session, buffer, count, byref(return_count))
  File "C:\Python27\lib\site-packages\pyvisa\ctwrapper\highlevel.py", line 188, in _return_handler
    raise errors.VisaIOError(ret_value)
pyvisa.errors.VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.
>>>

有谁知道我做错了什么?

2 个答案:

答案 0 :(得分:1)

我明白了。 而不是做

RAS = rm.open_resource('TCPIP::10.8.9.16::5025::SOCKET')

我只需要做

RAS = rm.open_resource('TCPIP::10.8.9.16::inst0::INSTR')

RAS = rm.open_resource('TCPIP::10.8.9.16::INSTR')

要么

答案 1 :(得分:0)

    import visa
    import socket


    try:
      #open connection
      rm = visa.ResourceManager()
      c = (rm.list_resources())
      myinst = rm.open_resource('TCPIP::xxx.xxx.xxx.xxx::inst0::INSTR')


      #Close Connection
      myinst.close()
      print 'close instrument connection'

    except Exception as err:
       print 'Exception: ' + str(err.message)

    finally:
      #perform clean up operations
      print 'complete'