Revision 046173d09cfe92210217f33b40697631ded5b146

HW/LaboratoryInstruments/Oscilloscopes/Tektronix/MSO58_500MHz_6p25GS_62p5M/Misc/mso5_screenshot.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#-----------------------------------------------------------------------------------
#  Save Screenshot (Hard Copy) to PC for 5 Series MSO Oscilloscopes
#
#  This example demonstrates how to save a screen shot (hard copy) image
#  from a 5 Series MSO oscilloscope to the PC.
#
#   Development Environment: Python 3.6, PyVisa 1.8, NI-VISA 2017, Windows 10 x64
#   Compatible Instruments: 5 Series MSO, MSO54, MSO56, MSO58
#   Compatible Interfaces:  USB, Ethernet
#
#   Tektronix provides the following example "AS IS" with no support or warranty.
#-----------------------------------------------------------------------------------
from datetime import datetime 						# std library
import time 								# std library
import visa 								# https://pyvisa.readthedocs.io/
visaRsrcAddr = "TCPIP::192.158.189.XXX::INSTR"
rm = visa.ResourceManager()
scope = rm.open_resource(visaRsrcAddr)
print(scope.query('*IDN?'))  						# Print instrument id to console window
scope.write('SAVE:IMAGe \"C:/Temp.png\"')			        # Save image to instrument's local disk
dt = datetime.now()							# Generate a filename based on the current Date & Time
fileName = dt.strftime("MSO5_%Y%m%d_%H%M%S.png")
scope.query('*OPC?')							# Wait for instrument to finish writing image to disk
scope.write('FILESystem:READFile \"C:/Temp.png\"')	                # Read image file from instrument
imgData = scope.read_raw(1024*1024)
file = open(fileName, "wb")						# Save image data to local disk
file.write(imgData)
file.close()
scope.write('FILESystem:DELEte \"C:/Temp.png\"')	                # Image data has been transferred to PC and saved. Delete image file from instrument's hard disk.
scope.close()
rm.close()