bin/gpib_detect

Wed, 18 Mar 2009 00:26:27 +0100

author
David Douard <david.douard@logilab.fr>
date
Wed, 18 Mar 2009 00:26:27 +0100
changeset 79
b8eec4f9db52
parent 70
4cd8edd2b4e7
permissions
-rwxr-xr-x

many improvements:
- in gpibcontroler system (it begins to work fine),
- add HP3456A description module,
- add an almost empty HP8904A description module,
- add forgotten files (tests, mockups)

#!/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
import pygpibtoolkit.HP3562A
from pygpibtoolkit.prologix import GPIB
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)

    print "Detecting GPIB devices on the bus. Please wait until completion."
    cnx = GPIB(device=options.device)
    c = GPIBController(cnx)
    
    signal.signal(signal.SIGINT, c.stop)
    signal.signal(signal.SIGQUIT, c.stop)
    
    time.sleep(1)
    devices = c.detect_devices()
    c.stop()
    
    print "GPIB devices:"
    for k in sorted(devices.keys()):
        print "%-3d: %s"%(k, devices[k])
    return c, devices
if __name__ == "__main__":
    c, dev = main()
    

mercurial