bin/gpib_detect

changeset 86
96e30b092f70
parent 85
b55977dcc311
child 87
59a0946aa3d1
equal deleted inserted replaced
85:b55977dcc311 86:96e30b092f70
1 #!/usr/bin/python
2 import sys
3 import os
4 import signal
5 import time
6
7 try:
8 from pygpibtoolkit.gpibcontroller import GPIBController
9 except ImportError:
10 sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
11 from pygpibtoolkit.gpibcontroller import GPIBController
12 import pygpibtoolkit.HP3562A
13 from pygpibtoolkit.prologix import GPIB
14 def main():
15 import optparse
16 opt = optparse.OptionParser("A simple tool for detecting connected GPIB devices")
17 opt.add_option('-d', '--device', default="/dev/ttyUSB0",
18 dest="device",
19 help="Device of connected Prologix GPIB bundle [/dev/ttyUSB0]",)
20 options, argv = opt.parse_args(sys.argv)
21
22 print "Detecting GPIB devices on the bus. Please wait until completion."
23 cnx = GPIB(device=options.device)
24 c = GPIBController(cnx)
25
26 signal.signal(signal.SIGINT, c.stop)
27 signal.signal(signal.SIGQUIT, c.stop)
28
29 time.sleep(1)
30 devices = c.detect_devices()
31 c.stop()
32
33 print "GPIB devices:"
34 for k in sorted(devices.keys()):
35 print "%-3d: %s"%(k, devices[k])
36 return c, devices
37 if __name__ == "__main__":
38 c, dev = main()
39

mercurial