[chirp_devel] [PATCH 2 of 3] [chirpc] Allow memnum arg to be a string to access special channels
Marco Filippi IZ3GME
Wed Mar 18 07:11:24 PDT 2015
# HG changeset patch
# User Marco Filippi <iz3gme.marco at 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
More information about the chirp_devel
mailing list