0

我正在尝试在 x86_64 linux 机器(CentOS 7)上通过 python 控制 Keithley 2410。我正在使用 python 2.7.5、NI-VISA 16 和 PyVISA 1.8。吉时利通过一根 RS232 转 USB 电缆连接到计算机,并配置为 RS232 通信(参数为:波特 57600、位 8、奇偶校验无、终止符、流控制无)。当我尝试查询 Keithley 时,出现超时错误,如下所示:

>>> import visa
>>> rm = visa.ResourceManager()
>>> print(rm.list_resources())
(u'ASRL1::INSTR', u'ASRL2::INSTR')
>>> keithley = rm.open_resource("ASRL2::INSTR")
>>> print(keithley.query('*IDN?'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/pyvisa/resources/messagebased.py", line 407, in query
return self.read()
File "/usr/lib/python2.7/site-packages/pyvisa/resources/messagebased.py", line 332, in read
message = self.read_raw().decode(enco)
File "/usr/lib/python2.7/site-packages/pyvisa/resources/messagebased.py", line 306, in read_raw
chunk, status = self.visalib.read(self.session, size)
File "/usr/lib/python2.7/site-packages/pyvisa/ctwrapper/functions.py", line 1582, in read
ret = library.viRead(session, buffer, count, byref(return_count))
File "/usr/lib/python2.7/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.
4

2 回答 2

2

PyVISA 1.8 应该默认为串行的 '\r' 行终止,因此您的 2410 可能没有收到它需要启动它来解析命令的 '\n'。尝试做

keithley.write_termination = '\n'
keithley.read_termination = '\n'

在你的open_resource()电话之后。

于 2017-04-14T23:40:39.287 回答
1

感谢您的建议,但似乎我需要明确设置波特率。

rm = visa.ResourceManager()
smu = rm.open_resource("ASRL2::INSTR")
smu.baud_rate = 57600
于 2017-05-03T13:04:45.647 回答