Question

Background

I need to communicate with a Tektronix MSO 4104 from python. The communication takes place over the LAN using the vxi11 ethernet protocol and python's socket library.

Situation

Now this works fairly well; I can cconnect to the scope and I can send it any command I want (eg: <socket object>.send('*IDN?')). However, whenever a command is supposed to send a response (like *IDN? is supposed to do) I attempt to use <socket object>.recv(1024) but I ALWAYS recieve the error "[Errno 11] Resource temporarily unavailable."

I know the connection is good as I can recieve infromation to the same '*IDN?' prompt via the built in HTTP interface.

Code

The following is a snippet from scope.py which creates teh socket interface with the scope.

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"

Now to get the error, I run the following:

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

System

  • Fedora 16
  • Python 2.7
  • Tektronix MSO4104

Question

So why aren't I recieveing any data in response to my prompt? Did I forget some sort of prep? Is the data going somewhere I am just not checking? Did I just use the modules wrong? Any help would be greatly appreciated!

Was it helpful?

Solution

This works for me using the same scope.

Set setblocking(True) and add a \n to the *IDN? command.

import socket
import sys
import time

class Tek_scope(object):

    def __init__(self, IPaddress, PortNumber = 4000):
        self.s = socket.socket(socket.AF_INET , socket.SOCK_STREAM)
        self.s.connect((IPaddress, PortNumber))
        self.s.setblocking(True)
        print "Scope opened Successfully"

scope1 = Tek_scope("10.1.10.15") # Connects to the scope

scope1.s.send('*IDN?\n') # Sends the *IDN? command to the scope. 

print scope1.s.recv(1024) 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top