Skip to content

Instantly share code, notes, and snippets.

@mobilinkd
Last active February 2, 2023 05:24
Show Gist options
  • Save mobilinkd/8a07cc124946c87715c6a1458118411e to your computer and use it in GitHub Desktop.
Save mobilinkd/8a07cc124946c87715c6a1458118411e to your computer and use it in GitHub Desktop.

Revisions

  1. mobilinkd revised this gist Apr 16, 2021. 1 changed file with 25 additions and 9 deletions.
    34 changes: 25 additions & 9 deletions sds_scdp.py
    Original file line number Diff line number Diff line change
    @@ -1,35 +1,51 @@
    #!/usr/bin/env python

    import argparse
    import visa, sys
    import sys, time
    import pyvisa as visa
    from pyvisa.constants import StatusCode

    from PIL import Image
    from cStringIO import StringIO
    from io import BytesIO

    def screendump(device, filename):
    rm = visa.ResourceManager('@py')

    # Siglent SDS2204X
    # Siglent device
    scope = rm.open_resource('TCPIP::%s' % device)
    scope.timeout = 1000 # ms
    scope.read_trermination = None

    n, status = scope.write('SCDP')
    if status == StatusCode.success:
    scope.read_termination = None
    data = scope.read_raw(2000000)
    image = Image.open(StringIO(data))
    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 DSO.')
    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)

  2. mobilinkd revised this gist Sep 29, 2017. 1 changed file with 6 additions and 3 deletions.
    9 changes: 6 additions & 3 deletions sds_scdp.py
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,9 @@
    import visa, sys
    from pyvisa.constants import StatusCode

    from PIL import Image
    from cStringIO import StringIO

    def screendump(device, filename):
    rm = visa.ResourceManager('@py')

    @@ -14,7 +17,8 @@ def screendump(device, filename):
    if status == StatusCode.success:
    scope.read_termination = None
    data = scope.read_raw(2000000)
    open(filename, "w").write(data)
    image = Image.open(StringIO(data))
    image.save(filename)
    scope.close()
    rm.close()

    @@ -25,8 +29,7 @@ def screendump(device, filename):
    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')
    help='the ip address or hostname of the DSO')

    args = parser.parse_args()
    screendump(args.device[0], args.filename)

  3. mobilinkd created this gist Jul 10, 2017.
    32 changes: 32 additions & 0 deletions sds_scdp.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    #!/usr/bin/env python

    import argparse
    import visa, sys
    from pyvisa.constants import StatusCode

    def screendump(device, filename):
    rm = visa.ResourceManager('@py')

    # Siglent SDS2204X
    scope = rm.open_resource('TCPIP::%s' % device)

    n, status = scope.write('SCDP')
    if status == StatusCode.success:
    scope.read_termination = None
    data = scope.read_raw(2000000)
    open(filename, "w").write(data)
    scope.close()
    rm.close()

    if __name__ == '__main__':

    parser = argparse.ArgumentParser(
    description='Grab a screenshot from a Siglent DSO.')
    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)