我正试图与支持SCPI的BraggMETER询问器进行通信。
操作系统: Windows 10
连接硬件: j5create JUH470 USB3.0多适配器千兆以太网/3端口USB3.0集线器
我的困惑之一是:我是作为USB设备访问还是作为TCPIP设备访问?
当我通过Telnet连接时,一切都很顺利。IP地址和端口分别为10.0.0.10和3500。
> telnet
> open 10.0.0.10 3500
:IDEN?
:ACK:HBM FiberSensing:FS22SI v3.0:08:046 840 200 898:20190116
:STAT?
:ACK:1
在Python中,我是usig -- pyvisa库。
import easy_scpi as scpi
import pyvisa
DeviceAddress = '10.0.0.10'
DevicePort = '3500'
VISADevice = f'TCPIP0::{DeviceAddress}::{DevicePort}::SOCKET'
# Doesn't work either --> VISADevice = 'ASRL10::INSTR'
rm = pyvisa.ResourceManager()
print(rm.list_resources())
inst = rm.open_resource(VISADevice)
print(inst.query("*IDEN?"))
inst.close()
错误总是出现在rm.open_resource
上。我尝试过无数的连接字符串。他们犯了不同的错误。以下是其中的三个:
pyvisa.errors.VisaIOError: VI_ERROR_INTF_NUM_NCONFIG (-1073807195): The interface type is valid but the specified interface number is not configured.
pyvisa.errors.VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.
pyvisa.errors.VisaIOError: VI_ERROR_RSRC_NFOUND (-1073807343): Insufficient location information or the requested device or resource is not present in the system.
更新1
我下载了国家仪器NI-Max,并使用了他们的NI I/O跟踪。此连接字符串“有效”:
TCPIP::10.0.0.10::3500::SOCKET
但是,我仍然会得到超时错误。尝试确保新行终止字符被发送,并将超时提高到5秒(这确实生效,因为它延迟了超时错误的记录)。没有骰子。仍然会出现超时错误。
更新2
虽然不是相同的设置,但其他人报告了使用NI GPIB到USB卡(GPIB-USB-HS)的问题。普通的线程是USB适配器..。
发布于 2020-09-03 15:43:21
我不能评论,所以我在这里评论
你试过使用普通套接字吗?
import socket
DeviceAddress = '10.0.0.10'
DevicePort = '3500'
BUFSIZ = 1024
ADDR = (DeviceAddress, DevicePort)
cmd = "IDN?" # or "*IDEN?" as you've put?
braggMeterSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
braggMeterSocket.connect(self.ADDR)
braggMeterSocket.send(cmd + "\n") #maybe with new line depending on what the device terminator is.
mesg = braggMeterSocket.recv(BUFSIZ)
mesg = mesg.strip() # Remove \n at end of mesg
print(mesg)
发布于 2020-09-04 12:49:15
问题是,该设备将CRLF (回车加linefeed)输出为SCPI命令终止符。我只发送了这两个字符中的一个,"\n“。
Python I/O不像我使用过的一些语言那样适应操作系统,在某些情况下,这些语言会将"\n“解释为"\r\n”。
同样,NI-Max只发送"\n“,省略了"\r”。
https://stackoverflow.com/questions/63714124
复制相似问题