我正在使用 RS-232 端口与 KeithleyInstruments(SCPI 协议(protocol))通信,但遇到了问题。我可以发送写入命令,但是当我发送查询命令时,它*显示以下错误。
import visa
rm = visa.ResourceManager()
inst = rm.list_resources()
print inst
# print inst --> (u'USB0::0x05E6::0x2200::9060025::INSTR', u'ASRL1::INSTR', u'ASRL6::INSTR', u'ASRL7::INSTR', u'ASRL10::INSTR', u'GPIB0::16::INSTR')
keithleyInst= rm.open_resource('ASRL7::INSTR')
print keithleyInst.write("*rst")
print keithleyInst.write(":meas:temp?")
print keithleyInst.query(":meas:temp?")
Error:
pyvisa.errors.VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.
最佳答案
查询是写入和读取的结合,因此您只需要查询,而不需要写入。
如果删除额外写入后仍然超时,请尝试设置一个非常长的超时时间,例如:
keithleyInst.timeout = 5000
给它 5 秒的响应时间。一旦开始工作,您可以随时缩短它。
如果仍然没有响应,可能是仪器没有发送 VISA 期望的终止字符。
尝试使用终端程序或 National Instruments 的 Measurement & Automation 程序与仪器通信,以确定它正在发送什么终止字符(如果它正在发送任何内容)。
您可以更改 VISA 期望的终止符
keithleyInst.read_termination = '\r'
或类似的东西。
关于python - VI_ERROR_TMO (-1073807339),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38454891/