背景
我需要用Python与Tektronix MSO 4104进行通信。通信是通过LAN使用vxi11以太网协议和Python的socket库实现的。
情况
现在这个方法相当有效;我可以连接到示波器,我可以发送任何想要的命令(例如:<socket object>.send('*IDN?')
)。然而,每当一个命令应该发送一个响应(像*IDN?应该做的那样),我尝试使用<socket object>.recv(1024)
,但我总是收到错误消息"[Errno 11] Resource temporarily unavailable."
我知道连接是良好的,因为我可以通过内置的HTTP接口从相同的'*IDN?'提示接收信息。
代码
以下是scope.py中创建与示波器接口的代码片段。
import socket
import sys
import time
class Tek_scope(object):
'''
Open up socket connection for a Tektronix scope given an IP address
'''
def __init__(self, IPaddress, PortNumber = 4000):
self.s = socket.socket(socket.AF_INET , socket.SOCK_STREAM)
self.s.connect((IPaddress, PortNumber))
self.s.setblocking(False)
print "Scope opened Successfully"
现在我要获取错误信息,我运行以下命令:
import scope # Imports the above (and other utility functions)
scope1 = scope.Tek_scope("10.1.10.15") #Connects to the scope
scope1.s.send('*IDN?') #Sends the *IDN? command to the scope.
# I have verified these signals are always recieved as I can
# see them reading out on the display
scope1.s.recv(1024)
# This should receive the response... but it always gives the error
系统
- Fedora 16
- Python 2.7
- Tektronix MSO4104
问题
为什么我没有收到任何响应我的提示的数据?是我忘记了某种准备工作吗?数据是否被发送到我没有检查的地方?还是我只是错误地使用了模块?任何帮助将不胜感激!