我正在尝试使用python控制一个乐器。在代码期间,我需要一次又一次地重新发出相同的命令以从仪器中读取数据。当我使用命令一次我得到答案,但我有它在for循环我得到消息“ERR”的数据。我不知道如何解决这个问题,任何人都可以帮助我吗?下面是我的代码及其输出:
import visa
rm = visa.ResourceManager()
print(rm.list_resources())
my_instrument = rm.open_resource('TCPIP0::169.254.164.61::3602::SOCKET', read_termination='\r\n')
for i in range(0, 10):
my_instrument.ask('RMMEAS\r')
ry3 = my_instrument.read()
print(ry3)
输出
C:\ProgramData\Anaconda3\python.exe C:/Users/nishant.mittal/PycharmProjects/demo.py/kjbkn.py
('TCPIP0::192.168.001.020::3602::INSTR', 'ASRL3::INSTR', 'ASRL4::INSTR', 'ASRL10::INSTR')
8,0.022,0.027,0.029,0.042,0.056,
ERR
8,0.022,0.027,0.029,0.042,0.056,
ERR
8,0.022,0.027,0.029,0.042,0.056,
ERR
8,0.022,0.027,0.029,0.042,0.056,
Process finished with exit code 0
答案 0 :(得分:0)
我从来没有尝试过这样的东西,但我猜是因为它打印出来
traceback
我认为它有效,因为退出代码0意味着它正确编译(根据C和C ++),而不是你想要的方式。我也认为这是正确的,因为它不会打印出>>> while True print('Hello world')
File "<stdin>", line 1
while True print('Hello world')
^
SyntaxError: invalid syntax
错误。
这是Python中的一个错误:
Julia Version 0.6.0
Commit 903644385b (2017-06-19 13:05 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin13.4.0)
CPU: Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
老实说,我不知道如何帮助你...对不起...... :(
我希望我对此有所帮助!