Skip to content

Instantly share code, notes, and snippets.

@bmjjr
Forked from mobilinkd/sds_scdp.py
Created September 6, 2020 19:54
Show Gist options
  • Save bmjjr/0aecf74774b3959aafe760a2b7ba3eff to your computer and use it in GitHub Desktop.
Save bmjjr/0aecf74774b3959aafe760a2b7ba3eff to your computer and use it in GitHub Desktop.

Revisions

  1. @mobilinkd 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)

  2. @mobilinkd 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)