forked from M-Labs/artiq
1
0
Fork 0

frontend/coreconfig: simplify action names

This commit is contained in:
Sebastien Bourdeauducq 2015-12-24 18:54:23 +08:00
parent 179c50480f
commit 5f3b69dd19
3 changed files with 23 additions and 23 deletions

View File

@ -19,12 +19,12 @@ def get_argparser():
subparsers = parser.add_subparsers(dest="action")
subparsers.required = True
p_read = subparsers.add_parser("cfg-read",
p_read = subparsers.add_parser("read",
help="read key from core device config")
p_read.add_argument("key", type=str,
help="key to be read from core device config")
p_write = subparsers.add_parser("cfg-write",
p_write = subparsers.add_parser("write",
help="write key-value records to core "
"device config")
p_write.add_argument("-s", "--string", nargs=2, action="append",
@ -37,13 +37,13 @@ def get_argparser():
help="key and file whose content to be written to "
"core device config")
p_delete = subparsers.add_parser("cfg-delete",
p_delete = subparsers.add_parser("delete",
help="delete key from core device config")
p_delete.add_argument("key", nargs=argparse.REMAINDER,
default=[], type=str,
help="key to be deleted from core device config")
subparsers.add_parser("cfg-erase", help="erase core device config")
subparsers.add_parser("erase", help="fully erase core device config")
return parser
@ -55,22 +55,22 @@ def main():
comm = device_mgr.get("comm")
comm.check_ident()
if args.action == "cfg-read":
if args.action == "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 == "cfg-write":
elif args.action == "write":
for key, value in args.string:
comm.flash_storage_write(key, value.encode("utf-8"))
for key, filename in args.file:
with open(filename, "rb") as fi:
comm.flash_storage_write(key, fi.read())
elif args.action == "cfg-delete":
elif args.action == "delete":
for key in args.key:
comm.flash_storage_remove(key)
elif args.action == "cfg-erase":
elif args.action == "erase":
comm.flash_storage_erase()
finally:
device_mgr.close_devices()

View File

@ -391,7 +391,7 @@ To flash the idle kernel:
* Write it into the core device configuration flash storage: ::
$ artiq_coreconfig cfg-write -f idle_kernel idle.elf
$ artiq_coreconfig write -f idle_kernel idle.elf
.. note:: You can find more information about how to use the ``artiq_coreconfig`` utility on the :ref:`Utilities <core-device-configuration-tool>` page.
@ -403,8 +403,8 @@ The startup kernel is executed once when the core device powers up. It should in
The core device may use either an external clock signal or its internal clock. This clock can be switched dynamically after the PC is connected using the ``external_clock`` parameter of the core device driver; however, one may want to select the clock at power-up so that it is used for the startup and idle kernels. Use one of these commands: ::
$ artiq_coreconfig cfg-write -s startup_clock i # internal clock (default)
$ artiq_coreconfig cfg-write -s startup_clock e # external clock
$ artiq_coreconfig write -s startup_clock i # internal clock (default)
$ artiq_coreconfig write -s startup_clock e # external clock
Ubuntu 15.10+/Debian jessie+ specific instructions
--------------------------------------------------

View File

@ -104,41 +104,41 @@ To use this tool, you need to specify a ``device_db.pyon`` device database file
To read the record whose key is ``mac``::
$ artiq_coreconfig cfg-read mac
$ artiq_coreconfig read mac
To write the value ``test_value`` in the key ``my_key``::
$ artiq_coreconfig cfg-write -s my_key test_value
$ artiq_coreconfig cfg-read my_key
$ artiq_coreconfig write -s my_key test_value
$ artiq_coreconfig 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 startup and idle kernels in the flash storage::
$ artiq_coreconfig cfg-write -f idle_kernel idle.elf
$ artiq_coreconfig cfg-read idle_kernel | head -c9
$ artiq_coreconfig write -f idle_kernel idle.elf
$ artiq_coreconfig read idle_kernel | head -c9
b'\x7fELF
You can write several records at once::
$ artiq_coreconfig cfg-write -s key1 value1 -f key2 filename -s key3 value3
$ artiq_coreconfig write -s key1 value1 -f key2 filename -s key3 value3
To remove the previously written key ``my_key``::
$ artiq_coreconfig cfg-delete my_key
$ artiq_coreconfig delete my_key
You can remove several keys at once::
$ artiq_coreconfig cfg-delete key1 key2
$ artiq_coreconfig delete key1 key2
To erase the entire flash storage area::
$ artiq_coreconfig cfg-erase
$ artiq_coreconfig erase
You do not need to remove a record in order to change its value, just overwrite it::
$ artiq_coreconfig cfg-write -s my_key some_value
$ artiq_coreconfig cfg-write -s my_key some_other_value
$ artiq_coreconfig cfg-read my_key
$ artiq_coreconfig write -s my_key some_value
$ artiq_coreconfig write -s my_key some_other_value
$ artiq_coreconfig read my_key
b'some_other_value'
.. argparse::