def parse_args(): parser = argparse.ArgumentParser() parser.add_argument("-c", "--config", dest="config", required=True, help="JSON configuration file") parser.add_argument("-d", "--device", dest="device", help="Arduino USB device") parser.add_argument("-i", "--deviceid", dest="deviceid", required=True, help="Device ID to configure") parser.add_argument("-a", "--address", dest="address", help="Address to configure (defaults to device ID)") parser.add_argument("-t", "--type", dest="type", default="nano", help="Device type for platformio scripts (nano, mini, uno, moteinomega, etc) [%(default)s)]") parser.add_argument("-s", "--stages", dest="stages", default="1,2,3", help="Stages to execute [%(default)s]") parser.add_argument("--module", dest="module", default=False, action='store_true', help="Initially load module code") options = parser.parse_args() if options.device == None: options.device = portscan.choose_port() return options
def handle_args(): parser = argparse.ArgumentParser() parser.add_argument("-d", "--device", dest="device", help="Arduino USB device") parser.add_argument("-b", "--baud", dest="baud", type=int, help="Serial port baud ([9600], 19200, 57600, 115200)", default=9600) parser.add_argument("-t", "--timestamp", dest="timestamp", action="store_true", help="Print timestamps", default=False) parser.add_argument("-i", "--input", dest="input", action="store_true", help="Resend stdin to the serial device", default=False) options = parser.parse_args() if options.device is None: options.device = portscan.choose_port() if options.device is None: parser.print_help() exit("Must specify device") return options
def handle_args(): global options parser = OptionParser() parser.add_option("-d", "--device", dest="device", help="Arduino USB device") parser.add_option("-b", "--baud", dest="baud", type="int", help="Serial port baud ([9600], 19200, 57600, 115200)", default=9600) parser.add_option("-v", "--verbose", dest="verbose", action="store_true", help="Verbose output", default=False) parser.add_option("-p", "--port", dest="port", type="int", help="Port to bind to", default=6000) parser.add_option("-a", "--address", dest="address", help="Address to bind to", default="0.0.0.0") (options, args) = parser.parse_args() print("options:" + str(options) + " args:" + str(args)) if options.device == None: options.device = portscan.choose_port() return (options, args)
def handle_args(): global options parser = OptionParser() parser.add_option("-f", "--file", dest="filename", help="HMTL configuration file", metavar="FILE") parser.add_option("-d", "--device", dest="device", help="Arduino USB device") parser.add_option("-a", "--address", dest="address", type="int", help="Set address") parser.add_option("-i", "--device_id", dest="device_id", type="int", help="Set device_id") parser.add_option("-b", "--baud", dest="baud", type="int", help="Set baud") parser.add_option("-w", "--write", dest="writeconfig", action="store_true", help="Write configuration", default=False) parser.add_option("-p", "--print", dest="printconfig", action="store_true", help="Read and print the current configuration", default=False) parser.add_option("-v", "--verbose", dest="verbose", action="store_true", help="Verbose output", default=False) (options, args) = parser.parse_args() # Required args if ((options.filename is None) and (options.printconfig is False) and (options.address is None) and (options.device_id is None) and (options.baud is None)): parser.print_help() exit("Must specify mode") if ((options.baud != None) and (options.baud % 1200 != 0)): exit("Baud must be a multiple of 1200") if (options.device == None): options.device = portscan.choose_port() if (options.device == None): parser.print_help() exit("Must specify device") if (options.printconfig): options.verbose = True return (options, args)