[chirp_devel] [PATCH 08/10] chirpc: add --clear-mem option (#2343)

Zachary T Welch
Fri Mar 6 01:16:06 PST 2015


# HG changeset patch
# User Zachary T Welch <zach at mandolincreekfarm.com>
# Fake Node ID 350eb045efef246b0f80657abe3678daf9170d66

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

This patch gives the CLI the means of clearing a memory channel.

diff --git a/chirpc b/chirpc
index 4e88dbd..c3b85d2 100755
--- a/chirpc
+++ b/chirpc
@@ -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)




More information about the chirp_devel mailing list