Skip to content

Commit ad7cbc4

Browse files
author
whitequark
committedAug 2, 2015
Rename artiq_coreconfig → artiq_coretool; add log subcommand.
1 parent b2f720d commit ad7cbc4

File tree

5 files changed

+57
-39
lines changed

5 files changed

+57
-39
lines changed
 

Diff for: ‎artiq/frontend/artiq_coreconfig.py renamed to ‎artiq/frontend/artiq_coretool.py

+31-15
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,26 @@ def to_bytes(string):
1111

1212

1313
def get_argparser():
14-
parser = argparse.ArgumentParser(description="ARTIQ core device config "
15-
"remote access")
14+
parser = argparse.ArgumentParser(description="ARTIQ core device "
15+
"remote access tool")
16+
parser.add_argument("--ddb", default="ddb.pyon",
17+
help="device database file")
18+
1619
subparsers = parser.add_subparsers(dest="action")
1720
subparsers.required = True
18-
p_read = subparsers.add_parser("read",
21+
22+
# Log Read command
23+
subparsers.add_parser("log",
24+
help="read from the core device log ring buffer")
25+
26+
# Configuration Read command
27+
p_read = subparsers.add_parser("cfg-read",
1928
help="read key from core device config")
2029
p_read.add_argument("key", type=to_bytes,
2130
help="key to be read from core device config")
22-
p_write = subparsers.add_parser("write",
31+
32+
# Configuration Write command
33+
p_write = subparsers.add_parser("cfg-write",
2334
help="write key-value records to core "
2435
"device config")
2536
p_write.add_argument("-s", "--string", nargs=2, action="append",
@@ -31,14 +42,17 @@ def get_argparser():
3142
metavar=("KEY", "FILENAME"),
3243
help="key and file whose content to be written to "
3344
"core device config")
34-
subparsers.add_parser("erase", help="erase core device config")
35-
p_delete = subparsers.add_parser("delete",
45+
46+
# Configuration Delete command
47+
p_delete = subparsers.add_parser("cfg-delete",
3648
help="delete key from core device config")
3749
p_delete.add_argument("key", nargs=argparse.REMAINDER,
3850
default=[], type=to_bytes,
3951
help="key to be deleted from core device config")
40-
parser.add_argument("--ddb", default="ddb.pyon",
41-
help="device database file")
52+
53+
# Configuration Erase command
54+
subparsers.add_parser("cfg-erase", help="erase core device config")
55+
4256
return parser
4357

4458

@@ -48,23 +62,25 @@ def main():
4862
try:
4963
comm = dmgr.get("comm")
5064

51-
if args.action == "read":
65+
if args.action == "log":
66+
print(comm.get_log())
67+
elif args.action == "cfg-read":
5268
value = comm.flash_storage_read(args.key)
5369
if not value:
5470
print("Key {} does not exist".format(args.key))
5571
else:
5672
print(value)
57-
elif args.action == "erase":
58-
comm.flash_storage_erase()
59-
elif args.action == "delete":
60-
for key in args.key:
61-
comm.flash_storage_remove(key)
62-
elif args.action == "write":
73+
elif args.action == "cfg-write":
6374
for key, value in args.string:
6475
comm.flash_storage_write(key, value)
6576
for key, filename in args.file:
6677
with open(filename, "rb") as fi:
6778
comm.flash_storage_write(key, fi.read())
79+
elif args.action == "cfg-delete":
80+
for key in args.key:
81+
comm.flash_storage_remove(key)
82+
elif args.action == "cfg-erase":
83+
comm.flash_storage_erase()
6884
finally:
6985
dmgr.close_devices()
7086

Diff for: ‎doc/manual/core_device_flash_storage.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ This storage area is used to store the core device MAC address, IP address and e
1111
The flash storage area is one sector (64 kB) large and is organized as a list
1212
of key-value records.
1313

14-
This flash storage space can be accessed by using the artiq_coreconfig.py :ref:`core-device-configuration-tool`.
14+
This flash storage space can be accessed by using the artiq_coretool.py :ref:`core-device-access-tool`.

Diff for: ‎doc/manual/installing.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,9 @@ To flash the ``idle`` kernel:
289289

290290
* Write it into the core device configuration flash storage: ::
291291

292-
$ artiq_coreconfig write -f idle_kernel idle.elf
292+
$ artiq_coretool cfg-write -f idle_kernel idle.elf
293293

294-
.. note:: You can find more information about how to use the ``artiq_coreconfig`` tool on the :ref:`Utilities <core-device-configuration-tool>` page.
294+
.. note:: You can find more information about how to use the ``artiq_coretool`` utility on the :ref:`Utilities <core-device-access-tool>` page.
295295

296296
Installing the host-side software
297297
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Diff for: ‎doc/manual/utilities.rst

+22-20
Original file line numberDiff line numberDiff line change
@@ -93,60 +93,62 @@ This tool compiles key/value pairs into a binary image suitable for flashing int
9393
:ref: artiq.frontend.artiq_mkfs.get_argparser
9494
:prog: artiq_mkfs
9595

96-
.. _core-device-configuration-tool:
96+
.. _core-device-access-tool:
9797

98-
Core device configuration tool
99-
------------------------------
98+
Core device access tool
99+
-----------------------
100100

101-
The artiq_coreconfig tool allows to read, write and remove key-value records from the :ref:`core-device-flash-storage`.
101+
The artiq_coretool utility allows to perform maintenance on the core device:
102102

103-
It also allows to erase the entire flash storage area.
103+
* read core device logs;
104+
* as well as read, write and remove key-value records from the :ref:`core-device-flash-storage`;
105+
* erase the entire flash storage area.
104106

105107
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``).
106108
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).
107-
When not specified, the artiq_coreconfig tool will assume that there is a file named ``ddb.pyon`` in the current directory.
109+
When not specified, the artiq_coretool utility will assume that there is a file named ``ddb.pyon`` in the current directory.
108110

109111

110112
To read the record whose key is ``mac``::
111113

112-
$ artiq_coreconfig read mac
114+
$ artiq_coretool cfg-read mac
113115

114116
To write the value ``test_value`` in the key ``my_key``::
115117

116-
$ artiq_coreconfig write -s my_key test_value
117-
$ artiq_coreconfig read my_key
118+
$ artiq_coretool cfg-write -s my_key test_value
119+
$ artiq_coretool cfg-read my_key
118120
b'test_value'
119121

120122
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::
121123

122-
$ artiq_coreconfig write -f idle_kernel idle.elf
123-
$ artiq_coreconfig read idle_kernel | head -c9
124+
$ artiq_coretool cfg-write -f idle_kernel idle.elf
125+
$ artiq_coretool cfg-read idle_kernel | head -c9
124126
b'\x7fELF
125127

126128
You can write several records at once::
127129

128-
$ artiq_coreconfig write -s key1 value1 -f key2 filename -s key3 value3
130+
$ artiq_coretool cfg-write -s key1 value1 -f key2 filename -s key3 value3
129131

130132
To remove the previously written key ``my_key``::
131133

132-
$ artiq_coreconfig delete my_key
134+
$ artiq_coretool cfg-delete my_key
133135

134136
You can remove several keys at once::
135137

136-
$ artiq_coreconfig delete key1 key2
138+
$ artiq_coretool cfg-delete key1 key2
137139

138140
To erase the entire flash storage area::
139141

140-
$ artiq_coreconfig erase
142+
$ artiq_coretool cfg-erase
141143

142144
You don't need to remove a record in order to change its value, just overwrite
143145
it::
144146

145-
$ artiq_coreconfig write -s my_key some_value
146-
$ artiq_coreconfig write -s my_key some_other_value
147-
$ artiq_coreconfig read my_key
147+
$ artiq_coretool cfg-write -s my_key some_value
148+
$ artiq_coretool cfg-write -s my_key some_other_value
149+
$ artiq_coretool cfg-read my_key
148150
b'some_other_value'
149151

150152
.. argparse::
151-
:ref: artiq.frontend.artiq_coreconfig.get_argparser
152-
:prog: artiq_coreconfig
153+
:ref: artiq.frontend.artiq_coretool.get_argparser
154+
:prog: artiq_coretool

Diff for: ‎setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def run(self):
2626
scripts = [
2727
"artiq_client=artiq.frontend.artiq_client:main",
2828
"artiq_compile=artiq.frontend.artiq_compile:main",
29-
"artiq_coreconfig=artiq.frontend.artiq_coreconfig:main",
29+
"artiq_coretool=artiq.frontend.artiq_coretool:main",
3030
"artiq_ctlmgr=artiq.frontend.artiq_ctlmgr:main",
3131
"artiq_gui=artiq.frontend.artiq_gui:main",
3232
"artiq_master=artiq.frontend.artiq_master:main",

0 commit comments

Comments
 (0)
Please sign in to comment.