-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcapture.py
More file actions
19 lines (18 loc) · 813 Bytes
/
capture.py
File metadata and controls
19 lines (18 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import visa
def read_capture(resource_string="GPIB0::18::INSTR"):
rm = visa.ResourceManager()
instr = rm.open_resource(resource_string)
# Override the default timeout as the transfer can exceed this
instr.timeout = 10000
# Store the current screen image to instrument memory, which is the R 'drive'
instr.write(":MMEM:STOR:SCR 'R:PICTURE.GIF'")
# Grab the screen image file from the instrument.
# Set datatype to char that will be written out to a binary file
capture = instr.query_binary_values(message=":MMEM:DATA? 'R:PICTURE.GIF'", container=list, datatype='c')
with open('capture.gif', 'wb') as fp:
for byte in capture:
fp.write(byte)
# Delete the file from memory
instr.write(":MMEM:DEL 'R:PICTURE.GIF'")
instr.close()
rm.close()