Skip to content

Instantly share code, notes, and snippets.

@idt12312

idt12312/load_screen.py

Last active Jun 18, 2020
Embed
What would you like to do?
Save screen image of RIGOL MSO5000 series oscilloscope
import visa
import argparse
from PIL import Image
import io
argparser = argparse.ArgumentParser()
argparser.add_argument('-a', '--address', required=True, help='VISA address like "TCPIP::{ipaddress}::INSTR"')
argparser.add_argument('-o', '--output', help='Output file name (default: "screen.png")', default='screen.png')
args = argparser.parse_args()
inst = visa.ResourceManager().open_resource(args.address)
print(inst.query('*IDN?').strip())
bmp_bin = inst.query_binary_values(':DISP:DATA?', datatype='B', container=bytes)
img = Image.open(io.BytesIO(bmp_bin))
img.save(args.output, args.output.split('.')[-1])
@idt12312

This comment has been minimized.

Copy link
Owner Author

@idt12312 idt12312 commented Jun 9, 2020

Requirement

If you already have some visa backend software (NI-VISA etc.), PyVISA-py isn't needed.

How to use

The following command means that the script loads a screen image from the oscilloscope whose visa address is TCPIP::192.168.1.21::INSTR and saves them to test.png. Output image format must be what Pillow library supports.
$ python python load_screen.py -a TCPIP::192.168.1.21::INSTR -o test.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.