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) | |
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:
#!/bin/sh
DEVICE=sdg2122x
image="${HOME}/Pictures/${DEVICE}-$(/usr/bin/date -Iseconds).png"
/usr/bin/python ${HOME}/bin/siglent_scdp.py -o $image ${DEVICE} 2> /tmp/error
/usr/bin/eog $image
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks !
Worked great on macOS 10.15.7 with Python3. Only added this comment to file so I remember more quickly how to use.
\#to use: In terminal move to this files directory. Paste following and return: python3 screenDump.py --output some_name.png 192.168.1.5 \# you need the filename.png and the current DHCP address. Note that jpg are 34KB vs 2KB and look blobbier
Might need a slight change to work with USB from command line.