[chirp_devel] [PATCH 1 of 3] [chirpc] Add --list-special-mem
# HG changeset patch # User Marco Filippi iz3gme.marco@gmail.com # Date 1426686272 -3600 # Wed Mar 18 14:44:32 2015 +0100 # Node ID 8d57cc100059afe033fd4d3daf27a94f4a17cb4d # Parent 5c8ac5597f34af143915667c51ed5882e97e30f7 [chirpc] Add --list-special-mem
Add to chirpc the capability to list special channels if any The string memory representation have been changed to print the extd_number when present instead of number
Improves #2343
diff --git a/chirp/chirp_common.py b/chirp/chirp_common.py --- a/chirp/chirp_common.py +++ b/chirp/chirp_common.py @@ -364,8 +364,9 @@ else: dup = self.duplex
- return "Memory %i: %s%s%s %s (%s) r%.1f%s c%.1f%s d%03i%s%s [%.2f]" % \ - (self.number, + return \ + "Memory %s: %s%s%s %s (%s) r%.1f%s c%.1f%s d%03i%s%s [%.2f]" % \ + (self.number if self.extd_number == "" else self.extd_number, format_freq(self.freq), dup, format_freq(self.offset), diff --git a/chirpc b/chirpc --- a/chirpc +++ b/chirpc @@ -105,6 +105,9 @@ memarg.add_argument("--list-mem", action="store_true", help="List all memory locations")
+ memarg.add_argument("--list-special-mem", action="store_true", + help="List all special memory locations") + memarg.add_argument("--raw", action="store_true", help="Dump raw memory location")
@@ -233,6 +236,15 @@ print mem sys.exit(0)
+ if options.list_special_mem: + rf = radio.get_features() + for i in sorted(rf.valid_special_chans): + mem = radio.get_memory(i) + if mem.empty and not logger.is_visible(logging.INFO): + continue + print mem + sys.exit(0) + if options.copy_mem: src = parse_memory_number(radio, args) dst = parse_memory_number(radio, args[1:])
# HG changeset patch # User Marco Filippi iz3gme.marco@gmail.com # Date 1426687444 -3600 # Wed Mar 18 15:04:04 2015 +0100 # Node ID 06641d7d614d2f70db935c777edbc5371def666a # Parent 8d57cc100059afe033fd4d3daf27a94f4a17cb4d [chirpc] Allow memnum arg to be a string to access special channels
Special channels are identified by extd_number which can be a string
Improves #2343
diff --git a/chirpc b/chirpc --- a/chirpc +++ b/chirpc @@ -74,14 +74,19 @@ try: memnum = int(args[0]) except ValueError: - LOG.error("'%s' is not a valid memory number", args[0]) - sys.exit(1) + memnum = args[0]
rf = radio.get_features() start, end = rf.memory_bounds - if memnum < start or memnum > end: - LOG.error("memory number must be between %d and %d (got %d)", - start, end, memnum) + if not (start <= memnum <= end or memnum in rf.valid_special_chans): + if len(rf.valid_special_chans) > 0: + LOG.error( + "memory number must be between %d and %d or one of %s" + " (got %s)", + start, end, ", ".join(rf.valid_special_chans), memnum) + else: + LOG.error("memory number must be between %d and %d (got %s)", + start, end, memnum) sys.exit(1) return memnum
@@ -253,7 +258,7 @@ except errors.InvalidMemoryLocation, e: LOG.exception(e) sys.exit(1) - LOG.info("copying memory %d to %d", src, dst) + LOG.info("copying memory %s to %s", src, dst) mem.number = dst radio.set_memory(mem)
@@ -265,7 +270,7 @@ LOG.exception(e) sys.exit(1) if mem.empty: - LOG.warn("memory %d is already empty, exiting", memnum) + LOG.warn("memory %s is already empty, exiting", memnum) sys.exit(0) mem.empty = True radio.set_memory(mem) @@ -275,7 +280,7 @@ data = radio.get_raw_memory(memnum) for i in data: if ord(i) > 0x7F: - print "Memory location %i (%i):\n%s" % \ + print "Memory location %s (%i):\n%s" % \ (memnum, len(data), util.hexprint(data)) sys.exit(0) print data @@ -319,7 +324,7 @@ sys.exit(1)
if mem.empty: - LOG.info("creating new memory (#%d)", memnum) + LOG.info("creating new memory (#%s)", memnum) mem = chirp_common.Memory() mem.number = memnum
# HG changeset patch # User Marco Filippi iz3gme.marco@gmail.com # Date 1426687447 -3600 # Wed Mar 18 15:04:07 2015 +0100 # Node ID 797a3a043831083140c39ac84eba11a8a5f286e8 # Parent 06641d7d614d2f70db935c777edbc5371def666a [chirpc] Allow deleting an already empty memory
On some radio (eg ft817) empty channels can contain valid data, deleting again such a memory usually clean data
Improves #2343
diff --git a/chirpc b/chirpc --- a/chirpc +++ b/chirpc @@ -270,8 +270,7 @@ LOG.exception(e) sys.exit(1) if mem.empty: - LOG.warn("memory %s is already empty, exiting", memnum) - sys.exit(0) + LOG.warn("memory %s is already empty, deleting again", memnum) mem.empty = True radio.set_memory(mem)
participants (1)
-
Marco Filippi IZ3GME