bin/gpib_detect

changeset 64
624157f78b77
child 65
10d218fbf86f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/gpib_detect	Tue Aug 19 22:47:16 2008 +0200
@@ -0,0 +1,34 @@
+#!/usr/bin/python
+import sys
+import os
+import signal
+import time
+
+try:
+    from pygpibtoolkit.gpibcontroller import GPIBController
+except ImportError:
+    sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
+    from pygpibtoolkit.gpibcontroller import GPIBController
+
+def main():
+    import optparse
+    opt = optparse.OptionParser("A simple tool for detecting connected GPIB devices")
+    opt.add_option('-d', '--device', default="/dev/ttyUSB0",
+                   dest="device",
+                   help="Device of connected Prologix GPIB bundle [/dev/ttyUSB0]",)
+    options, argv = opt.parse_args(sys.argv)
+
+    c = GPIBController(device=options.device)
+    signal.signal(signal.SIGINT, c.stop)
+    signal.signal(signal.SIGQUIT, c.stop)
+    
+    time.sleep(1)
+    devices = c.detect_devices()
+    print "Found devices:"
+    for k in sorted(devices.keys()):
+        print "%-3d: %s"%(k, devices[k])
+    c.stop()
+    
+if __name__ == "__main__":
+    main()
+    

mercurial