我正在尝试通过他们的 VICP VISA 护照 (TCP/IP) 在 Windows7/32bit 和 NI-VISA 5.4.1 下使用 PyVISA 1.7 连接到 LeCroy Wavesurfer 400 系列:
import visa
rm = visa.ResourceManager()
scope = rm.open_resource("VICP::169.254.201.2::INSTR")
print(scope.query("*IDN?"))
我收到以下错误:
警告(来自警告模块):文件“C:\Python27\lib\site-packages\pyvisa\ctwrapper\functions.py”,第 1378 行 alias_if_exists)
VisaIOWarning: VI_WARN_EXT_FUNC_NIMPL (1073676457): 操作成功,但较低级别的驱动程序没有实现扩展功能。
回溯(最后一次调用):文件“C:\path\scopeTest.py”,第 4 行,范围 = rm.open_resource("VICP::169.254.201.2::INSTR")
文件“C:\Python27\lib\site-packages\pyvisa\highlevel.py”,第 1614 行,在 >open_resource info = self.resource_info(resource_name)
文件“C:\Python27\lib\site-packages\pyvisa\highlevel.py”,第 1584 行,位于 >resource_info
raise ValueError('Could not parse resource: %s (error code %s)' % >(resource_name, ret))
ValueError:无法解析资源:VICP::169.254.201.2::INSTR(错误代码无)
在 LabVIEW 下,与该 VICP 地址下的设备的连接和通信工作正常。此外,当使用TCPIP::
而不是VICP::
在open_resource()
连接中建立时,没有警告和错误并且print(scope.ask("*IDN?"))
可以正常工作,但其他设备命令scope.write("C1:VDIV .02")
不起作用
print(scope.query("C1:VDIV .02"))
WARNING : CURRENT REMOTE CONTROL INTERFACE IS TCPI
得出的结论是,为了正确控制设备,必须使用 VICP 通行证。当使用 PyVISA 1.5 但其他配置相同并尝试通过以下方式连接时:
scope = visa.instrument("VICP::169.254.201.2::INSTR")
给出:
警告(来自警告模块):文件“C:\Python27\lib\site-packages\pyvisa-1.5-py2.7.egg\pyvisa\ctwrapper\functions.py”,第 1208 行 alias_if_exists)
VisaIOWarning: VI_WARN_EXT_FUNC_NIMPL (1073676457): 操作成功,但较低级别的驱动程序没有实现扩展功能。
警告(来自警告模块):
文件“C:\Python27\lib\site-packages\pyvisa-1.5-py2.7.egg\pyvisa\highlevel.py”,第 315 行返回 Instrument(resource_name, resource_manager=self, **夸格斯)用户警告:给定资源不是 INSTR 但未知
对于 PyVISA 的早期版本,讨论了仪器的空字符串返回:
http://osdir.com/ml/python.pyvisa.devel/2007-07/msg00003.html
和
http://sourceforge.net/p/pyvisa/bugs/5/
我怀疑问题出在C:\Python27\lib\site-packages\pyvisa\constants.py中的InterfaceType对于 PyVISA 中的 VICP 连接协议不存在。当,在C:\Python27\lib\site-packages\pyvisa\highlevel.py中引发错误的行被调用resource_info()
def resource_info(self, resource_name): """Get the extended information of a particular resource :param resource_name: Unique symbolic name of a resource. :rtype: :class:`pyvisa.highlevel.ResourceInfo` """ ret, err = self.visalib.parse_resource_extended(self.session, resource_name) if err == constants.StatusCode.success: return ret raise ValueError('Could not parse resource: %s (error code %s)' %(resource_name, ret))
似乎导致与interface_type不匹配,或者它可能是resource_class的问题和与旧版本的 PyVISA 一样的返回问题?