Tektronix Technical Forums are maintained by community involvement. Feel free to post questions or respond to questions by other members. Should you require a time-sensitive answer, please contact your local Tektronix support center here.

socket version of read_raw

Post Reply
Posts: 1
Joined: July 12th, 2017, 7:12 pm
Country: United States

socket version of read_raw

Post by korrigan » July 12th, 2017, 7:42 pm

Hi all,

I'm trying to convert visa code to use the socket interface with an MSO4104B.

I'm using the following as my starting point and it's working fine for the most part:

viewtopic.php?f=568&t=137002&hilit=sock ... e+read_raw

But the code I use to get the screen shot as a PNG file on the PC uses read_raw after a HARDCOPY START just like in this example:

scope.write('SAVE:IMAG:FILEF PNG')
scope.write('HARDCOPY START')
raw_data = scope.read_raw()

fid = open('my_image.png', 'wb')
print 'Done'

This works fine with visa but not with the socket interface. The read function function of the Socket_Instrument class locks up. I get two blank characters and then it hangs in the 'except' portion of the code, never getting to the 'break'.

def read(self):
response = ''
while True:
char = ""
char = self.s.recv(1)
if response.rstrip() != "":
if char:
response += char
return response.rstrip()

I tried to create a read_raw function in the classs from read by taking out the .rstrip portions and keeping the character arrays as they came in. But that doesn't change the issue. It's as if there's no data there or the socket interface is accessing the wrong location?

Has anyone used the socket interface to get the screen shot and write it to a file in this way? What would a socket version of read_raw look like?

Thanks in advance

Post Reply

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 4 guests