首先,感谢您停下来阅读我的文章。我正在写一个测试软件来控制下面描述的一些仪器:
我遇到的问题是,在某些情况下,运行测试脚本时,仪器可以按预期运行,但是有些时候却不能。请在下面查看我的系统和VISA信息:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\M>python -m visa info
Machine Details:
Platform ID: Windows-7-6.1.7601-SP1
Processor: Intel64 Family 6 Model 70 Stepping 1, GenuineIntel
Python:
Implementation: CPython
Executable: C:\Python27\python.exe
Version: 2.7.15
Compiler: MSC v.1500 64 bit (AMD64)
Bits: 64bit
Build: Apr 30 2018 16:30:26 (#v2.7.15:ca079a3ea3)
Unicode: UCS2
PyVISA Version: 1.9.1
Backends:
ni:
Version: 1.9.1 (bundled with PyVISA)
#1: C:\Windows\System32\visa32.dll:
found by: auto
bitness: 64
Vendor: Keysight Technologies
Impl. Version: 1377151778
Spec. Version: 5244928
#2: C:\Windows\System32\visa64.dll:
found by: auto
bitness: 64
Vendor: Keysight Technologies
Impl. Version: 1377151778
Spec. Version: 5244928
py:
Version: 0.3.1
ASRL INSTR:
Please install PySerial (>=3.0) to use this resource type.
No module named serial
TCPIP INSTR: Available
USB RAW:
Please install PyUSB to use this resource type.
No module named usb
USB INSTR:
Please install PyUSB to use this resource type.
No module named usb
GPIB INSTR:
Please install linux-gpib to use this resource type.
No module named gpib
TCPIP SOCKET: Available
同样,请参见下面的代码:
import visa
import time
import pyvisa
try:
inst_visa = ("C:\Program Files\\IVI Foundation\\VISA\\Win64\\agvisa\\agbin\\visa32.dll")
rm = visa.ResourceManager(inst_visa)
rm.list_resources()
print(rm.list_resources())
print("Requesting Instruments ID \n")
SG8648C = rm.open_resource("GPIB0::12::INSTR")
SG8648C.timeout = 5000
print (SG8648C.query("*IDN?"))
time.sleep(3)
当我使用pyVISA调试模式运行代码时,这是我得到的错误:
2018-10-11 19:09:37,707 - pyvisa - DEBUG - viParseRsrcEx(18L, 'GPIB2::11::INSTR', 'c_ushort(1)', 'c_ushort(2)', <ctypes.c_char_Array_256 object at 0x000000000A03D8C8>, <ctypes.c_char_Array_256 object at 0x000000000A03D0C8>, <ctypes.c_char_Array_256 object at 0x000000000A03BF48>) -> 0
2018-10-11 19:09:37,717 - pyvisa - DEBUG - GPIB2::11::INSTR - opening ...
2018-10-11 19:09:37,737 - pyvisa - DEBUG - viOpen(18L, 'GPIB2::11::INSTR', <AccessModes.no_lock: 0>, 0, '<ViObject object at 0x000000000A03D0C8>') -> 0
2018-10-11 19:09:37,747 - pyvisa - DEBUG - GPIB2::11::INSTR - is open with session 25
2018-10-11 19:09:37,757 - pyvisa - DEBUG - GPIB2::11::INSTR - closing
2018-10-11 19:09:37,767 - pyvisa - DEBUG - viDisableEvent(10L, 1073709055, 65535) -> 0
2018-10-11 19:09:37,778 - pyvisa - DEBUG - viDiscardEvents(10L, 1073709055, 65535) -> 1073676292
2018-10-11 19:09:37,798 - pyvisa - DEBUG - viClose(10L,) -> 0
2018-10-11 19:09:37,808 - pyvisa - DEBUG - GPIB2::11::INSTR - is closed
2018-10-11 19:09:37,848 - pyvisa - DEBUG - viSetAttribute(25L, 1073676314, 5000) -> 0
2018-10-11 19:09:38,128 - pyvisa - DEBUG - viWrite(25L, '*IDN?\r\n', 7, 'c_ulong(7L)') -> 0
2018-10-11 19:09:38,138 - pyvisa - DEBUG - GPIB2::11::INSTR - reading 20480 bytes (last status <StatusCode.success_max_count_read: 1073676294>)
2018-10-11 19:09:45,197 - pyvisa - DEBUG - viRead(25L, <ctypes.c_char_Array_20480 object at 0x000000000A03D0C8>, 20480, 'c_ulong(0L)') -> -1073807360
2018-10-11 19:09:45,217 - pyvisa - DEBUG - GPIB2::11::INSTR - exception while reading: VI_ERROR_SYSTEM_ERROR (-1073807360): Unknown system error (miscellaneous error).
Buffer content: bytearray(b'')
Unhandled exception while debugging...
Traceback (most recent call last):
File "\\Mac\Home\Documents\Python Scripts\Python Win Scripts\F-B\F.009.py", line 82, in <module>
print (RF53210A.query("*IDN?"))
File "C:\Python27\lib\site-packages\pyvisa\resources\messagebased.py", line 569, in query
return self.read()
File "C:\Python27\lib\site-packages\pyvisa\resources\messagebased.py", line 413, in read
message = self._read_raw().decode(enco)
File "C:\Python27\lib\site-packages\pyvisa\resources\messagebased.py", line 386, in _read_raw
chunk, status = self.visalib.read(self.session, size)
File "C:\Python27\lib\site-packages\pyvisa\ctwrapper\functions.py", line 1584, 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)
希望任何人都可以帮助我。
预先感谢 哈维尔·卡西安