forked from M-Labs/artiq
1
0
Fork 0

frontend: pass drtio destination during communication

This commit is contained in:
occheung 2024-08-26 17:41:27 +08:00
parent 259c5a2dc5
commit c4cef77132
3 changed files with 15 additions and 4 deletions

View File

@ -46,15 +46,17 @@ class LogLevel(Enum):
class CommMgmt: class CommMgmt:
def __init__(self, host, port=1380): def __init__(self, host, port=1380, drtio_dest=0):
self.host = host self.host = host
self.port = port self.port = port
self.drtio_dest = drtio_dest
def open(self): def open(self):
if hasattr(self, "socket"): if hasattr(self, "socket"):
return return
self.socket = create_connection(self.host, self.port) self.socket = create_connection(self.host, self.port)
self.socket.sendall(b"ARTIQ management\n") self.socket.sendall(b"ARTIQ management\n")
self._write_int8(self.drtio_dest)
endian = self._read(1) endian = self._read(1)
if endian == b"e": if endian == b"e":
self.endian = "<" self.endian = "<"

View File

@ -25,6 +25,9 @@ def get_argparser():
help="Simulation - does not connect to device") help="Simulation - does not connect to device")
parser.add_argument("core_addr", metavar="CORE_ADDR", parser.add_argument("core_addr", metavar="CORE_ADDR",
help="hostname or IP address of the core device") help="hostname or IP address of the core device")
parser.add_argument("-s", "--satellite", default=0,
metavar="DRTIO_ID", type=int,
help="the logged DRTIO destination")
return parser return parser
@ -39,7 +42,7 @@ async def get_logs_sim(host):
log_with_name("firmware.simulation", logging.INFO, "hello " + host) log_with_name("firmware.simulation", logging.INFO, "hello " + host)
async def get_logs(host): async def get_logs(host, drtio_dest):
try: try:
reader, writer = await async_open_connection( reader, writer = await async_open_connection(
host, host,
@ -49,6 +52,7 @@ async def get_logs(host):
max_fails=3, max_fails=3,
) )
writer.write(b"ARTIQ management\n") writer.write(b"ARTIQ management\n")
writer.write(drtio_dest.to_bytes(1))
endian = await reader.readexactly(1) endian = await reader.readexactly(1)
if endian == b"e": if endian == b"e":
endian = "<" endian = "<"
@ -96,7 +100,7 @@ def main():
signal_handler.setup() signal_handler.setup()
try: try:
get_logs_task = asyncio.ensure_future( get_logs_task = asyncio.ensure_future(
get_logs_sim(args.core_addr) if args.simulation else get_logs(args.core_addr), get_logs_sim(args.core_addr) if args.simulation else get_logs(args.core_addr, args.satellite),
loop=loop) loop=loop)
try: try:
server = Server({"corelog": PingTarget()}, None, True) server = Server({"corelog": PingTarget()}, None, True)

View File

@ -95,6 +95,11 @@ def get_argparser():
p_allocator = subparsers.add_parser("allocator", p_allocator = subparsers.add_parser("allocator",
help="show heap layout") help="show heap layout")
# manage target
p_drtio_dest = parser.add_argument("-s", "--satellite", default=0,
metavar="DRTIO ID", type=int,
help="specify DRTIO destination that receives this command")
return parser return parser
@ -107,7 +112,7 @@ def main():
core_addr = ddb.get("core", resolve_alias=True)["arguments"]["host"] core_addr = ddb.get("core", resolve_alias=True)["arguments"]["host"]
else: else:
core_addr = args.device core_addr = args.device
mgmt = CommMgmt(core_addr) mgmt = CommMgmt(core_addr, drtio_dest=args.satellite)
if args.tool == "log": if args.tool == "log":
if args.action == "set_level": if args.action == "set_level":