From ad7cbc439476db2d96017f912067991cf1514b79 Mon Sep 17 00:00:00 2001 From: whitequark Date: Sun, 2 Aug 2015 16:35:49 +0300 Subject: [PATCH] =?UTF-8?q?Rename=20artiq=5Fcoreconfig=20=E2=86=92=20artiq?= =?UTF-8?q?=5Fcoretool;=20add=20log=20subcommand.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...{artiq_coreconfig.py => artiq_coretool.py} | 46 +++++++++++++------ doc/manual/core_device_flash_storage.rst | 2 +- doc/manual/installing.rst | 4 +- doc/manual/utilities.rst | 42 +++++++++-------- setup.py | 2 +- 5 files changed, 57 insertions(+), 39 deletions(-) rename artiq/frontend/{artiq_coreconfig.py => artiq_coretool.py} (75%) diff --git a/artiq/frontend/artiq_coreconfig.py b/artiq/frontend/artiq_coretool.py similarity index 75% rename from artiq/frontend/artiq_coreconfig.py rename to artiq/frontend/artiq_coretool.py index 301657117..41649f03e 100755 --- a/artiq/frontend/artiq_coreconfig.py +++ b/artiq/frontend/artiq_coretool.py @@ -11,15 +11,26 @@ def to_bytes(string): def get_argparser(): - parser = argparse.ArgumentParser(description="ARTIQ core device config " - "remote access") + parser = argparse.ArgumentParser(description="ARTIQ core device " + "remote access tool") + parser.add_argument("--ddb", default="ddb.pyon", + help="device database file") + subparsers = parser.add_subparsers(dest="action") subparsers.required = True - p_read = subparsers.add_parser("read", + + # Log Read command + subparsers.add_parser("log", + help="read from the core device log ring buffer") + + # Configuration Read command + p_read = subparsers.add_parser("cfg-read", help="read key from core device config") p_read.add_argument("key", type=to_bytes, help="key to be read from core device config") - p_write = subparsers.add_parser("write", + + # Configuration Write command + p_write = subparsers.add_parser("cfg-write", help="write key-value records to core " "device config") p_write.add_argument("-s", "--string", nargs=2, action="append", @@ -31,14 +42,17 @@ def get_argparser(): metavar=("KEY", "FILENAME"), help="key and file whose content to be written to " "core device config") - subparsers.add_parser("erase", help="erase core device config") - p_delete = subparsers.add_parser("delete", + + # Configuration Delete command + p_delete = subparsers.add_parser("cfg-delete", help="delete key from core device config") p_delete.add_argument("key", nargs=argparse.REMAINDER, default=[], type=to_bytes, help="key to be deleted from core device config") - parser.add_argument("--ddb", default="ddb.pyon", - help="device database file") + + # Configuration Erase command + subparsers.add_parser("cfg-erase", help="erase core device config") + return parser @@ -48,23 +62,25 @@ def main(): try: comm = dmgr.get("comm") - if args.action == "read": + if args.action == "log": + print(comm.get_log()) + elif args.action == "cfg-read": value = comm.flash_storage_read(args.key) if not value: print("Key {} does not exist".format(args.key)) else: print(value) - elif args.action == "erase": - comm.flash_storage_erase() - elif args.action == "delete": - for key in args.key: - comm.flash_storage_remove(key) - elif args.action == "write": + elif args.action == "cfg-write": for key, value in args.string: comm.flash_storage_write(key, value) for key, filename in args.file: with open(filename, "rb") as fi: comm.flash_storage_write(key, fi.read()) + elif args.action == "cfg-delete": + for key in args.key: + comm.flash_storage_remove(key) + elif args.action == "cfg-erase": + comm.flash_storage_erase() finally: dmgr.close_devices() diff --git a/doc/manual/core_device_flash_storage.rst b/doc/manual/core_device_flash_storage.rst index fb2bb8d9a..cc5fe1b2d 100644 --- a/doc/manual/core_device_flash_storage.rst +++ b/doc/manual/core_device_flash_storage.rst @@ -11,4 +11,4 @@ This storage area is used to store the core device MAC address, IP address and e The flash storage area is one sector (64 kB) large and is organized as a list of key-value records. -This flash storage space can be accessed by using the artiq_coreconfig.py :ref:`core-device-configuration-tool`. +This flash storage space can be accessed by using the artiq_coretool.py :ref:`core-device-access-tool`. diff --git a/doc/manual/installing.rst b/doc/manual/installing.rst index 5ade4cb7e..3f04b043a 100644 --- a/doc/manual/installing.rst +++ b/doc/manual/installing.rst @@ -289,9 +289,9 @@ To flash the ``idle`` kernel: * Write it into the core device configuration flash storage: :: - $ artiq_coreconfig write -f idle_kernel idle.elf + $ artiq_coretool cfg-write -f idle_kernel idle.elf -.. note:: You can find more information about how to use the ``artiq_coreconfig`` tool on the :ref:`Utilities ` page. +.. note:: You can find more information about how to use the ``artiq_coretool`` utility on the :ref:`Utilities ` page. Installing the host-side software ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/doc/manual/utilities.rst b/doc/manual/utilities.rst index a507291ae..23df5b581 100644 --- a/doc/manual/utilities.rst +++ b/doc/manual/utilities.rst @@ -93,60 +93,62 @@ This tool compiles key/value pairs into a binary image suitable for flashing int :ref: artiq.frontend.artiq_mkfs.get_argparser :prog: artiq_mkfs -.. _core-device-configuration-tool: +.. _core-device-access-tool: -Core device configuration tool ------------------------------- +Core device access tool +----------------------- -The artiq_coreconfig tool allows to read, write and remove key-value records from the :ref:`core-device-flash-storage`. +The artiq_coretool utility allows to perform maintenance on the core device: -It also allows to erase the entire flash storage area. + * read core device logs; + * as well as read, write and remove key-value records from the :ref:`core-device-flash-storage`; + * erase the entire flash storage area. To use this tool, you need to specify a ``ddb.pyon`` DDB file which contains a ``comm`` device (an example is provided in ``artiq/examples/master/ddb.pyon``). This tells the tool how to connect to the core device (via serial or via TCP) and with which parameters (baudrate, serial device, IP address, TCP port). -When not specified, the artiq_coreconfig tool will assume that there is a file named ``ddb.pyon`` in the current directory. +When not specified, the artiq_coretool utility will assume that there is a file named ``ddb.pyon`` in the current directory. To read the record whose key is ``mac``:: - $ artiq_coreconfig read mac + $ artiq_coretool cfg-read mac To write the value ``test_value`` in the key ``my_key``:: - $ artiq_coreconfig write -s my_key test_value - $ artiq_coreconfig read my_key + $ artiq_coretool cfg-write -s my_key test_value + $ artiq_coretool cfg-read my_key b'test_value' You can also write entire files in a record using the ``-f`` parameter. This is useful for instance to write the ``idle`` kernel in the flash storage:: - $ artiq_coreconfig write -f idle_kernel idle.elf - $ artiq_coreconfig read idle_kernel | head -c9 + $ artiq_coretool cfg-write -f idle_kernel idle.elf + $ artiq_coretool cfg-read idle_kernel | head -c9 b'\x7fELF You can write several records at once:: - $ artiq_coreconfig write -s key1 value1 -f key2 filename -s key3 value3 + $ artiq_coretool cfg-write -s key1 value1 -f key2 filename -s key3 value3 To remove the previously written key ``my_key``:: - $ artiq_coreconfig delete my_key + $ artiq_coretool cfg-delete my_key You can remove several keys at once:: - $ artiq_coreconfig delete key1 key2 + $ artiq_coretool cfg-delete key1 key2 To erase the entire flash storage area:: - $ artiq_coreconfig erase + $ artiq_coretool cfg-erase You don't need to remove a record in order to change its value, just overwrite it:: - $ artiq_coreconfig write -s my_key some_value - $ artiq_coreconfig write -s my_key some_other_value - $ artiq_coreconfig read my_key + $ artiq_coretool cfg-write -s my_key some_value + $ artiq_coretool cfg-write -s my_key some_other_value + $ artiq_coretool cfg-read my_key b'some_other_value' .. argparse:: - :ref: artiq.frontend.artiq_coreconfig.get_argparser - :prog: artiq_coreconfig + :ref: artiq.frontend.artiq_coretool.get_argparser + :prog: artiq_coretool diff --git a/setup.py b/setup.py index e3ca507f6..8c97ce619 100755 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ requirements = [ scripts = [ "artiq_client=artiq.frontend.artiq_client:main", "artiq_compile=artiq.frontend.artiq_compile:main", - "artiq_coreconfig=artiq.frontend.artiq_coreconfig:main", + "artiq_coretool=artiq.frontend.artiq_coretool:main", "artiq_ctlmgr=artiq.frontend.artiq_ctlmgr:main", "artiq_gui=artiq.frontend.artiq_gui:main", "artiq_master=artiq.frontend.artiq_master:main",