summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Hibberd <hibby@debian.org>2024-04-13 21:27:52 +0100
committerDave Hibberd <hibby@debian.org>2024-04-13 21:27:52 +0100
commit0496ffac85e663ba4c9a14d2d4eb300a3c017ae2 (patch)
tree22850f3993686d89159885f516bfb4381ffc0906
parentfc438e6a84402e621877f6c30097442af46f122b (diff)
New upstream version 20240413upstream/20240413
-rw-r--r--PKG-INFO6
-rw-r--r--chirp.egg-info/PKG-INFO6
-rw-r--r--chirp.egg-info/SOURCES.txt4
-rw-r--r--chirp.egg-info/requires.txt4
-rw-r--r--chirp/__init__.py2
-rw-r--r--chirp/bandplan.py3
-rw-r--r--chirp/bitwise.py27
-rw-r--r--chirp/bitwise_grammar.py2
-rw-r--r--chirp/chirp_common.py120
-rw-r--r--chirp/drivers/__init__.py15
-rw-r--r--chirp/drivers/alinco_dr735t.py372
-rw-r--r--chirp/drivers/baofeng_uv17.py25
-rw-r--r--chirp/drivers/baofeng_uv17Pro.py31
-rw-r--r--chirp/drivers/baofeng_uv3r.py2
-rw-r--r--chirp/drivers/ft2900.py64
-rw-r--r--chirp/drivers/ft4.py44
-rw-r--r--chirp/drivers/ft450d.py8
-rw-r--r--chirp/drivers/ft70.py113
-rw-r--r--chirp/drivers/ft7100.py2
-rw-r--r--chirp/drivers/ft857.py2
-rw-r--r--chirp/drivers/ftlx011.py5
-rw-r--r--chirp/drivers/generic_csv.py1
-rw-r--r--chirp/drivers/ic2730.py5
-rw-r--r--chirp/drivers/icomciv.py98
-rw-r--r--chirp/drivers/idrp.py26
-rw-r--r--chirp/drivers/kenwood_d7.py7
-rw-r--r--chirp/drivers/mml_jc8810.py37
-rw-r--r--chirp/drivers/radioddity_r2.py10
-rw-r--r--chirp/drivers/radtel_rt490.py2
-rw-r--r--chirp/drivers/tdh8.py472
-rw-r--r--chirp/drivers/uv5x3.py52
-rw-r--r--chirp/drivers/uvk5.py10
-rw-r--r--chirp/drivers/vx8.py19
-rw-r--r--chirp/drivers/wouxun.py4
-rw-r--r--chirp/locale/es/LC_MESSAGES/CHIRP.mobin74488 -> 74948 bytes
-rw-r--r--chirp/locale/fr/LC_MESSAGES/CHIRP.mobin30539 -> 67489 bytes
-rw-r--r--chirp/locale/pl/LC_MESSAGES/CHIRP.mobin22928 -> 22922 bytes
-rw-r--r--chirp/locale/ru/LC_MESSAGES/CHIRP.mobin85384 -> 84607 bytes
-rw-r--r--chirp/locale/tr_TR/LC_MESSAGES/CHIRP.mobin67581 -> 71140 bytes
-rw-r--r--chirp/memmap.py10
-rw-r--r--chirp/platform.py6
-rw-r--r--chirp/pyPEG.py4
-rw-r--r--chirp/settings.py8
-rw-r--r--chirp/sources/radioreference.py20
-rw-r--r--chirp/sources/repeaterbook.py3
-rw-r--r--chirp/wxui/__init__.py84
-rw-r--r--chirp/wxui/clone.py25
-rw-r--r--chirp/wxui/common.py23
-rw-r--r--chirp/wxui/config.py5
-rw-r--r--chirp/wxui/developer.py12
-rw-r--r--chirp/wxui/main.py57
-rw-r--r--chirp/wxui/memedit.py12
-rw-r--r--chirp/wxui/report.py2
-rw-r--r--requirements.txt2
-rw-r--r--setup.py6
-rw-r--r--test-requirements.txt1
-rw-r--r--tests/Python3_Driver_Testing.md12
-rw-r--r--tests/__pycache__/base.cpython-310.pycbin5292 -> 5360 bytes
-rw-r--r--tests/__pycache__/test_brute_force.cpython-310-pytest-7.1.3.pycbin5055 -> 5396 bytes
-rw-r--r--tests/__pycache__/test_edges.cpython-310-pytest-7.1.3.pycbin7389 -> 7373 bytes
-rw-r--r--tests/base.py8
-rw-r--r--tests/images/Alinco_DR735T.imgbin0 -> 66093 bytes
-rw-r--r--tests/images/Baofeng_GM-5RH.imgbin0 -> 33845 bytes
-rw-r--r--tests/py3_driver_testers.txt3
-rw-r--r--tests/test_edges.py1
-rw-r--r--tests/unit/__pycache__/base.cpython-310.pycbin962 -> 1110 bytes
-rw-r--r--tests/unit/__pycache__/test_alinco_clone.cpython-310-pytest-7.1.3.pycbin4993 -> 6437 bytes
-rw-r--r--tests/unit/__pycache__/test_bitwise.cpython-310-pytest-7.1.3.pycbin15690 -> 17015 bytes
-rw-r--r--tests/unit/__pycache__/test_chirp_common.cpython-310-pytest-7.1.3.pycbin31358 -> 31375 bytes
-rw-r--r--tests/unit/__pycache__/test_wxui_radiothread.cpython-310-pytest-7.1.3.pycbin4770 -> 6529 bytes
-rw-r--r--tests/unit/base.py4
-rw-r--r--tests/unit/test_alinco_clone.py45
-rw-r--r--tests/unit/test_bitwise.py10
-rw-r--r--tests/unit/test_chirp_common.py1
-rw-r--r--tests/unit/test_wxui_radiothread.py72
-rw-r--r--tools/cpep8.manifest1
-rw-r--r--tools/experttune.py379
77 files changed, 1675 insertions, 741 deletions
diff --git a/PKG-INFO b/PKG-INFO
index 4c0022e..8fc2ec2 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,14 +1,12 @@
Metadata-Version: 2.1
Name: chirp
-Version: 20240224
+Version: 20240413
Summary: A cross-platform cross-radio programming tool
Home-page: https://chirp.danplanet.com
-Requires-Python: >=3.7,<4
+Requires-Python: >=3.10,<4
License-File: COPYING
Requires-Dist: pyserial
Requires-Dist: requests
-Requires-Dist: six
-Requires-Dist: importlib-resources; python_version < "3.10"
Requires-Dist: yattag
Provides-Extra: wx
Requires-Dist: wxPython; extra == "wx"
diff --git a/chirp.egg-info/PKG-INFO b/chirp.egg-info/PKG-INFO
index 4c0022e..8fc2ec2 100644
--- a/chirp.egg-info/PKG-INFO
+++ b/chirp.egg-info/PKG-INFO
@@ -1,14 +1,12 @@
Metadata-Version: 2.1
Name: chirp
-Version: 20240224
+Version: 20240413
Summary: A cross-platform cross-radio programming tool
Home-page: https://chirp.danplanet.com
-Requires-Python: >=3.7,<4
+Requires-Python: >=3.10,<4
License-File: COPYING
Requires-Dist: pyserial
Requires-Dist: requests
-Requires-Dist: six
-Requires-Dist: importlib-resources; python_version < "3.10"
Requires-Dist: yattag
Provides-Extra: wx
Requires-Dist: wxPython; extra == "wx"
diff --git a/chirp.egg-info/SOURCES.txt b/chirp.egg-info/SOURCES.txt
index 9599a98..a9496b2 100644
--- a/chirp.egg-info/SOURCES.txt
+++ b/chirp.egg-info/SOURCES.txt
@@ -35,6 +35,7 @@ chirp/cli/__init__.py
chirp/cli/main.py
chirp/drivers/__init__.py
chirp/drivers/alinco.py
+chirp/drivers/alinco_dr735t.py
chirp/drivers/anytone.py
chirp/drivers/anytone778uv.py
chirp/drivers/anytone_ht.py
@@ -299,6 +300,7 @@ tests/images/Alinco_DJ-G7EG.img
tests/images/Alinco_DJ175.img
tests/images/Alinco_DJ596.img
tests/images/Alinco_DR235T.img
+tests/images/Alinco_DR735T.img
tests/images/AnyTone_5888UV.img
tests/images/AnyTone_5888UVIII.img
tests/images/AnyTone_778UV.img
@@ -335,6 +337,7 @@ tests/images/Baofeng_BF-T20.img
tests/images/Baofeng_BF-T20FRS.img
tests/images/Baofeng_BF-T8.img
tests/images/Baofeng_F-11.img
+tests/images/Baofeng_GM-5RH.img
tests/images/Baofeng_UV-13Pro.img
tests/images/Baofeng_UV-17.img
tests/images/Baofeng_UV-17Pro.img
@@ -635,6 +638,7 @@ tools/cpep8.blacklist
tools/cpep8.exceptions
tools/cpep8.manifest
tools/cpep8.py
+tools/experttune.py
tools/fast-driver.py
tools/icomsio.sh
tools/py3_driver_progress.py
diff --git a/chirp.egg-info/requires.txt b/chirp.egg-info/requires.txt
index 1c9b3d4..c9ea9fd 100644
--- a/chirp.egg-info/requires.txt
+++ b/chirp.egg-info/requires.txt
@@ -1,10 +1,6 @@
pyserial
requests
-six
yattag
-[:python_version < "3.10"]
-importlib-resources
-
[wx]
wxPython
diff --git a/chirp/__init__.py b/chirp/__init__.py
index 5c8905b..12357cd 100644
--- a/chirp/__init__.py
+++ b/chirp/__init__.py
@@ -1 +1 @@
-CHIRP_VERSION = "next-20240224"
+CHIRP_VERSION = "next-20240413"
diff --git a/chirp/bandplan.py b/chirp/bandplan.py
index 6a38424..125b8de 100644
--- a/chirp/bandplan.py
+++ b/chirp/bandplan.py
@@ -175,7 +175,8 @@ class BandPlans(object):
for band in current_plan.bands:
if (band.limits[0] >= min_freq and
- band.name.lower().endswith('meter band')):
+ (band.name.lower().endswith('meter band') or
+ band.name.lower().endswith('cm band'))):
add_nodupes(band)
return sorted(bands_with_repeaters,
key=lambda b: b.limits[0])
diff --git a/chirp/bitwise.py b/chirp/bitwise.py
index 25e59d0..4cdbfad 100644
--- a/chirp/bitwise.py
+++ b/chirp/bitwise.py
@@ -18,6 +18,7 @@
# Example definitions:
#
# bit foo[8]; /* Eight single bit values */
+# lbit foo[16]; /* Sixteen single-bit values, little-endian*/
# u8 foo; /* Unsigned 8-bit value */
# u16 foo; /* Unsigned 16-bit value */
# ul16 foo; /* Unsigned 16-bit value (LE) */
@@ -63,7 +64,6 @@ import logging
import re
import warnings
-import six
from builtins import bytes
from chirp import bitwise_grammar
@@ -76,20 +76,6 @@ class ParseError(Exception):
pass
-def byte_to_int(b):
- if six.PY3 or isinstance(b, int):
- return b
- else:
- return ord(b)
-
-
-def int_to_byte(i):
- if six.PY3:
- return bytes([i])
- else:
- return chr(i)
-
-
def string_straight_encode(string):
"""str -> bytes"""
# So, there are a lot of py2-thinking chirp drivers that
@@ -106,7 +92,7 @@ def string_straight_encode(string):
# specific binary values in memory). Ideally we would have
# written all of chirp with bytes() for these values, but alas.
# We can get the intended string here by doing bytes([ord(char)]).
- return bytes(b''.join(int_to_byte(ord(b)) for b in string))
+ return bytes(b''.join(bytes([ord(b)]) for b in string))
def string_straight_decode(string):
@@ -124,7 +110,7 @@ def string_straight_decode(string):
# will detect '\xFF' properly.
# FIXMEPY3: Remove this and the hack below when drivers convert to
# bytestrings.
- return ''.join(chr(byte_to_int(b)) for b in string)
+ return ''.join(chr(b) for b in string)
def format_binary(nbits, value, pad=8):
@@ -952,13 +938,13 @@ class Processor:
return bytes
- def do_bitarray(self, i, count):
+ def do_bitarray(self, i, count, bigendian=True):
if count % 8 != 0:
raise ValueError("bit array must be divisible by 8.")
class bitDE(bitDataElement):
_nbits = 1
- _shift = 8 - i % 8
+ _shift = (8 - i % 8) if bigendian else (i % 8) + 1
return bitDE(self._data, self._offset)
@@ -991,6 +977,9 @@ class Processor:
if dtype == "bit":
gen = self.do_bitarray(i, count)
self._offset += int((i+1) % 8 == 0)
+ elif dtype == "lbit":
+ gen = self.do_bitarray(i, count, bigendian=False)
+ self._offset += int((i+1) % 8 == 0)
else:
gen = self._types[dtype](self._data, self._offset)
self._offset += (gen.size() // 8)
diff --git a/chirp/bitwise_grammar.py b/chirp/bitwise_grammar.py
index 969530e..934efa9 100644
--- a/chirp/bitwise_grammar.py
+++ b/chirp/bitwise_grammar.py
@@ -16,7 +16,7 @@
import re
from chirp.pyPEG import keyword, parse as pypeg_parse
-TYPES = ["bit", "u8", "u16", "ul16", "u24", "ul24", "u32", "ul32",
+TYPES = ["bit", "lbit", "u8", "u16", "ul16", "u24", "ul24", "u32", "ul32",
"i8", "i16", "il16", "i24", "il24", "i32", "il32", "char",
"lbcd", "bbcd"]
DIRECTIVES = ["seekto", "seek", "printoffset"]
diff --git a/chirp/chirp_common.py b/chirp/chirp_common.py
index 7272443..e8261cf 100644
--- a/chirp/chirp_common.py
+++ b/chirp/chirp_common.py
@@ -41,8 +41,9 @@ TONES = (
225.7, 229.1, 233.6, 241.8, 250.3, 254.1,
)
-OLD_TONES = tuple(set(TONES) - set([159.8, 165.5, 171.3, 177.3, 183.5, 189.9,
- 196.6, 199.5, 206.5, 229.1, 254.1]))
+OLD_TONES = tuple(x for x in sorted(
+ set(TONES) - set([159.8, 165.5, 171.3, 177.3, 183.5, 189.9,
+ 196.6, 199.5, 206.5, 229.1, 254.1])))
def VALIDTONE(v):
@@ -242,7 +243,7 @@ def parse_power(powerstr):
return AutoNamedPowerLevel(watts)
-def parse_freq(freqstr):
+def parse_freq(freqstr: str) -> int:
"""Parse a frequency string and return the value in integral Hz"""
freqstr = freqstr.strip()
if freqstr == "":
@@ -253,14 +254,14 @@ def parse_freq(freqstr):
return int(freqstr.split(" ")[0]) * 1000
if "." in freqstr:
- mhz, khz = freqstr.split(".")
- if mhz == "":
- mhz = 0
- khz = khz.ljust(6, "0")
- if len(khz) > 6:
- raise ValueError("Invalid kHz value: %s", khz)
- mhz = int(mhz) * 1000000
- khz = int(khz)
+ _mhz, _khz = freqstr.split(".")
+ if _mhz == "":
+ _mhz = "0"
+ _khz = _khz.ljust(6, "0")
+ if len(_khz) > 6:
+ raise ValueError("Invalid kHz value: %s", _khz)
+ mhz = int(_mhz) * 1000000
+ khz = int(_khz)
else:
mhz = int(freqstr) * 1000000
khz = 0
@@ -268,7 +269,7 @@ def parse_freq(freqstr):
return mhz + khz
-def format_freq(freq):
+def format_freq(freq: int) -> str:
"""Format a frequency given in Hz as a string"""
return "%i.%06i" % (freq / 1000000, freq % 1000000)
@@ -280,30 +281,30 @@ class ImmutableValueError(ValueError):
class Memory:
"""Base class for a single radio memory"""
- freq = 0
- number = 0
- extd_number = ""
- name = ""
- vfo = 0
- rtone = 88.5
- ctone = 88.5
- dtcs = 23
- rx_dtcs = 23
- tmode = ""
- cross_mode = "Tone->Tone"
- dtcs_polarity = "NN"
- skip = ""
- power = None
- duplex = ""
- offset = 600000
- mode = "FM"
- tuning_step = 5.0
-
- comment = ""
-
- empty = False
-
- immutable = []
+ freq: int = 0
+ number: int = 0
+ extd_number: str = ""
+ name: str = ""
+ vfo: int = 0
+ rtone: float = 88.5
+ ctone: float = 88.5
+ dtcs: int = 23
+ rx_dtcs: int = 23
+ tmode: str = ""
+ cross_mode: str = "Tone->Tone"
+ dtcs_polarity: str = "NN"
+ skip: str = ""
+ power: PowerLevel | None = None
+ duplex: str = ""
+ offset: int = 600000
+ mode: str = "FM"
+ tuning_step: float = 5.0
+
+ comment: str = ""
+
+ empty: bool = False
+
+ immutable: list[str] = []
# A RadioSettingGroup of additional settings supported by the radio,
# or an empty list if none
@@ -596,10 +597,10 @@ class Memory:
class DVMemory(Memory):
"""A Memory with D-STAR attributes"""
- dv_urcall = "CQCQCQ"
- dv_rpt1call = ""
- dv_rpt2call = ""
- dv_code = 0
+ dv_urcall: str = "CQCQCQ"
+ dv_rpt1call: str = ""
+ dv_rpt2call: str = ""
+ dv_code: int = 0
def __str__(self):
string = Memory.__str__(self)
@@ -1178,7 +1179,7 @@ class Radio(Alias):
WANTS_RTS = True
ALIASES = []
NEEDS_COMPAT_SERIAL = True
- FORMATS = []
+ FORMATS: list[str] = []
def status_fn(self, status):
"""Deliver @status to the UI"""
@@ -1188,25 +1189,25 @@ class Radio(Alias):
self.errors = []
self.pipe = pipe
- def get_features(self):
+ def get_features(self) -> RadioFeatures:
"""Return a RadioFeatures object for this radio"""
return RadioFeatures()
@classmethod
- def get_name(cls):
+ def get_name(cls) -> str:
"""Return a printable name for this radio"""
return "%s %s" % (cls.VENDOR, cls.MODEL)
@classmethod
- def get_prompts(cls):
+ def get_prompts(cls) -> RadioPrompts:
"""Return a set of strings for use in prompts"""
return RadioPrompts()
- def set_pipe(self, pipe):
+ def set_pipe(self, pipe) -> None:
"""Set the serial object to be used for communications"""
self.pipe = pipe
- def get_memory(self, number):
+ def get_memory(self, number: int | str) -> Memory:
"""Return a Memory object for the memory at location @number
Constructs and returns a generic Memory object for the given location
@@ -1218,12 +1219,15 @@ class Radio(Alias):
NB: No changes to the radio's memory should occur as a result of
calling get_memory().
"""
- pass
+ raise NotImplementedError()
- def erase_memory(self, number):
+ def erase_memory(self, number: int | str) -> None:
"""Erase memory at location @number"""
mem = Memory()
- mem.number = number
+ if isinstance(number, str):
+ mem.extd_number = number
+ else:
+ mem.number = number
mem.empty = True
self.set_memory(mem)
@@ -1231,7 +1235,7 @@ class Radio(Alias):
"""Get all the memories between @lo and @hi"""
pass
- def set_memory(self, memory):
+ def set_memory(self, memory: Memory) -> None:
"""Set the memory object @memory
This method should copy generic attributes from @memory to the
@@ -1242,7 +1246,7 @@ class Radio(Alias):
substitution will be made, or ValidationError if truly incompatible.
In the latter case, set_memory() will not be called.
"""
- pass
+ raise NotImplementedError()
def get_mapping_models(self):
"""Returns a list of MappingModel objects (or an empty list)"""
@@ -1253,11 +1257,11 @@ class Radio(Alias):
return [bank_model]
return []
- def get_raw_memory(self, number):
+ def get_raw_memory(self, number: int | str) -> str:
"""Return a raw string describing the memory at @number"""
- pass
+ return 'Memory<%r>' % number
- def filter_name(self, name):
+ def filter_name(self, name: str) -> str:
"""Filter @name to just the length and characters supported"""
rf = self.get_features()
if rf.valid_characters == rf.valid_characters.upper():
@@ -1266,12 +1270,12 @@ class Radio(Alias):
return "".join([x for x in name[:rf.valid_name_length]
if x in rf.valid_characters])
- def get_sub_devices(self):
+ def get_sub_devices(self) -> list[Alias]:
"""Return a list of sub-device Radio objects, if
RadioFeatures.has_sub_devices is True"""
return []
- def validate_memory(self, mem):
+ def validate_memory(self, mem: Memory) -> list[ValidationMessage]:
"""Return a list of warnings and errors that will be encountered
if trying to set @mem on the current radio"""
rf = self.get_features()
@@ -1294,7 +1298,7 @@ class Radio(Alias):
pass
@classmethod
- def supports_format(cls, fmt):
+ def supports_format(cls, fmt: str) -> bool:
"""Returns true if file format @fmt is supported by this radio.
This really should not be overridden by implementations
@@ -1302,7 +1306,7 @@ class Radio(Alias):
"""
return fmt in cls.FORMATS
- def check_set_memory_immutable_policy(self, existing, new):
+ def check_set_memory_immutable_policy(self, existing: Memory, new: Memory):
"""Checks whether or not a new memory will violate policy.
Some radios have complex requirements for which fields of which
diff --git a/chirp/drivers/__init__.py b/chirp/drivers/__init__.py
index 3dda0cd..12515fb 100644
--- a/chirp/drivers/__init__.py
+++ b/chirp/drivers/__init__.py
@@ -154,14 +154,15 @@ from chirp.drivers import vx8
from chirp.drivers import vxa700
from chirp.drivers import wouxun
from chirp.drivers import wouxun_common
-from chirp.drivers import kenwood_d7
from chirp.drivers import yaesu_clone
-from chirp.drivers import tdh8
from chirp.drivers import radtel_rt490
-from chirp.drivers import baofeng_uv17Pro
-from chirp.drivers import uvk5
-from chirp.drivers import baofeng_uv17
-from chirp.drivers import iradio_uv_5118plus
from chirp.drivers import mml_jc8810
+from chirp.drivers import alinco_dr735t
+from chirp.drivers import tdh8
+from chirp.drivers import iradio_uv_5118plus
from chirp.drivers import uvk5_egzumer
-__all__ = ['__init__', 'bj9900', 'anytone', 'anytone778uv', 'anytone_ht', 'anytone_iii', 'ap510', 'baofeng_common', 'baofeng_uv3r', 'baofeng_wp970i', 'bjuv55', 'boblov_x3plus', 'btech', 'fake', 'fd268', 'ft1500m', 'ft1802', 'ft1d', 'ft2900', 'ft2d', 'ft4', 'ft2800', 'ft450d', 'ft50', 'ft60', 'ft70', 'ft7100', 'ft7800', 'ft8100', 'ft817', 'ft818', 'ft857', 'ft90', 'ftlx011', 'ftm3200d', 'ftm350', 'ftm7250d', 'ga510', 'generic_csv', 'generic_tpe', 'gmrsuv1', 'gmrsv2', 'h777', 'hf90', 'bf_t1', 'ic208', 'hg_uv98', 'hobbypcb', 'ic2300', 'ic2100', 'ic2200', 'ic2720', 'ic2730', 'ic9x_icf', 'ic2820', 'ic9x', 'ic9x_ll', 'ic9x_icf_ll', 'icf', 'icomciv', 'icp7', 'ict8', 'icq7', 'ict70', 'ict7h', 'icv80', 'id31', 'icv86', 'icw32', 'icx8x', 'icx90', 'id5100', 'id51', 'id51plus', 'id880', 'id800', 'idrp', 'kg935g', 'iradio_uv_5118', 'kenwood_hmk', 'kenwood_itm', 'kenwood_live', 'kguv8d', 'kguv980p', 'kguv8dplus', 'kguv8e', 'kguv920pa', 'kguv9dplus', 'leixen', 'kyd', 'kyd_IP620', 'lt725uv', 'mursv1', 'alinco', 'puxing', 'puxing_px888k', 'radioddity_r2', 'radtel_t18', 'retevis_rb15', 'retevis_rb17p', 'retevis_rb28', 'retevis_rt1', 'retevis_rt21', 'retevis_rt22', 'retevis_rt23', 'retevis_rt26', 'retevis_rt76p', 'retevis_rt87', 'retevis_rt98', 'bf_t8', 'rh5r_v2', 'tdxone_tdq8a', 'template', 'tg_uv2p', 'th350', 'th7800', 'th9000', 'th9800', 'th_uv3r', 'th_uv3r25', 'th_uv8000', 'th_uv88', 'th_uvf8d', 'thd72', 'thd74', 'thuv1f', 'tk270', 'tk3140', 'tk760', 'tk760g', 'tk8102', 'tk8160', 'tk8180', 'tmd710', 'tmv71', 'tmv71_ll', 'ts2000', 'ts480', 'ts590', 'ts850', 'uv5r', 'uv5x3', 'uv6r', 'uvb5', 'vgc', 'vx170', 'vx2', 'vx3', 'vx5', 'vx510', 'vx6', 'vx7', 'vx8', 'vxa700', 'wouxun', 'wouxun_common', 'kenwood_d7', 'yaesu_clone', 'tdh8', 'radtel_rt490', 'baofeng_uv17Pro', 'uvk5', 'baofeng_uv17', 'iradio_uv_5118plus', 'mml_jc8810', 'uvk5_egzumer']
+from chirp.drivers import baofeng_uv17
+from chirp.drivers import baofeng_uv17Pro
+from chirp.drivers import kenwood_d7
+from chirp.drivers import uvk5
+__all__ = ['__init__', 'bj9900', 'anytone', 'anytone778uv', 'anytone_ht', 'anytone_iii', 'ap510', 'baofeng_common', 'baofeng_uv3r', 'baofeng_wp970i', 'bjuv55', 'boblov_x3plus', 'btech', 'fake', 'fd268', 'ft1500m', 'ft1802', 'ft1d', 'ft2900', 'ft2d', 'ft4', 'ft2800', 'ft450d', 'ft50', 'ft60', 'ft70', 'ft7100', 'ft7800', 'ft8100', 'ft817', 'ft818', 'ft857', 'ft90', 'ftlx011', 'ftm3200d', 'ftm350', 'ftm7250d', 'ga510', 'generic_csv', 'generic_tpe', 'gmrsuv1', 'gmrsv2', 'h777', 'hf90', 'bf_t1', 'ic208', 'hg_uv98', 'hobbypcb', 'ic2300', 'ic2100', 'ic2200', 'ic2720', 'ic2730', 'ic9x_icf', 'ic2820', 'ic9x', 'ic9x_ll', 'ic9x_icf_ll', 'icf', 'icomciv', 'icp7', 'ict8', 'icq7', 'ict70', 'ict7h', 'icv80', 'id31', 'icv86', 'icw32', 'icx8x', 'icx90', 'id5100', 'id51', 'id51plus', 'id880', 'id800', 'idrp', 'kg935g', 'iradio_uv_5118', 'kenwood_hmk', 'kenwood_itm', 'kenwood_live', 'kguv8d', 'kguv980p', 'kguv8dplus', 'kguv8e', 'kguv920pa', 'kguv9dplus', 'leixen', 'kyd', 'kyd_IP620', 'lt725uv', 'mursv1', 'alinco', 'puxing', 'puxing_px888k', 'radioddity_r2', 'radtel_t18', 'retevis_rb15', 'retevis_rb17p', 'retevis_rb28', 'retevis_rt1', 'retevis_rt21', 'retevis_rt22', 'retevis_rt23', 'retevis_rt26', 'retevis_rt76p', 'retevis_rt87', 'retevis_rt98', 'bf_t8', 'rh5r_v2', 'tdxone_tdq8a', 'template', 'tg_uv2p', 'th350', 'th7800', 'th9000', 'th9800', 'th_uv3r', 'th_uv3r25', 'th_uv8000', 'th_uv88', 'th_uvf8d', 'thd72', 'thd74', 'thuv1f', 'tk270', 'tk3140', 'tk760', 'tk760g', 'tk8102', 'tk8160', 'tk8180', 'tmd710', 'tmv71', 'tmv71_ll', 'ts2000', 'ts480', 'ts590', 'ts850', 'uv5r', 'uv5x3', 'uv6r', 'uvb5', 'vgc', 'vx170', 'vx2', 'vx3', 'vx5', 'vx510', 'vx6', 'vx7', 'vx8', 'vxa700', 'wouxun', 'wouxun_common', 'yaesu_clone', 'radtel_rt490', 'mml_jc8810', 'alinco_dr735t', 'tdh8', 'iradio_uv_5118plus', 'uvk5_egzumer', 'baofeng_uv17', 'baofeng_uv17Pro', 'kenwood_d7', 'uvk5']
diff --git a/chirp/drivers/alinco_dr735t.py b/chirp/drivers/alinco_dr735t.py
new file mode 100644
index 0000000..92817c5
--- /dev/null
+++ b/chirp/drivers/alinco_dr735t.py
@@ -0,0 +1,372 @@
+# Copyright 2024 Jacob Calvert <jcalvert@jacobncalvert.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+from chirp import chirp_common, bitwise, errors, memmap, directory
+from chirp.settings import RadioSettingGroup, RadioSetting
+from chirp.settings import RadioSettingValueBoolean, RadioSettingValueList
+from chirp.drivers.alinco import ALINCO_TONES, CHARSET
+from chirp import util
+
+import logging
+import codecs
+
+MEM_FORMAT = """
+struct {
+ u8 used;
+ u8 skip;
+ u8 favorite;
+ u8 unknown3;
+ ul32 frequency;
+ ul32 shift;
+ u8 shift_direction;
+ u8 subtone_selection;
+ u8 rx_tone_index;
+ u8 tx_tone_index;
+ u8 dcs_index;
+ u8 unknown17;
+ u8 power_index;
+ u8 busy_channel_lockout;
+ u8 mode;
+ u8 heterodyne_mode;
+ u8 unknown22;
+ u8 bell;
+ u8 name[6];
+ u8 dcs_off;
+ u8 unknown31;
+ u8 standby_screen_color;
+ u8 rx_screen_color;
+ u8 tx_screen_color;
+ u8 unknown35_to_63[29];
+} memory[1000];
+"""
+
+
+LOG = logging.getLogger(__name__)
+
+
+@directory.register
+class AlincoDR735T(chirp_common.CloneModeRadio):
+ """Base class for DR735T radio"""
+
+ """Alinco DR735T"""
+ VENDOR = "Alinco"
+ MODEL = "DR735T"
+ BAUD_RATE = 38400
+ NEEDS_COMPAT_SERIAL = False
+
+ TONE_MODE_MAP = {
+ 0x00: "",
+ 0x01: "Tone",
+ 0x03: "TSQL",
+ 0x0C: "DTCS"
+ }
+
+ SHIFT_DIR_MAP = ["", "-", "+"]
+
+ POWER_MAP = [
+ chirp_common.PowerLevel("High", watts=50.0),
+ chirp_common.PowerLevel("Mid", watts=25.00),
+ chirp_common.PowerLevel("Low", watts=5.00),
+ ]
+ MODE_MAP = {
+ 0x00: "FM",
+ 0x01: "NFM",
+ 0x02: "AM",
+ 0x03: "NAM",
+ 0x80: "Auto"
+ }
+
+ HET_MODE_MAP = ["Normal", "Reverse"]
+
+ SCREEN_COLOR_MAP = [f"Color {n+1}" for n in range(16)]
+
+ _freq_ranges = [
+ (108000000, 136000000),
+ (136000000, 174000000),
+ (400000000, 480000000)
+ ]
+ _no_channels = 1000
+
+ _model = b"DR735TN"
+
+ def get_features(self):
+ rf = chirp_common.RadioFeatures()
+ # convert to list to deal with dict_values unsubscriptable
+ rf.valid_tmodes = list(self.TONE_MODE_MAP.values())
+ rf.valid_modes = list(self.MODE_MAP.values())
+ rf.valid_skips = ["", "S"]
+ rf.valid_bands = self._freq_ranges
+ rf.memory_bounds = (0, self._no_channels-1)
+ rf.has_ctone = True
+ rf.has_bank = False
+ rf.has_dtcs_polarity = False
+ rf.valid_tuning_steps = [5.0]
+ rf.can_delete = False
+ rf.valid_name_length = 6
+ rf.valid_characters = chirp_common.CHARSET_UPPER_NUMERIC
+ rf.valid_power_levels = self.POWER_MAP
+ rf.valid_dtcs_codes = chirp_common.DTCS_CODES
+
+ return rf
+
+ def _identify(self) -> bool:
+ command = b"AL~WHO\r\n"
+ self.pipe.write(command)
+ self.pipe.read(len(command))
+ # expect DR735TN\r\n
+ radio_id = self.pipe.read(9).strip()
+ if not radio_id:
+ raise errors.RadioError("No response from radio")
+ LOG.debug('Model string is %s' % util.hexprint(radio_id))
+ return radio_id == b"DR735TN"
+
+ def do_download(self):
+ if not self._identify():
+ raise errors.RadioError("Unsupported radio model.")
+
+ channel_data = b""
+
+ for channel_no in range(0, self._no_channels):
+
+ command = f"AL~EEPEL{channel_no<<6 :04X}R\r\n".encode()
+ self.pipe.write(command)
+ self.pipe.read(len(command))
+ channel_spec = self.pipe.read(128) # 64 bytes, as hex
+ self.pipe.read(2) # \r\n
+ channel_spec = codecs.decode(channel_spec, "hex")
+ if len(channel_spec) != 64:
+ exit(1)
+ channel_data += channel_spec
+
+ if self.status_fn:
+ status = chirp_common.Status()
+ status.cur = channel_no
+ status.max = self._no_channels
+ status.msg = f"Downloading channel {channel_no} from radio"
+ self.status_fn(status)
+
+ return memmap.MemoryMapBytes(channel_data)
+
+ def do_upload(self):
+ if not self._identify():
+ raise errors.RadioError("Unsupported radio model.")
+
+ command = b"AL~DR735J\r\n"
+ self.pipe.write(command)
+ self.pipe.read(len(command))
+ resp = self.pipe.read(4)
+ if resp != b"OK\r\n":
+ errors.RadioError("Could not go into download mode.")
+
+ for channel_no in range(0, self._no_channels):
+ write_data = self.get_mmap()[channel_no*64:(channel_no+1)*64]
+ write_data = codecs.encode(write_data, 'hex').upper()
+ command = f"AL~EEPEL{channel_no<<6 :04X}W".encode(
+ ) + write_data + b"\r\n"
+ LOG.debug(f"COMM: {command}")
+ self.pipe.write(command)
+ back = self.pipe.read(len(command))
+ LOG.debug(f"BACK: {back}")
+ resp = self.pipe.read(4)
+ LOG.debug(f"RESP: {resp}")
+ if resp != b"OK\r\n":
+ raise errors.RadioError("failed to write to channel")
+
+ if self.status_fn:
+ status = chirp_common.Status()
+ status.cur = channel_no
+ status.max = self._no_channels
+ status.msg = f"Uploading channel {channel_no} to radio"
+ self.status_fn(status)
+
+ command = b"AL~RESET\r\n"
+ self.pipe.write(command)
+ self.pipe.read(len(command)) # command + OK\r\n
+ self.pipe.read(4)
+
+ def sync_in(self):
+ try:
+ self._mmap = self.do_download()
+ except Exception as exc:
+ raise errors.RadioError(f"Failed to download from radio: {exc}")
+ self.process_mmap()
+
+ def sync_out(self):
+ try:
+ self.do_upload()
+ except Exception as exc:
+ raise errors.RadioError(f"Failed to download from radio: {exc}")
+
+ def process_mmap(self):
+ self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
+
+ def get_raw_memory(self, number):
+ return repr(self._memobj.memory[number])
+
+ def get_memory(self, number):
+ _mem = self._memobj.memory[number]
+ mem = chirp_common.Memory()
+ mem.number = number # Set the memory number
+ mem.freq = int(_mem.frequency)
+ mem.name = "".join([CHARSET[_mem.name[i]] for i in range(6)]).strip()
+
+ mem.tmode = self.TONE_MODE_MAP[int(_mem.subtone_selection)]
+ mem.duplex = self.SHIFT_DIR_MAP[_mem.shift_direction]
+ mem.offset = _mem.shift
+
+ mem.rtone = ALINCO_TONES[_mem.rx_tone_index]
+ mem.ctone = ALINCO_TONES[_mem.tx_tone_index]
+ mem.dtcs = chirp_common.DTCS_CODES[_mem.dcs_index]
+ mem.power = self.POWER_MAP[_mem.power_index]
+ mem.skip = 'S' if bool(_mem.skip) else ''
+ mem.mode = self.MODE_MAP[int(_mem.mode)]
+
+ self._get_extra(_mem, mem)
+
+ if _mem.used == 0:
+ mem.empty = True
+ return mem
+
+ def set_memory(self, mem):
+ # Get a low-level memory object mapped to the image
+ _mem = self._memobj.memory[mem.number]
+
+ def find_key_in(d: dict, target_val):
+ for k, v in d.items():
+ if v == target_val:
+ return k
+
+ if not mem.empty:
+ mapped_name = [CHARSET.index(' ').to_bytes(1, 'little')]*6
+ for (i, c) in enumerate(mem.name.ljust(6)[:6].upper().strip()):
+ if c not in chirp_common.CHARSET_UPPER_NUMERIC:
+ c = " " # just make it a space
+ mapped_name[i] = CHARSET.index(c).to_bytes(1, 'little')
+ _mem.frequency = int(mem.freq)
+ _mem.name = b''.join(mapped_name)
+ _mem.mode = find_key_in(self.MODE_MAP, mem.mode)
+ _mem.subtone_selection = find_key_in(self.TONE_MODE_MAP, mem.tmode)
+ _mem.shift = mem.offset
+ _mem.used = 0x00 if mem.empty else 0x55
+ _mem.power_index = self.POWER_MAP.index(
+ mem.power) if mem.power in self.POWER_MAP else 0
+ _mem.skip = 0x01 if mem.skip == "S" else 0x00
+ try:
+ _mem.rx_tone_index = ALINCO_TONES.index(
+ mem.rtone)
+ except ValueError:
+ raise errors.UnsupportedToneError("This radio does "
+ "not support "
+ "tone %.1fHz" % mem.rtone)
+ try:
+
+ _mem.tx_tone_index = ALINCO_TONES.index(
+ mem.ctone)
+ except ValueError:
+ raise errors.UnsupportedToneError("This radio does "
+ "not support "
+ "tone %.1fHz" % mem.ctone)
+ _mem.dcs_index = chirp_common.DTCS_CODES.index(
+ mem.dtcs if mem.dtcs else chirp_common.DTCS_CODES[0])
+ _mem.shift_direction = self.SHIFT_DIR_MAP.index(
+ mem.duplex if mem.duplex else self.SHIFT_DIR_MAP[0])
+ else:
+ _mem.frequency = 0
+ _mem.name = b"\x00"*6
+ _mem.mode = find_key_in(self.MODE_MAP, "Auto")
+ _mem.subtone_selection = find_key_in(self.TONE_MODE_MAP, "")
+ _mem.shift = 0
+ _mem.used = 0x00 if mem.empty else 0x55
+ _mem.power_index = 0
+ _mem.skip = 0x01 if mem.skip == "S" else 0x00
+ _mem.rx_tone_index = 0
+ _mem.tx_tone_index = 0
+ _mem.dcs_index = 0
+ _mem.shift_direction = self.SHIFT_DIR_MAP.index("")
+
+ self._set_extra(_mem, mem)
+
+ def _get_extra(self, _mem, mem):
+ mem.extra = RadioSettingGroup("extra", "Extra")
+ het_mode = RadioSetting("heterodyne_mode", "Heterodyne Mode",
+ RadioSettingValueList(
+ self.HET_MODE_MAP,
+ current=self.HET_MODE_MAP[int(
+ _mem.heterodyne_mode)]
+ ))
+ het_mode.set_doc("Heterodyne Mode")
+
+ bcl = RadioSetting("bcl", "BCL",
+ RadioSettingValueBoolean(
+ bool(_mem.busy_channel_lockout)
+ ))
+ bcl.set_doc("Busy Channel Lockout")
+
+ stby_screen = RadioSetting("stby_screen", "Standby Screen Color",
+ RadioSettingValueList(
+ self.SCREEN_COLOR_MAP,
+ current=self.SCREEN_COLOR_MAP[int(
+ _mem.standby_screen_color)]
+ ))
+ stby_screen.set_doc("Standby Screen Color")
+
+ rx_screen = RadioSetting("rx_screen", "RX Screen Color",
+ RadioSettingValueList(
+ self.SCREEN_COLOR_MAP,
+ current=self.SCREEN_COLOR_MAP[int(
+ _mem.rx_screen_color)]
+ ))
+ rx_screen.set_doc("RX Screen Color")
+
+ tx_screen = RadioSetting("tx_screen", "TX Screen Color",
+ RadioSettingValueList(
+ self.SCREEN_COLOR_MAP,
+ current=self.SCREEN_COLOR_MAP[int(
+ _mem.tx_screen_color)]
+ ))
+ tx_screen.set_doc("TX Screen Color")
+
+ mem.extra.append(het_mode)
+ mem.extra.append(bcl)
+ mem.extra.append(stby_screen)
+ mem.extra.append(rx_screen)
+ mem.extra.append(tx_screen)
+
+ def _set_extra(self, _mem, mem):
+ for setting in mem.extra:
+ if setting.get_name() == "heterodyne_mode":
+ _mem.heterodyne_mode = \
+ self.HET_MODE_MAP.index(
+ setting.value) if \
+ setting.value else self.HET_MODE_MAP[0]
+
+ if setting.get_name() == "bcl":
+ _mem.busy_channel_lockout = \
+ 0x01 if setting.value else 0x00
+
+ if setting.get_name() == "stby_screen":
+ _mem.standby_screen_color = \
+ self.SCREEN_COLOR_MAP.index(setting.value) if \
+ setting.value else self.SCREEN_COLOR_MAP[0]
+
+ if setting.get_name() == "rx_screen":
+ _mem.rx_screen_color = \
+ self.SCREEN_COLOR_MAP.index(setting.value) if \
+ setting.value else self.SCREEN_COLOR_MAP[0]
+
+ if setting.get_name() == "tx_screen":
+ _mem.tx_screen_color = \
+ self.SCREEN_COLOR_MAP.index(setting.value) if \
+ setting.value else self.SCREEN_COLOR_MAP[0]
diff --git a/chirp/drivers/baofeng_uv17.py b/chirp/drivers/baofeng_uv17.py
index a9fe615..70f60c2 100644
--- a/chirp/drivers/baofeng_uv17.py
+++ b/chirp/drivers/baofeng_uv17.py
@@ -290,9 +290,15 @@ class UV17(baofeng_uv17Pro.UV17Pro):
} vfo;
#seekto 0x4000;
- struct {
+ struct channelname {
char name[11];
- } names[999];
+ };
+
+ struct channelname names1[372];
+ #seek 0x4;
+ struct channelname names2[372];
+ #seek 0x4;
+ struct channelname names3[255];
#seekto 0x8000;
struct {
@@ -408,9 +414,20 @@ class UV17(baofeng_uv17Pro.UV17Pro):
_mem = self._memobj.mem1.mem[number]
return _mem
+ def get_channel_name(self, number):
+ number = number - 1
+ if number >= 744:
+ _name = self._memobj.names3[number - 744]
+ return _name
+ if number >= 372:
+ _name = self._memobj.names2[number - 372]
+ return _name
+ _name = self._memobj.names1[number]
+ return _name
+
def get_memory(self, number):
_mem = self.get_raw_memory(number)
- _nam = self._memobj.names[number - 1]
+ _nam = self.get_channel_name(number)
mem = chirp_common.Memory()
mem.number = number
@@ -441,7 +458,7 @@ class UV17(baofeng_uv17Pro.UV17Pro):
def set_memory(self, mem):
_mem = self.get_raw_memory(mem.number)
- _nam = self._memobj.names[mem.number - 1]
+ _nam = self.get_channel_name(mem.number)
if mem.empty:
_mem.set_raw(b"\xff" * 16)
diff --git a/chirp/drivers/baofeng_uv17Pro.py b/chirp/drivers/baofeng_uv17Pro.py
index 41353b3..2113bac 100644
--- a/chirp/drivers/baofeng_uv17Pro.py
+++ b/chirp/drivers/baofeng_uv17Pro.py
@@ -21,7 +21,7 @@ from chirp import chirp_common, directory, memmap
from chirp import bitwise
from chirp.settings import RadioSetting, \
RadioSettingValueBoolean, RadioSettingValueList, \
- InvalidValueError, RadioSettingValueString, \
+ RadioSettingValueString, \
RadioSettings, RadioSettingGroup
import struct
from chirp import errors, util
@@ -31,6 +31,8 @@ LOG = logging.getLogger(__name__)
# Baofeng UV-17L magic string
MSTRING_UV17L = b"PROGRAMBFNORMALU"
MSTRING_UV17PROGPS = b"PROGRAMCOLORPROU"
+# Baofeng GM-5RH magic string
+MSTRING_GM5RH = b"PROGRAMBFGMRS05U"
DTMF_CHARS = "0123456789 *#ABCD"
STEPS = [2.5, 5.0, 6.25, 10.0, 12.5, 20.0, 25.0, 50.0]
@@ -782,10 +784,11 @@ class UV17Pro(bfc.BaofengCommonHT):
def my_validate(value):
value = chirp_common.parse_freq(value)
for band in self.VALID_BANDS:
- if value > band[0] and value < band[1]:
+ if value >= band[0] and value < band[1]:
return chirp_common.format_freq(value)
msg = ("{0} is not in a valid band.".format(value))
- raise InvalidValueError(msg)
+ LOG.debug(msg)
+ return chirp_common.format_freq(band[0]) # Default to valid value
def apply_freq(setting, obj):
value = chirp_common.parse_freq(str(setting.value)) / 10
@@ -1332,3 +1335,25 @@ class BF5RM(UV17Pro):
except ValueError:
pass
super().check_set_memory_immutable_policy(existing, new)
+
+
+@directory.register
+class BFK5Plus(BF5RM):
+ VENDOR = "Baofeng"
+ MODEL = "K5-Plus"
+
+
+@directory.register
+class GM5RH(UV17Pro):
+ VENDOR = "Baofeng"
+ MODEL = "GM-5RH"
+
+ VALID_BANDS = [UV17Pro._vhf_range, UV17Pro._vhf2_range, UV17Pro._uhf_range]
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=5.00),
+ chirp_common.PowerLevel("Low", watts=0.50),
+ chirp_common.PowerLevel("Medium", watts=3.00)]
+ SCODE_LIST = ["%s" % x for x in range(1, 16)]
+ LIST_PW_SAVEMODE = ["Off", "1:1", "2:1", "3:1", "4:1"]
+ _has_workmode_support = True
+
+ _magic = MSTRING_GM5RH
diff --git a/chirp/drivers/baofeng_uv3r.py b/chirp/drivers/baofeng_uv3r.py
index 39e9773..3120f5e 100644
--- a/chirp/drivers/baofeng_uv3r.py
+++ b/chirp/drivers/baofeng_uv3r.py
@@ -50,7 +50,7 @@ def uv3r_prep(radio):
for _i in range(0, 10):
try:
return _uv3r_prep(radio)
- except errors.RadioError:
+ except errors.RadioError as e:
time.sleep(1)
raise e
diff --git a/chirp/drivers/ft2900.py b/chirp/drivers/ft2900.py
index 1279317..1140155 100644
--- a/chirp/drivers/ft2900.py
+++ b/chirp/drivers/ft2900.py
@@ -189,7 +189,7 @@ struct {
u8 rf_sql;
u8 unk:6,
pag_abk:1,
- unk:1;
+ unk1:1;
u8 pag_cdr_1;
u8 pag_cdr_2;
u8 pag_cdt_1;
@@ -204,38 +204,38 @@ struct {
u8 xB3;
u8 resume;
u8 tot;
- u8 unk:1,
+ u8 unk2:1,
cw_id:1,
- unk:1,
+ unk3:1,
ts_speed:1,
ars:1,
- unk:2,
+ unk4:2,
dtmf_mode:1;
- u8 unk:1,
+ u8 unk5:1,
ts_mut:1,
wires_auto:1,
busy_lockout:1,
edge_beep:1,
- unk:3;
- u8 unk:2,
+ unk6:3;
+ u8 unk7:2,
s_search:1,
- unk:2,
+ unk8:2,
cw_trng_units:1,
- unk:2;
+ unk9:2;
u8 dtmf_speed:1,
- unk:2,
+ unk10:2,
arts_interval:1,
- unk:1,
+ unk11:1,
inverted_dcs:1,
- unk:1,
+ unk12:1,
mw_mode:1;
- u8 unk:2,
+ u8 unk13:2,
wires_mode:1,
wx_alert:1,
- unk:1,
+ unk14:1,
wx_vol_max:1,
revert:1,
- unk:1;
+ unk15:1;
u8 vfo_scan;
u8 scan_mode;
u8 dtmf_delay;
@@ -243,26 +243,21 @@ struct {
u8 xBF;
} settings;
-#seekto 0x00d0;
- u8 passwd[4];
- u8 mbs;
-
-#seekto 0x00c0;
+//#seekto 0x00c0;
struct {
u16 in_use;
} bank_used[8];
+//#seekto 0x00d0;
+ u8 passwd[4];
+ u8 mbs;
+
#seekto 0x00ef;
u8 currentTone;
-#seekto 0x00f0;
+//#seekto 0x00f0;
u8 curChannelMem[20];
-#seekto 0x1e0;
-struct {
- u8 dtmf_string[16];
-} dtmf_strings[10];
-
#seekto 0x0127;
u8 curChannelNum;
@@ -281,6 +276,11 @@ struct {
#seekto 0x1df;
u8 checksum2;
+//#seekto 0x1e0;
+struct {
+ u8 dtmf_string[16];
+} dtmf_strings[10];
+
#seekto 0x0360;
struct{
u8 name[6];
@@ -292,7 +292,7 @@ struct{
u16 channels[50];
} banks[8];
-#seekto 0x06e4;
+//#seekto 0x06e4;
struct {
u8 even_pskip:1,
even_skip:1,
@@ -302,9 +302,9 @@ struct {
odd_skip:1,
odd_valid:1,
odd_masked:1;
-} flags[225];
+} flags[128];
-#seekto 0x0764;
+//#seekto 0x0764;
struct {
u8 unknown0:2,
isnarrow:1,
@@ -394,7 +394,7 @@ def _encode_name(mem):
def _wipe_memory(mem):
- mem.set_raw(b"\xff" * (mem.size() // 8))
+ mem.fill_raw(b"\xff")
class FT2900Bank(chirp_common.NamedBank):
@@ -572,7 +572,7 @@ class FT2900Radio(YaesuCloneModeRadio):
mem.number = number
- if _mem.get_raw(asbytes=False)[0] == "\xFF" or not valid or not used:
+ if _mem.get_raw()[0] == 0xFF or not valid or not used:
mem.empty = True
return mem
@@ -711,7 +711,7 @@ class FT2900Radio(YaesuCloneModeRadio):
_mem.unknown5 = 0
LOG.debug("encoded mem\n%s\n" % (util.hexprint(
- _mem.get_raw(asbytes=False)[0:20])))
+ _mem.get_raw()[0:20])))
def get_settings(self):
_settings = self._memobj.settings
diff --git a/chirp/drivers/ft4.py b/chirp/drivers/ft4.py
index 418f358..6f08cfc 100644
--- a/chirp/drivers/ft4.py
+++ b/chirp/drivers/ft4.py
@@ -562,7 +562,7 @@ TONE_DICT = {} # encode sql_type.
CROSS_DICT = {} # encode sql_type.
for sql_type in reversed(range(0, len(RADIO_TMODES))):
- sql_type_row = RADIO_TMODES[sql_type]
+ sql_type_row: list = RADIO_TMODES[sql_type]
for decode_row in sql_type_row[0]:
suppress = None
if len(decode_row) == 3:
@@ -677,6 +677,7 @@ class YaesuSC35GenericRadio(chirp_common.CloneModeRadio,
BAUD_RATE = 9600
MAX_MEM_SLOT = 200
NEEDS_COMPAT_SERIAL = False
+ DUPLEX_OFF_VIA_OFFSET = False
# These settings are common to all radios in this family.
_valid_chars = chirp_common.CHARSET_ASCII
@@ -1149,12 +1150,34 @@ class YaesuSC35GenericRadio(chirp_common.CloneModeRadio,
mem.offset = txfreq
else:
mem.offset = int(_mem.offset) * 25000 * freq_offset_factor
+ if self.DUPLEX_OFF_VIA_OFFSET and mem.duplex in ['+', '-']:
+ band = self.band_for_freq(mem.freq)
+ if band is not None and self.DUPLEX_OFF_VIA_OFFSET[band]:
+ sign = 1 if mem.duplex == "+" else -1
+ tx = mem.freq + (sign * mem.offset)
+ if self.band_for_freq(tx) is None:
+ mem.duplex = "off"
+ mem.offset = 0
self.decode_sql(mem, _mem)
mem.power = POWER_LEVELS[2 - _mem.tx_pwr]
mem.mode = ["FM", "NFM"][_mem.tx_width]
mem.tuning_step = STEP_CODE[_mem.step]
return mem
+ def band_for_freq(self, freq):
+ """
+ We need to find the valid_bands list index a frequency falls
+ within, if any, to help determine if DUPLEX_OFF_VIA_OFFSET
+ logic is required
+ """
+ band_index = None
+ for i, limits in enumerate(self.valid_bands):
+ lo, hi = limits
+ if lo <= freq <= hi:
+ band_index = i
+ break
+ return band_index
+
def enforce_band(self, memloc, freq, mem_num, sname):
"""
vfo and home channels are each restricted to a particular band.
@@ -1189,20 +1212,26 @@ class YaesuSC35GenericRadio(chirp_common.CloneModeRadio,
_mem.tx_width = mem.mode == "NFM"
_mem.step = STEP_CODE.index(mem.tuning_step)
+ duplex = mem.duplex
+ offset = mem.offset
+ if self.DUPLEX_OFF_VIA_OFFSET and duplex == "off":
+ band = self.band_for_freq(mem.freq)
+ if band is not None and self.DUPLEX_OFF_VIA_OFFSET[band]:
+ duplex, offset = self.DUPLEX_OFF_VIA_OFFSET[band]
+
freq_offset_factor = self.freq_offset_factor
# FT-25R/65R Asia version (US version is 0)?
if self.subtype == 3 and freq_offset_factor == 2:
freq_offset_factor = 1 # 25000 scaler
- _mem.offset = mem.offset / (25000 * freq_offset_factor)
- duplex = mem.duplex
+ _mem.offset = offset / (25000 * freq_offset_factor)
if regtype in ["memory", "pms"]:
ndx = num - 1
store_bit(self._memobj.enable, ndx, True)
store_bit(self._memobj.scan, ndx, SKIPS.index(mem.skip))
nametrim = (mem.name + " ")[:8]
self._memobj.names[ndx].chrs = bytearray(nametrim, "ascii")
- if mem.duplex == "split":
- txfreq = mem.offset / 10
+ if duplex == "split":
+ txfreq = offset / 10
self._memobj.txfreqs[num-1].freq = txfreq
_mem.duplex = DUPLEX.index(duplex)
if regtype in ["vfo", "home"]:
@@ -1331,6 +1360,11 @@ class YaesuFT65RRadio(YaesuFT65GenericRadio):
DUPLEX_AUTO = DUPLEX_AUTO_US
legal_steps = STEP_CODE
BAND_ASSIGNMENTS = BAND_ASSIGNMENTS_DUALBAND
+ DUPLEX_OFF_VIA_OFFSET = [ # matches the order of valid_bands
+ None, # Don't modify broadcast FM memories
+ ("-", 99_950_000),
+ ("+", 99_950_000),
+ ]
@directory.register
diff --git a/chirp/drivers/ft450d.py b/chirp/drivers/ft450d.py
index e7e9dc1..d156884 100644
--- a/chirp/drivers/ft450d.py
+++ b/chirp/drivers/ft450d.py
@@ -239,7 +239,7 @@ class FT450DRadio(yaesu_clone.YaesuCloneModeRadio):
rty_sft:2,
rty_ton:1,
set2CC:1;
- u8 dig_vox; // 1:1
+ u8 dig_vox_dupe; // 1:1
u8 ext_mnu:1,
m_tune:1,
set2E:2,
@@ -313,7 +313,7 @@ class FT450DRadio(yaesu_clone.YaesuCloneModeRadio):
u8 set57;
} settings;
- #seekto 0x58;
+ //#seekto 0x58;
struct mem_struct vfoa[11]; // The current cfgs for each vfo 'band'
struct mem_struct vfob[11];
struct mem_struct home[2]; // The 2 Home cfgs (HF and 6m)
@@ -325,11 +325,11 @@ class FT450DRadio(yaesu_clone.YaesuCloneModeRadio):
u8 visible[63]; // 1 bit per channel
u8 pmsvisible; // @ 0x382
- #seekto 0x383;
+ //#seekto 0x383;
u8 filled[63];
u8 pmsfilled; // @ 0x3c2
- #seekto 0x3C3;
+ //#seekto 0x3C3;
struct mem_struct memory[500];
struct mem_struct pms[4]; // Programmed Scan limits @ x387F
diff --git a/chirp/drivers/ft70.py b/chirp/drivers/ft70.py
index bd49f1e..a244096 100644
--- a/chirp/drivers/ft70.py
+++ b/chirp/drivers/ft70.py
@@ -36,6 +36,16 @@ LOG = logging.getLogger(__name__)
# 47 RX.MOD Select the receive mode. Auto FM AM
MEM_SETTINGS_FORMAT = """
+ #seekto 0x047e;
+ struct {
+ u8 unknown1;
+ u8 flag;
+ u16 unknown2;
+ struct {
+ char padded_string[6]; // 36 OPN.MSG Select MSG then key vm to edit it
+ } message;
+ } opening_message; // 36 OPN.MSG Select the Opening Message when transceiver is ON. OFF/MSG/DC
+
// FT-70DE New Model #5329
//
@@ -96,22 +106,9 @@ MEM_SETTINGS_FORMAT = """
u8 unknown4:6,
gm_ring:2; // 24 GM RNG Select the beep option while receiving digital GM info. OFF/IN RNG/ALWAYS
u8 temp_cf; // Placeholder as not found
- u8 unknown5;
} first_settings;
- #seekto 0x04ed;
- struct {
- u8 unknown1:1,
- unknown2:1,
- unknown3:1,
- unknown4:1,
- unknown5:1,
- unknown6:1,
- unknown7:1,
- unknown8:1;
- } test_bit_field;
-
- #seekto 0x04c0;
+ //#seekto 0x04c0;
struct {
u8 unknown1:5,
beep_level:3; // 05 BEP.LVL Beep volume setting LEVEL1 - LEVEL4 - LEVEL7
@@ -125,7 +122,7 @@ MEM_SETTINGS_FORMAT = """
u8 dtmf_delay; // 18 DT DLY DTMF delay
u8 unknown0[3];
u8 unknown1:4,
- unknown1:4;
+ unknown1_2:4;
u8 lamp; // 28 LAMP Set the duration time of the backlight and keys to be lit
u8 lock; // 30 LOCK Configure the lock mode setting. KEY/DIAL/K+D/PTT/K+P/D+P/ALL
u8 unknown2_1;
@@ -146,7 +143,7 @@ MEM_SETTINGS_FORMAT = """
unknown8:1,
ars:1, // 45 RPT.ARS Turn the ARS function on/off.
dtmf_speed:1, // 20 DT SPD Set DTMF speed
- unknown8:1,
+ unknown8_1:1,
dtmf_mode:1; // DTMF Mode set from front panel
u8 busy_led:1, // Not Supported ?
unknown8_2:1,
@@ -190,11 +187,13 @@ MEM_SETTINGS_FORMAT = """
u8 unknown45;
u8 prog_key1; // P1 Set Mode Items to the Programmable Key
u8 prog_key2; // P2 Set Mode Items to the Programmable Key
- u8 unknown48;
- u8 unknown49;
- u8 unknown50;
} scan_settings;
+ #seekto 0x54a;
+ struct {
+ u16 in_use;
+ } bank_used[24];
+
#seekto 0x064b;
struct {
u8 unknown1:1,
@@ -213,43 +212,23 @@ MEM_SETTINGS_FORMAT = """
volume:5; // # VOL and Dial Adjust the volume level
} scan_settings_2;
- #seekto 0x0690; // Memory or VFO Settings Map?
- struct {
- u8 unknown[48]; // Array cannot be 64 elements!
- u8 unknown1[16]; // Exception: Not implemented for chirp.bitwise.structDataElement
- } vfo_info_1;
+ //#seekto 0x0690; // Memory or VFO Settings Map?
+ //struct {
+ //u8 unknown[48]; // Array cannot be 64 elements!
+ //u8 unknown1[16]; // Exception: Not implemented for chirp.bitwise.structDataElement
+ //} vfo_info_1;
- #seekto 0x0710; // Backup Memory or VFO Settings Map?
- struct {
- u8 unknown[48];
- u8 unknown1[16];
- } vfo_backup_info_1;
-
- #seekto 0x047e;
- struct {
- u8 unknown1;
- u8 flag;
- u16 unknown2;
- struct {
- char padded_string[6]; // 36 OPN.MSG Select MSG then key vm to edit it
- } message;
- } opening_message; // 36 OPN.MSG Select the Opening Message when transceiver is ON. OFF/MSG/DC
+ //#seekto 0x0710; // Backup Memory or VFO Settings Map?
+ //struct {
+ //u8 unknown[48];
+ //u8 unknown1[16];
+ //} vfo_backup_info_1;
#seekto 0x094a; // DTMF Memories
struct {
u8 memory[16];
} dtmf[10];
- #seekto 0x154a;
- struct {
- u16 channel[100];
- } bank_members[24];
-
- #seekto 0x54a;
- struct {
- u16 in_use;
- } bank_used[24];
-
#seekto 0x0EFE;
struct {
u8 unknown[2];
@@ -257,6 +236,13 @@ MEM_SETTINGS_FORMAT = """
u8 unknown1[10];
} bank_info[24];
+ #seekto 0x154a;
+ struct {
+ u16 channel[100];
+ } bank_members[24];
+"""
+
+MEM_SETTINGS_FORMAT_HI = """
#seekto 0xCF30;
struct {
u8 unknown0;
@@ -292,6 +278,16 @@ MEM_SETTINGS_FORMAT = """
"""
MEM_FORMAT = """
+ //#seekto 0x280A;
+ struct {
+ u8 nosubvfo:1,
+ unknown:3,
+ pskip:1, // PSkip (Select?)
+ skip:1, // Skip memory during scan
+ used:1, // Memory used
+ valid:1; // Always 1?
+ } flag[%d];
+
#seekto 0x2D4A;
struct { // 32 Bytes per memory entry
u8 display_tag:1, // 0 Display Freq, 1 Display Name
@@ -328,16 +324,6 @@ MEM_FORMAT = """
bell:1;
} memory[%d]; // DN, VW, FM, AM
// AMS DN, AMS VW, AMS FM
-
- #seekto 0x280A;
- struct {
- u8 nosubvfo:1,
- unknown:3,
- pskip:1, // PSkip (Select?)
- skip:1, // Skip memory during scan
- used:1, // Memory used
- valid:1; // Always 1?
- } flag[%d];
"""
MEM_CALLSIGN_FORMAT = """
@@ -560,15 +546,16 @@ class FT70Radio(yaesu_clone.YaesuCloneModeRadio):
"2. Connect cable to DATA terminal.\n"
"3. Unclip battery.\n"
"4. Press and hold in the [AMS] key and power key while clipping"
- " \n in back battery the"
+ " \n in back battery the "
"(\"ADMS\" will appear on the display).\n"
- "5. Press the [MODE] key (\"-WAIT-\" will appear on the LCD)."
- " OK</b>\n click <b>Then")
+ "5. Press the [MODE] key (\"-WAIT-\" will appear on the LCD).\n"
+ "<b>Then click OK</b>")
return rp
def process_mmap(self):
- mem_format = MEM_SETTINGS_FORMAT + MEM_FORMAT + MEM_CALLSIGN_FORMAT + MEM_CHECKSUM_FORMAT
+ mem_format = (MEM_SETTINGS_FORMAT + MEM_FORMAT + MEM_CALLSIGN_FORMAT +
+ MEM_SETTINGS_FORMAT_HI + MEM_CHECKSUM_FORMAT)
self._memobj = bitwise.parse(mem_format % self._mem_params, self._mmap)
diff --git a/chirp/drivers/ft7100.py b/chirp/drivers/ft7100.py
index 7c6f67c..286e4d4 100644
--- a/chirp/drivers/ft7100.py
+++ b/chirp/drivers/ft7100.py
@@ -301,7 +301,7 @@ struct
#seekto 0xc7;
u8 opt_03_arts_mode_uhf_1_2;
#seekto 0xa3;
- u8 opt_03_arts_mode_vhf_2_2;
+ u8 opt_03_arts_mode_uhf_2_2;
#seekto 0x8a;
u8 opt_04_beep_1_2;
diff --git a/chirp/drivers/ft857.py b/chirp/drivers/ft857.py
index 24a2b57..57acf9b 100644
--- a/chirp/drivers/ft857.py
+++ b/chirp/drivers/ft857.py
@@ -34,7 +34,7 @@ class FT857Radio(ft817.FT817Radio):
MODEL = "FT-857/897"
_model = ""
- TMODES = {
+ TMODES: dict[int, str] = {
0x04: "Tone",
0x05: "TSQL",
# 0x08 : "DTCS Enc", not supported in UI yet
diff --git a/chirp/drivers/ftlx011.py b/chirp/drivers/ftlx011.py
index 30c48ac..2c14f31 100644
--- a/chirp/drivers/ftlx011.py
+++ b/chirp/drivers/ftlx011.py
@@ -35,7 +35,6 @@ LOG = logging.getLogger(__name__)
MEM_FORMAT = """
-#seekto 0x000;
u8 rid; // Radio Identification
struct {
@@ -55,7 +54,7 @@ u8 tot:4, // Time out timer: 16 values (0.0-7.5 in 0.5s step)
tot_resume:2, // Time out timer resume: 3, 2, 1, 0 => 0s, 6s, 20s, 60s
unknownB:2;
u8 a_key:2, // A key function: resume: 0-3: Talkaround, High/Low, Call, Accessory
- unknownB:6;
+ unknownC:6;
u8 pch1; // Priority channel 1
u8 pch2; // Priority channel 1
} settings;
@@ -80,7 +79,7 @@ struct {
u8 unknownA[2];
} memory[24];
-#seekto 0x0190;
+//#seekto 0x0190;
char filename[11];
#seekto 0x19C;
diff --git a/chirp/drivers/generic_csv.py b/chirp/drivers/generic_csv.py
index 6744b80..9cec32e 100644
--- a/chirp/drivers/generic_csv.py
+++ b/chirp/drivers/generic_csv.py
@@ -243,7 +243,6 @@ class CSVRadio(chirp_common.FileBackedRadio):
good += 1
if not good:
- LOG.error(self.errors)
raise errors.InvalidDataError("No channels found")
def save(self, filename=None):
diff --git a/chirp/drivers/ic2730.py b/chirp/drivers/ic2730.py
index 876cb7c..ad104d7 100644
--- a/chirp/drivers/ic2730.py
+++ b/chirp/drivers/ic2730.py
@@ -18,6 +18,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import logging
+import typing
+
from chirp.drivers import icf
from chirp import chirp_common, directory, bitwise
from chirp.settings import RadioSettingGroup, RadioSetting, \
@@ -285,7 +287,7 @@ class IC2730Radio(icf.IcomCloneModeRadio):
_raw_frames = True
_highbit_flip = True
- _icf_data = {
+ _icf_data: dict[str, typing.Any] = {
'MapRev': 1,
'EtcData': 0, # This might be wrong
'Comment': '',
@@ -1316,7 +1318,6 @@ class IC2730Radio(icf.IcomCloneModeRadio):
def set_settings(self, settings):
_settings = self._memobj.settings
- _mem = self._memobj
for element in settings:
if not isinstance(element, RadioSetting):
self.set_settings(element)
diff --git a/chirp/drivers/icomciv.py b/chirp/drivers/icomciv.py
index 3135963..abfd974 100644
--- a/chirp/drivers/icomciv.py
+++ b/chirp/drivers/icomciv.py
@@ -142,6 +142,40 @@ bbcd ctone_tx[2]; // 15-17 tone rx squelch setting
char name[10]; // 18-27 Callsign
"""
+MEM_IC7400_FORMAT = """
+bbcd number[2];
+u8 unknown1;
+lbcd freq[5];
+u8 mode;
+u8 filter;
+u8 unknown2:7,
+ dig:1;
+u8 unknown3:2,
+ duplex:2,
+ unknown4:1,
+ tmode:3;
+bbcd rtone[3];
+bbcd ctone[3];
+u8 dtcs_polarity;
+bbcd dtcs[2];
+// As with IC-7300 it seems the following are duplicated parameters save for
+// `dig` which seem to be zeroed in unknown5
+lbcd freq_tx[5];
+u8 mode_tx;
+u8 filter_tx;
+u8 unknown5;
+u8 unknown6:2,
+ duplex_tx:2,
+ unknown7:1,
+ tmode_tx:3;
+bbcd rtone_tx[3];
+bbcd ctone_tx[3];
+u8 dtcs_polarity_tx;
+bbcd dtcs_tx[2];
+// End TX duplicate block
+char name[8];
+"""
+
MEM_IC7610_FORMAT = """
bbcd number[2]; // 1,2
u8 spl:4, // 3 split and select memory settings
@@ -169,7 +203,7 @@ class Frame:
def __init__(self):
self._data = b""
- def set_command(self, cmd, sub):
+ def set_command(self, cmd, sub=None):
"""Set the command number (and optional subcommand)"""
self._cmd = cmd
self._sub = sub
@@ -184,7 +218,10 @@ class Frame:
def send(self, src, dst, serial, willecho=True):
"""Send the frame over @serial, using @src and @dst addresses"""
- hdr = struct.pack("BBBBBB", 0xFE, 0xFE, src, dst, self._cmd, self._sub)
+ hdr = struct.pack("BBBBB", 0xFE, 0xFE, src, dst, self._cmd)
+ # Some commands have no subcommand
+ if self._sub is not None:
+ hdr += bytes([self._sub])
raw = bytearray(hdr)
if isinstance(self._data, MemoryMapBytes):
data = self._data.get_packed()
@@ -221,8 +258,14 @@ class Frame:
LOG.debug("%02x <- %02x:\n%s" % (dst, src, util.hexprint(bytes(data))))
self._cmd = data[4]
- self._sub = data[5]
- self._data = data[6:-1]
+ # If we've been set with a None subcommand, assume we don't expect
+ # it from the radio
+ if self._sub is None:
+ dataidx = 5
+ else:
+ self._sub = data[5]
+ dataidx = 6
+ self._data = data[dataidx:-1]
return src, dst
@@ -299,6 +342,12 @@ class DupToneMemFrame(MemFrame):
return bitwise.parse(mem_duptone_format, self._data)
+class IC7400MemFrame(MemFrame):
+ def get_obj(self):
+ self._data = MemoryMapBytes(bytes(self._data))
+ return bitwise.parse(MEM_IC7400_FORMAT, self._data)
+
+
class IC7300MemFrame(MemFrame):
FORMAT = MEM_IC7300_FORMAT
@@ -346,7 +395,7 @@ class IcomCIVRadio(icf.IcomLiveRadio):
# each radio supports a subset
# WARNING: "S-AM" and "PSK" are not valid (yet) for chirp
_MODES = [
- "LSB", "USB", "AM", "CW", "RTTY", "FM", "WFM", "CWR"
+ "LSB", "USB", "AM", "CW", "RTTY", "FM", "WFM", "CWR",
"RTTYR", "S-AM", "PSK", None, None, None, None, None,
None, None, None, None, None, None, None, None,
"DV",
@@ -411,7 +460,6 @@ class IcomCIVRadio(icf.IcomLiveRadio):
LOG.debug("Interface echo: %s" % self._willecho)
try:
f = self._get_template_memory()
- print('Chew: %i' % len(self.pipe.read(128)))
LOG.info('Detected %i baud' % baud)
break
except errors.RadioError:
@@ -901,6 +949,44 @@ class Icom746Radio(IcomCIVRadio):
@directory.register
+class Icom7400Radio(IcomCIVRadio):
+ """Icom IC-7400"""
+ MODEL = "IC-7400"
+ BAUD_RATE = 9600
+ _model = "\x66"
+ _template = 102
+
+ _num_banks = 1 # Banks not supported
+
+ def _initialize(self):
+ self._classes["mem"] = IC7400MemFrame
+ self._rf.has_bank = False
+ self._rf.has_dtcs_polarity = True
+ self._rf.has_dtcs = True
+ self._rf.has_ctone = True
+ self._rf.has_offset = False
+ self._rf.has_name = True
+ self._rf.has_tuning_step = False
+ self._rf.valid_modes = [
+ "LSB", "USB", "AM", "CW", "RTTY", "FM", "USB", "CWR", "RTTYR"
+ ]
+ self._rf.valid_tmodes = ["", "Tone", "TSQL", "DTCS"]
+ self._rf.valid_duplexes = ["", "-", "+"]
+ self._rf.valid_bands = [(30000, 174000000)]
+ self._rf.valid_tuning_steps = []
+ self._rf.valid_skips = []
+ self._rf.valid_name_length = 8
+ self._rf.valid_characters = " !#$%&'()*+,-./" \
+ "0123456789" \
+ ":;<=>?" \
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
+ "[\\]^_" \
+ "abcdefghijklmnopqrstuvwxyz" \
+ "{|}~"
+ self._rf.memory_bounds = (1, 99)
+
+
+@directory.register
class Icom910Radio(IcomCIVRadio):
"""Icom IC-910"""
MODEL = "IC-910"
diff --git a/chirp/drivers/idrp.py b/chirp/drivers/idrp.py
index 60680eb..1c02417 100644
--- a/chirp/drivers/idrp.py
+++ b/chirp/drivers/idrp.py
@@ -25,12 +25,12 @@ def parse_frames(buf):
"""Parse frames from the radio"""
frames = []
- while "\xfe\xfe" in buf:
+ while b"\xfe\xfe" in buf:
try:
- start = buf.index("\xfe\xfe")
- end = buf[start:].index("\xfd") + start + 1
+ start = buf.index(b"\xfe\xfe")
+ end = buf[start:].index(b"\xfd") + start + 1
except Exception:
- LOG.error("Unable to parse frames")
+ LOG.error("Unable to parse frames (buffer %i)", len(buf))
break
frames.append(buf[start:end])
@@ -41,10 +41,10 @@ def parse_frames(buf):
def send(pipe, buf):
"""Send data in @buf to @pipe"""
- pipe.write("\xfe\xfe%s\xfd" % buf)
+ pipe.write(b"\xfe\xfe%s\xfd" % buf)
pipe.flush()
- data = ""
+ data = b""
while True:
buf = pipe.read(4096)
if not buf:
@@ -53,12 +53,14 @@ def send(pipe, buf):
data += buf
LOG.debug("Got: \n%s" % util.hexprint(buf))
+ LOG.debug('Sent %i bytes, received %i', len(buf), len(data))
return parse_frames(data)
def send_magic(pipe):
"""Send the magic wakeup call to @pipe"""
- send(pipe, ("\xfe" * 15) + "\x01\x7f\x19")
+ LOG.debug('Sending magic wakeup')
+ send(pipe, (b"\xfe" * 15) + b"\x01\x7f\x19")
def drain(pipe):
@@ -72,14 +74,14 @@ def drain(pipe):
def set_freq(pipe, freq):
"""Set the frequency of the radio on @pipe to @freq"""
freqbcd = util.bcd_encode(freq, bigendian=False, width=9)
- buf = "\x01\x7f\x05" + freqbcd
+ buf = b"\x01\x7f\x05" + freqbcd
drain(pipe)
send_magic(pipe)
resp = send(pipe, buf)
for frame in resp:
if len(frame) == 6:
- if frame[4] == "\xfb":
+ if frame[4] == b"\xfb":
return True
raise errors.InvalidDataError("Repeater reported error")
@@ -87,14 +89,14 @@ def set_freq(pipe, freq):
def get_freq(pipe):
"""Get the frequency of the radio attached to @pipe"""
- buf = "\x01\x7f\x1a\x09"
+ buf = b"\x01\x7f\x1a\x09"
drain(pipe)
send_magic(pipe)
resp = send(pipe, buf)
for frame in resp:
- if frame[4] == "\x03":
+ if frame[4] == b"\x03":
els = frame[5:10]
freq = int("%02x%02x%02x%02x%02x" % (ord(els[4]),
@@ -104,6 +106,8 @@ def get_freq(pipe):
ord(els[0])))
LOG.debug("Freq: %f" % freq)
return freq
+ else:
+ LOG.debug('Unhandled frame type %i', frame[4])
raise errors.InvalidDataError("No frequency frame received")
diff --git a/chirp/drivers/kenwood_d7.py b/chirp/drivers/kenwood_d7.py
index 7ab8079..83665c2 100644
--- a/chirp/drivers/kenwood_d7.py
+++ b/chirp/drivers/kenwood_d7.py
@@ -1985,7 +1985,9 @@ class THD7GRadio(KenwoodD7Family):
"DSPA": {'type': 'list',
'values': ("Entire Display", "One Line")},
"ICO": {'type': 'map',
- 'map': (KenwoodD7Family._COMMON_SETTINGS["ICO"]["map"] +
+ 'map': (
+ KenwoodD7Family.
+ _COMMON_SETTINGS["ICO"]["map"] + # type: ignore
_APRS_EXTRA)}}
_SETTINGS_MENUS = (
@@ -2125,7 +2127,8 @@ class TMD700Radio(KenwoodD7Family):
"FUNC": {'type': 'map',
'map': (("Mode 1", "1"), ("Mode 2", "2"), ("Mode 3", "3"))},
"ICO": {'type': 'map',
- 'map': (KenwoodD7Family._COMMON_SETTINGS["ICO"]["map"] +
+ 'map': (KenwoodD7Family.
+ _COMMON_SETTINGS["ICO"]["map"] + # type: ignore
(('Digipeater', '0,F'),) +
THD7GRadio._APRS_EXTRA)},
"MCL 0": _BOOL,
diff --git a/chirp/drivers/mml_jc8810.py b/chirp/drivers/mml_jc8810.py
index 8dd62ba..65ee537 100644
--- a/chirp/drivers/mml_jc8810.py
+++ b/chirp/drivers/mml_jc8810.py
@@ -131,7 +131,7 @@ struct {
u8 unused_9022:7, // 9022
tailcode:1; // Tail Code (RT-470L)
u8 unknown_9023; // 9023
- u8 unknown_9024; // 9024
+ u8 unlock_sw_ch; // 9024 UNLOCK SW CH (A36plus 8w)
u8 unknown_9025; // 9025
u8 unknown_9026; // 9026
u8 unknown_9027; // 9027
@@ -148,6 +148,18 @@ struct {
// TAIL PHASE (A36plus)
u8 skey3_lp; // 9030 Skey3 Long (RT-470L)
// RX END TAIL (A36plus)
+ u8 unknown_9031; // 9031
+ u8 unknown_9032; // 9032
+ u8 unknown_9033; // 9033
+ u8 unknown_9034; // 9034
+ u8 unknown_9035; // 9035
+ u8 unknown_9036; // 9036
+ u8 unknown_9037; // 9037
+ u8 unknown_9038; // 9038
+ u8 unknown_9039; // 9039
+ u8 unknown_903a; // 903a
+ u8 single_mode; // 903b SINGLE MODE (A36plus 8w)
+ u8 dis_s_table; // 903b DIS S TABLE (A36plus 8w)
} settings;
#seekto 0xA006;
@@ -1174,6 +1186,22 @@ class JC8810base(chirp_common.CloneModeRadio):
rset = RadioSetting("rxendtail", "Tail Phase", rs)
basic.append(rset)
+ # Menu 20: SINGLE MODE
+ rs = RadioSettingValueBoolean(_settings.single_mode)
+ rset = RadioSetting("single_mode", "Single Display Mode", rs)
+ basic.append(rset)
+
+ # Menu 48: UNLOCK SW CH
+ rs = RadioSettingValueBoolean(_settings.unlock_sw_ch)
+ rset = RadioSetting("unlock_sw_ch",
+ "Override KB Lock for Channel Keys", rs)
+ basic.append(rset)
+
+ # Menu 49: DIS S TABLE
+ rs = RadioSettingValueBoolean(_settings.dis_s_table)
+ rset = RadioSetting("dis_s_table", "Display S Meter", rs)
+ basic.append(rset)
+
return group
def set_settings(self, settings):
@@ -1242,7 +1270,9 @@ class RT470Radio(JC8810base):
]
# pcb 2
- _fingerprint_pcb2 = [b"\x00\x00\x00\x2C\x00\x20\xD8\x04", # fw v2.11A
+ _fingerprint_pcb2 = [b"\x00\x00\x00\x28\x00\x20\xD4\x04", # fw v2.00
+ b"\x00\x00\x00\x2C\x00\x20\xD8\x04", # fw v2.11A
+ b"\x00\x00\x00\x36\x00\x20\xDC\x04", # fw v2.13A
]
_fingerprint = _fingerprint_pcb1 + _fingerprint_pcb2
@@ -1434,7 +1464,7 @@ class A36plus8wRadio(A36plusRadio):
# ==========
# Notice to developers:
- # The A36plus 8w support in this driver is currently based upon v1.4
+ # The A36plus 8w support in this driver is currently based upon v1.6
# firmware.
# ==========
@@ -1442,6 +1472,7 @@ class A36plus8wRadio(A36plusRadio):
chirp_common.PowerLevel("L", watts=1.00)]
_fingerprint = [b"\x00\x00\x00\xFA\x00\x20\x40\x05", # fw 1.4
+ b"\x00\x00\x00\xD8\x00\x20\x58\x05", # fw 1.6
]
diff --git a/chirp/drivers/radioddity_r2.py b/chirp/drivers/radioddity_r2.py
index 29f478d..e30bc35 100644
--- a/chirp/drivers/radioddity_r2.py
+++ b/chirp/drivers/radioddity_r2.py
@@ -180,13 +180,19 @@ def _r2_enter_programming_mode(radio):
raise errors.RadioError("Radio is password protected")
try:
serial.write(CMD_ACK)
- ack = serial.read(6)
+ ack = serial.read(1)
except:
_r2_exit_programming_mode(radio)
raise errors.RadioError("Error communicating with radio 2")
- if ack != CMD_ACK:
+ # The latest Retevis RT24 (and likely the RT24V and H777S) models no
+ # longer acknowlege the CMD_ACK above so the 'ack' will be empty and
+ # fail the check causing cloning to fail.
+ #
+ # The factory CPS continues with or without an ack so CHIRP will
+ # behave the same way.
+ if ack and ack != CMD_ACK:
_r2_exit_programming_mode(radio)
raise errors.RadioError("Radio refused to enter programming mode 2")
diff --git a/chirp/drivers/radtel_rt490.py b/chirp/drivers/radtel_rt490.py
index 15028c3..6e49b1a 100644
--- a/chirp/drivers/radtel_rt490.py
+++ b/chirp/drivers/radtel_rt490.py
@@ -17,7 +17,7 @@
# for inclusion in CHIRP here.
# The code is also available under the BSD 2-Clause "Simplified" License
# here:
-# https://chirp.danplanet.com/attachments/7833
+# https://chirpmyradio.com/attachments/7833
# Python3 byte clean by Darryl Pogue
# Pep8 style compliant by Jim Unroe <rock.unroe@gmail.com>
diff --git a/chirp/drivers/tdh8.py b/chirp/drivers/tdh8.py
index 7bedcf3..46b5f1a 100644
--- a/chirp/drivers/tdh8.py
+++ b/chirp/drivers/tdh8.py
@@ -29,7 +29,7 @@ from chirp import bandplan_na
LOG = logging.getLogger(__name__)
-
+AIRBAND = (108000000, 135999999)
MEM_FORMAT = """
#seekto 0x0008;
struct {
@@ -54,12 +54,6 @@ struct {
u8 unused10;
} memory[200];
-#seekto 0x0D38;
-struct {
- char name[8];
- u8 unknown2[8];
-} names[200];
-
#seekto 0x0CA8;
struct {
u8 txled:1,
@@ -111,51 +105,35 @@ struct {
alarm:1;
} settings;
-#seekto 0x0CB8;
+//#seekto 0x0CB8;
struct {
u8 ofseta[4];
- u8 ununsed26[12];
} aoffset;
-#seekto 0x0CBC;
+//#seekto 0x0CBC;
struct {
u8 ofsetb[4];
- u8 ununsed27[12];
} boffset;
#seekto 0x0CD8;
struct{
- u8 fmblock[4];
+ lbcd fmblock[4];
}fmmode[25];
+#seekto 0x0D48;
+struct {
+ char name[8];
+ u8 unknown2[8];
+} names[200];
+
#seekto 0x1A08;
-struct{
- u8 block8:1,
- block7:1,
- block6:1,
- block5:1,
- block4:1,
- block3:1,
- block2:1,
- block1:1;
-} usedflags[25];
+lbit usedflags[200];
#seekto 0x1a28;
-struct{
- u8 scan8:1,
- scan7:1,
- scan6:1,
- scan5:1,
- scan4:1,
- scan3:1,
- scan2:1,
- scan1:1;
-} scanadd[25];
+lbit scanadd[200];
#seekto 0x1B38;
-struct{
- u8 vfo[4];
-}fmvfo;
+lbcd fmvfo[4];
#seekto 0x1B58;
struct {
@@ -180,7 +158,7 @@ struct {
u8 unused10;
} vfoa;
-#seekto 0x1B68;
+//#seekto 0x1B68;
struct {
lbcd rxfreqb[4];
lbcd txfreq[4];
@@ -203,17 +181,8 @@ struct {
u8 unused10;
} vfob;
-#seekto 0x1B78;
-struct{
- u8 block8:1,
- block7:1,
- block6:1,
- block5:1,
- block4:1,
- block3:1,
- block2:1,
- block1:1;
-} fmusedflags[4];
+//#seekto 0x1B78;
+lbit fmusedflags[32];
#seekto 0x1c08;
struct {
@@ -384,24 +353,21 @@ struct {
alarm:1;
} settings;
-#seekto 0x0CB8;
+//#seekto 0x0CB8;
struct {
u8 ofseta[4];
- u8 ununsed26[12];
} aoffset;
-#seekto 0x0CBC;
+//#seekto 0x0CBC;
struct {
u8 ofsetb[4];
- u8 ununsed27[12];
} boffset;
#seekto 0x0CD8;
struct{
- u8 fmblock[4];
+ lbcd fmblock[4];
}fmmode[25];
-
#seekto 0x0D48;
struct {
char name[8];
@@ -413,7 +379,7 @@ struct{
u8 killcode[16];
}skcode;
-#seekto 0x1828;
+//#seekto 0x1828;
struct{
u8 idcode[3];
}icode;
@@ -423,7 +389,7 @@ struct{
u8 gcode;
}groupcode;
-#seekto 0x1838;
+//#seekto 0x1838;
struct{
u8 group1[7];
}group1;
@@ -474,40 +440,13 @@ struct{
}endcode;
#seekto 0x1908;
-struct{
- u8 block8:1,
- block7:1,
- block6:1,
- block5:1,
- block4:1,
- block3:1,
- block2:1,
- block1:1;
-} usedflags[25];
+lbit usedflags[200];
#seekto 0x1928;
-struct{
- u8 scan8:1,
- scan7:1,
- scan6:1,
- scan5:1,
- scan4:1,
- scan3:1,
- scan2:1,
- scan1:1;
-} scanadd[25];
+lbit scanadd[200];
#seekto 0x1948;
-struct{
- u8 block8:1,
- block7:1,
- block6:1,
- block5:1,
- block4:1,
- block3:1,
- block2:1,
- block1:1;
-} fmusedflags[4];
+lbit fmusedflags[32];
#seekto 0x1958;
struct {
@@ -532,7 +471,7 @@ struct {
u8 unused10;
} vfoa;
-#seekto 0x1968;
+//#seekto 0x1968;
struct {
lbcd rxfreqb[4];
lbcd txfreq[4];
@@ -555,11 +494,8 @@ struct {
u8 unused10;
} vfob;
-#seekto 0x1978;
-struct{
- u8 vfo[4];
-}fmvfo;
-
+//#seekto 0x1978;
+lbcd fmvfo[4];
#seekto 0x1c08;
struct {
@@ -679,8 +615,6 @@ TDRAB_LIST = ["Off"] + AB_LIST
TDRCH_LIST = ["CH%s" % x for x in range(1, 129)]
TIMEOUT_LIST = ["%s sec" % x for x in range(15, 615, 15)] + \
["Off (if supported by radio)"]
-TXPOWER_LIST = ["High", "Low"]
-TXPOWER3_LIST = ["High", "Mid", "Low"]
VOICE_LIST = ["Off", "English", "Chinese"]
VOX_LIST = ["OFF"] + ["%s" % x for x in range(1, 11)]
WORKMODE_LIST = ["Frequency", "Channel"]
@@ -705,6 +639,13 @@ TD_H8 = b"\x50\x56\x4F\x4A\x48\x1C\x14"
TD_H3 = b"\x50\x56\x4F\x4A\x48\x5C\x14"
+def in_range(freq, ranges):
+ for lo, hi in ranges:
+ if lo <= freq <= hi:
+ return True
+ return False
+
+
def _do_status(radio, block):
status = chirp_common.Status()
status.msg = "Cloning"
@@ -915,10 +856,6 @@ def _do_upload(radio):
LOG.debug("Upload all done.")
-TX_POWER = [chirp_common.PowerLevel("Low", watts=1.00),
- chirp_common.PowerLevel("Mid", watts=4.00),
- chirp_common.PowerLevel("High", watts=8.00)]
-
TDH8_CHARSET = chirp_common.CHARSET_ALPHANUMERIC + \
"!@#$%^&*()+-=[]:\";'<>?,./"
@@ -934,8 +871,8 @@ class TDH8(chirp_common.CloneModeRadio):
_memsize = 0x1eef
_ranges_main = [(0x0000, 0x1eef)]
_idents = [TD_H8]
- _vhf_range = (136000000, 175000000)
- _uhf_range = (400000000, 521000000)
+ _txbands = [(136000000, 175000000), (400000000, 521000000)]
+ _rxbands = []
_aux_block = True
_tri_power = True
_gmrs = False
@@ -946,6 +883,9 @@ class TDH8(chirp_common.CloneModeRadio):
_fw_ver_file_start = 0x1838
_fw_ver_file_stop = 0x1846
_valid_chars = TDH8_CHARSET
+ _tx_power = [chirp_common.PowerLevel("Low", watts=1.00),
+ chirp_common.PowerLevel("Mid", watts=4.00),
+ chirp_common.PowerLevel("High", watts=8.00)]
@classmethod
def get_prompts(cls):
@@ -988,17 +928,13 @@ class TDH8(chirp_common.CloneModeRadio):
"DTCS->Tone",
"->Tone",
"DTCS->DTCS"]
- rf.valid_power_levels = TX_POWER
+ rf.valid_power_levels = [x for x in self._tx_power if x]
rf.valid_duplexes = ["", "-", "+", "split", "off"]
rf.valid_modes = ["FM", "NFM"]
rf.valid_tuning_steps = STEPS
- normal_bands = [self._vhf_range, self._uhf_range]
-
- if self._mmap is None:
- rf.valid_bands = [normal_bands[0], normal_bands[1]]
- else:
- rf.valid_bands = normal_bands
+ rf.valid_bands = self._txbands + self._rxbands
+ rf.valid_bands.sort()
rf.memory_bounds = (1, 199)
return rf
@@ -1053,10 +989,7 @@ class TDH8(chirp_common.CloneModeRadio):
return self._memobj.memory[number]
def _get_nam(self, number):
- if self.MODEL in H8_LIST:
- return self._memobj.names[number]
- else:
- return self._memobj.names[number - 1]
+ return self._memobj.names[number - 1]
def _get_fm(self, number):
return self._memobj.fmmode[number]
@@ -1064,38 +997,27 @@ class TDH8(chirp_common.CloneModeRadio):
def _get_get_scanvfo(self, number):
return self._memobj.fmvfo[number]
- def _get_scan(self, number):
- return self._memobj.scanadd[number]
-
- def _get_block_data(self, number):
- return self._memobj.usedflags[number]
-
- def _get_fmblock_data(self, number):
- return self._memobj.fmusedflags[number]
-
def get_memory(self, number):
_mem = self._get_mem(number)
_nam = self._get_nam(number)
mem = chirp_common.Memory()
mem.number = number
- if _mem.get_raw(asbytes=False)[0] == "\xff":
+ if _mem.get_raw()[0] == 0xff:
mem.empty = True
return mem
- # receiving frequency
- mem.freq = int(_mem.rxfreq) * 10
-
# narrow and wide
mem.mode = _mem.wide and "NFM" or "FM"
# power
try:
- mem.power = TX_POWER[_mem.lowpower]
- except IndexError:
+ mem.power = self._tx_power[_mem.lowpower]
+ assert mem.power is not None
+ except (IndexError, AssertionError):
LOG.error("Radio reported invalid power level %s (in %s)" %
- (_mem.lowpower, TX_POWER))
- mem.power = TX_POWER[0]
+ (_mem.lowpower, self._tx_power))
+ mem.power = self._tx_power[0]
# Channel name
for char in _nam.name:
@@ -1129,30 +1051,16 @@ class TDH8(chirp_common.CloneModeRadio):
chirp_common.split_tone_decode(mem, txtone, rxtone)
- # skip/scanadd
- scan_val_list = []
- for x in range(25):
- a = self._get_scan(x)
- for i in range(0, 8):
- scan_val = (getattr(a, 'scan%i' % (i+1)))
- # print(str(scan_val)[3])
- used_scan_val = str(scan_val)[3]
- scan_val_list.append(used_scan_val)
+ mem.skip = '' if self._memobj.scanadd[mem.number - 1] else 'S'
- if int(scan_val_list[number - 1]) == 0:
- mem.skip = 'S'
- elif int(scan_val_list[number - 1]) == 1:
- mem.skip = ''
-
- if int(_mem.rxfreq) == int(_mem.txfreq):
- mem.duplex = ""
- mem.offset = 0
- elif int(_mem.txfreq) == 66666665 and int(_mem.rxfreq) != 66666665:
+ mem.freq = int(_mem.rxfreq) * 10
+ if _mem.txfreq.get_raw() == b'\xff\xff\xff\xff':
mem.offset = 0
mem.duplex = 'off'
else:
- mem.duplex = int(_mem.rxfreq) > int(_mem.txfreq) and "-" or "+"
- mem.offset = abs(int(_mem.rxfreq) - int(_mem.txfreq)) * 10
+ chirp_common.split_to_offset(mem,
+ int(_mem.rxfreq) * 10,
+ int(_mem.txfreq) * 10)
if self._gmrs:
# mem.duplex = ""
@@ -1161,7 +1069,7 @@ class TDH8(chirp_common.CloneModeRadio):
mem.immutable.append('freq')
if mem.number >= 8 and mem.number <= 14:
mem.mode = 'NFM'
- mem.power = TX_POWER[0]
+ mem.power = self._tx_power[0]
mem.immutable = ['freq', 'mode', 'power',
'duplex', 'offset']
elif mem.number >= 31 and mem.number <= 54:
@@ -1203,16 +1111,20 @@ class TDH8(chirp_common.CloneModeRadio):
FREQHOP_VALUES, FREQHOP_VALUES[_mem.freqhop]))
mem.extra.append(rs)
+ if in_range(mem.freq, self._rxbands):
+ mem.duplex = 'off'
+ mem.immutable.append('duplex')
+ if in_range(mem.freq, [AIRBAND]):
+ mem.mode = 'AM'
+ mem.immutable.append('mode')
+
return mem
def _set_mem(self, number):
return self._memobj.memory[number]
def _set_nam(self, number):
- if self.MODEL in H8_LIST:
- return self._memobj.names[number]
- else:
- return self._memobj.names[number - 1]
+ return self._memobj.names[number - 1]
def _get_scan_list(self, scan_data):
# scan_val_list - Get all scans Add data 1-200 digits
@@ -1243,77 +1155,19 @@ class TDH8(chirp_common.CloneModeRadio):
return ([x_list, y_list])
- def get_block_xy(self, number):
- if number % 8 != 0:
- x_list = number / 8
- y_list = number % 8
-
- else:
- x_list = (number / 8) - 1
- y_list = 8
-
- return ([x_list, y_list])
-
def set_memory(self, mem):
_mem = self._get_mem(mem.number)
_nam = self._get_nam(mem.number)
+ # When the channel is empty, you need to set "usedflags" to 0,
+ # When the channel is used , you need to set "usedflags" to 1.
+ self._memobj.usedflags[mem.number - 1] = int(not mem.empty)
+
if mem.empty:
- _mem.set_raw("\xff" * 16)
- if self.MODEL in H8_LIST:
- _nam.set_raw("\xff" * 16)
- else:
- _nam.set_raw("\xff" * 8)
+ _mem.fill_raw(b'\xFF')
return
- _mem.set_raw("\x00" * 16)
-
- # When the channel is empty, you need to set "usedflags" to 0,
- # which means it is empty.When the channel has a value,
- # you need to set "usedflags" to 0,
- # indicating that it contains a value.
- # The method "get_block_xy" is due to
- # the particularity of the structure,
- # x represents a certain structure group,
- # and y represents a certain byte of the structure group.
- if not mem.empty:
- block_xy = self.get_block_xy(mem.number)
- _usedflags = self._get_block_data(block_xy[0])
- if block_xy[1] == 1:
- _usedflags.block1 = 1
- elif block_xy[1] == 2:
- _usedflags.block2 = 1
- elif block_xy[1] == 3:
- _usedflags.block3 = 1
- elif block_xy[1] == 4:
- _usedflags.block4 = 1
- elif block_xy[1] == 5:
- _usedflags.block5 = 1
- elif block_xy[1] == 6:
- _usedflags.block6 = 1
- elif block_xy[1] == 7:
- _usedflags.block7 = 1
- elif block_xy[1] == 8:
- _usedflags.block8 = 1
- else:
- block_xy = self.get_block_xy(mem.number)
- _usedflags = self._get_block_data(block_xy[0])
- if block_xy[1] == 1:
- _usedflags.block1 = 0
- elif block_xy[1] == 2:
- _usedflags.block2 = 0
- elif block_xy[1] == 3:
- _usedflags.block3 = 0
- elif block_xy[1] == 4:
- _usedflags.block4 = 0
- elif block_xy[1] == 5:
- _usedflags.block5 = 0
- elif block_xy[1] == 6:
- _usedflags.block6 = 0
- elif block_xy[1] == 7:
- _usedflags.block7 = 0
- elif block_xy[1] == 8:
- _usedflags.block8 = 0
+ _mem.fill_raw(b'\x00')
if mem.duplex == "":
_mem.rxfreq = _mem.txfreq = mem.freq / 10
@@ -1324,10 +1178,13 @@ class TDH8(chirp_common.CloneModeRadio):
elif mem.duplex == "-":
_mem.txfreq = (mem.freq - mem.offset) / 10
elif mem.duplex == 'off':
- _mem.txfreq = 166666665
+ _mem.txfreq.fill_raw(b'\xFF')
else:
_mem.txfreq = mem.freq / 10
+ if in_range(mem.freq, self._rxbands):
+ _mem.txfreq.fill_raw(b'\xFF')
+
_mem.rxfreq = mem.freq / 10
_namelength = self.get_features().valid_name_length
@@ -1347,35 +1204,15 @@ class TDH8(chirp_common.CloneModeRadio):
else:
_mem.wide = 1
- if str(mem.power) == "Low":
- _mem.lowpower = 0
- elif str(mem.power) == "Mid":
- _mem.lowpower = 1
- elif str(mem.power) == "High":
- _mem.lowpower = 10
- else:
+ try:
+ _mem.lowpower = self._tx_power.index(mem.power or
+ self._tx_power[-1])
+ except ValueError:
_mem.lowpower = 0
+ LOG.warning('Unsupported power %r', mem.power)
# Skip/Scanadd Setting
- scanlist = self._get_scan_list(mem.number)
- _scan = self._get_scan(scanlist[0])
-
- if scanlist[1] == 1:
- _scan.scan1 = mem.skip != "S"
- elif scanlist[1] == 2:
- _scan.scan2 = mem.skip != "S"
- elif scanlist[1] == 3:
- _scan.scan3 = mem.skip != "S"
- elif scanlist[1] == 4:
- _scan.scan4 = mem.skip != "S"
- elif scanlist[1] == 5:
- _scan.scan5 = mem.skip != "S"
- elif scanlist[1] == 6:
- _scan.scan6 = mem.skip != "S"
- elif scanlist[1] == 7:
- _scan.scan7 = mem.skip != "S"
- elif scanlist[1] == 8:
- _scan.scan8 = mem.skip != "S"
+ self._memobj.scanadd[mem.number - 1] = mem.skip != 'S'
for setting in mem.extra:
if (self.ident_mode == b'P31185\xff\xff' or
@@ -1569,7 +1406,7 @@ class TDH8(chirp_common.CloneModeRadio):
_mic = self._memobj.mic
rs = RadioSetting("micgain", "MIC GAIN",
RadioSettingValueList(
- MIC_GAIN_LIST, MIC_GAIN_LIST[_mic.micgain]))
+ MIC_GAIN_LIST, current_index=_mic.micgain))
basic.append(rs)
if self.MODEL not in H8_LIST:
@@ -1736,32 +1573,33 @@ class TDH8(chirp_common.CloneModeRadio):
fmmode.append(rs)
# FM
+ numeric = '0123456789.'
for i in range(25):
- _fm = self._get_fm(i).fmblock
- _fm_len = len(_fm) - 1
- _fm_temp = ''
- for x in range(_fm_len, -1, -1):
- _fm_temp += str(_fm[x])[2:]
- if _fm_temp == "00000000" or _fm_temp == 'FFFFFFFF':
- rs = RadioSetting('block' + str(i), "Channel" + " " + str(i+1),
- RadioSettingValueString(0, 5, ""))
+ if self._memobj.fmusedflags[i]:
+ _fm = self._get_fm(i).fmblock
+ try:
+ assert 760 < int(_fm) < 1080
+ val = '%.1f' % (int(_fm) / 10)
+ except (ValueError, AssertionError):
+ LOG.warning('FM channel index %i is invalid', i)
+ val = ''
else:
- _fm_block = int(_fm_temp)
- _fm_block = '%i.%i' % (_fm_block / 10, _fm_block % 10)
- rs = RadioSetting('block' + str(i), "Channel" + " " + str(i+1),
- RadioSettingValueString(0, 5, _fm_block))
+ val = ''
+ rs = RadioSetting('block%02i' % i, "Channel %i" % (i + 1),
+ RadioSettingValueString(0, 5,
+ val,
+ False, charset=numeric))
fmmode.append(rs)
- _fmv = self._memobj.fmvfo.vfo
- _fmv_len = len(_fmv) - 1
- _fmv_temp = ''
- for x in range(_fmv_len, -1, -1):
- _fmv_temp += str(_fmv[x])[2:]
- _fmv_block = int(_fmv_temp)
- _fmv_block = '%i.%i' % (_fmv_block / 10, _fmv_block % 10)
+ try:
+ _fmv = int(self._memobj.fmvfo) / 10
+ except ValueError:
+ LOG.warning('FM VFO is invalid')
+ _fmv = 0
+
rs = RadioSetting(
"fmvfo", "VFO", RadioSettingValueFloat(
- 76.0, 108.0, _fmv_block, 0.1, 1))
+ 76.0, 108.0, _fmv, 0.1, 1))
fmmode.append(rs)
# DTMF
@@ -1936,7 +1774,7 @@ class TDH8(chirp_common.CloneModeRadio):
def fm_validate(value):
if 760 > value or value > 1080:
- msg = ("FM Channel muse be between 76.0-108.0")
+ msg = ("FM Channel must be between 76.0-108.0")
raise InvalidValueError(msg)
_settings = self._memobj.settings
@@ -1988,7 +1826,7 @@ class TDH8(chirp_common.CloneModeRadio):
obj = _fmmode
setting = element.get_name()
elif "fmvfo" in name:
- obj = self._memobj.fmvfo.vfo
+ obj = self._memobj.fmvfo
setting = element.get_name()
elif "gcode" in name:
obj = self._memobj.groupcode.gcode
@@ -2138,75 +1976,22 @@ class TDH8(chirp_common.CloneModeRadio):
# FM
elif "block" in name:
-
- val = str(element.value).replace('.', '').zfill(8)
- num = int(element.get_name().replace('block', '')) + 1
- lenth_val = 0
- list_val = []
- if str(element.value)[0] == ' ':
- list_val = [0, 0, 0, 0]
- else:
- val = val.replace(' ', '').zfill(8)
- fm_validate(int(val))
- while lenth_val < (len(val)):
- list_val.insert(
- 0, int(val[lenth_val:lenth_val + 2], 16))
- lenth_val += 2
- self._memobj.fmmode[num - 1].fmblock = list_val
-
- if val != '00000 ':
- fmblock_xy = self.get_block_xy(num)
- _fmusedflags = self._get_fmblock_data(
- fmblock_xy[0])
- if fmblock_xy[1] == 1:
- _fmusedflags.block1 = 1
- elif fmblock_xy[1] == 2:
- _fmusedflags.block2 = 1
- elif fmblock_xy[1] == 3:
- _fmusedflags.block3 = 1
- elif fmblock_xy[1] == 4:
- _fmusedflags.block4 = 1
- elif fmblock_xy[1] == 5:
- _fmusedflags.block5 = 1
- elif fmblock_xy[1] == 6:
- _fmusedflags.block6 = 1
- elif fmblock_xy[1] == 7:
- _fmusedflags.block7 = 1
- elif fmblock_xy[1] == 8:
- _fmusedflags.block8 = 1
+ num = int(name[-2:], 10)
+ val = str(element.value)
+ if val.strip():
+ try:
+ val = int(float(val) * 10)
+ except ValueError:
+ raise InvalidValueError(
+ 'Value must be between 76.0-108.0')
+ fm_validate(val)
else:
- fmblock_xy = self.get_block_xy(num)
- _fmusedflags = self._get_fmblock_data(
- fmblock_xy[0])
- if fmblock_xy[1] == 1:
- _fmusedflags.block1 = 0
- elif fmblock_xy[1] == 2:
- _fmusedflags.block2 = 0
- elif fmblock_xy[1] == 3:
- _fmusedflags.block3 = 0
- elif fmblock_xy[1] == 4:
- _fmusedflags.block4 = 0
- elif fmblock_xy[1] == 5:
- _fmusedflags.block5 = 0
- elif fmblock_xy[1] == 6:
- _fmusedflags.block6 = 0
- elif fmblock_xy[1] == 7:
- _fmusedflags.block7 = 0
- elif fmblock_xy[1] == 8:
- _fmusedflags.block8 = 0
+ val = 0
+ self._memobj.fmmode[num].fmblock = val
+ self._memobj.fmusedflags[num] = bool(val)
elif setting == 'fmvfo' and element.value.get_mutable():
- val = str(element.value).replace('.', '').zfill(8)
- lenth_val = 0
- list_val = []
- if " " in val:
- list_val = [0, 0, 0, 0]
- else:
- while lenth_val < (len(val)):
- list_val.insert(
- 0, int(val[lenth_val:lenth_val + 2], 16))
- lenth_val += 2
- self._memobj.fmvfo.vfo = list_val
+ self._memobj.fmvfo = int(element.value * 10)
elif setting == 'gcode' and element.value.get_mutable():
val = str(element.value)
@@ -2424,8 +2209,7 @@ class TDH8_HAM(TDH8):
MODEL = "TD-H8-HAM"
ident_mode = b'P31185\xff\xff'
_ham = True
- _vhf_range = (144000000, 149000000)
- _uhf_range = (420000000, 451000000)
+ _txbands = [(144000000, 149000000), (420000000, 451000000)]
@directory.register
@@ -2434,8 +2218,12 @@ class TDH8_GMRS(TDH8):
MODEL = "TD-H8-GMRS"
ident_mode = b'P31184\xff\xff'
_gmrs = True
- _vhf_range = (136000000, 175000000)
- _uhf_range = (400000000, 521000000)
+ _txbands = [(136000000, 175000000), (400000000, 521000000)]
+ _tx_power = [chirp_common.PowerLevel("Low", watts=1.00),
+ # This index should not be used on this radio, but if we
+ # find it, just treat it like "low"
+ chirp_common.PowerLevel("Low", watts=1.00),
+ chirp_common.PowerLevel("High", watts=8.00)]
def validate_memory(self, mem):
msgs = super().validate_memory(mem)
@@ -2459,13 +2247,15 @@ class TDH3(TDH8):
_memsize = 0x1fef
_ranges_main = [(0x0000, 0x1fef)]
_idents = [TD_H3]
- _vhf_range = (136000000, 175000000)
- _uhf_range = (400000000, 521000000)
+ _txbands = [(136000000, 600000000)]
+ _rxbands = [(50000000, 107999000), (108000000, 136000000)]
_aux_block = True
_tri_power = True
_gmrs = False
_ham = False
_mem_params = (0x1F2F)
+ _tx_power = [chirp_common.PowerLevel("Low", watts=1.00),
+ chirp_common.PowerLevel("High", watts=4.00)]
def process_mmap(self):
self._memobj = bitwise.parse(MEM_FORMAT_H3, self._mmap)
@@ -2477,8 +2267,7 @@ class TDH3_HAM(TDH3):
MODEL = "TD-H3-HAM"
ident_mode = b'P31185\xff\xff'
_ham = True
- _vhf_range = (144000000, 149000000)
- _uhf_range = (420000000, 451000000)
+ _txbands = [(144000000, 149000000), (420000000, 451000000)]
@directory.register
@@ -2487,8 +2276,7 @@ class TDH3_GMRS(TDH3):
MODEL = "TD-H3-GMRS"
ident_mode = b'P31184\xff\xff'
_gmrs = True
- _vhf_range = (136000000, 175000000)
- _uhf_range = (400000000, 521000000)
+ _txbands = [(136000000, 175000000), (400000000, 521000000)]
def validate_memory(self, mem):
msgs = super().validate_memory(mem)
diff --git a/chirp/drivers/uv5x3.py b/chirp/drivers/uv5x3.py
index ea8d69a..4220c4f 100644
--- a/chirp/drivers/uv5x3.py
+++ b/chirp/drivers/uv5x3.py
@@ -23,7 +23,7 @@ from chirp.settings import RadioSettingGroup, RadioSetting, \
RadioSettingValueBoolean, RadioSettingValueList, \
RadioSettingValueString, RadioSettingValueInteger, \
RadioSettingValueFloat, RadioSettings, \
- InvalidValueError
+ InvalidValueError, InternalError
LOG = logging.getLogger(__name__)
@@ -136,7 +136,7 @@ class UV5X3(bfc.BaofengCommonHT):
SCODE_LIST = LIST_SCODE
MEM_FORMAT = """
- #seekto 0x0000;
+ // #seekto 0x0000;
struct {
lbcd rxfreq[4];
lbcd txfreq[4];
@@ -855,54 +855,66 @@ class UV5X3(bfc.BaofengCommonHT):
rs.set_apply_callback(apply_freq, _mem.vfo.b)
work.append(rs)
- val = bfc.bcd_decode_freq(_mem.subvfoa.vhf.freq)
- if int(float(val)) == 0:
- val = str(int(_mem.limits.vhf.lower)) + ".000000"
+ try:
+ val = bfc.bcd_decode_freq(_mem.subvfoa.vhf.freq)
+ except InternalError:
+ LOG.debug('Failed to decode VFO A VHF (Saved)')
+ val = "000.000000"
val1a = RadioSettingValueString(0, 10, val)
val1a.set_validate_callback(my_vhf_validate)
rs = RadioSetting("subvfoa.vhf.freq", "VFO A VHF (Saved)", val1a)
rs.set_apply_callback(apply_freq, _mem.subvfoa.vhf)
work.append(rs)
- val = bfc.bcd_decode_freq(_mem.subvfob.vhf.freq)
- if int(float(val)) == 0:
- val = str(int(_mem.limits.vhf.lower)) + ".000000"
+ try:
+ val = bfc.bcd_decode_freq(_mem.subvfob.vhf.freq)
+ except InternalError:
+ LOG.debug('Failed to decode VFO B VHF (Saved)')
+ val = "000.000000"
val1b = RadioSettingValueString(0, 10, val)
val1b.set_validate_callback(my_vhf_validate)
rs = RadioSetting("subvfob.vhf.freq", "VFO B VHF (Saved)", val1b)
rs.set_apply_callback(apply_freq, _mem.subvfob.vhf)
work.append(rs)
- val = bfc.bcd_decode_freq(_mem.subvfoa.vhf2.freq)
- if int(float(val)) == 0:
- val = str(int(_mem.limits.vhf2.lower)) + ".000000"
+ try:
+ val = bfc.bcd_decode_freq(_mem.subvfoa.vhf2.freq)
+ except InternalError:
+ LOG.debug('Failed to decode VFO A VHF2 (Saved)')
+ val = "000.000000"
val1a = RadioSettingValueString(0, 10, val)
val1a.set_validate_callback(my_vhf2_validate)
rs = RadioSetting("subvfoa.vhf2.freq", "VFO A VHF2 (Saved)", val1a)
rs.set_apply_callback(apply_freq, _mem.subvfoa.vhf2)
work.append(rs)
- val = bfc.bcd_decode_freq(_mem.subvfob.vhf2.freq)
- if int(float(val)) == 0:
- val = str(int(_mem.limits.vhf2.lower)) + ".000000"
+ try:
+ val = bfc.bcd_decode_freq(_mem.subvfob.vhf2.freq)
+ except settings.InternalError:
+ LOG.debug('Failed to decode VFO B VHF2 (Saved)')
+ val = "000.000000"
val1b = RadioSettingValueString(0, 10, val)
val1b.set_validate_callback(my_vhf2_validate)
rs = RadioSetting("subvfob.vhf2.freq", "VFO B VHF2 (Saved)", val1b)
rs.set_apply_callback(apply_freq, _mem.subvfob.vhf2)
work.append(rs)
- val = bfc.bcd_decode_freq(_mem.subvfoa.uhf.freq)
- if int(float(val)) == 0:
- val = str(int(_mem.limits.uhf.lower)) + ".000000"
+ try:
+ val = bfc.bcd_decode_freq(_mem.subvfoa.uhf.freq)
+ except InternalError:
+ LOG.debug('Failed to decode VFO A UHF (Saved)')
+ val = "000.000000"
val1a = RadioSettingValueString(0, 10, val)
val1a.set_validate_callback(my_uhf_validate)
rs = RadioSetting("subvfoa.uhf.freq", "VFO A UHF (Saved)", val1a)
rs.set_apply_callback(apply_freq, _mem.subvfoa.uhf)
work.append(rs)
- val = bfc.bcd_decode_freq(_mem.subvfob.uhf.freq)
- if int(float(val)) == 0:
- val = str(int(_mem.limits.uhf.lower)) + ".000000"
+ try:
+ val = bfc.bcd_decode_freq(_mem.subvfob.uhf.freq)
+ except InternalError:
+ LOG.debug('Failed to decode VFO B UHF (Saved)')
+ val = "000.000000"
val1b = RadioSettingValueString(0, 10, val)
val1b.set_validate_callback(my_uhf_validate)
rs = RadioSetting("subvfob.uhf.freq", "VFO B UHF (Saved)", val1b)
diff --git a/chirp/drivers/uvk5.py b/chirp/drivers/uvk5.py
index 2ae2041..b320b4b 100644
--- a/chirp/drivers/uvk5.py
+++ b/chirp/drivers/uvk5.py
@@ -884,12 +884,12 @@ class UVK5RadioBase(chirp_common.CloneModeRadio):
mem.extra = RadioSettingGroup("Extra", "extra")
# BCLO
- is_bclo = bool(_mem.bclo > 0)
+ is_bclo = not mem.empty and bool(_mem.bclo > 0)
rs = RadioSetting("bclo", "BCLO", RadioSettingValueBoolean(is_bclo))
mem.extra.append(rs)
- # Frequency reverse - whatever that means, don't see it in the manual
- is_frev = bool(_mem.freq_reverse > 0)
+ # Frequency reverse - reverse tx/rx frequency
+ is_frev = not mem.empty and bool(_mem.freq_reverse > 0)
rs = RadioSetting("frev", "FreqRev", RadioSettingValueBoolean(is_frev))
mem.extra.append(rs)
@@ -903,7 +903,7 @@ class UVK5RadioBase(chirp_common.CloneModeRadio):
mem.extra.append(rs)
# DTMF DECODE
- is_dtmf = bool(_mem.dtmf_decode > 0)
+ is_dtmf = not mem.empty and bool(_mem.dtmf_decode > 0)
rs = RadioSetting("dtmfdecode", _("DTMF decode"),
RadioSettingValueBoolean(is_dtmf))
mem.extra.append(rs)
@@ -2065,7 +2065,7 @@ class UVK5Radio(UVK5RadioBase):
@classmethod
def k5_approve_firmware(cls, firmware):
approved_prefixes = ('k5_2.01.', 'app_2.01.', '2.01.',
- '1o11', '4.00.')
+ '1o11', '4.00.', 'k5_4.00.')
return any(firmware.startswith(x) for x in approved_prefixes)
@classmethod
diff --git a/chirp/drivers/vx8.py b/chirp/drivers/vx8.py
index 9160847..acd8087 100644
--- a/chirp/drivers/vx8.py
+++ b/chirp/drivers/vx8.py
@@ -151,7 +151,7 @@ struct {
#seekto 0x328A;
struct {
u8 unknown1a:2,
- half_deviation:1,
+ half_deviation:1, // This is not really right, maybe auto?
unknown1b:5;
u8 mode:2,
duplex:2,
@@ -337,7 +337,7 @@ u8 checksum;
TMODES = ["", "Tone", "TSQL", "DTCS"]
DUPLEX = ["", "-", "+", "split"]
-MODES = ["FM", "AM", "WFM", "NFM"]
+MODES = ["FM", "AM", "WFM"]
STEPS = [5.0, 6.25, 8.33, 9.0, 10.0, 12.5, 15.0, 20.0, 25.0, 50.0,
100.0, 200.0]
SKIPS = ["", "S", "P"]
@@ -656,10 +656,7 @@ class VX8Radio(yaesu_clone.YaesuCloneModeRadio):
mem.duplex = DUPLEX[_mem.duplex]
if mem.duplex == "split":
mem.offset = chirp_common.fix_rounded_step(mem.offset)
- if _mem.mode == "FM" and _mem.half_deviation == 1:
- mem.mode = "NFM"
- else:
- mem.mode = MODES[_mem.mode]
+ mem.mode = MODES[_mem.mode]
mem.dtcs = chirp_common.DTCS_CODES[_mem.dcs]
mem.tuning_step = STEPS[_mem.tune_step]
mem.power = POWER_LEVELS[3 - _mem.power]
@@ -705,12 +702,8 @@ class VX8Radio(yaesu_clone.YaesuCloneModeRadio):
_mem.tone = chirp_common.TONES.index(mem.rtone)
_mem.tone_mode = TMODES.index(mem.tmode)
_mem.duplex = DUPLEX.index(mem.duplex)
- if mem.mode == "NFM":
- _mem.mode = 0 # Yaesu's NFM, i.e. regular FM
- _mem.half_deviation = 1 # but half bandwidth
- else:
- _mem.mode = MODES.index(mem.mode)
- _mem.half_deviation = 0
+ _mem.mode = MODES.index(mem.mode)
+ _mem.half_deviation = 0
_mem.mode = MODES.index(mem.mode)
_mem.dcs = chirp_common.DTCS_CODES.index(mem.dtcs)
_mem.tune_step = STEPS.index(mem.tuning_step)
@@ -1380,7 +1373,7 @@ class VX8Radio(yaesu_clone.YaesuCloneModeRadio):
def apply_ff_padded_string(cls, setting, obj):
# FF pad.
val = setting.value.get_value()
- max_len = getattr(obj, "padded_string").size() / 8
+ max_len = getattr(obj, "padded_string").size() // 8
val = str(val).rstrip()
setattr(obj, "padded_string", cls._add_ff_pad(val, max_len))
diff --git a/chirp/drivers/wouxun.py b/chirp/drivers/wouxun.py
index 297a22b..ce00c08 100644
--- a/chirp/drivers/wouxun.py
+++ b/chirp/drivers/wouxun.py
@@ -154,9 +154,9 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio,
tx_time_out_alert:4;
u8 unknown_flag_16:6,
vfo_a_ch_disp:2;
- u8 unknown_flag_15:6,
+ u8 unknown_flag_27:6,
scan_mode:2;
- u8 unknown_flag_16:7,
+ u8 unknown_flag_28:7,
kbd_lock:1;
u8 unknown_flag_17:6,
ponmsg:2;
diff --git a/chirp/locale/es/LC_MESSAGES/CHIRP.mo b/chirp/locale/es/LC_MESSAGES/CHIRP.mo
index ddd60ce..06df346 100644
--- a/chirp/locale/es/LC_MESSAGES/CHIRP.mo
+++ b/chirp/locale/es/LC_MESSAGES/CHIRP.mo
Binary files differ
diff --git a/chirp/locale/fr/LC_MESSAGES/CHIRP.mo b/chirp/locale/fr/LC_MESSAGES/CHIRP.mo
index 8c2563c..53e61a9 100644
--- a/chirp/locale/fr/LC_MESSAGES/CHIRP.mo
+++ b/chirp/locale/fr/LC_MESSAGES/CHIRP.mo
Binary files differ
diff --git a/chirp/locale/pl/LC_MESSAGES/CHIRP.mo b/chirp/locale/pl/LC_MESSAGES/CHIRP.mo
index 99901da..eff9c87 100644
--- a/chirp/locale/pl/LC_MESSAGES/CHIRP.mo
+++ b/chirp/locale/pl/LC_MESSAGES/CHIRP.mo
Binary files differ
diff --git a/chirp/locale/ru/LC_MESSAGES/CHIRP.mo b/chirp/locale/ru/LC_MESSAGES/CHIRP.mo
index 183107e..cd87336 100644
--- a/chirp/locale/ru/LC_MESSAGES/CHIRP.mo
+++ b/chirp/locale/ru/LC_MESSAGES/CHIRP.mo
Binary files differ
diff --git a/chirp/locale/tr_TR/LC_MESSAGES/CHIRP.mo b/chirp/locale/tr_TR/LC_MESSAGES/CHIRP.mo
index 7dd79e2..44777eb 100644
--- a/chirp/locale/tr_TR/LC_MESSAGES/CHIRP.mo
+++ b/chirp/locale/tr_TR/LC_MESSAGES/CHIRP.mo
Binary files differ
diff --git a/chirp/memmap.py b/chirp/memmap.py
index ca27b53..b392ac6 100644
--- a/chirp/memmap.py
+++ b/chirp/memmap.py
@@ -15,8 +15,6 @@
from builtins import bytes
-import six
-
from chirp import util
@@ -64,9 +62,7 @@ class MemoryMapBytes(object):
self._data[pos] = byte
pos += 1
elif isinstance(value, str):
- if six.PY3:
- value = value.encode()
- for byte in value:
+ for byte in value.encode():
self._data[pos] = ord(byte)
pos += 1
else:
@@ -123,9 +119,7 @@ class MemoryMap(MemoryMapBytes):
from chirp import bitwise
self._bitwise = bitwise
- if six.PY3 and isinstance(data, bytes):
- # Be graceful if py3-enabled code uses this,
- # just don't encode it
+ if isinstance(data, bytes):
encode = bytes
else:
encode = self._bitwise.string_straight_encode
diff --git a/chirp/platform.py b/chirp/platform.py
index d2c587f..9cc816e 100644
--- a/chirp/platform.py
+++ b/chirp/platform.py
@@ -20,8 +20,6 @@ import re
import logging
from subprocess import Popen
-import six
-
LOG = logging.getLogger(__name__)
@@ -105,8 +103,8 @@ class Platform:
if we_are_frozen():
# Win32, find the directory of the executable
- return os.path.dirname(six.text_type(sys.executable,
- sys.getfilesystemencoding()))
+ return os.path.dirname(str(sys.executable,
+ sys.getfilesystemencoding()))
else:
# UNIX: Find the parent directory of this module
return os.path.dirname(os.path.abspath(os.path.join(_find_me(),
diff --git a/chirp/pyPEG.py b/chirp/pyPEG.py
index 3e27e74..fea232e 100644
--- a/chirp/pyPEG.py
+++ b/chirp/pyPEG.py
@@ -6,8 +6,6 @@ import re
import sys
import collections
-import six
-
class keyword(str):
pass
@@ -61,7 +59,7 @@ print_trace = False
def u(text):
- return six.text_type(text)
+ return str(text)
def skip(skipper, text, skipWS, skipComments):
diff --git a/chirp/settings.py b/chirp/settings.py
index 622a354..4fa49b8 100644
--- a/chirp/settings.py
+++ b/chirp/settings.py
@@ -226,9 +226,15 @@ class RadioSettingValueList(RadioSettingValue):
def __init__(self, options, current=None, current_index=0):
RadioSettingValue.__init__(self)
self._options = list(options)
- self.queue_current(current or self._options[int(current_index)])
+ self.queue_current(current if current is not None
+ else int(current_index))
def set_value(self, value):
+ if isinstance(value, int):
+ try:
+ value = self._options[value]
+ except IndexError:
+ raise InvalidValueError("Value for %s is out of range" % value)
if value not in self._options:
raise InvalidValueError("%s is not valid for this setting" % value)
RadioSettingValue.set_value(self, value)
diff --git a/chirp/sources/radioreference.py b/chirp/sources/radioreference.py
index e4f85f1..a466918 100644
--- a/chirp/sources/radioreference.py
+++ b/chirp/sources/radioreference.py
@@ -26,6 +26,7 @@ CONF = config.get()
try:
from suds.client import Client
from suds import WebFault
+ from suds.plugin import MessagePlugin
HAVE_SUDS = True
except ImportError:
HAVE_SUDS = False
@@ -85,8 +86,14 @@ class RadioReferenceRadio(base.NetworkResultRadio):
"Suds library required for RadioReference.com import.\n" +
"Try installing your distribution's python-suds package.")
+ class UnicodeFilter(MessagePlugin):
+ def received(self, context):
+ decoded = context.reply.decode('latin1')
+ reencoded = decoded.encode('utf-8')
+ context.reply = reencoded
+
self._auth = {"appKey": self.APPKEY, "username": "", "password": ""}
- self._client = Client(self.URL)
+ self._client = Client(self.URL, plugins=[UnicodeFilter()])
self._freqs = []
self._modes = None
self._zipcounty = None
@@ -150,9 +157,14 @@ class RadioReferenceRadio(base.NetworkResultRadio):
self._auth)
self._freqs += result
status_cur += 1
- status.send_status(
- 'Fetching %s:%s' % (cat.cName, subcat.scName),
- status_cur / status_max * 100)
+ try:
+ status.send_status(
+ 'Fetching %s:%s' % (cat.cName, subcat.scName),
+ status_cur / status_max * 100)
+ except AttributeError:
+ LOG.debug('Category %r subcat %r has no name',
+ cat.cName, subcat.scid)
+ pass
for agency in county.agencyList:
agency = self._client.service.getAgencyInfo(agency.aid, self._auth)
diff --git a/chirp/sources/repeaterbook.py b/chirp/sources/repeaterbook.py
index 3185d8a..2c2b222 100644
--- a/chirp/sources/repeaterbook.py
+++ b/chirp/sources/repeaterbook.py
@@ -229,6 +229,9 @@ class RepeaterBook(base.NetworkResultRadio):
if lat == 0 and lon == 0:
# No sort if not provided
return 0
+ if not item.get('Lat') or not item.get('Long'):
+ # Invalid or missing coordinates
+ return 0
return distance(lat, lon,
float(item.get('Lat', 0)),
float(item.get('Long', 0)))
diff --git a/chirp/wxui/__init__.py b/chirp/wxui/__init__.py
index f5b07cc..1102d46 100644
--- a/chirp/wxui/__init__.py
+++ b/chirp/wxui/__init__.py
@@ -1,14 +1,11 @@
import argparse
import builtins
+from importlib import resources
import logging
import os
import sys
-if sys.version_info < (3, 10):
- import importlib_resources
-else:
- import importlib.resources as importlib_resources
-
+from chirp import CHIRP_VERSION
from chirp import directory
from chirp import logger
@@ -16,20 +13,44 @@ LOG = logging.getLogger(__name__)
CONF = None
-def maybe_install_desktop():
+def developer_mode(enabled=None):
+ if not CONF:
+ return False
+
+ if enabled is True:
+ CONF.set('developer_mode', CHIRP_VERSION, 'state')
+ elif enabled is False:
+ CONF.remove_option('developer_mode', 'state')
+
+ return CONF.get('developer_mode', 'state') == CHIRP_VERSION
+
+
+def maybe_install_desktop(args):
local = os.path.join(os.path.expanduser('~'), '.local')
desktop_path = os.path.join(local, 'share',
'applications', 'chirp.desktop')
- with importlib_resources.as_file(
- importlib_resources.files('chirp.share')
- .joinpath('chirp.desktop')) as desktop_src:
+ with resources.as_file(
+ resources.files('chirp.share').joinpath('chirp.desktop')
+ ) as desktop_src:
with open(desktop_src) as f:
desktop_content = f.readlines()
- with importlib_resources.as_file(
- importlib_resources.files('chirp.share')
- .joinpath('chirp.ico')) as p:
+ with resources.as_file(
+ resources.files('chirp.share').joinpath('chirp.ico')) as p:
icon_path = str(p)
+
+ # If asked not to do this, always bail
+ if args.no_install_desktop_app:
+ return
+
+ # Already exists, don't prompt user
if os.path.exists(desktop_path):
+ LOG.debug('Desktop file exists')
+ return
+
+ # If already asked and not explicitly opted-in, stop nagging
+ if (CONF.get_bool('offered_desktop', 'state') and not
+ args.install_desktop_app):
+ LOG.debug('Desktop file missing but user previously offered')
return
import wx
@@ -67,9 +88,6 @@ def chirpmain():
# about duplicate "Windows bitmap file" handlers
import wx.richtext
- from chirp.wxui import config
- CONF = config.get()
-
actions = ['upload', 'download', 'query_rr', 'query_mg',
'query_rb', 'query_dm', 'new']
@@ -93,16 +111,34 @@ def chirpmain():
help="Restore previous tabs")
parser.add_argument('--force-language', default=None,
help='Force locale to this ISO language code')
+ parser.add_argument('--config-dir',
+ help=('Use this alternate directory for config and '
+ 'other profile data'))
if sys.platform == 'linux':
+ desktop = parser.add_mutually_exclusive_group()
parser.add_argument('--no-linux-gdk-backend', action='store_true',
help='Do not force GDK_BACKEND=x11')
- parser.add_argument('--install-desktop-app', action='store_true',
- default=not CONF.get_bool('offered_desktop',
- 'state'),
- help='Prompt to install a desktop icon')
+ desktop.add_argument('--install-desktop-app', action='store_true',
+ default=False,
+ help=('Install a desktop icon even if it was '
+ 'previously refused'))
+ desktop.add_argument('--no-install-desktop-app', action='store_true',
+ default=False,
+ help='Do not prompt to install a desktop icon')
logger.add_arguments(parser)
args = parser.parse_args()
logger.handle_options(args)
+ from chirp.wxui import config
+
+ if args.config_dir:
+ try:
+ os.mkdir(args.config_dir)
+ except Exception:
+ pass
+ assert os.path.isdir(args.config_dir), \
+ '--config must specify directory'
+ config._CONFIG = config.ChirpConfig(args.config_dir)
+ CONF = config.get()
app = wx.App()
if args.force_language:
@@ -127,8 +163,7 @@ def chirpmain():
else:
lang = wx.Locale.GetSystemLanguage()
- localedir = str(os.path.join(importlib_resources.files('chirp'),
- 'locale'))
+ localedir = str(os.path.join(resources.files('chirp'), 'locale'))
app._lc = wx.Locale()
if localedir and os.path.isdir(localedir):
wx.Locale.AddCatalogLookupPathPrefix(localedir)
@@ -165,7 +200,8 @@ def chirpmain():
directory.import_drivers(limit=args.onlydriver)
- if CONF.get_bool('developer', 'state'):
+ if developer_mode():
+ LOG.warning('Developer mode is enabled')
from chirp.drivers import fake
fake.register_fakes()
@@ -206,9 +242,9 @@ def chirpmain():
report.check_for_updates(
lambda ver: wx.CallAfter(main.display_update_notice, ver))
- if sys.platform == 'linux' and args.install_desktop_app:
+ if sys.platform == 'linux':
try:
- maybe_install_desktop()
+ maybe_install_desktop(args)
except Exception as e:
LOG.exception('Failed to run linux desktop installer: %s', e)
diff --git a/chirp/wxui/clone.py b/chirp/wxui/clone.py
index 5b6bdc8..2b80deb 100644
--- a/chirp/wxui/clone.py
+++ b/chirp/wxui/clone.py
@@ -39,13 +39,15 @@ CONF = config.get()
HELPME = _('Help Me...')
CUSTOM = _('Custom...')
-FAKES = {
- 'Fake NOP': developer.FakeSerial(),
- 'Fake Echo NOP': developer.FakeEchoSerial(),
- 'Fake F7E': fake.FakeKenwoodSerial(),
- 'Fake UV17': fake.FakeUV17Serial(),
- 'Fake UV17Pro': fake.FakeUV17ProSerial(),
-}
+
+def get_fakes():
+ return {
+ 'Fake NOP': developer.FakeSerial(),
+ 'Fake Echo NOP': developer.FakeEchoSerial(),
+ 'Fake F7E': fake.FakeKenwoodSerial(),
+ 'Fake UV17': fake.FakeUV17Serial(),
+ 'Fake UV17Pro': fake.FakeUV17ProSerial(),
+ }
class CloneThread(threading.Thread):
@@ -128,7 +130,7 @@ class SettingsThread(threading.Thread):
def open_serial(port, rclass):
if port.startswith('Fake'):
- return FAKES[port]
+ return get_fakes()[port]
if '://' in port:
pipe = serial.serial_for_url(port, do_not_open=True)
pipe.timeout = 0.25
@@ -247,7 +249,6 @@ CUSTOM_PORTS = []
class ChirpCloneDialog(wx.Dialog):
def __init__(self, *a, **k):
allow_detected_models = k.pop('allow_detected_models', False)
- print('_ is %r' % _)
super(ChirpCloneDialog, self).__init__(
*a, title=_('Communicate with radio'), **k)
self._clone_thread = None
@@ -255,8 +256,8 @@ class ChirpCloneDialog(wx.Dialog):
grid.AddGrowableCol(1)
bs = self.CreateButtonSizer(wx.OK | wx.CANCEL)
- if CONF.get_bool('developer', 'state'):
- for fakeserial in FAKES.keys():
+ if developer.developer_mode():
+ for fakeserial in get_fakes().keys():
if fakeserial not in CUSTOM_PORTS:
CUSTOM_PORTS.append(fakeserial)
@@ -374,7 +375,7 @@ class ChirpCloneDialog(wx.Dialog):
self._port.SetStringSelection(port[0])
else:
port = '(no ports available)'
- LOG.warning('Unable to select %r, defaulting to %s',
+ LOG.warning('Last port %r is unavailable, defaulting to %s',
select, port)
def get_selected_port(self):
diff --git a/chirp/wxui/common.py b/chirp/wxui/common.py
index 4c01bdc..33cce0e 100644
--- a/chirp/wxui/common.py
+++ b/chirp/wxui/common.py
@@ -22,6 +22,7 @@ import os
import platform
import shutil
import tempfile
+import textwrap
import threading
import wx
@@ -52,6 +53,10 @@ INDEX_CHAR = settings.BANNED_NAME_CHARACTERS[0]
EDIT_LOCK = threading.Lock()
+class ExportFailed(Exception):
+ pass
+
+
def closes_clipboard(fn):
@functools.wraps(fn)
def wrapper(*a, **k):
@@ -534,11 +539,14 @@ class ChirpSettingGrid(wx.Panel):
def _get_editor_choice(self, setting, value):
choices = value.get_options()
self._choices[setting.get_name()] = choices
- current = choices.index(str(value))
- return wx.propgrid.EnumProperty(setting.get_shortname(),
- setting.get_name(),
- choices, range(len(choices)),
- current)
+ e = wx.propgrid.EnumProperty(setting.get_shortname(),
+ setting.get_name(),
+ choices, range(len(choices)))
+ if value.initialized:
+ e.SetValue(choices.index(str(value)))
+ else:
+ e.SetValueToUnspecified()
+ return e
def _get_editor_bool(self, setting, value):
prop = wx.propgrid.BoolProperty(setting.get_shortname(),
@@ -704,7 +712,7 @@ def temporary_debug_log():
@contextlib.contextmanager
-def expose_logs(level, root, label):
+def expose_logs(level, root, label, maxlen=128):
if not isinstance(root, tuple):
root = (root,)
@@ -717,7 +725,8 @@ def expose_logs(level, root, label):
lines = list(itertools.chain.from_iterable(x.get_history()
for x in histories))
if lines:
- msg = os.linesep.join(x.getMessage() for x in lines)
+ msg = os.linesep.join(textwrap.shorten(x.getMessage(), maxlen)
+ for x in lines)
d = wx.MessageDialog(
None, str(msg), label,
style=wx.OK | wx.ICON_INFORMATION)
diff --git a/chirp/wxui/config.py b/chirp/wxui/config.py
index fa435d8..52360ca 100644
--- a/chirp/wxui/config.py
+++ b/chirp/wxui/config.py
@@ -17,10 +17,7 @@ import base64
import binascii
from chirp import platform
-try:
- from ConfigParser import ConfigParser
-except ImportError:
- from configparser import ConfigParser
+from configparser import ConfigParser
import os
diff --git a/chirp/wxui/developer.py b/chirp/wxui/developer.py
index d8047ce..68d0a57 100644
--- a/chirp/wxui/developer.py
+++ b/chirp/wxui/developer.py
@@ -27,12 +27,14 @@ import wx.lib.scrolledpanel
from chirp import bitwise
from chirp import util
+import chirp.wxui
from chirp.wxui import common
from chirp.wxui import report
LOG = logging.getLogger(__name__)
BrowserChanged, EVT_BROWSER_CHANGED = wx.lib.newevent.NewCommandEvent()
FROZEN = getattr(sys, 'frozen', False)
+developer_mode = chirp.wxui.developer_mode
def simple_diff(a, b, diffsonly=False):
@@ -356,10 +358,12 @@ class ChirpBrowserPanel(wx.lib.scrolledpanel.ScrolledPanel):
self._initialize()
label = wx.StaticText(self)
- pos = wx.StaticText(self, label='%i bits (%i bytes) at 0x%06x' % (
+ pos = wx.StaticText(
+ self, label='%i bits (%i bytes) at 0x%06x-0x%06x' % (
self._memobj.size(),
self._memobj.size() // 8,
- self._memobj.get_offset()))
+ self._memobj.get_offset(),
+ self._memobj.get_offset() + self._memobj.size() // 8))
self._sizer.Add(label, 0, wx.ALIGN_CENTER)
self._sizer.Add(pos, 1, flag=wx.EXPAND)
@@ -478,7 +482,7 @@ class IssueModuleLoader:
def get_attachments_from_issue(self, issue):
r = self.session.get(
- 'https://chirp.danplanet.com/issues/%i.json' % issue,
+ 'https://chirpmyradio.com/issues/%i.json' % issue,
params={'include': 'attachments'})
LOG.debug('Fetched attachments for issue %i (status %s)' % (
issue, r.status_code))
@@ -490,7 +494,7 @@ class IssueModuleLoader:
a['filesize'] < (256 * 1024)]
def get_user_is_developer(self, uid):
- r = self.session.get('https://chirp.danplanet.com/users/%i.json' % uid,
+ r = self.session.get('https://chirpmyradio.com/users/%i.json' % uid,
params={'include': 'memberships'})
LOG.debug('Fetched info for user %i (status %s)',
uid, r.status_code)
diff --git a/chirp/wxui/main.py b/chirp/wxui/main.py
index 20b91e5..8e24fca 100644
--- a/chirp/wxui/main.py
+++ b/chirp/wxui/main.py
@@ -16,6 +16,7 @@
import datetime
import functools
import hashlib
+from importlib import resources
import logging
import os
import pickle
@@ -25,10 +26,6 @@ import time
import typing
import webbrowser
-if sys.version_info < (3, 10):
- import importlib_resources
-else:
- import importlib.resources as importlib_resources
import wx
import wx.aui
@@ -215,7 +212,7 @@ class ChirpEditorSet(wx.Panel):
settings = self.SETTINGS_CLS(parent_radio, self._editors)
self.add_editor(settings, _('Settings'))
- if (CONF.get_bool('developer', 'state') and
+ if (developer.developer_mode() and
isinstance(radio, chirp_common.CloneModeRadio)):
browser = developer.ChirpRadioBrowser(parent_radio, self._editors)
browser.Bind(common.EVT_EDITOR_CHANGED, self._refresh_all)
@@ -317,7 +314,7 @@ class ChirpEditorSet(wx.Panel):
def close(self):
pass
- @common.error_proof()
+ @common.error_proof(common.ExportFailed)
def export_to_file(self, filename):
current = self.current_editor
if not isinstance(current, memedit.ChirpMemEdit):
@@ -374,9 +371,8 @@ class ChirpWelcomePanel(wx.Panel):
vbox = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(vbox)
- with importlib_resources.as_file(
- importlib_resources.files('chirp.share')
- .joinpath('welcome_screen.png')
+ with resources.as_file(
+ resources.files('chirp.share').joinpath('welcome_screen.png')
) as welcome:
bmp = wx.Bitmap(str(welcome))
width, height = self.GetSize()
@@ -453,9 +449,8 @@ class ChirpMain(wx.Frame):
self.add_tab_panel = wx.Panel(self, pos=(0, 0), size=(600, 600))
self.add_tab_panel.Hide()
- with importlib_resources.as_file(
- importlib_resources.files('chirp.share')
- .joinpath('plus-icon.png')
+ with resources.as_file(
+ resources.files('chirp.share').joinpath('plus-icon.png')
) as icon:
self.add_tab_bm = wx.Bitmap(str(icon), wx.BITMAP_TYPE_ANY)
@@ -525,9 +520,8 @@ class ChirpMain(wx.Frame):
icon = 'chirp.ico'
else:
icon = 'chirp.png'
- with importlib_resources.as_file(
- importlib_resources.files('chirp.share')
- .joinpath(icon)
+ with resources.as_file(
+ resources.files('chirp.share').joinpath(icon)
) as path:
self.SetIcon(wx.Icon(str(path)))
@@ -588,7 +582,7 @@ class ChirpMain(wx.Frame):
dist_stock_confs = sorted(
[
(conf.name, hashlib.md5(conf.read_bytes())) for conf
- in importlib_resources.files('chirp.stock_configs').iterdir()
+ in resources.files('chirp.stock_configs').iterdir()
if conf.is_file()
]
)
@@ -702,7 +696,7 @@ class ChirpMain(wx.Frame):
export_item.SetAccel(wx.AcceleratorEntry(wx.MOD_CONTROL, ord('E')))
self.Bind(wx.EVT_MENU, self._menu_export, export_item)
- if CONF.get_bool('developer', 'state'):
+ if developer.developer_mode():
loadmod_item = file_menu.Append(wx.MenuItem(file_menu, wx.NewId(),
_('Load Module...')))
self.Bind(wx.EVT_MENU, self._menu_load_module, loadmod_item)
@@ -866,7 +860,7 @@ class ChirpMain(wx.Frame):
self.Bind(wx.EVT_MENU, self._menu_select_bandplan, select_bandplan)
radio_menu.Append(select_bandplan)
- if CONF.get_bool('developer', 'state'):
+ if developer.developer_mode():
radio_menu.Append(wx.MenuItem(file_menu, wx.ID_SEPARATOR))
self._reload_driver_item = wx.NewId()
@@ -917,7 +911,7 @@ class ChirpMain(wx.Frame):
functools.partial(self._menu_developer, developer_menu),
developer_menu)
help_menu.Append(developer_menu)
- developer_menu.Check(CONF.get_bool('developer', 'state'))
+ developer_menu.Check(developer.developer_mode())
reporting_menu = wx.MenuItem(help_menu, wx.NewId(),
_('Reporting enabled'),
@@ -1038,7 +1032,8 @@ class ChirpMain(wx.Frame):
CONF.set('recent%i' % i, recent[i], 'state')
except IndexError:
# Clean higher-order entries if they exist
- CONF.remove_option('recent%i' % i, 'state')
+ if CONF.is_defined('recent%i' % i, 'state'):
+ CONF.remove_option('recent%i' % i, 'state')
config._CONFIG.save()
# Clear the menu
@@ -1232,9 +1227,8 @@ class ChirpMain(wx.Frame):
user_stock_dir = get_stock_configs()
user_stock_conf = os.path.join(user_stock_dir, fn)
- with importlib_resources.as_file(
- importlib_resources.files('chirp.stock_configs')
- .joinpath(fn)
+ with resources.as_file(
+ resources.files('chirp.stock_configs').joinpath(fn)
) as path:
dist_stock_conf = str(path)
if os.path.exists(user_stock_conf):
@@ -1639,7 +1633,7 @@ class ChirpMain(wx.Frame):
'or both. NEVER load a module from a source '
'you do not trust, and especially not from '
'anywhere other than the main CHIRP website '
- '(chirp.danplanet.com). Loading a module from '
+ '(chirpmyradio.com). Loading a module from '
'another source is akin to giving them direct '
'access to your computer and everything on '
'it! Proceed despite this risk?'),
@@ -1668,7 +1662,7 @@ class ChirpMain(wx.Frame):
wx.OK | wx.ICON_INFORMATION)
def _menu_developer(self, menuitem, event):
- CONF.set_bool('developer', menuitem.IsChecked(), 'state')
+ developer.developer_mode(menuitem.IsChecked())
state = menuitem.IsChecked() and _('enabled') or _('disabled')
if menuitem.IsChecked():
msg = _(
@@ -1687,6 +1681,7 @@ class ChirpMain(wx.Frame):
wx.MessageBox(_('Developer state is now %s. '
'CHIRP must be restarted to take effect') % state,
_('Restart Required'), wx.OK)
+ LOG.info('User set developer mode to %s', menuitem.IsChecked())
def _menu_reporting(self, menuitem, event):
if not menuitem.IsChecked():
@@ -1720,6 +1715,16 @@ class ChirpMain(wx.Frame):
@common.error_proof()
def _menu_load_from_issue(self, event):
+ if self.current_editorset:
+ r = wx.MessageBox(
+ _('Loading a module will not affect open tabs. '
+ 'It is recommended (unless instructed '
+ 'otherwise) to close all tabs before loading '
+ 'a module.'),
+ _('Warning'),
+ wx.ICON_WARNING | wx.OK | wx.CANCEL | wx.CANCEL_DEFAULT)
+ if r == wx.CANCEL:
+ return
module = developer.IssueModuleLoader(self).run()
if module:
if self.load_module(module):
@@ -1793,7 +1798,7 @@ def display_update_notice(version):
CONF.set_int("last_update_check", int(time.time()), "state")
- url = 'https://chirp.danplanet.com/projects/chirp/wiki/ChirpNextBuild'
+ url = 'https://chirpmyradio.com/projects/chirp/wiki/ChirpNextBuild'
msg = _('A new CHIRP version is available. Please visit the '
'website as soon as possible to download it!')
d = wx.MessageDialog(None, msg, _('New version available'),
diff --git a/chirp/wxui/memedit.py b/chirp/wxui/memedit.py
index 540643d..13b9df4 100644
--- a/chirp/wxui/memedit.py
+++ b/chirp/wxui/memedit.py
@@ -79,6 +79,7 @@ DEFAULT_COLUMN_HELP = {
'tmode': _('Tone squelch mode'),
'rtone': _('Transmit tone'),
'ctone': _('Transmit/receive tone for TSQL mode, else receive tone'),
+ 'mode': _('Transmit/receive modulation (FM, AM, SSB, etc)'),
'dtcs': _('Transmit/receive DTCS code for DTCS mode, else transmit code'),
'rx_dtcs': _('Receive DTCS code'),
'dtcs_polarity': _('TX-RX DTCS polarity (normal or reversed)'),
@@ -1721,7 +1722,7 @@ class ChirpMemEdit(common.ChirpEditor, common.ChirpSyncEditor):
insert_item.Enable(not self.busy and self.editable)
menu.Enable(sort_menu_item.GetId(), not self.busy and can_sort)
- if CONF.get_bool('developer', 'state'):
+ if developer.developer_mode():
menu.Append(wx.MenuItem(menu, wx.ID_SEPARATOR))
raw_item = wx.MenuItem(menu, wx.NewId(), _('Show Raw Memory'))
@@ -2121,8 +2122,13 @@ class ChirpMemEdit(common.ChirpEditor, common.ChirpSyncEditor):
# We don't export specials
continue
if not m.empty:
- m = import_logic.import_mem(r, self._features, m,
- mem_cls=chirp_common.Memory)
+ try:
+ m = import_logic.import_mem(r, self._features, m,
+ mem_cls=chirp_common.Memory)
+ except import_logic.ImportError as e:
+ LOG.error('Failed to export %r: %s', m, e)
+ raise common.ExportFailed(
+ 'Failed to export memory %i: %s' % (m.number, e))
r.set_memory(m)
r.save(filename)
LOG.info('Wrote exported CSV to %s' % filename)
diff --git a/chirp/wxui/report.py b/chirp/wxui/report.py
index d2ca771..9d6534b 100644
--- a/chirp/wxui/report.py
+++ b/chirp/wxui/report.py
@@ -34,7 +34,7 @@ logging.getLogger('urllib3.connectionpool').setLevel(logging.INFO)
SESSION = None
DISABLED = False
SEM = threading.Semaphore(2)
-BASE = 'http://chirp.danplanet.com/report'
+BASE = 'http://chirpmyradio.com/report'
def get_environment():
diff --git a/requirements.txt b/requirements.txt
index 8c2d059..b08f93e 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,9 +1,7 @@
-six
wxPython>=4.0,<4.2.0 ; platform_system=="Linux" # See https://github.com/wxWidgets/Phoenix/issues/2225
wxPython==4.2.0 ; platform_system!="Linux"
pyserial
requests
pywin32; platform_system=="Windows"
suds
-importlib-resources;python_version<"3.10"
yattag
diff --git a/setup.py b/setup.py
index e773da1..18dd18c 100644
--- a/setup.py
+++ b/setup.py
@@ -5,14 +5,12 @@ setup(name='chirp',
description='A cross-platform cross-radio programming tool',
packages=find_packages(include=["chirp*"]),
include_package_data=True,
- version='20240224',
+ version='20240413',
url='https://chirp.danplanet.com',
- python_requires=">=3.7,<4",
+ python_requires=">=3.10,<4",
install_requires=[
'pyserial',
'requests',
- 'six',
- 'importlib-resources;python_version<"3.10"',
'yattag',
],
extras_require={
diff --git a/test-requirements.txt b/test-requirements.txt
index 9d34147..b0f855f 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -9,3 +9,4 @@ future
requests
pyyaml
pywin32; platform_system=="Windows"
+ddt
diff --git a/tests/Python3_Driver_Testing.md b/tests/Python3_Driver_Testing.md
index a7864a1..68276b9 100644
--- a/tests/Python3_Driver_Testing.md
+++ b/tests/Python3_Driver_Testing.md
@@ -16,6 +16,7 @@
| <a name="Alinco_DR135T"></a> Alinco_DR135T | [Implied by Alinco_DR235T](#user-content-Alinco_DR235T) | 12-Dec-2022 | Yes | 0.04% |
| <a name="Alinco_DR235T"></a> Alinco_DR235T | [@kk7ds](https://github.com/kk7ds) | 12-Dec-2022 | Yes | 0.02% |
| <a name="Alinco_DR435T"></a> Alinco_DR435T | [Implied by Alinco_DR235T](#user-content-Alinco_DR235T) | 12-Dec-2022 | Yes | 0.02% |
+| <a name="Alinco_DR735T"></a> Alinco_DR735T | [@jacobcalvert](https://github.com/jacobcalvert) | 03-April-2024 | Yes | |
| <a name="AnyTone_5888UV"></a> AnyTone_5888UV | [@kk7ds](https://github.com/kk7ds) | 9-Dec-2022 | Yes | 0.14% |
| <a name="AnyTone_5888UVIII"></a> AnyTone_5888UVIII | [@bschuler42](https://github.com/bschuler42) | 9-Jan-2023 | Yes | 0.04% |
| <a name="AnyTone_778UV"></a> AnyTone_778UV | [Implied by Retevis_RT95](#user-content-Retevis_RT95) | 13-Nov-2022 | Yes | 0.17% |
@@ -60,8 +61,10 @@
| <a name="Baofeng_BF-T8"></a> Baofeng_BF-T8 | [@KC9HI](https://github.com/KC9HI) | 30-Nov-2022 | Yes | 0.42% |
| <a name="Baofeng_BF-V8A"></a> Baofeng_BF-V8A | [@KC9HI](https://github.com/KC9HI) | 28-Nov-2022 | Yes | 0.03% |
| <a name="Baofeng_F-11"></a> Baofeng_F-11 | [Implied by Baofeng_UV-5R](#user-content-Baofeng_UV-5R) | 18-Nov-2022 | Yes | 0.12% |
+| <a name="Baofeng_GM-5RH"></a> Baofeng_GM-5RH | [@KC9HI](https://github.com/KC9HI) | 21-Mar-2024 | Yes | |
| <a name="Baofeng_GT-3WP"></a> Baofeng_GT-3WP | [@KC9HI](https://github.com/KC9HI) | 3-Dec-2022 | Yes | 0.43% |
| <a name="Baofeng_GT-5R"></a> Baofeng_GT-5R | [@KC9HI](https://github.com/KC9HI) | 18-Nov-2022 | Yes | 0.68% |
+| <a name="Baofeng_K5-Plus"></a> Baofeng_K5-Plus | | | Yes | |
| <a name="Baofeng_UV-13Pro"></a> Baofeng_UV-13Pro | [@vdwel](https://github.com/vdwel) | 21-Feb-2024 | Yes | |
| <a name="Baofeng_UV-17"></a> Baofeng_UV-17 | [@vdwel](https://github.com/vdwel) | 27-Nov-2023 | Yes | |
| <a name="Baofeng_UV-17Pro"></a> Baofeng_UV-17Pro | [@vdwel](https://github.com/vdwel) | 27-Nov-2023 | Yes | |
@@ -113,6 +116,7 @@
| <a name="Icom_IC-7100"></a> Icom_IC-7100 | Mike W | 16-Feb-2023 | Yes | 0.06% |
| <a name="Icom_IC-7200"></a> Icom_IC-7200 | [@kk7ds](https://github.com/kk7ds) | 22-Oct-2022 | Yes | |
| <a name="Icom_IC-7300"></a> Icom_IC-7300 | [@kk7ds](https://github.com/kk7ds) | 22-Oct-2022 | Yes | 0.03% |
+| <a name="Icom_IC-7400"></a> Icom_IC-7400 | | | Yes | |
| <a name="Icom_IC-746"></a> Icom_IC-746 | [Reported working](https://chirp.danplanet.com/issues/10346) | 3-Feb-2023 | Yes | |
| <a name="Icom_IC-7610"></a> Icom_IC-7610 | [@kk7ds](https://github.com/kk7ds) | 24-Oct-2022 | Yes | 0.00% |
| <a name="Icom_IC-910"></a> Icom_IC-910 | [@mfncooper](https://github.com/mfncooper) | 1-Oct-2021 | Yes | 0.00% |
@@ -231,7 +235,7 @@
| <a name="LUITON_LT-580_VHF"></a> LUITON_LT-580_VHF | [@KC9HI](https://github.com/KC9HI) | 8-Dec-2022 | Yes | 0.01% |
| <a name="LUITON_LT-588UV"></a> LUITON_LT-588UV | [@KC9HI](https://github.com/KC9HI) | 11-Nov-2022 | Yes | 0.01% |
| <a name="LUITON_LT-725UV"></a> LUITON_LT-725UV | [@KC9HI](https://github.com/KC9HI) | 11-Dec-2022 | Yes | 0.02% |
-| <a name="Lanchonlh_HG-UV98"></a> Lanchonlh_HG-UV98 | | | Yes | 0.00% |
+| <a name="Lanchonlh_HG-UV98"></a> Lanchonlh_HG-UV98 | [Reported working](https://chirp.danplanet.com/issues/11179) | 23-Feb-2024 | Yes | 0.00% |
| <a name="Leixen_VV-898"></a> Leixen_VV-898 | [Implied by Jetstream_JT270MH](#user-content-Jetstream_JT270MH) | 13-Dec-2022 | Yes | 0.16% |
| <a name="Leixen_VV-898E"></a> Leixen_VV-898E | | | Yes | 0.02% |
| <a name="Leixen_VV-898E_Dual_Bank"></a> Leixen_VV-898E_Dual_Bank | [Implied by Leixen_VV-898S_Dual_Bank](#user-content-Leixen_VV-898S_Dual_Bank) | 10-Feb-2024 | Yes | |
@@ -452,11 +456,11 @@
| <a name="Zastone_ZT-X6"></a> Zastone_ZT-X6 | [Implied by Retevis_RT22](#user-content-Retevis_RT22) | 9-Dec-2022 | Yes | 0.11% |
## Stats
-**Drivers:** 449
+**Drivers:** 453
-**Tested:** 87% (395/54) (93% of usage stats)
+**Tested:** 87% (398/55) (93% of usage stats)
-**Byte clean:** 91% (410/39)
+**Byte clean:** 91% (414/39)
## Meaning of this testing
diff --git a/tests/__pycache__/base.cpython-310.pyc b/tests/__pycache__/base.cpython-310.pyc
index 888e3bc..c2ea0fe 100644
--- a/tests/__pycache__/base.cpython-310.pyc
+++ b/tests/__pycache__/base.cpython-310.pyc
Binary files differ
diff --git a/tests/__pycache__/test_brute_force.cpython-310-pytest-7.1.3.pyc b/tests/__pycache__/test_brute_force.cpython-310-pytest-7.1.3.pyc
index cebda28..5390656 100644
--- a/tests/__pycache__/test_brute_force.cpython-310-pytest-7.1.3.pyc
+++ b/tests/__pycache__/test_brute_force.cpython-310-pytest-7.1.3.pyc
Binary files differ
diff --git a/tests/__pycache__/test_edges.cpython-310-pytest-7.1.3.pyc b/tests/__pycache__/test_edges.cpython-310-pytest-7.1.3.pyc
index 963e1f1..263d58e 100644
--- a/tests/__pycache__/test_edges.cpython-310-pytest-7.1.3.pyc
+++ b/tests/__pycache__/test_edges.cpython-310-pytest-7.1.3.pyc
Binary files differ
diff --git a/tests/base.py b/tests/base.py
index 0cf8d36..093bede 100644
--- a/tests/base.py
+++ b/tests/base.py
@@ -132,6 +132,14 @@ class DriverTest(unittest.TestCase):
def assertEqualMem(self, a, b, ignore=None):
if a.tmode == "Cross":
tx_mode, rx_mode = a.cross_mode.split("->")
+ if ignore is None:
+ ignore = []
+
+ if a.duplex == b.duplex == 'off':
+ # If we're asking for duplex=off, we should not obsess over the
+ # driver keeping track of our offset, as it may use the offset
+ # field to manage the TX behavior
+ ignore.append('offset')
a_vals = {}
b_vals = {}
diff --git a/tests/images/Alinco_DR735T.img b/tests/images/Alinco_DR735T.img
new file mode 100644
index 0000000..a63b742
--- /dev/null
+++ b/tests/images/Alinco_DR735T.img
Binary files differ
diff --git a/tests/images/Baofeng_GM-5RH.img b/tests/images/Baofeng_GM-5RH.img
new file mode 100644
index 0000000..77ba742
--- /dev/null
+++ b/tests/images/Baofeng_GM-5RH.img
Binary files differ
diff --git a/tests/py3_driver_testers.txt b/tests/py3_driver_testers.txt
index d4a1d05..e2fbfe2 100644
--- a/tests/py3_driver_testers.txt
+++ b/tests/py3_driver_testers.txt
@@ -22,6 +22,7 @@ Alinco_DR06T,+Alinco_DR235T,12-Dec-2022
Alinco_DR135T,+Alinco_DR235T,12-Dec-2022
Alinco_DR235T,@kk7ds,12-Dec-2022
Alinco_DR435T,+Alinco_DR235T,12-Dec-2022
+Alinco_DR735T,@jacobcalvert,03-April-2024
Anysecu_UV-A37,@KC9HI,5-Jun-2023
Anysecu_WP-9900,@KC9HI,11-Nov-2022
Anysecu_AC-580,+Radioddity_GS-5B,17-Mar-2023
@@ -66,6 +67,7 @@ Baofeng_BF-T20FRS,@KC9HI,17-Dec-2023
Baofeng_BF-T8,@KC9HI,30-Nov-2022
Baofeng_BF-V8A,@KC9HI,28-Nov-2022
Baofeng_F-11,+Baofeng_UV-5R,18-Nov-2022
+Baofeng_GM-5RH,@KC9HI,21-Mar-2024
Baofeng_GT-3WP,@KC9HI,3-Dec-2022
Baofeng_GT-5R,@KC9HI,18-Nov-2022
Baofeng_UV-3R,@yarda,26-Sep-2022
@@ -201,6 +203,7 @@ Kenwood_TK-860,+Kenwood_TK-760,5-Dec-2022
Kenwood_TK-862,+Kenwood_TK-760,5-Dec-2022
Kenwood_TK-868,+Kenwood_TK-760,5-Dec-2022
Kenwood_TS-2000,ZS6CRW,10-Jan-2022
+Lanchonlh_HG-UV98,#11179,23-Feb-2024
Leixen_VV-898,+Jetstream_JT270MH,13-Dec-2022
Leixen_VV-898S,@READ10,19-Dec-2022
Leixen_VV-898S_Dual_Bank,#4069,10-Feb-2024
diff --git a/tests/test_edges.py b/tests/test_edges.py
index a186e18..86174ed 100644
--- a/tests/test_edges.py
+++ b/tests/test_edges.py
@@ -188,7 +188,6 @@ class TestBitwiseStrict(base.DriverTest):
def test_bitwise_unnecessary_seek(self, mock_assert):
super().setUp()
- @pytest.mark.xfail(strict=False)
@mock.patch.object(bitwise.LOG, 'error')
def test_bitwise_errors(self, mock_log):
super().setUp()
diff --git a/tests/unit/__pycache__/base.cpython-310.pyc b/tests/unit/__pycache__/base.cpython-310.pyc
index a5f2379..7fcc6bd 100644
--- a/tests/unit/__pycache__/base.cpython-310.pyc
+++ b/tests/unit/__pycache__/base.cpython-310.pyc
Binary files differ
diff --git a/tests/unit/__pycache__/test_alinco_clone.cpython-310-pytest-7.1.3.pyc b/tests/unit/__pycache__/test_alinco_clone.cpython-310-pytest-7.1.3.pyc
index f9c396a..9811cb6 100644
--- a/tests/unit/__pycache__/test_alinco_clone.cpython-310-pytest-7.1.3.pyc
+++ b/tests/unit/__pycache__/test_alinco_clone.cpython-310-pytest-7.1.3.pyc
Binary files differ
diff --git a/tests/unit/__pycache__/test_bitwise.cpython-310-pytest-7.1.3.pyc b/tests/unit/__pycache__/test_bitwise.cpython-310-pytest-7.1.3.pyc
index 3efe7a5..109a28e 100644
--- a/tests/unit/__pycache__/test_bitwise.cpython-310-pytest-7.1.3.pyc
+++ b/tests/unit/__pycache__/test_bitwise.cpython-310-pytest-7.1.3.pyc
Binary files differ
diff --git a/tests/unit/__pycache__/test_chirp_common.cpython-310-pytest-7.1.3.pyc b/tests/unit/__pycache__/test_chirp_common.cpython-310-pytest-7.1.3.pyc
index b47cb93..e4719f6 100644
--- a/tests/unit/__pycache__/test_chirp_common.cpython-310-pytest-7.1.3.pyc
+++ b/tests/unit/__pycache__/test_chirp_common.cpython-310-pytest-7.1.3.pyc
Binary files differ
diff --git a/tests/unit/__pycache__/test_wxui_radiothread.cpython-310-pytest-7.1.3.pyc b/tests/unit/__pycache__/test_wxui_radiothread.cpython-310-pytest-7.1.3.pyc
index 1c758c2..38b9af1 100644
--- a/tests/unit/__pycache__/test_wxui_radiothread.cpython-310-pytest-7.1.3.pyc
+++ b/tests/unit/__pycache__/test_wxui_radiothread.cpython-310-pytest-7.1.3.pyc
Binary files differ
diff --git a/tests/unit/base.py b/tests/unit/base.py
index 72c554a..a9e938c 100644
--- a/tests/unit/base.py
+++ b/tests/unit/base.py
@@ -12,6 +12,10 @@ class BaseTest(unittest.TestCase):
__builtins__['_'] = lambda s: s
self.mocks = []
+ def use(self, m):
+ self.mocks.append(m)
+ m.start()
+
def tearDown(self):
for m in self.mocks:
m.stop()
diff --git a/tests/unit/test_alinco_clone.py b/tests/unit/test_alinco_clone.py
index 5df6bcc..c5e28ca 100644
--- a/tests/unit/test_alinco_clone.py
+++ b/tests/unit/test_alinco_clone.py
@@ -19,7 +19,7 @@ import unittest
from unittest import mock
from chirp import directory
-from chirp.drivers import alinco
+from chirp.drivers import alinco, alinco_dr735t
from chirp import memmap
@@ -35,6 +35,29 @@ class FakeAlincoSerial:
"""Zero the mmap before an upload"""
self.image = memmap.MemoryMapBytes(b'\x00' * len(self.image))
+ def _handle_rw_dr735tn(self, data):
+ if b'R' in data:
+ addr_idx = data.index(b'R')-4
+ elif b'W' in data:
+ addr_idx = data.index(b'W')-4
+ else:
+ raise Exception('Unable to handle RW command %r' % data)
+ addr = int(data[addr_idx: addr_idx+4], 16)
+ cmd = chr(data[addr_idx+4])
+
+ if cmd == 'R':
+ bin_chunk = self.image[addr:addr+64]
+ hex_chunk = binascii.hexlify(bin_chunk)
+ assert (len(hex_chunk) == 128)
+ self.readbuf.append(hex_chunk)
+ self.readbuf.append(b'\r\n')
+
+ if cmd == 'W':
+ hex_chunk = data[addr_idx+5:addr_idx+128+5].decode()
+ bin_chunk = binascii.unhexlify(hex_chunk)
+ self.image[addr] = bin_chunk
+ self.readbuf.append(b'OK\r\n')
+
def _handle_rw(self, data):
if b'R' in data:
cmdindex = data.index(b'R')
@@ -87,8 +110,23 @@ class FakeAlincoSerial:
self.readbuf.append(ident_ack)
elif data.startswith(b'AL~F'):
self._handle_rw(data)
- elif data.startswith(b'AL~E'):
+ elif data.startswith(b'AL~E') and self.ident != b"DR735TN":
self.readbuf.append(b'OK' * 10)
+ elif data.startswith(b'AL~WHO'):
+ # radio responds with model to WHO
+ self.ident = b"DR735TN"
+ # expect back "DR735TN\r\nOK\r\n"
+ self.readbuf.append(self.ident+b"\r\n")
+ elif data.startswith(b'AL~DR735J'):
+ # this is somehow making the radio writeable...
+ self.readbuf.append(b'OK\r\n')
+
+ elif data.startswith(b'AL~RESET') and self.ident == b"DR735TN":
+ self.readbuf.append(b'OK\r\n')
+
+ elif data.startswith(b'AL~EEPEL'):
+ self._handle_rw_dr735tn(data)
+
else:
raise Exception('Unable to handle %r' % data)
@@ -134,6 +172,9 @@ class AlincoCloneTest(unittest.TestCase):
def test_dr235(self):
self._test_alinco(alinco.DR235Radio)
+ def test_dr735(self):
+ self._test_alinco(alinco_dr735t.AlincoDR735T)
+
def test_dj175(self):
# The 175 has a slightly different download string, so test it
# specifically
diff --git a/tests/unit/test_bitwise.py b/tests/unit/test_bitwise.py
index 9f40dcc..3ace170 100644
--- a/tests/unit/test_bitwise.py
+++ b/tests/unit/test_bitwise.py
@@ -192,6 +192,16 @@ class TestBitType(BaseTest):
obj.foo[i] = i % 2
self.assertEqual(data.get_packed(), b"\x55\x55\x55")
+ def test_lbit_array(self):
+ defn = "lbit foo[24];"
+ data = memmap.MemoryMapBytes(bytes(b"\x00\x20\x80"))
+ obj = bitwise.parse(defn, data)
+ for i, v in [(0, False), (13, True), (23, True)]:
+ self.assertEqual(bool(obj.foo[i]), v)
+ for i in range(0, 24):
+ obj.foo[i] = i % 2
+ self.assertEqual(data.get_packed(), b"\xAA\xAA\xAA")
+
def test_bit_array_fail(self):
self.assertRaises(ValueError, bitwise.parse, "bit foo[23];", b"000")
diff --git a/tests/unit/test_chirp_common.py b/tests/unit/test_chirp_common.py
index d0f22f9..9fe90ff 100644
--- a/tests/unit/test_chirp_common.py
+++ b/tests/unit/test_chirp_common.py
@@ -765,6 +765,7 @@ class TestOverrideRules(base.BaseTest):
'Retevis_RB17P',
'Baofeng_UV-17ProGPS',
'Baofeng_5RM',
+ 'Baofeng_K5-Plus',
]
def _test_radio_override_immutable_policy(self, rclass):
diff --git a/tests/unit/test_wxui_radiothread.py b/tests/unit/test_wxui_radiothread.py
index 1088b81..aedd7c8 100644
--- a/tests/unit/test_wxui_radiothread.py
+++ b/tests/unit/test_wxui_radiothread.py
@@ -1,7 +1,10 @@
+import os
import sys
import time
from unittest import mock
+import ddt
+
sys.modules['wx'] = wx = mock.MagicMock()
sys.modules['wx.lib'] = mock.MagicMock()
sys.modules['wx.lib.scrolledpanel'] = mock.MagicMock()
@@ -14,6 +17,7 @@ sys.modules['chirp.wxui.developer'] = mock.MagicMock()
# wx to be present for these tests
from tests.unit import base # noqa
from chirp.wxui import clone # noqa
+from chirp.wxui import config # noqa
from chirp.wxui import radiothread # noqa
@@ -151,3 +155,71 @@ class TestClone(base.BaseTest):
'COM17: Some other device'],
[clone.port_label(p)
for p in sorted(ports, key=clone.port_sort_key)])
+
+
+class TestException(Exception):
+ pass
+
+
+@ddt.ddt
+class TestStartup(base.BaseTest):
+ def setUp(self):
+ super().setUp()
+ self.use(mock.patch('os.path'))
+ self.use(mock.patch('os.makedirs'))
+ self.use(mock.patch('chirp.wxui.CONF'))
+ self.args = mock.MagicMock()
+ self.args.install_desktop_app = False
+ self.args.no_install_desktop_app = False
+ from chirp.wxui import maybe_install_desktop, CONF
+ self.maybe_install_desktop = maybe_install_desktop
+ self.conf = CONF
+
+ @ddt.data(
+ # No arguments, no file, no previous, answer no
+ [False, False, False, False, False],
+ # No arguments, no file, no previous, answer yes
+ [False, False, False, False, True],
+ # No arguments, no file, previous yes, no prompt
+ [False, False, False, True, None],
+ # No arguments, exists, previous no, no prompt
+ [False, False, True, False, None],
+ # Opt out, no file, no prompt
+ [False, True, False, None, None],
+ # Opt in, no file, previous yes, still prompt
+ [True, False, False, True, True],
+ # Opt in, exists, previous no, no prompt'),
+ [True, False, True, False, None],
+ )
+ @ddt.unpack
+ def test_linux_desktop_file(self, optin, optout, exists, last, answ):
+ self.args.install_desktop_app = optin
+ self.args.no_install_desktop_app = optout
+ os.path.exists.return_value = exists
+ self.conf.get_bool.return_value = last
+ wx.MessageBox.return_value = wx.YES if answ else wx.NO
+ os.makedirs.side_effect = TestException
+ wx.MessageBox.reset_mock()
+
+ if answ is True:
+ # If we made it through all the checks, and thus prompted the user,
+ # make sure we get to the makedirs part if expected
+ self.assertRaises(TestException,
+ self.maybe_install_desktop, self.args)
+ elif answ is False:
+ # If we were supposed to make it to the prompt but answer no,
+ # make sure we did
+ self.maybe_install_desktop(self.args)
+ self.assertFalse(os.makedirs.called)
+ self.assertTrue(wx.MessageBox.called)
+ else:
+ # If we were not supposed to make it to the prompt, make sure we
+ # didn't, nor did we do any create actions
+ self.maybe_install_desktop(self.args)
+ self.assertFalse(os.makedirs.called)
+ self.assertFalse(wx.MessageBox.called)
+
+ def test_linux_desktop_file_exists(self):
+ os.path.exists.return_value = True
+ self.maybe_install_desktop(self.args)
+ self.assertFalse(os.makedirs.called)
diff --git a/tools/cpep8.manifest b/tools/cpep8.manifest
index 4722d1f..b4f1142 100644
--- a/tools/cpep8.manifest
+++ b/tools/cpep8.manifest
@@ -23,7 +23,6 @@
./chirp/drivers/generic_csv.py
./chirp/drivers/gmrsv2.py
./chirp/drivers/h777.py
-./chirp/drivers/ic2730.py
./chirp/drivers/icf.py
./chirp/drivers/icomciv.py
./chirp/drivers/iradio_uv_5118.py
diff --git a/tools/experttune.py b/tools/experttune.py
new file mode 100644
index 0000000..326184e
--- /dev/null
+++ b/tools/experttune.py
@@ -0,0 +1,379 @@
+#!/bin/env python3
+
+import argparse
+import contextlib
+import logging
+import random
+import serial
+import time
+import sys
+
+from chirp import bitwise
+from chirp.drivers import icomciv
+from chirp import memmap
+
+LOG = logging.getLogger()
+
+# Note these are only the frequencies from the chart that fit into the
+# US band edges.
+BANDS = {
+ 160: [i for i in range(1805, 2005, 20)],
+ 80: [i for i in range(3510, 4010, 10)],
+ 40: [i for i in range(7013, 7313, 25)],
+ 30: [10125],
+ 20: [i for i in range(14025, 14325, 50)],
+ 17: [18075, 18125, 18165],
+ 15: [i for i in range(21025, 21475, 50)],
+ 12: [24891, 24963],
+ 10: [i for i in range(28050, 29750, 100)],
+ 6: [i for i in range(50125, 54125, 250)],
+}
+
+
+class BitwiseFrame(icomciv.Frame):
+ _fmt = ''
+ _datalen = 0
+ _querycmd = None
+
+ def __init__(self):
+ super().__init__()
+ self._data = memmap.MemoryMapBytes(b'\x00' * self._datalen)
+ self.parse()
+
+ def parse(self):
+ self._obj = bitwise.parse(self._fmt, self._data)
+
+ @classmethod
+ def get(cls, radio):
+ f = icomciv.Frame()
+ f.set_command(cls._querycmd or cls._cmd, cls._sub)
+ radio._send_frame(f)
+ r = radio._recv_frame(frame=cls())
+ # If we used a different command to query, reset the received frame
+ # to the one we'd use for the setting
+ r._cmd = cls._cmd
+ return r
+
+
+class SetFreqFrame(BitwiseFrame):
+ _datalen = 5
+ _cmd = 0x05
+ _querycmd = 0x03
+ _sub = None
+ _fmt = 'lbcd freq[5];'
+
+ @property
+ def freq(self):
+ return self._obj.freq // 1000
+
+ @freq.setter
+ def freq(self, khz):
+ self._obj.freq = khz * 1000
+
+
+class SetModeFrame(BitwiseFrame):
+ _datalen = 2
+ _cmd = 0x06
+ _querycmd = 0x04
+ _sub = None
+ _fmt = 'u8 mode; u8 filter;'
+ _modes = [
+ ('LSB', 0),
+ ('USB', 1),
+ ('AM', 2),
+ ('CW', 3),
+ ('RTTY', 4),
+ ('FM', 5),
+ ('CW-R', 7),
+ ('RTTY-R', 8),
+ ('PSK', 12),
+ ('PSK-R', 17),
+ ]
+
+ @property
+ def mode(self):
+ for mode, index in self._modes:
+ if index == self._obj.mode:
+ return mode
+ raise RuntimeError('Unsupported mode %i' % self._obj.mode)
+
+ @mode.setter
+ def mode(self, mode):
+ self._obj.filter = 1
+ for m, index in self._modes:
+ if mode == m:
+ self._obj.mode = index
+ return
+ raise RuntimeError('Unsupported mode %s' % mode)
+
+ @property
+ def filter(self):
+ return int(self._obj.filter)
+
+
+class BKINFrame(BitwiseFrame):
+ _datalen = 1
+ _cmd = 0x16
+ _sub = 0x47
+ _fmt = 'u8 mode;'
+ _modes = ('off', 'semi', 'full')
+
+ @property
+ def mode(self):
+ return self._modes[self._obj.mode]
+
+ @mode.setter
+ def mode(self, mode):
+ self._obj.mode = self._modes.index(mode)
+
+
+class CWSpeedFrame(BitwiseFrame):
+ _datalen = 2
+ _cmd = 0x14
+ _sub = 0x0C
+ _fmt = 'bbcd speed[2];'
+
+ @property
+ def speed(self):
+ return 48 * self._obj.speed // 255
+
+ @speed.setter
+ def speed(self, wpm):
+ self._obj.speed = int((wpm / 48) * 255)
+
+
+class PowerFrame(BitwiseFrame):
+ _datalen = 2
+ _cmd = 0x15
+ _sub = 0x11
+ _fmt = 'bbcd power[2];'
+
+ @classmethod
+ def get(cls, radio):
+ f = icomciv.Frame()
+ f.set_command(cls._cmd, cls._sub)
+ radio._send_frame(f)
+ f = radio._recv_frame(frame=cls())
+ f.parse()
+ return f
+
+ @property
+ def power(self):
+ return int(100 * int(self._obj.power) / 212)
+
+ @power.setter
+ def power(self, power):
+ self._obj.power = 212 * (power / 100)
+
+
+class Demo:
+ def __init__(self, s=None):
+ self._last_command = 0
+
+ def _send_frame(self, f):
+ self._last_command = f._cmd
+
+ def _recv_frame(self, frame=None):
+ if frame is None:
+ frame = PowerFrame()
+ if self._last_command == 0x15:
+ frame.power = random.randint(0, 10) * 10
+ else:
+ frame.set_command(0xFB, None)
+ return frame
+
+
+def setup(port, rcls):
+ LOG.debug('Connecting to %s' % port)
+ s = serial.Serial(port, timeout=1)
+ LOG.debug('Starting radio')
+ radio = rcls(s)
+ LOG.debug('Detecting baudrate')
+ radio._detect_baudrate()
+ LOG.debug('Connected')
+ return radio
+
+
+def set_freq(radio, khz, mode):
+ f = SetFreqFrame()
+ f.freq = khz
+ radio._send_frame(f)
+ r = radio._recv_frame()
+ assert r._cmd == 0xFB
+ LOG.debug('Set frequency to %i kHz', khz)
+
+ f = SetModeFrame()
+ f.mode = mode
+ radio._send_frame(f)
+ r = radio._recv_frame()
+ assert r._cmd == 0xFB
+ LOG.debug('Set mode to %s', mode)
+
+
+def interactive_next(current):
+ print()
+ print('Options:')
+ print('r: Retry this frequency')
+ print('x: Exit immediately')
+ print('[enter]: Continue to the next frequency')
+ i = input('> ').lower()
+ if i == '':
+ return True
+ elif i == 'r':
+ return False
+ elif i == 'x':
+ raise RuntimeError('Abort')
+
+
+def auto_next(current):
+ print()
+ return True
+
+
+def send_id(radio, call):
+ f = SetModeFrame()
+ f.mode = 'CW'
+ radio._send_frame(f)
+ r = radio._recv_frame()
+ assert r._cmd == 0xFB
+ LOG.debug('Set mode to CW')
+
+ f = BKINFrame()
+ f.mode = 'full'
+ radio._send_frame(f)
+ r = radio._recv_frame()
+ assert r._cmd == 0xFB
+ LOG.debug('Set BK-IN to full')
+
+ f = CWSpeedFrame()
+ f.speed = 22
+ radio._send_frame(f)
+ r = radio._recv_frame()
+ assert r._cmd == 0xFB
+ LOG.debug('Set key speed to 22WPM')
+
+ f = icomciv.Frame()
+ f.set_command(0x17, 0x40)
+ f.set_data(b'DE %s' % call.upper().encode())
+ radio._send_frame(f)
+ r = radio._recv_frame()
+ if r._cmd != 0xFB:
+ print('Radio does not support CWID - ID manually now')
+ else:
+ print('Sending id %s' % call)
+ time.sleep(len(call) + 2)
+ LOG.debug('Sent ID')
+
+
+def wait_for_power(radio, fn):
+ po = None
+ maxl = 0
+ while po is None or not fn(po):
+ po = PowerFrame.get(radio).power
+ line = sys.stdout.write('Po: |%-10s| %3iW\r' % ('=' * (po // 10), po))
+ maxl = max(maxl, line)
+ time.sleep(0.5)
+ sys.stdout.write('%s\r' % (' ' * maxl))
+
+
+def wait_for_tune(radio):
+ print('Transmit to tune now (waiting for key)')
+ wait_for_power(radio, lambda po: po > 0)
+ print('Keyed, waiting for completion')
+ wait_for_power(radio, lambda po: po == 0)
+ print('Done')
+
+
+@contextlib.contextmanager
+def restore_settings(radio):
+ if not isinstance(radio, Demo):
+ settings = [
+ SetModeFrame.get(radio),
+ SetFreqFrame.get(radio),
+ BKINFrame.get(radio),
+ CWSpeedFrame.get(radio),
+ ]
+ else:
+ settings = []
+ try:
+ yield
+ finally:
+ LOG.debug('Restoring previous settings')
+ for f in settings:
+ radio._send_frame(f)
+ radio._recv_frame()
+
+
+def tune_loop(radio, bands, call, next_fn):
+ for band in bands:
+ for freq in BANDS[band]:
+ done = False
+ while not done:
+ print('Changing to %i kHz' % freq)
+ set_freq(radio, freq, 'RTTY')
+ time.sleep(1)
+
+ wait_for_tune(radio)
+ time.sleep(2)
+ if call:
+ send_id(radio, call)
+
+ try:
+ done = next_fn(freq)
+ except RuntimeError:
+ return 0
+
+
+def main():
+ # More of these may work, but these are known to work
+ radios = {
+ '7200': icomciv.Icom7200Radio,
+ '7300': icomciv.Icom7300Radio,
+ '7610': icomciv.Icom7610Radio,
+ 'Demo': Demo,
+ }
+
+ p = argparse.ArgumentParser(description=(
+ 'A simple tool to automate running through the required frequencies '
+ 'to tune an SPE Expert linear.'))
+ p.add_argument('radio', choices=radios,
+ help='Radio model')
+ p.add_argument('port', help='Serial port for CAT control')
+ p.add_argument('--bands', help=('Comma-separated list of bands '
+ 'to tune (160, 80, etc)'))
+ p.add_argument('--call', help='Callsign for CW ID after each step')
+ p.add_argument('--next',
+ choices=['interactive', 'auto'],
+ default='interactive',
+ help='Next step strategy')
+ p.add_argument('--debug', action='store_true',
+ help='Enable verbose debugging')
+ args = p.parse_args()
+
+ logging.basicConfig(level=logging.DEBUG if args.debug else logging.INFO)
+
+ next_fn = globals()['%s_next' % args.next]
+
+ try:
+ bands = [int(i) for i in args.bands.split(',')]
+ for band in bands:
+ assert band in BANDS
+ except (ValueError, AssertionError):
+ print('Invalid band input. Must be one or more of %s' % (
+ ','.join(str(i) for i in BANDS.keys())))
+ return 1
+
+ if args.radio == 'Demo':
+ radio = Demo()
+ else:
+ radio = setup(args.port, radios[args.radio])
+
+ with restore_settings(radio):
+ tune_loop(radio, bands, args.call, next_fn)
+
+
+if __name__ == '__main__':
+ try:
+ sys.exit(main())
+ except KeyboardInterrupt:
+ pass