-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscpi.py
executable file
·37 lines (32 loc) · 1.14 KB
/
scpi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/python3
# SCPI Utility for SDS1104X-U and DSG1032X.
#
# Prerequisites:
# - pip3 install -U pyvisa
#
# (c) 2024 Sander Berents
# Published under GNU General Public License v3.0. See file "LICENSE" for full license text.
import argparse
import pyvisa
from eelib import *
parser = argparse.ArgumentParser(
description="SCPI Utility",
epilog="Submit SCPI command or query to SDS1104X-U or DSG1032X."
)
parser.add_argument('target', type=str, choices=('dso', 'awg'), metavar='target', help="Target instrument (one of 'dso' or 'awg')")
parser.add_argument('-q', type=str, dest='query', metavar='query', help="SCPI query")
parser.add_argument('-c', type=str, dest='command', metavar='command', help="SCPI command")
parser.add_argument('-x', action='store_true', dest='hex', help="Output query result as byte array")
args = parser.parse_args()
instr = resources[args.target]
if args.command != None:
instr.write(args.command)
if args.query != None:
if args.hex:
instr.write(args.query)
print(instr.read_raw())
else:
print(instr.query(args.query).strip())
if args.command == None and args.query == None:
print(instr.query('*IDN?'))
close_resources()