summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2022-11-06 21:01:26 +0100
committerChristoph Berg <myon@debian.org>2022-11-06 21:01:26 +0100
commit40c9ab872fbdd8b7d2b1cb630ea324b7a3b01e4a (patch)
tree60edba4b7a503cb639f603b9239192321bd78f6f
parenta1b9c5b655ec5b0bba958c41ebdabffb564eb7ee (diff)
parent14581c70e561f9f350a4d5ad86924a5d466028d4 (diff)
Update upstream source from tag 'upstream/20211015+py3'
Update to upstream version '20211015+py3' with Debian dir 0e6663ccd1c5a83c6b464f7b78532a8a4d2b0f98
-rw-r--r--.hg_archival.txt6
-rw-r--r--.hgignore18
-rw-r--r--.hgtags17
-rw-r--r--.pylintrc308
-rw-r--r--chirp/bitwise.py10
-rw-r--r--chirp/detect.py12
-rw-r--r--chirp/drivers/icomciv.py480
-rw-r--r--chirp/ui/memdetail.py28
-rw-r--r--chirp/wxui/developer.py3
-rw-r--r--chirp/wxui/main.py115
-rw-r--r--chirp/wxui/memedit.py4
-rw-r--r--[-rwxr-xr-x]chirpc34
-rw-r--r--[-rwxr-xr-x]tests/run_tests.py6
13 files changed, 590 insertions, 451 deletions
diff --git a/.hg_archival.txt b/.hg_archival.txt
deleted file mode 100644
index c9100da..0000000
--- a/.hg_archival.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-repo: 31cfb1a376fb354ec5e007193bde57cf2fb9f442
-node: 68534f20c1418ae8e4cc09f3ff468d0375ba843a
-branch: py3
-latesttag: release_0_4_0
-latesttagdistance: 996
-changessincelatesttag: 1144
diff --git a/.hgignore b/.hgignore
deleted file mode 100644
index 74517dc..0000000
--- a/.hgignore
+++ /dev/null
@@ -1,18 +0,0 @@
-.*\~$
-.*\.pyc$
-.*\.orig$
-.*\.rej$
-dist
-build/bdist
-tools/cpep8.venv/
-tests/logs/
-logs/
-ignored/
-patch_queue/
-archived_builds/
-.tox/
-.*\.mo$
-.*\.pot$
-locale/.files
-MANIFEST
-.pytest_cache
diff --git a/.hgtags b/.hgtags
deleted file mode 100644
index 3192edf..0000000
--- a/.hgtags
+++ /dev/null
@@ -1,17 +0,0 @@
-1428729c41b76d9e88023a8d9073bd947b1f64e4 release_0_1_1
-b6d7fbb63c67b431afb526c1c5682198884050e7 release_0_1_2
-1ed337baf81ee9e3a8cf80c095c79fda40f09000 release_0_1_3
-05dd19dd4db874ae9b94fd2ce4b81a9fe1a7b279 release_0_1_4
-5ab503b39a8609f428b4d44389507672090ddee6 release_0_1_5
-f31a4c4d772dfb9f0519586bfc683ac0c095e8a8 release_0_1_6
-61ed9897712816f2959ecda8135526e15ec7a046 release_0_1_7
-22c1e4d0f349c13e8a9e02cd2f0c4ba58033824e release_0_1_8
-c6f153e861ddca4b2568f83ef8d20c9ef3d6565e release_0_1_9
-03e812a988209069d5de9ff744a7c5d77bca4b94 release_0_1_10
-629e127c61ded83612f322d86b960c4fcbb5df7d release_0_1_11
-3dd33f5175ca34b06fd118a63c692297b5eb2550 release_0_1_12
-df5342f5ce3d3615dff38238d3112711c3628be6 release_0_2_0
-744ce08c8bea0868ce756e270043dbef59b5eb7f release_0_2_1
-30eeb96b77fb90ca88689cc2f76af379123e5e6e release_0_2_2
-e4901095dc40aa73cc9eb95105e7b32c756f53b0 release_0_3_0
-e91f09ca03d07a9f565291a60e8b84073298b8ac release_0_4_0
diff --git a/.pylintrc b/.pylintrc
deleted file mode 100644
index 8a8f0a3..0000000
--- a/.pylintrc
+++ /dev/null
@@ -1,308 +0,0 @@
-# lint Python modules using external checkers.
-#
-# This is the main checker controling the other ones and the reports
-# generation. It is itself both a raw checker and an astng checker in order
-# to:
-# * handle message activation / deactivation at the module level
-# * handle some basic but necessary stats'data (number of classes, methods...)
-#
-[MASTER]
-
-# Specify a configuration file.
-#rcfile=
-
-# Python code to execute, usually for sys.path manipulation such as
-# pygtk.require().
-#init-hook=
-
-# Profiled execution.
-profile=no
-
-# Add <file or directory> to the black list. It should be a base name, not a
-# path. You may set this option multiple times.
-ignore=dist
-ignore=icons
-ignore=.hg
-
-# Pickle collected data for later comparisons.
-persistent=yes
-
-# Set the cache size for astng objects.
-cache-size=500
-
-# List of plugins (as comma separated values of python modules names) to load,
-# usually to register additional checkers.
-load-plugins=
-
-
-[MESSAGES CONTROL]
-
-# Enable only checker(s) with the given id(s). This option conflicts with the
-# disable-checker option
-#enable-checker=
-
-# Enable all checker(s) except those with the given id(s). This option
-# conflicts with the enable-checker option
-disable-checker=SIMILARITIES
-
-# Enable all messages in the listed categories.
-#enable-msg-cat=
-
-# Disable all messages in the listed categories.
-#disable-msg-cat=
-
-# Enable the message(s) with the given id(s).
-#enable-msg=
-
-# Disable the message(s) with the given id(s).
-disable-msg=W0142,C0111
-
-
-[REPORTS]
-
-# set the output format. Available formats are text, parseable, colorized, msvs
-# (visual studio) and html
-output-format=text
-
-# Include message's id in output
-include-ids=no
-
-# Put messages in a separate file for each module / package specified on the
-# command line instead of printing them on stdout. Reports (if any) will be
-# written in a file name "pylint_global.[txt|html]".
-files-output=no
-
-# Tells wether to display a full report or only the messages
-reports=yes
-
-# Python expression which should return a note less than 10 (10 is the highest
-# note).You have access to the variables errors warning, statement which
-# respectivly contain the number of errors / warnings messages and the total
-# number of statements analyzed. This is used by the global evaluation report
-# (R0004).
-evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
-
-# Add a comment according to your evaluation note. This is used by the global
-# evaluation report (R0004).
-comment=no
-
-# Enable the report(s) with the given id(s).
-#enable-report=
-
-# Disable the report(s) with the given id(s).
-#disable-report=
-
-
-# checks for :
-# * doc strings
-# * modules / classes / functions / methods / arguments / variables name
-# * number of arguments, local variables, branchs, returns and statements in
-# functions, methods
-# * required module attributes
-# * dangerous default values as arguments
-# * redefinition of function / method / class
-# * uses of the global statement
-#
-[BASIC]
-
-# Required attributes for module, separated by a comma
-required-attributes=
-
-# Regular expression which should only match functions or classes name which do
-# not require a docstring
-#no-docstring-rgx=__.*__
-no-docstring-rgx=.*
-
-# Regular expression which should only match correct module names
-module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
-
-# Regular expression which should only match correct module level names
-const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
-
-# Regular expression which should only match correct class names
-class-rgx=[A-Z_][a-zA-Z0-9]+$
-
-# Regular expression which should only match correct function names
-function-rgx=[a-z_][a-z0-9_]{1,30}$
-
-# Regular expression which should only match correct method names
-method-rgx=[a-z_][a-z0-9_]{1,30}$
-
-# Regular expression which should only match correct instance attribute names
-attr-rgx=[a-z_][a-z0-9_]{1,30}$
-
-# Regular expression which should only match correct argument names
-argument-rgx=[a-z_][a-z0-9_]{1,30}$
-
-# Regular expression which should only match correct variable names
-variable-rgx=[a-z_][a-z0-9_]{1,30}$
-
-# Regular expression which should only match correct list comprehension /
-# generator expression variable names
-inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
-
-# Good variable names which should always be accepted, separated by a comma
-good-names=i,j,k,ex,Run,_,e
-
-# Bad variable names which should always be refused, separated by a comma
-bad-names=foo,bar,baz,toto,tutu,tata
-
-# List of builtins function names that should not be used, separated by a comma
-bad-functions=map,filter,apply,input
-
-
-# try to find bugs in the code using type inference
-#
-[TYPECHECK]
-
-# Tells wether missing members accessed in mixin class should be ignored. A
-# mixin class is detected if its name ends with "mixin" (case insensitive).
-ignore-mixin-members=yes
-
-# When zope mode is activated, consider the acquired-members option to ignore
-# access to some undefined attributes.
-zope=no
-
-# List of members which are usually get through zope's acquisition mecanism and
-# so shouldn't trigger E0201 when accessed (need zope=yes to be considered).
-acquired-members=REQUEST,acl_users,aq_parent
-
-
-# checks for
-# * unused variables / imports
-# * undefined variables
-# * redefinition of variable from builtins or from an outer scope
-# * use of variable before assigment
-#
-[VARIABLES]
-
-# Tells wether we should check for unused import in __init__ files.
-init-import=no
-
-# A regular expression matching names used for dummy variables (i.e. not used).
-dummy-variables-rgx=_|dummy
-
-# List of additional names supposed to be defined in builtins. Remember that
-# you should avoid to define new builtins when possible.
-additional-builtins=
-
-
-# checks for sign of poor/misdesign:
-# * number of methods, attributes, local variables...
-# * size, complexity of functions, methods
-#
-[DESIGN]
-
-# Maximum number of arguments for function / method
-max-args=5
-
-# Maximum number of locals for function / method body
-max-locals=15
-
-# Maximum number of return / yield for function / method body
-max-returns=6
-
-# Maximum number of branch for function / method body
-max-branchs=12
-
-# Maximum number of statements in function / method body
-max-statements=50
-
-# Maximum number of parents for a class (see R0901).
-max-parents=7
-
-# Maximum number of attributes for a class (see R0902).
-max-attributes=7
-
-# Minimum number of public methods for a class (see R0903).
-min-public-methods=2
-
-# Maximum number of public methods for a class (see R0904).
-max-public-methods=20
-
-
-# checks for :
-# * methods without self as first argument
-# * overridden methods signature
-# * access only to existant members via self
-# * attributes not defined in the __init__ method
-# * supported interfaces implementation
-# * unreachable code
-#
-[CLASSES]
-
-# List of interface methods to ignore, separated by a comma. This is used for
-# instance to not check methods defines in Zope's Interface base class.
-ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by
-
-# List of method names used to declare (i.e. assign) instance attributes.
-defining-attr-methods=__init__,__new__,setUp
-
-
-# checks for
-# * external modules dependencies
-# * relative / wildcard imports
-# * cyclic imports
-# * uses of deprecated modules
-#
-[IMPORTS]
-
-# Deprecated modules which should not be used, separated by a comma
-deprecated-modules=regsub,string,TERMIOS,Bastion,rexec
-
-# Create a graph of every (i.e. internal and external) dependencies in the
-# given file (report R0402 must not be disabled)
-import-graph=
-
-# Create a graph of external dependencies in the given file (report R0402 must
-# not be disabled)
-ext-import-graph=
-
-# Create a graph of internal dependencies in the given file (report R0402 must
-# not be disabled)
-int-import-graph=
-
-
-# checks for:
-# * warning notes in the code like FIXME, XXX
-# * PEP 263: source code with non ascii character but no encoding declaration
-#
-[MISCELLANEOUS]
-
-# List of note tags to take in consideration, separated by a comma.
-notes=FIXME,XXX,TODO
-
-
-# checks for :
-# * unauthorized constructions
-# * strict indentation
-# * line length
-# * use of <> instead of !=
-#
-[FORMAT]
-
-# Maximum number of characters on a single line.
-max-line-length=80
-
-# Maximum number of lines in a module
-max-module-lines=1000
-
-# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
-# tab).
-indent-string=' '
-
-
-# checks for similarities and duplicated code. This computation may be
-# memory / CPU intensive, so you should disable it if you experiments some
-# problems.
-#
-[SIMILARITIES]
-
-# Minimum lines number of a similarity.
-min-similarity-lines=4
-
-# Ignore comments when computing similarities.
-ignore-comments=yes
-
-# Ignore docstrings when computing similarities.
-ignore-docstrings=yes
diff --git a/chirp/bitwise.py b/chirp/bitwise.py
index 1559162..4a6016d 100644
--- a/chirp/bitwise.py
+++ b/chirp/bitwise.py
@@ -174,7 +174,7 @@ def bcd_to_int(bcd_array):
def int_to_bcd(bcd_array, value):
"""Convert an int like 1234 into bcdDataElements like "\x12\x34" """
- for i in reversed(list(range(0, len(bcd_array)))):
+ for i in reversed(range(0, len(bcd_array))):
bcd_array[i].set_value(value % 100)
value /= 100
@@ -732,7 +732,7 @@ class structDataElement(DataElement):
self._generators = {}
self._keys = []
self._count = 1
- if "name" in list(kwargs.keys()):
+ if "name" in kwargs.keys():
self._name = kwargs["name"]
del kwargs["name"]
else:
@@ -742,7 +742,7 @@ class structDataElement(DataElement):
def _value(self, data, generators):
result = {}
- for name, gen in list(generators.items()):
+ for name, gen in generators.items():
result[name] = gen.get_value(data)
return result
@@ -780,7 +780,7 @@ class structDataElement(DataElement):
def size(self):
size = 0
- for name, gen in list(self._generators.items()):
+ for name, gen in self._generators.items():
if not isinstance(gen, list):
gen = [gen]
@@ -806,7 +806,7 @@ class structDataElement(DataElement):
self._data[self._offset] = buffer
def __iter__(self):
- for item in list(self._generators.values()):
+ for item in self._generators.values():
yield item
def items(self):
diff --git a/chirp/detect.py b/chirp/detect.py
index ffa9024..1811fb6 100644
--- a/chirp/detect.py
+++ b/chirp/detect.py
@@ -16,12 +16,20 @@
import serial
import logging
-from chirp import errors, directory
+from chirp import chirp_common, errors, directory
from chirp.drivers import ic9x_ll, icf, kenwood_live, icomciv
LOG = logging.getLogger(__name__)
+class DetectorRadio(chirp_common.Radio):
+ """Minimal radio for model detection"""
+ MUNCH_CLONE_RESP = False
+
+ def get_payload(self, data, raw, checksum):
+ return data
+
+
def _icom_model_data_to_rclass(md):
for _rtype, rclass in list(directory.DRV_TO_RADIO.items()):
if rclass.VENDOR != "Icom":
@@ -40,7 +48,7 @@ def _detect_icom_radio(ser):
try:
ser.baudrate = 9600
- md = icf.get_model_data(ser)
+ md = icf.get_model_data(DetectorRadio(ser))
return _icom_model_data_to_rclass(md)
except errors.RadioError as e:
LOG.error("_detect_icom_radio: %s", e)
diff --git a/chirp/drivers/icomciv.py b/chirp/drivers/icomciv.py
index 24fb297..af7fa90 100644
--- a/chirp/drivers/icomciv.py
+++ b/chirp/drivers/icomciv.py
@@ -1,9 +1,9 @@
-
+# Latest update: April, 2021 Add hasattr test at line 564
import struct
import logging
from chirp.drivers import icf
from chirp import chirp_common, util, errors, bitwise, directory
-from chirp.memmap import MemoryMap
+from chirp.memmap import MemoryMapBytes
from chirp.settings import RadioSetting, RadioSettingGroup, \
RadioSettingValueList, RadioSettingValueBoolean
@@ -72,7 +72,7 @@ u8 unknown2:4, // 22 zero
u8 secondDtcs:4, // 23 second digit DTCS
thirdDtcs:4; // 23 third digit DTCS
u8 digitalSquelch; // 24 Digital code squelch setting
-u8 duplexOffset[3]; // 25-27 duplex offset freq
+lbcd duplexOffset[3]; // 25-27 duplex offset freq
char destCall[8]; // 28-35 destination call sign
char accessRepeaterCall[8];// 36-43 access repeater call sign
char linkRepeaterCall[8]; // 44-51 gateway/link repeater call sign
@@ -80,6 +80,19 @@ bbcd duplexSettings[47]; // repeat of 5-51 for duplex
char name[16]; // 52-60 Name of station
"""
+MEM_IC910_FORMAT = """
+u8 bank; // 1 bank number
+bbcd number[2]; // 2,3
+lbcd freq[5]; // 4-8 operating freq
+u8 mode; // 9 operating mode
+u8 filter; // 10 filter
+u8 tmode:4, // 11 tone
+ duplex:4; // 11 duplex off/-/+
+bbcd rtone[3]; // 12-14 repeater tone freq
+bbcd ctone[3]; // 15-17 tone squelch setting
+lbcd duplexOffset[3]; // 18-20 duplex offset freq
+"""
+
mem_duptone_format = """
bbcd number[2];
u8 unknown1;
@@ -101,6 +114,31 @@ u8 unknown[11];
char name[9];
"""
+MEM_IC7300_FORMAT = """
+bbcd number[2]; // 1,2
+u8 spl:4, // 3 split and select memory settings
+ select:4;
+lbcd freq[5]; // 4-8 receive freq
+u8 mode; // 9 operating mode
+u8 filter; // 10 filter 1-3 (undocumented)
+u8 dataMode:4, // 11 data mode setting (on or off)
+ tmode:4; // 11 tone type
+char pad1;
+bbcd rtone[2]; // 12-14 tx tone freq
+char pad2;
+bbcd ctone[2]; // 15-17 tone rx squelch setting
+lbcd freq_tx[5]; // 4-8 transmit freq
+u8 mode_tx; // 9 tx operating mode
+u8 filter_tx; // 10
+u8 dataMode_tx:4, // 11 tx data mode setting (on or off)
+ tmode_tx:4; // 11 tx tone type
+char pad3;
+bbcd rtone_tx[2]; // 12-14 repeater tone freq
+char pad4;
+bbcd ctone_tx[2]; // 15-17 tone squelch setting
+char name[10]; // 18-27 Callsign
+"""
+
SPLIT = ["", "spl"]
@@ -110,7 +148,7 @@ class Frame:
_sub = 0x00
def __init__(self):
- self._data = ""
+ self._data = b""
def set_command(self, cmd, sub):
"""Set the command number (and optional subcommand)"""
@@ -127,38 +165,44 @@ class Frame:
def send(self, src, dst, serial, willecho=True):
"""Send the frame over @serial, using @src and @dst addresses"""
- raw = struct.pack("BBBBBB", 0xFE, 0xFE, src, dst, self._cmd, self._sub)
- raw += str(self._data) + chr(0xFD)
+ hdr = struct.pack("BBBBBB", 0xFE, 0xFE, src, dst, self._cmd, self._sub)
+ raw = bytearray(hdr)
+ if isinstance(self._data, MemoryMapBytes):
+ data = self._data.get_packed()
+ else:
+ data = self._data
+ raw.extend(data)
+ raw.append(0xFD)
LOG.debug("%02x -> %02x (%i):\n%s" %
- (src, dst, len(raw), util.hexprint(raw)))
+ (src, dst, len(raw), util.hexprint(bytes(raw))))
serial.write(raw)
if willecho:
echo = serial.read(len(raw))
if echo != raw and echo:
LOG.debug("Echo differed (%i/%i)" % (len(raw), len(echo)))
- LOG.debug(util.hexprint(raw))
- LOG.debug(util.hexprint(echo))
+ LOG.debug(util.hexprint(bytes(raw)))
+ LOG.debug(util.hexprint(bytes(echo)))
def read(self, serial):
"""Read the frame from @serial"""
- data = ""
- while not data.endswith(chr(0xFD)):
+ data = bytearray()
+ while not (data and data[-1] == 0xFD):
char = serial.read(1)
if not char:
LOG.debug("Read %i bytes total" % len(data))
raise errors.RadioError("Timeout")
- data += char
+ data.extend(char)
- if data == chr(0xFD):
+ if data[0] == 0xFD:
raise errors.RadioError("Radio reported error")
src, dst = struct.unpack("BB", data[2:4])
- LOG.debug("%02x <- %02x:\n%s" % (dst, src, util.hexprint(data)))
+ LOG.debug("%02x <- %02x:\n%s" % (dst, src, util.hexprint(bytes(data))))
- self._cmd = ord(data[4])
- self._sub = ord(data[5])
+ self._cmd = data[4]
+ self._sub = data[5]
self._data = data[6:-1]
return src, dst
@@ -188,12 +232,14 @@ class MemFrame(Frame):
def get_obj(self):
"""Return a bitwise parsed object"""
- self._data = MemoryMap(str(self._data)) # Make sure we're assignable
+ # Make sure we're assignable
+ self._data = MemoryMapBytes(bytes(self._data))
return bitwise.parse(MEM_FORMAT, self._data)
def initialize(self):
"""Initialize to sane values"""
- self._data = MemoryMap("".join(["\x00"] * (self.get_obj().size() / 8)))
+ self._data = MemoryMapBytes(
+ bytes(b'\x00' * (self.get_obj().size() / 8)))
class BankMemFrame(MemFrame):
@@ -214,7 +260,8 @@ class BankMemFrame(MemFrame):
int("%04i" % self._loc, 16), 0xFF)
def get_obj(self):
- self._data = MemoryMap(str(self._data)) # Make sure we're assignable
+ # Make sure we're assignable
+ self._data = MemoryMapBytes(bytes(self._data))
return bitwise.parse(self.FORMAT, self._data)
@@ -222,15 +269,53 @@ class IC7100MemFrame(BankMemFrame):
FORMAT = MEM_IC7100_FORMAT
+class IC910MemFrame(BankMemFrame):
+ FORMAT = MEM_IC910_FORMAT
+
+
class DupToneMemFrame(MemFrame):
def get_obj(self):
- self._data = MemoryMap(str(self._data))
+ self._data = MemoryMapBytes(bytes(self._data))
return bitwise.parse(mem_duptone_format, self._data)
+class IC7300MemFrame(MemFrame):
+ FORMAT = MEM_IC7300_FORMAT
+
+ def get_obj(self):
+ self._data = MemoryMapBytes(bytes(self._data))
+ return bitwise.parse(self.FORMAT, self._data)
+
+
+class SpecialChannel(object):
+ """Info for special (named) channels"""
+
+ def __init__(self):
+ self.name = None
+ self.location = None
+ self.channel = None
+
+ def __repr__(self):
+ s = "SpecialChannel(name=%r, location=%r, channel=%r)"
+ return s % (self.name, self.location, self.channel)
+
+
+class BankSpecialChannel(SpecialChannel):
+ """Info for special (named) channels for radios with multiple banks"""
+
+ def __init__(self):
+ super(BankSpecialChannel, self).__init__()
+ self.bank = None
+
+ def __repr__(self):
+ s = "BankSpecialChannel(name=%r, location=%r, bank=%r, channel=%r)"
+ return s % (self.name, self.location, self.bank, self.channel)
+
+
class IcomCIVRadio(icf.IcomLiveRadio):
"""Base class for ICOM CIV-based radios"""
BAUD_RATE = 19200
+ NEEDS_COMPAT_SERIAL = False
MODEL = "CIV Radio"
_model = "\x00"
_template = 0
@@ -245,12 +330,27 @@ class IcomCIVRadio(icf.IcomLiveRadio):
"DV",
]
+ # Unified modes where mode and filter are combined. See note at
+ # _unified_modes.
+ _UNIFIED_MODES = {
+ 'FM': 'NFM',
+ 'CW': 'NCW'
+ }
+
def mem_to_ch_bnk(self, mem):
+ if self._adjust_bank_loc_start:
+ mem -= 1
l, h = self._bank_index_bounds
bank_no = (mem // (h - l + 1)) + l
channel = mem % (h - l + 1) + l
return (channel, bank_no)
+ def _is_special(self, number):
+ return False
+
+ def _get_special_info(self, number):
+ raise errors.RadioError("Radio does not support special channels")
+
def _send_frame(self, frame):
return frame.send(ord(self._model), 0xE0, self.pipe,
willecho=self._willecho)
@@ -265,10 +365,10 @@ class IcomCIVRadio(icf.IcomLiveRadio):
pass
def _detect_echo(self):
- echo_test = "\xfe\xfe\xe0\xe0\xfa\xfd"
+ echo_test = b"\xfe\xfe\xe0\xe0\xfa\xfd"
self.pipe.write(echo_test)
resp = self.pipe.read(6)
- LOG.debug("Echo:\n%s" % util.hexprint(resp))
+ LOG.debug("Echo:\n%s" % util.hexprint(bytes(resp)))
return resp == echo_test
def __init__(self, *args, **kwargs):
@@ -282,6 +382,8 @@ class IcomCIVRadio(icf.IcomLiveRadio):
self._willecho = self._detect_echo()
LOG.debug("Interface echo: %s" % self._willecho)
self.pipe.timeout = 1
+ else:
+ self._willecho = False
# f = Frame()
# f.set_command(0x19, 0x00)
@@ -296,6 +398,22 @@ class IcomCIVRadio(icf.IcomLiveRadio):
# self._id = f.get_data()[0]
self._rf = chirp_common.RadioFeatures()
+ # On some radios, the filter field is used to signify normal versus
+ # narrow modes, rather than being a distinct passband feature. As
+ # such, mode + filter comprises a "unified mode" value that can be
+ # mapped into a Chirp mode.
+ self._unified_modes = False
+
+ # Icom live radios with bank support present their memories to the
+ # user starting from 1. For some reason, IC-7000 and IC-7100 were
+ # implemented with the Chirp location starting from 0, so that the
+ # user must mentally adjust. While adding IC-910 support, allowance
+ # was made to provide a 1-based start, using the following setting.
+ # This is not currently applied to the IC-7000 or IC-7100 due to the
+ # inability to test, and also since changing it may cause issues if
+ # location limit keys have been saved in the user's config file.
+ self._adjust_bank_loc_start = False
+
self._initialize()
def get_features(self):
@@ -309,14 +427,24 @@ class IcomCIVRadio(icf.IcomLiveRadio):
return f
def get_raw_memory(self, number):
+ LOG.debug("Getting %s (raw)" % number)
f = self._classes["mem"]()
- if self._rf.has_bank:
+ if self._is_special(number):
+ info = self._get_special_info(number)
+ LOG.debug("Special info: %s" % info)
+ ch = info.channel
+ if self._rf.has_bank:
+ bnk = info.bank
+ elif self._rf.has_bank:
ch, bnk = self.mem_to_ch_bnk(number)
+ else:
+ ch = number
+ if self._rf.has_bank:
f.set_location(ch, bnk)
loc = "bank %i, channel %02i" % (bnk, ch)
else:
- f.set_location(number)
- loc = "number %i" % number
+ f.set_location(ch)
+ loc = "number %i" % ch
self._send_frame(f)
f.read(self.pipe)
if f.get_data() and f.get_data()[-1] == "\xFF":
@@ -329,6 +457,8 @@ class IcomCIVRadio(icf.IcomLiveRadio):
# change so we use a little math to calculate what bank a location
# is in. We can't change the bank a location is in so we just pass.
def _get_bank(self, loc):
+ if self._adjust_bank_loc_start:
+ loc -= 1
l, h = self._bank_index_bounds
return loc // (h - l + 1)
@@ -336,24 +466,33 @@ class IcomCIVRadio(icf.IcomLiveRadio):
pass
def get_memory(self, number):
- LOG.debug("Getting %i" % number)
+ LOG.debug("Getting %s" % number)
f = self._classes["mem"]()
- if self._rf.has_bank:
- ch, bnk = self.mem_to_ch_bnk(number)
- f.set_location(ch, bnk)
- LOG.debug("Bank %i, Channel %02i" % (bnk, ch))
+ mem = chirp_common.Memory()
+ if self._is_special(number):
+ info = self._get_special_info(number)
+ LOG.debug("Special info: %s" % info)
+ if self._rf.has_bank:
+ f.set_location(info.channel, info.bank)
+ else:
+ f.set_location(info.channel)
+ mem.number = info.location
+ mem.extd_number = info.name
+ mem.immutable = ["number", "extd_number"]
else:
- f.set_location(number)
+ if self._rf.has_bank:
+ ch, bnk = self.mem_to_ch_bnk(number)
+ f.set_location(ch, bnk)
+ LOG.debug("Bank %i, Channel %02i" % (bnk, ch))
+ else:
+ f.set_location(number)
+ mem.number = number
self._send_frame(f)
- mem = chirp_common.Memory()
- mem.number = number
- mem.immutable = []
-
f = self._recv_frame(f)
if len(f.get_data()) == 0:
raise errors.RadioError("Radio reported error")
- if f.get_data() and f.get_data()[-1] == "\xFF":
+ if f.get_data() and f.get_data()[-1] == 0xFF:
mem.empty = True
LOG.debug("Found %i empty" % mem.number)
return mem
@@ -388,6 +527,20 @@ class IcomCIVRadio(icf.IcomLiveRadio):
repr(memobj.mode),
)
raise
+ if self._unified_modes and memobj.filter == 2:
+ try:
+ # Adjust mode to its narrow variant
+ mem.mode = self._UNIFIED_MODES[mem.mode]
+ except KeyError:
+ LOG.error(
+ "Bank %s location %s is set for mode %s with filter %s, "
+ "but no known mode matches that combination.",
+ int(memobj.bank),
+ int(memobj.number),
+ repr(memobj.mode),
+ int(memobj.filter),
+ )
+ raise
if self._rf.has_name:
mem.name = str(memobj.name).rstrip()
@@ -418,13 +571,15 @@ class IcomCIVRadio(icf.IcomLiveRadio):
mem.duplex = self._rf.valid_duplexes[memobj.duplex]
if self._rf.can_odd_split and memobj.spl:
- mem.duplex = "split"
+ if hasattr(memobj, "duplex"):
+ mem.duplex = "split"
mem.offset = int(memobj.freq_tx)
mem.immutable = []
+ elif hasattr(memobj, "duplexOffset"):
+ mem.offset = int(memobj.duplexOffset) * 100
else:
mem.immutable = ["offset"]
- mem.extra = RadioSettingGroup("extra", "Extra")
try:
dig = RadioSetting("dig", "Digital",
RadioSettingValueBoolean(bool(memobj.dig)))
@@ -432,33 +587,46 @@ class IcomCIVRadio(icf.IcomLiveRadio):
pass
else:
dig.set_doc("Enable digital mode")
+ if not mem.extra:
+ mem.extra = RadioSettingGroup("extra", "Extra")
mem.extra.append(dig)
- options = ["Wide", "Mid", "Narrow"]
- try:
- fil = RadioSetting(
- "filter", "Filter",
- RadioSettingValueList(options,
- options[memobj.filter - 1]))
- except AttributeError:
- pass
- else:
- fil.set_doc("Filter settings")
- mem.extra.append(fil)
+ if not self._unified_modes:
+ options = ["Wide", "Mid", "Narrow"]
+ try:
+ fil = RadioSetting(
+ "filter", "Filter",
+ RadioSettingValueList(options,
+ options[memobj.filter - 1]))
+ except AttributeError:
+ pass
+ else:
+ fil.set_doc("Filter settings")
+ if not mem.extra:
+ mem.extra = RadioSettingGroup("extra", "Extra")
+ mem.extra.append(fil)
return mem
def set_memory(self, mem):
- LOG.debug("Setting %i(%s)" % (mem.number, mem.extd_number))
- if self._rf.has_bank:
+ LOG.debug("Setting %s(%s)" % (mem.number, mem.extd_number))
+ f = self._get_template_memory()
+ if self._is_special(mem.number):
+ info = self._get_special_info(mem.number)
+ LOG.debug("Special info: %s" % info)
+ ch = info.channel
+ if self._rf.has_bank:
+ bnk = info.bank
+ elif self._rf.has_bank:
ch, bnk = self.mem_to_ch_bnk(mem.number)
LOG.debug("Bank %i, Channel %02i" % (bnk, ch))
- f = self._get_template_memory()
+ else:
+ ch = mem.number
if mem.empty:
if self._rf.has_bank:
f.set_location(ch, bnk)
else:
- f.set_location(mem.number)
+ f.set_location(ch)
LOG.debug("Making %i empty" % mem.number)
f.make_empty()
self._send_frame(f)
@@ -468,7 +636,7 @@ class IcomCIVRadio(icf.IcomLiveRadio):
# IC-7000. No testing was done to see if it breaks memory delete on the
# IC-746 or IC-7200.
f = self._recv_frame()
- LOG.debug("Result:\n%s" % util.hexprint(f.get_data()))
+ LOG.debug("Result:\n%s" % util.hexprint(bytes(f.get_data())))
return
# f.set_data(MemoryMap(self.get_raw_memory(mem.number)))
@@ -479,7 +647,7 @@ class IcomCIVRadio(icf.IcomLiveRadio):
memobj.bank = bnk
memobj.number = ch
else:
- memobj.number = mem.number
+ memobj.number = ch
if mem.skip == "S":
memobj.skip = 0
else:
@@ -488,7 +656,16 @@ class IcomCIVRadio(icf.IcomLiveRadio):
except KeyError:
pass
memobj.freq = int(mem.freq)
- memobj.mode = self._MODES.index(mem.mode)
+ mode = mem.mode
+ if self._unified_modes:
+ lookup = [
+ k for k, v in self._UNIFIED_MODES.items() if v == mode]
+ if lookup:
+ mode = lookup[0]
+ memobj.filter = 2
+ else:
+ memobj.filter = 1
+ memobj.mode = self._MODES.index(mode)
if self._rf.has_name:
name_length = len(memobj.name.get_value())
memobj.name = mem.name.ljust(name_length)[:name_length]
@@ -515,15 +692,19 @@ class IcomCIVRadio(icf.IcomLiveRadio):
if self._rf.can_odd_split and mem.duplex == "split":
memobj.spl = 1
- memobj.duplex = 0
+ if hasattr(memobj, "duplex"):
+ memobj.duplex = 0
memobj.freq_tx = int(mem.offset)
memobj.tmode_tx = memobj.tmode
memobj.ctone_tx = memobj.ctone
memobj.rtone_tx = memobj.rtone
- memobj.dtcs_polarity_tx = memobj.dtcs_polarity
- memobj.dtcs_tx = memobj.dtcs
+ if self._rf.has_dtcs:
+ memobj.dtcs_polarity_tx = memobj.dtcs_polarity
+ memobj.dtcs_tx = memobj.dtcs
elif self._rf.valid_duplexes:
memobj.duplex = self._rf.valid_duplexes.index(mem.duplex)
+ if hasattr(memobj, "duplexOffset"):
+ memobj.duplexOffset = int(mem.offset) // 100
for setting in mem.extra:
if setting.get_name() == "filter":
@@ -535,7 +716,7 @@ class IcomCIVRadio(icf.IcomLiveRadio):
self._send_frame(f)
f = self._recv_frame()
- LOG.debug("Result:\n%s" % util.hexprint(f.get_data()))
+ LOG.debug("Result:\n%s" % util.hexprint(bytes(f.get_data())))
@directory.register
@@ -660,12 +841,162 @@ class Icom746Radio(IcomCIVRadio):
self._rf.valid_characters = chirp_common.CHARSET_ASCII
self._rf.memory_bounds = (1, 99)
-CIV_MODELS = {
- (0x76, 0xE0): Icom7200Radio,
- (0x88, 0xE0): Icom7100Radio,
- (0x70, 0xE0): Icom7000Radio,
- (0x46, 0xE0): Icom746Radio,
-}
+
+@directory.register
+class Icom910Radio(IcomCIVRadio):
+ """Icom IC-910"""
+ MODEL = "IC-910"
+ BAUD_RATE = 19200
+ _model = "\x60"
+ _template = 100
+
+ _num_banks = 3 # Banks for 2m, 70cm, 23cm
+ _bank_index_bounds = (1, 99)
+ _bank_class = icf.IcomBank
+
+ _SPECIAL_CHANNELS = {
+ "1A": 100,
+ "1b": 101,
+ "2A": 102,
+ "2b": 103,
+ "3A": 104,
+ "3b": 105,
+ "C": 106,
+ }
+ _SPECIAL_CHANNELS_REV = {v: k for k, v in _SPECIAL_CHANNELS.items()}
+
+ _SPECIAL_BANKS = {
+ "2m": 1,
+ "70cm": 2,
+ "23cm": 3,
+ }
+ _SPECIAL_BANKS_REV = {v: k for k, v in _SPECIAL_BANKS.items()}
+
+ def _get_special_names(self, band):
+ return sorted([band + "-" + key
+ for key in self._SPECIAL_CHANNELS.keys()])
+
+ def _is_special(self, number):
+ return isinstance(number, str) or number >= 1000
+
+ def _get_special_info(self, number):
+ info = BankSpecialChannel()
+ if isinstance(number, str):
+ info.name = number
+ (band_name, chan_name) = number.split("-")
+ info.bank = self._SPECIAL_BANKS[band_name]
+ info.channel = self._SPECIAL_CHANNELS[chan_name]
+ info.location = info.bank * 1000 + info.channel
+ else:
+ info.location = number
+ (info.bank, info.channel) = divmod(number, 1000)
+ band_name = self._SPECIAL_BANKS_REV[info.bank]
+ chan_name = self._SPECIAL_CHANNELS_REV[info.channel]
+ info.name = band_name + "-" + chan_name
+ return info
+
+ # The IC-910 has a bank of memories for each band. The 23cm band is only
+ # available when the optional UX-910 unit is installed, but there is no
+ # direct means of detecting its presence. Instead, attempt to access the
+ # first memory in the 23cm bank. If that's successful, the unit is there,
+ # and we can present all 3 banks to the user. Otherwise, the unit is not
+ # installed, so we present 2 banks to the user, for 2m and 70cm.
+ def _detect_23cm_unit(self):
+ if not self.pipe:
+ return True
+ f = IC910MemFrame()
+ f.set_location(1, 3) # First memory in 23cm bank
+ self._send_frame(f)
+ f.read(self.pipe)
+ if f._cmd == 0xFA: # Error code lands in command field
+ self._num_banks = 2
+ LOG.debug("UX-910 unit is %sinstalled" %
+ ("not " if self._num_banks == 2 else ""))
+ return self._num_banks == 3
+
+ def _initialize(self):
+ self._classes["mem"] = IC910MemFrame
+ self._has_23cm_unit = self._detect_23cm_unit()
+ self._rf.has_bank = True
+ self._rf.has_dtcs_polarity = False
+ self._rf.has_dtcs = False
+ self._rf.has_ctone = True
+ self._rf.has_offset = True
+ self._rf.has_name = False
+ self._rf.has_tuning_step = False
+ self._rf.valid_modes = ["LSB", "USB", "CW", "NCW", "FM", "NFM"]
+ self._rf.valid_tmodes = ["", "Tone", "TSQL"]
+ self._rf.valid_duplexes = ["", "-", "+"]
+ self._rf.valid_bands = [(136000000, 174000000),
+ (420000000, 480000000)]
+ self._rf.valid_tuning_steps = []
+ self._rf.valid_skips = []
+ self._rf.valid_special_chans = (self._get_special_names("2m") +
+ self._get_special_names("70cm"))
+ self._rf.memory_bounds = (1, 99 * self._num_banks)
+
+ if self._has_23cm_unit:
+ self._rf.valid_bands.append((1240000000, 1320000000))
+ self._rf.valid_special_chans += self._get_special_names("23cm")
+
+ # Combine mode and filter into unified mode
+ self._unified_modes = True
+
+ # Use Chirp locations starting with 1
+ self._adjust_bank_loc_start = True
+
+
+@directory.register
+class Icom7300Radio(IcomCIVRadio): # Added March, 2021 by Rick DeWitt
+ """Icom IC-7300"""
+ MODEL = "IC-7300"
+ _model = "\x94"
+ _template = 100 # Use P1 as blank template
+
+ _SPECIAL_CHANNELS = {
+ "P1": 100,
+ "P2": 101,
+ }
+ _SPECIAL_CHANNELS_REV = dict(zip(_SPECIAL_CHANNELS.values(),
+ _SPECIAL_CHANNELS.keys()))
+
+ def _is_special(self, number):
+ return number > 99 or isinstance(number, str)
+
+ def _get_special_info(self, number):
+ info = SpecialChannel()
+ if isinstance(number, str):
+ info.name = number
+ info.channel = self._SPECIAL_CHANNELS[number]
+ info.location = info.channel
+ else:
+ info.location = number
+ info.name = self._SPECIAL_CHANNELS_REV[number]
+ info.channel = info.location
+ return info
+
+ def _initialize(self):
+ self._classes["mem"] = IC7300MemFrame
+ self._rf.has_name = True
+ self._rf.has_dtcs = False
+ self._rf.has_dtcs_polarity = False
+ self._rf.has_bank = False
+ self._rf.has_tuning_step = False
+ self._rf.has_nostep_tuning = True
+ self._rf.can_odd_split = True
+ self._rf.memory_bounds = (1, 99)
+ self._rf.valid_modes = [
+ "LSB", "USB", "AM", "CW", "RTTY", "FM", "CWR", "RTTYR",
+ "Data+LSB", "Data+USB", "Data+AM", "N/A", "N/A", "Data+FM"
+ ]
+ self._rf.valid_tmodes = ["", "Tone", "TSQL"]
+ # self._rf.valid_duplexes = ["", "-", "+", "split"]
+ self._rf.valid_duplexes = [] # To prevent using memobj.duplex
+ self._rf.valid_bands = [(1800000, 70500000)]
+ self._rf.valid_skips = []
+ self._rf.valid_name_length = 10
+ self._rf.valid_characters = chirp_common.CHARSET_ASCII
+ self._rf.valid_special_chans = sorted(self._SPECIAL_CHANNELS.keys())
def probe_model(ser):
@@ -673,20 +1004,27 @@ def probe_model(ser):
f = Frame()
f.set_command(0x19, 0x00)
- for model, controller in CIV_MODELS.keys():
- f.send(model, controller, ser)
+ models = {}
+ for rclass in directory.DRV_TO_RADIO.values():
+ if issubclass(rclass, IcomCIVRadio):
+ models[rclass.MODEL] = rclass
+
+ for rclass in models.values():
+ model = ord(rclass._model)
+ f.send(model, 0xE0, ser)
try:
f.read(ser)
except errors.RadioError:
continue
if len(f.get_data()) == 1:
- model = ord(f.get_data()[0])
- return CIV_MODELS[(model, controller)]
+ md = f.get_data()[0]
+ if (md == model):
+ return rclass
if f.get_data():
LOG.debug("Got data, but not 1 byte:")
- LOG.debug(util.hexprint(f.get_data()))
+ LOG.debug(util.hexprint(bytes(f.get_data())))
raise errors.RadioError("Unknown response")
raise errors.RadioError("Unsupported model")
diff --git a/chirp/ui/memdetail.py b/chirp/ui/memdetail.py
index bee6083..6f34b7b 100644
--- a/chirp/ui/memdetail.py
+++ b/chirp/ui/memdetail.py
@@ -68,8 +68,10 @@ class ValueEditor:
if self._name.startswith("extra_"):
try:
- self._memory.extra[self._name.split("_", 1)[1]].value = newval
- except settings.InternalError as e:
+ extra_name = self._name.split("_", 1)[1]
+ LOG.debug('Setting extra %s=%r' % (extra_name, newval))
+ self._memory.extra[extra_name].value = newval
+ except settings.InternalError, e:
self._errfn(self._name, str(e))
return str(e)
else:
@@ -111,6 +113,22 @@ class StringEditor(ValueEditor):
self.update()
+class IntegerEditor(ValueEditor):
+ def _init(self, data):
+ self._widget = gtk.SpinButton()
+ adj = self._widget.get_adjustment()
+ adj.configure(data.get_value(),
+ data.get_min(), data.get_max(),
+ data.get_step(), 1, 0)
+ self._widget.connect('value-changed', self.changed)
+
+ def changed(self, _widget):
+ self.update()
+
+ def _get_value(self):
+ return int(self._widget.get_value())
+
+
class ChoiceEditor(ValueEditor):
def _init(self, data):
self._choice = miscwidgets.make_choice([str(x) for x in data],
@@ -288,6 +306,12 @@ class MemoryDetailEditor(gtk.Dialog):
self._add(table, row, name, editor,
setting.get_shortname())
self._set_doc(name, setting.__doc__)
+ elif isinstance(setting.value,
+ settings.RadioSettingValueInteger):
+ editor = IntegerEditor(self._features, self._memory,
+ _err, name, setting.value)
+ self._add(table, row, name, editor,
+ setting.get_shortname())
row += 1
self._order.append(name)
diff --git a/chirp/wxui/developer.py b/chirp/wxui/developer.py
index a4e5c70..fd6cf62 100644
--- a/chirp/wxui/developer.py
+++ b/chirp/wxui/developer.py
@@ -316,7 +316,8 @@ class ChirpRadioBrowser(common.ChirpEditor):
self._radio.MODEL),
self._radio._memobj, pd)
pd.Destroy()
- self._treebook.ExpandNode(0)
+ if self._treebook.GetPageCount():
+ self._treebook.ExpandNode(0)
def page_selected(self, event):
page = self._treebook.GetPage(event.GetSelection())
diff --git a/chirp/wxui/main.py b/chirp/wxui/main.py
index 0c179dc..b5dff0d 100644
--- a/chirp/wxui/main.py
+++ b/chirp/wxui/main.py
@@ -9,6 +9,7 @@ import wx.aui
import wx.lib.newevent
from chirp import directory
+from chirp import platform
from chirp.ui import config
from chirp.wxui import common
from chirp.wxui import clone
@@ -17,10 +18,16 @@ from chirp.wxui import memedit
from chirp.wxui import settingsedit
from chirp import CHIRP_VERSION
+from fnmatch import fnmatch
+
EditorSetChanged, EVT_EDITORSET_CHANGED = wx.lib.newevent.NewCommandEvent()
CONF = config.get()
LOG = logging.getLogger(__name__)
+EMPTY_MENU_LABEL = '(none)'
+KEEP_RECENT = 8
+OPEN_RECENT_MENU = None
+OPEN_STOCK_CONFIG_MENU = None
class ChirpEditorSet(wx.Panel):
def __init__(self, radio, filename, *a, **k):
@@ -139,6 +146,10 @@ class ChirpMain(wx.Frame):
self.SetSize(int(CONF.get('window_w', 'state') or 1024),
int(CONF.get('window_h', 'state') or 768))
+ d = CONF.get('last_dir', 'state')
+ if d and os.path.isdir(d):
+ platform.get_platform().set_last_dir(d)
+
self.SetMenuBar(self.make_menubar())
# Stock items look good on linux, terrible on others,
@@ -166,6 +177,7 @@ class ChirpMain(wx.Frame):
CSVRadio = directory.get_radio('Generic_CSV')
radio = CSVRadio(None)
+ self.adj_menu_open_recent(filename)
editorset = ChirpEditorSet(radio, filename, self._editors)
self.add_editorset(editorset, select=select)
@@ -185,6 +197,41 @@ class ChirpMain(wx.Frame):
open_item = file_menu.Append(wx.ID_OPEN)
self.Bind(wx.EVT_MENU, self._menu_open, open_item)
+ stock_dir = platform.get_platform().config_file("stock_configs")
+ sconfigs = []
+ if os.path.isdir(stock_dir):
+ for fn in os.listdir(stock_dir):
+ if fnmatch(fn, "*.csv"):
+ config, ext = os.path.splitext(fn)
+ sconfigs.append(config)
+ sconfigs.sort()
+ if len(sconfigs):
+ self.OPEN_STOCK_CONFIG_MENU = wx.Menu()
+ for fn in sconfigs:
+ submenu_item = self.OPEN_STOCK_CONFIG_MENU.Append(
+ wx.ID_ANY, fn)
+ self.Bind(wx.EVT_MENU,
+ self._menu_open_stock_config, submenu_item)
+ file_menu.AppendSubMenu(self.OPEN_STOCK_CONFIG_MENU,
+ "Open Stock Config")
+
+ self.OPEN_RECENT_MENU = wx.Menu()
+ i = 0
+ fn = CONF.get("recent%i" % i, "state")
+ while fn:
+ submenu_item = self.OPEN_RECENT_MENU.Append(wx.ID_ANY, fn)
+ self.Bind(wx.EVT_MENU, self._menu_open_recent, submenu_item)
+ i += 1
+ if i >= KEEP_RECENT:
+ break
+ fn = CONF.get("recent%i" % i, "state")
+ if self.OPEN_RECENT_MENU.GetMenuItemCount() <= 0:
+ submenu_item = self.OPEN_RECENT_MENU.Append(wx.ID_ANY,
+ EMPTY_MENU_LABEL)
+ submenu_item.Enable(False)
+ self.Bind(wx.EVT_MENU, self._menu_open_recent, submenu_item)
+ file_menu.AppendSubMenu(self.OPEN_RECENT_MENU, 'Open Recent')
+
save_item = file_menu.Append(wx.ID_SAVE)
self.Bind(wx.EVT_MENU, self._menu_save, save_item)
@@ -299,6 +346,53 @@ class ChirpMain(wx.Frame):
self.Bind(wx.EVT_MENU, self._menu_open, tbopen)
tb.Realize()
+ def adj_menu_open_recent(self, filename):
+ ### Don't add stock config files to the recent files list
+ stock_dir = platform.get_platform().config_file("stock_configs")
+ this_dir = os.path.dirname(filename)
+ if (stock_dir and os.path.exists(stock_dir) and
+ this_dir and os.path.samefile(stock_dir, this_dir)):
+ return
+
+ ### Travel the Open Recent menu looking for filename
+ found_mi = None
+ empty_mi = None
+ for i in range(0, self.OPEN_RECENT_MENU.GetMenuItemCount()):
+ menu_item = self.OPEN_RECENT_MENU.FindItemByPosition(i)
+ fn = menu_item.GetItemLabelText()
+ if fn == filename:
+ found_mi = menu_item
+ if fn == EMPTY_MENU_LABEL:
+ empty_mi = menu_item
+
+ ### Move filename to top of menu or add it to top if it wasn't found
+ if found_mi:
+ self.OPEN_RECENT_MENU.Remove(found_mi)
+ self.OPEN_RECENT_MENU.Prepend(found_mi)
+ else:
+ submenu_item = self.OPEN_RECENT_MENU.Prepend(wx.ID_ANY, filename)
+ self.Bind(wx.EVT_MENU, self._menu_open_recent, submenu_item)
+
+ ### Get rid of the place holder used in an empty menu
+ if empty_mi:
+ self.OPEN_RECENT_MENU.Delete(empty_mi)
+
+ ### Trim the menu length
+ if self.OPEN_RECENT_MENU.GetMenuItemCount() > KEEP_RECENT:
+ for i in range(self.OPEN_RECENT_MENU.GetMenuItemCount() - 1,
+ KEEP_RECENT - 1, -1):
+ extra_mi = self.OPEN_RECENT_MENU.FindItemByPosition(i)
+ self.OPEN_RECENT_MENU.Delete(extra_mi)
+
+ ### Travel the Open Recent menu and save file names to config.
+ for i in range(0, self.OPEN_RECENT_MENU.GetMenuItemCount()):
+ if i >= KEEP_RECENT:
+ break
+ menu_item = self.OPEN_RECENT_MENU.FindItemByPosition(i)
+ fn = menu_item.GetItemLabelText()
+ CONF.set("recent%i" % i, fn, "state")
+ config._CONFIG.save()
+
def _editor_page_changed(self, event):
self._editors.GetPage(event.GetSelection())
self._update_window_for_editor()
@@ -372,13 +466,31 @@ class ChirpMain(wx.Frame):
wildcard = '|'.join(['Chirp Image Files (*.img)|*.img',
'CSV Files (*.csv)|*.csv',
'All Files (*.*)|*.*'])
- with wx.FileDialog(self, 'Open a file', wildcard=wildcard,
+ with wx.FileDialog(self, 'Open a file',
+ platform.get_platform().get_last_dir(),
+ wildcard=wildcard,
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) as fd:
if fd.ShowModal() == wx.ID_CANCEL:
return
filename = fd.GetPath()
+ d = fd.GetDirectory()
+ platform.get_platform().set_last_dir(d)
+ CONF.set('last_dir', d, 'state')
+ config._CONFIG.save()
self.open_file(str(filename))
+ def _menu_open_stock_config(self, event):
+ stock_dir = platform.get_platform().config_file("stock_configs")
+ fn = self.OPEN_STOCK_CONFIG_MENU.FindItemById(event.GetId()).GetLabel()
+ fn += ".csv"
+ filename = os.path.join(stock_dir, fn)
+ self.open_file(filename)
+
+ def _menu_open_recent(self, event):
+ filename = self.OPEN_RECENT_MENU.FindItemById(
+ event.GetId()).GetItemLabelText()
+ self.open_file(filename)
+
def _menu_save_as(self, event):
eset = self.current_editorset
wildcard = 'CHIRP %(vendor)s %(model)s Files (*.%(ext)s)|*.%(ext)s' % {
@@ -394,6 +506,7 @@ class ChirpMain(wx.Frame):
return
filename = fd.GetPath()
eset.save(filename)
+ self.adj_menu_open_recent(filename)
self._update_editorset_title(eset)
def _menu_save(self, event):
diff --git a/chirp/wxui/memedit.py b/chirp/wxui/memedit.py
index 4eef1be..2a41ec6 100644
--- a/chirp/wxui/memedit.py
+++ b/chirp/wxui/memedit.py
@@ -404,6 +404,8 @@ class ChirpMemEdit(common.ChirpEditor):
def _memory_rclick(self, event):
menu = wx.Menu()
selected_rows = self._grid.GetSelectedRows()
+ if not selected_rows:
+ selected_rows = [event.GetRow()]
props_item = wx.MenuItem(menu, wx.NewId(), 'Properties')
self.Bind(wx.EVT_MENU,
@@ -547,6 +549,7 @@ class ChirpMemPropDialog(wx.Dialog):
for coldef in memedit._col_defs:
if coldef.valid:
self._pg.Append(coldef.get_propeditor(memory))
+ self._pg.FitColumns()
hbox = wx.BoxSizer(wx.HORIZONTAL)
hbox.Add(wx.Button(self, wx.ID_OK))
@@ -579,6 +582,7 @@ class ChirpMemPropDialog(wx.Dialog):
LOG.debug('Value for %s is %r' % (name, value))
setattr(mem, prop.GetName(), value)
+ mem.empty = False
if self._tabs.GetPageCount() == 2:
extra = self._tabs.GetPage(1).get_values()
diff --git a/chirpc b/chirpc
index 1663a05..a32cb9f 100755..100644
--- a/chirpc
+++ b/chirpc
@@ -44,29 +44,30 @@ def fail_missing_mmap():
class ToneAction(argparse.Action):
- def __call__(self, parser, namespace, value, option_string=None):
- if value in chirp_common.TONES:
- raise argparse.ArgumentError("Invalid tone valeu: %.1f" % value)
+ def __call__(self, parser, namespace, values, option_string=None):
+ value = values[0]
+ if value not in chirp_common.TONES:
+ raise argparse.ArgumentError(
+ self, "Invalid tone value: %.1f" % value)
setattr(namespace, self.dest, value)
class DTCSAction(argparse.Action):
- def __call__(self, parser, namespace, value, option_string=None):
- try:
- value = int(value, 10)
- except ValueError:
- raise argparse.ArgumentError("Invalid DTCS value: %s" % value)
-
+ def __call__(self, parser, namespace, values, option_string=None):
+ value = values[0]
if value not in chirp_common.DTCS_CODES:
- raise argparse.ArgumentError("Invalid DTCS value: %03i" % value)
+ raise argparse.ArgumentError(
+ self, "Invalid DTCS value: %03i" % value)
setattr(namespace, self.dest, value)
class DTCSPolarityAction(argparse.Action):
- def __call__(self, parser, namespace, value, option_string=None):
+ def __call__(self, parser, namespace, values, option_string=None):
+ value = values[0]
if value not in ["NN", "RN", "NR", "RR"]:
- raise optparse.OptionValueError("Invaid DTCS polarity: %s" % value)
- setattr(parser.values, option.dest, value)
+ raise argparse.ArgumentError(
+ self, "Invaid DTCS polarity: %s" % value)
+ setattr(namespace, self.dest, value)
def parse_memory_number(radio, args):
@@ -199,10 +200,9 @@ if __name__ == "__main__":
sys.exit(0)
if options.id:
- from chirp import icf
- s = serial.Serial(port=options.serial, baudrate=9600, timeout=0.5)
- md = icf.get_model_data(s)
- print("Model:\n%s" % util.hexprint(md))
+ from chirp import detect
+ md = detect.detect_icom_radio(options.serial)
+ print("Model:\n%s" % md.MODEL)
sys.exit(0)
if not options.radio:
diff --git a/tests/run_tests.py b/tests/run_tests.py
index e13fd8c..195f4c4 100755..100644
--- a/tests/run_tests.py
+++ b/tests/run_tests.py
@@ -1120,7 +1120,7 @@ class TestOutputHTML(TestOutput):
def prepare(self):
print("Writing to %s" % self._filename, end=' ')
sys.stdout.flush()
- self._out = file(self._filename, "w")
+ self._out = open(self._filename, "w")
s = """
<html>
<head>
@@ -1204,7 +1204,7 @@ class TestRunner:
def log(self, rclass, tc, e):
fn = "logs/%s_%s.log" % (directory.radio_class_id(rclass), tc)
- log = file(fn, "a")
+ log = open(fn, "a")
print("---- Begin test %s ----" % tc, file=log)
log.write(e.get_detail())
print(file=log)
@@ -1344,7 +1344,7 @@ Available tests:
stdout = sys.stdout
if not os.path.exists("logs"):
os.mkdir("logs")
- sys.stdout = file("logs/verbose", "w")
+ sys.stdout = open("logs/verbose", "w")
test_out = TestOutputANSI(stdout)
test_out.prepare()