Last active
December 26, 2022 16:42
-
-
Save idt12312/98f52c0b524b9cc5fbda9dfd84a3f421 to your computer and use it in GitHub Desktop.
Save screen image of RIGOL MSO5000 series oscilloscope
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
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]) |
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
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