From d4781e9a8a1d0380c92c18c5b9940c05280db185 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Fri, 19 Apr 2019 23:42:37 +0800 Subject: [PATCH] aqctl_corelog: add simulation mode --- artiq/frontend/aqctl_corelog.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/artiq/frontend/aqctl_corelog.py b/artiq/frontend/aqctl_corelog.py index 9df2c3a8d..c93908de8 100755 --- a/artiq/frontend/aqctl_corelog.py +++ b/artiq/frontend/aqctl_corelog.py @@ -16,6 +16,8 @@ def get_argparser(): parser = argparse.ArgumentParser( description="ARTIQ controller for core device logs") simple_network_args(parser, 1068) + parser.add_argument("--simulation", action="store_true", + help="Simulation - does not connect to device") parser.add_argument("core_addr", metavar="CORE_ADDR", help="hostname or IP address of the core device") return parser @@ -26,6 +28,12 @@ class PingTarget: return True +async def get_logs_sim(host): + while True: + await asyncio.sleep(2) + log_with_name("firmware.simulation", logging.INFO, "hello " + host) + + async def get_logs(host): reader, writer = await asyncio.open_connection(host, 1380) writer.write(b"ARTIQ management\n") @@ -59,7 +67,8 @@ def main(): loop = asyncio.get_event_loop() try: - get_logs_task = asyncio.ensure_future(get_logs(args.core_addr)) + get_logs_task = asyncio.ensure_future( + get_logs_sim(args.core_addr) if args.simulation else get_logs(args.core_addr)) try: server = Server({"corelog": PingTarget()}, None, True) loop.run_until_complete(server.start(bind_address_from_args(args), args.port))