Mon, 04 Jun 2018 22:28:05 +0200
[plotter] add a --mockup option to the demo main function
79 | 1 | #!/usr/bin/python |
2 | import sys | |
3 | import os | |
4 | import signal | |
5 | import time | |
6 | import optparse | |
7 | ||
8 | try: | |
9 | from pygpibtoolkit.gpibcontroller import GPIBController, deviceRegister | |
10 | except ImportError: | |
11 | sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")) | |
12 | from pygpibtoolkit.gpibcontroller import GPIBController, deviceRegister | |
13 | ||
14 | import pygpibtoolkit.HP3562A | |
15 | import pygpibtoolkit.HP3456 | |
16 | ||
17 | from pygpibtoolkit.prologix import GPIB | |
18 | ||
19 | opt = optparse.OptionParser("A simple tool for detecting connected GPIB devices") | |
20 | opt.add_option('-d', '--device', default="/dev/ttyUSB0", | |
21 | dest="device", | |
22 | help="Device of connected Prologix GPIB bundle [/dev/ttyUSB0]",) | |
23 | options, argv = opt.parse_args(sys.argv) | |
24 | ||
25 | ||
26 | cnx = GPIB(device=options.device) | |
27 | c = GPIBController(cnx) | |
28 | ||
29 | m = c.register_device(24, "HP3456A") | |
30 | ||
31 | def cb(val): | |
32 | print val | |
33 | ||
34 | m.register_data_cb(cb) | |
35 | m.send_command('SM004') | |
36 | m.send_command('T1SO1') | |
37 | ||
38 | try: | |
39 | while True: | |
40 | time.sleep(0.1) | |
41 | except KeyboardInterrupt: | |
42 | pass | |
43 | ||
44 | m.send_command('SO0') | |
45 | c.stop() |