2018-09-15 10:44:59 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import asyncio
|
|
|
|
|
2022-05-27 15:17:27 +08:00
|
|
|
from sipyco.asyncio_tools import SignalHandler
|
|
|
|
|
2018-09-15 10:44:59 +08:00
|
|
|
from artiq.coredevice.comm_moninj import *
|
|
|
|
|
|
|
|
|
|
|
|
def get_argparser():
|
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
description="ARTIQ RTIO monitor")
|
|
|
|
parser.add_argument("core_addr", metavar="CORE_ADDR",
|
|
|
|
help="hostname or IP address of the core device")
|
|
|
|
parser.add_argument("channel", metavar="CHANNEL", type=lambda x: int(x, 0), nargs="+",
|
|
|
|
help="channel(s) to monitor")
|
|
|
|
return parser
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
args = get_argparser().parse_args()
|
2022-05-27 15:17:27 +08:00
|
|
|
|
2022-05-31 22:25:43 +08:00
|
|
|
loop = asyncio.new_event_loop()
|
|
|
|
asyncio.set_event_loop(loop)
|
2018-09-15 10:44:59 +08:00
|
|
|
try:
|
2022-05-27 15:17:27 +08:00
|
|
|
signal_handler = SignalHandler()
|
|
|
|
signal_handler.setup()
|
2018-09-15 10:44:59 +08:00
|
|
|
try:
|
2022-05-27 15:17:27 +08:00
|
|
|
comm = CommMonInj(
|
|
|
|
lambda channel, probe, value: print("0x{:06x}: {}".format(channel, value)),
|
|
|
|
lambda channel, override, value: None)
|
|
|
|
loop.run_until_complete(comm.connect(args.core_addr))
|
|
|
|
try:
|
|
|
|
for channel in args.channel:
|
|
|
|
comm.monitor_probe(True, channel, 0)
|
|
|
|
loop.run_until_complete(signal_handler.wait_terminate())
|
|
|
|
finally:
|
|
|
|
loop.run_until_complete(comm.close())
|
2018-09-15 10:44:59 +08:00
|
|
|
finally:
|
2022-05-27 15:17:27 +08:00
|
|
|
signal_handler.teardown()
|
2018-09-15 10:44:59 +08:00
|
|
|
finally:
|
|
|
|
loop.close()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|