forked from M-Labs/artiq
1
0
Fork 0

pdq2_controller: add dump option

This commit is contained in:
Robert Jördens 2015-03-19 21:38:46 -06:00
parent 5ab3290ed4
commit 222d0a9d37
1 changed files with 10 additions and 7 deletions

View File

@ -11,11 +11,11 @@ def get_argparser():
parser = argparse.ArgumentParser(description="PDQ2 controller") parser = argparse.ArgumentParser(description="PDQ2 controller")
simple_network_args(parser, 3252) simple_network_args(parser, 3252)
parser.add_argument( parser.add_argument(
"-s", "--serial", default=None, "-u", "--url", default="hwgrep://",
help="device (FT245R) serial string [first]") help="device url [%(default)s]")
parser.add_argument( parser.add_argument(
"-d", "--debug", default=False, action="store_true", "-d", "--dump", default=None,
help="debug communications") help="file to dump pdq2 data into, for later simulation")
verbosity_args(parser) verbosity_args(parser)
return parser return parser
@ -23,13 +23,16 @@ def get_argparser():
def main(): def main():
args = get_argparser().parse_args() args = get_argparser().parse_args()
init_logger(args) init_logger(args)
port = None
dev = Pdq2(serial=args.serial) if args.dump:
port = open(args.dump, "wb")
dev = Pdq2(url=args.url, dev=port)
try: try:
simple_server_loop({"pdq2": dev}, args.bind, args.port, simple_server_loop({"pdq2": dev}, args.bind, args.port,
id_parameters="serial=" + str(args.serial)) id_parameters="url=" + str(args.url))
finally: finally:
dev.close() dev.close()
if __name__ == "__main__": if __name__ == "__main__":
main() main()