frontend/coretool: basic analyzer dump

This commit is contained in:
Sebastien Bourdeauducq 2015-12-18 18:23:16 +08:00
parent 0832c71a66
commit 10d4bfba38
1 changed files with 30 additions and 7 deletions

View File

@ -1,11 +1,33 @@
#!/usr/bin/env python3.5 #!/usr/bin/env python3.5
import argparse import argparse
import struct
from artiq.master.databases import DeviceDB from artiq.master.databases import DeviceDB
from artiq.master.worker_db import DeviceManager from artiq.master.worker_db import DeviceManager
def print_analyzer_dump(dump):
sent_bytes, total_byte_count, overflow_occured = struct.unpack(">IQI", dump[:16])
dump = dump[16:]
print(sent_bytes, total_byte_count, overflow_occured)
while dump:
message_type_channel = struct.unpack(">I", dump[28:32])[0]
message_type = message_type_channel & 0b11
channel = message_type_channel >> 2
if message_type == 2:
exception_type, rtio_counter = struct.unpack(">BQ", dump[11:20])
print("EXC exception_type={} channel={} rtio_counter={}"
.format(exception_type, channel, rtio_counter))
else:
(data, address_padding, rtio_counter, timestamp) = struct.unpack(">QIQQ", dump[:28])
print("IO type={} channel={} timestamp={} rtio_counter={} address_padding={} data={}"
.format(message_type, channel, timestamp, rtio_counter, address_padding, data))
dump = dump[32:]
def get_argparser(): def get_argparser():
parser = argparse.ArgumentParser(description="ARTIQ core device " parser = argparse.ArgumentParser(description="ARTIQ core device "
"remote access tool") "remote access tool")
@ -15,17 +37,14 @@ def get_argparser():
subparsers = parser.add_subparsers(dest="action") subparsers = parser.add_subparsers(dest="action")
subparsers.required = True subparsers.required = True
# Log Read command
subparsers.add_parser("log", subparsers.add_parser("log",
help="read from the core device log ring buffer") help="read from the core device log ring buffer")
# Configuration Read command
p_read = subparsers.add_parser("cfg-read", p_read = subparsers.add_parser("cfg-read",
help="read key from core device config") help="read key from core device config")
p_read.add_argument("key", type=str, p_read.add_argument("key", type=str,
help="key to be read from core device config") help="key to be read from core device config")
# Configuration Write command
p_write = subparsers.add_parser("cfg-write", p_write = subparsers.add_parser("cfg-write",
help="write key-value records to core " help="write key-value records to core "
"device config") "device config")
@ -39,16 +58,16 @@ def get_argparser():
help="key and file whose content to be written to " help="key and file whose content to be written to "
"core device config") "core device config")
# Configuration Delete command
p_delete = subparsers.add_parser("cfg-delete", p_delete = subparsers.add_parser("cfg-delete",
help="delete key from core device config") help="delete key from core device config")
p_delete.add_argument("key", nargs=argparse.REMAINDER, p_delete.add_argument("key", nargs=argparse.REMAINDER,
default=[], type=str, default=[], type=str,
help="key to be deleted from core device config") help="key to be deleted from core device config")
# Configuration Erase command
subparsers.add_parser("cfg-erase", help="erase core device config") subparsers.add_parser("cfg-erase", help="erase core device config")
subparsers.add_parser("analyzer-dump")
return parser return parser
@ -57,6 +76,7 @@ def main():
device_mgr = DeviceManager(DeviceDB(args.device_db)) device_mgr = DeviceManager(DeviceDB(args.device_db))
try: try:
comm = device_mgr.get("comm") comm = device_mgr.get("comm")
if args.action != "analyzer-dump":
comm.check_ident() comm.check_ident()
if args.action == "log": if args.action == "log":
@ -78,6 +98,9 @@ def main():
comm.flash_storage_remove(key) comm.flash_storage_remove(key)
elif args.action == "cfg-erase": elif args.action == "cfg-erase":
comm.flash_storage_erase() comm.flash_storage_erase()
elif args.action == "analyzer-dump":
dump = comm.get_analyzer_dump()
print_analyzer_dump(dump)
finally: finally:
device_mgr.close_devices() device_mgr.close_devices()