def visa_main(command=None): import argparse parser = argparse.ArgumentParser( description='PyVISA command-line utilities') parser.add_argument('--backend', '-b', dest='backend', action='store', default=None, help='backend to be used (default: ivi)') if not command: subparsers = parser.add_subparsers(title='command', dest='command') info_parser = subparsers.add_parser( 'info', help='print information to diagnose PyVISA') console_parser = subparsers.add_parser('shell', help='start the PyVISA console') args = parser.parse_args() if command: args.command = command if args.command == 'info': from pyvisa import util util.get_debug_info() elif args.command == 'shell': from pyvisa import shell shell.main('@' + args.backend if args.backend else '')
def visa_main(command: Optional[str] = None) -> None: """Run the main entry point for command line tools. Parameters ---------- command : str, optional What command to invoke, if None the value is read from the command line arguments """ import argparse parser = argparse.ArgumentParser( description="PyVISA command-line utilities") parser.add_argument( "--backend", "-b", dest="backend", action="store", default=None, help="backend to be used (default: ivi)", ) if not command: subparsers = parser.add_subparsers(title="command", dest="command") subparsers.add_parser("info", help="print information to diagnose PyVISA") subparsers.add_parser("shell", help="start the PyVISA console") args = parser.parse_args() if command: args.command = command if args.command == "info": from pyvisa import util util.get_debug_info() elif args.command == "shell": from pyvisa import shell shell.main("@" + args.backend if args.backend else "") shell.main("@" + args.backend if args.backend else "") else: raise ValueError( f"Unknown command {args.command}. Valid values are: info and shell" )
def visa_main(command=None): import argparse parser = argparse.ArgumentParser(description='PyVISA command-line utilities') parser.add_argument('--backend', '-b', dest='backend', action='store', default=None, help='backend to be used (default: ni)') if not command: subparsers = parser.add_subparsers(title='command', dest='command') info_parser = subparsers.add_parser('info', help='print information to diagnose PyVISA') console_parser = subparsers.add_parser('shell', help='start the PyVISA console') args = parser.parse_args() if command: args.command = command if args.command == 'info': from pyvisa import util util.get_debug_info() elif args.command == 'shell': from pyvisa import shell shell.main('@' + args.backend if args.backend else '')
:copyright: 2014 by PyVISA Authors, see AUTHORS for more details. :license: MIT, see COPYING for more details. """ from __future__ import division, unicode_literals, print_function, absolute_import from pyvisa import logger, __version__, log_to_screen, constants from pyvisa.highlevel import ResourceManager from pyvisa.errors import (Error, VisaIOError, VisaIOWarning, VisaTypeError, UnknownHandler, OSNotSupported, InvalidBinaryFormat, InvalidSession, LibraryError) # This is needed to registry all resources. from pyvisa.resources import Resource if __name__ == '__main__': import argparse parser = argparse.ArgumentParser(description='PyVISA command-line utilities') subparsers = parser.add_subparsers(title='command', dest='command') info_parser = subparsers.add_parser('info', help='print information to diagnose PyVISA') console_parser = subparsers.add_parser('shell', help='start the PyVISA console') args = parser.parse_args() if args.command == 'info': from pyvisa import util util.get_debug_info() elif args.command == 'shell': from pyvisa import shell shell.main()
from __future__ import division, unicode_literals, print_function, absolute_import from pyvisa import logger, __version__, log_to_screen, constants from pyvisa.highlevel import ResourceManager from pyvisa.errors import (Error, VisaIOError, VisaIOWarning, VisaTypeError, UnknownHandler, OSNotSupported, InvalidBinaryFormat, InvalidSession, LibraryError) # This is needed to registry all resources. from pyvisa.resources import Resource if __name__ == '__main__': import argparse parser = argparse.ArgumentParser(description='PyVISA command-line utilities') parser.add_argument('--backend', '-b', dest='backend', action='store', default=None, help='backend to be used (default: ni)') subparsers = parser.add_subparsers(title='command', dest='command') info_parser = subparsers.add_parser('info', help='print information to diagnose PyVISA') console_parser = subparsers.add_parser('shell', help='start the PyVISA console') args = parser.parse_args() if args.command == 'info': from pyvisa import util util.get_debug_info() elif args.command == 'shell': from pyvisa import shell shell.main('@' + args.backend if args.backend else '')
from __future__ import division, unicode_literals, print_function, absolute_import from pyvisa import logger, __version__, log_to_screen, constants from pyvisa.highlevel import ResourceManager from pyvisa.errors import (Error, VisaIOError, VisaIOWarning, VisaTypeError, UnknownHandler, OSNotSupported, InvalidBinaryFormat, InvalidSession, LibraryError) # This is needed to registry all resources. from pyvisa.resources import Resource if __name__ == '__main__': import argparse parser = argparse.ArgumentParser(description='PyVISA command-line utilities') parser.add_argument("--read", type=str, default='\n', help='Read termination character.') parser.add_argument("--write", type=str, default='\n', help='Write termination character.') parser.add_argument("--backend", type=str, default='@py', help='backend implementation (@ni|@py|<Simulation YAML>@sim).') subparsers = parser.add_subparsers(title='command', dest='command') info_parser = subparsers.add_parser('info', help='print information to diagnose PyVISA') console_parser = subparsers.add_parser('shell', help='start the PyVISA console') args = parser.parse_args() if args.command == 'info': from pyvisa import util util.get_debug_info() elif args.command == 'shell': from pyvisa import shell shell.main(library_path=args.backend, read_termination=args.read, write_termination=args.write)
return parser if __name__ == '__main__': parser = configure_opts() args = parser.parse_args() resources = visa.ResourceManager('@py') if args.cmd == 'list': list(resources) sys.exit(0) elif args.cmd == 'shell': from pyvisa import shell shell.main(library_path='@py') sys.exit(0) device = resources.open_resource(args.device, write_termination='\n', query_delay=0.25) idn = device.query('*IDN?') logger.info('Connected to device \'%s\'' % idn) if args.cmd == 'wave': waveform(device, args.out, args.channel) elif args.cmd == 'dumpscreen': dumpscreen(device, args.out) elif args.cmd == 'template': template(device)