首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用PyVISA查询仪器

无法使用PyVISA查询仪器
EN

Stack Overflow用户
提问于 2015-05-21 04:59:35
回答 2查看 2.6K关注 0票数 0

我正在尝试使用PyVISA控制罗德和施瓦茨信号发生器

PyVISA的详细信息如下。

代码语言:javascript
复制
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。下面是我在运行以下代码时得到的结果

代码语言:javascript
复制
>>> 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.
>>>

有人知道我做错了什么吗?

EN

回答 2

Stack Overflow用户

发布于 2015-05-21 06:50:50

我想通了。而不是做

代码语言:javascript
复制
RAS = rm.open_resource('TCPIP::10.8.9.16::5025::SOCKET')

我只是不得不做

代码语言:javascript
复制
RAS = rm.open_resource('TCPIP::10.8.9.16::inst0::INSTR')

代码语言:javascript
复制
RAS = rm.open_resource('TCPIP::10.8.9.16::INSTR')

两者都不管用

票数 1
EN

Stack Overflow用户

发布于 2015-10-26 07:04:43

代码语言:javascript
复制
    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'
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30360271

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档