Last active
February 2, 2023 05:24
-
-
Save mobilinkd/8a07cc124946c87715c6a1458118411e to your computer and use it in GitHub Desktop.
Screendump From Siglent DSO via VXI-11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import argparse | |
import sys, time | |
import pyvisa as visa | |
from pyvisa.constants import StatusCode | |
from PIL import Image | |
from io import BytesIO | |
def screendump(device, filename): | |
rm = visa.ResourceManager('@py') | |
# Siglent device | |
scope = rm.open_resource('TCPIP::%s' % device) | |
scope.timeout = 1000 # ms | |
scope.read_trermination = None | |
print(scope.query('*IDN?')) | |
scope.write('SCDP') | |
print(scope.last_status) | |
if scope.last_status == StatusCode.success: | |
time.sleep(1) | |
fp = BytesIO() | |
count = 0 | |
try: | |
data = scope.read_raw(20000000) | |
fp.write(data) | |
count = len(data) | |
except: | |
print("timeout") | |
pass | |
print("Read {} bytes.".format(count)) | |
image = Image.open(fp) | |
image.save(filename) | |
scope.close() | |
rm.close() | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser( | |
description='Grab a screenshot from a Siglent LXI device.') | |
parser.add_argument('--output', '-o', dest='filename', required=True, | |
help='the output filename') | |
parser.add_argument('device', metavar='DEVICE', nargs=1, | |
help='the ip address or hostname of the DSO') | |
args = parser.parse_args() | |
screendump(args.device[0], args.filename) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I should add that this code will work to dump screenshots from all of my Siglent gear. I use this code (renamed to
siglent_scdp.py
) to dump screenshots from the following equipment: SDM3065X, SDG2042X, SSA3021X, and SDS2204X. I have wrapper scripts that look something like this to automatically save and display a screenshot:These scripts (one for each device) are mapped to some of the special keys on my Microsoft keyboard. It just takes a single keypress to grab a screenshot.