Skip to content

Instantly share code, notes, and snippets.

@idt12312
Last active December 26, 2022 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save idt12312/98f52c0b524b9cc5fbda9dfd84a3f421 to your computer and use it in GitHub Desktop.
Save idt12312/98f52c0b524b9cc5fbda9dfd84a3f421 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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

@raspopov
Copy link

BTW for Rigol MSO8000 by adding PNG parameter to DISPlay:SNAPshot (undocumented) command it is possible to save screen in the PNG-format i.e. :DISP:SNAP? PNG, by default :DISP:SNAP? saves in the BMP-format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment