采用pycharm建个工程,添加一个python脚本,脚本内容如下:
#!/usr/bin/env python
import visa
from pyvisa.resources.usb import USBInstrument
from pyvisa.constants import *
rm = visa.ResourceManager()
res = rm.list_resources()
#print rm
#print(len(res))
if len(res) > 0:
# print(res[0])
for dev in res:
dev_name = str(dev)
if dev_name.startswith("USB"):
print("usb resource")
usb_res = USBInstrument(rm, dev_name)
usb_res.open()
#usb_res = rm.open_resource(res[0])
idn = usb_res.query("*IDN?")
print(idn)
print("over")
else:
print("other resources")
else:
print("no dev found")
连接示波器设备到pc端,打开iolibsuite,执行python脚本可以看到连接机器的idn字符串