chirpc: add --clear-mem option (#2343)

This patch gives the CLI the means of clearing a memory channel.
This commit is contained in:
Zachary T Welch 2015-03-09 06:55:03 -07:00
parent 28b131ea20
commit 8336361662

16
chirpc
View File

@ -110,6 +110,9 @@ if __name__ == "__main__":
memarg.add_argument("--get-mem", action="store_true",
help="Get and print memory location")
memarg.add_argument("--clear-mem", action="store_true",
help="Clear memory location")
memarg.add_argument("--set-mem-name", help="Set memory name")
memarg.add_argument("--set-mem-freq", type=float,
help="Set memory frequency")
@ -228,6 +231,19 @@ if __name__ == "__main__":
print mem
sys.exit(0)
if options.clear_mem:
memnum = parse_memory_number(radio, args)
try:
mem = radio.get_memory(memnum)
except errors.InvalidMemoryLocation, e:
LOG.exception(e)
sys.exit(1)
if mem.empty:
LOG.warn("memory %d is already empty, exiting", memnum)
sys.exit(0)
mem.empty = True
radio.set_memory(mem)
if options.raw:
memnum = parse_memory_number(radio, args)
data = radio.get_raw_memory(memnum)