PyVISA超时错误

时间:2016-03-30 00:39:00

标签: python

我正在尝试将范围文件从Tektronix传输到PC。不幸的是,我一直收到TIMEOUT错误。我的写作有效,但在阅读原始格式时,我被卡住了。 这是我的代码:

import visa
import time

scope = visa.ResourceManager()
tek = scope.open_resource('GPIB::1::INSTR')
tek.timeout=100000 # timeout 100s
print(tek.query('*IDN?'))
tek.write('FILESYSTEM:FRINT "C:\EDIR\EDIR_812\140mV.png", GPIB')

time.sleep(6)
data = tek.read_raw()
time.sleep(6)


fid = open('C:/Users/svpxi01/Desktop/GPIB read/my_image.png', 'wb')
fid.write(data)
fid.close()
tek.close()
print('Done')

调试日志:

    TEKTRONIX,TDS5034B,B052776,CF:91.1CT FV:2.0.11

2016-03-29 17:28:38,119 - pyvisa - DEBUG - viWrite(60710720, b'FILESYSTEM:FRINT "C:\\EDIR\\EDIR_812`mV.png", GPIB\r\n', 50, 'c_ulong(50)') -> 0
2016-03-29 17:28:44,130 - pyvisa - DEBUG - GPIB::1::INSTR - reading 20480 bytes (last status <StatusCode.success_max_count_read: 1073676294>)
2016-03-29 17:30:58,366 - pyvisa - DEBUG - viRead(60710720, <ctypes.c_char_Array_20480 object at 0x0389FF30>, 20480, 'c_ulong(0)') -> -1073807339
2016-03-29 17:30:58,406 - pyvisa - DEBUG - GPIB::1::INSTR - exception while reading: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.
Traceback (most recent call last):
  File "C:\Users\SyedM03\python\tekwrite.py", line 20, in <module>
    data = tek.read_raw()
  File "C:\Python34\lib\site-packages\pyvisa\resources\messagebased.py", line 306, in read_raw
    chunk, status = self.visalib.read(self.session, size)
  File "C:\Python34\lib\site-packages\pyvisa\ctwrapper\functions.py", line 1582, in read
    ret = library.viRead(session, buffer, count, byref(return_count))
  File "C:\Python34\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.

1 个答案:

答案 0 :(得分:1)

找到我的问题。

tek.write('FILESYSTEM:FRINT "C:\EDIR\EDIR_812\140mV.png", GPIB')

不正确。它应该是

tek.write('FILESYSTEM:FRINT "C:/EDIR/EDIR_812/140mV.png", GPIB')