summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Hibberd <hibby@debian.org>2024-02-24 13:47:27 +0000
committerDave Hibberd <hibby@debian.org>2024-02-24 13:47:27 +0000
commitfc438e6a84402e621877f6c30097442af46f122b (patch)
tree7a6ca4af4159368f92d10c6c932c4b5e662715aa
parent99bce70f3ca5cea0eb28f5158cfa00803cf6a19a (diff)
New upstream version 20240224upstream/20240224
-rw-r--r--PKG-INFO3
-rw-r--r--chirp.egg-info/PKG-INFO3
-rw-r--r--chirp.egg-info/SOURCES.txt9
-rw-r--r--chirp.egg-info/requires.txt1
-rw-r--r--chirp/__init__.py2
-rw-r--r--chirp/bandplan_au.py10
-rw-r--r--chirp/bandplan_iaru_r1.py4
-rw-r--r--chirp/bandplan_iaru_r2.py4
-rw-r--r--chirp/bandplan_iaru_r3.py6
-rw-r--r--chirp/bandplan_na.py10
-rw-r--r--chirp/bitwise.py175
-rw-r--r--chirp/bitwise_grammar.py3
-rw-r--r--chirp/chirp_common.py45
-rw-r--r--chirp/directory.py30
-rw-r--r--chirp/drivers/__init__.py9
-rw-r--r--chirp/drivers/anytone_ht.py4
-rw-r--r--chirp/drivers/anytone_iii.py8
-rw-r--r--chirp/drivers/baofeng_common.py19
-rw-r--r--chirp/drivers/baofeng_uv17.py78
-rw-r--r--chirp/drivers/baofeng_uv17Pro.py404
-rw-r--r--chirp/drivers/baofeng_wp970i.py38
-rw-r--r--chirp/drivers/bj9900.py52
-rw-r--r--chirp/drivers/bjuv55.py24
-rw-r--r--chirp/drivers/btech.py34
-rw-r--r--chirp/drivers/fake.py65
-rw-r--r--chirp/drivers/ft1d.py78
-rw-r--r--chirp/drivers/ft450d.py4
-rw-r--r--chirp/drivers/generic_csv.py32
-rw-r--r--chirp/drivers/gmrsuv1.py14
-rw-r--r--chirp/drivers/gmrsv2.py18
-rw-r--r--chirp/drivers/hg_uv98.py39
-rw-r--r--chirp/drivers/icv80.py10
-rw-r--r--chirp/drivers/id880.py2
-rw-r--r--chirp/drivers/iradio_uv_5118plus.py6
-rw-r--r--chirp/drivers/kenwood_hmk.py4
-rw-r--r--chirp/drivers/kenwood_itm.py4
-rw-r--r--chirp/drivers/kg935g.py46
-rw-r--r--chirp/drivers/kguv980p.py133
-rw-r--r--chirp/drivers/kguv9dplus.py44
-rw-r--r--chirp/drivers/kyd.py11
-rw-r--r--chirp/drivers/kyd_IP620.py20
-rw-r--r--chirp/drivers/leixen.py147
-rw-r--r--chirp/drivers/mml_jc8810.py50
-rw-r--r--chirp/drivers/puxing_px888k.py4
-rw-r--r--chirp/drivers/radioddity_r2.py2
-rw-r--r--chirp/drivers/radtel_rt490.py8
-rw-r--r--chirp/drivers/retevis_rb15.py11
-rw-r--r--chirp/drivers/retevis_rb17p.py52
-rw-r--r--chirp/drivers/retevis_rb28.py19
-rw-r--r--chirp/drivers/retevis_rt1.py7
-rw-r--r--chirp/drivers/retevis_rt21.py7
-rw-r--r--chirp/drivers/retevis_rt22.py5
-rw-r--r--chirp/drivers/retevis_rt26.py7
-rw-r--r--chirp/drivers/th7800.py2
-rw-r--r--chirp/drivers/th_uv8000.py6
-rw-r--r--chirp/drivers/th_uv88.py157
-rw-r--r--chirp/drivers/th_uvf8d.py2
-rw-r--r--chirp/drivers/thd72.py71
-rw-r--r--chirp/drivers/thd74.py27
-rw-r--r--chirp/drivers/tk3140.py2
-rw-r--r--chirp/drivers/tk760g.py4
-rw-r--r--chirp/drivers/tk8180.py14
-rw-r--r--chirp/drivers/tmd710.py1692
-rw-r--r--chirp/drivers/uv5r.py200
-rw-r--r--chirp/drivers/uv5x3.py31
-rw-r--r--chirp/drivers/uv6r.py18
-rw-r--r--chirp/drivers/uvk5.py517
-rw-r--r--chirp/drivers/uvk5_egzumer.py1725
-rw-r--r--chirp/drivers/vx6.py3
-rw-r--r--chirp/drivers/wouxun.py26
-rw-r--r--chirp/locale/de/LC_MESSAGES/CHIRP.mobin1540 -> 1486 bytes
-rw-r--r--chirp/locale/es/LC_MESSAGES/CHIRP.mobin70259 -> 74488 bytes
-rw-r--r--chirp/locale/fr/LC_MESSAGES/CHIRP.mobin30577 -> 30539 bytes
-rw-r--r--chirp/locale/hu/LC_MESSAGES/CHIRP.mobin1567 -> 1510 bytes
-rw-r--r--chirp/locale/it/LC_MESSAGES/CHIRP.mobin15513 -> 15459 bytes
-rw-r--r--chirp/locale/ja_JP/LC_MESSAGES/CHIRP.mobin12214 -> 15101 bytes
-rw-r--r--chirp/locale/pl/LC_MESSAGES/CHIRP.mobin22970 -> 22928 bytes
-rw-r--r--chirp/locale/ru/LC_MESSAGES/CHIRP.mobin85433 -> 85384 bytes
-rw-r--r--chirp/locale/tr_TR/LC_MESSAGES/CHIRP.mobin67620 -> 67581 bytes
-rw-r--r--chirp/locale/zh_CN/LC_MESSAGES/CHIRP.mobin1538 -> 9634 bytes
-rw-r--r--chirp/logger.py27
-rw-r--r--chirp/settings.py80
-rw-r--r--chirp/share/chirp-logo.pngbin0 -> 459863 bytes
-rw-r--r--chirp/share/chirp.pngbin459863 -> 262950 bytes
-rw-r--r--chirp/share/welcome_screen.pngbin25877 -> 30104 bytes
-rw-r--r--chirp/stock_configs/GR Marine VHF Channels.csv58
-rw-r--r--chirp/stock_configs/US Marine VHF Channels.csv112
-rw-r--r--chirp/wxui/clone.py79
-rw-r--r--chirp/wxui/common.py110
-rw-r--r--chirp/wxui/fips.py2
-rw-r--r--chirp/wxui/main.py187
-rw-r--r--chirp/wxui/memedit.py74
-rw-r--r--chirp/wxui/query_sources.py9
-rw-r--r--chirp/wxui/radioinfo.py21
-rw-r--r--chirp/wxui/settingsedit.py31
-rw-r--r--requirements.txt1
-rw-r--r--setup.py3
-rw-r--r--tests/Python3_Driver_Testing.md19
-rw-r--r--tests/__pycache__/test_detect.cpython-310-pytest-7.1.3.pycbin1952 -> 2193 bytes
-rw-r--r--tests/__pycache__/test_edges.cpython-310-pytest-7.1.3.pycbin6940 -> 7389 bytes
-rw-r--r--tests/images/BTECH_UV-25X2.imgbin16384 -> 16557 bytes
-rw-r--r--tests/images/BTECH_UV-50X2.imgbin16384 -> 16557 bytes
-rw-r--r--tests/images/BTECH_UV-5X3.imgbin8206 -> 8375 bytes
-rw-r--r--tests/images/Baofeng_5RM.imgbin33849 -> 33849 bytes
-rw-r--r--tests/images/Baofeng_UV-13Pro.imgbin0 -> 37041 bytes
-rw-r--r--tests/images/Kenwood_TH-D75.imgbin0 -> 500669 bytes
-rw-r--r--tests/images/Leixen_VV-898S.imgbin8192 -> 8381 bytes
-rw-r--r--tests/images/Quansheng_UV-K5.imgbin8361 -> 8425 bytes
-rw-r--r--tests/images/Quansheng_UV-K5_egzumer.imgbin0 -> 8437 bytes
-rw-r--r--tests/images/Retevis_RA79.imgbin8365 -> 8421 bytes
-rw-r--r--tests/images/Talkpod_A36plus_8w.imgbin0 -> 46341 bytes
-rw-r--r--tests/py3_driver_testers.txt6
-rw-r--r--tests/test_brute_force.py3
-rw-r--r--tests/test_detect.py7
-rw-r--r--tests/test_edges.py7
-rw-r--r--tests/unit/__pycache__/test_bitwise.cpython-310-pytest-7.1.3.pycbin13846 -> 15690 bytes
-rw-r--r--tests/unit/__pycache__/test_chirp_common.cpython-310-pytest-7.1.3.pycbin31324 -> 31358 bytes
-rw-r--r--tests/unit/__pycache__/test_csv.cpython-310-pytest-7.1.3.pycbin6717 -> 7624 bytes
-rw-r--r--tests/unit/__pycache__/test_logger.cpython-310-pytest-7.1.3.pycbin0 -> 1330 bytes
-rw-r--r--tests/unit/__pycache__/test_settings.cpython-310-pytest-7.1.3.pycbin7332 -> 7767 bytes
-rw-r--r--tests/unit/test_bitwise.py77
-rw-r--r--tests/unit/test_chirp_common.py4
-rw-r--r--tests/unit/test_csv.py18
-rw-r--r--tests/unit/test_logger.py38
-rw-r--r--tests/unit/test_settings.py16
-rwxr-xr-xtools/check_commit.sh8
126 files changed, 4987 insertions, 2331 deletions
diff --git a/PKG-INFO b/PKG-INFO
index 2e7d530..4c0022e 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: chirp
-Version: 20240122
+Version: 20240224
Summary: A cross-platform cross-radio programming tool
Home-page: https://chirp.danplanet.com
Requires-Python: >=3.7,<4
@@ -8,7 +8,6 @@ License-File: COPYING
Requires-Dist: pyserial
Requires-Dist: requests
Requires-Dist: six
-Requires-Dist: future
Requires-Dist: importlib-resources; python_version < "3.10"
Requires-Dist: yattag
Provides-Extra: wx
diff --git a/chirp.egg-info/PKG-INFO b/chirp.egg-info/PKG-INFO
index 2e7d530..4c0022e 100644
--- a/chirp.egg-info/PKG-INFO
+++ b/chirp.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: chirp
-Version: 20240122
+Version: 20240224
Summary: A cross-platform cross-radio programming tool
Home-page: https://chirp.danplanet.com
Requires-Python: >=3.7,<4
@@ -8,7 +8,6 @@ License-File: COPYING
Requires-Dist: pyserial
Requires-Dist: requests
Requires-Dist: six
-Requires-Dist: future
Requires-Dist: importlib-resources; python_version < "3.10"
Requires-Dist: yattag
Provides-Extra: wx
diff --git a/chirp.egg-info/SOURCES.txt b/chirp.egg-info/SOURCES.txt
index 9e4ab7d..9599a98 100644
--- a/chirp.egg-info/SOURCES.txt
+++ b/chirp.egg-info/SOURCES.txt
@@ -185,6 +185,7 @@ chirp/drivers/uv5x3.py
chirp/drivers/uv6r.py
chirp/drivers/uvb5.py
chirp/drivers/uvk5.py
+chirp/drivers/uvk5_egzumer.py
chirp/drivers/vgc.py
chirp/drivers/vx170.py
chirp/drivers/vx2.py
@@ -213,6 +214,7 @@ chirp/locale/ru/LC_MESSAGES/CHIRP.mo
chirp/locale/tr_TR/LC_MESSAGES/CHIRP.mo
chirp/locale/uk_UA/LC_MESSAGES/CHIRP.mo
chirp/locale/zh_CN/LC_MESSAGES/CHIRP.mo
+chirp/share/chirp-logo.png
chirp/share/chirp.desktop
chirp/share/chirp.ico
chirp/share/chirp.png
@@ -230,6 +232,7 @@ chirp/stock_configs/AU NZ UHF Citizens Band.csv
chirp/stock_configs/DE Freenet Frequencies.csv
chirp/stock_configs/EU LPD and PMR Channels.csv
chirp/stock_configs/FR Marine VHF Channels.csv
+chirp/stock_configs/GR Marine VHF Channels.csv
chirp/stock_configs/PL Calling Frequencies and Simplex.csv
chirp/stock_configs/SE Jaktradio 155MHz.csv
chirp/stock_configs/SE NO KDR444.csv
@@ -332,6 +335,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_UV-13Pro.img
tests/images/Baofeng_UV-17.img
tests/images/Baofeng_UV-17Pro.img
tests/images/Baofeng_UV-17ProGPS.img
@@ -387,6 +391,7 @@ tests/images/KYD_NC-630A.img
tests/images/Kenwood_HMK.hmk
tests/images/Kenwood_TH-D72_clone_mode.img
tests/images/Kenwood_TH-D74_clone_mode.img
+tests/images/Kenwood_TH-D75.img
tests/images/Kenwood_TK-272G.img
tests/images/Kenwood_TK-3140K.img
tests/images/Kenwood_TK-3180K2.img
@@ -417,6 +422,7 @@ tests/images/QYT_KT7900D.img
tests/images/QYT_KT8900D.img
tests/images/Quansheng_TG-UV2+.img
tests/images/Quansheng_UV-K5.img
+tests/images/Quansheng_UV-K5_egzumer.img
tests/images/Radioddity_GA-510.img
tests/images/Radioddity_GS-5B.img
tests/images/Radioddity_R2.img
@@ -508,6 +514,7 @@ tests/images/TYT_TH-UVF1.img
tests/images/TYT_TH-UVF8D.img
tests/images/TYT_TH9000_144.img
tests/images/Talkpod_A36plus.img
+tests/images/Talkpod_A36plus_8w.img
tests/images/Vertex_Standard_FTL-2011.img
tests/images/Vertex_Standard_VXA-700.img
tests/images/WACCOM_MINI-8900.img
@@ -587,6 +594,7 @@ tests/unit/test_icom_clone.py
tests/unit/test_import_logic.py
tests/unit/test_kguv8d.py
tests/unit/test_kguv920.py
+tests/unit/test_logger.py
tests/unit/test_mappingmodel.py
tests/unit/test_network_sources.py
tests/unit/test_repeaterbook.py
@@ -610,6 +618,7 @@ tests/unit/__pycache__/test_icom_clone.cpython-310-pytest-7.1.3.pyc
tests/unit/__pycache__/test_import_logic.cpython-310-pytest-7.1.3.pyc
tests/unit/__pycache__/test_kguv8d.cpython-310-pytest-7.1.3.pyc
tests/unit/__pycache__/test_kguv920.cpython-310-pytest-7.1.3.pyc
+tests/unit/__pycache__/test_logger.cpython-310-pytest-7.1.3.pyc
tests/unit/__pycache__/test_mappingmodel.cpython-310-pytest-7.1.3.pyc
tests/unit/__pycache__/test_network_sources.cpython-310-pytest-7.1.3.pyc
tests/unit/__pycache__/test_repeaterbook.cpython-310-pytest-7.1.3.pyc
diff --git a/chirp.egg-info/requires.txt b/chirp.egg-info/requires.txt
index 03fb3aa..1c9b3d4 100644
--- a/chirp.egg-info/requires.txt
+++ b/chirp.egg-info/requires.txt
@@ -1,7 +1,6 @@
pyserial
requests
six
-future
yattag
[:python_version < "3.10"]
diff --git a/chirp/__init__.py b/chirp/__init__.py
index fc64372..5c8905b 100644
--- a/chirp/__init__.py
+++ b/chirp/__init__.py
@@ -1 +1 @@
-CHIRP_VERSION = "next-20240122"
+CHIRP_VERSION = "next-20240224"
diff --git a/chirp/bandplan_au.py b/chirp/bandplan_au.py
index 9f4ba50..7a9fc0d 100644
--- a/chirp/bandplan_au.py
+++ b/chirp/bandplan_au.py
@@ -108,8 +108,8 @@ BANDS_6CM = (
mode="FM", step_khz=100),
)
-BANDS = bandplan_iaru_r3.BANDS_20M + bandplan_iaru_r3.BANDS_17M
-BANDS += bandplan_iaru_r3.BANDS_15M + bandplan_iaru_r3.BANDS_12M
-BANDS += bandplan_iaru_r3.BANDS_10M + bandplan_iaru_r3.BANDS_6M
-BANDS += BANDS_10M + BANDS_6M + BANDS_2M + BANDS_70CM + BANDS_23CM
-BANDS += BANDS_13CM + BANDS_9CM + BANDS_6CM
+BANDS = bandplan_iaru_r3.BANDS_20M + bandplan_iaru_r3.BANDS_17M + \
+ bandplan_iaru_r3.BANDS_15M + bandplan_iaru_r3.BANDS_12M + \
+ bandplan_iaru_r3.BANDS_10M + bandplan_iaru_r3.BANDS_6M + \
+ BANDS_10M + BANDS_6M + BANDS_2M + BANDS_70CM + BANDS_23CM + \
+ BANDS_13CM + BANDS_9CM + BANDS_6CM
diff --git a/chirp/bandplan_iaru_r1.py b/chirp/bandplan_iaru_r1.py
index c0f39ae..46bd275 100644
--- a/chirp/bandplan_iaru_r1.py
+++ b/chirp/bandplan_iaru_r1.py
@@ -143,8 +143,8 @@ BANDS_10M = (
bandplan.Band((29520000, 29700000), "Wide band", step_khz=10, mode="NFM"),
)
-BANDS = BANDS_2100M + BANDS_160M + BANDS_80M + BANDS_40M + BANDS_30M
-BANDS = BANDS + BANDS_20M + BANDS_17M + BANDS_15M + BANDS_12M + BANDS_10M
+BANDS = BANDS_2100M + BANDS_160M + BANDS_80M + BANDS_40M + BANDS_30M + \
+ BANDS_20M + BANDS_17M + BANDS_15M + BANDS_12M + BANDS_10M
# EU Analogue/DMR PMR446 Frequencies
diff --git a/chirp/bandplan_iaru_r2.py b/chirp/bandplan_iaru_r2.py
index 5886187..dfcd98f 100644
--- a/chirp/bandplan_iaru_r2.py
+++ b/chirp/bandplan_iaru_r2.py
@@ -141,5 +141,5 @@ BANDS_10M = (
bandplan.Band((29620000, 29690000), "FM Repeaters", input_offset=-100000),
)
-BANDS = BANDS_160M + BANDS_80M + BANDS_40M + BANDS_30M + BANDS_20M
-BANDS = BANDS + BANDS_17M + BANDS_15M + BANDS_12M + BANDS_10M
+BANDS = BANDS_160M + BANDS_80M + BANDS_40M + BANDS_30M + BANDS_20M + \
+ BANDS_17M + BANDS_15M + BANDS_12M + BANDS_10M
diff --git a/chirp/bandplan_iaru_r3.py b/chirp/bandplan_iaru_r3.py
index 582bd8a..d4dabd6 100644
--- a/chirp/bandplan_iaru_r3.py
+++ b/chirp/bandplan_iaru_r3.py
@@ -134,6 +134,6 @@ BANDS_23CM = (
bandplan.Band((1296000000, 1297000000), "Earth Moon Earth"),
)
-BANDS = BANDS_2100M + BANDS_160M + BANDS_80M + BANDS_40M + BANDS_30M
-BANDS = BANDS + BANDS_20M + BANDS_17M + BANDS_15M + BANDS_12M + BANDS_10M
-BANDS = BANDS + BANDS_6M + BANDS_2M + BANDS_70CM + BANDS_23CM
+BANDS = BANDS_2100M + BANDS_160M + BANDS_80M + BANDS_40M + BANDS_30M + \
+ BANDS_20M + BANDS_17M + BANDS_15M + BANDS_12M + BANDS_10M + \
+ BANDS_6M + BANDS_2M + BANDS_70CM + BANDS_23CM
diff --git a/chirp/bandplan_na.py b/chirp/bandplan_na.py
index ba32aa5..a1f7ea6 100644
--- a/chirp/bandplan_na.py
+++ b/chirp/bandplan_na.py
@@ -263,11 +263,11 @@ BANDS_13CM = (
bandplan.Band((2410000000, 2450000000), "Broadband Modes, 22 MHz max."),
)
-BANDS = bandplan_iaru_r2.BANDS
-BANDS += BANDS_160M + BANDS_80M + BANDS_40M + BANDS_30M + BANDS_20M
-BANDS += BANDS_17M + BANDS_15M + BANDS_12M + BANDS_10M + BANDS_6M
-BANDS += BANDS_2M + BANDS_1_25M + BANDS_70CM + BANDS_33CM + BANDS_23CM
-BANDS += BANDS_13CM
+BANDS = bandplan_iaru_r2.BANDS + \
+ BANDS_160M + BANDS_80M + BANDS_40M + BANDS_30M + BANDS_20M + \
+ BANDS_17M + BANDS_15M + BANDS_12M + BANDS_10M + BANDS_6M + \
+ BANDS_2M + BANDS_1_25M + BANDS_70CM + BANDS_33CM + BANDS_23CM + \
+ BANDS_13CM
# US 2017+ GMRS/FRS Frequencies
diff --git a/chirp/bitwise.py b/chirp/bitwise.py
index 98720a1..25e59d0 100644
--- a/chirp/bitwise.py
+++ b/chirp/bitwise.py
@@ -60,13 +60,13 @@
import struct
import os
import logging
+import re
import warnings
import six
from builtins import bytes
from chirp import bitwise_grammar
-from chirp.memmap import MemoryMap
LOG = logging.getLogger(__name__)
@@ -233,6 +233,42 @@ class DataElement:
data = string_straight_encode(data)
self._data[self._offset] = data[:self._size]
+ def get_path(self, path):
+ """Retrieve a child element starting from here by symbolic path.
+
+ Examples:
+ .mystruct.foo[2].field1
+ [3]
+ .bar
+ """
+ tok = re.search('[.[]', path)
+ if tok:
+ tok = tok.group(0)
+ if path.startswith('.'):
+ return self.get_path(path[1:])
+ elif path.startswith('['):
+ index, rest = path.split(']', 1)
+ index = int(index[1:])
+ return self[index].get_path(rest)
+ elif tok == '.':
+ field, rest = path.split('.', 1)
+ return getattr(self, field).get_path(rest)
+ elif tok == '[':
+ field, rest = path.split('[', 1)
+ return getattr(self, field).get_path('[' + rest)
+ elif path:
+ return getattr(self, path)
+ else:
+ return self
+
+ def fill_raw(self, byteval):
+ """Fill object with bytes
+
+ :param byteval: A bytes of length 1 to fill the object's memory with
+ """
+ assert isinstance(byteval, bytes) and len(byteval) == 1
+ self.set_raw(byteval * (self.size() // 8))
+
def __getattr__(self, name):
raise AttributeError("Unknown attribute %s in %s" % (name,
self.__class__))
@@ -270,6 +306,12 @@ class arrayDataElement(DataElement):
raw = [item.get_raw(asbytes=True) for item in self.__items]
return self._compat_bytes(bytes(b''.join(raw)), asbytes)
+ def set_raw(self, data):
+ item_size = self.__items[0].size() // 8
+ assert len(data) / item_size == len(self), 'Invalid raw data length'
+ for i in range(len(self)):
+ self[i].set_raw(data[i * item_size:(i + 1) * item_size])
+
def __setitem__(self, index, val):
self.__items[index].set_value(val)
@@ -765,6 +807,9 @@ class structDataElement(DataElement):
else:
return result
+ def __contains__(self, key):
+ return key in self._generators.keys()
+
def __getitem__(self, key):
return self._generators[key]
@@ -779,7 +824,10 @@ class structDataElement(DataElement):
try:
return self._generators[name]
except KeyError:
- raise AttributeError("No attribute %s in struct" % name)
+ LOG.error('Request for struct element %s not in %s' % (
+ name, self._generators.keys()))
+ raise AttributeError("No attribute %s in struct %s" % (
+ name, self._name))
def __setattr__(self, name, value):
if "_structDataElement__init" not in self.__dict__:
@@ -842,7 +890,7 @@ class Processor:
"bbcd": bbcdDataElement,
}
- def __init__(self, data, offset):
+ def __init__(self, data, offset, input):
if hasattr(data, 'get_byte_compatible'):
# bitwise uses the byte-compatible interface of MemoryMap,
# if that is what was passed in
@@ -851,17 +899,40 @@ class Processor:
self._offset = offset
self._obj = None
self._user_types = {}
+ self._input = input.split('\n')
def do_symbol(self, symdef, gen):
name = symdef[1]
self._generators[name] = gen
+ def get_source_line(self, lineno):
+ return self._input[lineno]
+
+ def get_line_from_sym(self, sym):
+ name = sym.__name__
+ if ':' in name.line:
+ _, num = name.line.split(':')
+ else:
+ num = 0
+ return int(num)
+
+ def get_line_sym(self, sym):
+ num = self.get_line_from_sym(sym)
+ return '%i: %s' % (num, self.get_source_line(num))
+
def do_bitfield(self, dtype, bitfield):
bytes = self._types[dtype](self._data, 0).size() // 8
bitsleft = bytes * 8
for _bitdef, defn in bitfield:
name = defn[0][1]
+ if name in self._generators:
+ newname = '%s_%06x' % (name, self._offset)
+ prevline = self._lines.get(name, 'unknown')
+ LOG.error('Duplicate definition for %s on line %s; '
+ 'renaming to %s (previous definition line %s)',
+ name, self.get_line_sym(defn[0]), newname, prevline)
+ name = newname
bits = int(defn[1][1])
if bitsleft < 0:
raise ParseError("Invalid bitfield spec")
@@ -872,11 +943,12 @@ class Processor:
_subgen = self._types[dtype]
self._generators[name] = bitDE(self._data, self._offset)
+ self._lines[name] = self.get_line_from_sym(defn[0])
bitsleft -= bits
if bitsleft:
LOG.warn("WARNING: %i trailing bits unaccounted for in %s" %
- (bitsleft, bitfield))
+ (bitsleft, name))
return bytes
@@ -906,6 +978,13 @@ class Processor:
sym = defn[1]
name = sym[1]
+ if name in self._generators:
+ newname = '%s_%06x' % (name, self._offset)
+ prevline = self._lines.get(name, 'unknown')
+ LOG.error('Duplicate definition for %s on line %s; '
+ 'renaming to %s (previous definition line %s)',
+ name, self.get_line_sym(sym), newname, prevline)
+ name = newname
res = arrayDataElement(self._offset)
size = 0
for i in range(0, count):
@@ -921,6 +1000,7 @@ class Processor:
self._generators[name] = res[0]
else:
self._generators[name] = res
+ self._lines[name] = self.get_line_from_sym(sym)
def parse_struct_decl(self, struct):
block = struct[:-1]
@@ -941,9 +1021,12 @@ class Processor:
name=name)
result.append(element)
tmp = self._generators
+ tmp_lines = self._lines
self._generators = element
+ self._lines = {}
self.parse_block(block)
self._generators = tmp
+ self._lines = tmp_lines
if count == 1:
self._generators[name] = result[0]
@@ -997,6 +1080,7 @@ class Processor:
self.parse_directive(d)
def parse(self, lang):
+ self._lines = {}
self._generators = structDataElement(self._data, self._offset)
self.parse_block(lang)
return self._generators
@@ -1004,86 +1088,5 @@ class Processor:
def parse(spec, data, offset=0):
ast = bitwise_grammar.parse(spec)
- p = Processor(data, offset)
+ p = Processor(data, offset, spec)
return p.parse(ast)
-
-
-if __name__ == "__main__":
- defn = """
-// comment
-struct mytype { u8 foo; };
-struct mytype bar;
-struct {
- u8 foo; // inline
- u8 highbit:1,
- sixzeros:6,
- lowbit:1;
- char string[3];
- bbcd fourdigits[2];
-} mystruct;
-"""
- data = b"\xab\x7F\x81abc\x12\x34"
- tree = parse(defn, data)
-
- print(repr(tree))
-
- print("Foo %i" % tree.mystruct.foo)
- print("Highbit: %i SixZeros: %i: Lowbit: %i" % (tree.mystruct.highbit,
- tree.mystruct.sixzeros,
- tree.mystruct.lowbit))
- print("String: %s" % tree.mystruct.string)
- print("Fourdigits: %i" % tree.mystruct.fourdigits)
-
- import sys
- sys.exit(0)
-
- test = """
- struct {
- u16 bar;
- u16 baz;
- u8 one;
- u8 upper:2,
- twobit:1,
- onebit:1,
- lower:4;
- u8 array[3];
- char str[3];
- bbcd bcdL[2];
- } foo[2];
- u8 tail;
- """
- data = "\xfe\x10\x00\x08\xFF\x23\x01\x02\x03abc\x34\x89"
- data = (data * 2) + "\x12"
- data = MemoryMap(data)
-
- ast = bitwise_grammar.parse(test)
-
- # Just for testing, pretty-print the tree
- pp(ast)
-
- # Mess with it a little
- p = Processor(data, 0)
- obj = p.parse(ast)
- print("Object: %s" % obj)
- print(obj["foo"][0]["bcdL"])
- print(obj["tail"])
- print(obj["foo"][0]["bar"])
- obj["foo"][0]["bar"].set_value(255 << 8)
- obj["foo"][0]["twobit"].set_value(0)
- obj["foo"][0]["onebit"].set_value(1)
- print("%i" % int(obj["foo"][0]["bar"]))
-
- for i in obj["foo"][0]["array"]:
- print(int(i))
- obj["foo"][0]["array"][1].set_value(255)
-
- for i in obj["foo"][0]["bcdL"]:
- print(i.get_value())
-
- int_to_bcd(obj["foo"][0]["bcdL"], 1234)
- print(bcd_to_int(obj["foo"][0]["bcdL"]))
-
- set_string(obj["foo"][0]["str"], "xyz")
- print(get_string(obj["foo"][0]["str"]))
-
- print(repr(data.get_packed()))
diff --git a/chirp/bitwise_grammar.py b/chirp/bitwise_grammar.py
index fd49b24..969530e 100644
--- a/chirp/bitwise_grammar.py
+++ b/chirp/bitwise_grammar.py
@@ -120,9 +120,6 @@ def parse(data):
def __iter__(self):
return self
- def next(self):
- return self.__next__()
-
def __next__(self):
self.line += 1
try:
diff --git a/chirp/chirp_common.py b/chirp/chirp_common.py
index e737401..7272443 100644
--- a/chirp/chirp_common.py
+++ b/chirp/chirp_common.py
@@ -14,7 +14,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from builtins import bytes
-from future import standard_library
import base64
import json
@@ -42,10 +41,8 @@ TONES = (
225.7, 229.1, 233.6, 241.8, 250.3, 254.1,
)
-OLD_TONES = list(TONES)
-[OLD_TONES.remove(x) for x in [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(OLD_TONES)
+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]))
def VALIDTONE(v):
@@ -67,12 +64,10 @@ DTCS_CODES = (
)
# 512 Possible DTCS Codes
-ALL_DTCS_CODES = []
-for a in range(0, 8):
- for b in range(0, 8):
- for c in range(0, 8):
- ALL_DTCS_CODES.append((a * 100) + (b * 10) + c)
-ALL_DTCS_CODES = tuple(ALL_DTCS_CODES)
+ALL_DTCS_CODES = tuple([((a * 100) + (b * 10) + c)
+ for a in range(0, 8)
+ for b in range(0, 8)
+ for c in range(0, 8)])
CROSS_MODES = (
"Tone->Tone",
@@ -1035,6 +1030,7 @@ class RadioFeatures:
if (self.valid_modes and
mem.mode not in self.valid_modes and
+ 'mode' not in mem.immutable and
mem.mode != "Auto"):
msg = ValidationError("Mode %s not supported" % mem.mode)
msgs.append(msg)
@@ -1389,7 +1385,29 @@ class FileBackedRadio(Radio):
pass
-class CloneModeRadio(FileBackedRadio, ExternalMemoryProperties):
+class DetectableInterface:
+ DETECTED_MODELS = None
+
+ @classmethod
+ def detect_from_serial(cls, pipe):
+ """Communicate with the radio via serial to determine proper class
+
+ Returns an in implementation of CloneModeRadio if detected, or raises
+ RadioError if not. If NotImplemented is raised, we assume that no
+ detection is possible or necessary.
+ """
+ assert cls.DETECTED_MODELS is None, (
+ 'Class has detected models but no detect_from_serial() '
+ 'implementation')
+ raise NotImplementedError()
+
+ @classmethod
+ def detected_models(cls):
+ return list(cls.DETECTED_MODELS or [])
+
+
+class CloneModeRadio(FileBackedRadio, ExternalMemoryProperties,
+ DetectableInterface):
"""A clone-mode radio does a full memory dump in and out and we store
an image of the radio into an image file"""
FILE_EXTENSION = "img"
@@ -1557,7 +1575,7 @@ class CloneModeRadio(FileBackedRadio, ExternalMemoryProperties):
self._metadata['mem_extra'].pop('%04i_comment' % number, None)
-class LiveRadio(Radio):
+class LiveRadio(Radio, DetectableInterface):
"""Base class for all Live-Mode radios"""
pass
@@ -1959,7 +1977,6 @@ def http_user_agent():
def urlretrieve(url, fn):
"""Grab an URL and save it in a specified file"""
- standard_library.install_aliases()
import urllib.request
import urllib.error
diff --git a/chirp/directory.py b/chirp/directory.py
index e25ae10..b917bb6 100644
--- a/chirp/directory.py
+++ b/chirp/directory.py
@@ -63,9 +63,33 @@ def register(cls):
DRV_TO_RADIO[ident] = cls
RADIO_TO_DRV[cls] = ident
+ if not hasattr(cls, '_DETECTED_MODEL'):
+ cls._DETECTED_MODEL = False
+
return cls
+def detected_by(manager_class):
+ """Mark a class as detected by another class
+
+ This means it may not be offered directly as a choice and instead is added
+ to @manager_class's DETECTED_MODELS list and should be returned from
+ detect_from_serial() when appropriate.
+ """
+ assert issubclass(manager_class, chirp_common.CloneModeRadio)
+
+ def wrapper(cls):
+ assert issubclass(cls, chirp_common.CloneModeRadio)
+
+ cls._DETECTED_MODEL = True
+ if manager_class.DETECTED_MODELS is None:
+ manager_class.DETECTED_MODELS = []
+ manager_class.DETECTED_MODELS.append(cls)
+ return cls
+
+ return wrapper
+
+
DRV_TO_RADIO = {}
RADIO_TO_DRV = {}
AUX_FORMATS = set()
@@ -163,10 +187,10 @@ def get_radio_by_image(image_file):
return DynamicRadioAlias(image_file)
if metadata:
- e = errors.ImageMetadataInvalidModel("Unsupported model %s %s" % (
+ ex = errors.ImageMetadataInvalidModel("Unsupported model %s %s" % (
metadata.get("vendor"), metadata.get("model")))
- e.metadata = metadata
- raise e
+ ex.metadata = metadata
+ raise ex
else:
raise errors.ImageDetectFailed("Unknown file format")
diff --git a/chirp/drivers/__init__.py b/chirp/drivers/__init__.py
index fcb714e..3dda0cd 100644
--- a/chirp/drivers/__init__.py
+++ b/chirp/drivers/__init__.py
@@ -156,11 +156,12 @@ 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 radtel_rt490
from chirp.drivers import tdh8
-from chirp.drivers import baofeng_uv17
+from chirp.drivers import radtel_rt490
from chirp.drivers import baofeng_uv17Pro
-from chirp.drivers import mml_jc8810
from chirp.drivers import uvk5
+from chirp.drivers import baofeng_uv17
from chirp.drivers import iradio_uv_5118plus
-__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', 'radtel_rt490', 'tdh8', 'baofeng_uv17', 'baofeng_uv17Pro', 'mml_jc8810', 'uvk5', 'iradio_uv_5118plus']
+from chirp.drivers import mml_jc8810
+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']
diff --git a/chirp/drivers/anytone_ht.py b/chirp/drivers/anytone_ht.py
index 754157e..6a9039e 100644
--- a/chirp/drivers/anytone_ht.py
+++ b/chirp/drivers/anytone_ht.py
@@ -369,7 +369,7 @@ BCLO = ['Off', 'Repeater', 'Busy']
CHARSET = chirp_common.CHARSET_ASCII
COLOR = ['Blue', 'Orange', 'Purple']
DISPLAY = ['Frequency', 'N/A', 'Name']
-DUPLEXES = ['', 'N/A', '-', '+', 'split', 'off']
+DUPLEXES = ['', '', '-', '+', 'split', 'off']
GMRS = ['GMRS %s' % x for x in range(1, 8)] + \
['GMRS %s' % x for x in range(15, 23)] + \
['GMRS Repeater %s' % x for x in range(15, 23)]
@@ -498,7 +498,7 @@ class AnyToneTERMN8RRadio(chirp_common.CloneModeRadio,
mem.duplex = DUPLEXES[_mem.duplex]
mem.mode = MODES[_mem.channel_width]
- if _mem.tx_off is True:
+ if bool(_mem.tx_off):
mem.duplex = "off"
mem.offset = 0
diff --git a/chirp/drivers/anytone_iii.py b/chirp/drivers/anytone_iii.py
index 8b4f4be..7b78eda 100644
--- a/chirp/drivers/anytone_iii.py
+++ b/chirp/drivers/anytone_iii.py
@@ -114,7 +114,6 @@ struct {
u8 zeros128[128];
} oem_info;
-#seekto 0x0100;
struct flag chan_flags[750]; // Channel flags
struct flag limit_flags[10]; // Limit channel flags
//u8 effs8[8];
@@ -195,7 +194,6 @@ struct DTMF12p3 dtmf_encodings[16];
#seekto 0x0540; // Hyper channels (12 x 2)
struct memory hyper_channels[24];
-#seekto 0x0840; // Settings
struct {
u8 unknown1:6,
display:2; // Display Mode: [freq, chan, name]
@@ -460,13 +458,13 @@ struct {
u8 unknown:6,
mode:2; // [Alarm, Transpond+Background,
// Transpond+Alarm, Both]
- u8 unknown:6,
+ u8 unknown2:6,
eni_type:2; // [None, DTMF, 5Tone]
u8 id; // When DTMF: [M1-M16], When 5Tone: 0-99
u8 alarm_time; // [1-255] seconds
u8 tx_time; // [0-255] seconds
u8 rx_time; // [0-255] seconds
- u8 unknown:7,
+ u8 unknown3:7,
chan_select:1; // [Assigned, Selected]
ul16 channel; // [0-749]
u8 cycle; // [Continuous, 1-255]
@@ -938,7 +936,7 @@ class AnyTone5888UVIIIRadio(chirp_common.CloneModeRadio,
if not is_hyper_chan and _flg.unused:
mem.empty = True
- _mem.set_raw("\x00" * 32)
+ _mem.fill_raw(b"\x00")
_mem.name = SEVEN_SPACES
_flg.scan = 0
diff --git a/chirp/drivers/baofeng_common.py b/chirp/drivers/baofeng_common.py
index ec4f811..d990c47 100644
--- a/chirp/drivers/baofeng_common.py
+++ b/chirp/drivers/baofeng_common.py
@@ -23,7 +23,8 @@ from chirp import chirp_common, memmap
from chirp import errors, util
from chirp import bandplan_na
from chirp.settings import RadioSettingGroup, RadioSetting, \
- RadioSettingValueBoolean, RadioSettingValueList
+ RadioSettingValueBoolean, InternalError, \
+ RadioSettingValueList
LOG = logging.getLogger(__name__)
@@ -363,19 +364,19 @@ def _upload(radio):
if aux_i1 != aux_r1:
# Area 1 does not match
# The safest thing to do is to skip uploading Aux mem area.
- LOG.info("Aux memory mis-match")
+ LOG.info("Aux memory mismatch")
LOG.info("Aux area 1 from image is %s" % repr(aux_i1))
LOG.info("Aux area 1 from radio is %s" % repr(aux_r1))
elif aux_i2 != aux_r2:
# Area 2 does not match
# The safest thing to do is to skip uploading Aux mem area.
- LOG.info("Aux memory mis-match")
+ LOG.info("Aux memory mismatch")
LOG.info("Aux area 2 from image is %s" % repr(aux_i2))
LOG.info("Aux area 2 from radio is %s" % repr(aux_r2))
elif aux_i3 != aux_r3:
# Area 3 does not match
# The safest thing to do is to skip uploading Aux mem area.
- LOG.info("Aux memory mis-match")
+ LOG.info("Aux memory mismatch")
LOG.info("Aux area 3 from image is %s" % repr(aux_i3))
LOG.info("Aux area 3 from radio is %s" % repr(aux_r3))
else:
@@ -443,6 +444,16 @@ def _split(rf, f1, f2):
return True
+def bcd_decode_freq(bytes):
+ real_freq = 0
+ for byte in bytes:
+ if byte > 9:
+ msg = ("Found Invalid BCD Encoding")
+ raise InternalError(msg)
+ real_freq = (real_freq * 10) + byte
+ return chirp_common.format_freq(real_freq * 10)
+
+
class BaofengCommonHT(chirp_common.CloneModeRadio,
chirp_common.ExperimentalRadio):
"""Baofeng HT Style Radios"""
diff --git a/chirp/drivers/baofeng_uv17.py b/chirp/drivers/baofeng_uv17.py
index e3f0e21..a9fe615 100644
--- a/chirp/drivers/baofeng_uv17.py
+++ b/chirp/drivers/baofeng_uv17.py
@@ -30,32 +30,38 @@ LIST_SAVE = ["Off", "1:1", "1:2", "1:3", "1:4"]
LIST_SCANMODE = ["Time", "Carrier", "Search"]
-def _sendmagic(radio, magic, response_len):
- baofeng_common._rawsend(radio, magic)
- baofeng_common._rawrecv(radio, response_len)
+# Radios seem to have different memory sizes
+def _get_memory_size(radio):
+ response = baofeng_uv17Pro._sendmagic(radio, radio._magic_memsize[0][0],
+ radio._magic_memsize[0][1])
+ mem_size = struct.unpack("<I", response[7:])[0]
+ for magic, resplen in radio._magics2:
+ baofeng_uv17Pro._sendmagic(radio, magic, resplen)
+ return mem_size
# Locations of memory may differ each time, so a mapping has to be made first
def _get_memory_map(radio):
# Get memory map
memory_map = []
- for addr in range(0x1FFF, 0x10FFF, 0x1000):
+ mem_size = _get_memory_size(radio)
+ if mem_size != radio._radio_memsize:
+ raise errors.RadioError("Incorrect radio model or model not supported "
+ "(memory size doesn't match)")
+ for addr in range(0x1FFF, mem_size + 0x1000, 0x1000):
frame = radio._make_frame(b"R", addr, 1)
baofeng_common._rawsend(radio, frame)
blocknr = ord(baofeng_common._rawrecv(radio, 6)[5:])
blocknr = (blocknr >> 4 & 0xf) * 10 + (blocknr & 0xf)
memory_map += [blocknr]
- _sendmagic(radio, b"\x06", 1)
+ baofeng_uv17Pro._sendmagic(radio, b"\x06", 1)
return memory_map
def _download(radio):
"""Get the memory map"""
baofeng_uv17Pro._do_ident(radio)
-
data = b""
- _start_communication(radio)
-
memory_map = _get_memory_map(radio)
status = chirp_common.Status()
@@ -65,6 +71,11 @@ def _download(radio):
radio.status_fn(status)
for block_number in radio.BLOCK_ORDER:
+ if block_number not in memory_map:
+ # Memory block not found.
+ raise errors.RadioError('Radio memory is corrupted. ' +
+ 'Fix this by uploading a backup image ' +
+ 'to the radio.')
block_index = memory_map.index(block_number) + 1
start_addr = block_index * 0x1000
for addr in range(start_addr, start_addr + 0x1000,
@@ -85,17 +96,13 @@ def _download(radio):
status.msg = "Cloning from radio..."
radio.status_fn(status)
- _sendmagic(radio, b"\x06", 1)
- data += bytes(radio.MODEL, 'ascii')
+ baofeng_uv17Pro._sendmagic(radio, b"\x06", 1)
return data
def _upload(radio):
"""Upload procedure"""
baofeng_uv17Pro._do_ident(radio)
-
- _start_communication(radio)
-
memory_map = _get_memory_map(radio)
status = chirp_common.Status()
@@ -105,8 +112,8 @@ def _upload(radio):
radio.status_fn(status)
for block_number in radio.BLOCK_ORDER:
- # Choose a block number is memory map is corrupt
- # This happens when te upload process is interrupted
+ # Choose a block number if memory map is corrupt
+ # This can happen when the upload process was interrupted
if block_number not in memory_map:
memory_map[memory_map.index(165)] = block_number
block_index = memory_map.index(block_number) + 1
@@ -133,11 +140,6 @@ def _upload(radio):
radio.status_fn(status)
-def _start_communication(radio):
- for magic in radio._magics:
- _sendmagic(radio, magic[0], magic[1])
-
-
@directory.register
class UV17(baofeng_uv17Pro.UV17Pro):
"""Baofeng UV-17"""
@@ -155,14 +157,20 @@ class UV17(baofeng_uv17Pro.UV17Pro):
BLOCK_SIZE = 0x40
BAUD_RATE = 57600
_magic = b"PSEARCH"
- _magic_response_length = 8
- _magics = [[b"PASSSTA", 3], [b"SYSINFO", 1],
- [b"\x56\x00\x00\x0A\x0D", 13], [b"\x06", 1],
- [b"\x56\x00\x10\x0A\x0D", 13], [b"\x06", 1],
- [b"\x56\x00\x20\x0A\x0D", 13], [b"\x06", 1],
- [b"\x56\x00\x00\x00\x0A", 11], [b"\x06", 1],
- [b"\xFF\xFF\xFF\xFF\x0C\x55\x56\x31\x35\x39\x39\x39", 1],
- [b"\02", 8], [b"\x06", 1]]
+ _magics = [(b"PASSSTA", 3),
+ (b"SYSINFO", 1),
+ (b"\x56\x00\x00\x0A\x0D", 13),
+ (b"\x06", 1),
+ (b"\x56\x00\x10\x0A\x0D", 13),
+ (b"\x06", 1),
+ (b"\x56\x00\x20\x0A\x0D", 13),
+ (b"\x06", 1)]
+ _magic_memsize = [(b"\x56\x00\x00\x00\x0A", 11)]
+ _radio_memsize = 0xffff
+ _magics2 = [(b"\x06", 1),
+ (b"\xFF\xFF\xFF\xFF\x0C\x55\x56\x31\x35\x39\x39\x39", 1),
+ (b"\02", 8),
+ (b"\x06", 1)]
_fingerprint = b"\x06" + b"UV15999"
_scode_offset = 1
@@ -300,7 +308,7 @@ class UV17(baofeng_uv17Pro.UV17Pro):
def _make_frame(self, cmd, addr, length, data=""):
"""Pack the info in the header format"""
- frame = struct.pack("<cH", cmd, addr) + struct.pack(">H", length)
+ frame = struct.pack("<cI", cmd, addr)[:-1] + struct.pack(">B", length)
# add the data if set
if len(data) != 0:
frame += data
@@ -359,7 +367,7 @@ class UV17(baofeng_uv17Pro.UV17Pro):
RadioSettingValueBoolean(_mem.settings.fmenable))
basic.append(rs)
- self.get_settings_common_dtmf(dtmfe)
+ self.get_settings_common_dtmf(dtmfe, _mem)
return top
@@ -442,6 +450,14 @@ class UV17(baofeng_uv17Pro.UV17Pro):
_mem.set_raw(b"\x00" * 16)
_namelength = self.get_features().valid_name_length
- _nam.name = mem.name.ljust(_namelength, '\xFF')
+ _nam.name = mem.name.ljust(_namelength, '\x00')
self.set_memory_common(mem, _mem)
+
+
+@directory.register
+class UV13Pro(UV17):
+ VENDOR = "Baofeng"
+ MODEL = "UV-13Pro"
+
+ _radio_memsize = 0x31fff
diff --git a/chirp/drivers/baofeng_uv17Pro.py b/chirp/drivers/baofeng_uv17Pro.py
index 2bf370b..41353b3 100644
--- a/chirp/drivers/baofeng_uv17Pro.py
+++ b/chirp/drivers/baofeng_uv17Pro.py
@@ -16,12 +16,12 @@
import logging
-from chirp.drivers import baofeng_common
+from chirp.drivers import baofeng_common as bfc
from chirp import chirp_common, directory, memmap
from chirp import bitwise
from chirp.settings import RadioSetting, \
RadioSettingValueBoolean, RadioSettingValueList, \
- RadioSettingValueString, \
+ InvalidValueError, RadioSettingValueString, \
RadioSettings, RadioSettingGroup
import struct
from chirp import errors, util
@@ -34,6 +34,7 @@ MSTRING_UV17PROGPS = b"PROGRAMCOLORPROU"
DTMF_CHARS = "0123456789 *#ABCD"
STEPS = [2.5, 5.0, 6.25, 10.0, 12.5, 20.0, 25.0, 50.0]
+LIST_STEPS = ["2.5", "5.0", "6.25", "10.0", "12.5", "20.0", "25.0", "50.0"]
LIST_AB = ["A", "B"]
LIST_BANDWIDTH = ["Wide", "Narrow"]
@@ -58,6 +59,7 @@ LIST_VOX_LEVEL = ["Off"] + ["%s" % x for x in range(1, 10, 1)]
LIST_VOX_LEVEL_ALT = ["%s" % x for x in range(1, 10, 1)]
LIST_GPS_MODE = ["GPS", "Beidou", "GPS + Beidou"]
LIST_GPS_TIMEZONE = ["%s" % x for x in range(-12, 13, 1)]
+LIST_SHIFTS = ["Off", "+", "-"]
CHARSET_GB2312 = chirp_common.CHARSET_ASCII
for x in range(0xB0, 0xD7):
for y in range(0xA1, 0xFF):
@@ -94,20 +96,26 @@ def _crypt(symbol_index, buffer):
return dec_buffer
+def _sendmagic(radio, magic, response_len):
+ bfc._rawsend(radio, magic)
+ return bfc._rawrecv(radio, response_len)
+
+
def _do_ident(radio):
# Flush input buffer
- baofeng_common._clean_buffer(radio)
+ bfc._clean_buffer(radio)
# Ident radio
- magic = radio._magic
- baofeng_common._rawsend(radio, magic)
- ack = baofeng_common._rawrecv(radio, radio._magic_response_length)
+ ack = _sendmagic(radio, radio._magic, len(radio._fingerprint))
if not ack.startswith(radio._fingerprint):
if ack:
LOG.debug(repr(ack))
raise errors.RadioError("Radio did not respond as expected (A)")
+ for magic, resplen in radio._magics:
+ _sendmagic(radio, magic, resplen)
+
return True
@@ -116,10 +124,6 @@ def _download(radio):
# Put radio in program mode and identify it
_do_ident(radio)
- for index in range(len(radio._magics)):
- baofeng_common._rawsend(radio, radio._magics[index])
- baofeng_common._rawrecv(radio, radio._magicResponseLengths[index])
-
data = b""
# UI progress
@@ -139,10 +143,10 @@ def _download(radio):
LOG.debug("Frame=" + util.hexprint(frame))
# Sending the read request
- baofeng_common._rawsend(radio, frame)
+ bfc._rawsend(radio, frame)
# Now we read data
- d = baofeng_common._rawrecv(radio, radio.BLOCK_SIZE + 4)
+ d = bfc._rawrecv(radio, radio.BLOCK_SIZE + 4)
LOG.debug("Response Data= " + util.hexprint(d))
d = _crypt(1, d[4:])
@@ -160,10 +164,6 @@ def _download(radio):
def _upload(radio):
# Put radio in program mode and identify it
_do_ident(radio)
- for index in range(len(radio._magics)):
- baofeng_common._rawsend(radio, radio._magics[index])
- baofeng_common._rawrecv(radio, radio._magicResponseLengths[index])
-
data = b""
# UI progress
@@ -189,10 +189,10 @@ def _upload(radio):
LOG.debug("Frame=" + util.hexprint(frame))
# Sending the read request
- baofeng_common._rawsend(radio, frame)
+ bfc._rawsend(radio, frame)
# receiving the response
- ack = baofeng_common._rawrecv(radio, 1)
+ ack = bfc._rawrecv(radio, 1)
if ack != b"\x06":
msg = "Bad ack writing block 0x%04x" % addr
raise errors.RadioError(msg)
@@ -205,7 +205,7 @@ def _upload(radio):
@directory.register
-class UV17Pro(baofeng_common.BaofengCommonHT):
+class UV17Pro(bfc.BaofengCommonHT):
"""Baofeng UV-17Pro"""
VENDOR = "Baofeng"
MODEL = "UV-17Pro"
@@ -224,16 +224,17 @@ class UV17Pro(baofeng_common.BaofengCommonHT):
_gmrs = False
_bw_shift = False
_has_support_for_banknames = False
+ _has_workmode_support = True
+ _has_savemode = True
_tri_band = True
_fileid = []
_magic = MSTRING_UV17L
- _magic_response_length = 1
_fingerprint = b"\x06"
- _magics = [b"\x46", b"\x4d",
- b"\x53\x45\x4E\x44\x21\x05\x0D\x01\x01\x01\x04\x11\x08\x05" +
- b"\x0D\x0D\x01\x11\x0F\x09\x12\x09\x10\x04\x00"]
- _magicResponseLengths = [16, 15, 1]
+ _magics = [(b"\x46", 16),
+ (b"\x4d", 15),
+ (b"\x53\x45\x4E\x44\x21\x05\x0D\x01\x01\x01\x04\x11\x08\x05" +
+ b"\x0D\x0D\x01\x11\x0F\x09\x12\x09\x10\x04\x00", 1)]
_fw_ver_start = 0x1EF0
_recv_block_size = 0x40
_mem_size = MEM_TOTAL
@@ -254,6 +255,7 @@ class UV17Pro(baofeng_common.BaofengCommonHT):
SKIP_VALUES = ["", "S"]
DTCS_CODES = tuple(sorted(chirp_common.DTCS_CODES + (645,)))
RXTX_CODES = ('Off', )
+ LIST_PW_SAVEMODE = ["Off", "On"]
for code in chirp_common.TONES:
RXTX_CODES = (RXTX_CODES + (str(code), ))
for code in DTCS_CODES:
@@ -462,7 +464,7 @@ class UV17Pro(baofeng_common.BaofengCommonHT):
code.append(0xFF)
obj.code = code
- def get_settings_common_dtmf(self, dtmfe):
+ def get_settings_common_dtmf(self, dtmfe, _mem):
for i in range(0, len(self.SCODE_LIST)):
_codeobj = self._memobj.pttid[i].code
_code = "".join([
@@ -482,6 +484,42 @@ class UV17Pro(baofeng_common.BaofengCommonHT):
rs.set_apply_callback(self.apply_code, self._memobj.ani, 5)
dtmfe.append(rs)
+ def get_settings_pro_dtmf(self, dtmfe, _mem):
+ if _mem.ani.dtmfon > 0xC3:
+ val = 0x03
+ else:
+ val = _mem.ani.dtmfon
+ rs = RadioSetting("ani.dtmfon", "DTMF Speed (on)",
+ RadioSettingValueList(LIST_DTMFSPEED,
+ LIST_DTMFSPEED[val]))
+ dtmfe.append(rs)
+
+ if _mem.ani.dtmfoff > 0xC3:
+ val = 0x03
+ else:
+ val = _mem.ani.dtmfoff
+ rs = RadioSetting("ani.dtmfoff", "DTMF Speed (off)",
+ RadioSettingValueList(LIST_DTMFSPEED,
+ LIST_DTMFSPEED[val]))
+ dtmfe.append(rs)
+
+ if self._has_when_to_send_aniid:
+ rs = RadioSetting("ani.aniid", "When to send ANI ID",
+ RadioSettingValueList(LIST_PTTID,
+ LIST_PTTID[
+ _mem.ani.aniid]))
+ dtmfe.append(rs)
+
+ if _mem.settings.hangup >= len(LIST_HANGUPTIME):
+ val = 0
+ else:
+ val = _mem.settings.hangup
+ rs = RadioSetting("settings.hangup", "Hang-up time",
+ RadioSettingValueList(LIST_HANGUPTIME,
+ LIST_HANGUPTIME[
+ val]))
+ dtmfe.append(rs)
+
def get_settings_common_basic(self, basic, _mem):
if _mem.settings.squelch >= len(self.SQUELCH_LIST):
val = 0x00
@@ -564,21 +602,15 @@ class UV17Pro(baofeng_common.BaofengCommonHT):
self.LIST_MODE[_mem.settings.chbdistype]))
basic.append(rs)
- def get_settings(self):
- """Translate the bit in the mem_struct into settings in the UI"""
- _mem = self._memobj
- basic = RadioSettingGroup("basic", "Basic Settings")
- dtmfe = RadioSettingGroup("dtmfe", "DTMF Encode Settings")
- if self._has_support_for_banknames:
- bank = RadioSettingGroup("bank", "Bank names")
- top = RadioSettings(basic, bank, dtmfe)
- else:
- top = RadioSettings(basic, dtmfe)
-
- self.get_settings_common_basic(basic, _mem)
+ def get_settings_pro_basic(self, basic, _mem):
+ if _mem.settings.savemode > len(self.LIST_PW_SAVEMODE):
+ val = 0x01 # assume values out of range are some form of "On"
+ else:
+ val = _mem.settings.savemode
rs = RadioSetting("settings.savemode", "Save Mode",
- RadioSettingValueBoolean(_mem.settings.savemode))
+ RadioSettingValueList(self.LIST_PW_SAVEMODE,
+ self.LIST_PW_SAVEMODE[val]))
basic.append(rs)
rs = RadioSetting("settings.totalarm", "Timeout Timer Alarm",
@@ -742,6 +774,157 @@ class UV17Pro(baofeng_common.BaofengCommonHT):
RadioSettingValueBoolean(_mem.settings.fmenable))
basic.append(rs)
+ def get_settings_common_workmode(self, workmode, _mem):
+
+ vfoA = RadioSettingGroup("vfoA", "VFO A")
+ vfoB = RadioSettingGroup("vfoB", "VFO B")
+
+ def my_validate(value):
+ value = chirp_common.parse_freq(value)
+ for band in self.VALID_BANDS:
+ 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)
+
+ def apply_freq(setting, obj):
+ value = chirp_common.parse_freq(str(setting.value)) / 10
+ for i in range(7, -1, -1):
+ obj.freq[i] = value % 10
+ value /= 10
+
+ freqA = RadioSettingValueString(0, 10,
+ bfc.bcd_decode_freq(_mem.vfo.a.freq))
+ freqA.set_validate_callback(my_validate)
+ rs = RadioSetting("vfo.a.freq", "Frequency", freqA)
+ rs.set_apply_callback(apply_freq, _mem.vfo.a)
+ vfoA.append(rs)
+
+ freqB = RadioSettingValueString(0, 10,
+ bfc.bcd_decode_freq(_mem.vfo.b.freq))
+ freqB.set_validate_callback(my_validate)
+ rs = RadioSetting("vfo.b.freq", "Frequency", freqB)
+ rs.set_apply_callback(apply_freq, _mem.vfo.b)
+ vfoB.append(rs)
+
+ if _mem.vfo.a.sftd >= len(LIST_SHIFTS):
+ val = 0
+ else:
+ val = _mem.vfo.a.sftd
+ rs = RadioSetting("vfo.a.sftd", "Shift",
+ RadioSettingValueList(LIST_SHIFTS, LIST_SHIFTS[val]))
+ vfoA.append(rs)
+
+ if _mem.vfo.b.sftd >= len(LIST_SHIFTS):
+ val = 0
+ else:
+ val = _mem.vfo.b.sftd
+ rs = RadioSetting("vfo.b.sftd", "Shift",
+ RadioSettingValueList(LIST_SHIFTS, LIST_SHIFTS[val]))
+ vfoB.append(rs)
+
+ def convert_bytes_to_offset(bytes):
+ real_offset = 0
+ for byte in bytes:
+ real_offset = (real_offset * 10) + byte
+ return chirp_common.format_freq(real_offset * 1000)
+
+ def apply_offset(setting, obj):
+ value = chirp_common.parse_freq(str(setting.value)) / 1000
+ for i in range(5, -1, -1):
+ obj.offset[i] = value % 10
+ value /= 10
+
+ offA = RadioSettingValueString(
+ 0, 10, convert_bytes_to_offset(_mem.vfo.a.offset))
+ rs = RadioSetting("vfo.a.offset",
+ "Offset (0.0-999.999)", offA)
+ rs.set_apply_callback(apply_offset, _mem.vfo.a)
+ vfoA.append(rs)
+
+ offB = RadioSettingValueString(
+ 0, 10, convert_bytes_to_offset(_mem.vfo.b.offset))
+ rs = RadioSetting("vfo.b.offset",
+ "Offset (0.0-999.999)", offB)
+ rs.set_apply_callback(apply_offset, _mem.vfo.b)
+ vfoB.append(rs)
+
+ POWER_LEVELS = [str(x) for x in self.POWER_LEVELS]
+ if _mem.vfo.a.lowpower >= len(POWER_LEVELS):
+ val = 0
+ else:
+ val = _mem.vfo.a.lowpower
+ rs = RadioSetting("vfo.a.lowpower", "Power",
+ RadioSettingValueList(POWER_LEVELS,
+ POWER_LEVELS[val]))
+ vfoA.append(rs)
+
+ if _mem.vfo.b.lowpower >= len(POWER_LEVELS):
+ val = 0
+ else:
+ val = _mem.vfo.b.lowpower
+ rs = RadioSetting("vfo.b.lowpower", "Power",
+ RadioSettingValueList(POWER_LEVELS,
+ POWER_LEVELS[val]))
+ vfoB.append(rs)
+
+ if _mem.vfo.a.wide >= len(LIST_BANDWIDTH):
+ val = 0
+ else:
+ val = _mem.vfo.a.wide
+ rs = RadioSetting("vfo.a.wide", "Bandwidth",
+ RadioSettingValueList(LIST_BANDWIDTH,
+ LIST_BANDWIDTH[val]))
+ vfoA.append(rs)
+
+ if _mem.vfo.b.wide >= len(LIST_BANDWIDTH):
+ val = 0
+ else:
+ val = _mem.vfo.b.wide
+ rs = RadioSetting("vfo.b.wide", "Bandwidth",
+ RadioSettingValueList(LIST_BANDWIDTH,
+ LIST_BANDWIDTH[val]))
+ vfoB.append(rs)
+
+ if _mem.vfo.a.scode >= len(self.SCODE_LIST):
+ val = 0
+ else:
+ val = _mem.vfo.a.scode
+ rs = RadioSetting("vfo.a.scode", "Signal Code",
+ RadioSettingValueList(self.SCODE_LIST,
+ self.SCODE_LIST[val]))
+ vfoA.append(rs)
+
+ if _mem.vfo.b.scode >= len(self.SCODE_LIST):
+ val = 0
+ else:
+ val = _mem.vfo.b.scode
+ rs = RadioSetting("vfo.b.scode", "Signal Code",
+ RadioSettingValueList(self.SCODE_LIST,
+ self.SCODE_LIST[val]))
+ vfoB.append(rs)
+
+ if _mem.vfo.a.step >= len(STEPS):
+ val = 0
+ else:
+ val = _mem.vfo.a.step
+ rs = RadioSetting("vfo.a.step", "Tuning Step",
+ RadioSettingValueList(LIST_STEPS, LIST_STEPS[val]))
+ vfoA.append(rs)
+
+ if _mem.vfo.b.step >= len(STEPS):
+ val = 0
+ else:
+ val = _mem.vfo.b.step
+ rs = RadioSetting("vfo.b.step", "Tuning Step",
+ RadioSettingValueList(LIST_STEPS, LIST_STEPS[val]))
+ vfoB.append(rs)
+
+ workmode.append(vfoA)
+ workmode.append(vfoB)
+
+ def get_settings_common_bank(self, bank, _mem):
+
def _filterName(name):
fname = b""
for char in name:
@@ -765,45 +948,68 @@ class UV17Pro(baofeng_common.BaofengCommonHT):
rs.set_apply_callback(apply_bankname, _nameobj)
bank.append(rs)
- self.get_settings_common_dtmf(dtmfe)
+ def get_settings(self):
+ """Translate the bit in the mem_struct into settings in the UI"""
+ _mem = self._memobj
+ supported = []
- if _mem.ani.dtmfon > 0xC3:
- val = 0x03
- else:
- val = _mem.ani.dtmfon
- rs = RadioSetting("ani.dtmfon", "DTMF Speed (on)",
- RadioSettingValueList(LIST_DTMFSPEED,
- LIST_DTMFSPEED[val]))
- dtmfe.append(rs)
+ basic = RadioSettingGroup("basic", "Basic Settings")
+ self.get_settings_common_basic(basic, _mem)
+ self.get_settings_pro_basic(basic, _mem)
+ supported.append(basic) # add basic menu
- if _mem.ani.dtmfoff > 0xC3:
- val = 0x03
- else:
- val = _mem.ani.dtmfoff
- rs = RadioSetting("ani.dtmfoff", "DTMF Speed (off)",
- RadioSettingValueList(LIST_DTMFSPEED,
- LIST_DTMFSPEED[val]))
- dtmfe.append(rs)
+ if self._has_workmode_support:
+ workmode = RadioSettingGroup("workmode", "Work Mode Settings")
+ self.get_settings_common_workmode(workmode, _mem)
+ supported.append(workmode) # add workmode menu if supported
- if self._has_when_to_send_aniid:
- rs = RadioSetting("ani.aniid", "When to send ANI ID",
- RadioSettingValueList(LIST_PTTID,
- LIST_PTTID[
- _mem.ani.aniid]))
- dtmfe.append(rs)
+ dtmfe = RadioSettingGroup("dtmfe", "DTMF Encode Settings")
+ self.get_settings_common_dtmf(dtmfe, _mem)
+ self.get_settings_pro_dtmf(dtmfe, _mem)
+ supported.append(dtmfe) # add dtmfe menu
- if _mem.settings.hangup >= len(LIST_HANGUPTIME):
- val = 0
- else:
- val = _mem.settings.hangup
- rs = RadioSetting("settings.hangup", "Hang-up time",
- RadioSettingValueList(LIST_HANGUPTIME,
- LIST_HANGUPTIME[
- val]))
- dtmfe.append(rs)
+ if self._has_support_for_banknames:
+ bank = RadioSettingGroup("bank", "Bank names")
+ self.get_settings_common_bank(bank, _mem)
+ supported.append(bank) # add bank menu if supported
+ top = RadioSettings(*tuple(supported))
return top
+ def set_settings(self, settings):
+ _settings = self._memobj.settings
+ for element in settings:
+ if not isinstance(element, RadioSetting):
+ self.set_settings(element)
+ continue
+ else:
+ try:
+ name = element.get_name()
+ if "." in name:
+ bits = name.split(".")
+ obj = self._memobj
+ for bit in bits[:-1]:
+ if "/" in bit:
+ bit, index = bit.split("/", 1)
+ index = int(index)
+ obj = getattr(obj, bit)[index]
+ else:
+ obj = getattr(obj, bit)
+ setting = bits[-1]
+ else:
+ obj = _settings
+ setting = element.get_name()
+
+ if element.has_apply_callback():
+ LOG.debug("Using apply callback")
+ element.run_apply_callback()
+ elif element.value.get_mutable():
+ LOG.debug("Setting %s = %s" % (setting, element.value))
+ setattr(obj, setting, element.value)
+ except Exception:
+ LOG.debug(element.get_name())
+ raise
+
def sync_in(self):
"""Download from radio"""
try:
@@ -916,7 +1122,7 @@ class UV17Pro(baofeng_common.BaofengCommonHT):
else:
offset = (int(_mem.txfreq) * 10) - freq
if offset != 0:
- if baofeng_common._split(self.get_features(), freq, int(
+ if bfc._split(self.get_features(), freq, int(
_mem.txfreq) * 10):
duplex = "split"
offset = int(_mem.txfreq) * 10
@@ -954,6 +1160,13 @@ class UV17Pro(baofeng_common.BaofengCommonHT):
mem.power = levels[0]
mem.mode = _mem.wide and self.MODES[0] or self.MODES[1]
+ if (mem.freq >= self._airband[0] and mem.freq <= self._airband[1]):
+ # NOTE: AM is not in valid_modes because you can't arbitrarily
+ # enable it on this radio. However, we can expose it as immutable
+ # which will display properly in the UI and not allow the user
+ # to change those channels to FM.
+ mem.mode = "AM"
+ mem.immutable = ['mode']
mem.extra = RadioSettingGroup("Extra", "extra")
@@ -1056,11 +1269,13 @@ class UV17ProGPS(UV17Pro):
MODEL = "UV-17ProGPS"
_has_support_for_banknames = True
+ _has_workmode_support = True
_magic = MSTRING_UV17PROGPS
- _magics = [b"\x46", b"\x4d", b"\x53\x45\x4E\x44\x21\x05\x0D\x01\x01" +
- b"\x01\x04\x11\x08\x05\x0D\x0D\x01\x11\x0F\x09\x12\x09" +
- b"\x10\x04\x00"]
- _magicResponseLengths = [16, 7, 1]
+ _magics = [(b"\x46", 16),
+ (b"\x4d", 7),
+ (b"\x53\x45\x4E\x44\x21\x05\x0D\x01\x01" +
+ b"\x01\x04\x11\x08\x05\x0D\x0D\x01\x11\x0F\x09\x12\x09" +
+ b"\x10\x04\x00", 1)]
_has_when_to_send_aniid = False
_vfoscan = True
_has_gps = True
@@ -1071,10 +1286,49 @@ class UV17ProGPS(UV17Pro):
VALID_BANDS = [UV17Pro._airband, UV17Pro._vhf_range, UV17Pro._vhf2_range,
UV17Pro._uhf_range, UV17Pro._uhf2_range]
+ def check_set_memory_immutable_policy(self, existing, new):
+ if (self._airband[0] <= new.freq <= self._airband[1] and
+ new.mode == 'AM'):
+ # This is valid, so mark mode as immutable so it doesn't get
+ # blocked, and let the radio override it during set.
+ new.immutable.append('mode')
+ existing.immutable = []
+ elif existing.mode == 'AM' and new.mode in self.MODES:
+ # If we're going from a forced-AM channel to some valid one,
+ # clear immutable so we allow the change.
+ try:
+ existing.immutable.remove('mode')
+ except ValueError:
+ pass
+ super().check_set_memory_immutable_policy(existing, new)
+
@directory.register
class BF5RM(UV17Pro):
VENDOR = "Baofeng"
MODEL = "5RM"
+
VALID_BANDS = [UV17Pro._airband, UV17Pro._vhf_range, UV17Pro._vhf2_range,
UV17Pro._uhf_range, UV17Pro._uhf2_range]
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=8.00),
+ chirp_common.PowerLevel("Low", watts=1.00),
+ chirp_common.PowerLevel("Medium", watts=5.00)]
+ SCODE_LIST = ["%s" % x for x in range(1, 16)]
+ LIST_PW_SAVEMODE = ["Off", "1:1", "1:2", "1:4"]
+ _has_workmode_support = True
+
+ def check_set_memory_immutable_policy(self, existing, new):
+ if (self._airband[0] <= new.freq <= self._airband[1] and
+ new.mode == 'AM'):
+ # This is valid, so mark mode as immutable so it doesn't get
+ # blocked, and let the radio override it during set.
+ new.immutable.append('mode')
+ existing.immutable = []
+ elif existing.mode == 'AM' and new.mode in self.MODES:
+ # If we're going from a forced-AM channel to some valid one,
+ # clear immutable so we allow the change.
+ try:
+ existing.immutable.remove('mode')
+ except ValueError:
+ pass
+ super().check_set_memory_immutable_policy(existing, new)
diff --git a/chirp/drivers/baofeng_wp970i.py b/chirp/drivers/baofeng_wp970i.py
index 447a8f6..ee558c2 100644
--- a/chirp/drivers/baofeng_wp970i.py
+++ b/chirp/drivers/baofeng_wp970i.py
@@ -16,7 +16,7 @@
import logging
-from chirp.drivers import baofeng_common
+from chirp.drivers import baofeng_common as bfc
from chirp import chirp_common, directory
from chirp import bitwise
from chirp.settings import RadioSettingGroup, RadioSetting, \
@@ -83,7 +83,7 @@ def model_match(cls, data):
return False
-class WP970I(baofeng_common.BaofengCommonHT):
+class WP970I(bfc.BaofengCommonHT):
"""Baofeng WP970I"""
VENDOR = "Baofeng"
MODEL = "WP970I"
@@ -124,7 +124,7 @@ class WP970I(baofeng_common.BaofengCommonHT):
SCODE_LIST = LIST_SCODE
MEM_FORMAT = """
- #seekto 0x0000;
+ // #seekto 0x0000;
struct {
lbcd rxfreq[4];
lbcd txfreq[4];
@@ -166,20 +166,20 @@ class WP970I(baofeng_common.BaofengCommonHT):
struct {
u8 squelch;
u8 step;
- u8 unknown1;
+ u8 unknown_e22;
u8 save;
u8 vox;
- u8 unknown2;
+ u8 unknown_e25;
u8 abr;
u8 tdr;
u8 beep;
u8 timeout;
- u8 unknown3[4];
+ u8 unknown_e2a[4];
u8 voice;
- u8 unknown4;
+ u8 unknown_e2f;
u8 dtmfst;
- u8 unknown5;
- u8 unknown12:6,
+ u8 unknown_e31;
+ u8 unknown_e32:6,
screv:2;
u8 pttid;
u8 pttlt;
@@ -188,7 +188,7 @@ class WP970I(baofeng_common.BaofengCommonHT):
u8 bcl;
u8 autolk;
u8 sftd;
- u8 unknown6[3];
+ u8 unknown_e3a[3];
u8 wtled;
u8 rxled;
u8 txled;
@@ -203,13 +203,13 @@ class WP970I(baofeng_common.BaofengCommonHT):
u8 rogerrx;
u8 tdrch;
u8 displayab:1,
- unknown1:2,
+ unknown_e4a1:2,
fmradio:1,
alarm:1,
- unknown2:1,
+ unknown_e4a2:1,
reset:1,
menu:1;
- u8 unknown1:6,
+ u8 unknown_e4b:6,
singleptt:1,
vfomrlock:1;
u8 workmode;
@@ -339,7 +339,7 @@ class WP970I(baofeng_common.BaofengCommonHT):
return rp
def get_features(self):
- rf = baofeng_common.BaofengCommonHT.get_features(self)
+ rf = bfc.BaofengCommonHT.get_features(self)
rf.valid_tuning_steps = STEPS
return rf
@@ -647,12 +647,6 @@ class WP970I(baofeng_common.BaofengCommonHT):
_mem.wmchannel.mrchb))
work.append(rs)
- def convert_bytes_to_freq(bytes):
- real_freq = 0
- for byte in bytes:
- real_freq = (real_freq * 10) + byte
- return chirp_common.format_freq(real_freq * 10)
-
def my_validate(value):
value = chirp_common.parse_freq(value)
msg = ("Can't be less than %i.0000")
@@ -673,14 +667,14 @@ class WP970I(baofeng_common.BaofengCommonHT):
value /= 10
val1a = RadioSettingValueString(0, 10,
- convert_bytes_to_freq(_mem.vfo.a.freq))
+ bfc.bcd_decode_freq(_mem.vfo.a.freq))
val1a.set_validate_callback(my_validate)
rs = RadioSetting("vfo.a.freq", "VFO A Frequency", val1a)
rs.set_apply_callback(apply_freq, _mem.vfo.a)
work.append(rs)
val1b = RadioSettingValueString(0, 10,
- convert_bytes_to_freq(_mem.vfo.b.freq))
+ bfc.bcd_decode_freq(_mem.vfo.b.freq))
val1b.set_validate_callback(my_validate)
rs = RadioSetting("vfo.b.freq", "VFO B Frequency", val1b)
rs.set_apply_callback(apply_freq, _mem.vfo.b)
diff --git a/chirp/drivers/bj9900.py b/chirp/drivers/bj9900.py
index d4f1847..0afd74a 100644
--- a/chirp/drivers/bj9900.py
+++ b/chirp/drivers/bj9900.py
@@ -23,7 +23,7 @@ import logging
LOG = logging.getLogger(__name__)
-CMD_ACK = 0x06
+CMD_ACK = b'\x06'
@directory.register
@@ -34,6 +34,7 @@ class BJ9900Radio(chirp_common.CloneModeRadio,
MODEL = "BJ-9900"
VARIANT = ""
BAUD_RATE = 115200
+ NEEDS_COMPAT_SERIAL = False
DUPLEX = ["", "-", "+", "split"]
MODES = ["NFM", "FM"]
@@ -57,7 +58,7 @@ class BJ9900Radio(chirp_common.CloneModeRadio,
# 2 char per byte hex string
# on CR LF terminated lines of 96 char
# plus an empty line at the end
- _datsize = (_memsize * 2) / 96 * 98 + 2
+ _datsize = (_memsize * 2) // 96 * 98 + 2
# block are read in same order as original sw even though they are not
# in physical order
@@ -91,7 +92,7 @@ class BJ9900Radio(chirp_common.CloneModeRadio,
compandor:1,
unknown3:5;
u8 namelen;
- u8 name[7];
+ char name[7];
} memory[128];
"""
@@ -114,21 +115,21 @@ class BJ9900Radio(chirp_common.CloneModeRadio,
def _read(self, addr, blocksize):
# read a single block
- msg = struct.pack(">4sHH", "READ", addr, blocksize)
+ msg = struct.pack(">4sHH", b"READ", addr, blocksize)
LOG.debug("sending " + util.hexprint(msg))
self.pipe.write(msg)
block = self.pipe.read(blocksize)
LOG.debug("received " + util.hexprint(block))
if len(block) != blocksize:
- raise Exception("Unable to read block at addr %04X expected"
- " %i got %i bytes" %
- (addr, blocksize, len(block)))
+ raise errors.RadioError(
+ ("Unable to read block at addr %04X expected"
+ " %i got %i bytes") % (addr, blocksize, len(block)))
return block
def _clone_in(self):
start = time.time()
- data = ""
+ data = b""
status = chirp_common.Status()
status.msg = _("Cloning from radio")
status.max = self._memsize
@@ -140,16 +141,21 @@ class BJ9900Radio(chirp_common.CloneModeRadio,
LOG.info("Clone completed in %i seconds" % (time.time() - start))
- return memmap.MemoryMap(data)
+ # This driver will accept any amount of garbage, and fails tests
+ # as a result. This assertion appears correct based on the file
+ # data matching below. However, untested as of 2024-Feb.
+ assert data[-2:] == b'\r\n', 'Unrecognized radio image'
+
+ return memmap.MemoryMapBytes(data)
def _write(self, addr, block):
# write a single block
- msg = struct.pack(">4sHH", "WRIE", addr, len(block)) + block
+ msg = struct.pack(">4sHH", b"WRIE", addr, len(block)) + block
LOG.debug("sending " + util.hexprint(msg))
self.pipe.write(msg)
data = self.pipe.read(1)
LOG.debug("received " + util.hexprint(data))
- if ord(data) != CMD_ACK:
+ if data != CMD_ACK:
raise errors.RadioError(
"Radio refused to accept block 0x%04x" % addr)
@@ -188,10 +194,10 @@ class BJ9900Radio(chirp_common.CloneModeRadio,
def process_mmap(self):
if len(self._mmap) == self._datsize:
- self._mmap = memmap.MemoryMap([
+ self._mmap = memmap.MemoryMapBytes([
chr(int(self._mmap.get(i, 2), 16))
for i in range(0, self._datsize, 2)
- if self._mmap.get(i, 2) != "\r\n"
+ if self._mmap.get(i, 2) != b"\r\n"
])
try:
self._memobj = bitwise.parse(
@@ -236,23 +242,22 @@ class BJ9900Radio(chirp_common.CloneModeRadio,
_mem = self._memobj.memory[mem.number - 1]
if mem.empty:
- _mem.set_raw("\xff" * (_mem.size() // 8)) # clean up
+ _mem.fill_raw(b"\xff")
_mem.namelen = 0
return
_mem.rxfreq = mem.freq / 10
if mem.duplex == "split":
- _mem.txfreq = mem.offset / 10
+ _mem.txfreq = mem.offset // 10
elif mem.duplex == "+":
- _mem.txfreq = (mem.freq + mem.offset) / 10
+ _mem.txfreq = (mem.freq + mem.offset) // 10
elif mem.duplex == "-":
- _mem.txfreq = (mem.freq - mem.offset) / 10
+ _mem.txfreq = (mem.freq - mem.offset) // 10
else:
- _mem.txfreq = mem.freq / 10
+ _mem.txfreq = mem.freq // 10
_mem.namelen = len(mem.name)
- for i in range(_mem.namelen):
- _mem.name[i] = ord(mem.name[i])
+ _mem.name = mem.name.ljust(7)
rxmode = ""
txmode = ""
@@ -322,7 +327,7 @@ class BJ9900Radio(chirp_common.CloneModeRadio,
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
@@ -338,8 +343,7 @@ class BJ9900Radio(chirp_common.CloneModeRadio,
mem.duplex = int(_mem.rxfreq) > int(_mem.txfreq) and "-" or "+"
mem.offset = abs(int(_mem.rxfreq) - int(_mem.txfreq)) * 10
- for char in _mem.name[0:_mem.namelen]:
- mem.name += chr(char)
+ mem.name = str(_mem.name)[:_mem.namelen]
dtcs_pol = ["N", "N"]
@@ -389,7 +393,7 @@ class BJ9900Radio(chirp_common.CloneModeRadio,
@classmethod
def match_model(cls, filedata, filename):
return len(filedata) == cls._memsize or \
- (len(filedata) == cls._datsize and filedata[-4:] == "\r\n\r\n")
+ (len(filedata) == cls._datsize and filedata[-4:] == b"\r\n\r\n")
class BJ9900RadioLeft(BJ9900Radio):
diff --git a/chirp/drivers/bjuv55.py b/chirp/drivers/bjuv55.py
index 5be6cd6..a46335a 100644
--- a/chirp/drivers/bjuv55.py
+++ b/chirp/drivers/bjuv55.py
@@ -18,6 +18,7 @@
import logging
from chirp.drivers import uv5r
+from chirp.drivers import baofeng_common as bfc
from chirp import chirp_common, directory
from chirp import bitwise
from chirp.settings import RadioSetting, RadioSettingGroup, \
@@ -28,7 +29,7 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \
LOG = logging.getLogger(__name__)
-BJUV55_MODEL = "\x50\xBB\xDD\x55\x63\x98\x4D"
+BJUV55_MODEL = b"\x50\xBB\xDD\x55\x63\x98\x4D"
COLOR_LIST = ["Off", "Blue", "Red", "Pink"]
@@ -154,7 +155,7 @@ struct {
sftd:2,
scode:4;
u8 unknown4;
- u8 unused3:1
+ u8 unused3:1,
step:3,
unused4:4;
u8 txpower:1,
@@ -177,7 +178,7 @@ struct {
sftd:2,
scode:4;
u8 unknown4;
- u8 unused3:1
+ u8 unused3:1,
step:3,
unused4:4;
u8 txpower:1,
@@ -233,6 +234,7 @@ struct {
class BaojieBJUV55Radio(uv5r.BaofengUV5R):
VENDOR = "Baojie"
MODEL = "BJ-UV55"
+ NEEDS_COMPAT_SERIAL = False
_basetype = [b"BJ55"]
_idents = [BJUV55_MODEL]
_mem_params = (0x1928 # poweron_msg offset
@@ -435,12 +437,6 @@ class BaojieBJUV55Radio(uv5r.BaofengUV5R):
RadioSettingValueInteger(0, 127, _mrcnb))
workmode.append(rs)
- def convert_bytes_to_freq(bytes):
- real_freq = 0
- for byte in bytes:
- real_freq = (real_freq * 10) + byte
- return chirp_common.format_freq(real_freq * 10)
-
def my_validate(value):
value = chirp_common.parse_freq(value)
if 17400000 <= value and value < 40000000:
@@ -454,15 +450,17 @@ class BaojieBJUV55Radio(uv5r.BaofengUV5R):
obj.freq[i] = value % 10
value /= 10
- val1a = RadioSettingValueString(
- 0, 10, convert_bytes_to_freq(self._memobj.vfoa.freq))
+ val1a = RadioSettingValueString(0, 10,
+ bfc.bcd_decode_freq(
+ self._memobj.vfoa.freq))
val1a.set_validate_callback(my_validate)
rs = RadioSetting("vfoa.freq", "VFO A Frequency", val1a)
rs.set_apply_callback(apply_freq, self._memobj.vfoa)
workmode.append(rs)
- val1b = RadioSettingValueString(
- 0, 10, convert_bytes_to_freq(self._memobj.vfob.freq))
+ val1b = RadioSettingValueString(0, 10,
+ bfc.bcd_decode_freq(
+ self._memobj.vfob.freq))
val1b.set_validate_callback(my_validate)
rs = RadioSetting("vfob.freq", "VFO B Frequency", val1b)
rs.set_apply_callback(apply_freq, self._memobj.vfob)
diff --git a/chirp/drivers/btech.py b/chirp/drivers/btech.py
index 1bbd3f7..50d11b0 100644
--- a/chirp/drivers/btech.py
+++ b/chirp/drivers/btech.py
@@ -21,6 +21,7 @@ import struct
import logging
from time import sleep
+from chirp.drivers import baofeng_common as bfc
from chirp import chirp_common, directory, memmap
from chirp import bitwise, errors, util
from chirp.settings import RadioSettingGroup, RadioSetting, \
@@ -669,7 +670,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
_350_range = (350000000, 391000000)
_upper = 199
_magic = MSTRING
- _fileid = None
+ _fileid = []
_id2 = False
btech3 = False
_gmrs = False
@@ -816,6 +817,12 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
LOG.error(msg)
raise errors.InvalidDataError(msg)
+ def _is_txinh(self, _mem):
+ raw_tx = b""
+ for i in range(0, 4):
+ raw_tx += _mem.txfreq[i].get_raw()
+ return raw_tx == b"\xFF\xFF\xFF\xFF"
+
def get_memory(self, number):
"""Get the mem representation from the radio image"""
_mem = self._memobj.memory[number]
@@ -834,7 +841,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
# Freq and offset
mem.freq = int(_mem.rxfreq) * 10
# tx freq can be blank
- if _mem.get_raw()[:4] == b"\xFF":
+ if self._is_txinh(_mem):
# TX freq not set
mem.offset = 0
mem.duplex = "off"
@@ -1891,12 +1898,6 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
mrchd = RadioSetting("settings2.mrchd", "MR D channel", rs)
work.append(mrchd)
- def convert_bytes_to_freq(bytes):
- real_freq = 0
- for byte in bytes:
- real_freq = (real_freq * 10) + byte
- return chirp_common.format_freq(real_freq * 10)
-
def my_validate(value):
_vhf_lower = int(convert_bytes_to_limit(_ranges.vhf_low))
_vhf_upper = int(convert_bytes_to_limit(_ranges.vhf_high))
@@ -1949,14 +1950,14 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
_vhf_upper = (convert_bytes_to_limit(_ranges.vhf_high))
_uhf_lower = (convert_bytes_to_limit(_ranges.uhf_low))
- val1a = RadioSettingValueString(0, 10, convert_bytes_to_freq(
- _mem.vfo.a.freq))
+ val1a = RadioSettingValueString(0, 10,
+ bfc.bcd_decode_freq(_mem.vfo.a.freq))
val1a.set_validate_callback(my_validate)
vfoafreq = RadioSetting("vfo.a.freq", "VFO A frequency", val1a)
vfoafreq.set_apply_callback(apply_freq, _mem.vfo.a)
work.append(vfoafreq)
- val = convert_bytes_to_freq(_mem.vfo.b.freq)
+ val = bfc.bcd_decode_freq(_mem.vfo.b.freq)
if self.MODEL in ["GMRS-50V2", "GMRS-50X1"]:
if val[:3] > _vhf_upper and val[:3] < _uhf_lower:
val = "462.562500"
@@ -1967,15 +1968,16 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
work.append(vfobfreq)
if self.COLOR_LCD:
- val1c = RadioSettingValueString(0, 10, convert_bytes_to_freq(
- _mem.vfo.c.freq))
+ val1c = RadioSettingValueString(0, 10,
+ bfc.bcd_decode_freq(
+ _mem.vfo.c.freq))
val1c.set_validate_callback(my_validate)
vfocfreq = RadioSetting("vfo.c.freq", "VFO C frequency", val1c)
vfocfreq.set_apply_callback(apply_freq, _mem.vfo.c)
work.append(vfocfreq)
if not self.COLOR_LCD4:
- val = convert_bytes_to_freq(_mem.vfo.d.freq)
+ val = bfc.bcd_decode_freq(_mem.vfo.d.freq)
if self.MODEL in ["GMRS-50V2", "GMRS-50X1"]:
if val[:3] > _vhf_upper and val[:3] < _uhf_lower:
val = "462.562500"
@@ -2275,8 +2277,8 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
preset.broadcast_station_name)
val = RadioSettingValueFloat(0, 108,
- convert_bytes_to_freq(
- preset.freq))
+ bfc.bcd_decode_freq(
+ preset.freq))
fmfreq = RadioSetting("fm_presets_" + str(i) + "_freq",
"Frequency " + str(i), val)
val.set_validate_callback(fm_validate)
diff --git a/chirp/drivers/fake.py b/chirp/drivers/fake.py
index 0872ae9..f7f3e85 100644
--- a/chirp/drivers/fake.py
+++ b/chirp/drivers/fake.py
@@ -1,10 +1,14 @@
+import importlib
import logging
+import os
+import struct
import time
from chirp import chirp_common
from chirp import directory
from chirp import errors
from chirp import settings
+from chirp import util
LOG = logging.getLogger(__name__)
@@ -147,6 +151,67 @@ class FakeKenwoodSerial:
return ret
+# NOTE: This is not complete, it's just enough to do the ident dance with
+# these radios
+class FakeUV17Serial:
+ def get_radio(self):
+ baofeng_uv17 = importlib.import_module('chirp.drivers.baofeng_uv17')
+ self.rclass = baofeng_uv17.UV17
+
+ def __init__(self, *a, **k):
+ self._sbuf = b''
+ self.get_radio()
+ imgfn = os.path.join(os.path.dirname(__file__), '..', '..',
+ 'tests', 'images',
+ '%s_%s.img' % (self.rclass.VENDOR,
+ self.rclass.MODEL))
+ LOG.debug('Opening %s' % imgfn)
+ try:
+ with open(imgfn, 'rb') as f:
+ self._img = f.read()
+ LOG.debug('Loaded image size 0x%x', len(self._img))
+ except FileNotFoundError:
+ LOG.error('Unable to open image, fixture will not work')
+ self._img = b''
+
+ def write(self, buffer):
+ baofeng_uv17Pro = importlib.import_module(
+ 'chirp.drivers.baofeng_uv17Pro')
+ if buffer == self.rclass._magic:
+ LOG.debug('Sent first magic')
+ self._sbuf += self.rclass._fingerprint
+ elif buffer.startswith(b'R'):
+ LOG.debug('Got: %s' % util.hexprint(buffer))
+ cmd, addr, blen = struct.unpack('>cHb', buffer)
+ resp = struct.pack('>cHb', b'W', addr, blen)
+ block = self._img[addr:addr + blen] or (b'\x00' * blen)
+ LOG.debug('Sending block length 0x%x', len(block))
+ self._sbuf += resp + baofeng_uv17Pro._crypt(1, block)
+ else:
+ for magic, rlen in self.rclass._magics:
+ if buffer == magic:
+ LOG.debug('Sent magic %r' % magic)
+ self._sbuf += b' ' * rlen
+ return
+ LOG.debug('Unrecognized ident string %r' % buffer)
+ self._sbuf += b'\x15' * 32
+
+ def read(self, length):
+ chunk = self._sbuf[:length]
+ self._sbuf = self._sbuf[length:]
+ return chunk
+
+ def close(self):
+ pass
+
+
+class FakeUV17ProSerial(FakeUV17Serial):
+ def get_radio(self):
+ baofeng_uv17Pro = importlib.import_module(
+ 'chirp.drivers.baofeng_uv17Pro')
+ self.rclass = baofeng_uv17Pro.UV17Pro
+
+
def register_fakes():
directory.register(FakeLiveRadio)
directory.register(FakeLiveSlowRadio)
diff --git a/chirp/drivers/ft1d.py b/chirp/drivers/ft1d.py
index f50ed1f..4882766 100644
--- a/chirp/drivers/ft1d.py
+++ b/chirp/drivers/ft1d.py
@@ -33,6 +33,16 @@ from chirp import util
LOG = logging.getLogger(__name__)
MEM_SETTINGS_FORMAT = """
+#seekto 0x047e;
+struct {
+ u8 unknown1;
+ u8 flag;
+ u16 unknown2;
+ struct {
+ u8 padded_yaesu[16];
+ } message;
+} opening_message;
+
#seekto 0x049a;
struct {
u8 vfo_a;
@@ -92,6 +102,11 @@ struct {
dw_rt:1; // 23 DW RVT;
} scan_settings;
+#seekto 0x54a;
+struct {
+ u16 in_use;
+} bank_used[24];
+
#seekto 0x064a;
struct {
u8 unknown0[4];
@@ -136,21 +151,17 @@ struct {
u8 checksum;
} vfo_info[6];
-#seekto 0x047e;
-struct {
- u8 unknown1;
- u8 flag;
- u16 unknown2;
- struct {
- u8 padded_yaesu[16];
- } message;
-} opening_message;
-
#seekto 0x%(dtmadd)04X; // FT-1D:0e4a, FT2D:094a
struct {
u8 memory[16];
} dtmf[10];
+#seekto 0x0EFE;
+struct {
+ u8 unknown[2];
+ u8 name[16];
+} bank_info[24];
+
#seekto 0x154a;
// These "channels" seem to actually be a structure:
// first five bits are flags
@@ -164,17 +175,6 @@ struct {
struct {
u16 channel[100];
} bank_members[24];
-
-#seekto 0x54a;
-struct {
- u16 in_use;
-} bank_used[24];
-
-#seekto 0x0EFE;
-struct {
- u8 unknown[2];
- u8 name[16];
-} bank_info[24];
"""
MEM_FORMAT = """
@@ -428,9 +428,16 @@ struct {
u8 unknown4:6,
gm_ring:2; // 24 GM RNG
u8 temp_cf; // Placeholder as not found
- u8 unknown5;
} first_settings;
+#seekto 0x04c0;
+struct {
+ u8 unknown1:5,
+ beep_level:3; // 05 BEP.LVL
+ u8 unknown2:6,
+ beep_select:2; // 04 BEEP
+ } beep_settings;
+
#seekto 0x04ed;
struct {
u8 unknown1:1,
@@ -443,13 +450,11 @@ struct {
unknown8:1;
} test_bit_field;
-#seekto 0x04c0;
+#seekto 0x0ced0;
struct {
- u8 unknown1:5,
- beep_level:3; // 05 BEP.LVL
- u8 unknown2:6,
- beep_select:2; // 04 BEEP
- } beep_settings;
+ char callsign[10]; // 63 MYCALL
+ u16 charset; // character set ID
+ } my_call;
#seekto 0xCF30;
struct {
@@ -486,12 +491,6 @@ struct {
char message[32];
} GM[10];
-#seekto 0x0ced0;
-struct {
- char callsign[10]; // 63 MYCALL
- u16 charset; // character set ID
- } my_call;
-
#seekto 0x1ddca;
struct {
struct {
@@ -828,9 +827,6 @@ class FT1Radio(yaesu_clone.YaesuCloneModeRadio):
_VFO_SCAN_MODE = ("BAND", "ALL")
_MEMORY_SCAN_MODE = ("BAND", "ALL")
- _SG_RE = re.compile(r"(?P<sign>[-+NESW]?)(?P<d>[\d]+)[\s\.,]*"
- "(?P<m>[\d]*)[\s\']*(?P<s>[\d]*)")
-
_RX_BAUD = ("off", "1200 baud", "9600 baud")
_TX_DELAY = ("100ms", "150ms", "200ms", "250ms", "300ms",
"400ms", "500ms", "750ms", "1000ms")
@@ -878,7 +874,7 @@ class FT1Radio(yaesu_clone.YaesuCloneModeRadio):
_SQUELCH = ["%d" % x for x in range(0, 16)]
_VOLUME = ["%d" % x for x in range(0, 33)]
_DG_ID = ["%d" % x for x in range(0, 100)]
- _GM_RING = ("OFF", "IN RING", "AlWAYS")
+ _GM_RING = ("OFF", "IN RING", "ALWAYS")
_GM_INTERVAL = ("LONG", "NORMAL", "OFF")
_MYCALL_CHR_SET = list(string.ascii_uppercase) + \
@@ -911,7 +907,7 @@ class FT1Radio(yaesu_clone.YaesuCloneModeRadio):
def process_mmap(self):
mem_format = MEM_SETTINGS_FORMAT + MEM_FORMAT + MEM_APRS_FORMAT + \
- MEM_BACKTRACK_FORMAT + MEM_GM_FORMAT + MEM_CHECKSUM_FORMAT
+ MEM_GM_FORMAT + MEM_BACKTRACK_FORMAT + MEM_CHECKSUM_FORMAT
self._memobj = bitwise.parse(mem_format % self._mem_params, self._mmap)
def get_features(self):
@@ -989,7 +985,7 @@ class FT1Radio(yaesu_clone.YaesuCloneModeRadio):
num += len(x[1])
# num -= len(x[1])
if array is None:
- raise IndexError("Unknown special %s", memref)
+ raise IndexError("Unknown special %s" % memref)
num += ndx
# num -= ndx
elif memref > self.MAX_MEM_SLOT: # numbered special
@@ -1003,7 +999,7 @@ class FT1Radio(yaesu_clone.YaesuCloneModeRadio):
break
ndx -= len(x[1])
if array is None:
- raise IndexError("Unknown memref number %s", memref)
+ raise IndexError("Unknown memref number %s" % memref)
else:
array = "memory"
ndx = memref - 1
diff --git a/chirp/drivers/ft450d.py b/chirp/drivers/ft450d.py
index 43c6407..e7e9dc1 100644
--- a/chirp/drivers/ft450d.py
+++ b/chirp/drivers/ft450d.py
@@ -31,8 +31,8 @@ import itertools
LOG = logging.getLogger(__name__)
CMD_ACK = b'\x06'
-# can't update chirp_common data modes for this radio, so for wierd
-# data modes with will use main mode of DIG and then have these sub-modes
+# can't update chirp_common data modes for this radio, so for weird
+# data modes we will use main mode of DIG and then have these sub-modes
DATA_MODES = ["USER-L", "USER-U", "RTTY", "N/A"]
T_STEPS = sorted(list(chirp_common.TUNING_STEPS))
T_STEPS.remove(30.0)
diff --git a/chirp/drivers/generic_csv.py b/chirp/drivers/generic_csv.py
index 92eb071..6744b80 100644
--- a/chirp/drivers/generic_csv.py
+++ b/chirp/drivers/generic_csv.py
@@ -96,6 +96,10 @@ class CSVRadio(chirp_common.FileBackedRadio):
self.file_has_rTone = None # Set in load(), used in _clean_tmode()
self.file_has_cTone = None
+ # Persistence for comment lines
+ # List of tuples of (previous_memory, comment)
+ self._comments = []
+
self._filename = pipe
if self._filename and os.path.exists(self._filename):
self.load()
@@ -201,9 +205,15 @@ class CSVRadio(chirp_common.FileBackedRadio):
def _load(self, f):
reader = csv.reader(f, delimiter=chirp_common.SEPCHAR, quotechar='"')
+ self._comments = []
good = 0
lineno = 0
+ last_number = -1
for line in reader:
+ # Skip (but stash) comment lines that start with #
+ if line and line[0].startswith('#'):
+ self._comments.append((last_number, ' '.join(line)))
+ continue
lineno += 1
if lineno == 1:
header = line
@@ -227,6 +237,7 @@ class CSVRadio(chirp_common.FileBackedRadio):
self.errors.append("Line %i: %s" % (lineno, e))
continue
+ last_number = mem.number
self._grow(mem.number)
self.memories[mem.number] = mem
good += 1
@@ -243,10 +254,23 @@ class CSVRadio(chirp_common.FileBackedRadio):
self._filename = filename
with open(self._filename, "w", newline='', encoding='utf-8') as f:
+ comments = list(self._comments)
writer = csv.writer(f, delimiter=chirp_common.SEPCHAR)
+
+ for index, comment in comments[:]:
+ if index >= 0:
+ break
+ writer.writerow([comment])
+ comments.pop(0)
+
writer.writerow(chirp_common.Memory.CSV_FORMAT)
for mem in self.memories:
+ for index, comment in comments[:]:
+ if index >= mem.number:
+ break
+ writer.writerow([comment])
+ comments.pop(0)
write_memory(writer, mem)
# MMAP compatibility
@@ -311,7 +335,13 @@ class CSVRadio(chirp_common.FileBackedRadio):
# CSV files are text
return False
return filename.lower().endswith("." + cls.FILE_EXTENSION) and \
- (filedata.startswith("Location,") or filedata == "")
+ (find_csv_header(filedata) or filedata == "")
+
+
+def find_csv_header(filedata):
+ while filedata.startswith('#'):
+ filedata = filedata[filedata.find('\n') + 1:]
+ return filedata.startswith('Location,')
@directory.register
diff --git a/chirp/drivers/gmrsuv1.py b/chirp/drivers/gmrsuv1.py
index adbab72..e275042 100644
--- a/chirp/drivers/gmrsuv1.py
+++ b/chirp/drivers/gmrsuv1.py
@@ -16,7 +16,7 @@
import logging
-from chirp.drivers import baofeng_common
+from chirp.drivers import baofeng_common as bfc
from chirp import chirp_common, directory
from chirp import bitwise
from chirp.settings import RadioSettingGroup, RadioSetting, \
@@ -89,7 +89,7 @@ def model_match(cls, data):
@directory.register
-class GMRSV1(baofeng_common.BaofengCommonHT):
+class GMRSV1(bfc.BaofengCommonHT):
"""BTech GMRS-V1"""
VENDOR = "BTECH"
MODEL = "GMRS-V1"
@@ -929,12 +929,6 @@ class GMRSV1(baofeng_common.BaofengCommonHT):
_mem.wmchannel.mrchb))
work.append(rs)
- def convert_bytes_to_freq(bytes):
- real_freq = 0
- for byte in bytes:
- real_freq = (real_freq * 10) + byte
- return chirp_common.format_freq(real_freq * 10)
-
def my_validate(value):
value = chirp_common.parse_freq(value)
msg = ("Can't be less than %i.0000")
@@ -955,14 +949,14 @@ class GMRSV1(baofeng_common.BaofengCommonHT):
value /= 10
val1a = RadioSettingValueString(0, 10,
- convert_bytes_to_freq(_mem.vfo.a.freq))
+ bfc.bcd_decode_freq(_mem.vfo.a.freq))
val1a.set_validate_callback(my_validate)
rs = RadioSetting("vfo.a.freq", "VFO A Frequency", val1a)
rs.set_apply_callback(apply_freq, _mem.vfo.a)
work.append(rs)
val1b = RadioSettingValueString(0, 10,
- convert_bytes_to_freq(_mem.vfo.b.freq))
+ bfc.bcd_decode_freq(_mem.vfo.b.freq))
val1b.set_validate_callback(my_validate)
rs = RadioSetting("vfo.b.freq", "VFO B Frequency", val1b)
rs.set_apply_callback(apply_freq, _mem.vfo.b)
diff --git a/chirp/drivers/gmrsv2.py b/chirp/drivers/gmrsv2.py
index 06d6171..ef6688b 100644
--- a/chirp/drivers/gmrsv2.py
+++ b/chirp/drivers/gmrsv2.py
@@ -16,7 +16,7 @@
import logging
-from chirp.drivers import baofeng_common
+from chirp.drivers import baofeng_common as bfc
from chirp import chirp_common, directory
from chirp import bitwise
from chirp import bandplan_na
@@ -73,7 +73,7 @@ LIST_VOICE = ["Off", "English", "Chinese"]
LIST_WORKMODE = ["Frequency", "Channel"]
-class GMRSV2base(baofeng_common.BaofengCommonHT):
+class GMRSV2base(bfc.BaofengCommonHT):
"""BTech GMRS-V2base"""
VENDOR = ""
MODEL = ""
@@ -252,14 +252,14 @@ class GMRSV2base(baofeng_common.BaofengCommonHT):
u8 keylock;
u8 cht;
u8 unused40[5];
- u8 unknown1:3,
+ u8 unknown3:3,
fmradio:1,
alarm:1,
unknown2:1,
reset:1,
menu:1;
u8 unused41;
- u8 unknown:7,
+ u8 unknown4:7,
workmode:1;
} settings;
@@ -902,12 +902,6 @@ class GMRSV2base(baofeng_common.BaofengCommonHT):
_mem.wmchannel.mrchb))
work.append(rs)
- def convert_bytes_to_freq(bytes):
- real_freq = 0
- for byte in bytes:
- real_freq = (real_freq * 10) + byte
- return chirp_common.format_freq(real_freq * 10)
-
def my_validate(value):
value = chirp_common.parse_freq(value)
msg = ("Can't be less than %i.0000")
@@ -928,14 +922,14 @@ class GMRSV2base(baofeng_common.BaofengCommonHT):
value /= 10
val1a = RadioSettingValueString(0, 10,
- convert_bytes_to_freq(_mem.vfo.a.freq))
+ bfc.bcd_decode_freq(_mem.vfo.a.freq))
val1a.set_validate_callback(my_validate)
rs = RadioSetting("vfo.a.freq", "VFO A Frequency", val1a)
rs.set_apply_callback(apply_freq, _mem.vfo.a)
work.append(rs)
val1b = RadioSettingValueString(0, 10,
- convert_bytes_to_freq(_mem.vfo.b.freq))
+ bfc.bcd_decode_freq(_mem.vfo.b.freq))
val1b.set_validate_callback(my_validate)
rs = RadioSetting("vfo.b.freq", "VFO B Frequency", val1b)
rs.set_apply_callback(apply_freq, _mem.vfo.b)
diff --git a/chirp/drivers/hg_uv98.py b/chirp/drivers/hg_uv98.py
index b70273f..0673466 100644
--- a/chirp/drivers/hg_uv98.py
+++ b/chirp/drivers/hg_uv98.py
@@ -134,10 +134,7 @@ MAX_ADDR = 0x2000
POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=1),
chirp_common.PowerLevel("High", watts=5)]
MODES = ["FM", "NFM"]
-SPECIAL_CHANNELS = {
- 129: ("VFO-A", "A"),
- 130: ("VFO-B", "B"),
-}
+SPECIAL_CHANNELS = ['VFO-A', 'VFO-B']
# Settings maps
ABR_LIST = [str(v) for v in range(0, 151, 5)]
@@ -277,10 +274,11 @@ class RadioSettingValueChannel(RadioSettingValueList):
def __init__(self, radio, current_raw):
current = int(current_raw)
current_mem = radio.get_memory(current)
+ lo, hi = radio.get_features().memory_bounds
options = [
self._format_memory(mem)
for mem in [radio.get_memory(n)
- for n in range(*radio.get_features().memory_bounds)]]
+ for n in range(lo, hi + 1)]]
RadioSettingValueList.__init__(self, options,
self._format_memory(current_mem))
@@ -344,7 +342,7 @@ class LanchonlhHG_UV98(chirp_common.CloneModeRadio, chirp_common.ExperimentalRad
rf.valid_skips = ["", "S"]
rf.valid_bands = [(136000000, 174000000), (400000000, 500000000)]
rf.valid_name_length = 8
- rf.valid_special_chans = [129, 130]
+ rf.valid_special_chans = SPECIAL_CHANNELS
rf.memory_bounds = (1, self._upper)
return rf
@@ -413,23 +411,30 @@ class LanchonlhHG_UV98(chirp_common.CloneModeRadio, chirp_common.ExperimentalRad
mem.dtcs_polarity = "%s%s" % (tpol, rpol)
def get_memory(self, number):
- _mem = self._memobj.memory[number - 1]
mem = chirp_common.Memory()
- mem.number = number
+
+ if isinstance(number, str):
+ mem.number = MAX_CHANNELS + SPECIAL_CHANNELS.index(number) + 1
+ mem.extd_number = number
+ elif number > MAX_CHANNELS:
+ mem.number = number
+ else:
+ mem.number = number
+ _name = self._memobj.name[mem.number - 1]
+
+ _mem = self._memobj.memory[mem.number - 1]
+
+ if mem.number > MAX_CHANNELS:
+ mem.immutable = ['name']
+ else:
+ mem.name, _, _ = _name.name.get_raw().partition(b"\xFF")
+ mem.name = mem.name.decode('ascii').rstrip()
if _mem.get_raw()[:4] == b"\xFF\xFF\xFF\xFF":
mem.empty = True
return mem
- if mem.number in SPECIAL_CHANNELS:
- mem.name, mem.extd_number = SPECIAL_CHANNELS[mem.number]
- else:
- _name = self._memobj.name[number - 1]
- mem.name, _, _ = _name.name.get_raw().partition(b"\xFF")
- mem.name = mem.name.decode('ascii')
- # XXX: other drivers rstrip the name and test_badname enforces this
- mem.name = mem.name.rstrip()
mem.freq = int(_mem.rx_freq) * 10
offset = (int(_mem.tx_freq) * 10) - mem.freq
if offset < 0:
@@ -499,7 +504,7 @@ class LanchonlhHG_UV98(chirp_common.CloneModeRadio, chirp_common.ExperimentalRad
_mem.set_raw(b"\xFF" * 16)
return
- if mem.number not in SPECIAL_CHANNELS:
+ if mem.number < 129:
_name = self._memobj.name[mem.number - 1]
_namelength = self.get_features().valid_name_length
for i in range(NAME_FIELD_SIZE):
diff --git a/chirp/drivers/icv80.py b/chirp/drivers/icv80.py
index 9747711..7a753e7 100644
--- a/chirp/drivers/icv80.py
+++ b/chirp/drivers/icv80.py
@@ -25,8 +25,6 @@ LOG = logging.getLogger(__name__)
ICV80_MEM_FORMAT = """
-
-#seekto 0x0000;
struct {
ul16 freq;
ul16 offset;
@@ -48,15 +46,13 @@ struct {
dtcs_polarity:2,
unknown8:2,
tmode:2;
- u8 unknown8:5,
+ u8 unknown9:5,
tx_inhibit:1,
power:2;
-} memory[208];
+} memory[207];
-#seekto 0x0cf0;
u8 skip[32];
-#seekto 0x0d10;
u8 unused[32];
#seekto 0x0e50;
@@ -481,7 +477,7 @@ class ICV80Radio(icf.IcomCloneModeRadio, chirp_common.ExperimentalRadio):
_skip |= bit
return
- _mem.set_raw(b'\x00' * 15)
+ _mem.set_raw(b'\x00' * 16)
if chirp_common.required_step(mem.freq) == 12.5:
mult = 6250
diff --git a/chirp/drivers/id880.py b/chirp/drivers/id880.py
index ffd1291..26d00f5 100644
--- a/chirp/drivers/id880.py
+++ b/chirp/drivers/id880.py
@@ -81,7 +81,7 @@ u8 name_flags[132];
"""
TMODES = ["", "Tone", "TSQL", "TSQL", "DTCS", "DTCS", "TSQL-R", "DTCS-R"]
-DUPLEX = ["", "-", "+", "?3"]
+DUPLEX = ["", "-", "+", ""]
DTCSP = ["NN", "NR", "RN", "RR"]
MODES = ["FM", "NFM", "WFM", "AM", "NAM", "DV"]
STEPS = [5.0, 6.25, 8.33, 9.0, 10.0, 12.5, 15.0, 20.0, 25.0, 30.0, 50.0,
diff --git a/chirp/drivers/iradio_uv_5118plus.py b/chirp/drivers/iradio_uv_5118plus.py
index 0666c4f..a4166be 100644
--- a/chirp/drivers/iradio_uv_5118plus.py
+++ b/chirp/drivers/iradio_uv_5118plus.py
@@ -550,11 +550,13 @@ class IradioUV5118plus(chirp_common.CloneModeRadio):
mem.extra.append(rset)
rs = RadioSettingValueInteger(0, 16777215, _mem.mutecode)
- rset = RadioSetting("mutecode", "Mute Code (0-16777215)", rs)
+ rset = RadioSetting("mutecode", "Mute Code", rs)
+ rset.set_doc('Value between 0-16777215')
mem.extra.append(rset)
rs = RadioSettingValueInteger(0, 8, _mem.scno)
- rset = RadioSetting("scno", "SC No. (0-8)", rs)
+ rset = RadioSetting("scno", "SC No.", rs)
+ rset.set_doc('Value between 0-8')
mem.extra.append(rset)
return mem
diff --git a/chirp/drivers/kenwood_hmk.py b/chirp/drivers/kenwood_hmk.py
index 65a9ccc..f0bba10 100644
--- a/chirp/drivers/kenwood_hmk.py
+++ b/chirp/drivers/kenwood_hmk.py
@@ -124,8 +124,8 @@ class HMKRadio(generic_csv.CSVRadio):
good += 1
if not good:
- for e in errors:
- LOG.error("kenwood_hmk: %s", e)
+ for error in errors:
+ LOG.error("kenwood_hmk: %s", error)
raise errors.InvalidDataError("No channels found")
@classmethod
diff --git a/chirp/drivers/kenwood_itm.py b/chirp/drivers/kenwood_itm.py
index cf98f07..5544f49 100644
--- a/chirp/drivers/kenwood_itm.py
+++ b/chirp/drivers/kenwood_itm.py
@@ -128,8 +128,8 @@ class ITMRadio(generic_csv.CSVRadio):
good += 1
if not good:
- for e in errors:
- LOG.error("kenwood_itm: %s", e)
+ for error in errors:
+ LOG.error("kenwood_itm: %s", error)
raise errors.InvalidDataError("No channels found")
@classmethod
diff --git a/chirp/drivers/kg935g.py b/chirp/drivers/kg935g.py
index 9a9e927..0a179b9 100644
--- a/chirp/drivers/kg935g.py
+++ b/chirp/drivers/kg935g.py
@@ -1312,9 +1312,6 @@ class KG935GRadio(chirp_common.CloneModeRadio,
# always set it even if no dtcs is used
mem.dtcs_polarity = "%s%s" % (tpol or "N", rpol or "N")
- LOG.debug("Got TX %s (%i) RX %s (%i)" %
- (txmode, _mem.txtone, rxmode, _mem.rxtone))
-
def get_memory(self, number):
_mem = self._memobj.memory[number]
_nam = self._memobj.names[number]
@@ -1322,7 +1319,6 @@ class KG935GRadio(chirp_common.CloneModeRadio,
mem = chirp_common.Memory()
mem.number = number
_valid = self._memobj.valid[mem.number]
- LOG.debug("%d %s", number, _valid == MEM_VALID)
if _valid != MEM_VALID:
mem.empty = True
return mem
@@ -1542,9 +1538,8 @@ class KG935GRadio(chirp_common.CloneModeRadio,
callchars = "0123456789"
for i in range(1, 21):
- callnum = str(i)
_msg = ""
- _msg1 = str(eval("_callname.call_name"+callnum)).split("\0")[0]
+ _msg1 = str(getattr(_callname, 'call_name%i' % i)).split('\0')[0]
# MRT - Handle default factory values of 0xFF or
# non-ascii values in Call Name memory
for char in _msg1:
@@ -1554,8 +1549,8 @@ class KG935GRadio(chirp_common.CloneModeRadio,
_msg += str(char)
val = RadioSettingValueString(0, 6, _msg)
val.set_mutable(True)
- rs = RadioSetting("call_names.call_name"+callnum,
- "Call Name "+callnum, val)
+ rs = RadioSetting("call_names.call_name%i" % i,
+ "Call Name %i" % i, val)
call_grp.append(rs)
x = i - 1
@@ -1564,7 +1559,7 @@ class KG935GRadio(chirp_common.CloneModeRadio,
self.callid2str(callid.cid),
False)
rs = RadioSetting("call_ids[%i].cid" % x,
- "Call Code %s" % str(i), c_id)
+ "Call Code %i" % i, c_id)
rs.set_apply_callback(apply_callid, callid)
call_grp.append(rs)
@@ -1819,24 +1814,16 @@ class KG935GRadio(chirp_common.CloneModeRadio,
scan_grp.append(rs)
for i in range(1, 11):
- scgroup = str(i)
-
- rs = RadioSetting("scan_groups.Group_lower"+scgroup,
- "Scan Group "+scgroup+" Lower",
- RadioSettingValueInteger(1, 999,
- eval("self._memobj. \
- scan_groups. \
- Group_lower" +
- scgroup)))
+ val = getattr(self._memobj.scan_groups, 'Group_lower%i' % i)
+ rs = RadioSetting("scan_groups.Group_lower%i" % i,
+ "Scan Group %i Lower" % i,
+ RadioSettingValueInteger(1, 999, val))
scan_grp.append(rs)
- rs = RadioSetting("scan_groups.Group_upper"+scgroup,
- "Scan Group "+scgroup+" Upper",
- RadioSettingValueInteger(1, 999,
- eval("self._memobj. \
- scan_groups. \
- Group_upper" +
- scgroup)))
+ val = getattr(self._memobj.scan_groups, 'Group_upper%i' % i)
+ rs = RadioSetting("scan_groups.Group_upper%i" % i,
+ "Scan Group %i Upper" % i,
+ RadioSettingValueInteger(1, 999, val))
scan_grp.append(rs)
# VFO A Settings
@@ -2008,12 +1995,9 @@ class KG935GRadio(chirp_common.CloneModeRadio,
# memory stores raw integer value like 760
# radio will divide 760 by 10 and interpret correctly at 76.0 MHz
for i in range(1, 21):
- chan = str(i)
- rs = RadioSetting("FM_radio" + chan, "FM Preset" + chan,
- RadioSettingValueFloat(76.0, 108.0,
- eval("_settings. \
- FM_radio" +
- chan)/10.0,
+ val = getattr(_settings, 'FM_radio%i' % i)
+ rs = RadioSetting("FM_radio%i" % i, "FM Preset %i" % i,
+ RadioSettingValueFloat(76.0, 108.0, val / 10,
0.1, 1))
fmradio_grp.append(rs)
diff --git a/chirp/drivers/kguv980p.py b/chirp/drivers/kguv980p.py
index f171d35..ae7b5d5 100644
--- a/chirp/drivers/kguv980p.py
+++ b/chirp/drivers/kguv980p.py
@@ -53,7 +53,7 @@ DIR_FROM = 0x00
config_map = ( # map address, write size, write count
# (0x0, 64, 512), # 0 to 8000 - full write use only
(0x4c, 12, 1), # Mode PSW -- Display name
- (0x60, 44, 1), # Freq Limits
+ (0x60, 16, 3), # Freq Limits
(0x740, 40, 1), # FM chan 1-20
(0x830, 16, 13), # General settings
(0x900, 8, 1), # General settings
@@ -68,6 +68,7 @@ config_map = ( # map address, write size, write count
MEM_VALID = 0x00
+MEM_INVALID = [0x80]
TX_BLANK = 0x40
RX_BLANK = 0x80
@@ -1006,14 +1007,31 @@ class KG980PRadio(chirp_common.CloneModeRadio,
mem = chirp_common.Memory()
mem.number = number
_valid = self._memobj.valid[mem.number]
+ _nam = self._memobj.names[number]
- if (_valid != MEM_VALID) & ((_mem.rxfreq == 0xFFFFFFFF) or
- _mem.rxfreq == 0x00000000):
+ # Handle deleted channel quirks due to radio firmware
+ # not always clearing the valid channel indicators
+ # _valid == 0x80 indicates channel was deleted thru radio menu and
+ # only part of the channel structure data is cleared by firmware
+ # _valid == 0x00 indicates the channel is Valid
+ # all other values the firmware uses for _valid: look for valid
+ # Rx and Tx freq values to determine validity
+ if (_valid in MEM_INVALID or
+ ((_valid != MEM_VALID) & ((_mem.rxfreq == 0xFFFFFFFF) or
+ _mem.rxfreq == 0x00000000))):
mem.empty = True
+ if _valid == 0x80:
+ LOG.debug("Ch %s was deleted by using radio menu" % number)
+ LOG.debug("Current Memory: \n%s" % _mem)
+ LOG.debug("Clearing Ch %s memory" % number)
+ _mem.set_raw(b"\xFF" * (_mem.size() // 8))
+ _nam.set_raw(b"\xFF" * (_nam.size() // 8))
+ self._memobj.valid[mem.number] = 0xFF
return mem
elif (_valid != MEM_VALID) & ((_mem.rxfreq != 0xFFFFFFFF) and
(_mem.rxfreq != 0x00000000)):
mem.empty = False
+ self._memobj.valid[mem.number] = MEM_VALID
else:
mem.empty = False
mem.freq = int(_mem.rxfreq) * 10
@@ -1122,9 +1140,8 @@ class KG980PRadio(chirp_common.CloneModeRadio,
if mem.empty:
self._memobj.valid[number] = 0xFF
- _mem.rxfreq = 0xFFFFFFFF
- _mem.txfreq = 0xFFFFFFFF
- self._memobj.names[number].set_raw("\xFF" * (_nam.size() // 8))
+ _mem.set_raw(b"\xFF" * (_mem.size() // 8))
+ self._memobj.names[number].set_raw(b"\xFF" * (_nam.size() // 8))
else:
if len(mem.name) > 0:
_mem.named = True
@@ -1168,18 +1185,15 @@ class KG980PRadio(chirp_common.CloneModeRadio,
_mem.scrambler = 0
_mem.compander = 0
# set the power
- if mem.power:
- _mem.power = self.POWER_LEVELS.index(mem.power)
- else:
- _mem.power = True
- # pwr_index= mem.power
+ # Updated to resolve "Illegal set on attribute power" Warning
if str(mem.power) == "None":
- mem.power = self.POWER_LEVELS[1]
- index = self.POWER_LEVELS.index(mem.power)
- if index == 2:
- _mem.power = 0b11
+ _mem.power = 0 # Default to Low power
else:
- _mem.power = self.POWER_LEVELS.index(mem.power)
+ index = self.POWER_LEVELS.index(mem.power)
+ if index == 2:
+ _mem.power = 0b11 # Force H to value of binary 3
+ else:
+ _mem.power = index
# Not sure what this bit does yet but it causes
# the radio to display
# MED power when the CPS shows Low Power.
@@ -1197,6 +1211,7 @@ class KG980PRadio(chirp_common.CloneModeRadio,
# set to mute mode to QT (not QT+DTMF or QT*DTMF) by default
# This changes them in the channel memory
_mem.mute_mode = 1
+ self._memobj.valid[number] = MEM_VALID
def _get_settings(self):
_settings = self._memobj.settings
@@ -1642,48 +1657,42 @@ class KG980PRadio(chirp_common.CloneModeRadio,
val = RadioSettingValueInteger(0, 999, _temp)
rs = RadioSetting("bandlimits.limit_144M_ChA_rx_start",
"144M Area A Rx Lower Limit (MHz)",
- RadioSettingValueInteger(0, 999,
- val))
+ val)
rxlim_grp.append(rs)
_temp = int(s.bandlimits.limit_144M_ChA_rx_stop) // 10
val = RadioSettingValueInteger(0, 999, _temp)
rs = RadioSetting("bandlimits.limit_144M_ChA_rx_stop",
"144M Area A Rx Upper Limit (+ .9975 MHz)",
- RadioSettingValueInteger(0, 999,
- val))
+ val)
rxlim_grp.append(rs)
_temp = int(s.bandlimits.limit_144M_ChB_rx_start) // 10
val = RadioSettingValueInteger(0, 999, _temp)
rs = RadioSetting("bandlimits.limit_144M_ChB_rx_start",
"144M Area B Rx Lower Limit (MHz)",
- RadioSettingValueInteger(0, 999,
- val))
+ val)
rxlim_grp.append(rs)
_temp = int(s.bandlimits.limit_144M_ChB_rx_stop) // 10
val = RadioSettingValueInteger(0, 999, _temp)
rs = RadioSetting("bandlimits.limit_144M_ChB_rx_stop",
"144M Area B Rx Upper Limit (+ .9975 MHz)",
- RadioSettingValueInteger(0, 999,
- val))
+ val)
rxlim_grp.append(rs)
_temp = int(s.bandlimits.limit_70cm_rx_start) // 10
val = RadioSettingValueInteger(0, 999, _temp)
rs = RadioSetting("bandlimits.limit_70cm_rx_start",
"450M Rx Lower Limit (MHz)",
- RadioSettingValueInteger(0, 999,
- val))
+ val)
rxlim_grp.append(rs)
_temp = int(s.bandlimits.limit_70cm_rx_stop) // 10
val = RadioSettingValueInteger(0, 999, _temp)
rs = RadioSetting("bandlimits.limit_70cm_rx_stop",
"450M Rx Upper Limit (+ .9975 MHz)",
- RadioSettingValueInteger(0, 999,
- val))
+ val)
rxlim_grp.append(rs)
if self.MODEL == "KG-UV980P":
@@ -1691,96 +1700,84 @@ class KG980PRadio(chirp_common.CloneModeRadio,
val = RadioSettingValueInteger(0, 999, _temp)
rs = RadioSetting("bandlimits.limit_10m_rx_start",
"20M Rx Lower Limit (MHz)",
- RadioSettingValueInteger(0, 999,
- val))
+ val)
rxlim_grp.append(rs)
_temp = int(s.bandlimits.limit_10m_rx_stop) // 10
val = RadioSettingValueInteger(0, 999, _temp)
rs = RadioSetting("bandlimits.limit_10m_rx_stop",
"20M Rx Upper Limit (+ .9975 MHz)",
- RadioSettingValueInteger(0, 999,
- val))
+ val)
rxlim_grp.append(rs)
_temp = int(s.bandlimits.limit_6m_rx_start) // 10
val = RadioSettingValueInteger(0, 999, _temp)
rs = RadioSetting("bandlimits.limit_6m_rx_start",
"50M Rx Lower Limit (MHz)",
- RadioSettingValueInteger(0, 999,
- val))
+ val)
rxlim_grp.append(rs)
_temp = int(s.bandlimits.limit_6m_rx_stop) // 10
val = RadioSettingValueInteger(0, 999, _temp)
rs = RadioSetting("bandlimits.limit_6m_rx_stop",
"50M Rx Upper Limit (+ .9975 MHz)",
- RadioSettingValueInteger(0, 999,
- val))
+ val)
rxlim_grp.append(rs)
_temp = int(s.bandlimits.limit_350M_rx_start) // 10
val = RadioSettingValueInteger(0, 999, _temp)
rs = RadioSetting("bandlimits.limit_350M_rx_start",
"350M Rx Lower Limit (MHz)",
- RadioSettingValueInteger(0, 999,
- val))
+ val)
rxlim_grp.append(rs)
_temp = int(s.bandlimits.limit_350M_rx_stop) // 10
val = RadioSettingValueInteger(0, 999, _temp)
rs = RadioSetting("bandlimits.limit_350M_rx_stop",
"350M Rx Upper Limit (+ .9975 MHz)",
- RadioSettingValueInteger(0, 999,
- val))
+ val)
rxlim_grp.append(rs)
_temp = int(s.bandlimits.limit_850M_rx_start) // 10
val = RadioSettingValueInteger(0, 999, _temp)
rs = RadioSetting("bandlimits.limit_850M_rx_start",
"850M Rx Lower Limit (MHz)",
- RadioSettingValueInteger(0, 999,
- val))
+ val)
rxlim_grp.append(rs)
_temp = int(s.bandlimits.limit_850M_rx_stop) // 10
val = RadioSettingValueInteger(0, 999, _temp)
rs = RadioSetting("bandlimits.limit_850M_rx_stop",
"850M Rx Upper Limit (+ .9975 MHz)",
- RadioSettingValueInteger(0, 999,
- val))
+ val)
rxlim_grp.append(rs)
if self.MODEL == "KG-UV980P":
_temp = int(s.bandlimits.limit_144M_tx_start) // 10
val = RadioSettingValueInteger(0, 999, _temp)
rs = RadioSetting("bandlimits.limit_144M_tx_start",
"144M Tx Lower Limit (MHz)",
- RadioSettingValueInteger(0, 999,
- val))
+ val)
txlim_grp.append(rs)
_temp = int(s.bandlimits.limit_144M_tx_stop) // 10
val = RadioSettingValueInteger(0, 999, _temp)
rs = RadioSetting("bandlimits.limit_144M_tx_stop",
"144M Tx Upper Limit (+ .9975 MHz)",
- RadioSettingValueInteger(0, 999,
- val))
+ val)
txlim_grp.append(rs)
_temp = int(s.bandlimits.limit_70cm_tx_start) // 10
val = RadioSettingValueInteger(0, 999, _temp)
rs = RadioSetting("bandlimits.limit_70cm_tx_start",
"450M Tx Lower Limit (MHz)",
- RadioSettingValueInteger(0, 999,
- val))
+ val)
txlim_grp.append(rs)
_temp = int(s.bandlimits.limit_70cm_tx_stop) // 10
val = RadioSettingValueInteger(0, 999, _temp)
rs = RadioSetting("bandlimits.limit_70cm_tx_stop",
"450M tx Upper Limit (+ .9975 MHz)",
- RadioSettingValueInteger(0, 999,
- val))
+ val)
txlim_grp.append(rs)
if self.MODEL == "KG-UV980P":
@@ -1788,32 +1785,28 @@ class KG980PRadio(chirp_common.CloneModeRadio,
val = RadioSettingValueInteger(0, 999, _temp)
rs = RadioSetting("bandlimits.limit_10m_tx_start",
"20M tx Lower Limit (MHz)",
- RadioSettingValueInteger(0, 999,
- val))
+ val)
txlim_grp.append(rs)
_temp = int(s.bandlimits.limit_10m_tx_stop) // 10
val = RadioSettingValueInteger(0, 999, _temp)
rs = RadioSetting("bandlimits.limit_10m_tx_stop",
"20M tx Upper Limit (+ .9975 MHz)",
- RadioSettingValueInteger(0, 999,
- val))
+ val)
txlim_grp.append(rs)
_temp = int(s.bandlimits.limit_6m_tx_start) // 10
val = RadioSettingValueInteger(0, 999, _temp)
rs = RadioSetting("bandlimits.limit_6m_tx_start",
"50M tx Lower Limit (MHz)",
- RadioSettingValueInteger(0, 999,
- val))
+ val)
txlim_grp.append(rs)
_temp = int(s.bandlimits.limit_6m_tx_stop) // 10
val = RadioSettingValueInteger(0, 999, _temp)
rs = RadioSetting("bandlimits.limit_6m_tx_stop",
"50M tx Upper Limit (+ .9975 MHz)",
- RadioSettingValueInteger(0, 999,
- val))
+ val)
txlim_grp.append(rs)
# VFO Settings
@@ -2352,7 +2345,7 @@ class KG980PRadio(chirp_common.CloneModeRadio,
for i in range(1, 11):
x = str(i)
- _str = _decode(eval("_settings.scanname"+x))
+ _str = _decode(getattr(_settings, 'scanname%s' % x))
LOG.debug("ScanName %s", i)
LOG.debug("is %s", _str)
# CPS treats PPPPPP as a blank name as it is the factory reset
@@ -2382,19 +2375,13 @@ class KG980PRadio(chirp_common.CloneModeRadio,
RadioSettingValueString(0, 8, _str))
scanname_grp.append(rs)
- scngrp = str(i)
- rs = RadioSetting("scanlower"+scngrp, "Scan Lower "+scngrp,
- RadioSettingValueInteger(1, 999,
- eval(
- "_settings.\
- scanlower" +
- scngrp)))
+ val = getattr(_settings, 'scanlower%i' % i)
+ rs = RadioSetting("scanlower%i" % i, "Scan Lower %i" % i,
+ RadioSettingValueInteger(1, 999, val))
scan_grp.append(rs)
- rs = RadioSetting("scanupper"+scngrp, "Scan Upper "+scngrp,
- RadioSettingValueInteger(1, 999,
- eval(
- "_settings.scanupper" +
- scngrp)))
+ val = getattr(_settings, 'scanupper%i' % i)
+ rs = RadioSetting("scanupper%i" % i, "Scan Upper %i" % i,
+ RadioSettingValueInteger(1, 999, val))
scan_grp.append(rs)
# remote settings
rs = RadioSetting("rc_power", "RC Power",
diff --git a/chirp/drivers/kguv9dplus.py b/chirp/drivers/kguv9dplus.py
index 53c8443..7cae5a7 100644
--- a/chirp/drivers/kguv9dplus.py
+++ b/chirp/drivers/kguv9dplus.py
@@ -2784,28 +2784,28 @@ class KGUV9PXRadio(KGUV9DPlusRadio):
(l.lim_150M_Txlower_limit) / 10.0)
rs = RadioSetting("limits.lim_150M_Txlower_limit",
"150M Tx Lower Limit (MHz)",
- RadioSettingValueInteger(136, 180, val))
+ val)
limgrp.append(rs)
val = RadioSettingValueInteger(136, 180,
(l.lim_150M_Txupper_limit) / 10.0)
rs = RadioSetting("limits.lim_150M_Txupper_limit",
"150M Tx Upper Limit (MHz + 0.9975)",
- RadioSettingValueInteger(136, 180, val))
+ val)
limgrp.append(rs)
val = RadioSettingValueInteger(400, 512,
(l.lim_450M_Txlower_limit) / 10.0)
rs = RadioSetting("limits.lim_450M_Txlower_limit",
"450M Tx Lower Limit (MHz)",
- RadioSettingValueInteger(400, 512, val))
+ val)
limgrp.append(rs)
val = RadioSettingValueInteger(400, 512,
(l.lim_450M_Txupper_limit) / 10.0)
rs = RadioSetting("limits.lim_450M_Txupper_limit",
"450M Tx Upper Limit (MHz + 0.9975)",
- RadioSettingValueInteger(400, 512, val))
+ val)
limgrp.append(rs)
val = RadioSettingValueInteger(108, 180,
@@ -2813,8 +2813,7 @@ class KGUV9PXRadio(KGUV9DPlusRadio):
10.0)
rs = RadioSetting("limits.lim_150M_area_a_rxlower_limit",
"Rcvr A 150M Rx Lower Limit (MHz)",
- RadioSettingValueInteger(108, 180,
- val))
+ val)
limgrp.append(rs)
val = RadioSettingValueInteger(108, 180,
@@ -2822,8 +2821,7 @@ class KGUV9PXRadio(KGUV9DPlusRadio):
10.0)
rs = RadioSetting("limits.lim_150M_area_a_rxupper_limit",
"Rcvr A 150M Rx Upper Limit (MHz + 0.9975)",
- RadioSettingValueInteger(108, 180,
- val))
+ val)
limgrp.append(rs)
val = RadioSettingValueInteger(136, 180,
@@ -2831,8 +2829,7 @@ class KGUV9PXRadio(KGUV9DPlusRadio):
10.0)
rs = RadioSetting("limits.lim_150M_area_b_rxlower_limit",
"Rcvr B 150M Rx Lower Limit (MHz)",
- RadioSettingValueInteger(136, 180,
- val))
+ val)
limgrp.append(rs)
val = RadioSettingValueInteger(136, 180,
@@ -2840,71 +2837,62 @@ class KGUV9PXRadio(KGUV9DPlusRadio):
10.0)
rs = RadioSetting("limits.lim_150M_area_b_rxupper_limit",
"Rcvr B 150M Rx Upper Limit (MHz + 0.9975)",
- RadioSettingValueInteger(136, 180,
- val))
+ val)
limgrp.append(rs)
val = RadioSettingValueInteger(400, 512,
(l.lim_450M_rxlower_limit) / 10.0)
rs = RadioSetting("limits.lim_450M_rxlower_limit",
"450M Rx Lower Limit (MHz)",
- RadioSettingValueInteger(400, 512,
- val))
+ val)
limgrp.append(rs)
val = RadioSettingValueInteger(400, 512,
(l.lim_450M_rxupper_limit) / 10.0)
rs = RadioSetting("limits.lim_450M_rxupper_limit",
"450M Rx Upper Limit (MHz + 0.9975)",
- RadioSettingValueInteger(400, 512,
- val))
+ val)
limgrp.append(rs)
val = RadioSettingValueInteger(350, 399,
(l.lim_300M_rxlower_limit) / 10.0)
rs = RadioSetting("limits.lim_300M_rxlower_limit",
"300M Rx Lower Limit (MHz)",
- RadioSettingValueInteger(350, 399,
- val))
+ val)
limgrp.append(rs)
val = RadioSettingValueInteger(350, 399,
(l.lim_300M_rxupper_limit) / 10.0)
rs = RadioSetting("limits.lim_300M_rxupper_limit",
"300M Rx Upper Limit (MHz + 0.9975)",
- RadioSettingValueInteger(350, 399,
- val))
+ val)
limgrp.append(rs)
val = RadioSettingValueInteger(700, 986,
(l.lim_800M_rxlower_limit) / 10.0)
rs = RadioSetting("limits.lim_800M_rxlower_limit",
"800M Rx Lower Limit (MHz)",
- RadioSettingValueInteger(700, 986,
- val))
+ val)
limgrp.append(rs)
val = RadioSettingValueInteger(700, 986,
(l.lim_800M_rxupper_limit) / 10.0)
rs = RadioSetting("limits.lim_800M_rxupper_limit",
"800M Rx Upper Limit (MHz + 0.9975)",
- RadioSettingValueInteger(700, 986,
- val))
+ val)
limgrp.append(rs)
val = RadioSettingValueInteger(219, 250,
(l.lim_210M_rxlower_limit) / 10.0)
rs = RadioSetting("limits.lim_210M_rxlower_limit",
"210M Rx Lower Limit (MHz)",
- RadioSettingValueInteger(219, 250,
- val))
+ val)
limgrp.append(rs)
val = RadioSettingValueInteger(219, 250,
(l.lim_210M_rxupper_limit) / 10.0)
rs = RadioSetting("limits.lim_210M_rxupper_limit",
"210M Rx Upper Limit (MHz + 0.9975)",
- RadioSettingValueInteger(219, 250,
- val))
+ val)
limgrp.append(rs)
return limgrp
diff --git a/chirp/drivers/kyd.py b/chirp/drivers/kyd.py
index b83dff1..c79a9a3 100644
--- a/chirp/drivers/kyd.py
+++ b/chirp/drivers/kyd.py
@@ -312,7 +312,7 @@ class NC630aRadio(chirp_common.CloneModeRadio):
mem.empty = True
return mem
- if _mem.rxfreq.get_raw(asbytes=False) == "\xFF\xFF\xFF\xFF":
+ if _mem.rxfreq.get_raw() == b"\xFF\xFF\xFF\xFF":
mem.freq = 0
mem.empty = True
return mem
@@ -320,6 +320,8 @@ class NC630aRadio(chirp_common.CloneModeRadio):
if int(_mem.rxfreq) == int(_mem.txfreq):
mem.duplex = ""
mem.offset = 0
+ elif _mem.txfreq.get_raw() == b"\xFF\xFF\xFF\xFF":
+ mem.duplex = "off"
else:
mem.duplex = int(_mem.rxfreq) > int(_mem.txfreq) and "-" or "+"
mem.offset = abs(int(_mem.rxfreq) - int(_mem.txfreq)) * 10
@@ -390,16 +392,15 @@ class NC630aRadio(chirp_common.CloneModeRadio):
_skp = self._memobj.skipflags[bytepos]
if mem.empty:
- _mem.set_raw("\xFF" * 16)
+ _mem.fill_raw(b"\xFF")
return
- _mem.set_raw("\x00" * 14 + "\xFF" * 2)
+ _mem.set_raw(b"\x00" * 14 + b"\xFF" * 2)
_mem.rxfreq = mem.freq / 10
if mem.duplex == "off":
- for i in range(0, 4):
- _mem.txfreq[i].set_raw("\xFF")
+ _mem.txfreq.fill_raw(b"\xFF")
elif mem.duplex == "split":
_mem.txfreq = mem.offset / 10
elif mem.duplex == "+":
diff --git a/chirp/drivers/kyd_IP620.py b/chirp/drivers/kyd_IP620.py
index 9a779b5..2666fbe 100644
--- a/chirp/drivers/kyd_IP620.py
+++ b/chirp/drivers/kyd_IP620.py
@@ -37,11 +37,11 @@ struct { // Channel memory structure
ul16 rx_tone; // RX tone
ul16 tx_tone; // TX tone
u8 unknown_1:4, // n-a
- busy_loc:2, // NO-00, Crrier wave-01, SM-10
+ busy_loc:2, // NO-00, Carrier wave-01, SM-10
n_a:2; // n-a
u8 unknown_2:1, // n-a
scan_add:1, // Scan add
- n_a:1, // n-a
+ n_a2:1, // n-a
w_n:1, // Narrow-0 Wide-1
lout:1, // LOCKOUT OFF-0 ON-1
n_a_:1, // n-a
@@ -67,7 +67,7 @@ struct { // Settings memory structure ( A-Frequency mode )
n_a:2;
u8 unknown_1_6:3,
freq_a_w_n:1,
- n_a:1,
+ n_a2:1,
na:1,
freq_a_power:2;
u8 unknown_1_7;
@@ -371,9 +371,8 @@ class IP620Radio(chirp_common.CloneModeRadio,
_nam = self._memobj.chan_names[number - 1]
def _is_empty():
- for i in range(0, 4):
- if _mem.rx_freq[i].get_raw(asbytes=False) != "\xFF":
- return False
+ if _mem.rx_freq.get_raw() != b"\xFF\xFF\xFF\xFF":
+ return False
return True
mem = chirp_common.Memory()
@@ -388,6 +387,8 @@ class IP620Radio(chirp_common.CloneModeRadio,
if int(_mem.rx_freq) == int(_mem.tx_freq):
mem.duplex = ""
mem.offset = 0
+ elif _mem.tx_freq.get_raw() == b"\xFF\xFF\xFF\xFF":
+ mem.duplex = "off"
else:
mem.duplex = int(_mem.rx_freq) > int(_mem.tx_freq) and "-" or "+"
mem.offset = abs(int(_mem.rx_freq) - int(_mem.tx_freq)) * 10
@@ -468,13 +469,12 @@ class IP620Radio(chirp_common.CloneModeRadio,
def set_memory(self, mem):
_mem = self._memobj.memory[mem.number - 1]
if mem.empty:
- _mem.set_raw("\xFF" * (_mem.size() // 8))
+ _mem.fill_raw(b"\xFF")
return
_mem.rx_freq = mem.freq / 10
- if mem.duplex == "OFF":
- for i in range(0, 4):
- _mem.tx_freq[i].set_raw("\xFF")
+ if mem.duplex == "off":
+ _mem.tx_freq.fill_raw(b"\xFF")
elif mem.duplex == "+":
_mem.tx_freq = (mem.freq + mem.offset) / 10
elif mem.duplex == "-":
diff --git a/chirp/drivers/leixen.py b/chirp/drivers/leixen.py
index 777b2be..a4628bd 100644
--- a/chirp/drivers/leixen.py
+++ b/chirp/drivers/leixen.py
@@ -28,21 +28,21 @@ LOG = logging.getLogger(__name__)
MEM_FORMAT = """
#seekto 0x0184;
struct {
- u8 unknown:4,
+ u8 unknown1:4,
sql:4; // squelch level
- u8 unknown0x0185;
+ u8 unknown2;
u8 obeep:1, // open beep
dw_off:1, // dual watch (inverted)
kbeep:1, // key beep
rbeep:1, // roger beep
- unknown:2,
+ unknown3:2,
ctdcsb:1, // ct/dcs busy lock
- unknown:1;
+ unknown4:1;
u8 alarm:1, // alarm key
- unknown1:1,
+ unknown5:1,
aliasen_off:1, // alias enable (inverted)
save:1, // battery save
- unknown2:2,
+ unknown6:2,
mrcha:1, // mr/cha
vfomr:1; // vfo/mr
u8 keylock_off:1, // key lock (inverted)
@@ -53,20 +53,20 @@ struct {
lamp:2; // backlight
u8 opendis:2, // open display
fmen_off:1, // fm enable (inverted)
- unknown1:1,
+ unknown7:1,
fmscan_off:1, // fm scan (inverted)
fmdw:1, // fm dual watch
- unknown2:2;
+ unknown8:2;
u8 step:4, // step
vol:4; // volume
u8 apo:4, // auto power off
tot:4; // time out timer
- u8 unknown0x018C;
+ u8 unknown9;
u8 voxdt:4, // vox delay time
voxgain:4; // vox gain
- u8 unknown0x018E;
- u8 unknown0x018F;
- u8 unknown:3,
+ u8 unknown10;
+ u8 unknown11;
+ u8 unknown12:3,
lptime:5; // long press time
u8 keyp2long:4, // p2 key long press
keyp2short:4; // p2 key short press
@@ -74,34 +74,34 @@ struct {
keyp1short:4; // p1 key short press
u8 keyp3long:4, // p3 key long press
keyp3short:4; // p3 key short press
- u8 unknown0x0194;
+ u8 unknown13;
u8 menuen:1, // menu enable
absel:1, // a/b select
- unknown:2,
+ unknown14:2,
keymshort:4; // m key short press
- u8 unknown:4,
+ u8 unknown15:4,
dtmfst:1, // dtmf sidetone
ackdecode:1, // ack decode
monitor:2; // monitor
- u8 unknown1:3,
+ u8 unknown16:3,
reset:1, // reset enable
- unknown2:1,
+ unknown17:1,
keypadmic_off:1, // keypad mic (inverted)
- unknown3:2;
- u8 unknown0x0198;
- u8 unknown1:3,
+ unknown18:2;
+ u8 unknown19;
+ u8 unknown20:3,
dtmftime:5; // dtmf digit time
- u8 unknown1:3,
+ u8 unknown21:3,
dtmfspace:5; // dtmf digit space time
- u8 unknown1:2,
+ u8 unknown22:2,
dtmfdelay:6; // dtmf first digit delay
- u8 unknown1:1,
+ u8 unknown23:1,
dtmfpretime:7; // dtmf pretime
- u8 unknown1:2,
+ u8 unknown24:2,
dtmfdelay2:6; // dtmf * and # digit delay
- u8 unknown1:3,
+ u8 unknown25:3,
smfont_off:1, // small font (inverted)
- unknown:4;
+ unknown26:4;
} settings;
#seekto 0x01cd;
@@ -297,7 +297,7 @@ def do_ident(radio):
def do_download(radio):
- do_ident(radio)
+ # Ident should have already been done by the detect_from_serial()
data = b""
data += b"\xFF" * (0 - len(data))
@@ -355,19 +355,12 @@ def finish(radio):
ack = radio.pipe.read(8)
-# Declaring Aliases
-class LT898UV(chirp_common.Alias):
- VENDOR = "LUITON"
- MODEL = "LT-898UV"
-
-
@directory.register
class LeixenVV898Radio(chirp_common.CloneModeRadio):
"""Leixen VV-898"""
VENDOR = "Leixen"
MODEL = "VV-898"
- ALIASES = [LT898UV, ]
BAUD_RATE = 9600
NEEDS_COMPAT_SERIAL = False
@@ -393,6 +386,21 @@ class LeixenVV898Radio(chirp_common.CloneModeRadio):
_power_levels = [chirp_common.PowerLevel("Low", watts=4),
chirp_common.PowerLevel("High", watts=10)]
+ @classmethod
+ def detect_from_serial(cls, pipe):
+ radio = cls(pipe)
+ do_ident(radio)
+ send(radio, make_frame(b"R", 0x0168, b'\x10'))
+ _addr, _data = recv(radio)
+ ident = _data[8:14]
+ LOG.debug('Got ident from radio:\n%s' % util.hexprint(ident))
+ for rclass in [cls] + cls.detected_models():
+ if ident == rclass._model_ident:
+ return rclass
+ # Reset the radio if we didn't find a match
+ finish(radio)
+ raise errors.RadioError('Unable to detect a supported model')
+
def get_features(self):
rf = chirp_common.RadioFeatures()
rf.has_settings = True
@@ -418,7 +426,7 @@ class LeixenVV898Radio(chirp_common.CloneModeRadio):
rf.valid_skips = ["", "S"]
rf.valid_tuning_steps = _STEP_LIST
rf.valid_bands = [(136000000, 174000000),
- (400000000, 470000000)]
+ (400000000, 480000000)]
rf.valid_tones = TONES
rf.valid_dtcs_codes = DTCS_CODES
rf.memory_bounds = (1, 199)
@@ -472,9 +480,9 @@ class LeixenVV898Radio(chirp_common.CloneModeRadio):
(rx_tmode, rx_tone, rx_pol))
def _is_txinh(self, _mem):
- raw_tx = ""
+ raw_tx = b""
for i in range(0, 4):
- raw_tx += _mem.tx_freq[i].get_raw(asbytes=False)
+ raw_tx += _mem.tx_freq[i].get_raw()
return raw_tx == b"\xFF\xFF\xFF\xFF"
def _get_memobjs(self, number):
@@ -488,7 +496,7 @@ class LeixenVV898Radio(chirp_common.CloneModeRadio):
mem = chirp_common.Memory()
mem.number = number
- if _mem.get_raw(asbytes=False)[:4] == "\xFF\xFF\xFF\xFF":
+ if _mem.get_raw()[:4] == b"\xFF\xFF\xFF\xFF":
mem.empty = True
return mem
@@ -590,7 +598,7 @@ class LeixenVV898Radio(chirp_common.CloneModeRadio):
if mem.empty:
_mem.set_raw(b"\xFF" * 16)
return
- elif _mem.get_raw(asbytes=False) == (b"\xFF" * 16):
+ elif _mem.get_raw() == (b"\xFF" * 16):
_mem.set_raw(b"\xFF" * 8 + b"\xFF\x00\xFF\x00\xFF\xFE\xF0\xFC")
_mem.rx_freq = mem.freq / 10
@@ -962,13 +970,21 @@ class JetstreamJT270MRadio(LeixenVV898Radio):
_model_ident = b'LX-\x89\x85\x53'
+class LT898UV(LeixenVV898Radio):
+ VENDOR = "LUITON"
+ MODEL = "LT-898UV"
+
+ @classmethod
+ def match_model(cls, filedata, filename):
+ return False
+
+
@directory.register
class JetstreamJT270MHRadio(LeixenVV898Radio):
"""Jetstream JT270MH"""
VENDOR = "Jetstream"
MODEL = "JT270MH"
- ALIASES = []
_file_ident = b"Leixen"
_model_ident = b'LX-\x89\x85\x85'
@@ -981,10 +997,12 @@ class JetstreamJT270MHRadio(LeixenVV898Radio):
_power_levels = [chirp_common.PowerLevel("Low", watts=5),
chirp_common.PowerLevel("Mid", watts=10),
chirp_common.PowerLevel("High", watts=25)]
+ # Base radio has offset zero to distinguish from sub devices
+ _offset = 0
def get_features(self):
rf = super(JetstreamJT270MHRadio, self).get_features()
- rf.has_sub_devices = self.VARIANT == ''
+ rf.has_sub_devices = self._offset == 0
rf.memory_bounds = (1, 99)
return rf
@@ -1009,21 +1027,12 @@ class JetstreamJT270MHRadioB(JetstreamJT270MHRadio):
_offset = 2
-class VV898E(chirp_common.Alias):
-
- '''Leixen has called this radio both 898E and S historically, ident is
- identical'''
- VENDOR = "Leixen"
- MODEL = "VV-898E"
-
-
@directory.register
class LeixenVV898SRadio(LeixenVV898Radio):
"""Leixen VV-898S, also VV-898E which is identical"""
VENDOR = "Leixen"
MODEL = "VV-898S"
- ALIASES = [VV898E, ]
_model_ident = b'LX-\x89\x85\x75'
_mem_formatter = {'unknownormode': 'mode:1',
@@ -1034,3 +1043,41 @@ class LeixenVV898SRadio(LeixenVV898Radio):
_power_levels = [chirp_common.PowerLevel("Low", watts=5),
chirp_common.PowerLevel("Med", watts=10),
chirp_common.PowerLevel("High", watts=25)]
+
+
+@directory.register
+class VV898E(LeixenVV898SRadio):
+ '''Leixen has called this radio both 898E and S historically, ident is
+ identical'''
+ VENDOR = "Leixen"
+ MODEL = "VV-898E"
+
+ @classmethod
+ def match_model(cls, filedata, filename):
+ return False
+
+
+@directory.register
+@directory.detected_by(LeixenVV898SRadio)
+class VV898SDualBank(JetstreamJT270MHRadio):
+ '''Newer VV898S 1.06+ firmware that features dual memory banks'''
+ VENDOR = "Leixen"
+ MODEL = "VV-898S"
+ VARIANT = "Dual Bank"
+
+ @classmethod
+ def match_model(cls, filedata, filename):
+ return False
+
+
+@directory.register
+@directory.detected_by(VV898E)
+class VV898EDualBank(JetstreamJT270MHRadio):
+ '''Newer VV898E 1.06+ firmware that features dual memory banks'''
+ VENDOR = "Leixen"
+ MODEL = "VV-898E"
+ VARIANT = "Dual Bank"
+
+ @classmethod
+ def match_model(cls, filedata, filename):
+ return False
diff --git a/chirp/drivers/mml_jc8810.py b/chirp/drivers/mml_jc8810.py
index a10546a..8dd62ba 100644
--- a/chirp/drivers/mml_jc8810.py
+++ b/chirp/drivers/mml_jc8810.py
@@ -72,7 +72,7 @@ struct {
abr:4; // Auto BackLight
u8 unused_9004:7, // 9004
tdr:1; // TDR
- u8 unused:5, // 9005
+ u8 unused_9005:5, // 9005
tot:3; // Time-out Timer
u8 unused_9006:7, // 9006
beep:1; // Beep
@@ -90,7 +90,7 @@ struct {
pttlt:3; // PTT Delay
u8 unused_900d:6, // 900D
mdfa:2; // Channel_A Display
- u8 unused_9003:6, // 900E
+ u8 unused_900e:6, // 900E
mdfb:2; // Channel_B Display
u8 unknown_900f; // 900F
u8 unused_9010:4, // 9010
@@ -517,7 +517,7 @@ class JC8810base(chirp_common.CloneModeRadio):
# Freq and offset
mem.freq = int(_mem.rxfreq) * 10
# tx freq can be blank
- if _mem.get_raw()[:4] == b"\xFF\xFF\xFF\xFF":
+ if _mem.txfreq.get_raw() == b"\xFF\xFF\xFF\xFF":
# TX freq not set
mem.offset = 0
mem.duplex = "off"
@@ -594,7 +594,7 @@ class JC8810base(chirp_common.CloneModeRadio):
mem.skip = "S"
_levels = self.POWER_LEVELS
- if self.MODEL in ["A36plus", "UV-A37", "AR-730"]:
+ if self.MODEL in ["A36plus", "A36plus_8w", "UV-A37", "AR-730"]:
if _mem.txpower == TXPOWER_HIGH:
mem.power = _levels[0]
elif _mem.txpower == TXPOWER_LOW:
@@ -646,8 +646,7 @@ class JC8810base(chirp_common.CloneModeRadio):
_mem.rxfreq = mem.freq / 10
if mem.duplex == "off":
- for i in range(0, 4):
- _mem.txfreq[i].set_raw("\xFF")
+ _mem.txfreq.fill_raw(b"\xFF")
elif mem.duplex == "split":
_mem.txfreq = mem.offset / 10
elif mem.duplex == "+":
@@ -702,7 +701,7 @@ class JC8810base(chirp_common.CloneModeRadio):
_mem.narrow = mem.mode == "NFM"
_levels = self.POWER_LEVELS
- if self.MODEL in ["A36plus", "UV-A37", "AR-730"]:
+ if self.MODEL in ["A36plus", "A36plus_8w", "UV-A37", "AR-730"]:
if mem.power is None:
_mem.txpower = TXPOWER_HIGH
elif mem.power == _levels[0]:
@@ -763,7 +762,7 @@ class JC8810base(chirp_common.CloneModeRadio):
rset = RadioSetting("voice", "Voice Prompts", rs)
basic.append(rset)
- if self.MODEL not in ["A36plus", "UV-A37", "AR-730"]:
+ if self.MODEL not in ["A36plus", "A36plus_8w", "UV-A37", "AR-730"]:
# Menu 17: LANGUAGE
rs = RadioSettingValueList(LANGUAGE_LIST,
LANGUAGE_LIST[_settings.language])
@@ -834,7 +833,7 @@ class JC8810base(chirp_common.CloneModeRadio):
unwanted = [9, 10, 11, 12]
elif self.MODEL in ["UV-A37", "AR-730"]:
unwanted = [0, 5, 7, 9, 10, 11, 12]
- elif self.MODEL in ["A36plus"]:
+ elif self.MODEL in ["A36plus", "A36plus_8w"]:
unwanted = [0, 5, 7, 9, 10, 11]
else:
unwanted = []
@@ -865,7 +864,7 @@ class JC8810base(chirp_common.CloneModeRadio):
unwanted = [8, 9, 10, 11, 12]
elif self.MODEL in ["UV-A37", "AR-730"]:
unwanted = [0, 5, 7, 8, 10, 11, 12]
- elif self.MODEL in ["A36plus"]:
+ elif self.MODEL in ["A36plus", "A36plus_8w"]:
unwanted = [0, 5, 7, 8, 11, 12]
else:
unwanted = []
@@ -896,7 +895,7 @@ class JC8810base(chirp_common.CloneModeRadio):
unwanted = [8, 9, 10, 11, 12]
elif self.MODEL in ["UV-A37", "AR-730"]:
unwanted = [0, 5, 7, 8, 9, 10, 11, 12]
- elif self.MODEL in ["A36plus"]:
+ elif self.MODEL in ["A36plus", "A36plus_8w"]:
unwanted = [0, 5, 7, 8, 11]
else:
unwanted = []
@@ -958,7 +957,7 @@ class JC8810base(chirp_common.CloneModeRadio):
unwanted = [8, 9, 10, 11, 12]
elif self.MODEL in ["UV-A37", "AR-730"]:
unwanted = [0, 5, 7, 8, 9, 10, 11, 12]
- elif self.MODEL in ["A36plus"]:
+ elif self.MODEL in ["A36plus", "A36plus_8w"]:
unwanted = [0, 5, 7, 8, 11]
else:
unwanted = []
@@ -1068,7 +1067,7 @@ class JC8810base(chirp_common.CloneModeRadio):
rset = RadioSetting("beep", "Beep", rs)
basic.append(rset)
- if self.MODEL not in ["A36plus", "UV-A37", "AR-730"]:
+ if self.MODEL not in ["A36plus", "A36plus_8w", "UV-A37", "AR-730"]:
# Menu 48: RX END TAIL
rs = RadioSettingValueList(TONERXEND_LIST,
TONERXEND_LIST[_settings.rxendtail])
@@ -1151,7 +1150,7 @@ class JC8810base(chirp_common.CloneModeRadio):
"ANI Code %i Name" % (i + 1), rs)
ani.append(rset)
- if self.MODEL == "A36plus":
+ if self.MODEL in ["A36plus", "A36plus_8w"]:
custom = RadioSettingGroup("custom", "Custom Channel Names")
group.append(custom)
@@ -1162,7 +1161,7 @@ class JC8810base(chirp_common.CloneModeRadio):
"Custom Name %i" % (i + 1), rs)
custom.append(rset)
- if self.MODEL == "A36plus":
+ if self.MODEL in ["A36plus", "A36plus_8w"]:
# Menu 21: RX END TAIL
rs = RadioSettingValueList(TONERXEND_LIST,
TONERXEND_LIST[_settings.skey3_lp])
@@ -1338,6 +1337,7 @@ class HI8811Radio(RT470LRadio):
# pcb 2
_fingerprint_pcb2 = [b"\x00\x00\x00\x28\x00\x20\xD4\x04", # fw v2.00
+ b"\x00\x00\x00\x28\x00\x20\x07\x00", # fw v2.00
]
_fingerprint = _fingerprint_pcb1 + _fingerprint_pcb2
@@ -1404,6 +1404,7 @@ class A36plusRadio(JC8810base):
_fingerprint = [b"\x00\x00\x00\x42\x00\x20\xF0\x04",
b"\x00\x00\x00\x5A\x00\x20\x08\x05", # fw 1.18
b"\x00\x00\x00\x9E\x00\x20\x0C\x05", # fw 1.22
+ b"\x00\x00\x00\xFA\x00\x20\x40\x05", # fw 1.4
]
_ranges = [
@@ -1426,6 +1427,25 @@ class A36plusRadio(JC8810base):
@directory.register
+class A36plus8wRadio(A36plusRadio):
+ """Talkpod A36plus8w"""
+ VENDOR = "Talkpod"
+ MODEL = "A36plus_8w"
+
+ # ==========
+ # Notice to developers:
+ # The A36plus 8w support in this driver is currently based upon v1.4
+ # firmware.
+ # ==========
+
+ POWER_LEVELS = [chirp_common.PowerLevel("H", watts=8.00),
+ chirp_common.PowerLevel("L", watts=1.00)]
+
+ _fingerprint = [b"\x00\x00\x00\xFA\x00\x20\x40\x05", # fw 1.4
+ ]
+
+
+@directory.register
class AR730Radio(UVA37Radio):
"""Abbree AR730"""
VENDOR = "Abbree"
diff --git a/chirp/drivers/puxing_px888k.py b/chirp/drivers/puxing_px888k.py
index a940958..01ed20e 100644
--- a/chirp/drivers/puxing_px888k.py
+++ b/chirp/drivers/puxing_px888k.py
@@ -344,7 +344,7 @@ struct {
u8 rxtx_stun_code_length;
u8 cancel_rxtx_stun_code_length;
u8 cancel_rxtx_stun_code[4];
- u8 _unknown_0D4E[2];
+ u8 _unknown_0D5E[2];
// 0x0d60
struct {
@@ -1327,7 +1327,7 @@ class Puxing_PX888K_Radio(chirp_common.CloneModeRadio):
_data.ptt_id_edge,
PTT_ID_EDGES),
list_setting("Optional signal before/after transmission, " +
- "this setting overrides the PTT ID setting.",
+ "this setting overrides the PTT ID setting",
"Opt Signal",
_data.opt_signal,
OPTSIGN_MODES))
diff --git a/chirp/drivers/radioddity_r2.py b/chirp/drivers/radioddity_r2.py
index 328d5e4..29f478d 100644
--- a/chirp/drivers/radioddity_r2.py
+++ b/chirp/drivers/radioddity_r2.py
@@ -576,7 +576,7 @@ class RadioddityR2(chirp_common.CloneModeRadio):
# extra settings are unfortunately inverted
for setting in mem.extra:
- LOG.debug("@set_mem:", setting.get_name(), setting.value)
+ LOG.debug("@set_mem: %s %s", setting.get_name(), setting.value)
setattr(_mem, setting.get_name(), not setting.value)
def get_settings(self):
diff --git a/chirp/drivers/radtel_rt490.py b/chirp/drivers/radtel_rt490.py
index 6db6391..15028c3 100644
--- a/chirp/drivers/radtel_rt490.py
+++ b/chirp/drivers/radtel_rt490.py
@@ -122,7 +122,7 @@ struct {
u8 timeout; // 5: n*30seconds, 0-240s
u8 beep; // 6: bool
u8 voice; // 7: bool
- u8 byte_not_used_10; // 8: Allways 1
+ u8 byte_not_used_10; // 8: Always 1
u8 dtmfst; // 9: ['OFF', 'KB Side Tone', 'ANI Side Tone',
// 'KB ST + ANI ST']
u8 scanmode; // 10: ['TO', 'CO', 'SE']
@@ -146,7 +146,7 @@ struct {
workmodea:4; // 10:down ['VFO', 'CH Mode']
u8 kblock; // 11: bool // TODO TEST WITH autolock
u8 powermsg; // 12: 0=Image / 1=Voltage
- u8 byte_not_used_21; // 13: Allways 0
+ u8 byte_not_used_21; // 13: Always 0
u8 rpttone; // 14: ['1000Hz', '1450Hz', '1750Hz', '2100Hz']
u8 byte_not_used_22; // 15: pad with xFF
u8 vox_delay; // 0: [str(float(a)/10)+'s' for a in range(5,21)]
@@ -1489,7 +1489,7 @@ struct settings {
u8 timeout; // 5: n*30seconds, 0-240s
u8 beep; // 6: bool
u8 voice; // 7: bool
- u8 byte_not_used_10; // 8: Allways 1
+ u8 byte_not_used_10; // 8: Always 1
u8 dtmfst; // 9: ['OFF', 'KB Side Tone', 'ANI Side Tone',
// 'KB ST + ANI ST']
u8 scanmode; // 10: ['TO', 'CO', 'SE']
@@ -1512,7 +1512,7 @@ struct settings {
workmode _workmode; // 10: up ['VFO', 'CH Mode']
u8 kblock; // 11: bool // TODO TEST WITH autolock
u8 powermsg; // 12: 0=Image / 1=Voltage
- u8 byte_not_used_21; // 13: Allways 0
+ u8 byte_not_used_21; // 13: Always 0
u8 rpttone; // 14: ['1000Hz', '1450Hz', '1750Hz', '2100Hz']
u8 byte_not_used_22; // 15: pad with xFF
u8 vox_delay; // 0: [str(float(a)/10)+'s' for a in range(5,21)]
diff --git a/chirp/drivers/retevis_rb15.py b/chirp/drivers/retevis_rb15.py
index a1235da..5b3aa69 100644
--- a/chirp/drivers/retevis_rb15.py
+++ b/chirp/drivers/retevis_rb15.py
@@ -471,19 +471,19 @@ class RB15RadioBase(chirp_common.CloneModeRadio):
mem.empty = True
return mem
- if _mem.rxfreq.get_raw(asbytes=False) == "\xFF\xFF\xFF\xFF":
+ if _mem.rxfreq.get_raw() == b"\xFF\xFF\xFF\xFF":
mem.freq = 0
mem.empty = True
return mem
- if _mem.get_raw(asbytes=False) == ("\xFF" * 16):
+ if _mem.get_raw() == (b"\xFF" * 16):
LOG.debug("Initializing empty memory")
- _mem.set_raw("\x00" * 16)
+ _mem.set_raw(b"\x00" * 16)
# Freq and offset
mem.freq = int(_mem.rxfreq) * 10
# tx freq can be blank
- if _mem.get_raw(asbytes=False)[4] == "\xFF":
+ if _mem.txfreq.get_raw() == b"\xFF\xFF\xFF\xFF":
# TX freq not set
mem.offset = 0
mem.duplex = "off"
@@ -545,8 +545,7 @@ class RB15RadioBase(chirp_common.CloneModeRadio):
_mem.rxfreq = mem.freq / 10
if mem.duplex == "off":
- for i in range(0, 4):
- _mem.txfreq[i].set_raw("\xFF")
+ _mem.txfreq.fill_raw(b"\xFF")
elif mem.duplex == "split":
_mem.txfreq = mem.offset / 10
elif mem.duplex == "+":
diff --git a/chirp/drivers/retevis_rb17p.py b/chirp/drivers/retevis_rb17p.py
index 04be42a..fe8e11e 100644
--- a/chirp/drivers/retevis_rb17p.py
+++ b/chirp/drivers/retevis_rb17p.py
@@ -26,24 +26,10 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \
LOG = logging.getLogger(__name__)
MEM_FORMAT = """
-#seekto 0x1000;
+#seekto 0x0010;
struct {
- lbcd rxfreq[4];
- lbcd txfreq[4];
- lbcd rxtone[2];
- lbcd txtone[2];
- u8 unknown1:4,
- compander:1,
- unknown2:1,
- highpower:1,
- unknown3:1;
- u8 unknown4:3,
- wide:1,
- scan:1,
- unknown4:1,
- bcl:2;
- u8 unknown6[2];
-} memory[128];
+ char name[10]; // 10-character Alpha Tag
+} names[128];
#seekto 0x0810;
struct {
u8 unknown01:5,
@@ -76,10 +62,24 @@ struct {
unknown14:1,
sidekey:3;
} settings;
-#seekto 0x0010;
+#seekto 0x1000;
struct {
- char name[10]; // 10-character Alpha Tag
-} names[128];
+ lbcd rxfreq[4];
+ lbcd txfreq[4];
+ lbcd rxtone[2];
+ lbcd txtone[2];
+ u8 unknown1:4,
+ compander:1,
+ unknown2:1,
+ highpower:1,
+ unknown3:1;
+ u8 unknown4:3,
+ wide:1,
+ scan:1,
+ unknown5:1,
+ bcl:2;
+ u8 unknown6[2];
+} memory[128];
"""
@@ -325,12 +325,12 @@ class RB17P_Base(chirp_common.CloneModeRadio):
mem.empty = True
return mem
- if _mem.rxfreq.get_raw(asbytes=False) == "\xFF\xFF\xFF\xFF":
+ if _mem.rxfreq.get_raw() == b"\xFF\xFF\xFF\xFF":
mem.freq = 0
mem.empty = True
return mem
- if _mem.txfreq.get_raw(asbytes=False) == "\xFF\xFF\xFF\xFF":
+ if _mem.txfreq.get_raw() == b"\xFF\xFF\xFF\xFF":
mem.duplex = "off"
mem.offset = 0
elif int(_mem.rxfreq) == int(_mem.txfreq):
@@ -408,18 +408,18 @@ class RB17P_Base(chirp_common.CloneModeRadio):
_nam = self._memobj.names[mem.number - 1]
if mem.empty:
- _mem.set_raw("\xFF" * (_mem.size() // 8))
- _nam.set_raw("\xFF" * (_nam.size() // 8))
+ _mem.set_raw(b"\xFF" * (_mem.size() // 8))
+ _nam.set_raw(b"\xFF" * (_nam.size() // 8))
return
- _mem.set_raw("\x00" * (_mem.size() // 8))
+ _mem.set_raw(b"\x00" * (_mem.size() // 8))
_mem.rxfreq = mem.freq / 10
if mem.duplex == "off":
for i in range(0, 4):
- _mem.txfreq[i].set_raw("\xFF")
+ _mem.txfreq[i].set_raw(b"\xFF")
elif mem.duplex == "split":
_mem.txfreq = mem.offset / 10
elif mem.duplex == "+":
diff --git a/chirp/drivers/retevis_rb28.py b/chirp/drivers/retevis_rb28.py
index c4bbec0..61a68fc 100644
--- a/chirp/drivers/retevis_rb28.py
+++ b/chirp/drivers/retevis_rb28.py
@@ -140,14 +140,17 @@ VOICE_LIST = ["Off", "English"]
VOXD_LIST = ["0.5", "1.0", "1.5", "2.0", "2.5", "3.0"]
VOXL_LIST = ["OFF"] + ["%s" % x for x in range(1, 10)]
-PMR_TONES = list(chirp_common.TONES)
-[PMR_TONES.remove(x) for x in [69.3, 159.8, 165.5, 171.3, 177.3, 183.5,
- 189.9, 196.6, 199.5, 206.5, 229.1, 254.1]]
-
-PMR_DTCS_CODES = list(chirp_common.DTCS_CODES)
-[PMR_DTCS_CODES.remove(x) for x in [36, 53, 122, 145, 212, 225, 246,
- 252, 255, 266, 274, 325, 332, 356,
- 446, 452, 454, 455, 462, 523, 526]]
+PMR_TONES = tuple(
+ set(chirp_common.TONES) - set([69.3, 159.8, 165.5, 171.3, 177.3,
+ 183.5, 189.9, 196.6, 199.5, 206.5,
+ 229.1, 254.1]))
+
+PMR_DTCS_CODES = tuple(
+ set(chirp_common.DTCS_CODES) - set([36, 53, 122, 145, 212,
+ 225, 246, 252, 255, 266,
+ 274, 325, 332, 356, 446,
+ 452, 454, 455, 462, 523,
+ 526]))
def _enter_programming_mode(radio):
diff --git a/chirp/drivers/retevis_rt1.py b/chirp/drivers/retevis_rt1.py
index 5d44329..f2fe245 100644
--- a/chirp/drivers/retevis_rt1.py
+++ b/chirp/drivers/retevis_rt1.py
@@ -426,7 +426,7 @@ class RT1Radio(chirp_common.CloneModeRadio):
mem.empty = True
return mem
- if _mem.rxfreq.get_raw(asbytes=False) == "\xFF\xFF\xFF\xFF":
+ if _mem.rxfreq.get_raw() == b"\xFF\xFF\xFF\xFF":
mem.freq = 0
mem.empty = True
return mem
@@ -434,6 +434,8 @@ class RT1Radio(chirp_common.CloneModeRadio):
if int(_mem.rxfreq) == int(_mem.txfreq):
mem.duplex = ""
mem.offset = 0
+ elif _mem.txfreq.get_raw() == b"\xFF\xFF\xFF\xFF":
+ mem.duplex = "off"
else:
mem.duplex = int(_mem.rxfreq) > int(_mem.txfreq) and "-" or "+"
mem.offset = abs(int(_mem.rxfreq) - int(_mem.txfreq)) * 10
@@ -480,8 +482,7 @@ class RT1Radio(chirp_common.CloneModeRadio):
_mem.rxfreq = mem.freq / 10
if mem.duplex == "off":
- for i in range(0, 4):
- _mem.txfreq[i].set_raw("\xFF")
+ _mem.txfreq.fill_raw(b"\xFF")
elif mem.duplex == "split":
_mem.txfreq = mem.offset / 10
elif mem.duplex == "+":
diff --git a/chirp/drivers/retevis_rt21.py b/chirp/drivers/retevis_rt21.py
index 11a5cac..7d458a7 100644
--- a/chirp/drivers/retevis_rt21.py
+++ b/chirp/drivers/retevis_rt21.py
@@ -910,7 +910,7 @@ class RT21Radio(chirp_common.CloneModeRadio):
mem.empty = True
return mem
- if _mem.rxfreq.get_raw(asbytes=False) == "\xFF\xFF\xFF\xFF":
+ if _mem.rxfreq.get_raw() == b"\xFF\xFF\xFF\xFF":
mem.freq = 0
mem.empty = True
return mem
@@ -918,6 +918,8 @@ class RT21Radio(chirp_common.CloneModeRadio):
if int(_mem.rxfreq) == int(_mem.txfreq):
mem.duplex = ""
mem.offset = 0
+ elif _mem.txfreq.get_raw() == b"\xFF\xFF\xFF\xFF":
+ mem.duplex = "off"
else:
mem.duplex = int(_mem.rxfreq) > int(_mem.txfreq) and "-" or "+"
mem.offset = abs(int(_mem.rxfreq) - int(_mem.txfreq)) * 10
@@ -1214,8 +1216,7 @@ class RT21Radio(chirp_common.CloneModeRadio):
_mem.rxfreq = mem.freq / 10
if mem.duplex == "off":
- for i in range(0, 4):
- _mem.txfreq[i].set_raw("\xFF")
+ _mem.txfreq.fill_raw(b"\xFF")
elif mem.duplex == "split":
_mem.txfreq = mem.offset / 10
elif mem.duplex == "+":
diff --git a/chirp/drivers/retevis_rt22.py b/chirp/drivers/retevis_rt22.py
index b295871..28991c9 100644
--- a/chirp/drivers/retevis_rt22.py
+++ b/chirp/drivers/retevis_rt22.py
@@ -470,6 +470,8 @@ class RT22Radio(chirp_common.CloneModeRadio):
if int(_mem.rxfreq) == int(_mem.txfreq):
mem.duplex = ""
mem.offset = 0
+ elif _mem.txfreq.get_raw() == b"\xFF\xFF\xFF\xFF":
+ mem.duplex = "off"
else:
mem.duplex = int(_mem.rxfreq) > int(_mem.txfreq) and "-" or "+"
mem.offset = abs(int(_mem.rxfreq) - int(_mem.txfreq)) * 10
@@ -550,8 +552,7 @@ class RT22Radio(chirp_common.CloneModeRadio):
_mem.rxfreq = mem.freq / 10
if mem.duplex == "off":
- for i in range(0, 4):
- _mem.txfreq[i].set_raw("\xFF")
+ _mem.txfreq.fill_raw(b"\xFF")
elif mem.duplex == "split":
_mem.txfreq = mem.offset / 10
elif mem.duplex == "+":
diff --git a/chirp/drivers/retevis_rt26.py b/chirp/drivers/retevis_rt26.py
index b1d5da4..4c75727 100644
--- a/chirp/drivers/retevis_rt26.py
+++ b/chirp/drivers/retevis_rt26.py
@@ -438,7 +438,7 @@ class RT26Radio(chirp_common.CloneModeRadio):
mem.empty = True
return mem
- if _mem.rxfreq.get_raw(asbytes=False) == "\xFF\xFF\xFF\xFF":
+ if _mem.rxfreq.get_raw() == b"\xFF\xFF\xFF\xFF":
mem.freq = 0
mem.empty = True
return mem
@@ -446,6 +446,8 @@ class RT26Radio(chirp_common.CloneModeRadio):
if int(_mem.rxfreq) == int(_mem.txfreq):
mem.duplex = ""
mem.offset = 0
+ elif _mem.txfreq.get_raw() == b"\xFF\xFF\xFF\xFF":
+ mem.duplex = "off"
else:
mem.duplex = int(_mem.rxfreq) > int(_mem.txfreq) and "-" or "+"
mem.offset = abs(int(_mem.rxfreq) - int(_mem.txfreq)) * 10
@@ -490,8 +492,7 @@ class RT26Radio(chirp_common.CloneModeRadio):
_mem.rxfreq = mem.freq / 10
if mem.duplex == "off":
- for i in range(0, 4):
- _mem.txfreq[i].set_raw("\xFF")
+ _mem.txfreq.fill_raw(b"\xFF")
elif mem.duplex == "split":
_mem.txfreq = mem.offset / 10
elif mem.duplex == "+":
diff --git a/chirp/drivers/th7800.py b/chirp/drivers/th7800.py
index a04a4ca..2cc89ff 100644
--- a/chirp/drivers/th7800.py
+++ b/chirp/drivers/th7800.py
@@ -378,7 +378,7 @@ class TYTTH7800Base(chirp_common.Radio):
_mem.step = STEPS.index(mem.tuning_step)
for setting in mem.extra:
- LOG.debug("@set_mem:", setting.get_name(), setting.value)
+ LOG.debug("@set_mem: %s %s", setting.get_name(), setting.value)
setattr(_mem, setting.get_name(), setting.value)
def get_settings(self):
diff --git a/chirp/drivers/th_uv8000.py b/chirp/drivers/th_uv8000.py
index cdca651..6fa49a1 100644
--- a/chirp/drivers/th_uv8000.py
+++ b/chirp/drivers/th_uv8000.py
@@ -142,7 +142,7 @@ struct {
sql:4;
u8 setunk27:1, // 0x11c0
voxdelay:2,
- setunk28:1,
+ setunk31:1,
voxgain:4;
u8 fmstep:4, // 0x11c1
freqstep:4;
@@ -193,7 +193,7 @@ struct {
u8 setunk65;
u8 setunk66;
u8 manfrqyn; // 0x11fd
- u8 setunk27:3,
+ u8 setunk30:3,
frqr3:1,
setunk28:1,
frqr2:1,
@@ -628,7 +628,7 @@ class THUV8000Radio(chirp_common.CloneModeRadio):
"""Convert raw channel memory data into UI columns"""
mem.extra = RadioSettingGroup("extra", "Extra")
- if _mem.get_raw(asbytes=False)[0] == "\xff":
+ if _mem.get_raw()[0] == 0xff:
mem.empty = True
return mem
diff --git a/chirp/drivers/th_uv88.py b/chirp/drivers/th_uv88.py
index e6632db..8a76297 100644
--- a/chirp/drivers/th_uv88.py
+++ b/chirp/drivers/th_uv88.py
@@ -28,6 +28,8 @@ from chirp.settings import RadioSettingGroup, RadioSetting, \
LOG = logging.getLogger(__name__)
+CHAN_NUM = 200
+
MEM_FORMAT = """
struct chns {
ul32 rxfreq;
@@ -83,20 +85,20 @@ struct chname {
};
// #seekto 0x0000;
-struct chns chan_mem[199];
+struct chns chan_mem[200]; // CHAN_NUM
#seekto 0x1140;
struct {
u8 autoKeylock:1, // 0x1140 [18] *OFF, On
- unk_bit6_5:1, //
+ unk1:1, //
vfomrmodeb:1, // *VFO B, MR B
vfomrmode:1, // *VFO, MR
- unk_bit3_0:4; //
+ unk2:4; //
u8 mrAch; // 0x1141 MR A Channel #
u8 mrBch; // 0x1142 MR B Channel #
- u8 unk_bit7_3:5, //
+ u8 unk3:5, //
ab:1, // * A, B
- unk_bit1_0:2; //
+ unk4:2; //
} workmodesettings;
"""
@@ -113,7 +115,7 @@ struct {
#seekto 0x191E;
struct {
- u8 unknown191e:4, //
+ u8 unk1:4, //
region:4; // 0x191E Radio Region (read only)
// 0 = Unlocked TX: 136-174 MHz / 400-480 MHz
// 2-3 = Unknown
@@ -124,18 +126,16 @@ struct {
#seekto 0x1940;
struct {
- char name1[15]; // Intro Screen Line 1 (16 alpha text characters)
- u8 unk1;
- char name2[15]; // Intro Screen Line 2 (16 alpha text characters)
- u8 unk2;
-} openradioname;
+ char name1[16]; // Intro Screen Line 1 (16 alpha text characters)
+ char name2[16]; // Intro Screen Line 2 (16 alpha text characters)
+} openradioname;
struct fm_chn {
ul32 rxfreq;
};
// #seekto 0x1960;
-struct chname chan_name[199];
+struct chname chan_name[200]; // CHAN_NUM
#seekto 0x2180;
struct fm_chn fm_stations[24];
@@ -155,54 +155,54 @@ struct {
THUV88_SETTINGS = """
#seekto 0x1160;
struct {
- u8 introScreen1[12]; // 0x1160 *Intro Screen Line 1(truncated to 12 alpha
- // text characters)
+ char introScreen1[12]; // 0x1160 *Intro Screen Line 1(truncated to 12
+ // alpha text characters)
u8 offFreqVoltage : 3, // 0x116C unknown referred to in code but not on
// screen
- unk_bit4 : 1, //
+ unk1:1, //
sqlLevel : 4; // [05] *OFF, 1-9
u8 beep : 1, // 0x116D [09] *OFF, On
callKind : 2, // code says 1750,2100,1000,1450 as options
// not on screen
introScreen: 2, // [20] *OFF, Voltage, Char String
- unkstr2: 2, //
+ unk2:2, //
txChSelect : 1; // [02] *Last CH, Main CH
u8 autoPowOff : 3, // 0x116E not on screen? OFF, 30Min, 1HR, 2HR
- unk : 1, //
+ unk3:1, //
tot : 4; // [11] *OFF, 30 Second, 60 Second, 90 Second,
// ... , 270 Second
- u8 unk_bit7:1, // 0x116F
+ u8 unk4:1, // 0x116F
roger:1, // [14] *OFF, On
dailDef:1, // Unknown - 'Volume, Frequency'
language:1, // ?Chinese, English (English only FW BQ1.38+)
- unk_bit3:1, //
+ unk5:1, //
endToneElim:1, // *OFF, Frequency
- unkCheckBox1:1, //
- unkCheckBox2:1; //
+ unk6:1, //
+ unk7:1; //
u8 scanResumeTime : 2, // 0x1170 2S, 5S, 10S, 15S (not on screen)
disMode : 2, // [33] *Frequency, Channel, Name
scanType: 2, // [17] *To, Co, Se
ledMode: 2; // [07] *Off, On, Auto
- u8 unky; // 0x1171
- u8 str6; // 0x1172 Has flags to do with logging - factory
+ u8 unk8; // 0x1171
+ u8 unk9; // 0x1172 Has flags to do with logging - factory
// enabled (bits 16,64,128)
- u8 unk; // 0x1173
+ u8 unk10; // 0x1173
u8 swAudio : 1, // 0x1174 [19] *OFF, On
radioMoni : 1, // [34] *OFF, On
keylock : 1, // [18] *OFF, On
dualWait : 1, // [06] *OFF, On
- unk_bit3 : 1, //
+ unk11:1, //
light : 3; // [08] *1, 2, 3, 4, 5, 6, 7
u8 voxSw : 1, // 0x1175 [13] *OFF, On
voxDelay: 4, // *0.5S, 1.0S, 1.5S, 2.0S, 2.5S, 3.0S, 3.5S,
// 4.0S, 4.5S, 5.0S
voxLevel : 3; // [03] *1, 2, 3, 4, 5, 6, 7
- u8 str9 : 4, // 0x1176
+ u8 unk12:4, // 0x1176
saveMode : 2, // [16] *OFF, 1:1, 1:2, 1:4
keyMode : 2; // [32] *ALL, PTT, KEY, Key & Side Key
- u8 unk2; // 0x1177
- u8 unk3; // 0x1178
- u8 unk4; // 0x1179
+ u8 unk13; // 0x1177
+ u8 unk14; // 0x1178
+ u8 unk15; // 0x1179
u8 name2[6]; // 0x117A unused
} basicsettings;
"""
@@ -217,48 +217,48 @@ struct {
u8 unknownBytes[10]; // 0x1162 - 0x116B
u8 offFreqVoltage : 3, // 0x116C unknown referred to in code but not on
// screen
- unk_bit4 : 1, //
+ unk1:1, //
sqlLevel : 4; // [05] *OFF, 1-9
u8 beep : 1, // 0x116D [09] *OFF, On
callKind : 2, // code says 1750,2100,1000,1450 as options
// not on screen
introScreen: 2, // [20] *OFF, Voltage, Char String
- unkstr2: 2, //
+ unk2:2, //
txChSelect : 1; // [02] *Last CH, Main CH
u8 autoPowOff : 3, // 0x116E not on screen? OFF, 30Min, 1HR, 2HR
- unk : 1, //
+ unk3:1, //
tot : 4; // [11] *OFF, 30 Second, 60 Second, 90 Second,
// ... , 270 Second
- u8 unk_bit7:1, // 0x116F
+ u8 unk4:1, // 0x116F
roger:1, // [14] *OFF, On
dailDef:1, // Unknown - 'Volume, Frequency'
language:1, // English only
endToneElim:2, // *Frequency, 120, 180, 240 (RA89)
- unkCheckBox1:1, //
- unkCheckBox2:1; //
+ unk5:1, //
+ unk6:1; //
u8 scanType: 2, // 0x1170 [17] *Off, On, 5s, 10s, 15s, 20s, 25s, 30s
disMode : 2, // [33] *Frequency, Channel, Name
ledMode: 4; // [07] *Off, On, 5s, 10s, 15s, 20s, 25s, 30s
- u8 unky; // 0x1171
- u8 str6; // 0x1172 Has flags to do with logging - factory
+ u8 unk7; // 0x1171
+ u8 unk8; // 0x1172 Has flags to do with logging - factory
// enabled (bits 16,64,128)
- u8 unk; // 0x1173
+ u8 unk9; // 0x1173
u8 swAudio : 1, // 0x1174 [19] *OFF, On
radioMoni : 1, // [34] *OFF, On
keylock : 1, // [18] *OFF, On
dualWait : 1, // [06] *OFF, On
- unk_bit3 : 1, //
+ unk10:1, //
light : 3; // [08] *1, 2, 3, 4, 5, 6, 7
u8 voxSw : 1, // 0x1175 [13] *OFF, On
voxDelay: 4, // *0.5S, 1.0S, 1.5S, 2.0S, 2.5S, 3.0S, 3.5S,
// 4.0S, 4.5S, 5.0S
voxLevel : 3; // [03] *1, 2, 3, 4, 5, 6, 7
- u8 str9 : 4, // 0x1176
+ u8 unk11:4, // 0x1176
saveMode : 2, // [16] *OFF, 1:1, 1:2, 1:4
keyMode : 2; // [32] *ALL, PTT, KEY, Key & Side Key
- u8 unk2; // 0x1177
- u8 unk3; // 0x1178
- u8 unk4; // 0x1179
+ u8 unk12; // 0x1177
+ u8 unk13; // 0x1178
+ u8 unk14; // 0x1179
u8 name2[6]; // 0x117A unused
} basicsettings;
"""
@@ -371,9 +371,6 @@ def _do_ident(radio):
radio.pipe.parity = "N"
radio.pipe.timeout = STIMEOUT
- # Flush input buffer
- _clean_buffer(radio)
-
# Ident radio
magic = radio._magic0
_rawsend(radio, magic)
@@ -528,7 +525,10 @@ class THUV88Radio(chirp_common.CloneModeRadio):
MODEL = "TH-UV88"
NEEDS_COMPAT_SERIAL = False
MODES = ['WFM', 'FM', 'NFM']
- TONES = chirp_common.TONES
+ # 62.5 is a non standard tone listed in the official programming software
+ # 169.9 is a non standard tone listed in the official programming software
+ # probably by mistake instead of 167.9
+ TONES = (62.5,) + chirp_common.TONES + (169.9,)
DTCS_CODES = chirp_common.DTCS_CODES
NAME_LENGTH = 10
DTMF_CHARS = list("0123456789ABCD*#")
@@ -584,10 +584,10 @@ class THUV88Radio(chirp_common.CloneModeRadio):
"DTCS->DTCS"]
rf.valid_skips = []
rf.valid_power_levels = POWER_LEVELS
- rf.valid_dtcs_codes = chirp_common.ALL_DTCS_CODES # this is just to
- # get it working, not sure this is right
+ rf.valid_tones = self.TONES
+ rf.valid_dtcs_codes = self.DTCS_CODES
rf.valid_bands = self.VALID_BANDS
- rf.memory_bounds = (1, 199)
+ rf.memory_bounds = (1, CHAN_NUM)
rf.valid_skips = ["", "S"]
return rf
@@ -859,6 +859,7 @@ class THUV88Radio(chirp_common.CloneModeRadio):
_settings = self._memobj.basicsettings
_settings2 = self._memobj.settings2
_workmode = self._memobj.workmodesettings
+ _openradioname = self._memobj.openradioname
basic = RadioSettingGroup("basic", "Basic Settings")
group = RadioSettings(basic)
@@ -988,29 +989,45 @@ class THUV88Radio(chirp_common.CloneModeRadio):
rset = RadioSetting("basicsettings.endToneElim", "End Tone Elim", rx)
advanced.append(rset)
+ def _name_apply(setting, obj1, atrb1, obj2, atrb2):
+ # Store a trunctaded version avec the first line
+ # in basicsettings.intrScreen1. The original
+ # do this for an unkown reason
+ setattr(obj1, atrb1, str(setting.value)[:12])
+ setattr(obj2, atrb2, setting.value)
+ return
+
+ def _name_validate(value):
+ # The 16th char is not displayed correctly.
+ # Force it to space
+ return value[:15].ljust(16)
+
+ def _char_to_name(name):
+ rname = ""
+ for i in range(16): # 0 - 15
+ char = chr(int(name[i]))
+ if char == "\x00":
+ char = " " # Other software may have 0x00 mid-name
+ rname += char
+ return rname.rstrip() # remove trailing spaces
+
# software only
- name = ""
- for i in range(15): # 0 - 15
- char = chr(int(self._memobj.openradioname.name1[i]))
- if char == "\x00":
- char = " " # Other software may have 0x00 mid-name
- name += char
- name = name.rstrip() # remove trailing spaces
-
- rx = RadioSettingValueString(0, 15, name)
+ rx = RadioSettingValueString(0, 16,
+ _char_to_name(_openradioname.name1))
+ rx.set_validate_callback(_name_validate)
rset = RadioSetting("openradioname.name1", "Intro Line 1", rx)
+
+ # On model others than RA89 store a trunctated name1 into basicsettings
+ if self.MODEL != "RA89":
+ rset.set_apply_callback(_name_apply, _settings, "introScreen1",
+ _openradioname, "name1")
+
advanced.append(rset)
# software only
- name = ""
- for i in range(15): # 0 - 15
- char = chr(int(self._memobj.openradioname.name2[i]))
- if char == "\x00":
- char = " " # Other software may have 0x00 mid-name
- name += char
- name = name.rstrip() # remove trailing spaces
-
- rx = RadioSettingValueString(0, 15, name)
+ rx = RadioSettingValueString(0, 16,
+ _char_to_name(_openradioname.name2))
+ rx.set_validate_callback(_name_validate)
rset = RadioSetting("openradioname.name2", "Intro Line 2", rx)
advanced.append(rset)
@@ -1084,11 +1101,11 @@ class THUV88Radio(chirp_common.CloneModeRadio):
rset = RadioSetting("workmodesettings.ab", "A/B Select", rx)
workmode.append(rset)
- rx = RadioSettingValueInteger(1, 199, _workmode.mrAch + 1)
+ rx = RadioSettingValueInteger(1, CHAN_NUM, _workmode.mrAch + 1)
rset = RadioSetting("workmodesettings.mrAch", "MR A Channel #", rx)
workmode.append(rset)
- rx = RadioSettingValueInteger(1, 199, _workmode.mrBch + 1)
+ rx = RadioSettingValueInteger(1, CHAN_NUM, _workmode.mrBch + 1)
rset = RadioSetting("workmodesettings.mrBch", "MR B Channel #", rx)
workmode.append(rset)
diff --git a/chirp/drivers/th_uvf8d.py b/chirp/drivers/th_uvf8d.py
index 51881b2..5249f37 100644
--- a/chirp/drivers/th_uvf8d.py
+++ b/chirp/drivers/th_uvf8d.py
@@ -632,7 +632,7 @@ class TYTUVF8DRadio(chirp_common.CloneModeRadio):
_settings.rxsave = 0
continue
if element.get_name().endswith('_channel'):
- LOG.debug(element.value, type(element.value))
+ LOG.debug('%s %s', element.value, type(element.value))
setattr(_settings, element.get_name(), int(element.value) - 1)
continue
if not isinstance(element, RadioSetting):
diff --git a/chirp/drivers/thd72.py b/chirp/drivers/thd72.py
index ef39ec4..391ef90 100644
--- a/chirp/drivers/thd72.py
+++ b/chirp/drivers/thd72.py
@@ -769,74 +769,3 @@ class THD72Radio(chirp_common.CloneModeRadio):
return True
else:
return super(THD72Radio, cls).match_model(filedata, filename)
-
-
-if __name__ == "__main__":
- import sys
- import serial
- import getopt
-
- def fixopts(opts):
- r = {}
- for opt in opts:
- k, v = opt
- r[k] = v
- return r
-
- def usage():
- print("Usage: %s <-i input.img>|<-o output.img> -p port "
- "[[-f first-addr] [-l last-addr] | [-b list,of,blocks]]" %
- sys.argv[0])
- sys.exit(1)
-
- opts, args = getopt.getopt(sys.argv[1:], "i:o:p:f:l:b:")
- opts = fixopts(opts)
- first = last = 0
- blocks = None
- if '-i' in opts:
- fname = opts['-i']
- download = False
- elif '-o' in opts:
- fname = opts['-o']
- download = True
- else:
- usage()
- if '-p' in opts:
- port = opts['-p']
- else:
- usage()
-
- if '-f' in opts:
- first = int(opts['-f'], 0)
- if '-l' in opts:
- last = int(opts['-l'], 0)
- if '-b' in opts:
- blocks = [int(b, 0) for b in opts['-b'].split(',')]
- blocks.sort()
-
- ser = serial.Serial(port=port, baudrate=9600, timeout=0.25)
- r = THD72Radio(ser)
- memmax = r._memsize
- if not download:
- memmax -= 512
-
- if blocks is None:
- if first < 0 or first > (r._memsize - 1):
- raise errors.RadioError("first address out of range")
- if (last > 0 and last < first) or last > memmax:
- raise errors.RadioError("last address out of range")
- elif last == 0:
- last = memmax
- first /= 256
- if last % 256 != 0:
- last += 256
- last /= 256
- blocks = range(first, last)
-
- if download:
- data = r.download(True, blocks)
- open(fname, "wb").write(data)
- else:
- r._mmap = open(fname, "rb").read(r._memsize)
- r.upload(blocks)
- print("\nDone")
diff --git a/chirp/drivers/thd74.py b/chirp/drivers/thd74.py
index c2c44eb..b0ec5b2 100644
--- a/chirp/drivers/thd74.py
+++ b/chirp/drivers/thd74.py
@@ -48,8 +48,7 @@ struct {
} flags[1200];
#seekto 0x4000;
-struct {
- struct {
+struct memory {
ul32 freq;
ul32 offset;
u8 tuning_step:4,
@@ -81,11 +80,14 @@ struct {
char dv_rpt2call[8];
u8 unknown9:1,
dv_code:7;
- } memories[6];
+};
+
+struct {
+ struct memory memories[6];
u8 pad[16];
-} memgroups[210];
+} memgroups[192];
-#seekto 0x10000;
+//#seekto 0x10000;
struct {
char name[16];
} names[1200];
@@ -307,6 +309,7 @@ class THD74Radio(chirp_common.CloneModeRadio,
raise errors.RadioError("No response to ID command")
def _detect_baud(self):
+ id = None
for baud in [9600, 19200, 38400, 57600]:
self.pipe.baudrate = baud
try:
@@ -317,11 +320,16 @@ class THD74Radio(chirp_common.CloneModeRadio,
try:
id = self.get_id()
LOG.info("Radio %s at %i baud" % (id, baud))
- return True
+ break
except errors.RadioError:
pass
- raise errors.RadioError("No response from radio")
+ if id and not self.MODEL.startswith(id):
+ raise errors.RadioError(_('Unsupported model %r' % id))
+ elif id:
+ return id
+ else:
+ raise errors.RadioError("No response from radio")
def process_mmap(self):
self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
@@ -524,3 +532,8 @@ class THD74Radio(chirp_common.CloneModeRadio,
return True
else:
return chirp_common.CloneModeRadio.match_model(filedata, filename)
+
+
+@directory.register
+class THD75Radio(THD74Radio):
+ MODEL = 'TH-D75'
diff --git a/chirp/drivers/tk3140.py b/chirp/drivers/tk3140.py
index 5e87653..3678966 100644
--- a/chirp/drivers/tk3140.py
+++ b/chirp/drivers/tk3140.py
@@ -557,7 +557,7 @@ class KenwoodTKx140Radio(chirp_common.CloneModeRadio):
elif mem.duplex == 'split':
_mem.tx_freq = mem.offset // 10
elif mem.duplex == 'off':
- _mem.tx_freq = 0xFFFFFFFF
+ _mem.tx_freq.fill_raw(b'\xFF')
elif mem.duplex == '-':
_mem.tx_freq = (mem.freq - mem.offset) // 10
elif mem.duplex == '+':
diff --git a/chirp/drivers/tk760g.py b/chirp/drivers/tk760g.py
index 5ce31e9..f40ccca 100644
--- a/chirp/drivers/tk760g.py
+++ b/chirp/drivers/tk760g.py
@@ -769,8 +769,8 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio,
if k == 0:
k = 1
raise errors.InvalidValueError(
- "Invalid bank value '%k', bad data in the image? \
- Trying to fix this, review your bank data!" % k)
+ "Invalid bank value '%s', bad data in the image? "
+ "Trying to fix this, review your bank data!" % k)
c = 1
for i in v:
fdata += bytes([k, c, k - 1, i])
diff --git a/chirp/drivers/tk8180.py b/chirp/drivers/tk8180.py
index 476df13..a3f7965 100644
--- a/chirp/drivers/tk8180.py
+++ b/chirp/drivers/tk8180.py
@@ -23,7 +23,7 @@ from chirp import bitwise
from chirp.settings import RadioSettingGroup, RadioSetting
from chirp.settings import RadioSettingValueBoolean, RadioSettingValueList
from chirp.settings import RadioSettingValueString, RadioSettingValueInteger
-from chirp.settings import RadioSettings
+from chirp.settings import RadioSettings, RadioSettingSubGroup
LOG = logging.getLogger(__name__)
@@ -1041,7 +1041,7 @@ class KenwoodTKx180Radio(chirp_common.CloneModeRadio):
zones.append(zone_count)
for i in range(len(self._zones)):
- zone = RadioSettingGroup('zone%i' % i, 'Zone %i' % (i + 1))
+ zone = RadioSettingSubGroup('zone%i' % i, 'Zone %i' % (i + 1))
_zone = getattr(self._memobj, 'zone%i' % i).zoneinfo
_name = str(_zone.name).rstrip('\x00')
@@ -1107,10 +1107,14 @@ class KenwoodTKx180Radio(chirp_common.CloneModeRadio):
def _tones():
return ['Off'] + [str(x) for x in tones]
+ ostgroup = RadioSettingGroup('ost', 'OST')
+ ostgroup.set_doc('Operator Selectable Tone')
+ parent.append(ostgroup)
+
for i in range(0, 40):
_ost = self._memobj.ost_tones[i]
- ost = RadioSettingGroup('ost%i' % i,
- 'OST %i' % (i + 1))
+ ost = RadioSettingSubGroup('ost%i' % i,
+ 'OST %i' % (i + 1))
cur = str(_ost.name).rstrip('\x00')
name = RadioSetting('name%i' % i, 'Name',
@@ -1145,7 +1149,7 @@ class KenwoodTKx180Radio(chirp_common.CloneModeRadio):
tx.set_apply_callback(apply_tone, i, 'tx')
ost.append(tx)
- parent.append(ost)
+ ostgroup.append(ost)
def get_settings(self):
settings = self._memobj.settings
diff --git a/chirp/drivers/tmd710.py b/chirp/drivers/tmd710.py
index cd553db..365a33e 100644
--- a/chirp/drivers/tmd710.py
+++ b/chirp/drivers/tmd710.py
@@ -28,21 +28,13 @@ from chirp.drivers import kenwood_live
LOG = logging.getLogger(__name__)
-HAS_FUTURE = True
-try: # PY3 compliance
- from builtins import bytes
-except ImportError:
- HAS_FUTURE = False
- LOG.debug('python-future package is not '
- 'available; %s requires it' % __name__)
-
BAUD = 0
STIMEOUT = 0.2
TERM = b'\x0d' # Cmd write terminator (CR)
ACK = b'\x06' # Data write acknowledge char
W8S = 0.001 # short wait, secs
W8L = 0.1 # long wait
-TMD710_DUPLEX = ["", "+", "-", "n/a", "split"]
+TMD710_DUPLEX = ["", "+", "-", "", "split"]
TMD710_SKIP = ["", "S"]
TMD710_MODES = ["FM", "NFM", "AM"]
TMD710_BANDS = [(118000000, 135995000),
@@ -1251,847 +1243,847 @@ class KenwoodTMx710Radio(chirp_common.CloneModeRadio):
return False
-if HAS_FUTURE: # Only register drivers if environment is PY3 compliant
- @directory.register
- class KenwoodTMD710Radio(KenwoodTMx710Radio):
- """ Kenwood TM-D710 VHF/UHF/APRS Radio model. """
- VENDOR = "Kenwood"
- MODEL = "TM-D710_CloneMode"
- SHORT = "" # Quick model code
-
- _num_blocks = 3
- _num_packets = [0x9c, 1, 1]
-
- MEM_FORMAT = """
- struct chns { // 16 bytes channel structure
- ul32 rxfreq;
- u8 tstep;
- u8 mode;
- u8 tmode:4,
- duplex:4; // 4 = split
- u8 rtone;
- u8 ctone;
- u8 dtcs;
- ul32 offset; // or Split mode TX freq
- u8 splitstep;
- u8 cross; // not used
- };
-
- struct pm_grp { // 512 bytes per group
- u8 unk0200;
- u8 a_mr;
- u8 unk0202;
- u8 unk0203;
- u8 unk0204;
- u8 unk0205;
- u8 unk0206;
- u8 a_pwr;
- u8 wxalerta;
- u8 asmsql;
- u8 a_chn;
- u8 unk020b;
- u8 unk020c;
- u8 b_mr;
- u8 unk020e;
- u8 unk020f;
- u8 unk0210;
- u8 unk0211;
- u8 unk0212;
- u8 b_pwr;
- u8 wxalertb;
- u8 bsmsql;
- u8 b_chn;
- u8 unk0217;
- u8 unk0218;
- u8 unk0219;
- u8 unk021a;
- u8 unk021b;
- u8 unk021c;
- u8 unk021d;
- u8 unk021e;
- u8 unk021f;
- u8 unk0220;
- u8 unk0221;
- u8 unk0222;
- u8 unk0223;
- u8 unk0224;
- u8 unk0225;
- u8 unk0226;
- u8 unk0227;
- u8 unk0228;
- u8 unk0229;
- u8 unk022a;
- u8 unk022b;
- u8 unk022c;
- u8 unk022d;
- u8 unk022e;
- u8 unk022f;
- u8 unk0230;
- u8 unk0231;
- u8 sqclogic;
- u8 txband;
- u8 single;
- u8 unk0235;
- u8 mute;
- u8 unk0237;
- u8 unk0238;
- u8 unk0239;
- u8 unk0237a;
- u8 unk023b;
- u8 unk023c;
- u8 unk023d;
- u8 unk023e;
- u8 unk023f;
- struct chns vfo[10]; // 0x0240 - 0x02df
- char pwron[8];
- u8 unk02e8;
- u8 unk02e9;
- u8 unk02ea;
- u8 unk02eb;
- u8 unk02ec;
- u8 unk02ed;
- u8 unk02ee;
- u8 unk02ef;
- char memgrplk[10];
- u8 unk02fa;
- u8 unk02fb;
- u8 unk02fc;
- u8 unk02fd;
- u8 unk02fe;
- u8 unk02ff;
- struct {
- ul32 blow;
- ul32 bhigh;
- } progvfo[10];
- u8 beepon;
- u8 beepvol;
- u8 extspkr;
- u8 ance;
- u8 lang;
- u8 vcvol;
- u8 vcspd;
- u8 pbkrpt;
- u8 pbkint;
- u8 cntrec;
- u8 vhfaip;
- u8 uhfaip;
- u8 ssqlhu;
- u8 mutehu;
- u8 beatshft;
- u8 tot;
- u8 recall;
- u8 eclnkspd;
- u8 dtmfhld;
- u8 dtmfspd;
- u8 dtmfpau;
- u8 dtmflck;
- u8 rptrofst;
- u8 rptr1750;
- u8 bright;
- u8 autobri;
- u8 bkltclr;
- u8 pf1key;
- u8 pf2key;
- u8 micpf1;
- u8 micpf2;
- u8 micpf3;
- u8 micpf4;
- u8 miclck;
- u8 unk0372;
- u8 scnrsm;
- u8 apo;
- u8 extband;
- u8 extbaud;
- u8 sqcsrc;
- u8 autopm;
- u8 dispbar;
- u8 unk037a;
- u8 bkltcont;
- u8 dsprev;
- u8 vsmode;
- u8 intband;
- u8 wxscntm;
- u8 scntot;
- u8 scncot;
- u8 unk0382;
- u8 unk0383;
- u8 unk0384;
- u8 unk0385;
- u8 unk0386;
- u8 unk0387;
- u8 unk0388;
- u8 unk0389;
- u8 unk038a;
- u8 unk038b;
- u8 unk038c;
- u8 unk038d;
- u8 unk038e;
- u8 unk038f;
- u8 abnd118;
- u8 abnd144;
- u8 abnd220;
- u8 abnd300;
- u8 abnd430;
- u8 bbnd144;
- u8 bbnd220;
- u8 bbnd300;
- u8 bbnd430;
- u8 bbnd800;
- u8 unk039a;
- u8 unk039b;
- u8 unk039c;
- u8 unk039d;
- u8 unk039e;
- u8 unk039f;
- u8 unk03a0[96]; // to 0x03ff
- }; // end of struct pm
-
- #seekto 0x0000; // block1: x000 - x023f
- struct {
- u8 unk000[16];
- u8 unk010;
- u8 unk011;
- char unk012[3];
- u8 ansbck;
- u8 pmrecall; // 0x0016
- u8 pnlklk;
- u8 dspmemch;
- u8 m10mz;
- u8 micsens;
- u8 opband;
- u8 unk01c;
- u8 rptrmode;
- u8 rptrhold;
- u8 rptridx;
- u8 unk020;
- u8 pcbaud;
- u8 unk022;
- u8 pwdon; // 0x0023
- u8 unk024;
- u8 unk025;
- u8 unk026;
- u8 unk027;
- u8 unk028;
- u8 unk029;
- char pswd[6]; // 0x023a - 23f
- } block1;
-
- #seekto 0x0030;
- struct {
- char code[16]; // @ 0x0030
- } dtmc[10];
-
- struct {
- char id[8]; // 0x00d0 - 0x011f
- } dtmn[10];
-
- struct { // block1a: 0x0120 - 0x023f
- u8 unk0120;
- u8 unk0121;
- u8 unk0122[78];
- char rptrid[12]; // 0x0170 - 017b
- u8 unk017c;
- u8 unk017d;
- u8 unk017e;
- u8 unk017f;
- u8 unk0180[128]; // 0x0180 - 0x01ff
- } block1a;
-
- struct pm_grp pmg[6]; // 0x0200 - 0x0dff
-
- #seekto 0x0e00;
- struct {
- u8 band;
- u8 skip;
- } chmap[1030]; // to 0x0160b
-
- #seekto 0x01700; // 0x01700 - 0x0575f
- struct chns ch_mem[1030]; // 0-999 MR and 1000 -1029 Specials
-
- #seekto 0x05760;
- struct chns call[2];
-
- #seekto 0x05800;
- struct {
- char name[8];
- } ch_nam[1020]; // ends @ 0x07e0
-
- #seekto 0x077e0; // 0x077e0 - 0x07830
- struct {
- char name[8];
- } wxnam[10];
-
- #seekto 0x07da0;
- struct {
- char pmname[16];
- } pm_name[5];
-
- #seekto 0x07df0;
- struct {
- char comnt[32];
- } mcpcom;
-
- #seekto 0x08660;
- struct {
- char cmdr[10];
- char tptr[10];
- u8 skytone; // 0x08674
- } skycmd;
- // data stops at 0x09b98
- """
-
- def _read_mem(radio):
- """ Load the memory map """
- global BAUD
- status = chirp_common.Status()
- status.cur = 0
- val = 0
- for mx in range(0, radio._num_blocks):
- val += radio._num_packets[mx]
- status.max = val
- status.msg = "Reading %i packets" % val
- radio.status_fn(status)
-
- data = ""
-
- radio.pipe.baudrate = BAUD
- cmc = b"0M PROGRAM" + TERM
- resp0 = _command(radio.pipe, cmc, 3, W8S)
- junk = radio.pipe.read(16) # flushit
- for bkx in range(0, 0x09c):
- if bkx != 0x07f: # Skip block 7f !!??
- cmc = struct.pack('>cHB', b'R', bkx << 8, 0)
- resp0 = _command(radio.pipe, cmc, 260, W8S)
- junk = _command(radio.pipe, ACK, 1, W8S)
- if len(resp0) < 260:
- junk = _command(radio.pipe, b"E", 2, W8S)
- sx = "Block 0x%x read error: " % bkx
- sx += "Got %i bytes, expected 260." % len(resp0)
- LOG.error(sx)
- sx = "Block read error! Check debug.log"
- raise errors.RadioError(sx)
- if bkx == 0: # 1st packet of 1st block
- mht = resp0[4:7] # [57 00 00 00] 03 4b 01 ff ff ...
- data = resp0[5:6] # 2nd byte (4b) replaces 1st
- data += resp0[5:] # then bytes 2 on (4b 4b 01 ff ...)
- else:
- data += resp0[4:] # skip cmd echo
- _update_status(radio, status) # UI Update
- cmc = struct.pack('>cHB', b'R', 0xFEF0, 0x10)
- resp0 = _command(radio.pipe, cmc, 0x014, W8S)
- data += resp0[4:]
- junk = _command(radio.pipe, ACK, 1, W8S)
- _update_status(radio, status)
- cmc = struct.pack('>cHB', b'R', 0xFF00, 0x90)
- resp0 = _command(radio.pipe, cmc, 0x094, W8S)
- data += resp0[4:]
- junk = _command(radio.pipe, ACK, 1, W8S)
- _update_status(radio, status)
- # Exit Prog mode, no TERM
- resp = _command(radio.pipe, b"E", 2, W8S) # Rtns 06 0d
- radio.pipe.baudrate = BAUD
- return data
-
- def _write_mem(radio):
- """ PROG MCP Blocks Send """
- global BAUD
- # UI progress
- status = chirp_common.Status()
- status.cur = 0
- val = 0
- for mx in range(0, radio._num_blocks):
- val += radio._num_packets[mx]
- status.max = val
- status.msg = "Writing %i packets" % val
- radio.status_fn(status)
-
- imgadr = 0
- radio.pipe.baudrate = BAUD
- resp0 = _command(radio.pipe, b"0M PROGRAM" + TERM, 3, W8S)
- # Read block 0 magic header thingy, save it
- cmc = b"R" + bytes([0, 0, 4])
- resp0 = _command(radio.pipe, cmc, 8, W8S)
- mht0 = resp0[4:] # Expecting [57 00 00 04] 03 4b 01 ff
- junk = _command(radio.pipe, ACK, 1, W8S)
- cmc = b"W" + bytes([0, 0, 1, 0xff])
- junk = _command(radio.pipe, cmc, 1, W8S) # responds ACK
- cmc = b"R" + bytes([0x80, 0, 3])
- resp = _command(radio.pipe, cmc, 7, W8S) # [57 80 00 03] 00 33 00
- mht1 = resp[4:]
- junk = _command(radio.pipe, ACK, 1, W8S)
- cmc = b"W" + bytes([0x80, 0, 1, 0xff])
- junk = _command(radio.pipe, cmc, 1, W8S)
- imgadr = 4 # After 03 4b 01 ff
- for bkx in range(0, radio._num_packets[0]):
- cmc = b"W" + bytes([bkx, 0, 0])
- imgstep = 256
- if bkx == 0:
- imgstep = 0x0fc
- cmc = b"W" + bytes([0, 4, imgstep])
- cmc += radio.get_mmap()[imgadr:imgadr + imgstep]
- else: # after first packet
- cmc += radio.get_mmap()[imgadr:imgadr + imgstep]
- if bkx != 0x07f: # don't send 7f !
- resp0 = _command(radio.pipe, cmc, 1, W8S)
- if resp0 != ACK:
- LOG.error("Packet 0x%x Write error, no ACK." % bkx)
- sx = "Radio failed to acknowledge upload packet!"
- raise errors.RadioError(sx)
- imgadr += imgstep
+@directory.register
+class KenwoodTMD710Radio(KenwoodTMx710Radio):
+ """ Kenwood TM-D710 VHF/UHF/APRS Radio model. """
+ VENDOR = "Kenwood"
+ MODEL = "TM-D710_CloneMode"
+ SHORT = "" # Quick model code
+
+ _num_blocks = 3
+ _num_packets = [0x9c, 1, 1]
+
+ MEM_FORMAT = """
+ struct chns { // 16 bytes channel structure
+ ul32 rxfreq;
+ u8 tstep;
+ u8 mode;
+ u8 tmode:4,
+ duplex:4; // 4 = split
+ u8 rtone;
+ u8 ctone;
+ u8 dtcs;
+ ul32 offset; // or Split mode TX freq
+ u8 splitstep;
+ u8 cross; // not used
+ };
+
+ struct pm_grp { // 512 bytes per group
+ u8 unk0200;
+ u8 a_mr;
+ u8 unk0202;
+ u8 unk0203;
+ u8 unk0204;
+ u8 unk0205;
+ u8 unk0206;
+ u8 a_pwr;
+ u8 wxalerta;
+ u8 asmsql;
+ u8 a_chn;
+ u8 unk020b;
+ u8 unk020c;
+ u8 b_mr;
+ u8 unk020e;
+ u8 unk020f;
+ u8 unk0210;
+ u8 unk0211;
+ u8 unk0212;
+ u8 b_pwr;
+ u8 wxalertb;
+ u8 bsmsql;
+ u8 b_chn;
+ u8 unk0217;
+ u8 unk0218;
+ u8 unk0219;
+ u8 unk021a;
+ u8 unk021b;
+ u8 unk021c;
+ u8 unk021d;
+ u8 unk021e;
+ u8 unk021f;
+ u8 unk0220;
+ u8 unk0221;
+ u8 unk0222;
+ u8 unk0223;
+ u8 unk0224;
+ u8 unk0225;
+ u8 unk0226;
+ u8 unk0227;
+ u8 unk0228;
+ u8 unk0229;
+ u8 unk022a;
+ u8 unk022b;
+ u8 unk022c;
+ u8 unk022d;
+ u8 unk022e;
+ u8 unk022f;
+ u8 unk0230;
+ u8 unk0231;
+ u8 sqclogic;
+ u8 txband;
+ u8 single;
+ u8 unk0235;
+ u8 mute;
+ u8 unk0237;
+ u8 unk0238;
+ u8 unk0239;
+ u8 unk0237a;
+ u8 unk023b;
+ u8 unk023c;
+ u8 unk023d;
+ u8 unk023e;
+ u8 unk023f;
+ struct chns vfo[10]; // 0x0240 - 0x02df
+ char pwron[8];
+ u8 unk02e8;
+ u8 unk02e9;
+ u8 unk02ea;
+ u8 unk02eb;
+ u8 unk02ec;
+ u8 unk02ed;
+ u8 unk02ee;
+ u8 unk02ef;
+ char memgrplk[10];
+ u8 unk02fa;
+ u8 unk02fb;
+ u8 unk02fc;
+ u8 unk02fd;
+ u8 unk02fe;
+ u8 unk02ff;
+ struct {
+ ul32 blow;
+ ul32 bhigh;
+ } progvfo[10];
+ u8 beepon;
+ u8 beepvol;
+ u8 extspkr;
+ u8 ance;
+ u8 lang;
+ u8 vcvol;
+ u8 vcspd;
+ u8 pbkrpt;
+ u8 pbkint;
+ u8 cntrec;
+ u8 vhfaip;
+ u8 uhfaip;
+ u8 ssqlhu;
+ u8 mutehu;
+ u8 beatshft;
+ u8 tot;
+ u8 recall;
+ u8 eclnkspd;
+ u8 dtmfhld;
+ u8 dtmfspd;
+ u8 dtmfpau;
+ u8 dtmflck;
+ u8 rptrofst;
+ u8 rptr1750;
+ u8 bright;
+ u8 autobri;
+ u8 bkltclr;
+ u8 pf1key;
+ u8 pf2key;
+ u8 micpf1;
+ u8 micpf2;
+ u8 micpf3;
+ u8 micpf4;
+ u8 miclck;
+ u8 unk0372;
+ u8 scnrsm;
+ u8 apo;
+ u8 extband;
+ u8 extbaud;
+ u8 sqcsrc;
+ u8 autopm;
+ u8 dispbar;
+ u8 unk037a;
+ u8 bkltcont;
+ u8 dsprev;
+ u8 vsmode;
+ u8 intband;
+ u8 wxscntm;
+ u8 scntot;
+ u8 scncot;
+ u8 unk0382;
+ u8 unk0383;
+ u8 unk0384;
+ u8 unk0385;
+ u8 unk0386;
+ u8 unk0387;
+ u8 unk0388;
+ u8 unk0389;
+ u8 unk038a;
+ u8 unk038b;
+ u8 unk038c;
+ u8 unk038d;
+ u8 unk038e;
+ u8 unk038f;
+ u8 abnd118;
+ u8 abnd144;
+ u8 abnd220;
+ u8 abnd300;
+ u8 abnd430;
+ u8 bbnd144;
+ u8 bbnd220;
+ u8 bbnd300;
+ u8 bbnd430;
+ u8 bbnd800;
+ u8 unk039a;
+ u8 unk039b;
+ u8 unk039c;
+ u8 unk039d;
+ u8 unk039e;
+ u8 unk039f;
+ u8 unk03a0[96]; // to 0x03ff
+ }; // end of struct pm
+
+ #seekto 0x0000; // block1: x000 - x023f
+ struct {
+ u8 unk000[16];
+ u8 unk010;
+ u8 unk011;
+ char unk012[3];
+ u8 ansbck;
+ u8 pmrecall; // 0x0016
+ u8 pnlklk;
+ u8 dspmemch;
+ u8 m10mz;
+ u8 micsens;
+ u8 opband;
+ u8 unk01c;
+ u8 rptrmode;
+ u8 rptrhold;
+ u8 rptridx;
+ u8 unk020;
+ u8 pcbaud;
+ u8 unk022;
+ u8 pwdon; // 0x0023
+ u8 unk024;
+ u8 unk025;
+ u8 unk026;
+ u8 unk027;
+ u8 unk028;
+ u8 unk029;
+ char pswd[6]; // 0x023a - 23f
+ } block1;
+
+ #seekto 0x0030;
+ struct {
+ char code[16]; // @ 0x0030
+ } dtmc[10];
+
+ struct {
+ char id[8]; // 0x00d0 - 0x011f
+ } dtmn[10];
+
+ struct { // block1a: 0x0120 - 0x023f
+ u8 unk0120;
+ u8 unk0121;
+ u8 unk0122[78];
+ char rptrid[12]; // 0x0170 - 017b
+ u8 unk017c;
+ u8 unk017d;
+ u8 unk017e;
+ u8 unk017f;
+ u8 unk0180[128]; // 0x0180 - 0x01ff
+ } block1a;
+
+ struct pm_grp pmg[6]; // 0x0200 - 0x0dff
+
+ #seekto 0x0e00;
+ struct {
+ u8 band;
+ u8 skip;
+ } chmap[1030]; // to 0x0160b
+
+ #seekto 0x01700; // 0x01700 - 0x0575f
+ struct chns ch_mem[1030]; // 0-999 MR and 1000 -1029 Specials
+
+ #seekto 0x05760;
+ struct chns call[2];
+
+ #seekto 0x05800;
+ struct {
+ char name[8];
+ } ch_nam[1020]; // ends @ 0x07e0
+
+ #seekto 0x077e0; // 0x077e0 - 0x07830
+ struct {
+ char name[8];
+ } wxnam[10];
+
+ #seekto 0x07da0;
+ struct {
+ char pmname[16];
+ } pm_name[5];
+
+ #seekto 0x07df0;
+ struct {
+ char comnt[32];
+ } mcpcom;
+
+ #seekto 0x08660;
+ struct {
+ char cmdr[10];
+ char tptr[10];
+ u8 skytone; // 0x08674
+ } skycmd;
+ // data stops at 0x09b98
+ """
+
+ def _read_mem(radio):
+ """ Load the memory map """
+ global BAUD
+ status = chirp_common.Status()
+ status.cur = 0
+ val = 0
+ for mx in range(0, radio._num_blocks):
+ val += radio._num_packets[mx]
+ status.max = val
+ status.msg = "Reading %i packets" % val
+ radio.status_fn(status)
+
+ data = ""
+
+ radio.pipe.baudrate = BAUD
+ cmc = b"0M PROGRAM" + TERM
+ resp0 = _command(radio.pipe, cmc, 3, W8S)
+ junk = radio.pipe.read(16) # flushit
+ for bkx in range(0, 0x09c):
+ if bkx != 0x07f: # Skip block 7f !!??
+ cmc = struct.pack('>cHB', b'R', bkx << 8, 0)
+ resp0 = _command(radio.pipe, cmc, 260, W8S)
+ junk = _command(radio.pipe, ACK, 1, W8S)
+ if len(resp0) < 260:
+ junk = _command(radio.pipe, b"E", 2, W8S)
+ sx = "Block 0x%x read error: " % bkx
+ sx += "Got %i bytes, expected 260." % len(resp0)
+ LOG.error(sx)
+ sx = "Block read error! Check debug.log"
+ raise errors.RadioError(sx)
+ if bkx == 0: # 1st packet of 1st block
+ mht = resp0[4:7] # [57 00 00 00] 03 4b 01 ff ff ...
+ data = resp0[5:6] # 2nd byte (4b) replaces 1st
+ data += resp0[5:] # then bytes 2 on (4b 4b 01 ff ...)
+ else:
+ data += resp0[4:] # skip cmd echo
_update_status(radio, status) # UI Update
- # write fe and ff blocks
- cmc = b"W" + bytes([0xfe, 0xf0, 16])
- cmc += radio.get_mmap()[imgadr:imgadr + 16]
- resp0 = _command(radio.pipe, cmc, 1, W8S)
- if resp0 != ACK:
- LOG.error("Packet 0xfe Write error, no ACK.")
- sx = "Radio failed to acknowledge upload packet!"
- raise errors.RadioError(sx)
- imgadr += 16
- cmc = b"W" + bytes([0xff, 0, 0x90])
- cmc += radio.get_mmap()[imgadr:imgadr + 0x090]
- resp0 = _command(radio.pipe, cmc, 1, W8S)
- if resp0 != ACK:
- LOG.error("Packet 0xff Write error, no ACK.")
- sx = "Radio failed to acknowledge upload packet!"
- raise errors.RadioError(sx)
- # Write mht1
- cmc = b"W" + bytes([0x80, 0, 3]) + mht1
- resp0 = _command(radio.pipe, cmc, 1, W8S)
- if resp0 != ACK:
- LOG.error("Mht1 Write error at 0x080 00 03 , no ACK.")
- sx = "Radio failed to acknowledge upload packet!"
- raise errors.RadioError(sx)
- # and mht0
- cmc = b"W" + bytes([0, 0, 4]) + mht0
- resp0 = _command(radio.pipe, cmc, 1, W8S)
- if resp0 != ACK:
- LOG.error("Mht0 Write error at 00 00 04 , no ACK.")
- sx = "Radio failed to acknowledge upload packet!"
- raise errors.RadioError(sx)
- # Write E to Exit PROG mode
- resp = _command(radio.pipe, b"E", 2, W8S)
- return
+ cmc = struct.pack('>cHB', b'R', 0xFEF0, 0x10)
+ resp0 = _command(radio.pipe, cmc, 0x014, W8S)
+ data += resp0[4:]
+ junk = _command(radio.pipe, ACK, 1, W8S)
+ _update_status(radio, status)
+ cmc = struct.pack('>cHB', b'R', 0xFF00, 0x90)
+ resp0 = _command(radio.pipe, cmc, 0x094, W8S)
+ data += resp0[4:]
+ junk = _command(radio.pipe, ACK, 1, W8S)
+ _update_status(radio, status)
+ # Exit Prog mode, no TERM
+ resp = _command(radio.pipe, b"E", 2, W8S) # Rtns 06 0d
+ radio.pipe.baudrate = BAUD
+ return data
+
+ def _write_mem(radio):
+ """ PROG MCP Blocks Send """
+ global BAUD
+ # UI progress
+ status = chirp_common.Status()
+ status.cur = 0
+ val = 0
+ for mx in range(0, radio._num_blocks):
+ val += radio._num_packets[mx]
+ status.max = val
+ status.msg = "Writing %i packets" % val
+ radio.status_fn(status)
+
+ imgadr = 0
+ radio.pipe.baudrate = BAUD
+ resp0 = _command(radio.pipe, b"0M PROGRAM" + TERM, 3, W8S)
+ # Read block 0 magic header thingy, save it
+ cmc = b"R" + bytes([0, 0, 4])
+ resp0 = _command(radio.pipe, cmc, 8, W8S)
+ mht0 = resp0[4:] # Expecting [57 00 00 04] 03 4b 01 ff
+ junk = _command(radio.pipe, ACK, 1, W8S)
+ cmc = b"W" + bytes([0, 0, 1, 0xff])
+ junk = _command(radio.pipe, cmc, 1, W8S) # responds ACK
+ cmc = b"R" + bytes([0x80, 0, 3])
+ resp = _command(radio.pipe, cmc, 7, W8S) # [57 80 00 03] 00 33 00
+ mht1 = resp[4:]
+ junk = _command(radio.pipe, ACK, 1, W8S)
+ cmc = b"W" + bytes([0x80, 0, 1, 0xff])
+ junk = _command(radio.pipe, cmc, 1, W8S)
+ imgadr = 4 # After 03 4b 01 ff
+ for bkx in range(0, radio._num_packets[0]):
+ cmc = b"W" + bytes([bkx, 0, 0])
+ imgstep = 256
+ if bkx == 0:
+ imgstep = 0x0fc
+ cmc = b"W" + bytes([0, 4, imgstep])
+ cmc += radio.get_mmap()[imgadr:imgadr + imgstep]
+ else: # after first packet
+ cmc += radio.get_mmap()[imgadr:imgadr + imgstep]
+ if bkx != 0x07f: # don't send 7f !
+ resp0 = _command(radio.pipe, cmc, 1, W8S)
+ if resp0 != ACK:
+ LOG.error("Packet 0x%x Write error, no ACK." % bkx)
+ sx = "Radio failed to acknowledge upload packet!"
+ raise errors.RadioError(sx)
+ imgadr += imgstep
+ _update_status(radio, status) # UI Update
+ # write fe and ff blocks
+ cmc = b"W" + bytes([0xfe, 0xf0, 16])
+ cmc += radio.get_mmap()[imgadr:imgadr + 16]
+ resp0 = _command(radio.pipe, cmc, 1, W8S)
+ if resp0 != ACK:
+ LOG.error("Packet 0xfe Write error, no ACK.")
+ sx = "Radio failed to acknowledge upload packet!"
+ raise errors.RadioError(sx)
+ imgadr += 16
+ cmc = b"W" + bytes([0xff, 0, 0x90])
+ cmc += radio.get_mmap()[imgadr:imgadr + 0x090]
+ resp0 = _command(radio.pipe, cmc, 1, W8S)
+ if resp0 != ACK:
+ LOG.error("Packet 0xff Write error, no ACK.")
+ sx = "Radio failed to acknowledge upload packet!"
+ raise errors.RadioError(sx)
+ # Write mht1
+ cmc = b"W" + bytes([0x80, 0, 3]) + mht1
+ resp0 = _command(radio.pipe, cmc, 1, W8S)
+ if resp0 != ACK:
+ LOG.error("Mht1 Write error at 0x080 00 03 , no ACK.")
+ sx = "Radio failed to acknowledge upload packet!"
+ raise errors.RadioError(sx)
+ # and mht0
+ cmc = b"W" + bytes([0, 0, 4]) + mht0
+ resp0 = _command(radio.pipe, cmc, 1, W8S)
+ if resp0 != ACK:
+ LOG.error("Mht0 Write error at 00 00 04 , no ACK.")
+ sx = "Radio failed to acknowledge upload packet!"
+ raise errors.RadioError(sx)
+ # Write E to Exit PROG mode
+ resp = _command(radio.pipe, b"E", 2, W8S)
+ return
+
- @directory.register
- class KenwoodTMD710GRadio(KenwoodTMx710Radio):
- """ Kenwood TM-D710G VHF/UHF/GPS/APRS Radio model. """
- VENDOR = "Kenwood"
- MODEL = "TM-D710G_CloneMode"
- SHORT = "G" # Quick model code 1 for G
-
- _num_blocks = 2 # Only reading first 2, not GPS logs
- _packet_size = [261, 261, 261]
- _block_addr = [0, 0x100, 0x200] # starting addr, each block
- _num_packets = [0x7f, 0x0fe, 0x200] # num packets per block, 0-based
-
- MEM_FORMAT = """
- struct chns { // 16 bytes channel structure
- ul32 rxfreq;
- u8 tstep;
- u8 mode;
- u8 tmode:4,
- duplex:4; // 4 = split
- u8 rtone;
- u8 ctone;
- u8 dtcs;
- u8 cross;
- ul32 offset; // or Split mode TX freq
- u8 splitstep;
- };
-
- struct pm_grp { // 512 bytes per group
- u8 unk0200;
- u8 a_mr;
- u8 unk0202;
- u8 unk0203;
- u8 unk0204;
- u8 unk0205;
- u8 unk0206;
- u8 a_pwr;
- u8 wxalerta;
- u8 asmsql;
- u8 a_chn;
- u8 unk020b;
- u8 unk020c;
- u8 b_mr;
- u8 unk020e;
- u8 unk020f;
- u8 unk0210;
- u8 unk0211;
- u8 unk0212;
- u8 b_pwr;
- u8 wxalertb;
- u8 bsmsql;
- u8 b_chn;
- u8 unk0217;
- u8 unk0218;
- u8 unk0219;
- u8 unk021a;
- u8 unk021b;
- u8 unk021c;
- u8 unk021d;
- u8 unk021e;
- u8 unk021f;
- u8 unk0220;
- u8 unk0221;
- u8 unk0222;
- u8 unk0223;
- u8 unk0224;
- u8 unk0225;
- u8 unk0226;
- u8 unk0227;
- u8 unk0228;
- u8 unk0229;
- u8 unk022a;
- u8 unk022b;
- u8 unk022c;
- u8 unk022d;
- u8 unk022e;
- u8 unk022f;
- u8 unk0230;
- u8 unk0231;
- u8 sqclogic;
- u8 txband;
- u8 single;
- u8 unk0235;
- u8 mute;
- u8 unk0237;
- u8 unk0238;
- u8 unk0239;
- u8 unk0237a;
- u8 unk023b;
- u8 unk023c;
- u8 unk023d;
- u8 unk023e;
- u8 unk023f;
- struct chns vfo[10]; // 0x0240 - 0x02df
- char pwron[8];
- u8 unk02e8;
- u8 unk02e9;
- u8 unk02ea;
- u8 unk02eb;
- u8 unk02ec;
- u8 unk02ed;
- u8 unk02ee;
- u8 unk02ef;
- char memgrplk[10];
- u8 unk02fa;
- u8 unk02fb;
- u8 unk02fc;
- u8 unk02fd;
- u8 unk02fe;
- u8 unk02ff;
- struct {
- ul32 blow;
- ul32 bhigh;
- } progvfo[10];
- u8 beepon;
- u8 beepvol;
- u8 extspkr;
- u8 ance;
- u8 lang;
- u8 vcvol;
- u8 vcspd;
- u8 pbkrpt;
- u8 pbkint;
- u8 cntrec;
- u8 vhfaip;
- u8 uhfaip;
- u8 ssqlhu;
- u8 mutehu;
- u8 beatshft;
- u8 tot;
- u8 recall;
- u8 eclnkspd;
- u8 dtmfhld;
- u8 dtmfspd;
- u8 dtmfpau;
- u8 dtmflck;
- u8 rptrofst;
- u8 rptr1750;
- u8 bright;
- u8 autobri;
- u8 bkltclr;
- u8 pf1key;
- u8 pf2key;
- u8 micpf1;
- u8 micpf2;
- u8 micpf3;
- u8 micpf4;
- u8 miclck;
- u8 unk0372;
- u8 scnrsm;
- u8 apo;
- u8 extband;
- u8 extbaud;
- u8 sqcsrc;
- u8 autopm;
- u8 dispbar;
- u8 unk037a;
- u8 bkltcont;
- u8 dsprev;
- u8 vsmode;
- u8 intband;
- u8 wxscntm;
- u8 scntot;
- u8 scncot;
- u8 unk0382;
- u8 unk0383;
- u8 unk0384;
- u8 unk0385;
- u8 unk0386;
- u8 unk0387;
- u8 unk0388;
- u8 unk0389;
- u8 unk038a;
- u8 unk038b;
- u8 unk038c;
- u8 unk038d;
- u8 unk038e;
- u8 unk038f;
- u8 abnd118;
- u8 abnd144;
- u8 abnd220;
- u8 abnd300;
- u8 abnd430;
- u8 bbnd144;
- u8 bbnd220;
- u8 bbnd300;
- u8 bbnd430;
- u8 bbnd800;
- u8 unk039a;
- u8 unk039b;
- u8 unk039c;
- u8 unk039d;
- u8 unk039e;
- u8 unk039f;
- u8 unk03a0[96]; // to 0x03ff
- }; // end of struct pm
-
- #seekto 0x0000; // block1: x000 - x023f
- struct {
- u8 unk000[16];
- u8 unk010;
- u8 unk011;
- char unk012[3];
- u8 ansbck;
- u8 pmrecall; // 0x0016
- u8 pnlklk;
- u8 dspmemch;
- u8 m10mz;
- u8 micsens;
- u8 opband;
- u8 unk01c;
- u8 rptrmode;
- u8 rptrhold;
- u8 rptridx;
- u8 unk020;
- u8 pcbaud;
- u8 unk022;
- u8 pwdon; // 0x0023
- u8 unk024;
- u8 unk025;
- u8 unk026;
- u8 unk027;
- u8 unk028;
- u8 unk029;
- char pswd[6]; // 0x023a - 23f
- } block1;
-
- #seekto 0x0030;
- struct {
- char code[16]; // @ 0x0030
- } dtmc[10];
-
- struct {
- char id[8]; // 0x00d0 - 0x011f
- } dtmn[10];
-
- struct { // block1a: 0x0120 - 0x023f
- u8 unk0120;
- u8 unk0121;
- u8 unk0122[78];
- char rptrid[12]; // 0x0170 - 017b
- u8 unk017c;
- u8 unk017d;
- u8 unk017e;
- u8 unk017f;
- u8 unk0180[128]; // 0x0180 - 0x01ff
- } block1a;
-
- struct pm_grp pmg[6]; // 0x0200 - 0x0dff
-
- #seekto 0x0e00;
- struct {
- u8 band;
- u8 skip;
- } chmap[1030]; // to 0x0160b
-
- #seekto 0x01700; // 0x01700 - 0x0575f
- struct chns ch_mem[1030]; // 0-999 MR and 1000 -1029 Specials
-
- #seekto 0x058a0;
- struct chns call[2];
-
- #seekto 0x05900;
- struct {
- char name[8];
- } ch_nam[1020]; // ends @ 0x07840
-
- #seekto 0x078e0; // 0x078e0 - 0x0792f
- struct {
- char name[8];
- } wxnam[10];
-
- #seekto 0x07da0;
- struct {
- char pmname[16];
- } pm_name[5];
-
- #seekto 0x07df0;
- struct {
- char comnt[32];
- } mcpcom;
- // Block 1 ends @ 0x07eff
- // Block 2 starts @ 0x07f00
- #seekto 0x08660;
- struct {
- char cmdr[10];
- char tptr[10];
- u8 skytone; // 0x08674
- } skycmd;
-
- #seekto 0x10ef0;
- struct {
- u8 bmp[1896];
- u8 unk11658[8]; // 0x11658
- char bmpfyl[64]; // 0x11660
- u8 unk116a0[95];
- u8 bmpon; // 0x116ff
- } bitmap;
-
- // 2nd block ends @ 0x017cff
- """
-
- def _make_command(self, cmd, addr, length, data=b''):
- cmc = struct.pack('>IB', addr, length)
- return cmd + cmc[1:] + data
-
- def _read_mem(radio):
- """ Load the memory map """
- global BAUD
- status = chirp_common.Status()
- status.cur = 0
- val = 0
- for mx in range(0, radio._num_blocks):
- val += radio._num_packets[mx]
- status.max = val
- status.msg = "Reading %i packets" % val
- radio.status_fn(status)
-
- data = b""
-
- radio.pipe.baudrate = BAUD
- resp0 = radio.pipe.read(16) # flush
- cmc = b"0M PROGRAM" + TERM
+@directory.register
+class KenwoodTMD710GRadio(KenwoodTMx710Radio):
+ """ Kenwood TM-D710G VHF/UHF/GPS/APRS Radio model. """
+ VENDOR = "Kenwood"
+ MODEL = "TM-D710G_CloneMode"
+ SHORT = "G" # Quick model code 1 for G
+
+ _num_blocks = 2 # Only reading first 2, not GPS logs
+ _packet_size = [261, 261, 261]
+ _block_addr = [0, 0x100, 0x200] # starting addr, each block
+ _num_packets = [0x7f, 0x0fe, 0x200] # num packets per block, 0-based
+
+ MEM_FORMAT = """
+ struct chns { // 16 bytes channel structure
+ ul32 rxfreq;
+ u8 tstep;
+ u8 mode;
+ u8 tmode:4,
+ duplex:4; // 4 = split
+ u8 rtone;
+ u8 ctone;
+ u8 dtcs;
+ u8 cross;
+ ul32 offset; // or Split mode TX freq
+ u8 splitstep;
+ };
+
+ struct pm_grp { // 512 bytes per group
+ u8 unk0200;
+ u8 a_mr;
+ u8 unk0202;
+ u8 unk0203;
+ u8 unk0204;
+ u8 unk0205;
+ u8 unk0206;
+ u8 a_pwr;
+ u8 wxalerta;
+ u8 asmsql;
+ u8 a_chn;
+ u8 unk020b;
+ u8 unk020c;
+ u8 b_mr;
+ u8 unk020e;
+ u8 unk020f;
+ u8 unk0210;
+ u8 unk0211;
+ u8 unk0212;
+ u8 b_pwr;
+ u8 wxalertb;
+ u8 bsmsql;
+ u8 b_chn;
+ u8 unk0217;
+ u8 unk0218;
+ u8 unk0219;
+ u8 unk021a;
+ u8 unk021b;
+ u8 unk021c;
+ u8 unk021d;
+ u8 unk021e;
+ u8 unk021f;
+ u8 unk0220;
+ u8 unk0221;
+ u8 unk0222;
+ u8 unk0223;
+ u8 unk0224;
+ u8 unk0225;
+ u8 unk0226;
+ u8 unk0227;
+ u8 unk0228;
+ u8 unk0229;
+ u8 unk022a;
+ u8 unk022b;
+ u8 unk022c;
+ u8 unk022d;
+ u8 unk022e;
+ u8 unk022f;
+ u8 unk0230;
+ u8 unk0231;
+ u8 sqclogic;
+ u8 txband;
+ u8 single;
+ u8 unk0235;
+ u8 mute;
+ u8 unk0237;
+ u8 unk0238;
+ u8 unk0239;
+ u8 unk0237a;
+ u8 unk023b;
+ u8 unk023c;
+ u8 unk023d;
+ u8 unk023e;
+ u8 unk023f;
+ struct chns vfo[10]; // 0x0240 - 0x02df
+ char pwron[8];
+ u8 unk02e8;
+ u8 unk02e9;
+ u8 unk02ea;
+ u8 unk02eb;
+ u8 unk02ec;
+ u8 unk02ed;
+ u8 unk02ee;
+ u8 unk02ef;
+ char memgrplk[10];
+ u8 unk02fa;
+ u8 unk02fb;
+ u8 unk02fc;
+ u8 unk02fd;
+ u8 unk02fe;
+ u8 unk02ff;
+ struct {
+ ul32 blow;
+ ul32 bhigh;
+ } progvfo[10];
+ u8 beepon;
+ u8 beepvol;
+ u8 extspkr;
+ u8 ance;
+ u8 lang;
+ u8 vcvol;
+ u8 vcspd;
+ u8 pbkrpt;
+ u8 pbkint;
+ u8 cntrec;
+ u8 vhfaip;
+ u8 uhfaip;
+ u8 ssqlhu;
+ u8 mutehu;
+ u8 beatshft;
+ u8 tot;
+ u8 recall;
+ u8 eclnkspd;
+ u8 dtmfhld;
+ u8 dtmfspd;
+ u8 dtmfpau;
+ u8 dtmflck;
+ u8 rptrofst;
+ u8 rptr1750;
+ u8 bright;
+ u8 autobri;
+ u8 bkltclr;
+ u8 pf1key;
+ u8 pf2key;
+ u8 micpf1;
+ u8 micpf2;
+ u8 micpf3;
+ u8 micpf4;
+ u8 miclck;
+ u8 unk0372;
+ u8 scnrsm;
+ u8 apo;
+ u8 extband;
+ u8 extbaud;
+ u8 sqcsrc;
+ u8 autopm;
+ u8 dispbar;
+ u8 unk037a;
+ u8 bkltcont;
+ u8 dsprev;
+ u8 vsmode;
+ u8 intband;
+ u8 wxscntm;
+ u8 scntot;
+ u8 scncot;
+ u8 unk0382;
+ u8 unk0383;
+ u8 unk0384;
+ u8 unk0385;
+ u8 unk0386;
+ u8 unk0387;
+ u8 unk0388;
+ u8 unk0389;
+ u8 unk038a;
+ u8 unk038b;
+ u8 unk038c;
+ u8 unk038d;
+ u8 unk038e;
+ u8 unk038f;
+ u8 abnd118;
+ u8 abnd144;
+ u8 abnd220;
+ u8 abnd300;
+ u8 abnd430;
+ u8 bbnd144;
+ u8 bbnd220;
+ u8 bbnd300;
+ u8 bbnd430;
+ u8 bbnd800;
+ u8 unk039a;
+ u8 unk039b;
+ u8 unk039c;
+ u8 unk039d;
+ u8 unk039e;
+ u8 unk039f;
+ u8 unk03a0[96]; // to 0x03ff
+ }; // end of struct pm
+
+ #seekto 0x0000; // block1: x000 - x023f
+ struct {
+ u8 unk000[16];
+ u8 unk010;
+ u8 unk011;
+ char unk012[3];
+ u8 ansbck;
+ u8 pmrecall; // 0x0016
+ u8 pnlklk;
+ u8 dspmemch;
+ u8 m10mz;
+ u8 micsens;
+ u8 opband;
+ u8 unk01c;
+ u8 rptrmode;
+ u8 rptrhold;
+ u8 rptridx;
+ u8 unk020;
+ u8 pcbaud;
+ u8 unk022;
+ u8 pwdon; // 0x0023
+ u8 unk024;
+ u8 unk025;
+ u8 unk026;
+ u8 unk027;
+ u8 unk028;
+ u8 unk029;
+ char pswd[6]; // 0x023a - 23f
+ } block1;
+
+ #seekto 0x0030;
+ struct {
+ char code[16]; // @ 0x0030
+ } dtmc[10];
+
+ struct {
+ char id[8]; // 0x00d0 - 0x011f
+ } dtmn[10];
+
+ struct { // block1a: 0x0120 - 0x023f
+ u8 unk0120;
+ u8 unk0121;
+ u8 unk0122[78];
+ char rptrid[12]; // 0x0170 - 017b
+ u8 unk017c;
+ u8 unk017d;
+ u8 unk017e;
+ u8 unk017f;
+ u8 unk0180[128]; // 0x0180 - 0x01ff
+ } block1a;
+
+ struct pm_grp pmg[6]; // 0x0200 - 0x0dff
+
+ #seekto 0x0e00;
+ struct {
+ u8 band;
+ u8 skip;
+ } chmap[1030]; // to 0x0160b
+
+ #seekto 0x01700; // 0x01700 - 0x0575f
+ struct chns ch_mem[1030]; // 0-999 MR and 1000 -1029 Specials
+
+ #seekto 0x058a0;
+ struct chns call[2];
+
+ #seekto 0x05900;
+ struct {
+ char name[8];
+ } ch_nam[1020]; // ends @ 0x07840
+
+ #seekto 0x078e0; // 0x078e0 - 0x0792f
+ struct {
+ char name[8];
+ } wxnam[10];
+
+ #seekto 0x07da0;
+ struct {
+ char pmname[16];
+ } pm_name[5];
+
+ #seekto 0x07df0;
+ struct {
+ char comnt[32];
+ } mcpcom;
+ // Block 1 ends @ 0x07eff
+ // Block 2 starts @ 0x07f00
+ #seekto 0x08660;
+ struct {
+ char cmdr[10];
+ char tptr[10];
+ u8 skytone; // 0x08674
+ } skycmd;
+
+ #seekto 0x10ef0;
+ struct {
+ u8 bmp[1896];
+ u8 unk11658[8]; // 0x11658
+ char bmpfyl[64]; // 0x11660
+ u8 unk116a0[95];
+ u8 bmpon; // 0x116ff
+ } bitmap;
+
+ // 2nd block ends @ 0x017cff
+ """
+
+ def _make_command(self, cmd, addr, length, data=b''):
+ cmc = struct.pack('>IB', addr, length)
+ return cmd + cmc[1:] + data
+
+ def _read_mem(radio):
+ """ Load the memory map """
+ global BAUD
+ status = chirp_common.Status()
+ status.cur = 0
+ val = 0
+ for mx in range(0, radio._num_blocks):
+ val += radio._num_packets[mx]
+ status.max = val
+ status.msg = "Reading %i packets" % val
+ radio.status_fn(status)
+
+ data = b""
+
+ radio.pipe.baudrate = BAUD
+ resp0 = radio.pipe.read(16) # flush
+ cmc = b"0M PROGRAM" + TERM
+ resp0 = _command(radio.pipe, cmc, 3, W8S)
+ if resp0[:1] == "?": # try once more
resp0 = _command(radio.pipe, cmc, 3, W8S)
- if resp0[:1] == "?": # try once more
- resp0 = _command(radio.pipe, cmc, 3, W8S)
- radio.pipe.baudrate = 57600 # PROG mode is always 57.6
- LOG.debug("Switching to 57600 baud download.")
- junk = radio.pipe.read(1) # trailing byte
- for blkn in range(0, radio._num_blocks):
- for bkx in range(0, radio._num_packets[blkn]):
- addr = (radio._block_addr[blkn] << 8) | (bkx << 8)
- resp0 = _command(radio.pipe,
- radio._make_command(b'R', addr, 0),
- radio._packet_size[blkn], W8S)
- if len(resp0) < radio._packet_size[blkn]:
- junk = _command(radio.pipe, b"E", 0, W8S)
- lb = len(resp0)
- xb = radio._packet_size[blkn]
- sx = "Block 0x%x, 0x%x read error: " % (blkn, bkx)
- sx += "Got %i bytes, expected %i." % (lb, xb)
- LOG.error(sx)
- sx = "Block read error! Check debug.log"
- raise errors.RadioError(sx)
- if blkn == 0 and bkx == 0: # 1st packet of 1st block
- mht = resp0[5:9] # Magic Header Thingy after cmd echo
- data += mht[0:1]
- data += b'\xff\xff\xff'
- data += resp0[9:]
- else:
- data += resp0[5:] # skip cmd echo
- _update_status(radio, status) # UI Update
- # Exit Prog mode, no TERM
- resp = _command(radio.pipe, b"E", 0, W8S)
- radio.pipe.baudrate = BAUD
- return data
-
- def _write_mem(radio):
- """ PROG MCP Blocks Send """
- global BAUD
- # UI progress
- status = chirp_common.Status()
- status.cur = 0
- val = 0
- for mx in range(0, radio._num_blocks):
- val += radio._num_packets[mx]
- status.max = val
- status.msg = "Writing %i packets" % val
- radio.status_fn(status)
-
- imgadr = 0
- radio.pipe.baudrate = BAUD
- resp0 = _command(radio.pipe, b"0M PROGRAM" + TERM, 3, W8S)
- radio.pipe.baudrate = 57600
- LOG.debug("Switching to 57600 baud upload.")
- junk = radio.pipe.read(1)
- # Read block 0 magic header thingy, save it
- addr = radio._block_addr[0] << 8
- resp0 = _command(radio.pipe,
- radio._make_command(b'R', addr, 4),
- 16, W8S)
- mht0 = resp0[5:]
- # Now get block 1 mht
- addr = radio._block_addr[1] << 8
- resp0 = _command(radio.pipe,
- radio._make_command(b'R', addr, 5),
- 16, W8S)
- mht1 = resp0[5:]
- for blkn in range(0, radio._num_blocks):
- for bkx in range(0, radio._num_packets[blkn]):
- addr = (radio._block_addr[blkn] << 8) | (bkx << 8)
-
- if bkx == 0: # First packet of the block includes mht
- if blkn == 0:
- data = (b'\xff\x4b\x01\x32' +
- radio.get_mmap()[4:imgadr + 256])
- elif blkn == 1:
- data = mht1 + radio.get_mmap()[imgadr + 5:imgadr +
- 256]
- else: # after first packet
- data = radio.get_mmap()[imgadr:imgadr + 256]
- cmc = radio._make_command(b'W', addr, 0, data)
-
- resp0 = _command(radio.pipe, cmc, 6, W8S)
- if bkx > 0 and resp0 != ACK:
- LOG.error("Packet 0x%x Write error, no ACK!" % bkx)
- sx = "Radio failed to acknowledge upload. "
- sx += "See debug.log"
- raise errors.RadioError(sx)
- imgadr += 256
- _update_status(radio, status) # UI Update
- # Re-write magic headers
- cmc = radio._make_command(b'W', (radio._block_addr[0] << 8) | 1, 3,
- mht0[1:3] + b'\x32')
- resp0 = _command(radio.pipe, cmc, 1, W8S)
- cmc = radio._make_command(b'W', radio._block_addr[1] << 8, 5, mht1)
- resp0 = _command(radio.pipe, cmc, 1, W8S)
- cmc = radio._make_command(b'Z', radio._block_addr[0], 1, mht0[0:1])
- resp0 = _command(radio.pipe, cmc, 16, W8S)
- # Write E to Exit PROG mode
- resp = _command(radio.pipe, b"E", 0, W8S)
- radio.pipe.baudrate = BAUD
- return
+ radio.pipe.baudrate = 57600 # PROG mode is always 57.6
+ LOG.debug("Switching to 57600 baud download.")
+ junk = radio.pipe.read(1) # trailing byte
+ for blkn in range(0, radio._num_blocks):
+ for bkx in range(0, radio._num_packets[blkn]):
+ addr = (radio._block_addr[blkn] << 8) | (bkx << 8)
+ resp0 = _command(radio.pipe,
+ radio._make_command(b'R', addr, 0),
+ radio._packet_size[blkn], W8S)
+ if len(resp0) < radio._packet_size[blkn]:
+ junk = _command(radio.pipe, b"E", 0, W8S)
+ lb = len(resp0)
+ xb = radio._packet_size[blkn]
+ sx = "Block 0x%x, 0x%x read error: " % (blkn, bkx)
+ sx += "Got %i bytes, expected %i." % (lb, xb)
+ LOG.error(sx)
+ sx = "Block read error! Check debug.log"
+ raise errors.RadioError(sx)
+ if blkn == 0 and bkx == 0: # 1st packet of 1st block
+ mht = resp0[5:9] # Magic Header Thingy after cmd echo
+ data += mht[0:1]
+ data += b'\xff\xff\xff'
+ data += resp0[9:]
+ else:
+ data += resp0[5:] # skip cmd echo
+ _update_status(radio, status) # UI Update
+ # Exit Prog mode, no TERM
+ resp = _command(radio.pipe, b"E", 0, W8S)
+ radio.pipe.baudrate = BAUD
+ return data
+
+ def _write_mem(radio):
+ """ PROG MCP Blocks Send """
+ global BAUD
+ # UI progress
+ status = chirp_common.Status()
+ status.cur = 0
+ val = 0
+ for mx in range(0, radio._num_blocks):
+ val += radio._num_packets[mx]
+ status.max = val
+ status.msg = "Writing %i packets" % val
+ radio.status_fn(status)
+
+ imgadr = 0
+ radio.pipe.baudrate = BAUD
+ resp0 = _command(radio.pipe, b"0M PROGRAM" + TERM, 3, W8S)
+ radio.pipe.baudrate = 57600
+ LOG.debug("Switching to 57600 baud upload.")
+ junk = radio.pipe.read(1)
+ # Read block 0 magic header thingy, save it
+ addr = radio._block_addr[0] << 8
+ resp0 = _command(radio.pipe,
+ radio._make_command(b'R', addr, 4),
+ 16, W8S)
+ mht0 = resp0[5:]
+ # Now get block 1 mht
+ addr = radio._block_addr[1] << 8
+ resp0 = _command(radio.pipe,
+ radio._make_command(b'R', addr, 5),
+ 16, W8S)
+ mht1 = resp0[5:]
+ for blkn in range(0, radio._num_blocks):
+ for bkx in range(0, radio._num_packets[blkn]):
+ addr = (radio._block_addr[blkn] << 8) | (bkx << 8)
+
+ if bkx == 0: # First packet of the block includes mht
+ if blkn == 0:
+ data = (b'\xff\x4b\x01\x32' +
+ radio.get_mmap()[4:imgadr + 256])
+ elif blkn == 1:
+ data = mht1 + radio.get_mmap()[imgadr + 5:imgadr +
+ 256]
+ else: # after first packet
+ data = radio.get_mmap()[imgadr:imgadr + 256]
+ cmc = radio._make_command(b'W', addr, 0, data)
+
+ resp0 = _command(radio.pipe, cmc, 6, W8S)
+ if bkx > 0 and resp0 != ACK:
+ LOG.error("Packet 0x%x Write error, no ACK!" % bkx)
+ sx = "Radio failed to acknowledge upload. "
+ sx += "See debug.log"
+ raise errors.RadioError(sx)
+ imgadr += 256
+ _update_status(radio, status) # UI Update
+ # Re-write magic headers
+ cmc = radio._make_command(b'W', (radio._block_addr[0] << 8) | 1, 3,
+ mht0[1:3] + b'\x32')
+ resp0 = _command(radio.pipe, cmc, 1, W8S)
+ cmc = radio._make_command(b'W', radio._block_addr[1] << 8, 5, mht1)
+ resp0 = _command(radio.pipe, cmc, 1, W8S)
+ cmc = radio._make_command(b'Z', radio._block_addr[0], 1, mht0[0:1])
+ resp0 = _command(radio.pipe, cmc, 16, W8S)
+ # Write E to Exit PROG mode
+ resp = _command(radio.pipe, b"E", 0, W8S)
+ radio.pipe.baudrate = BAUD
+ return
diff --git a/chirp/drivers/uv5r.py b/chirp/drivers/uv5r.py
index a64b5fa..993ccb4 100644
--- a/chirp/drivers/uv5r.py
+++ b/chirp/drivers/uv5r.py
@@ -19,6 +19,7 @@ import struct
import time
import logging
+from chirp.drivers import baofeng_common as bfc
from chirp import chirp_common, errors, util, directory, memmap
from chirp import bitwise
from chirp.settings import RadioSetting, RadioSettingGroup, \
@@ -128,13 +129,13 @@ struct {
// calls it tdrch. Since this is a minor difference, it will
// be referred to by the wrong name for the UV-82HP.
u8 displayab:1,
- unknown1:2,
+ unknown7:2,
fmradio:1,
alarm:1,
- unknown2:1,
+ unknown8:1,
reset:1,
menu:1;
- u8 unknown1:6,
+ u8 unknown9:6,
singleptt:1,
vfomrlock:1;
u8 workmode;
@@ -655,19 +656,19 @@ def _do_upload(radio):
if aux_i1 != aux_r1:
# Area 1 does not match
# The safest thing to do is to skip uploading Aux mem area.
- LOG.info("Aux memory mis-match")
+ LOG.info("Aux memory mismatch")
LOG.info("Aux area 1 from image is %s" % repr(aux_i1))
LOG.info("Aux area 1 from radio is %s" % repr(aux_r1))
elif aux_i2 != aux_r2:
# Area 2 does not match
# The safest thing to do is to skip uploading Aux mem area.
- LOG.info("Aux memory mis-match")
+ LOG.info("Aux memory mismatch")
LOG.info("Aux area 2 from image is %s" % repr(aux_i2))
LOG.info("Aux area 2 from radio is %s" % repr(aux_r2))
elif aux_i3 != aux_r3:
# Area 3 does not match
# The safest thing to do is to skip uploading Aux mem area.
- LOG.info("Aux memory mis-match")
+ LOG.info("Aux memory mismatch")
LOG.info("Aux area 3 from image is %s" % repr(aux_i3))
LOG.info("Aux area 3 from radio is %s" % repr(aux_r3))
else:
@@ -1409,48 +1410,10 @@ class BaofengUV5R(chirp_common.CloneModeRadio):
if self.MODEL != "UV-6":
other = RadioSettingGroup("other", "Other Settings")
group.append(other)
-
- def _filter(name):
- filtered = ""
- for char in str(name):
- if char in chirp_common.CHARSET_ASCII:
- filtered += char
- else:
- filtered += " "
- return filtered
-
- _msg = self._memobj.firmware_msg
- val = RadioSettingValueString(0, 7, _filter(_msg.line1))
- val.set_mutable(False)
- rs = RadioSetting("firmware_msg.line1", "Firmware Message 1", val)
- other.append(rs)
-
- val = RadioSettingValueString(0, 7, _filter(_msg.line2))
- val.set_mutable(False)
- rs = RadioSetting("firmware_msg.line2", "Firmware Message 2", val)
- other.append(rs)
-
- _msg = self._memobj.sixpoweron_msg
- val = RadioSettingValueString(0, 7, _filter(_msg.line1))
- val.set_mutable(False)
- rs = RadioSetting("sixpoweron_msg.line1",
- "6+Power-On Message 1", val)
- other.append(rs)
- val = RadioSettingValueString(0, 7, _filter(_msg.line2))
- val.set_mutable(False)
- rs = RadioSetting("sixpoweron_msg.line2",
- "6+Power-On Message 2", val)
- other.append(rs)
-
- _msg = self._memobj.poweron_msg
- rs = RadioSetting("poweron_msg.line1", "Power-On Message 1",
- RadioSettingValueString(
- 0, 7, _filter(_msg.line1)))
- other.append(rs)
- rs = RadioSetting("poweron_msg.line2", "Power-On Message 2",
- RadioSettingValueString(
- 0, 7, _filter(_msg.line2)))
- other.append(rs)
+ try:
+ self._get_aux_other_settings(other)
+ except Exception as e:
+ LOG.exception('Failed to get aux-block other settings: %s', e)
rs = RadioSetting("ponmsg", "Power-On Message",
RadioSettingValueList(
@@ -1458,43 +1421,6 @@ class BaofengUV5R(chirp_common.CloneModeRadio):
PONMSG_LIST[_settings.ponmsg]))
other.append(rs)
- if self._is_orig():
- limit = "limits_old"
- else:
- limit = "limits_new"
-
- vhf_limit = getattr(self._memobj, limit).vhf
- rs = RadioSetting("%s.vhf.lower" % limit,
- "VHF Lower Limit (MHz)",
- RadioSettingValueInteger(1, 1000,
- vhf_limit.lower))
- other.append(rs)
-
- rs = RadioSetting("%s.vhf.upper" % limit,
- "VHF Upper Limit (MHz)",
- RadioSettingValueInteger(1, 1000,
- vhf_limit.upper))
- other.append(rs)
-
- rs = RadioSetting("%s.vhf.enable" % limit, "VHF TX Enabled",
- RadioSettingValueBoolean(vhf_limit.enable))
- other.append(rs)
-
- uhf_limit = getattr(self._memobj, limit).uhf
- rs = RadioSetting("%s.uhf.lower" % limit,
- "UHF Lower Limit (MHz)",
- RadioSettingValueInteger(1, 1000,
- uhf_limit.lower))
- other.append(rs)
- rs = RadioSetting("%s.uhf.upper" % limit,
- "UHF Upper Limit (MHz)",
- RadioSettingValueInteger(1, 1000,
- uhf_limit.upper))
- other.append(rs)
- rs = RadioSetting("%s.uhf.enable" % limit, "UHF TX Enabled",
- RadioSettingValueBoolean(uhf_limit.enable))
- other.append(rs)
-
if self.MODEL != "UV-6":
workmode = RadioSettingGroup("workmode", "Work Mode Settings")
group.append(workmode)
@@ -1524,12 +1450,6 @@ class BaofengUV5R(chirp_common.CloneModeRadio):
_wmchannel.mrchb))
workmode.append(rs)
- def convert_bytes_to_freq(bytes):
- real_freq = 0
- for byte in bytes:
- real_freq = (real_freq * 10) + byte
- return chirp_common.format_freq(real_freq * 10)
-
def my_validate(value):
value = chirp_common.parse_freq(value)
if 17400000 <= value and value < 40000000:
@@ -1545,14 +1465,14 @@ class BaofengUV5R(chirp_common.CloneModeRadio):
value /= 10
val1a = RadioSettingValueString(0, 10,
- convert_bytes_to_freq(_vfoa.freq))
+ bfc.bcd_decode_freq(_vfoa.freq))
val1a.set_validate_callback(my_validate)
rs = RadioSetting("vfoa.freq", "VFO A Frequency", val1a)
rs.set_apply_callback(apply_freq, _vfoa)
workmode.append(rs)
val1b = RadioSettingValueString(0, 10,
- convert_bytes_to_freq(_vfob.freq))
+ bfc.bcd_decode_freq(_vfob.freq))
val1b.set_validate_callback(my_validate)
rs = RadioSetting("vfob.freq", "VFO B Frequency", val1b)
rs.set_apply_callback(apply_freq, _vfob)
@@ -1774,9 +1694,98 @@ class BaofengUV5R(chirp_common.CloneModeRadio):
RadioSettingValueInteger(0, 50, _settings.pttlt))
dtmf.append(rs)
+ try:
+ service = self._get_service_settings()
+ if service:
+ group.append(service)
+ except Exception as e:
+ LOG.exception('Failed to load service settings: %s', e)
+
+ return group
+
+ def _get_aux_other_settings(self, other):
+ def _filter(name):
+ filtered = ""
+ for char in str(name):
+ if char in chirp_common.CHARSET_ASCII:
+ filtered += char
+ else:
+ filtered += " "
+ return filtered
+
+ _msg = self._memobj.firmware_msg
+ val = RadioSettingValueString(0, 7, _filter(_msg.line1))
+ val.set_mutable(False)
+ rs = RadioSetting("firmware_msg.line1", "Firmware Message 1", val)
+ other.append(rs)
+
+ val = RadioSettingValueString(0, 7, _filter(_msg.line2))
+ val.set_mutable(False)
+ rs = RadioSetting("firmware_msg.line2", "Firmware Message 2", val)
+ other.append(rs)
+
+ _msg = self._memobj.sixpoweron_msg
+ val = RadioSettingValueString(0, 7, _filter(_msg.line1))
+ val.set_mutable(False)
+ rs = RadioSetting("sixpoweron_msg.line1",
+ "6+Power-On Message 1", val)
+ other.append(rs)
+ val = RadioSettingValueString(0, 7, _filter(_msg.line2))
+ val.set_mutable(False)
+ rs = RadioSetting("sixpoweron_msg.line2",
+ "6+Power-On Message 2", val)
+ other.append(rs)
+
+ _msg = self._memobj.poweron_msg
+ rs = RadioSetting("poweron_msg.line1", "Power-On Message 1",
+ RadioSettingValueString(
+ 0, 7, _filter(_msg.line1)))
+ other.append(rs)
+ rs = RadioSetting("poweron_msg.line2", "Power-On Message 2",
+ RadioSettingValueString(
+ 0, 7, _filter(_msg.line2)))
+ other.append(rs)
+
+ if self._is_orig():
+ limit = "limits_old"
+ else:
+ limit = "limits_new"
+
+ vhf_limit = getattr(self._memobj, limit).vhf
+ rs = RadioSetting("%s.vhf.lower" % limit,
+ "VHF Lower Limit (MHz)",
+ RadioSettingValueInteger(1, 1000,
+ vhf_limit.lower))
+ other.append(rs)
+
+ rs = RadioSetting("%s.vhf.upper" % limit,
+ "VHF Upper Limit (MHz)",
+ RadioSettingValueInteger(1, 1000,
+ vhf_limit.upper))
+ other.append(rs)
+
+ rs = RadioSetting("%s.vhf.enable" % limit, "VHF TX Enabled",
+ RadioSettingValueBoolean(vhf_limit.enable))
+ other.append(rs)
+
+ uhf_limit = getattr(self._memobj, limit).uhf
+ rs = RadioSetting("%s.uhf.lower" % limit,
+ "UHF Lower Limit (MHz)",
+ RadioSettingValueInteger(1, 1000,
+ uhf_limit.lower))
+ other.append(rs)
+ rs = RadioSetting("%s.uhf.upper" % limit,
+ "UHF Upper Limit (MHz)",
+ RadioSettingValueInteger(1, 1000,
+ uhf_limit.upper))
+ other.append(rs)
+ rs = RadioSetting("%s.uhf.enable" % limit, "UHF TX Enabled",
+ RadioSettingValueBoolean(uhf_limit.enable))
+ other.append(rs)
+
+ def _get_service_settings(self):
if not self._is_orig() and self._aux_block:
service = RadioSettingGroup("service", "Service Settings")
- group.append(service)
for band in ["vhf", "uhf"]:
for index in range(0, 10):
@@ -1791,8 +1800,7 @@ class BaofengUV5R(chirp_common.CloneModeRadio):
0, 123,
getattr(_obj, "sql%i" % (index))))
service.append(rs)
-
- return group
+ return service
def get_settings(self):
try:
diff --git a/chirp/drivers/uv5x3.py b/chirp/drivers/uv5x3.py
index 3f633e9..ea8d69a 100644
--- a/chirp/drivers/uv5x3.py
+++ b/chirp/drivers/uv5x3.py
@@ -16,7 +16,7 @@
import logging
-from chirp.drivers import baofeng_common
+from chirp.drivers import baofeng_common as bfc
from chirp import chirp_common, directory
from chirp import bitwise
from chirp.settings import RadioSettingGroup, RadioSetting, \
@@ -94,7 +94,7 @@ def model_match(cls, data):
@directory.register
-class UV5X3(baofeng_common.BaofengCommonHT):
+class UV5X3(bfc.BaofengCommonHT):
"""BTech UV-5X3"""
VENDOR = "BTECH"
MODEL = "UV-5X3"
@@ -780,15 +780,6 @@ class UV5X3(baofeng_common.BaofengCommonHT):
_mem.wmchannel.mrchb))
work.append(rs)
- def convert_bytes_to_freq(bytes):
- real_freq = 0
- for byte in bytes:
- if byte > 9:
- real_freq = 0
- continue
- real_freq = (real_freq * 10) + byte
- return chirp_common.format_freq(real_freq * 10)
-
def my_validate(value):
_vhf_lower = int(_mem.limits.vhf.lower)
_vhf_upper = int(_mem.limits.vhf.upper)
@@ -849,20 +840,22 @@ class UV5X3(baofeng_common.BaofengCommonHT):
value /= 10
val1a = RadioSettingValueString(0, 10,
- convert_bytes_to_freq(_mem.vfo.a.freq))
+ bfc.bcd_decode_freq(
+ _mem.vfo.a.freq))
val1a.set_validate_callback(my_validate)
rs = RadioSetting("vfo.a.freq", "VFO A Frequency", val1a)
rs.set_apply_callback(apply_freq, _mem.vfo.a)
work.append(rs)
val1b = RadioSettingValueString(0, 10,
- convert_bytes_to_freq(_mem.vfo.b.freq))
+ bfc.bcd_decode_freq(
+ _mem.vfo.b.freq))
val1b.set_validate_callback(my_validate)
rs = RadioSetting("vfo.b.freq", "VFO B Frequency", val1b)
rs.set_apply_callback(apply_freq, _mem.vfo.b)
work.append(rs)
- val = convert_bytes_to_freq(_mem.subvfoa.vhf.freq)
+ val = bfc.bcd_decode_freq(_mem.subvfoa.vhf.freq)
if int(float(val)) == 0:
val = str(int(_mem.limits.vhf.lower)) + ".000000"
val1a = RadioSettingValueString(0, 10, val)
@@ -871,7 +864,7 @@ class UV5X3(baofeng_common.BaofengCommonHT):
rs.set_apply_callback(apply_freq, _mem.subvfoa.vhf)
work.append(rs)
- val = convert_bytes_to_freq(_mem.subvfob.vhf.freq)
+ val = bfc.bcd_decode_freq(_mem.subvfob.vhf.freq)
if int(float(val)) == 0:
val = str(int(_mem.limits.vhf.lower)) + ".000000"
val1b = RadioSettingValueString(0, 10, val)
@@ -880,7 +873,7 @@ class UV5X3(baofeng_common.BaofengCommonHT):
rs.set_apply_callback(apply_freq, _mem.subvfob.vhf)
work.append(rs)
- val = convert_bytes_to_freq(_mem.subvfoa.vhf2.freq)
+ val = bfc.bcd_decode_freq(_mem.subvfoa.vhf2.freq)
if int(float(val)) == 0:
val = str(int(_mem.limits.vhf2.lower)) + ".000000"
val1a = RadioSettingValueString(0, 10, val)
@@ -889,7 +882,7 @@ class UV5X3(baofeng_common.BaofengCommonHT):
rs.set_apply_callback(apply_freq, _mem.subvfoa.vhf2)
work.append(rs)
- val = convert_bytes_to_freq(_mem.subvfob.vhf2.freq)
+ val = bfc.bcd_decode_freq(_mem.subvfob.vhf2.freq)
if int(float(val)) == 0:
val = str(int(_mem.limits.vhf2.lower)) + ".000000"
val1b = RadioSettingValueString(0, 10, val)
@@ -898,7 +891,7 @@ class UV5X3(baofeng_common.BaofengCommonHT):
rs.set_apply_callback(apply_freq, _mem.subvfob.vhf2)
work.append(rs)
- val = convert_bytes_to_freq(_mem.subvfoa.uhf.freq)
+ val = bfc.bcd_decode_freq(_mem.subvfoa.uhf.freq)
if int(float(val)) == 0:
val = str(int(_mem.limits.uhf.lower)) + ".000000"
val1a = RadioSettingValueString(0, 10, val)
@@ -907,7 +900,7 @@ class UV5X3(baofeng_common.BaofengCommonHT):
rs.set_apply_callback(apply_freq, _mem.subvfoa.uhf)
work.append(rs)
- val = convert_bytes_to_freq(_mem.subvfob.uhf.freq)
+ val = bfc.bcd_decode_freq(_mem.subvfob.uhf.freq)
if int(float(val)) == 0:
val = str(int(_mem.limits.uhf.lower)) + ".000000"
val1b = RadioSettingValueString(0, 10, val)
diff --git a/chirp/drivers/uv6r.py b/chirp/drivers/uv6r.py
index 64e27ba..231d29c 100644
--- a/chirp/drivers/uv6r.py
+++ b/chirp/drivers/uv6r.py
@@ -16,7 +16,7 @@
import logging
-from chirp.drivers import baofeng_common
+from chirp.drivers import baofeng_common as bfc
from chirp import chirp_common, directory
from chirp import bitwise
from chirp.settings import RadioSettingGroup, RadioSetting, \
@@ -89,7 +89,7 @@ def model_match(cls, data):
@directory.register
-class UV6R(baofeng_common.BaofengCommonHT):
+class UV6R(bfc.BaofengCommonHT):
"""Baofeng UV-6R"""
VENDOR = "Baofeng"
MODEL = "UV-6R"
@@ -221,9 +221,7 @@ class UV6R(baofeng_common.BaofengCommonHT):
ponmsg:1;
u8 unused26:7,
roger:1;
- u8 unused27:7,
- reset:1;
- u8 unknown08;
+ u8 unknown08[2];
u8 displayab:1,
unknown09:2,
fmradio:1,
@@ -646,12 +644,6 @@ class UV6R(baofeng_common.BaofengCommonHT):
_mem.wmchannel.mrchb))
work.append(rs)
- def convert_bytes_to_freq(bytes):
- real_freq = 0
- for byte in bytes:
- real_freq = (real_freq * 10) + byte
- return chirp_common.format_freq(real_freq * 10)
-
def my_validate(value):
_vhf_lower = int(_mem.limits.vhf.lower)
_vhf_upper = int(_mem.limits.vhf.upper)
@@ -676,14 +668,14 @@ class UV6R(baofeng_common.BaofengCommonHT):
value /= 10
val1a = RadioSettingValueString(0, 10,
- convert_bytes_to_freq(_mem.vfo.a.freq))
+ bfc.bcd_decode_freq(_mem.vfo.a.freq))
val1a.set_validate_callback(my_validate)
rs = RadioSetting("vfo.a.freq", "VFO A Frequency", val1a)
rs.set_apply_callback(apply_freq, _mem.vfo.a)
work.append(rs)
val1b = RadioSettingValueString(0, 10,
- convert_bytes_to_freq(_mem.vfo.b.freq))
+ bfc.bcd_decode_freq(_mem.vfo.b.freq))
val1b.set_validate_callback(my_validate)
rs = RadioSetting("vfo.b.freq", "VFO B Frequency", val1b)
rs.set_apply_callback(apply_freq, _mem.vfo.b)
diff --git a/chirp/drivers/uvk5.py b/chirp/drivers/uvk5.py
index f7a1a38..2ae2041 100644
--- a/chirp/drivers/uvk5.py
+++ b/chirp/drivers/uvk5.py
@@ -53,10 +53,8 @@ struct {
u8 rxcode;
u8 txcode;
- u8 unknown1:2,
- txcodeflag:2,
- unknown2:2,
- rxcodeflag:2;
+ u8 txcodeflag:4,
+ rxcodeflag:4;
//u8 flags1;
u8 flags1_unknown7:1,
@@ -94,8 +92,7 @@ struct {
struct {
u8 is_scanlist1:1,
is_scanlist2:1,
-unknown1:1,
-unknown2:1,
+compander:2,
is_free:1,
band:3;
} channel_attributes[200];
@@ -246,9 +243,6 @@ POWER_HIGH = 0b10
POWER_MEDIUM = 0b01
POWER_LOW = 0b00
-# dtmf_flags
-PTTID_LIST = ["off", "BOT", "EOT", "BOTH"]
-
# power
UVK5_POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=1.50),
chirp_common.PowerLevel("Med", watts=3.00),
@@ -270,9 +264,6 @@ BACKLIGHT_LIST = ["Off", "1s", "2s", "3s", "4s", "5s"]
CROSSBAND_LIST = ["Off", "Band A", "Band B"]
DUALWATCH_LIST = CROSSBAND_LIST
-# steps
-STEPS = [2.5, 5.0, 6.25, 10.0, 12.5, 25.0, 8.33]
-
# ctcss/dcs codes
TMODES = ["", "Tone", "DTCS", "DTCS"]
TONE_NONE = 0
@@ -388,36 +379,38 @@ KEYACTIONS_LIST = ["None", "Flashlight on/off", "Power select",
"Alarm on/off", "FM radio on/off", "Transmit 1750 Hz"]
-# the communication is obfuscated using this fine mechanism
def xorarr(data: bytes):
+ """the communication is obfuscated using this fine mechanism"""
tbl = [22, 108, 20, 230, 46, 145, 13, 64, 33, 53, 213, 64, 19, 3, 233, 128]
- x = b""
- r = 0
+ ret = b""
+ idx = 0
for byte in data:
- x += bytes([byte ^ tbl[r]])
- r = (r+1) % len(tbl)
- return x
+ ret += bytes([byte ^ tbl[idx]])
+ idx = (idx+1) % len(tbl)
+ return ret
-# if this crc was used for communication to AND from the radio, then it
-# would be a measure to increase reliability.
-# but it's only used towards the radio, so it's for further obfuscation
def calculate_crc16_xmodem(data: bytes):
+ """
+ if this crc was used for communication to AND from the radio, then it
+ would be a measure to increase reliability.
+ but it's only used towards the radio, so it's for further obfuscation
+ """
poly = 0x1021
crc = 0x0
for byte in data:
crc = crc ^ (byte << 8)
- for i in range(8):
+ for _ in range(8):
crc = crc << 1
- if (crc & 0x10000):
+ if crc & 0x10000:
crc = (crc ^ poly) & 0xFFFF
return crc & 0xFFFF
def _send_command(serport, data: bytes):
"""Send a command to UV-K5 radio"""
- LOG.debug("Sending command (unobfuscated) len=0x%4.4x:\n%s" %
- (len(data), util.hexprint(data)))
+ LOG.debug("Sending command (unobfuscated) len=0x%4.4x:\n%s",
+ len(data), util.hexprint(data))
crc = calculate_crc16_xmodem(data)
data2 = data + struct.pack("<H", crc)
@@ -426,65 +419,65 @@ def _send_command(serport, data: bytes):
xorarr(data2) + \
struct.pack(">H", 0xdcba)
if DEBUG_SHOW_OBFUSCATED_COMMANDS:
- LOG.debug("Sending command (obfuscated):\n%s" % util.hexprint(command))
+ LOG.debug("Sending command (obfuscated):\n%s", util.hexprint(command))
try:
result = serport.write(command)
- except Exception:
- raise errors.RadioError("Error writing data to radio")
+ except Exception as e:
+ raise errors.RadioError("Error writing data to radio") from e
return result
def _receive_reply(serport):
header = serport.read(4)
if len(header) != 4:
- LOG.warning("Header short read: [%s] len=%i" %
- (util.hexprint(header), len(header)))
+ LOG.warning("Header short read: [%s] len=%i",
+ util.hexprint(header), len(header))
raise errors.RadioError("Header short read")
if header[0] != 0xAB or header[1] != 0xCD or header[3] != 0x00:
- LOG.warning("Bad response header: %s len=%i" %
- (util.hexprint(header), len(header)))
+ LOG.warning("Bad response header: %s len=%i",
+ util.hexprint(header), len(header))
raise errors.RadioError("Bad response header")
cmd = serport.read(int(header[2]))
if len(cmd) != int(header[2]):
- LOG.warning("Body short read: [%s] len=%i" %
- (util.hexprint(cmd), len(cmd)))
+ LOG.warning("Body short read: [%s] len=%i",
+ util.hexprint(cmd), len(cmd))
raise errors.RadioError("Command body short read")
footer = serport.read(4)
if len(footer) != 4:
- LOG.warning("Footer short read: [%s] len=%i" %
- (util.hexprint(footer), len(footer)))
+ LOG.warning("Footer short read: [%s] len=%i",
+ util.hexprint(footer), len(footer))
raise errors.RadioError("Footer short read")
if footer[2] != 0xDC or footer[3] != 0xBA:
- LOG.debug(
- "Reply before bad response footer (obfuscated)"
- "len=0x%4.4x:\n%s" % (len(cmd), util.hexprint(cmd)))
- LOG.warning("Bad response footer: %s len=%i" %
- (util.hexprint(footer), len(footer)))
+ LOG.debug("Reply before bad response footer (obfuscated)"
+ "len=0x%4.4x:\n%s", len(cmd), util.hexprint(cmd))
+ LOG.warning("Bad response footer: %s len=%i",
+ util.hexprint(footer), len(footer))
raise errors.RadioError("Bad response footer")
if DEBUG_SHOW_OBFUSCATED_COMMANDS:
- LOG.debug("Received reply (obfuscated) len=0x%4.4x:\n%s" %
- (len(cmd), util.hexprint(cmd)))
+ LOG.debug("Received reply (obfuscated) len=0x%4.4x:\n%s",
+ len(cmd), util.hexprint(cmd))
cmd2 = xorarr(cmd)
- LOG.debug("Received reply (unobfuscated) len=0x%4.4x:\n%s" %
- (len(cmd2), util.hexprint(cmd2)))
+ LOG.debug("Received reply (unobfuscated) len=0x%4.4x:\n%s",
+ len(cmd2), util.hexprint(cmd2))
return cmd2
def _getstring(data: bytes, begin, maxlen):
tmplen = min(maxlen+1, len(data))
- s = [data[i] for i in range(begin, tmplen)]
- for key, val in enumerate(s):
+ ss = [data[i] for i in range(begin, tmplen)]
+ key = 0
+ for key, val in enumerate(ss):
if val < ord(' ') or val > ord('~'):
- break
- return ''.join(chr(x) for x in s[0:key])
+ return ''.join(chr(x) for x in ss[0:key])
+ return ''
def _sayhello(serport):
@@ -494,46 +487,43 @@ def _sayhello(serport):
while True:
LOG.debug("Sending hello packet")
_send_command(serport, hellopacket)
- o = _receive_reply(serport)
-
- if o[0] == 0x18 and o[1] == 0x05:
- LOG.warning("Radio is in firmware flash mode")
- raise errors.RadioError(
- "This radio is in firmware flash mode (PTT + turn on). "
- "Please do this according to the vendor documentation")
-
- if (o):
+ rep = _receive_reply(serport)
+ if rep:
break
tries -= 1
if tries == 0:
LOG.warning("Failed to initialise radio")
raise errors.RadioError("Failed to initialize radio")
- firmware = _getstring(o, 4, 16)
- LOG.info("Found firmware: %s" % firmware)
+ if rep.startswith(b'\x18\x05'):
+ raise errors.RadioError("Radio is in programming mode, "
+ "restart radio into normal mode")
+ firmware = _getstring(rep, 4, 24)
+
+ LOG.info("Found firmware: %s", firmware)
return firmware
def _readmem(serport, offset, length):
- LOG.debug("Sending readmem offset=0x%4.4x len=0x%4.4x" % (offset, length))
+ LOG.debug("Sending readmem offset=0x%4.4x len=0x%4.4x", offset, length)
readmem = b"\x1b\x05\x08\x00" + \
struct.pack("<HBB", offset, length, 0) + \
b"\x6a\x39\x57\x64"
_send_command(serport, readmem)
- o = _receive_reply(serport)
+ rep = _receive_reply(serport)
if DEBUG_SHOW_MEMORY_ACTIONS:
- LOG.debug("readmem Received data len=0x%4.4x:\n%s" %
- (len(o), util.hexprint(o)))
- return o[8:]
+ LOG.debug("readmem Received data len=0x%4.4x:\n%s",
+ len(rep), util.hexprint(rep))
+ return rep[8:]
def _writemem(serport, data, offset):
- LOG.debug("Sending writemem offset=0x%4.4x len=0x%4.4x" %
- (offset, len(data)))
+ LOG.debug("Sending writemem offset=0x%4.4x len=0x%4.4x",
+ offset, len(data))
if DEBUG_SHOW_MEMORY_ACTIONS:
- LOG.debug("writemem sent data offset=0x%4.4x len=0x%4.4x:\n%s" %
- (offset, len(data), util.hexprint(data)))
+ LOG.debug("writemem sent data offset=0x%4.4x len=0x%4.4x:\n%s",
+ offset, len(data), util.hexprint(data))
dlen = len(data)
writemem = b"\x1d\x05" + \
@@ -541,19 +531,18 @@ def _writemem(serport, data, offset):
b"\x6a\x39\x57\x64"+data
_send_command(serport, writemem)
- o = _receive_reply(serport)
+ rep = _receive_reply(serport)
- LOG.debug("writemem Received data: %s len=%i" % (util.hexprint(o), len(o)))
+ LOG.debug("writemem Received data: %s len=%i",
+ util.hexprint(rep), len(rep))
- if (o[0] == 0x1e
- and
- o[4] == (offset & 0xff)
- and
- o[5] == (offset >> 8) & 0xff):
+ if (rep[0] == 0x1e and
+ rep[4] == (offset & 0xff) and
+ rep[5] == (offset >> 8) & 0xff):
return True
- else:
- LOG.warning("Bad data from writemem")
- raise errors.RadioError("Bad response to writemem")
+
+ LOG.warning("Bad data from writemem")
+ raise errors.RadioError("Bad response to writemem")
def _resetradio(serport):
@@ -562,6 +551,7 @@ def _resetradio(serport):
def do_download(radio):
+ """download eeprom from radio"""
serport = radio.pipe
serport.timeout = 0.5
status = chirp_common.Status()
@@ -572,19 +562,23 @@ def do_download(radio):
eeprom = b""
f = _sayhello(serport)
- if f:
- radio.FIRMWARE_VERSION = f
- else:
+ if not f:
raise errors.RadioError('Unable to determine firmware version')
+ if not radio.k5_approve_firmware(f):
+ raise errors.RadioError(
+ 'Firmware version is not supported by this driver')
+
+ radio.metadata = {'uvk5_firmware': f}
+
addr = 0
while addr < MEM_SIZE:
- o = _readmem(serport, addr, MEM_BLOCK)
+ data = _readmem(serport, addr, MEM_BLOCK)
status.cur = addr
radio.status_fn(status)
- if o and len(o) == MEM_BLOCK:
- eeprom += o
+ if data and len(data) == MEM_BLOCK:
+ eeprom += data
addr += MEM_BLOCK
else:
raise errors.RadioError("Memory download incomplete")
@@ -593,27 +587,40 @@ def do_download(radio):
def do_upload(radio):
+ """upload configuration to radio eeprom"""
serport = radio.pipe
serport.timeout = 0.5
status = chirp_common.Status()
status.cur = 0
- status.max = PROG_SIZE
status.msg = "Uploading to radio"
+
+ if radio._upload_calibration:
+ status.max = MEM_SIZE - radio._cal_start
+ start_addr = radio._cal_start
+ stop_addr = MEM_SIZE
+ else:
+ status.max = PROG_SIZE
+ start_addr = 0
+ stop_addr = PROG_SIZE
+
radio.status_fn(status)
f = _sayhello(serport)
- if f:
- radio.FIRMWARE_VERSION = f
- else:
- return False
+ if not f:
+ raise errors.RadioError('Unable to determine firmware version')
- addr = 0
- while addr < PROG_SIZE:
- o = radio.get_mmap()[addr:addr+MEM_BLOCK]
- _writemem(serport, o, addr)
- status.cur = addr
+ if not radio.k5_approve_firmware(f):
+ raise errors.RadioError(
+ 'Firmware version is not supported by this driver')
+ LOG.info('Uploading image from firmware %r to radio with %r',
+ radio.metadata.get('uvk5_firmware', 'unknown'), f)
+ addr = start_addr
+ while addr < stop_addr:
+ dat = radio.get_mmap()[addr:addr+MEM_BLOCK]
+ _writemem(serport, dat, addr)
+ status.cur = addr - start_addr
radio.status_fn(status)
- if o:
+ if dat:
addr += MEM_BLOCK
else:
raise errors.RadioError("Memory upload incomplete")
@@ -641,15 +648,22 @@ def _find_band(nolimits, hz):
return False
-@directory.register
-class UVK5Radio(chirp_common.CloneModeRadio):
+class UVK5RadioBase(chirp_common.CloneModeRadio):
"""Quansheng UV-K5"""
VENDOR = "Quansheng"
MODEL = "UV-K5"
BAUD_RATE = 38400
NEEDS_COMPAT_SERIAL = False
- FIRMWARE_VERSION = ""
+ _cal_start = 0
_expanded_limits = False
+ _upload_calibration = False
+ _pttid_list = ["off", "BOT", "EOT", "BOTH"]
+ _steps = [1.0, 2.5, 5.0, 6.25, 10.0, 12.5, 25.0, 8.33]
+
+ @classmethod
+ def k5_approve_firmware(cls, firmware):
+ # All subclasses must implement this
+ raise NotImplementedError()
def get_prompts(x=None):
rp = chirp_common.RadioPrompts()
@@ -694,7 +708,7 @@ class UVK5Radio(chirp_common.CloneModeRadio):
# hack so we can input any frequency,
# the 0.1 and 0.01 steps don't work unfortunately
- rf.valid_tuning_steps = [0.01, 0.1, 1.0] + STEPS
+ rf.valid_tuning_steps = list(self._steps)
rf.valid_tmodes = ["", "Tone", "TSQL", "DTCS", "Cross"]
rf.valid_cross_modes = ["Tone->Tone", "Tone->DTCS", "DTCS->Tone",
@@ -725,8 +739,23 @@ class UVK5Radio(chirp_common.CloneModeRadio):
def sync_out(self):
do_upload(self)
+ def _check_firmware_at_load(self):
+ firmware = self.metadata.get('uvk5_firmware')
+ if not firmware:
+ LOG.warning(_('This image is missing firmware information. '
+ 'It may have been generated with an old or '
+ 'modified version of CHIRP. It is advised that '
+ 'you download a fresh image from your radio and '
+ 'use that going forward for the best safety and '
+ 'compatibility.'))
+ elif not self.k5_approve_firmware(self.metadata['uvk5_firmware']):
+ raise errors.RadioError(
+ 'Image firmware is %r but is not supported by '
+ 'this driver' % firmware)
+
# Convert the raw byte array into a memory object structure
def process_mmap(self):
+ self._check_firmware_at_load()
self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
# Return a raw representation of the memory object, which
@@ -734,6 +763,9 @@ class UVK5Radio(chirp_common.CloneModeRadio):
def get_raw_memory(self, number):
return repr(self._memobj.channel[number-1])
+ def _find_band(self, hz):
+ return _find_band(self._expanded_limits, hz)
+
def validate_memory(self, mem):
msgs = super().validate_memory(mem)
@@ -749,13 +781,13 @@ class UVK5Radio(chirp_common.CloneModeRadio):
txfreq = mem.freq
# find band
- band = _find_band(self._expanded_limits, txfreq)
+ band = self._find_band(txfreq)
if band is False:
msg = "Transmit frequency %.4f MHz is not supported by this radio"\
% (txfreq/1000000.0)
msgs.append(chirp_common.ValidationError(msg))
- band = _find_band(self._expanded_limits, mem.freq)
+ band = self._find_band(mem.freq)
if band is False:
msg = "The frequency %.4f MHz is not supported by this radio" \
% (mem.freq/1000000.0)
@@ -789,8 +821,6 @@ class UVK5Radio(chirp_common.CloneModeRadio):
_mem.rxcodeflag = rxmoval
_mem.txcodeflag = txmoval
- _mem.unknown1 = 0
- _mem.unknown2 = 0
_mem.rxcode = rxtoval
_mem.txcode = txtoval
@@ -834,6 +864,79 @@ class UVK5Radio(chirp_common.CloneModeRadio):
chirp_common.split_tone_decode(mem, (tx_tmode, tx_tone, tx_pol),
(rx_tmode, rx_tone, rx_pol))
+ def _get_mem_extra(self, mem, _mem):
+ tmpscn = SCANLIST_LIST[0]
+
+ # We'll also look at the channel attributes if a memory has them
+ if mem.number <= 200:
+ _mem3 = self._memobj.channel_attributes[mem.number - 1]
+ # free memory bit
+ if _mem3.is_free > 0:
+ mem.empty = True
+ # scanlists
+ if _mem3.is_scanlist1 > 0 and _mem3.is_scanlist2 > 0:
+ tmpscn = SCANLIST_LIST[3] # "1+2"
+ elif _mem3.is_scanlist1 > 0:
+ tmpscn = SCANLIST_LIST[1] # "1"
+ elif _mem3.is_scanlist2 > 0:
+ tmpscn = SCANLIST_LIST[2] # "2"
+
+ mem.extra = RadioSettingGroup("Extra", "extra")
+
+ # BCLO
+ is_bclo = 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)
+ rs = RadioSetting("frev", "FreqRev", RadioSettingValueBoolean(is_frev))
+ mem.extra.append(rs)
+
+ # PTTID
+ try:
+ pttid = self._pttid_list[_mem.dtmf_pttid]
+ except IndexError:
+ pttid = 0
+ rs = RadioSetting("pttid", "PTTID", RadioSettingValueList(
+ self._pttid_list, pttid))
+ mem.extra.append(rs)
+
+ # DTMF DECODE
+ is_dtmf = bool(_mem.dtmf_decode > 0)
+ rs = RadioSetting("dtmfdecode", _("DTMF decode"),
+ RadioSettingValueBoolean(is_dtmf))
+ mem.extra.append(rs)
+
+ # Scrambler
+ if _mem.scrambler & 0x0f < len(SCRAMBLER_LIST):
+ enc = _mem.scrambler & 0x0f
+ else:
+ enc = 0
+
+ rs = RadioSetting("scrambler", _("Scrambler"), RadioSettingValueList(
+ SCRAMBLER_LIST, SCRAMBLER_LIST[enc]))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("scanlists", _("Scanlists"), RadioSettingValueList(
+ SCANLIST_LIST, tmpscn))
+ mem.extra.append(rs)
+
+ def _get_mem_mode(self, _mem):
+ if _mem.enable_am > 0:
+ if _mem.bandwidth > 0:
+ return "NAM"
+ else:
+ return "AM"
+ else:
+ if _mem.bandwidth > 0:
+ return "NFM"
+ else:
+ return "FM"
+
+ def _get_specials(self):
+ return dict(SPECIALS)
+
# Extract a high-level memory object from the low-level memory map
# This is called to populate a memory in the UI
def get_memory(self, number2):
@@ -841,7 +944,7 @@ class UVK5Radio(chirp_common.CloneModeRadio):
mem = chirp_common.Memory()
if isinstance(number2, str):
- number = SPECIALS[number2]
+ number = self._get_specials()[number2]
mem.extd_number = number2
else:
number = number2 - 1
@@ -850,65 +953,13 @@ class UVK5Radio(chirp_common.CloneModeRadio):
_mem = self._memobj.channel[number]
- tmpcomment = ""
-
- is_empty = False
# We'll consider any blank (i.e. 0 MHz frequency) to be empty
if (_mem.freq == 0xffffffff) or (_mem.freq == 0):
- is_empty = True
-
- tmpscn = SCANLIST_LIST[0]
-
- # We'll also look at the channel attributes if a memory has them
- if number < 200:
- _mem3 = self._memobj.channel_attributes[number]
- # free memory bit
- if _mem3.is_free > 0:
- is_empty = True
- # scanlists
- if _mem3.is_scanlist1 > 0 and _mem3.is_scanlist2 > 0:
- tmpscn = SCANLIST_LIST[3] # "1+2"
- elif _mem3.is_scanlist1 > 0:
- tmpscn = SCANLIST_LIST[1] # "1"
- elif _mem3.is_scanlist2 > 0:
- tmpscn = SCANLIST_LIST[2] # "2"
-
- if is_empty:
mem.empty = True
- # set some sane defaults:
- mem.power = UVK5_POWER_LEVELS[2]
- mem.extra = RadioSettingGroup("Extra", "extra")
- rs = RadioSetting(
- "bclo", "BCLO",
- RadioSettingValueBoolean(False))
- mem.extra.append(rs)
- rs = RadioSetting(
- "frev", "FreqRev",
- RadioSettingValueBoolean(False))
- mem.extra.append(rs)
- rs = RadioSetting(
- "pttid", "PTTID",
- RadioSettingValueList(PTTID_LIST, PTTID_LIST[0]))
- mem.extra.append(rs)
- rs = RadioSetting(
- "dtmfdecode", _("DTMF decode"),
- RadioSettingValueBoolean(False))
- mem.extra.append(rs)
- rs = RadioSetting(
- "scrambler", _("Scrambler"),
- RadioSettingValueList(SCRAMBLER_LIST, SCRAMBLER_LIST[0]))
- mem.extra.append(rs)
-
- rs = RadioSetting(
- "scanlists", _("Scanlists"),
- RadioSettingValueList(SCANLIST_LIST, SCANLIST_LIST[0]))
- mem.extra.append(rs)
-
- # actually the step and duplex are overwritten by chirp based on
- # bandplan. they are here to document sane defaults for IARU r1
- # mem.tuning_step = 25.0
- # mem.duplex = ""
+ self._get_mem_extra(mem, _mem)
+
+ if mem.empty:
return mem
if number > 199:
@@ -943,23 +994,12 @@ class UVK5Radio(chirp_common.CloneModeRadio):
# tone data
self._get_tone(mem, _mem)
- # mode
- if _mem.enable_am > 0:
- if _mem.bandwidth > 0:
- mem.mode = "NAM"
- else:
- mem.mode = "AM"
- else:
- if _mem.bandwidth > 0:
- mem.mode = "NFM"
- else:
- mem.mode = "FM"
+ mem.mode = self._get_mem_mode(_mem)
# tuning step
- tstep = _mem.step & 0x7
- if tstep < len(STEPS):
- mem.tuning_step = STEPS[tstep]
- else:
+ try:
+ mem.tuning_step = self._steps[_mem.step]
+ except IndexError:
mem.tuning_step = 2.5
# power
@@ -976,49 +1016,6 @@ class UVK5Radio(chirp_common.CloneModeRadio):
else:
mem.empty = False
- mem.extra = RadioSettingGroup("Extra", "extra")
-
- # BCLO
- is_bclo = bool(_mem.bclo > 0)
- rs = RadioSetting("bclo", "BCLO", RadioSettingValueBoolean(is_bclo))
- mem.extra.append(rs)
- tmpcomment += "BCLO:"+(is_bclo and "ON" or "off")+" "
-
- # Frequency reverse - whatever that means, don't see it in the manual
- is_frev = bool(_mem.freq_reverse > 0)
- rs = RadioSetting("frev", "FreqRev", RadioSettingValueBoolean(is_frev))
- mem.extra.append(rs)
- tmpcomment += "FreqReverse:"+(is_frev and "ON" or "off")+" "
-
- # PTTID
- pttid = _mem.dtmf_pttid
- rs = RadioSetting("pttid", "PTTID", RadioSettingValueList(
- PTTID_LIST, PTTID_LIST[pttid]))
- mem.extra.append(rs)
- tmpcomment += "PTTid:"+PTTID_LIST[pttid]+" "
-
- # DTMF DECODE
- is_dtmf = bool(_mem.dtmf_decode > 0)
- rs = RadioSetting("dtmfdecode", _("DTMF decode"),
- RadioSettingValueBoolean(is_dtmf))
- mem.extra.append(rs)
- tmpcomment += "DTMFdecode:"+(is_dtmf and "ON" or "off")+" "
-
- # Scrambler
- if _mem.scrambler & 0x0f < len(SCRAMBLER_LIST):
- enc = _mem.scrambler & 0x0f
- else:
- enc = 0
-
- rs = RadioSetting("scrambler", _("Scrambler"), RadioSettingValueList(
- SCRAMBLER_LIST, SCRAMBLER_LIST[enc]))
- mem.extra.append(rs)
- tmpcomment += "Scrambler:"+SCRAMBLER_LIST[enc]+" "
-
- rs = RadioSetting("scanlists", _("Scanlists"), RadioSettingValueList(
- SCANLIST_LIST, tmpscn))
- mem.extra.append(rs)
-
return mem
def set_settings(self, settings):
@@ -1530,14 +1527,6 @@ class UVK5Radio(chirp_common.CloneModeRadio):
"Revive code (5 chars 0-9 ABCD)", val)
dtmf.append(rs)
- val = RadioSettingValueString(0, 80,
- "All DTMF Contacts are 3 codes "
- "(valid: 0-9 * # ABCD), "
- "or an empty string")
- val.set_mutable(False)
- rs = RadioSetting("dtmf_descr1", "DTMF Contacts", val)
- dtmfc.append(rs)
-
for i in range(1, 17):
varname = "DTMF_"+str(i)
varnumname = "DTMFNUM_"+str(i)
@@ -1555,6 +1544,8 @@ class UVK5Radio(chirp_common.CloneModeRadio):
val.set_charset(DTMF_CHARS)
rs = RadioSetting(varnumname, varinumdescr, val)
dtmfc.append(rs)
+ rs.set_doc("DTMF Contacts are 3 codes (valid: 0-9 * # ABCD), "
+ "or an empty string")
# scanlists
if _mem.scanlist_default == 1:
@@ -1905,11 +1896,7 @@ class UVK5Radio(chirp_common.CloneModeRadio):
# readonly info
# Firmware
- if self.FIRMWARE_VERSION == "":
- firmware = "To get the firmware version please download"
- "the image from the radio first"
- else:
- firmware = self.FIRMWARE_VERSION
+ firmware = self.metadata.get('uvk5_firmware', 'UNKNOWN')
val = RadioSettingValueString(0, 128, firmware)
val.set_mutable(False)
@@ -1930,6 +1917,20 @@ class UVK5Radio(chirp_common.CloneModeRadio):
return top
+ def _set_mem_mode(self, _mem, mode):
+ if mode == "NFM":
+ _mem.bandwidth = 1
+ _mem.enable_am = 0
+ elif mode == "FM":
+ _mem.bandwidth = 0
+ _mem.enable_am = 0
+ elif mode == "NAM":
+ _mem.bandwidth = 1
+ _mem.enable_am = 1
+ elif mode == "AM":
+ _mem.bandwidth = 0
+ _mem.enable_am = 1
+
# Store details about a high-level memory to the memory map
# This is called when a user edits a memory in the UI
def set_memory(self, mem):
@@ -1940,14 +1941,14 @@ class UVK5Radio(chirp_common.CloneModeRadio):
_mem4 = self._memobj
# empty memory
if mem.empty:
- _mem.set_raw("\xFF" * 16)
+ _mem.set_raw(b"\xFF" * 16)
if number < 200:
_mem2 = self._memobj.channelname[number]
- _mem2.set_raw("\xFF" * 16)
+ _mem2.set_raw(b"\xFF" * 16)
_mem4.channel_attributes[number].is_scanlist1 = 0
_mem4.channel_attributes[number].is_scanlist2 = 0
- _mem4.channel_attributes[number].unknown1 = 0
- _mem4.channel_attributes[number].unknown2 = 0
+ # Compander in other models, not supported here
+ _mem4.channel_attributes[number].compander = 0
_mem4.channel_attributes[number].is_free = 1
_mem4.channel_attributes[number].band = 0x7
return mem
@@ -1955,7 +1956,7 @@ class UVK5Radio(chirp_common.CloneModeRadio):
# clean the channel memory, restore some bits if it was used before
if _mem.get_raw(asbytes=False)[0] == "\xff":
# this was an empty memory
- _mem.set_raw("\x00" * 16)
+ _mem.set_raw(b"\x00" * 16)
else:
# this memory wasn't empty, save some bits that we don't know the
# meaning of, or that we don't support yet
@@ -1965,34 +1966,21 @@ class UVK5Radio(chirp_common.CloneModeRadio):
prev_0d = _mem.get_raw()[0x0d] & SAVE_MASK_0D
prev_0e = _mem.get_raw()[0x0e] & SAVE_MASK_0E
prev_0f = _mem.get_raw()[0x0f] & SAVE_MASK_0F
- _mem.set_raw("\x00" * 10 +
- chr(prev_0a) + chr(prev_0b) + chr(prev_0c) +
- chr(prev_0d) + chr(prev_0e) + chr(prev_0f))
+ _mem.set_raw(b"\x00" * 10 +
+ bytes([prev_0a, prev_0b, prev_0c,
+ prev_0d, prev_0e, prev_0f]))
if number < 200:
_mem4.channel_attributes[number].is_scanlist1 = 0
_mem4.channel_attributes[number].is_scanlist2 = 0
- _mem4.channel_attributes[number].unknown1 = 0
- _mem4.channel_attributes[number].unknown2 = 0
+ _mem4.channel_attributes[number].compander = 0
_mem4.channel_attributes[number].is_free = 1
_mem4.channel_attributes[number].band = 0x7
# find band
band = _find_band(self, mem.freq)
- # mode
- if mem.mode == "NFM":
- _mem.bandwidth = 1
- _mem.enable_am = 0
- elif mem.mode == "FM":
- _mem.bandwidth = 0
- _mem.enable_am = 0
- elif mem.mode == "NAM":
- _mem.bandwidth = 1
- _mem.enable_am = 1
- elif mem.mode == "AM":
- _mem.bandwidth = 0
- _mem.enable_am = 1
+ self._set_mem_mode(_mem, mem.mode)
# frequency/offset
_mem.freq = mem.freq/10
@@ -2025,7 +2013,7 @@ class UVK5Radio(chirp_common.CloneModeRadio):
self._set_tone(mem, _mem)
# step
- _mem.step = STEPS.index(mem.tuning_step)
+ _mem.step = self._steps.index(mem.tuning_step)
# tx power
if str(mem.power) == str(UVK5_POWER_LEVELS[2]):
@@ -2043,7 +2031,7 @@ class UVK5Radio(chirp_common.CloneModeRadio):
_mem.bclo = svalue and 1 or 0
if sname == "pttid":
- _mem.dtmf_pttid = PTTID_LIST.index(svalue)
+ _mem.dtmf_pttid = self._pttid_list.index(svalue)
if sname == "frev":
_mem.freq_reverse = svalue and 1 or 0
@@ -2073,6 +2061,23 @@ class UVK5Radio(chirp_common.CloneModeRadio):
@directory.register
+class UVK5Radio(UVK5RadioBase):
+ @classmethod
+ def k5_approve_firmware(cls, firmware):
+ approved_prefixes = ('k5_2.01.', 'app_2.01.', '2.01.',
+ '1o11', '4.00.')
+ return any(firmware.startswith(x) for x in approved_prefixes)
+
+ @classmethod
+ def detect_from_serial(cls, pipe):
+ firmware = _sayhello(pipe)
+ for rclass in [UVK5Radio] + cls.detected_models():
+ if rclass.k5_approve_firmware(firmware):
+ return rclass
+ raise errors.RadioError('Firmware %r not supported' % firmware)
+
+
+@directory.register
class RA79Radio(UVK5Radio):
"""Retevis RA79"""
VENDOR = "Retevis"
diff --git a/chirp/drivers/uvk5_egzumer.py b/chirp/drivers/uvk5_egzumer.py
new file mode 100644
index 0000000..f81b82f
--- /dev/null
+++ b/chirp/drivers/uvk5_egzumer.py
@@ -0,0 +1,1725 @@
+# Quansheng UV-K5 driver (c) 2023 Jacek Lipkowski <sq5bpf@lipkowski.org>
+# Adapted For UV-K5 EGZUMER custom software By EGZUMER, JOC2
+#
+# based on template.py Copyright 2012 Dan Smith <dsmith@danplanet.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 2 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/>.
+
+
+import logging
+
+from chirp import chirp_common, directory, bitwise
+from chirp.drivers import uvk5
+from chirp.settings import RadioSetting, RadioSettingGroup, \
+ RadioSettingValueBoolean, RadioSettingValueList, \
+ RadioSettingValueInteger, RadioSettingValueString, \
+ RadioSettings, InvalidValueError, RadioSettingSubGroup
+
+LOG = logging.getLogger(__name__)
+
+MEM_FORMAT = """
+//#seekto 0x0000;
+struct {
+ ul32 freq;
+ ul32 offset;
+
+// 0x08
+ u8 rxcode;
+ u8 txcode;
+
+// 0x0A
+ u8 txcodeflag:4,
+ rxcodeflag:4;
+
+// 0x0B
+ u8 modulation:4,
+ shift:4;
+
+// 0x0C
+ u8 __UNUSED1:3,
+ bclo:1,
+ txpower:2,
+ bandwidth:1,
+ freq_reverse:1;
+
+ // 0x0D
+ u8 __UNUSED2:4,
+ dtmf_pttid:3,
+ dtmf_decode:1;
+
+ // 0x0E
+ u8 step;
+ u8 scrambler;
+
+} channel[214];
+
+//#seekto 0xd60;
+struct {
+u8 is_scanlist1:1,
+is_scanlist2:1,
+compander:2,
+is_free:1,
+band:3;
+} channel_attributes[207];
+
+#seekto 0xe40;
+ul16 fmfreq[20];
+
+#seekto 0xe70;
+u8 call_channel;
+u8 squelch;
+u8 max_talk_time;
+u8 noaa_autoscan;
+u8 key_lock;
+u8 vox_switch;
+u8 vox_level;
+u8 mic_gain;
+
+
+u8 backlight_min:4,
+backlight_max:4;
+
+u8 channel_display_mode;
+u8 crossband;
+u8 battery_save;
+u8 dual_watch;
+u8 backlight_time;
+u8 ste;
+u8 freq_mode_allowed;
+
+#seekto 0xe80;
+u8 ScreenChannel_A;
+u8 MrChannel_A;
+u8 FreqChannel_A;
+u8 ScreenChannel_B;
+u8 MrChannel_B;
+u8 FreqChannel_B;
+u8 NoaaChannel_A;
+u8 NoaaChannel_B;
+
+#seekto 0xe90;
+
+u8 keyM_longpress_action:7,
+ button_beep:1;
+
+u8 key1_shortpress_action;
+u8 key1_longpress_action;
+u8 key2_shortpress_action;
+u8 key2_longpress_action;
+u8 scan_resume_mode;
+u8 auto_keypad_lock;
+u8 power_on_dispmode;
+ul32 password;
+
+#seekto 0xea0;
+u8 voice;
+u8 s0_level;
+u8 s9_level;
+
+#seekto 0xea8;
+u8 alarm_mode;
+u8 roger_beep;
+u8 rp_ste;
+u8 TX_VFO;
+u8 Battery_type;
+
+#seekto 0xeb0;
+char logo_line1[16];
+char logo_line2[16];
+
+//#seekto 0xed0;
+struct {
+ u8 side_tone;
+ char separate_code;
+ char group_call_code;
+ u8 decode_response;
+ u8 auto_reset_time;
+ u8 preload_time;
+ u8 first_code_persist_time;
+ u8 hash_persist_time;
+ u8 code_persist_time;
+ u8 code_interval_time;
+ u8 permit_remote_kill;
+
+ #seekto 0xee0;
+ char local_code[3];
+ #seek 5;
+ char kill_code[5];
+ #seek 3;
+ char revive_code[5];
+ #seek 3;
+ char up_code[16];
+ char down_code[16];
+} dtmf;
+
+//#seekto 0xf18;
+u8 slDef;
+u8 sl1PriorEnab;
+u8 sl1PriorCh1;
+u8 sl1PriorCh2;
+u8 sl2PriorEnab;
+u8 sl2PriorCh1;
+u8 sl2PriorCh2;
+
+#seekto 0xf40;
+u8 int_flock;
+u8 int_350tx;
+u8 int_KILLED;
+u8 int_200tx;
+u8 int_500tx;
+u8 int_350en;
+u8 int_scren;
+
+
+u8 backlight_on_TX_RX:2,
+ AM_fix:1,
+ mic_bar:1,
+ battery_text:2,
+ live_DTMF_decoder:1,
+ unknown:1;
+
+
+#seekto 0xf50;
+struct {
+char name[16];
+} channelname[200];
+
+#seekto 0x1c00;
+struct {
+char name[8];
+char number[3];
+#seek 5;
+} dtmfcontact[16];
+
+struct {
+ struct {
+ #seekto 0x1E00;
+ u8 openRssiThr[10];
+ #seekto 0x1E10;
+ u8 closeRssiThr[10];
+ #seekto 0x1E20;
+ u8 openNoiseThr[10];
+ #seekto 0x1E30;
+ u8 closeNoiseThr[10];
+ #seekto 0x1E40;
+ u8 closeGlitchThr[10];
+ #seekto 0x1E50;
+ u8 openGlitchThr[10];
+ } sqlBand4_7;
+
+ struct {
+ #seekto 0x1E60;
+ u8 openRssiThr[10];
+ #seekto 0x1E70;
+ u8 closeRssiThr[10];
+ #seekto 0x1E80;
+ u8 openNoiseThr[10];
+ #seekto 0x1E90;
+ u8 closeNoiseThr[10];
+ #seekto 0x1EA0;
+ u8 closeGlitchThr[10];
+ #seekto 0x1EB0;
+ u8 openGlitchThr[10];
+ } sqlBand1_3;
+
+ #seekto 0x1EC0;
+ struct {
+ ul16 level1;
+ ul16 level2;
+ ul16 level4;
+ ul16 level6;
+ } rssiLevelsBands3_7;
+
+ struct {
+ ul16 level1;
+ ul16 level2;
+ ul16 level4;
+ ul16 level6;
+ } rssiLevelsBands1_2;
+
+ struct {
+ struct {
+ u8 lower;
+ u8 center;
+ u8 upper;
+ } low;
+ struct {
+ u8 lower;
+ u8 center;
+ u8 upper;
+ } mid;
+ struct {
+ u8 lower;
+ u8 center;
+ u8 upper;
+ } hi;
+ #seek 7;
+ } txp[7];
+
+ #seekto 0x1F40;
+ ul16 batLvl[6];
+
+ #seekto 0x1F50;
+ ul16 vox1Thr[10];
+
+ #seekto 0x1F68;
+ ul16 vox0Thr[10];
+
+ #seekto 0x1F80;
+ u8 micLevel[5];
+
+ #seekto 0x1F88;
+ il16 xtalFreqLow;
+
+ #seekto 0x1F8E;
+ u8 volumeGain;
+ u8 dacGain;
+} cal;
+
+
+#seekto 0x1FF0;
+struct {
+u8 ENABLE_DTMF_CALLING:1,
+ ENABLE_PWRON_PASSWORD:1,
+ ENABLE_TX1750:1,
+ ENABLE_ALARM:1,
+ ENABLE_VOX:1,
+ ENABLE_VOICE:1,
+ ENABLE_NOAA:1,
+ ENABLE_FMRADIO:1;
+u8 __UNUSED:2,
+ ENABLE_SPECTRUM:1,
+ ENABLE_AM_FIX:1,
+ ENABLE_BLMIN_TMP_OFF:1,
+ ENABLE_RAW_DEMODULATORS:1,
+ ENABLE_WIDE_RX:1,
+ ENABLE_FLASHLIGHT:1;
+} BUILD_OPTIONS;
+
+"""
+
+
+# power
+UVK5_POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=1.50),
+ chirp_common.PowerLevel("Med", watts=3.00),
+ chirp_common.PowerLevel("High", watts=5.00),
+ ]
+
+# scrambler
+SCRAMBLER_LIST = ["Off", "2600Hz", "2700Hz", "2800Hz", "2900Hz", "3000Hz",
+ "3100Hz", "3200Hz", "3300Hz", "3400Hz", "3500Hz"]
+# compander
+COMPANDER_LIST = ["Off", "TX", "RX", "TX/RX"]
+# rx mode
+RXMODE_LIST = ["Main only", "Dual RX, respond", "Crossband",
+ "Dual RX, TX on main"]
+# channel display mode
+CHANNELDISP_LIST = ["Frequency", "Channel Number", "Name", "Name + Frequency"]
+
+# TalkTime
+TALK_TIME_LIST = ["30 sec", "1 min", "2 min", "3 min", "4 min", "5 min",
+ "6 min", "7 min", "8 min", "9 min", "15 min"]
+
+# battery save
+BATSAVE_LIST = ["Off", "1:1", "1:2", "1:3", "1:4"]
+
+# battery type
+BATTYPE_LIST = ["1600 mAh", "2200 mAh"]
+# bat txt
+BAT_TXT_LIST = ["None", "Voltage", "Percentage"]
+# Backlight auto mode
+BACKLIGHT_LIST = ["Off", "5s", "10s", "20s", "1min", "2min", "4min",
+ "Always On"]
+
+# Backlight LVL
+BACKLIGHT_LVL_LIST = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]
+
+# Backlight _TX_RX_LIST
+BACKLIGHT_TX_RX_LIST = ["Off", "TX", "RX", "TX/RX"]
+
+# flock list extended
+FLOCK_LIST = ["Default+ (137-174, 400-470 + Tx200, Tx350, Tx500)",
+ "FCC HAM (144-148, 420-450)",
+ "CE HAM (144-146, 430-440)",
+ "GB HAM (144-148, 430-440)",
+ "137-174, 400-430",
+ "137-174, 400-438",
+ "Disable All",
+ "Unlock All"]
+
+SCANRESUME_LIST = ["Listen 5 seconds and resume",
+ "Listen until carrier disappears",
+ "Stop scanning after receiving a signal"]
+WELCOME_LIST = ["Full screen test", "User message", "Battery voltage", "None"]
+VOICE_LIST = ["Off", "Chinese", "English"]
+
+# ACTIVE CHANNEL
+TX_VFO_LIST = ["A", "B"]
+ALARMMODE_LIST = ["Site", "Tone"]
+ROGER_LIST = ["Off", "Roger beep", "MDC data burst"]
+RTE_LIST = ["Off", "100ms", "200ms", "300ms", "400ms",
+ "500ms", "600ms", "700ms", "800ms", "900ms", "1000ms"]
+VOX_LIST = ["Off", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]
+
+# fm radio supported frequencies
+FMMIN = 76.0
+FMMAX = 108.0
+
+# bands supported by the UV-K5
+BANDS_STANDARD = {
+ 0: [50.0, 76.0],
+ 1: [108.0, 136.9999],
+ 2: [137.0, 173.9999],
+ 3: [174.0, 349.9999],
+ 4: [350.0, 399.9999],
+ 5: [400.0, 469.9999],
+ 6: [470.0, 600.0]
+ }
+
+BANDS_WIDE = {
+ 0: [18.0, 108.0],
+ 1: [108.0, 136.9999],
+ 2: [137.0, 173.9999],
+ 3: [174.0, 349.9999],
+ 4: [350.0, 399.9999],
+ 5: [400.0, 469.9999],
+ 6: [470.0, 1300.0]
+ }
+
+SCANLIST_SELECT_LIST = ["List 1", "List 2", "All channels"]
+
+DTMF_CHARS = "0123456789ABCD*# "
+DTMF_CHARS_ID = "0123456789ABCDabcd"
+DTMF_CHARS_KILL = "0123456789ABCDabcd"
+DTMF_CHARS_UPDOWN = "0123456789ABCDabcd#* "
+DTMF_CODE_CHARS = "ABCD*# "
+DTMF_DECODE_RESPONSE_LIST = ["Do nothing", "Local ringing", "Replay response",
+ "Local ringing + reply response"]
+
+KEYACTIONS_LIST = ["None",
+ "Flashlight",
+ "TX power",
+ "Monitor",
+ "Scan",
+ "VOX",
+ "Alarm",
+ "FM broadcast radio",
+ "1750Hz tone",
+ "Lock keypad",
+ "Switch main VFO",
+ "Switch frequency/memory mode",
+ "Switch demodulation",
+ "Min backlight temporary off",
+ "Spectrum analyzer"
+ ]
+
+MIC_GAIN_LIST = ["+1.1dB", "+4.0dB", "+8.0dB", "+12.0dB", "+15.1dB"]
+
+
+def min_max_def(value, min_val, max_val, default):
+ """returns value if in bounds or default otherwise"""
+ if min_val is not None and value < min_val:
+ return default
+ if max_val is not None and value > max_val:
+ return default
+ return value
+
+
+def list_def(value, lst, default):
+ """return value if is in the list, default otherwise"""
+ if isinstance(default, str):
+ default = lst.index(default)
+ if value < 0 or value >= len(lst):
+ return default
+ return value
+
+
+@directory.register
+@directory.detected_by(uvk5.UVK5Radio)
+class UVK5RadioEgzumer(uvk5.UVK5RadioBase):
+ """Quansheng UV-K5 (egzumer)"""
+ VENDOR = "Quansheng"
+ MODEL = "UV-K5"
+ VARIANT = "egzumer"
+ BAUD_RATE = 38400
+ NEEDS_COMPAT_SERIAL = False
+ FIRMWARE_VERSION = ""
+ _cal_start = 0x1E00 # calibration memory start address
+ _pttid_list = ["Off", "Up code", "Down code", "Up+Down code",
+ "Apollo Quindar"]
+ _steps = [2.5, 5, 6.25, 10, 12.5, 25, 8.33, 0.01, 0.05, 0.1, 0.25, 0.5, 1,
+ 1.25, 9, 15, 20, 30, 50, 100, 125, 200, 250, 500]
+
+ @classmethod
+ def k5_approve_firmware(cls, firmware):
+ return firmware.startswith('EGZUMER ')
+
+ def _get_bands(self):
+ is_wide = self._memobj.BUILD_OPTIONS.ENABLE_WIDE_RX \
+ if self._memobj is not None else True
+ bands = BANDS_WIDE if is_wide else BANDS_STANDARD
+ return bands
+
+ def _find_band(self, hz):
+ mhz = hz/1000000.0
+ bands = self._get_bands()
+ for bnd, rng in bands.items():
+ if rng[0] <= mhz <= rng[1]:
+ return bnd
+ return False
+
+ def _get_vfo_channel_names(self):
+ """generates VFO_CHANNEL_NAMES"""
+ bands = self._get_bands()
+ names = []
+ for bnd, rng in bands.items():
+ name = f"F{bnd + 1}({round(rng[0])}M-{round(rng[1])}M)"
+ names.append(name + "A")
+ names.append(name + "B")
+ return names
+
+ def _get_specials(self):
+ """generates SPECIALS"""
+ specials = {}
+ for idx, name in enumerate(self._get_vfo_channel_names()):
+ specials[name] = 200 + idx
+ return specials
+
+ # Return information about this radio's features, including
+ # how many memories it has, what bands it supports, etc
+ def get_features(self):
+ rf = super().get_features()
+ rf.valid_special_chans = self._get_vfo_channel_names()
+ rf.valid_modes = ["FM", "NFM", "AM", "NAM", "USB"]
+
+ rf.valid_bands = []
+ bands = self._get_bands()
+ for _, rng in bands.items():
+ rf.valid_bands.append(
+ (int(rng[0]*1000000), int(rng[1]*1000000)))
+ return rf
+
+ # Convert the raw byte array into a memory object structure
+ def process_mmap(self):
+ self._check_firmware_at_load()
+ self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
+
+ def _get_mem_mode(self, _mem):
+ temp_modes = self.get_features().valid_modes
+ temp_modul = _mem.modulation * 2 + _mem.bandwidth
+ if temp_modul < len(temp_modes):
+ return temp_modes[temp_modul]
+ elif temp_modul == 5: # USB with narrow setting
+ return temp_modes[4]
+ elif temp_modul >= len(temp_modes):
+ LOG.error('Mode %i unsupported', temp_modul)
+ return "FM"
+
+ def get_memory(self, number):
+ mem = super().get_memory(number)
+ try:
+ number = self._get_specials()[number]
+ except KeyError:
+ number -= 1
+
+ if number < 200:
+ comp = list_def(self._memobj.channel_attributes[number].compander,
+ COMPANDER_LIST, 0)
+ else:
+ comp = 0
+ val = RadioSettingValueList(COMPANDER_LIST, None, comp)
+ rs = RadioSetting("compander", "Compander (Compnd)", val)
+ mem.extra.append(rs)
+ return mem
+
+ def _set_mem_mode(self, _mem, mode):
+ tmp_mode = self.get_features().valid_modes.index(mode)
+ _mem.modulation = tmp_mode / 2
+ _mem.bandwidth = tmp_mode % 2
+ if mode == "USB":
+ _mem.bandwidth = 1 # narrow
+
+ def set_memory(self, mem):
+ super().set_memory(mem)
+ try:
+ number = self._get_specials()[mem.number]
+ except KeyError:
+ number = mem.number - 1
+
+ if number < 200 and 'compander' in mem.extra:
+ self._memobj.channel_attributes[number].compander = (
+ COMPANDER_LIST.index(str(mem.extra['compander'].value)))
+
+ def set_settings(self, settings):
+ _mem = self._memobj
+ for element in settings:
+ if not isinstance(element, RadioSetting):
+ self.set_settings(element)
+ continue
+
+ elname = element.get_name()
+
+ # basic settings
+
+ # VFO_A e80 ScreenChannel_A
+ if elname == "VFO_A_chn":
+ _mem.ScreenChannel_A = element.value
+ if _mem.ScreenChannel_A < 200:
+ _mem.MrChannel_A = _mem.ScreenChannel_A
+ elif _mem.ScreenChannel_A < 207:
+ _mem.FreqChannel_A = _mem.ScreenChannel_A
+ else:
+ _mem.NoaaChannel_A = _mem.ScreenChannel_A
+
+ # VFO_B e83
+ elif elname == "VFO_B_chn":
+ _mem.ScreenChannel_B = element.value
+ if _mem.ScreenChannel_B < 200:
+ _mem.MrChannel_B = _mem.ScreenChannel_B
+ elif _mem.ScreenChannel_B < 207:
+ _mem.FreqChannel_B = _mem.ScreenChannel_B
+ else:
+ _mem.NoaaChannel_B = _mem.ScreenChannel_B
+
+ # TX_VFO channel selected A,B
+ elif elname == "TX_VFO":
+ _mem.TX_VFO = element.value
+
+ # call channel
+ elif elname == "call_channel":
+ _mem.call_channel = element.value
+
+ # squelch
+ elif elname == "squelch":
+ _mem.squelch = element.value
+
+ # TOT
+ elif elname == "tot":
+ _mem.max_talk_time = element.value
+
+ # NOAA autoscan
+ elif elname == "noaa_autoscan":
+ _mem.noaa_autoscan = element.value
+
+ # VOX
+ elif elname == "vox":
+ voxvalue = int(element.value)
+ _mem.vox_switch = voxvalue > 0
+ _mem.vox_level = (voxvalue - 1) if _mem.vox_switch else 0
+
+ # mic gain
+ elif elname == "mic_gain":
+ _mem.mic_gain = element.value
+
+ # Channel display mode
+ elif elname == "channel_display_mode":
+ _mem.channel_display_mode = element.value
+
+ # RX Mode
+ elif elname == "rx_mode":
+ tmptxmode = int(element.value)
+ tmpmainvfo = _mem.TX_VFO + 1
+ _mem.crossband = tmpmainvfo * bool(tmptxmode & 0b10)
+ _mem.dual_watch = tmpmainvfo * bool(tmptxmode & 0b01)
+
+ # Battery Save
+ elif elname == "battery_save":
+ _mem.battery_save = element.value
+
+ # Backlight auto mode
+ elif elname == "backlight_time":
+ _mem.backlight_time = element.value
+
+ # Backlight min
+ elif elname == "backlight_min":
+ _mem.backlight_min = element.value
+
+ # Backlight max
+ elif elname == "backlight_max":
+ _mem.backlight_max = element.value
+
+ # Backlight TX_RX
+ elif elname == "backlight_on_TX_RX":
+ _mem.backlight_on_TX_RX = element.value
+ # AM_fix
+ elif elname == "AM_fix":
+ _mem.AM_fix = element.value
+
+ # mic_bar
+ elif elname == "mem.mic_bar":
+ _mem.mic_bar = element.value
+
+ # Batterie txt
+ elif elname == "_mem.battery_text":
+ _mem.battery_text = element.value
+
+ # Tail tone elimination
+ elif elname == "ste":
+ _mem.ste = element.value
+
+ # VFO Open
+ elif elname == "freq_mode_allowed":
+ _mem.freq_mode_allowed = element.value
+
+ # Beep control
+ elif elname == "button_beep":
+ _mem.button_beep = element.value
+
+ # Scan resume mode
+ elif elname == "scan_resume_mode":
+ _mem.scan_resume_mode = element.value
+
+ # Keypad lock
+ elif elname == "key_lock":
+ _mem.key_lock = element.value
+
+ # Auto keypad lock
+ elif elname == "auto_keypad_lock":
+ _mem.auto_keypad_lock = element.value
+
+ # Power on display mode
+ elif elname == "welcome_mode":
+ _mem.power_on_dispmode = element.value
+
+ # Keypad Tone
+ elif elname == "voice":
+ _mem.voice = element.value
+
+ elif elname == "s0_level":
+ _mem.s0_level = element.value * -1
+
+ elif elname == "s9_level":
+ _mem.s9_level = element.value * -1
+
+ elif elname == "password":
+ if element.value.get_value() is None or element.value == "":
+ _mem.password = 0xFFFFFFFF
+ else:
+ _mem.password = element.value
+
+ # Alarm mode
+ elif elname == "alarm_mode":
+ _mem.alarm_mode = element.value
+
+ # Reminding of end of talk
+ elif elname == "roger_beep":
+ _mem.roger_beep = element.value
+
+ # Repeater tail tone elimination
+ elif elname == "rp_ste":
+ _mem.rp_ste = element.value
+
+ # Logo string 1
+ elif elname == "logo1":
+ bts = str(element.value).rstrip("\x20\xff\x00")+"\x00" * 12
+ _mem.logo_line1 = bts[0:12] + "\x00\xff\xff\xff"
+
+ # Logo string 2
+ elif elname == "logo2":
+ bts = str(element.value).rstrip("\x20\xff\x00")+"\x00" * 12
+ _mem.logo_line2 = bts[0:12] + "\x00\xff\xff\xff"
+
+ # unlock settings
+
+ # FLOCK
+ elif elname == "int_flock":
+ _mem.int_flock = element.value
+
+ # 350TX
+ elif elname == "int_350tx":
+ _mem.int_350tx = element.value
+
+ # KILLED
+ elif elname == "int_KILLED":
+ _mem.int_KILLED = element.value
+
+ # 200TX
+ elif elname == "int_200tx":
+ _mem.int_200tx = element.value
+
+ # 500TX
+ elif elname == "int_500tx":
+ _mem.int_500tx = element.value
+
+ # 350EN
+ elif elname == "int_350en":
+ _mem.int_350en = element.value
+
+ # SCREN
+ elif elname == "int_scren":
+ _mem.int_scren = element.value
+
+ # battery type
+ elif elname == "Battery_type":
+ _mem.Battery_type = element.value
+ # fm radio
+ for i in range(1, 21):
+ freqname = "FM_%i" % i
+ if elname == freqname:
+ val = str(element.value).strip()
+ try:
+ val2 = int(float(val) * 10)
+ except Exception:
+ val2 = 0xffff
+
+ if val2 < FMMIN * 10 or val2 > FMMAX * 10:
+ val2 = 0xffff
+# raise errors.InvalidValueError(
+# "FM radio frequency should be a value "
+# "in the range %.1f - %.1f" % (FMMIN , FMMAX))
+ _mem.fmfreq[i-1] = val2
+
+ # dtmf settings
+ if elname == "dtmf_side_tone":
+ _mem.dtmf.side_tone = element.value
+
+ elif elname == "dtmf_separate_code":
+ _mem.dtmf.separate_code = element.value
+
+ elif elname == "dtmf_group_call_code":
+ _mem.dtmf.group_call_code = element.value
+
+ elif elname == "dtmf_decode_response":
+ _mem.dtmf.decode_response = element.value
+
+ elif elname == "dtmf_auto_reset_time":
+ _mem.dtmf.auto_reset_time = element.value
+
+ elif elname == "dtmf_preload_time":
+ _mem.dtmf.preload_time = element.value // 10
+
+ elif elname == "dtmf_first_code_persist_time":
+ _mem.dtmf.first_code_persist_time = element.value // 10
+
+ elif elname == "dtmf_hash_persist_time":
+ _mem.dtmf.hash_persist_time = element.value // 10
+
+ elif elname == "dtmf_code_persist_time":
+ _mem.dtmf.code_persist_time = element.value // 10
+
+ elif elname == "dtmf_code_interval_time":
+ _mem.dtmf.code_interval_time = element.value // 10
+
+ elif elname == "dtmf_permit_remote_kill":
+ _mem.dtmf.permit_remote_kill = element.value
+
+ elif elname == "dtmf_dtmf_local_code":
+ k = str(element.value).rstrip("\x20\xff\x00") + "\x00" * 3
+ _mem.dtmf.local_code = k[0:3]
+
+ elif elname == "dtmf_dtmf_up_code":
+ k = str(element.value).strip("\x20\xff\x00") + "\x00" * 16
+ _mem.dtmf.up_code = k[0:16]
+
+ elif elname == "dtmf_dtmf_down_code":
+ k = str(element.value).rstrip("\x20\xff\x00") + "\x00" * 16
+ _mem.dtmf.down_code = k[0:16]
+
+ elif elname == "dtmf_kill_code":
+ k = str(element.value).strip("\x20\xff\x00") + "\x00" * 5
+ _mem.dtmf.kill_code = k[0:5]
+
+ elif elname == "dtmf_revive_code":
+ k = str(element.value).strip("\x20\xff\x00") + "\x00" * 5
+ _mem.dtmf.revive_code = k[0:5]
+
+ elif elname == "live_DTMF_decoder":
+ _mem.live_DTMF_decoder = element.value
+
+ # dtmf contacts
+ for i in range(1, 17):
+ varname = "DTMF_%i" % i
+ if elname == varname:
+ k = str(element.value).rstrip("\x20\xff\x00") + "\x00" * 8
+ _mem.dtmfcontact[i-1].name = k[0:8]
+
+ varnumname = "DTMFNUM_%i" % i
+ if elname == varnumname:
+ k = str(element.value).rstrip("\x20\xff\x00") + "\xff" * 3
+ _mem.dtmfcontact[i-1].number = k[0:3]
+
+ # scanlist stuff
+ if elname == "slDef":
+ _mem.slDef = element.value
+
+ elif elname == "sl1PriorEnab":
+ _mem.sl1PriorEnab = element.value
+
+ elif elname == "sl2PriorEnab":
+ _mem.sl2PriorEnab = element.value
+
+ elif elname in ["sl1PriorCh1", "sl1PriorCh2", "sl2PriorCh1",
+ "sl2PriorCh2"]:
+ val = int(element.value)
+ if val > 200 or val < 1:
+ val = 0xff
+ else:
+ val -= 1
+
+ _mem[elname] = val
+
+ if elname == "key1_shortpress_action":
+ _mem.key1_shortpress_action = \
+ KEYACTIONS_LIST.index(element.value)
+
+ elif elname == "key1_longpress_action":
+ _mem.key1_longpress_action = \
+ KEYACTIONS_LIST.index(element.value)
+
+ elif elname == "key2_shortpress_action":
+ _mem.key2_shortpress_action = \
+ KEYACTIONS_LIST.index(element.value)
+
+ elif elname == "key2_longpress_action":
+ _mem.key2_longpress_action = \
+ KEYACTIONS_LIST.index(element.value)
+
+ elif elname == "keyM_longpress_action":
+ _mem.keyM_longpress_action = \
+ KEYACTIONS_LIST.index(element.value)
+
+ elif elname == "upload_calibration":
+ self._upload_calibration = bool(element.value)
+
+ elif element.changed() and elname.startswith("cal."):
+ _mem.get_path(elname).set_value(element.value)
+
+ def get_settings(self):
+ _mem = self._memobj
+ basic = RadioSettingGroup("basic", "Basic Settings")
+ advanced = RadioSettingGroup("advanced", "Advanced Settings")
+ keya = RadioSettingGroup("keya", "Programmable Keys")
+ dtmf = RadioSettingGroup("dtmf", "DTMF Settings")
+ dtmfc = RadioSettingGroup("dtmfc", "DTMF Contacts")
+ scanl = RadioSettingGroup("scn", "Scan Lists")
+ unlock = RadioSettingGroup("unlock", "Unlock Settings")
+ fmradio = RadioSettingGroup("fmradio", "FM Radio")
+ calibration = RadioSettingGroup("calibration", "Calibration")
+
+ roinfo = RadioSettingGroup("roinfo", "Driver Information")
+ top = RadioSettings()
+ top.append(basic)
+ top.append(advanced)
+ top.append(keya)
+ top.append(dtmf)
+ if _mem.BUILD_OPTIONS.ENABLE_DTMF_CALLING:
+ top.append(dtmfc)
+ top.append(scanl)
+ top.append(unlock)
+ if _mem.BUILD_OPTIONS.ENABLE_FMRADIO:
+ top.append(fmradio)
+ top.append(roinfo)
+ top.append(calibration)
+
+ # helper function
+ def append_label(radio_setting, label, descr=""):
+ if not hasattr(append_label, 'idx'):
+ append_label.idx = 0
+
+ val = RadioSettingValueString(len(descr), len(descr), descr)
+ val.set_mutable(False)
+ rs = RadioSetting("label%s" % append_label.idx, label, val)
+ append_label.idx += 1
+ radio_setting.append(rs)
+
+ # Programmable keys
+ def get_action(action_num):
+ """"get actual key action"""
+ lst = KEYACTIONS_LIST.copy()
+ if not self._memobj.BUILD_OPTIONS.ENABLE_ALARM:
+ lst.remove("Alarm")
+ if not self._memobj.BUILD_OPTIONS.ENABLE_TX1750:
+ lst.remove("1750Hz tone")
+ if not self._memobj.BUILD_OPTIONS.ENABLE_FLASHLIGHT:
+ lst.remove("Flashlight")
+ if not self._memobj.BUILD_OPTIONS.ENABLE_VOX:
+ lst.remove("VOX")
+ if not self._memobj.BUILD_OPTIONS.ENABLE_FMRADIO:
+ lst.remove("FM broadcast radio")
+ if not self._memobj.BUILD_OPTIONS.ENABLE_BLMIN_TMP_OFF:
+ lst.remove("Min backlight temporary off")
+ if not self._memobj.BUILD_OPTIONS.ENABLE_SPECTRUM:
+ lst.remove("Spectrum analyzer")
+
+ action_num = int(action_num)
+ if action_num >= len(KEYACTIONS_LIST) or \
+ KEYACTIONS_LIST[action_num] not in lst:
+ action_num = 0
+ return lst, KEYACTIONS_LIST[action_num]
+
+ val = RadioSettingValueList(*get_action(_mem.key1_shortpress_action))
+ rs = RadioSetting("key1_shortpress_action",
+ "Side key 1 short press (F1Shrt)", val)
+ keya.append(rs)
+
+ val = RadioSettingValueList(*get_action(_mem.key1_longpress_action))
+ rs = RadioSetting("key1_longpress_action",
+ "Side key 1 long press (F1Long)", val)
+ keya.append(rs)
+
+ val = RadioSettingValueList(*get_action(_mem.key2_shortpress_action))
+ rs = RadioSetting("key2_shortpress_action",
+ "Side key 2 short press (F2Shrt)", val)
+ keya.append(rs)
+
+ val = RadioSettingValueList(*get_action(_mem.key2_longpress_action))
+ rs = RadioSetting("key2_longpress_action",
+ "Side key 2 long press (F2Long)", val)
+ keya.append(rs)
+
+ val = RadioSettingValueList(*get_action(_mem.keyM_longpress_action))
+ rs = RadioSetting("keyM_longpress_action",
+ "Menu key long press (M Long)", val)
+ keya.append(rs)
+
+ # ----------------- DTMF settings
+
+ tmpval = str(_mem.dtmf.separate_code)
+ if tmpval not in DTMF_CODE_CHARS:
+ tmpval = '*'
+ val = RadioSettingValueString(1, 1, tmpval)
+ val.set_charset(DTMF_CODE_CHARS)
+ sep_code_setting = RadioSetting("dtmf_separate_code",
+ "Separate Code", val)
+
+ tmpval = str(_mem.dtmf.group_call_code)
+ if tmpval not in DTMF_CODE_CHARS:
+ tmpval = '#'
+ val = RadioSettingValueString(1, 1, tmpval)
+ val.set_charset(DTMF_CODE_CHARS)
+ group_code_setting = RadioSetting("dtmf_group_call_code",
+ "Group Call Code", val)
+
+ tmpval = min_max_def(_mem.dtmf.first_code_persist_time * 10,
+ 30, 1000, 300)
+ val = RadioSettingValueInteger(30, 1000, tmpval, 10)
+ first_code_per_setting = \
+ RadioSetting("dtmf_first_code_persist_time",
+ "First code persist time (ms)", val)
+
+ tmpval = min_max_def(_mem.dtmf.hash_persist_time * 10, 30, 1000, 300)
+ val = RadioSettingValueInteger(30, 1000, tmpval, 10)
+ spec_per_setting = RadioSetting("dtmf_hash_persist_time",
+ "#/* persist time (ms)", val)
+
+ tmpval = min_max_def(_mem.dtmf.code_persist_time * 10, 30, 1000, 300)
+ val = RadioSettingValueInteger(30, 1000, tmpval, 10)
+ code_per_setting = RadioSetting("dtmf_code_persist_time",
+ "Code persist time (ms)", val)
+
+ tmpval = min_max_def(_mem.dtmf.code_interval_time * 10, 30, 1000, 300)
+ val = RadioSettingValueInteger(30, 1000, tmpval, 10)
+ code_int_setting = RadioSetting("dtmf_code_interval_time",
+ "Code interval time (ms)", val)
+
+ tmpval = str(_mem.dtmf.local_code).upper().strip(
+ "\x00\xff\x20")
+ for i in tmpval:
+ if i in DTMF_CHARS_ID:
+ continue
+ tmpval = "103"
+ break
+ val = RadioSettingValueString(3, 3, tmpval)
+ val.set_charset(DTMF_CHARS_ID)
+ ani_id_setting = \
+ RadioSetting("dtmf_dtmf_local_code",
+ "Local code (ANI ID)", val)
+ ani_id_setting.set_doc('3 chars 0-9 ABCD')
+
+ tmpval = str(_mem.dtmf.up_code).upper().strip(
+ "\x00\xff\x20")
+ for i in tmpval:
+ if i in DTMF_CHARS_UPDOWN or i == "":
+ continue
+ else:
+ tmpval = "123"
+ break
+ val = RadioSettingValueString(1, 16, tmpval)
+ val.set_charset(DTMF_CHARS_UPDOWN)
+ up_code_setting = \
+ RadioSetting("dtmf_dtmf_up_code",
+ "Up code", val)
+ up_code_setting.set_doc('1-16 chars 0-9 ABCD*#')
+
+ tmpval = str(_mem.dtmf.down_code).upper().strip(
+ "\x00\xff\x20")
+ for i in tmpval:
+ if i in DTMF_CHARS_UPDOWN:
+ continue
+ else:
+ tmpval = "456"
+ break
+ val = RadioSettingValueString(1, 16, tmpval)
+ val.set_charset(DTMF_CHARS_UPDOWN)
+ dw_code_setting = \
+ RadioSetting("dtmf_dtmf_down_code",
+ "Down code", val)
+ dw_code_setting.set_doc('1-16 chars 0-9 ABCD*#')
+
+ val = RadioSettingValueBoolean(_mem.dtmf.side_tone)
+ dtmf_side_tone_setting = \
+ RadioSetting("dtmf_side_tone",
+ "DTMF Sidetone on speaker when sent (D ST)", val)
+
+ tmpval = list_def(_mem.dtmf.decode_response,
+ DTMF_DECODE_RESPONSE_LIST, 0)
+ val = RadioSettingValueList(DTMF_DECODE_RESPONSE_LIST, None, tmpval)
+ dtmf_resp_setting = RadioSetting("dtmf_decode_response",
+ "Decode Response (D Resp)", val)
+
+ tmpval = min_max_def(_mem.dtmf.auto_reset_time, 5, 60, 10)
+ val = RadioSettingValueInteger(5, 60, tmpval)
+ d_hold_setting = RadioSetting("dtmf_auto_reset_time",
+ "Auto reset time (s) (D Hold)", val)
+
+ # D Prel
+ tmpval = min_max_def(_mem.dtmf.preload_time * 10, 30, 990, 300)
+ val = RadioSettingValueInteger(30, 990, tmpval, 10)
+ d_prel_setting = RadioSetting("dtmf_preload_time",
+ "Pre-load time (ms) (D Prel)", val)
+
+ # D LIVE
+ val = RadioSettingValueBoolean(_mem.live_DTMF_decoder)
+ d_live_setting = \
+ RadioSetting("live_DTMF_decoder", "Displays DTMF codes"
+ " received in the middle of the screen (D Live)", val)
+
+ val = RadioSettingValueBoolean(_mem.dtmf.permit_remote_kill)
+ perm_kill_setting = RadioSetting("dtmf_permit_remote_kill",
+ "Permit remote kill", val)
+
+ tmpval = str(_mem.dtmf.kill_code).upper().strip(
+ "\x00\xff\x20")
+ for i in tmpval:
+ if i in DTMF_CHARS_KILL:
+ continue
+ else:
+ tmpval = "77777"
+ break
+ if not len(tmpval) == 5:
+ tmpval = "77777"
+ val = RadioSettingValueString(5, 5, tmpval)
+ val.set_charset(DTMF_CHARS_KILL)
+ kill_code_setting = RadioSetting("dtmf_kill_code",
+ "Kill code", val)
+ kill_code_setting.set_doc('5 chars 0-9 ABCD')
+
+ tmpval = str(_mem.dtmf.revive_code).upper().strip(
+ "\x00\xff\x20")
+ for i in tmpval:
+ if i in DTMF_CHARS_KILL:
+ continue
+ else:
+ tmpval = "88888"
+ break
+ if not len(tmpval) == 5:
+ tmpval = "88888"
+ val = RadioSettingValueString(5, 5, tmpval)
+ val.set_charset(DTMF_CHARS_KILL)
+ rev_code_setting = RadioSetting("dtmf_revive_code",
+ "Revive code", val)
+ rev_code_setting.set_doc('5 chars 0-9 ABCD')
+
+ val = RadioSettingValueBoolean(_mem.int_KILLED)
+ killed_setting = RadioSetting("int_KILLED", "DTMF kill lock", val)
+
+ # ----------------- DTMF Contacts
+
+ for i in range(1, 17):
+ varname = "DTMF_"+str(i)
+ varnumname = "DTMFNUM_"+str(i)
+ vardescr = "DTMF Contact "+str(i)+" name"
+ varinumdescr = "DTMF Contact "+str(i)+" number"
+
+ cntn = str(_mem.dtmfcontact[i-1].name).strip("\x20\x00\xff")
+ cntnum = str(_mem.dtmfcontact[i-1].number).strip("\x20\x00\xff")
+
+ val = RadioSettingValueString(0, 8, cntn)
+ rs = RadioSetting(varname, vardescr, val)
+ dtmfc.append(rs)
+
+ val = RadioSettingValueString(0, 3, cntnum)
+ val.set_charset(DTMF_CHARS)
+ rs = RadioSetting(varnumname, varinumdescr, val)
+ rs.set_doc("DTMF Contacts are 3 codes (valid: 0-9 * # ABCD), "
+ "or an empty string")
+ dtmfc.append(rs)
+
+ # ----------------- Scan Lists
+
+ tmpscanl = list_def(_mem.slDef, SCANLIST_SELECT_LIST, 0)
+ val = RadioSettingValueList(SCANLIST_SELECT_LIST, None, tmpscanl)
+ rs = RadioSetting("slDef", "Default scanlist (SList)", val)
+ scanl.append(rs)
+
+ val = RadioSettingValueBoolean(_mem.sl1PriorEnab)
+ rs = RadioSetting("sl1PriorEnab", "List 1 priority channel scan", val)
+ scanl.append(rs)
+
+ ch_list = ["None"]
+ for ch in range(1, 201):
+ ch_list.append("Channel M%i" % ch)
+
+ tmpch = list_def(_mem.sl1PriorCh1 + 1, ch_list, 0)
+ val = RadioSettingValueList(ch_list, None, tmpch)
+ rs = RadioSetting("sl1PriorCh1", "List 1 priority channel 1", val)
+ scanl.append(rs)
+
+ tmpch = list_def(_mem.sl1PriorCh2 + 1, ch_list, 0)
+ val = RadioSettingValueList(ch_list, None, tmpch)
+ rs = RadioSetting("sl1PriorCh2", "List 1 priority channel 2", val)
+ scanl.append(rs)
+
+ val = RadioSettingValueBoolean(_mem.sl2PriorEnab)
+ rs = RadioSetting("sl2PriorEnab", "List 2 priority channel scan", val)
+ scanl.append(rs)
+
+ tmpch = list_def(_mem.sl2PriorCh1 + 1, ch_list, 0)
+ val = RadioSettingValueList(ch_list, None, tmpch)
+ rs = RadioSetting("sl2PriorCh1", "List 2 priority channel 1", val)
+ scanl.append(rs)
+
+ tmpch = list_def(_mem.sl2PriorCh2 + 1, ch_list, 0)
+ val = RadioSettingValueList(ch_list, None, tmpch)
+ rs = RadioSetting("sl2PriorCh2", "List 2 priority channel 2", val)
+ scanl.append(rs)
+
+ # ----------------- Basic settings
+
+ ch_list = []
+ for ch in range(1, 201):
+ ch_list.append("Channel M%i" % ch)
+ for bnd in range(1, 8):
+ ch_list.append("Band F%i" % bnd)
+ if _mem.BUILD_OPTIONS.ENABLE_NOAA:
+ for bnd in range(1, 11):
+ ch_list.append("NOAA N%i" % bnd)
+
+ tmpfreq0 = list_def(_mem.ScreenChannel_A, ch_list, 0)
+ val = RadioSettingValueList(ch_list, None, tmpfreq0)
+ freq0_setting = RadioSetting("VFO_A_chn",
+ "VFO A current channel/band", val)
+
+ tmpfreq1 = list_def(_mem.ScreenChannel_B, ch_list, 0)
+ val = RadioSettingValueList(ch_list, None, tmpfreq1)
+ freq1_setting = RadioSetting("VFO_B_chn",
+ "VFO B current channel/band", val)
+
+ tmptxvfo = list_def(_mem.TX_VFO, TX_VFO_LIST, 0)
+ val = RadioSettingValueList(TX_VFO_LIST, None, tmptxvfo)
+ tx_vfo_setting = RadioSetting("TX_VFO", "Main VFO", val)
+
+ tmpsq = min_max_def(_mem.squelch, 0, 9, 1)
+ val = RadioSettingValueInteger(0, 9, tmpsq)
+ squelch_setting = RadioSetting("squelch", "Squelch (Sql)", val)
+
+ ch_list = []
+ for ch in range(1, 201):
+ ch_list.append("Channel M%i" % ch)
+
+ tmpc = list_def(_mem.call_channel, ch_list, 0)
+ val = RadioSettingValueList(ch_list, None, tmpc)
+ call_channel_setting = RadioSetting("call_channel",
+ "One key call channel (1 Call)",
+ val)
+
+ val = RadioSettingValueBoolean(_mem.key_lock)
+ keypad_cock_setting = RadioSetting("key_lock", "Keypad locked", val)
+
+ val = RadioSettingValueBoolean(_mem.auto_keypad_lock)
+ auto_keypad_lock_setting = \
+ RadioSetting("auto_keypad_lock",
+ "Auto keypad lock (KeyLck)", val)
+
+ tmptot = list_def(_mem.max_talk_time, TALK_TIME_LIST, 1)
+ val = RadioSettingValueList(TALK_TIME_LIST, None, tmptot)
+ tx_t_out_setting = RadioSetting("tot",
+ "Max talk, TX Time Out (TxTOut)", val)
+
+ tmpbatsave = list_def(_mem.battery_save, BATSAVE_LIST, 4)
+ val = RadioSettingValueList(BATSAVE_LIST, None, tmpbatsave)
+ bat_save_setting = RadioSetting("battery_save",
+ "Battery save (BatSav)", val)
+
+ val = RadioSettingValueBoolean(_mem.noaa_autoscan)
+ noaa_auto_scan_setting = RadioSetting("noaa_autoscan",
+ "NOAA Autoscan (NOAA-S)", val)
+
+ tmpmicgain = list_def(_mem.mic_gain, MIC_GAIN_LIST, 2)
+ val = RadioSettingValueList(MIC_GAIN_LIST, None, tmpmicgain)
+ mic_gain_setting = RadioSetting("mic_gain", "Mic Gain (Mic)", val)
+
+ val = RadioSettingValueBoolean(_mem.mic_bar)
+ mic_bar_setting = RadioSetting("mic_bar",
+ "Microphone Bar display (MicBar)", val)
+
+ tmpchdispmode = list_def(_mem.channel_display_mode,
+ CHANNELDISP_LIST, 0)
+ val = RadioSettingValueList(CHANNELDISP_LIST, None, tmpchdispmode)
+ ch_disp_setting = RadioSetting("channel_display_mode",
+ "Channel display mode (ChDisp)", val)
+
+ tmpdispmode = list_def(_mem.power_on_dispmode, WELCOME_LIST, 0)
+ val = RadioSettingValueList(WELCOME_LIST, None, tmpdispmode)
+ p_on_msg_setting = RadioSetting("welcome_mode",
+ "Power ON display message (POnMsg)",
+ val)
+
+ logo1 = str(_mem.logo_line1).strip("\x20\x00\xff") + "\x00"
+ logo1 = uvk5._getstring(logo1.encode('ascii', errors='ignore'), 0, 12)
+ val = RadioSettingValueString(0, 12, logo1)
+ logo1_setting = RadioSetting("logo1",
+ "Message line 1",
+ val)
+
+ logo2 = str(_mem.logo_line2).strip("\x20\x00\xff") + "\x00"
+ logo2 = uvk5._getstring(logo2.encode('ascii', errors='ignore'), 0, 12)
+ val = RadioSettingValueString(0, 12, logo2)
+ logo2_setting = RadioSetting("logo2",
+ "Message line 2",
+ val)
+
+ tmpbattxt = list_def(_mem.battery_text, BAT_TXT_LIST, 2)
+ val = RadioSettingValueList(BAT_TXT_LIST, None, tmpbattxt)
+ bat_txt_setting = RadioSetting("battery_text",
+ "Battery Level Display (BatTXT)", val)
+
+ tmpback = list_def(_mem.backlight_time, BACKLIGHT_LIST, 0)
+ val = RadioSettingValueList(BACKLIGHT_LIST, None, tmpback)
+ back_lt_setting = RadioSetting("backlight_time",
+ "Backlight time (BackLt)", val)
+
+ tmpback = list_def(_mem.backlight_min, BACKLIGHT_LVL_LIST, 0)
+ val = RadioSettingValueList(BACKLIGHT_LVL_LIST, None, tmpback)
+ bl_min_setting = RadioSetting("backlight_min",
+ "Backlight level min (BLMin)", val)
+
+ tmpback = list_def(_mem.backlight_max, BACKLIGHT_LVL_LIST, 10)
+ val = RadioSettingValueList(BACKLIGHT_LVL_LIST, None, tmpback)
+ bl_max_setting = RadioSetting("backlight_max",
+ "Backlight level max (BLMax)", val)
+
+ tmpback = list_def(_mem.backlight_on_TX_RX, BACKLIGHT_TX_RX_LIST, 0)
+ val = RadioSettingValueList(BACKLIGHT_TX_RX_LIST, None, tmpback)
+ blt_trx_setting = RadioSetting("backlight_on_TX_RX",
+ "Backlight on TX/RX (BltTRX)", val)
+
+ val = RadioSettingValueBoolean(_mem.button_beep)
+ beep_setting = RadioSetting("button_beep",
+ "Key press beep sound (Beep)", val)
+
+ tmpalarmmode = list_def(_mem.roger_beep, ROGER_LIST, 0)
+ val = RadioSettingValueList(ROGER_LIST, None, tmpalarmmode)
+ roger_setting = RadioSetting("roger_beep",
+ "End of transmission beep (Roger)", val)
+
+ val = RadioSettingValueBoolean(_mem.ste)
+ ste_setting = RadioSetting("ste", "Squelch tail elimination (STE)",
+ val)
+
+ tmprte = list_def(_mem.rp_ste, RTE_LIST, 0)
+ val = RadioSettingValueList(RTE_LIST, None, tmprte)
+ rp_ste_setting = \
+ RadioSetting("rp_ste",
+ "Repeater squelch tail elimination (RP STE)", val)
+
+ val = RadioSettingValueBoolean(_mem.AM_fix)
+ am_fix_setting = RadioSetting("AM_fix",
+ "AM reception fix (AM Fix)", val)
+
+ tmpvox = min_max_def((_mem.vox_level + 1) * _mem.vox_switch, 0, 10, 0)
+ val = RadioSettingValueList(VOX_LIST, None, tmpvox)
+ vox_setting = RadioSetting("vox", "Voice-operated switch (VOX)", val)
+
+ tmprxmode = list_def((bool(_mem.crossband) << 1)
+ + bool(_mem.dual_watch),
+ RXMODE_LIST, 0)
+ val = RadioSettingValueList(RXMODE_LIST, None, tmprxmode)
+ rx_mode_setting = RadioSetting("rx_mode", "RX Mode (RxMode)", val)
+
+ val = RadioSettingValueBoolean(_mem.freq_mode_allowed)
+ freq_mode_allowed_setting = RadioSetting("freq_mode_allowed",
+ "Frequency mode allowed", val)
+
+ tmpscanres = list_def(_mem.scan_resume_mode, SCANRESUME_LIST, 0)
+ val = RadioSettingValueList(SCANRESUME_LIST, None, tmpscanres)
+ scn_rev_setting = RadioSetting("scan_resume_mode",
+ "Scan resume mode (ScnRev)", val)
+
+ tmpvoice = list_def(_mem.voice, VOICE_LIST, 0)
+ val = RadioSettingValueList(VOICE_LIST, None, tmpvoice)
+ voice_setting = RadioSetting("voice", "Voice", val)
+
+ tmpalarmmode = list_def(_mem.alarm_mode, ALARMMODE_LIST, 0)
+ val = RadioSettingValueList(ALARMMODE_LIST, None, tmpalarmmode)
+ alarm_setting = RadioSetting("alarm_mode", "Alarm mode", val)
+
+ # ----------------- Extra settings
+
+ # S-meter
+ tmp_s0 = -int(_mem.s0_level)
+ tmp_s9 = -int(_mem.s9_level)
+
+ if tmp_s0 not in range(-200, -91) or tmp_s9 not in range(-160, -51) \
+ or tmp_s9 < tmp_s0+9:
+
+ tmp_s0 = -130
+ tmp_s9 = -76
+ val = RadioSettingValueInteger(-200, -90, tmp_s0)
+ s0_level_setting = RadioSetting("s0_level",
+ "S-meter S0 level [dBm]", val)
+
+ val = RadioSettingValueInteger(-160, -50, tmp_s9)
+ s9_level_setting = RadioSetting("s9_level",
+ "S-meter S9 level [dBm]", val)
+
+ # Battery Type
+ tmpbtype = list_def(_mem.Battery_type, BATTYPE_LIST, 0)
+ val = RadioSettingValueList(BATTYPE_LIST, BATTYPE_LIST[tmpbtype])
+ bat_type_setting = RadioSetting("Battery_type",
+ "Battery Type (BatTyp)", val)
+
+ # Power on password
+ def validate_password(value):
+ value = value.strip(" ")
+ if value.isdigit():
+ return value.zfill(6)
+ if value != "":
+ raise InvalidValueError("Power on password "
+ "can only have digits")
+ return ""
+
+ pswd_str = str(int(_mem.password)).zfill(6) \
+ if _mem.password < 1000000 else ""
+ val = RadioSettingValueString(0, 6, pswd_str)
+ val.set_validate_callback(validate_password)
+ pswd_setting = RadioSetting("password", "Power on password", val)
+
+ # ----------------- FM radio
+
+ for i in range(1, 21):
+ fmfreq = _mem.fmfreq[i-1] / 10.0
+ freq_name = str(fmfreq)
+ if fmfreq < FMMIN or fmfreq > FMMAX:
+ freq_name = ""
+ rs = RadioSetting("FM_%i" % i, "Ch %i" % i,
+ RadioSettingValueString(0, 5, freq_name))
+ fmradio.append(rs)
+ rs.set_doc('Frequency in MHz')
+
+ # ----------------- Unlock settings
+
+ # F-LOCK
+ def validate_int_flock(value):
+ mem_val = self._memobj.int_flock
+ if mem_val != 7 and value == FLOCK_LIST[7]:
+ msg = "%r can only be enabled from radio menu" % value
+ raise InvalidValueError(msg)
+ return value
+
+ tmpflock = list_def(_mem.int_flock, FLOCK_LIST, 0)
+ val = RadioSettingValueList(FLOCK_LIST, None, tmpflock)
+ val.set_validate_callback(validate_int_flock)
+ f_lock_setting = RadioSetting("int_flock",
+ "TX Frequency Lock (F Lock)", val)
+
+ val = RadioSettingValueBoolean(_mem.int_200tx)
+ tx200_setting = RadioSetting("int_200tx",
+ "Unlock 174-350MHz TX (Tx 200)", val)
+
+ val = RadioSettingValueBoolean(_mem.int_350tx)
+ tx350_setting = RadioSetting("int_350tx",
+ "Unlock 350-400MHz TX (Tx 350)", val)
+
+ val = RadioSettingValueBoolean(_mem.int_500tx)
+ tx500_setting = RadioSetting("int_500tx",
+ "Unlock 500-600MHz TX (Tx 500)", val)
+
+ val = RadioSettingValueBoolean(_mem.int_350en)
+ en350_setting = RadioSetting("int_350en",
+ "Unlock 350-400MHz RX (350 En)", val)
+
+ val = RadioSettingValueBoolean(_mem.int_scren)
+ en_scrambler_setting = RadioSetting("int_scren",
+ "Scrambler enabled (ScraEn)", val)
+
+ # ----------------- Driver Info
+
+ firmware = self.metadata.get('uvk5_firmware', 'UNKNOWN')
+ append_label(roinfo, "Firmware Version", firmware)
+
+ # ----------------- Calibration
+
+ val = RadioSettingValueBoolean(False)
+
+ radio_setting = RadioSetting("upload_calibration",
+ "Upload calibration", val)
+ radio_setting.set_warning(
+ _('This option may break your radio! '
+ 'Each radio has a unique set of calibration data '
+ 'and uploading the data from the image will cause '
+ 'physical harm to the radio if it is from a '
+ 'different piece of hardware. Do not use this '
+ 'unless you know what you are doing and accept the '
+ 'risk of destroying your radio!'),
+ safe_value=False)
+ calibration.append(radio_setting)
+
+ radio_setting_group = RadioSettingGroup("squelch_calibration",
+ "Squelch")
+ calibration.append(radio_setting_group)
+
+ bands = {"sqlBand1_3": "Frequency Band 1-3",
+ "sqlBand4_7": "Frequency Band 4-7"}
+ for bnd, bndn in bands.items():
+ band_group_range = RadioSettingSubGroup(bnd, bndn)
+ radio_setting_group.append(band_group_range)
+ for sql in range(0, 10):
+ band_group = RadioSettingSubGroup(
+ '%s_%i' % (bnd, sql),
+ "Squelch %i" % sql)
+ band_group_range.append(band_group)
+
+ name = 'cal.%s.openRssiThr[%i]' % (bnd, sql)
+ tempval = min_max_def(_mem.get_path(name), 0, 255, 0)
+ val = RadioSettingValueInteger(0, 255, tempval)
+ radio_setting = RadioSetting(name, "RSSI threshold open", val)
+ band_group.append(radio_setting)
+
+ name = 'cal.%s.closeRssiThr[%i]' % (bnd, sql)
+ tempval = min_max_def(_mem.get_path(name), 0, 255, 0)
+ val = RadioSettingValueInteger(0, 255, tempval)
+ radio_setting = RadioSetting(name, "RSSI threshold close", val)
+ band_group.append(radio_setting)
+
+ name = "cal.%s.openNoiseThr[%i]" % (bnd, sql)
+ tempval = min_max_def(_mem.get_path(name), 0, 127, 0)
+ val = RadioSettingValueInteger(0, 127, tempval)
+ radio_setting = RadioSetting(name, "Noise threshold open", val)
+ band_group.append(radio_setting)
+
+ name = "cal.%s.closeNoiseThr[%i]" % (bnd, sql)
+ tempval = min_max_def(_mem.get_path(name), 0, 127, 0)
+ val = RadioSettingValueInteger(0, 127, tempval)
+ radio_setting = RadioSetting(name, "Noise threshold close",
+ val)
+ band_group.append(radio_setting)
+
+ name = "cal.%s.openGlitchThr[%i]" % (bnd, sql)
+ tempval = min_max_def(_mem.get_path(name), 0, 255, 0)
+ val = RadioSettingValueInteger(0, 255, tempval)
+ radio_setting = RadioSetting(name, "Glitch threshold open",
+ val)
+ band_group.append(radio_setting)
+
+ name = "cal.%s.closeGlitchThr[%i]" % (bnd, sql)
+ tempval = min_max_def(_mem.get_path(name), 0, 255, 0)
+ val = RadioSettingValueInteger(0, 255, tempval)
+ radio_setting = RadioSetting(name, "Glitch threshold close",
+ val)
+ band_group.append(radio_setting)
+
+#
+
+ radio_setting_group = RadioSettingGroup("rssi_level_calibration",
+ "RSSI levels")
+ calibration.append(radio_setting_group)
+
+ bands = {"rssiLevelsBands1_2": "1-2 ", "rssiLevelsBands3_7": "3-7 "}
+ for bnd, bndn in bands.items():
+ band_group = RadioSettingSubGroup(bnd, 'Frequency Band %s' % bndn)
+ radio_setting_group.append(band_group)
+
+ for lvl in [1, 2, 4, 6]:
+ name = "cal.%s.level%i" % (bnd, lvl)
+ value = int(_mem.get_path(name))
+ tempval = min_max_def(value, 0, 65535, 0)
+ val = RadioSettingValueInteger(0, 65535, tempval)
+ radio_setting = RadioSetting(name, "Level %i" % lvl, val)
+ band_group.append(radio_setting)
+
+#
+
+ radio_setting_group = RadioSettingGroup("tx_power_calibration",
+ "TX power")
+ calibration.append(radio_setting_group)
+
+ for bnd in range(0, 7):
+ band_group = RadioSettingSubGroup('txpower_band_%i' % bnd,
+ 'Band %i' % (bnd + 1))
+ powers = {"low": "Low", "mid": "Medium", "hi": "High"}
+ radio_setting_group.append(band_group)
+ for pwr, pwrn in powers.items():
+ bounds = ["lower", "center", "upper"]
+ subgroup = RadioSettingSubGroup('txpower_band_%i_%s' % (
+ bnd, pwr), pwrn)
+ band_group.append(subgroup)
+ for bound in bounds:
+ name = f"cal.txp[{bnd}].{pwr}.{bound}"
+ tempval = min_max_def(_mem.get_path(name), 0, 255, 0)
+ val = RadioSettingValueInteger(0, 255, tempval)
+ radio_setting = RadioSetting(name, bound.capitalize(), val)
+ subgroup.append(radio_setting)
+
+#
+
+ radio_setting_group = RadioSettingGroup("battery_calibration",
+ "Battery")
+ calibration.append(radio_setting_group)
+
+ for lvl in range(0, 6):
+ name = "cal.batLvl[%i]" % lvl
+ temp_val = min_max_def(_mem.get_path(name), 0, 4999, 4999)
+ val = RadioSettingValueInteger(0, 4999, temp_val)
+ label = 'Level %i%s' % (
+ lvl,
+ " (voltage calibration)" if lvl == 3 else "")
+ radio_setting = RadioSetting(name, label, val)
+ radio_setting_group.append(radio_setting)
+
+ radio_setting_group = RadioSettingGroup("vox_calibration", "VOX")
+ calibration.append(radio_setting_group)
+
+ for lvl in range(0, 10):
+ name = "cal.vox1Thr[%s]" % lvl
+ val = RadioSettingValueInteger(0, 65535, _mem.get_path(name))
+ radio_setting = RadioSetting(name, "Level %i On" % (lvl + 1), val)
+ radio_setting_group.append(radio_setting)
+
+ name = "cal.vox0Thr[%s]" % lvl
+ val = RadioSettingValueInteger(0, 65535, _mem.get_path(name))
+ radio_setting = RadioSetting(name, "Level %i Off" % (lvl + 1), val)
+ radio_setting_group.append(radio_setting)
+
+ radio_setting_group = RadioSettingGroup("mic_calibration",
+ "Microphone sensitivity")
+ calibration.append(radio_setting_group)
+
+ for lvl in range(0, 5):
+ name = "cal.micLevel[%s]" % lvl
+ tempval = min_max_def(_mem.get_path(name), 0, 31, 31)
+ val = RadioSettingValueInteger(0, 31, tempval)
+ radio_setting = RadioSetting(name, "Level %i" % lvl, val)
+ radio_setting_group.append(radio_setting)
+
+ radio_setting_group = RadioSettingGroup("other_calibration", "Other")
+ calibration.append(radio_setting_group)
+
+ name = "cal.xtalFreqLow"
+ temp_val = min_max_def(_mem.get_path(name), -1000, 1000, 0)
+ val = RadioSettingValueInteger(-1000, 1000, temp_val)
+ radio_setting = RadioSetting(name, "Xtal frequency low", val)
+ radio_setting_group.append(radio_setting)
+
+ name = "cal.volumeGain"
+ temp_val = min_max_def(_mem.get_path(name), 0, 63, 58)
+ val = RadioSettingValueInteger(0, 63, temp_val)
+ radio_setting = RadioSetting(name, "Volume gain", val)
+ radio_setting_group.append(radio_setting)
+
+ name = "cal.dacGain"
+ temp_val = min_max_def(_mem.get_path(name), 0, 15, 8)
+ val = RadioSettingValueInteger(0, 15, temp_val)
+ radio_setting = RadioSetting(name, "DAC gain", val)
+ radio_setting_group.append(radio_setting)
+
+ # -------- LAYOUT
+
+ basic.append(squelch_setting)
+ basic.append(rx_mode_setting)
+ basic.append(call_channel_setting)
+ basic.append(auto_keypad_lock_setting)
+ basic.append(tx_t_out_setting)
+ basic.append(bat_save_setting)
+ basic.append(scn_rev_setting)
+ if _mem.BUILD_OPTIONS.ENABLE_NOAA:
+ basic.append(noaa_auto_scan_setting)
+ if _mem.BUILD_OPTIONS.ENABLE_AM_FIX:
+ basic.append(am_fix_setting)
+
+ dispSubGrp = RadioSettingSubGroup("dispSubGrp", "Display settings")
+ basic.append(dispSubGrp)
+ dispSubGrp.append(bat_txt_setting)
+ dispSubGrp.append(mic_bar_setting)
+ dispSubGrp.append(ch_disp_setting)
+ dispSubGrp.append(p_on_msg_setting)
+ dispSubGrp.append(logo1_setting)
+ dispSubGrp.append(logo2_setting)
+
+ bcklSubGrp = RadioSettingSubGroup("bcklSubGrp", "Backlight settings")
+ basic.append(bcklSubGrp)
+ bcklSubGrp.append(back_lt_setting)
+ bcklSubGrp.append(bl_min_setting)
+ bcklSubGrp.append(bl_max_setting)
+ bcklSubGrp.append(blt_trx_setting)
+
+ audioSubGrp = RadioSettingSubGroup("audioSubGrp",
+ "Audio related settings")
+ basic.append(audioSubGrp)
+ if _mem.BUILD_OPTIONS.ENABLE_VOX:
+ audioSubGrp.append(vox_setting)
+ audioSubGrp.append(mic_gain_setting)
+ audioSubGrp.append(beep_setting)
+ audioSubGrp.append(roger_setting)
+ audioSubGrp.append(ste_setting)
+ audioSubGrp.append(rp_ste_setting)
+ if _mem.BUILD_OPTIONS.ENABLE_VOICE:
+ audioSubGrp.append(voice_setting)
+ if _mem.BUILD_OPTIONS.ENABLE_ALARM:
+ audioSubGrp.append(alarm_setting)
+
+ stateSubGrp = RadioSettingSubGroup("stateSubGrp", "Radio state")
+ basic.append(stateSubGrp)
+ stateSubGrp.append(freq0_setting)
+ stateSubGrp.append(freq1_setting)
+ stateSubGrp.append(tx_vfo_setting)
+ stateSubGrp.append(keypad_cock_setting)
+
+ advanced.append(freq_mode_allowed_setting)
+ advanced.append(bat_type_setting)
+ advanced.append(s0_level_setting)
+ advanced.append(s9_level_setting)
+ if _mem.BUILD_OPTIONS.ENABLE_PWRON_PASSWORD:
+ advanced.append(pswd_setting)
+
+ if _mem.BUILD_OPTIONS.ENABLE_DTMF_CALLING:
+ dtmf.append(sep_code_setting)
+ dtmf.append(group_code_setting)
+ dtmf.append(first_code_per_setting)
+ dtmf.append(spec_per_setting)
+ dtmf.append(code_per_setting)
+ dtmf.append(code_int_setting)
+ if _mem.BUILD_OPTIONS.ENABLE_DTMF_CALLING:
+ dtmf.append(ani_id_setting)
+ dtmf.append(up_code_setting)
+ dtmf.append(dw_code_setting)
+ dtmf.append(d_prel_setting)
+ dtmf.append(dtmf_side_tone_setting)
+ if _mem.BUILD_OPTIONS.ENABLE_DTMF_CALLING:
+ dtmf.append(dtmf_resp_setting)
+ dtmf.append(d_hold_setting)
+ dtmf.append(d_live_setting)
+ dtmf.append(perm_kill_setting)
+ dtmf.append(kill_code_setting)
+ dtmf.append(rev_code_setting)
+ dtmf.append(killed_setting)
+
+ unlock.append(f_lock_setting)
+ unlock.append(tx200_setting)
+ unlock.append(tx350_setting)
+ unlock.append(tx500_setting)
+ unlock.append(en350_setting)
+ unlock.append(en_scrambler_setting)
+
+ return top
diff --git a/chirp/drivers/vx6.py b/chirp/drivers/vx6.py
index 080570a..1d644ed 100644
--- a/chirp/drivers/vx6.py
+++ b/chirp/drivers/vx6.py
@@ -197,8 +197,9 @@ struct {
DUPLEX = ["", "-", "+", "split"]
MODES = ["FM", "AM", "WFM", "FM"] # last is auto
TMODES = ["", "Tone", "TSQL",
+ "DTCS",
"TSQL-R", # This is "RV TN" as Yaesu calls it
- "DTCS", "DTCS->", "Tone->DTCS", "DTCS->Tone"]
+ "DTCS->", "Tone->DTCS", "DTCS->Tone"]
DTMFCHARSET = list("0123456789ABCD*#-")
STEPS = [5.0, 10.0, 12.5, 15.0, 20.0, 25.0, 50.0, 100.0,
9.0, 200.0, 5.0] # last is auto, 9.0k and 200.0k are unadvertised
diff --git a/chirp/drivers/wouxun.py b/chirp/drivers/wouxun.py
index a0e2116..297a22b 100644
--- a/chirp/drivers/wouxun.py
+++ b/chirp/drivers/wouxun.py
@@ -180,7 +180,7 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio,
u8 unknown_flag_24:7,
dual_band_receive:1;
u8 current_vfo:1,
- unknown_flag_24:7;
+ unknown_flag_26:7;
u8 unknown_8[2];
u8 mode_password[6];
u8 reset_password[6];
@@ -743,10 +743,7 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio,
(txmode, _mem.tx_tone, rxmode, _mem.rx_tone))
def _is_txinh(self, _mem):
- raw_tx = ""
- for i in range(0, 4):
- raw_tx += _mem.tx_freq[i].get_raw(asbytes=False)
- return raw_tx == "\xFF\xFF\xFF\xFF"
+ return _mem.tx_freq.get_raw() == b"\xFF\xFF\xFF\xFF"
def get_memory(self, number):
_mem = self._memobj.memory[number - 1]
@@ -755,7 +752,7 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio,
mem = chirp_common.Memory()
mem.number = number
- if _mem.get_raw(asbytes=False) == ("\xff" * 16):
+ if _mem.get_raw() == (b"\xff" * 16):
mem.empty = True
return mem
@@ -851,15 +848,14 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio,
wipe_memory(_mem, "\xFF")
return
- if _mem.get_raw(asbytes=False) == ("\xFF" * 16):
+ if _mem.get_raw() == (b"\xFF" * 16):
wipe_memory(_mem, "\x00")
_mem.rx_freq = int(mem.freq / 10)
if mem.duplex == "split":
_mem.tx_freq = int(mem.offset / 10)
elif mem.duplex == "off":
- for i in range(0, 4):
- _mem.tx_freq[i].set_raw("\xFF")
+ _mem.tx_freq.fill_raw(b"\xFF")
elif mem.duplex == "+":
_mem.tx_freq = int(mem.freq / 10) + int(mem.offset / 10)
elif mem.duplex == "-":
@@ -979,9 +975,9 @@ class KGUV6DRadio(KGUVD1PRadio):
tx_time_out_alert:4;
u8 unknown_flag_16:6,
vfo_a_ch_disp:2;
- u8 unknown_flag_15:6,
+ u8 unknown_flag_20:6,
scan_mode:2;
- u8 unknown_flag_16:7,
+ u8 unknown_flag_31:7,
kbd_lock:1;
u8 unknown_flag_17:6,
ponmsg:2;
@@ -990,11 +986,11 @@ class KGUV6DRadio(KGUVD1PRadio):
u8 unknown_5[1];
u8 unknown_flag_19:7,
auto_backlight:1;
- u8 unknown_flag_20:7,
+ u8 unknown_flag_26:7,
sos_ch:1;
u8 unknown_6;
u8 sd_available;
- u8 unknown_flag_21:7,
+ u8 unknown_flag_32:7,
auto_lock_kbd:1;
u8 unknown_flag_22:4,
vfo_b_squelch:4;
@@ -1005,7 +1001,7 @@ class KGUV6DRadio(KGUVD1PRadio):
u8 unknown_flag_24:7,
dual_band_receive:1;
u8 current_vfo:1,
- unknown_flag_24:7;
+ unknown_flag_33:7;
u8 unknown_8[2];
u8 mode_password[6];
u8 reset_password[6];
@@ -1017,7 +1013,7 @@ class KGUV6DRadio(KGUVD1PRadio):
u8 vfo_b_cur_chan;
} settings;
- #seekto 0x0f60;
+ //#seekto 0x0f60;
struct {
lbcd rx_freq[4];
lbcd tx_freq[4];
diff --git a/chirp/locale/de/LC_MESSAGES/CHIRP.mo b/chirp/locale/de/LC_MESSAGES/CHIRP.mo
index f04f7a7..d1720f1 100644
--- a/chirp/locale/de/LC_MESSAGES/CHIRP.mo
+++ b/chirp/locale/de/LC_MESSAGES/CHIRP.mo
Binary files differ
diff --git a/chirp/locale/es/LC_MESSAGES/CHIRP.mo b/chirp/locale/es/LC_MESSAGES/CHIRP.mo
index 52a2df1..ddd60ce 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 5569d58..8c2563c 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/hu/LC_MESSAGES/CHIRP.mo b/chirp/locale/hu/LC_MESSAGES/CHIRP.mo
index ce503e6..251f615 100644
--- a/chirp/locale/hu/LC_MESSAGES/CHIRP.mo
+++ b/chirp/locale/hu/LC_MESSAGES/CHIRP.mo
Binary files differ
diff --git a/chirp/locale/it/LC_MESSAGES/CHIRP.mo b/chirp/locale/it/LC_MESSAGES/CHIRP.mo
index 3b006e8..2a9e844 100644
--- a/chirp/locale/it/LC_MESSAGES/CHIRP.mo
+++ b/chirp/locale/it/LC_MESSAGES/CHIRP.mo
Binary files differ
diff --git a/chirp/locale/ja_JP/LC_MESSAGES/CHIRP.mo b/chirp/locale/ja_JP/LC_MESSAGES/CHIRP.mo
index 29b3ae4..d6ff34d 100644
--- a/chirp/locale/ja_JP/LC_MESSAGES/CHIRP.mo
+++ b/chirp/locale/ja_JP/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 249f2a1..99901da 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 da0903c..183107e 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 adf35ae..7dd79e2 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/locale/zh_CN/LC_MESSAGES/CHIRP.mo b/chirp/locale/zh_CN/LC_MESSAGES/CHIRP.mo
index 96b79a3..d71b822 100644
--- a/chirp/locale/zh_CN/LC_MESSAGES/CHIRP.mo
+++ b/chirp/locale/zh_CN/LC_MESSAGES/CHIRP.mo
Binary files differ
diff --git a/chirp/logger.py b/chirp/logger.py
index 64e93f7..050ac02 100644
--- a/chirp/logger.py
+++ b/chirp/logger.py
@@ -21,6 +21,7 @@ it checks the CHIRP_DEBUG, CHIRP_LOG, and CHIRP_LOG_LEVEL environment
variables.
"""
+import contextlib
import os
import sys
import logging
@@ -150,7 +151,7 @@ class Logger(object):
def set_log_level_by_name(self, level):
self.set_log_level(log_level_names[level])
- instance = None
+ instance: object
Logger.instance = Logger()
@@ -189,3 +190,27 @@ def handle_options(options):
if logger.early_level > logging.DEBUG:
logger.LOG.debug(version_string())
+
+
+class LookbackHandler(logging.Handler):
+ def __init__(self):
+ super().__init__()
+ self._history = []
+
+ def emit(self, record):
+ self._history.append(record)
+
+ def get_history(self):
+ return self._history
+
+
+@contextlib.contextmanager
+def log_history(level, root=None):
+ root = logging.getLogger(root)
+ handler = LookbackHandler()
+ handler.setLevel(level)
+ try:
+ root.addHandler(handler)
+ yield handler
+ finally:
+ root.removeHandler(handler)
diff --git a/chirp/settings.py b/chirp/settings.py
index 3ba8666..622a354 100644
--- a/chirp/settings.py
+++ b/chirp/settings.py
@@ -13,8 +13,11 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import logging
+
from chirp import chirp_common
+LOG = logging.getLogger(__name__)
BANNED_NAME_CHARACTERS = r'%'
@@ -41,10 +44,21 @@ class RadioSettingValue:
def __init__(self):
self._current = None
+ self._preinit_current = None
self._has_changed = False
self._validate_callback = self.null_callback
self._mutable = True
+ def initialize(self):
+ """Initialize this value to the stashed value"""
+ assert self._current is None and self._preinit_current is not None
+ self.set_value(self._preinit_current)
+ self._preinit_current = None
+
+ def queue_current(self, current):
+ """Set this value's current on initialization"""
+ self._preinit_current = current
+
def null_callback(self, x):
return x
@@ -63,7 +77,7 @@ class RadioSettingValue:
def set_value(self, value):
"""Sets the current value, triggers changed"""
- if not self.get_mutable():
+ if not self.get_mutable() and self.initialized:
raise InvalidValueError("This value is not mutable")
if self._current is not None and value != self._current:
@@ -72,6 +86,8 @@ class RadioSettingValue:
def get_value(self):
"""Gets the current value"""
+ if not self.initialized:
+ LOG.error('Accessing setting value before init!')
return self._current
def __trunc__(self):
@@ -86,6 +102,28 @@ class RadioSettingValue:
def __str__(self):
return str(self.get_value())
+ def __floordiv__(self, value):
+ return int(self.get_value()) // value
+
+ def __div__(self, value):
+ return float(self.get_value()) / value
+
+ def __mul__(self, value):
+ return self.get_value() * value
+
+ def __gt__(self, value):
+ return self.get_value() > value
+
+ def __lt__(self, value):
+ return self.get_value() < value
+
+ def __eq__(self, value):
+ return self.get_value() == value
+
+ @property
+ def initialized(self):
+ return self._current is not None
+
class RadioSettingValueInteger(RadioSettingValue):
@@ -96,7 +134,7 @@ class RadioSettingValueInteger(RadioSettingValue):
self._min = minval
self._max = maxval
self._step = step
- self.set_value(current)
+ self.queue_current(current)
def set_value(self, value):
try:
@@ -131,7 +169,7 @@ class RadioSettingValueFloat(RadioSettingValue):
self._max = maxval
self._res = resolution
self._pre = precision
- self.set_value(current)
+ self.queue_current(current)
def format(self, value=None):
"""Formats the value into a string"""
@@ -168,7 +206,7 @@ class RadioSettingValueBoolean(RadioSettingValue):
def __init__(self, current):
RadioSettingValue.__init__(self)
- self.set_value(current)
+ self.queue_current(current)
def set_value(self, value):
RadioSettingValue.set_value(self, bool(value))
@@ -188,7 +226,7 @@ class RadioSettingValueList(RadioSettingValue):
def __init__(self, options, current=None, current_index=0):
RadioSettingValue.__init__(self)
self._options = list(options)
- self.set_value(current or self._options[int(current_index)])
+ self.queue_current(current or self._options[int(current_index)])
def set_value(self, value):
if value not in self._options:
@@ -221,7 +259,7 @@ class RadioSettingValueString(RadioSettingValue):
self._maxlength = maxlength
self._charset = charset
self._autopad = autopad
- self.set_value(current)
+ self.queue_current(current)
def set_charset(self, charset):
"""Sets the set of allowed characters"""
@@ -231,12 +269,12 @@ class RadioSettingValueString(RadioSettingValue):
if len(value) < self._minlength or len(value) > self._maxlength:
raise InvalidValueError("Value must be between %i and %i chars" %
(self._minlength, self._maxlength))
- if self._autopad:
- value = value.ljust(self._maxlength)
for char in value:
if char not in self._charset:
raise InvalidValueError("Value contains invalid " +
"character `%s'" % char)
+ if self._autopad:
+ value = value.ljust(self._maxlength)
RadioSettingValue.set_value(self, value)
def __str__(self):
@@ -352,8 +390,17 @@ class RadioSettingGroup(object):
self._element_order = []
self._frozen = False
- for element in elements:
+ for i, element in enumerate(elements):
self._validate(element)
+ if (isinstance(element, RadioSettingValue) and
+ not element.initialized):
+ # Late-initialize this value
+ try:
+ element.initialize()
+ except InvalidValueError as e:
+ LOG.error('Failed to load %s value %i: %s',
+ self._name, i, e)
+
self.append(element)
def set_frozen(self):
@@ -428,6 +475,10 @@ class RadioSettingGroup(object):
self._elements[name] = value
self._element_order.append(name)
+ def __delitem__(self, item):
+ del self._elements[item.get_name()]
+ self._element_order.remove(item.get_name())
+
def __contains__(self, name):
return name in self._elements
@@ -447,6 +498,15 @@ class RadioSettingGroup(object):
return self._name < other._name
+class RadioSettingSubGroup(RadioSettingGroup):
+ """A subgroup of related settings.
+
+ These are to be displayed with less weight than a regular group. Used
+ for repeated sections of related settings, or small groups that don't
+ merit their own panel of display in the UI.
+ """
+
+
class RadioSetting(RadioSettingGroup):
"""A single setting, which could be an array of items like a group"""
@@ -516,7 +576,7 @@ class RadioSetting(RadioSettingGroup):
return self._elements[self._element_order[0]]
else:
return list(self._elements.values())
- elif name in ('__getstate__', '__setstate__'):
+ elif name in ('__getstate__', '__setstate__', '__deepcopy__'):
super().__getattr__(name)
else:
return self.__dict__[name]
diff --git a/chirp/share/chirp-logo.png b/chirp/share/chirp-logo.png
new file mode 100644
index 0000000..d144e02
--- /dev/null
+++ b/chirp/share/chirp-logo.png
Binary files differ
diff --git a/chirp/share/chirp.png b/chirp/share/chirp.png
index d144e02..ea13972 100644
--- a/chirp/share/chirp.png
+++ b/chirp/share/chirp.png
Binary files differ
diff --git a/chirp/share/welcome_screen.png b/chirp/share/welcome_screen.png
index 2144125..dc4075a 100644
--- a/chirp/share/welcome_screen.png
+++ b/chirp/share/welcome_screen.png
Binary files differ
diff --git a/chirp/stock_configs/GR Marine VHF Channels.csv b/chirp/stock_configs/GR Marine VHF Channels.csv
new file mode 100644
index 0000000..9cc862b
--- /dev/null
+++ b/chirp/stock_configs/GR Marine VHF Channels.csv
@@ -0,0 +1,58 @@
+Location,Name,Frequency,Duplex,Offset,Tone,rToneFreq,cToneFreq,DtcsCode,DtcsPolarity,RxDtcsCode,CrossMode,Mode,TStep,Skip,Power,Comment,URCALL,RPT1CALL,RPT2CALL,DVCODE
+1,MRN 01,160.650000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+2,MRN 02,160.700000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+3,MRN 03,160.750000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+4,MRN 04,160.800000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+5,MRN 05,160.850000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+6,MRN 06,156.300000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+7,MRN 07,160.950000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+8,MRN 08,156.400000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+9,MRN 09,156.450000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+10,MRN 10,156.500000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+11,MRN 11,156.550000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+12,MRN 12,156.600000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+13,MRN 13,156.650000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+14,MRN 14,156.700000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+15,MRN 15,156.750000,off,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+16,MRN 16,156.800000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+17,MRN 17,156.850000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+18,MRN 18,161.500000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+19,MRN 19,161.550000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+20,MRN 20,161.600000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+21,MRN 21,161.650000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+22,MRN 22,161.700000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+23,MRN 23,161.750000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+24,MRN 24,161.800000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+25,MRN 25,161.850000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+26,MRN 26,161.900000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+27,MRN 27,161.950000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+28,MRN 28,162.000000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+29,MRN 60,160.625000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+30,MRN 61,160.675000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+31,MRN 62,160.725000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+32,MRN 63,160.775000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+33,MRN 64,160.825000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+34,MRN 65,160.875000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+35,MRN 66,160.925000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+36,MRN 67,156.375000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+37,MRN 68,156.425000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+38,MRN 69,156.475000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+39,MRN 70,156.525000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+40,MRN 71,156.575000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+41,MRN 72,156.625000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+42,MRN 73,156.675000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+43,MRN 74,156.725000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+44,MRN 75,156.775000,off,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+45,MRN 76,156.825000,off,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+46,MRN 77,156.875000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+47,MRN 78,161.525000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+48,MRN 79,161.575000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+49,MRN 80,161.625000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+50,MRN 81,161.675000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+51,MRN 82,161.725000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+52,MRN 83,161.775000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+53,MRN 84,161.825000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+54,MRN 85,161.875000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+55,MRN 86,161.925000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,5.00,,50W,,,,,
+56,MRN 87,161.975000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,,,,,
+57,MRN 88,162.025000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,,,,,
diff --git a/chirp/stock_configs/US Marine VHF Channels.csv b/chirp/stock_configs/US Marine VHF Channels.csv
index 21a6f79..09023e6 100644
--- a/chirp/stock_configs/US Marine VHF Channels.csv
+++ b/chirp/stock_configs/US Marine VHF Channels.csv
@@ -1,61 +1,51 @@
-Location,Name,Frequency,Duplex,Offset,Tone,rToneFreq,cToneFreq,DtcsCode,DtcsPolarity,Mode,TStep,Skip,Comment,URCALL,RPT1CALL,RPT2CALL
-1,SEA 01,160.650000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-2,SEA 02,160.700000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-3,SEA 03,160.750000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-4,SEA 04,160.800000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-5,SEA 05,160.850000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-6,SEA 06,156.300000,,0.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-7,SEA 07,160.950000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-8,SEA 08,156.400000,,0.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-9,SEA 09,156.450000,,0.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-10,SEA 10,156.500000,,0.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-11,SEA 11,156.550000,,0.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-12,SEA 12,156.600000,,0.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-13,SEA 13,156.650000,,0.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-14,SEA 14,156.700000,,0.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-15,SEA 15,156.750000,,0.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-16,SEA 16,156.800000,,0.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-17,SEA 17,156.850000,,0.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-18,SEA 18,161.500000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-19,SEA 19,161.550000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-20,SEA 20,161.600000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-21,SEA 21,161.650000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-22,SEA 22,161.700000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-23,SEA 23,161.750000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-24,SEA 24,161.800000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-25,SEA 25,161.850000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-26,SEA 26,161.900000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-27,SEA 27,161.950000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-28,SEA 28,162.000000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-29,SEA 60,160.625000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-30,SEA 61,160.675000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-31,SEA 62,160.725000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-32,SEA 63,160.775000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-33,SEA 64,160.825000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-34,SEA 65,160.875000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-35,SEA 66,160.925000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-36,SEA 67,156.375000,,0.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-37,SEA 68,156.425000,,0.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-38,SEA 69,156.475000,,0.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-39,DSC 70,156.525000,,0.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-40,SEA 71,156.575000,,0.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-41,SEA 72,156.625000,,0.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-42,SEA 73,156.675000,,0.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-43,SEA 74,156.725000,,0.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-44,SEA 77,156.875000,,0.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-45,SEA 78,161.525000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-46,SEA 79,161.575000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-47,SEA 80,161.625000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-48,SEA 81,161.675000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-49,SEA 82,161.725000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-50,SEA 83,161.775000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-51,SEA 84,161.825000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-52,SEA 85,161.875000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-53,SEA 86,161.925000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-54,AIS 87,161.975000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-55,AIS 88,162.025000,-,4.600000,,88.5,88.5,023,NN,FM,25.00,,,,,
-56,SEA F1,155.625000,,0.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-57,SEA F2,155.775000,,0.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-58,SEA F3,155.825000,,0.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-59,SEA L1,155.500000,,0.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-60,SEA L2,155.525000,,0.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
+Location,Name,Frequency,Duplex,Offset,Tone,rToneFreq,cToneFreq,DtcsCode,DtcsPolarity,RxDtcsCode,CrossMode,Mode,TStep,Skip,Power,Comment,URCALL,RPT1CALL,RPT2CALL,DVCODE
+1,SEA 01,156.050000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Port Operations and Commercial,,,,
+2,SEA 05,156.250000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Port Operations. VTS in Seattle,,,,
+3,SEA 06,156.300000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Intership Safety,,,,
+4,SEA 07,156.350000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Commercial,,,,
+5,SEA 08,156.400000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Commercial (Intership only),,,,
+6,SEA 09,156.450000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Boater Calling. Commercial and Non-Commercial.,,,,
+7,SEA 10,156.500000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Commercial,,,,
+8,SEA 11,156.550000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Commercial. VTS in selected areas.,,,,
+9,SEA 12,156.600000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Port Operations. VTS in selected areas.,,,,
+10,SEA 13,156.650000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Intership Navigation Safety (Bridge-to-bridge). Ships >20m length maintain a listening watch on this channel in US waters.,,,,
+11,SEA 14,156.700000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Port Operations. VTS in selected areas.,,,,
+12,SEA 15,156.750000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Environmental (Receive only). Used by Class C EPIRBs.,,,,
+13,SEA 16,156.800000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,"International Distress, Safety and Calling. Ships required to carry radio, USCG, and most coast stations maintain a listening watch on this channel.",,,,
+14,SEA 17,156.850000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,State Control,,,,
+15,SEA 18,156.900000,-,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Commercial,,,,
+16,SEA 19,156.950000,-,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Commercial,,,,
+17,SEA 20,157.000000,-,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Port Operations (duplex),,,,
+18,SEA 21,157.050000,-,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Port Operations,,,,
+19,SEA 22,157.100000,-,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Coast Guard Liaison and Maritime Safety Information Broadcasts. Broadcasts announced on channel 16.,,,,
+20,SEA 23,157.150000,-,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,U.S. Government only,,,,
+21,SEA 24,157.200000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Public Correspondence (Marine Operator),,,,
+22,SEA 25,157.250000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Public Correspondence (Marine Operator),,,,
+23,SEA 26,157.300000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Public Correspondence (Marine Operator),,,,
+24,SEA 27,157.350000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Public Correspondence (Marine Operator),,,,
+25,SEA 28,157.400000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Public Correspondence (Marine Operator),,,,
+26,SEA 63,156.175000,-,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Port Operations and Commercial. VTS in selected areas.,,,,
+27,SEA 65,156.275000,-,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Port Operations,,,,
+28,SEA 66,156.325000,-,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Port Operations,,,,
+29,SEA 67,156.375000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Commercial. Used for Bridge-to-bridge communications in lower Mississippi River. Intership only.,,,,
+30,SEA 68,156.425000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Non-Commercial-Working Channel,,,,
+31,SEA 69,156.475000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Non-Commercial,,,,
+32,DSC 70,156.525000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Digital Selective Calling (voice communications not allowed),,,,
+33,SEA 71,156.575000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Non-Commercial,,,,
+34,SEA 72,156.625000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Non-Commercial (Intership only),,,,
+35,SEA 73,156.675000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Port Operations,,,,
+36,SEA 74,156.725000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Port Operations,,,,
+37,SEA 77,156.875000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Port Operations,,,,
+38,SEA 78,156.925000,-,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Non-Commercial,,,,
+39,SEA 79,156.975000,-,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Commercial,,,,
+40,SEA 80,157.025000,-,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Commercial,,,,
+41,SEA 81,157.075000,-,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,U.S. Government only - Environmental Protection Operations,,,,
+42,SEA 82,157.125000,-,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,U.S. Government only,,,,
+43,SEA 83,157.175000,-,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,U.S. Government only,,,,
+44,SEA 84,157.225000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Public Correspondence (Marine Operator),,,,
+45,SEA 85,157.275000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Public Correspondence (Marine Operator),,,,
+46,SEA 86,157.325000,-,4.600000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Public Correspondence (Marine Operator),,,,
+47,SEA 87,157.375000,-,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Public Correspondence (Marine Operator),,,,
+48,SEA 88,157.425000,-,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,Public Correspondence in selected areas only.,,,,
+49,AIS 1,161.975000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,,,,,
+50,AIS 2,162.025000,,0.000000,,88.5,88.5,023,NN,023,Tone->Tone,FM,25.00,,50W,,,,,
diff --git a/chirp/wxui/clone.py b/chirp/wxui/clone.py
index fe3c2ee..5b6bdc8 100644
--- a/chirp/wxui/clone.py
+++ b/chirp/wxui/clone.py
@@ -28,10 +28,12 @@ import wx.lib.sized_controls
from chirp import chirp_common
from chirp import directory
from chirp.drivers import fake
+from chirp import errors
from chirp.wxui import config
from chirp.wxui import common
from chirp.wxui import developer
+_ = wx.GetTranslation
LOG = logging.getLogger(__name__)
CONF = config.get()
HELPME = _('Help Me...')
@@ -41,6 +43,8 @@ FAKES = {
'Fake NOP': developer.FakeSerial(),
'Fake Echo NOP': developer.FakeEchoSerial(),
'Fake F7E': fake.FakeKenwoodSerial(),
+ 'Fake UV17': fake.FakeUV17Serial(),
+ 'Fake UV17Pro': fake.FakeUV17ProSerial(),
}
@@ -166,6 +170,10 @@ class ChirpRadioPromptDialog(wx.Dialog):
instructions.SetLabelMarkup(self.message)
vbox.Add(instructions,
border=20, flag=wx.ALL)
+ if self.prompt == 'experimental':
+ risk_warning = wx.StaticText(self)
+ risk_warning.SetLabelMarkup(_('Do you accept the risk?'))
+ vbox.Add(risk_warning, border=20, flag=wx.ALL)
self.cb = wx.CheckBox(
self, label=_("Do not prompt again for %s") % (
'%s %s' % (self.radio.VENDOR, self.radio.MODEL)))
@@ -238,6 +246,8 @@ 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
@@ -299,6 +309,9 @@ class ChirpCloneDialog(wx.Dialog):
if (not issubclass(rclass, chirp_common.CloneModeRadio) and
not issubclass(rclass, chirp_common.LiveRadio)):
continue
+ if (getattr(rclass, '_DETECTED_MODEL', False) and
+ not allow_detected_models):
+ continue
self._vendors[rclass.VENDOR].append(rclass)
self._add_aliases(rclass)
@@ -356,7 +369,13 @@ class ChirpCloneDialog(wx.Dialog):
self._port.SetStringSelection(name)
break
else:
- LOG.warning('Unable to select %r' % select)
+ if self.ports:
+ port = self.ports[0]
+ self._port.SetStringSelection(port[0])
+ else:
+ port = '(no ports available)'
+ LOG.warning('Unable to select %r, defaulting to %s',
+ select, port)
def get_selected_port(self):
selected = self._port.GetStringSelection()
@@ -370,14 +389,14 @@ class ChirpCloneDialog(wx.Dialog):
r = wx.MessageBox(
_('Unplug your cable (if needed) and then click OK'),
_('USB Port Finder'),
- style=wx.OK | wx.CANCEL | wx.OK_DEFAULT)
+ style=wx.OK | wx.CANCEL | wx.OK_DEFAULT, parent=self)
if r == wx.CANCEL:
return
before = list_ports.comports()
r = wx.MessageBox(
_('Plug in your cable and then click OK'),
_('USB Port Finder'),
- style=wx.OK | wx.CANCEL | wx.OK_DEFAULT)
+ style=wx.OK | wx.CANCEL | wx.OK_DEFAULT, parent=self)
if r == wx.CANCEL:
return
after = list_ports.comports()
@@ -387,7 +406,7 @@ class ChirpCloneDialog(wx.Dialog):
wx.MessageBox(
_('Unable to determine port for your cable. '
'Check your drivers and connections.'),
- _('USB Port Finder'))
+ _('USB Port Finder'), parent=self)
self.set_ports(after)
return
elif len(changed) == 1:
@@ -395,11 +414,11 @@ class ChirpCloneDialog(wx.Dialog):
wx.MessageBox(
'%s\n%s' % (_('Your cable appears to be on port:'),
port_label(found)),
- _('USB Port Finder'))
+ _('USB Port Finder'), parent=self)
else:
wx.MessageBox(
_('More than one port found: %s') % ', '.join(changed),
- _('USB Port Finder'))
+ _('USB Port Finder'), parent=self)
self.set_ports(after)
return
self.set_ports(after, select=found.device)
@@ -475,7 +494,7 @@ class ChirpCloneDialog(wx.Dialog):
def safe_fail():
wx.MessageBox(message,
_('Error communicating with radio'),
- wx.ICON_ERROR)
+ wx.ICON_ERROR, parent=self)
self.cancel_action()
wx.CallAfter(safe_fail)
@@ -504,12 +523,23 @@ class ChirpDownloadDialog(ChirpCloneDialog):
rclass = self.get_selected_rclass()
prompts = rclass.get_prompts()
if prompts.experimental:
- d = ChirpRadioPromptDialog(self,
- title=_('Experimental driver'),
- buttons=wx.OK,
- radio=rclass,
- prompt='experimental')
- d.ShowModal()
+ d = ChirpRadioPromptDialog(
+ self,
+ title=_('Experimental driver'),
+ buttons=wx.YES_NO | wx.NO_DEFAULT,
+ radio=rclass,
+ prompt='experimental')
+ d.SetAffirmativeId(wx.ID_YES)
+ d.SetEscapeId(wx.ID_NO)
+ r = d.ShowModal()
+ if r == wx.ID_CANCEL:
+ LOG.info('User did not accept experimental risk for %s',
+ rclass)
+ self.FindWindowById(wx.ID_OK).Disable()
+ else:
+ LOG.info('User accepted experimental risk for %s',
+ rclass)
+ self.FindWindowById(wx.ID_OK).Enable()
def _action(self, event):
if event.GetEventObject().GetId() == wx.ID_CANCEL:
@@ -544,8 +574,26 @@ class ChirpDownloadDialog(ChirpCloneDialog):
self.cancel_action()
return
+ serial = open_serial(port, rclass)
+
+ # See if the driver detects we should be using a different radio class
+ # to communicate with this model
+ try:
+ rclass = rclass.detect_from_serial(serial)
+ LOG.info('Detected %s from serial', rclass)
+ except NotImplementedError:
+ pass
+ except errors.RadioError as e:
+ LOG.error('Radio serial detection failed: %s', e)
+ self.fail(str(e))
+ return
+ except Exception as e:
+ LOG.exception('Exception during detection: %s', e)
+ self.fail(_('Internal driver error'))
+ return
+
try:
- self._radio = rclass(open_serial(port, rclass))
+ self._radio = rclass(serial)
except Exception as e:
LOG.exception('Failed to open serial: %s' % e)
self.fail(str(e))
@@ -569,7 +617,8 @@ class ChirpDownloadDialog(ChirpCloneDialog):
class ChirpUploadDialog(ChirpCloneDialog):
def __init__(self, radio, *a, **k):
- super(ChirpUploadDialog, self).__init__(*a, **k)
+ super(ChirpUploadDialog, self).__init__(*a, allow_detected_models=True,
+ **k)
self._radio = radio
self.select_vendor_model(
diff --git a/chirp/wxui/common.py b/chirp/wxui/common.py
index 7513cc0..4c01bdc 100644
--- a/chirp/wxui/common.py
+++ b/chirp/wxui/common.py
@@ -14,7 +14,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import atexit
+import contextlib
import functools
+import itertools
import logging
import os
import platform
@@ -27,6 +29,7 @@ import wx
from chirp import chirp_common
from chirp.drivers import generic_csv
from chirp import errors
+from chirp import logger
from chirp import platform as chirp_platform
from chirp import settings
from chirp.wxui import config
@@ -353,6 +356,7 @@ class ChirpSettingGrid(wx.Panel):
def __init__(self, settinggroup, *a, **k):
super(ChirpSettingGrid, self).__init__(*a, **k)
self._group = settinggroup
+ self._settings = {}
self._needs_reload = False
self.pg = wx.propgrid.PropertyGrid(
@@ -361,6 +365,7 @@ class ChirpSettingGrid(wx.Panel):
wx.propgrid.PG_BOLD_MODIFIED)
self.pg.Bind(wx.propgrid.EVT_PG_CHANGED, self._pg_changed)
+ self.pg.Bind(wx.EVT_MOTION, self._mouseover)
sizer = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(sizer)
@@ -368,12 +373,42 @@ class ChirpSettingGrid(wx.Panel):
self._choices = {}
- for name, element in self._group.items():
- if not isinstance(element, settings.RadioSetting):
+ self._add_items(self._group)
+ self.pg.Bind(wx.propgrid.EVT_PG_CHANGING, self._check_change)
+
+ def _mouseover(self, event):
+ prop = self.pg.HitTest(event.GetPosition()).GetProperty()
+ tip = None
+ if prop:
+ setting = self.get_setting_by_name(prop.GetName())
+ tip = setting.__doc__ or None
+ if tip and tip == setting.get_name():
+ # This is the default, which makes no sense, but it's been
+ # that way for ages, so just avoid exposing it here if it's
+ # set to the default.
+ tip = None
+
+ event.GetEventObject().SetToolTip(tip)
+
+ def _add_items(self, group, parent=None):
+ def append(item):
+ if parent:
+ self.pg.AppendIn(parent, item)
+ else:
+ self.pg.Append(item)
+
+ for name, element in group.items():
+ if isinstance(element, settings.RadioSettingSubGroup):
+ category = wx.propgrid.PropertyCategory(
+ element.get_shortname(), element.get_name())
+ append(category)
+ self._add_items(element, parent=category)
+ continue
+ elif not isinstance(element, settings.RadioSetting):
LOG.debug('Skipping nested group %s' % element)
continue
if len(element.keys()) > 1:
- self.pg.Append(wx.propgrid.PropertyCategory(
+ append(wx.propgrid.PropertyCategory(
element.get_shortname()))
for i in element.keys():
@@ -398,14 +433,20 @@ class ChirpSettingGrid(wx.Panel):
if len(element.keys()) > 1:
editor.SetLabel('')
editor.Enable(value.get_mutable())
- self.pg.Append(editor)
+ append(editor)
+ self._settings[element.get_name()] = element
+ if editor.IsValueUnspecified():
+ # Mark invalid/unspecified values so the user can fix them
+ self.pg.SetPropertyBackgroundColour(editor.GetName(),
+ wx.YELLOW)
+
self.pg.Bind(wx.propgrid.EVT_PG_CHANGING, self._check_change)
def get_setting_by_name(self, name, index=0):
if INDEX_CHAR in name:
# FIXME: This will only work for single-index settings of course
name, _ = name.split(INDEX_CHAR, 1)
- for setting_name, setting in self._group.items():
+ for setting_name, setting in self._settings.items():
if name == setting_name:
return setting
@@ -435,6 +476,9 @@ class ChirpSettingGrid(wx.Panel):
'the image, which will happen now.'),
_('Refresh required'), wx.OK)
+ # If we were unspecified or otherwise marked, clear those markings
+ self.pg.SetPropertyColoursToDefault(event.GetProperty().GetName())
+
@property
def name(self):
return self._group.get_name()
@@ -452,8 +496,11 @@ class ChirpSettingGrid(wx.Panel):
def _get_editor_int(self, setting, value):
e = wx.propgrid.IntProperty(setting.get_shortname(),
- setting.get_name(),
- value=int(value))
+ setting.get_name())
+ if value.initialized:
+ e.SetValue(int(value))
+ else:
+ e.SetValueToUnspecified()
e.SetEditor('SpinCtrl')
e.SetAttribute(wx.propgrid.PG_ATTR_MIN, value.get_min())
e.SetAttribute(wx.propgrid.PG_ATTR_MAX, value.get_max())
@@ -476,9 +523,13 @@ class ChirpSettingGrid(wx.Panel):
def ValueToString(self, _value, flags=0):
return value.format(_value)
- return ChirpFloatProperty(setting.get_shortname(),
- setting.get_name(),
- value=float(value))
+ e = ChirpFloatProperty(setting.get_shortname(),
+ setting.get_name())
+ if value.initialized:
+ e.SetValue(float(value))
+ else:
+ e.SetValueToUnspecified()
+ return e
def _get_editor_choice(self, setting, value):
choices = value.get_options()
@@ -506,9 +557,13 @@ class ChirpSettingGrid(wx.Panel):
return False
return True
- return ChirpStrProperty(setting.get_shortname(),
- setting.get_name(),
- value=str(value))
+ e = ChirpStrProperty(setting.get_shortname(),
+ setting.get_name())
+ if value.initialized:
+ e.SetValue(str(value))
+ else:
+ e.SetValueToUnspecified()
+ return e
def get_setting_values(self):
"""Return a dict of {name: (RadioSetting, newvalue)}"""
@@ -516,12 +571,14 @@ class ChirpSettingGrid(wx.Panel):
for prop in self.pg._Items():
if prop.IsCategory():
continue
+ if prop.IsValueUnspecified():
+ continue
basename = prop.GetName().split(INDEX_CHAR)[0]
if isinstance(prop, wx.propgrid.EnumProperty):
value = self._choices[basename][prop.GetValue()]
else:
value = prop.GetValue()
- setting = self._group[basename]
+ setting = self._settings[basename]
values[prop.GetName()] = setting, value
return values
@@ -565,6 +622,7 @@ def _error_proof(*expected_errors):
class error_proof(object):
def __init__(self, *expected_exceptions):
self._expected = expected_exceptions
+ self.fn = None
@staticmethod
def show_error(msg):
@@ -596,7 +654,8 @@ class error_proof(object):
def __exit__(self, exc_type, exc_val, traceback):
if exc_type:
if exc_type in self._expected:
- LOG.error('%s: %s: %s' % (self.fn, exc_type, exc_val))
+ LOG.error('%s: %s: %s',
+ self.fn or 'context', exc_type, exc_val)
self.show_error(exc_val)
return True
else:
@@ -642,3 +701,24 @@ def temporary_debug_log():
delete_atexit(dst)
shutil.copy(src, dst)
return dst
+
+
+@contextlib.contextmanager
+def expose_logs(level, root, label):
+ if not isinstance(root, tuple):
+ root = (root,)
+
+ mgrs = (logger.log_history(level, x) for x in root)
+ with contextlib.ExitStack() as stack:
+ histories = [stack.enter_context(m) for m in mgrs]
+ try:
+ yield
+ finally:
+ 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)
+ d = wx.MessageDialog(
+ None, str(msg), label,
+ style=wx.OK | wx.ICON_INFORMATION)
+ d.ShowModal()
diff --git a/chirp/wxui/fips.py b/chirp/wxui/fips.py
index 49e144d..df3ae3e 100644
--- a/chirp/wxui/fips.py
+++ b/chirp/wxui/fips.py
@@ -6609,7 +6609,7 @@ if __name__ == "__main__":
pp = PrettyPrinter(indent=2)
import csv
- fipsreader = csv.reader(open(argv[1], 'rb'), delimiter=',', quotechar='"')
+ fipsreader = csv.reader(open(argv[1], 'r'), delimiter=',', quotechar='"')
for row in fipsreader:
try:
FIPS_COUNTIES[int(row[1])][row[3]] = row[2]
diff --git a/chirp/wxui/main.py b/chirp/wxui/main.py
index 77eed77..20b91e5 100644
--- a/chirp/wxui/main.py
+++ b/chirp/wxui/main.py
@@ -22,6 +22,7 @@ import pickle
import platform
import sys
import time
+import typing
import webbrowser
if sys.version_info < (3, 10):
@@ -140,7 +141,7 @@ class ChirpDropTarget(wx.DropTarget):
class ChirpEditorSet(wx.Panel):
MEMEDIT_CLS = memedit.ChirpMemEdit
SETTINGS_CLS = settingsedit.ChirpCloneSettingsEdit
- BANK_CLS = bankedit.ChirpBankEditSync
+ BANK_CLS: typing.Union[type, None] = bankedit.ChirpBankEditSync
@property
def tab_name(self):
@@ -538,18 +539,19 @@ class ChirpMain(wx.Frame):
@common.error_proof(errors.ImageDetectFailed, FileNotFoundError)
def open_file(self, filename, exists=True, select=True, rclass=None):
-
CSVRadio = directory.get_radio('Generic_CSV')
- if exists:
- if not os.path.exists(filename):
- raise FileNotFoundError(
- _('File does not exist: %s') % filename)
- if rclass is None:
- radio = directory.get_radio_by_image(filename)
+ label = _('Driver messages')
+ with common.expose_logs(logging.WARNING, 'chirp.drivers', label):
+ if exists:
+ if not os.path.exists(filename):
+ raise FileNotFoundError(
+ _('File does not exist: %s') % filename)
+ if rclass is None:
+ radio = directory.get_radio_by_image(filename)
+ else:
+ radio = rclass(filename)
else:
- radio = rclass(filename)
- else:
- radio = CSVRadio(None)
+ radio = CSVRadio(None)
if (not isinstance(radio, CSVRadio) or
isinstance(radio, chirp_common.NetworkSourceRadio)):
@@ -662,12 +664,14 @@ class ChirpMain(wx.Frame):
_("Open Stock Config"))
self.OPEN_RECENT_MENU = wx.Menu()
+ self.restore_tabs_item = wx.NewId()
+
last_files = [
x for x in (CONF.get('last_open', 'state') or '').split('$')
if x]
- self.restore_tabs_item = wx.NewId()
+ self.adj_menu_open_recent(None)
if last_files:
- submenu_item = self.OPEN_RECENT_MENU.Append(
+ submenu_item = self.OPEN_RECENT_MENU.Prepend(
self.restore_tabs_item,
ngettext('Restore %i tab', 'Restore %i tabs', len(last_files))
% len(last_files))
@@ -675,20 +679,6 @@ class ChirpMain(wx.Frame):
wx.MOD_CONTROL | wx.ACCEL_SHIFT, ord('T')))
self.Bind(wx.EVT_MENU, self.restore_tabs, submenu_item)
- i = 0
- fn = CONF.get("recent%i" % i, "state")
- while fn:
- submenu_item = self.OPEN_RECENT_MENU.Append(wx.ID_ANY, fn)
- self.Bind(wx.EVT_MENU, self._menu_open_recent, submenu_item)
- i += 1
- if i >= KEEP_RECENT:
- break
- fn = CONF.get("recent%i" % i, "state")
- if self.OPEN_RECENT_MENU.GetMenuItemCount() <= 0:
- submenu_item = self.OPEN_RECENT_MENU.Append(wx.ID_ANY,
- EMPTY_MENU_LABEL)
- submenu_item.Enable(False)
- self.Bind(wx.EVT_MENU, self._menu_open_recent, submenu_item)
file_menu.AppendSubMenu(self.OPEN_RECENT_MENU, _('Open Recent'))
save_item = file_menu.Append(wx.ID_SAVE)
@@ -952,6 +942,11 @@ class ChirpMain(wx.Frame):
self.Bind(wx.EVT_MENU, self._menu_debug_loc, debug_loc_menu)
help_menu.Append(debug_loc_menu)
+ backup_loc_menu = wx.MenuItem(help_menu, wx.NewId(),
+ _('Show image backup location'))
+ self.Bind(wx.EVT_MENU, self._menu_backup_loc, backup_loc_menu)
+ help_menu.Append(backup_loc_menu)
+
lmfi_menu = wx.MenuItem(help_menu, wx.NewId(),
_('Load module from issue...'))
self.Bind(wx.EVT_MENU, self._menu_load_from_issue, lmfi_menu)
@@ -1005,60 +1000,57 @@ class ChirpMain(wx.Frame):
tb.Realize()
def adj_menu_open_recent(self, filename):
- # Don't persist template names that have not been saved or do not
- # exist.
- if not os.path.exists(filename):
- LOG.debug('Ignoring recent file %s', filename)
- return
-
- # Don't add stock config files to the recent files list
- stock_dir = get_stock_configs()
- this_dir = os.path.dirname(filename)
- if (stock_dir and os.path.exists(stock_dir) and
- this_dir and os.path.samefile(stock_dir, this_dir)):
- return
+ """Update the "open recent" menu
+
+ If filename is passed, arrange for it to be the most-recent recent
+ file. Otherwise just synchronize config and the submenu state.
+ """
+ if filename:
+ # Don't persist template names that have not been saved or do not
+ # exist.
+ if not os.path.exists(filename):
+ LOG.debug('Ignoring recent file %s', filename)
+ return
+ # Don't add stock config files to the recent files list
+ stock_dir = get_stock_configs()
+ this_dir = os.path.dirname(filename)
+ if (stock_dir and os.path.exists(stock_dir) and
+ this_dir and os.path.samefile(stock_dir, this_dir)):
+ return
- # Travel the Open Recent menu looking for filename
- found_mi = None
- empty_mi = None
- for i in range(0, self.OPEN_RECENT_MENU.GetMenuItemCount()):
- menu_item = self.OPEN_RECENT_MENU.FindItemByPosition(i)
- fn = menu_item.GetItemLabelText()
- if fn == filename:
- found_mi = menu_item
- if fn == EMPTY_MENU_LABEL:
- empty_mi = menu_item
-
- # Move filename to top of menu or add it to top if it wasn't found
- if found_mi:
- self.OPEN_RECENT_MENU.Remove(found_mi)
- self.OPEN_RECENT_MENU.Prepend(found_mi)
- else:
- submenu_item = self.OPEN_RECENT_MENU.Prepend(wx.ID_ANY, filename)
- self.Bind(wx.EVT_MENU, self._menu_open_recent, submenu_item)
-
- # Get rid of the place holder used in an empty menu
- if empty_mi:
- self.OPEN_RECENT_MENU.Delete(empty_mi)
-
- # Trim the menu length
- if self.OPEN_RECENT_MENU.GetMenuItemCount() > KEEP_RECENT:
- for i in range(self.OPEN_RECENT_MENU.GetMenuItemCount() - 1,
- KEEP_RECENT - 1, -1):
- extra_mi = self.OPEN_RECENT_MENU.FindItemByPosition(i)
- self.OPEN_RECENT_MENU.Delete(extra_mi)
-
- # Travel the Open Recent menu and save file names to config.
- for i in range(0, self.OPEN_RECENT_MENU.GetMenuItemCount()):
- if i >= KEEP_RECENT:
- break
- menu_item = self.OPEN_RECENT_MENU.FindItemByPosition(i)
- if menu_item.GetId() == self.restore_tabs_item:
- continue
- fn = menu_item.GetItemLabelText()
- CONF.set("recent%i" % i, fn, "state")
+ # Make a list of recent files in config
+ recent = [CONF.get('recent%i' % i, 'state')
+ for i in range(KEEP_RECENT)
+ if CONF.get('recent%i' % i, 'state')]
+ while filename in recent:
+ # The old algorithm could have dupes, so keep looking and
+ # cleaning until they're gone
+ LOG.debug('File exists in recent, moving to front')
+ recent.remove(filename)
+ if filename:
+ recent.insert(0, filename)
+ recent = recent[:KEEP_RECENT]
+ LOG.debug('Recent is now %s' % recent)
+
+ # Update and clean config
+ for i in range(KEEP_RECENT):
+ try:
+ CONF.set('recent%i' % i, recent[i], 'state')
+ except IndexError:
+ # Clean higher-order entries if they exist
+ CONF.remove_option('recent%i' % i, 'state')
config._CONFIG.save()
+ # Clear the menu
+ while self.OPEN_RECENT_MENU.GetMenuItemCount():
+ self.OPEN_RECENT_MENU.Delete(
+ self.OPEN_RECENT_MENU.FindItemByPosition(0))
+
+ # Update the menu to match our list
+ for i, fn in enumerate(recent):
+ mi = self.OPEN_RECENT_MENU.Append(wx.ID_ANY, fn.replace('&', '&&'))
+ self.Bind(wx.EVT_MENU, self._menu_open_recent, mi)
+
def _editor_page_changed(self, event):
self._editors.GetPage(event.GetSelection())
self._update_window_for_editor()
@@ -1088,7 +1080,6 @@ class ChirpMain(wx.Frame):
can_edit = False
is_memedit = False
is_bank = False
- CSVRadio = directory.get_radio('Generic_CSV')
if eset is not None:
is_live = isinstance(eset.radio, chirp_common.LiveRadio)
is_network = isinstance(eset.radio,
@@ -1096,9 +1087,7 @@ class ChirpMain(wx.Frame):
can_close = True
can_save = eset.modified and not is_live and not is_network
can_saveas = not is_live and not is_network
- can_upload = (not isinstance(eset.radio, CSVRadio) and
- not isinstance(eset.radio, common.LiveAdapter) and
- not is_live and not is_network)
+ can_upload = True
is_memedit = isinstance(eset.current_editor, memedit.ChirpMemEdit)
is_bank = isinstance(eset.current_editor, bankedit.ChirpBankEdit)
can_edit = not is_network
@@ -1328,7 +1317,6 @@ class ChirpMain(wx.Frame):
filename = self._do_open()
if filename is None:
return
- radio = directory.get_radio_by_image(filename)
d = wx.MessageDialog(
self,
_('The recommended procedure for importing memories is to open '
@@ -1343,7 +1331,10 @@ class ChirpMain(wx.Frame):
d.SetYesNoLabels(_('Import'), _('Open'))
r = d.ShowModal()
if r == wx.ID_YES:
- self.current_editorset.current_editor.memedit_import_all(radio)
+ with common.expose_logs(logging.WARNING, 'chirp.drivers',
+ _('Import messages')):
+ radio = directory.get_radio_by_image(filename)
+ self.current_editorset.current_editor.memedit_import_all(radio)
elif r == wx.ID_NO:
self.open_file(filename)
else:
@@ -1511,9 +1502,26 @@ class ChirpMain(wx.Frame):
def _menu_upload(self, event):
radio = self.current_editorset.radio
report.report_model(radio, 'upload')
- with clone.ChirpUploadDialog(radio, self) as d:
- d.Centre()
- d.ShowModal()
+ CSVRadio = directory.get_radio('Generic_CSV')
+
+ if isinstance(radio, chirp_common.LiveRadio):
+ msg = _('This is a live-mode radio, which means changes are '
+ 'sent to the radio in real-time as you make them. Upload '
+ 'is not necessary!')
+ d = wx.MessageDialog(self, msg, _('Live Radio'),
+ wx.ICON_INFORMATION)
+ elif isinstance(radio, (CSVRadio, base.NetworkResultRadio)):
+ msg = _('This is a radio-independent file and cannot be uploaded '
+ 'directly to a radio. Open a radio image (or download one '
+ 'from a radio) an then copy/paste items from this tab '
+ 'into that one in order to upload')
+ d = wx.MessageDialog(self, msg, _('Unable to upload this file'),
+ wx.ICON_INFORMATION)
+ else:
+ d = clone.ChirpUploadDialog(radio, self)
+
+ d.Centre()
+ d.ShowModal()
@common.error_proof()
def _menu_reload_driver(self, event, andfile=False):
@@ -1706,6 +1714,11 @@ class ChirpMain(wx.Frame):
common.reveal_location(dst)
@common.error_proof()
+ def _menu_backup_loc(self, event):
+ backup_dir = chirp_platform.get_platform().config_file('backups')
+ common.reveal_location(backup_dir)
+
+ @common.error_proof()
def _menu_load_from_issue(self, event):
module = developer.IssueModuleLoader(self).run()
if module:
diff --git a/chirp/wxui/memedit.py b/chirp/wxui/memedit.py
index c904326..540643d 100644
--- a/chirp/wxui/memedit.py
+++ b/chirp/wxui/memedit.py
@@ -35,6 +35,7 @@ from chirp.wxui import config
from chirp.wxui import common
from chirp.wxui import developer
+_ = wx.GetTranslation
LOG = logging.getLogger(__name__)
CONF = config.get()
WX_GTK = 'gtk' in wx.version().lower()
@@ -72,8 +73,28 @@ class ChirpRowLabelRenderer(glr.GridDefaultRowLabelRenderer):
self.DrawText(grid, dc, rect, text, hAlign, vAlign)
+DEFAULT_COLUMN_HELP = {
+ 'freq': _('Receive frequency'),
+ 'name': _('Memory label (stored in radio)'),
+ 'tmode': _('Tone squelch mode'),
+ 'rtone': _('Transmit tone'),
+ 'ctone': _('Transmit/receive tone for TSQL mode, else receive tone'),
+ '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)'),
+ 'cross_mode': _('Complex or non-standard tone squelch mode '
+ '(starts the tone mode selection wizard)'),
+ 'duplex': _('Transmit shift, split mode, or transmit inhibit'),
+ 'offset': _('Shift amount (or transmit frequency) controlled by duplex'),
+ 'tuning_step': _('Frequency granularity in kHz'),
+ 'skip': _('Scan control (skip, include, priority, etc)'),
+ 'power': _('Transmit Power'),
+ 'comment': _('Human-readable comment (not stored in radio)'),
+}
+
+
class ChirpMemoryColumn(object):
- DEFAULT = ''
+ DEFAULT: object = ''
def __init__(self, name, radio, label=None):
"""
@@ -84,12 +105,21 @@ class ChirpMemoryColumn(object):
self._label = label or _(name.title())
self._radio = radio
self._features = radio.get_features()
+ self._doc = None
@property
def name(self):
return self._name
@property
+ def doc(self):
+ return self._doc or DEFAULT_COLUMN_HELP.get(self.name)
+
+ @doc.setter
+ def doc(self, value):
+ self._doc = value
+
+ @property
def label(self):
labelwords = self._label.replace('_', ' ').split(' ')
middle = len(labelwords) // 2
@@ -130,7 +160,7 @@ class ChirpMemoryColumn(object):
def value(self, memory):
if '.' in self._name:
- parent, child = self._name.split('.')
+ parent, child = self._name.split('.', 1)
try:
return getattr(memory, parent)[child].value
except (AttributeError, KeyError):
@@ -151,7 +181,7 @@ class ChirpMemoryColumn(object):
def digest_value(self, memory, input_value):
if '.' in self._name:
- parent, child = self._name.split('.')
+ parent, child = self._name.split('.', 1)
try:
getattr(memory, parent)[child].value = self._digest_value(
memory, input_value)
@@ -348,7 +378,7 @@ class ChirpToneColumn(ChirpChoiceColumn):
def __init__(self, name, radio):
self.rf = radio.get_features()
tones = self.rf.valid_tones or chirp_common.TONES
- tones = [str(x) for x in tones]
+ tones = [str(x) for x in sorted(tones)]
super(ChirpToneColumn, self).__init__(name, radio,
tones)
@@ -443,7 +473,7 @@ class ChirpDTCSColumn(ChirpChoiceColumn):
def __init__(self, name, radio):
rf = radio.get_features()
codes = rf.valid_dtcs_codes or chirp_common.DTCS_CODES
- dtcs_codes = ['%03i' % code for code in codes]
+ dtcs_codes = ['%03i' % code for code in sorted(codes)]
super(ChirpDTCSColumn, self).__init__(name, radio,
dtcs_codes)
@@ -519,7 +549,7 @@ class ChirpCrossModeColumn(ChirpChoiceColumn):
@property
def label(self):
- return _('Cross mode')
+ return _('Cross Mode')
def hidden_for(self, memory):
return memory.tmode != 'Cross'
@@ -558,6 +588,8 @@ def get_column_for_extra(radio, setting):
label=label)
elif isinstance(value, settings.RadioSettingValueBoolean):
return ChirpFlagColumn(field, radio, label=label)
+ elif isinstance(value, settings.RadioSettingValueInteger):
+ return ChirpMemoryColumn(field, radio, label=label)
class ChirpMemoryDropTarget(wx.DropTarget):
@@ -680,6 +712,8 @@ class ChirpMemEdit(common.ChirpEditor, common.ChirpSyncEditor):
row_labels.Bind(wx.EVT_LEFT_DOWN, self._row_click)
row_labels.Bind(wx.EVT_LEFT_UP, self._row_click)
row_labels.Bind(wx.EVT_MOTION, self._rowheader_mouseover)
+ col_labels = self._grid.GetGridColLabelWindow()
+ col_labels.Bind(wx.EVT_MOTION, self._colheader_mouseover)
self._dragging_rows = None
self._dc = wx.ScreenDC()
@@ -759,6 +793,12 @@ class ChirpMemEdit(common.ChirpEditor, common.ChirpSyncEditor):
self._dragging_rows = None
return self._memory_drag(event)
+ def _colheader_mouseover(self, event):
+ x, y = self._grid.CalcUnscrolledPosition(event.GetX(), event.GetY())
+ _row, cell = self._grid.XYToCell(x, y)
+ col = self._col_defs[cell]
+ event.GetEventObject().SetToolTip(col.doc or None)
+
def _memory_drag(self, event):
data = self.cb_copy_getdata()
ds = wx.DropSource(self)
@@ -934,6 +974,8 @@ class ChirpMemEdit(common.ChirpEditor, common.ChirpSyncEditor):
self._extra_cols.add(setting.get_name())
col = get_column_for_extra(self._radio, setting)
if col:
+ col.doc = (setting.__doc__
+ if setting.__doc__ != setting.get_name() else None)
LOG.debug('Adding mem.extra column %s as %s',
setting.get_name(), col.__class__.__name__)
# We insert extra columns in front of the comment column, which
@@ -1141,7 +1183,7 @@ class ChirpMemEdit(common.ChirpEditor, common.ChirpSyncEditor):
# Build our row label renderers so we can set colors to
# indicate success or failure
self._row_label_renderers = []
- for row, _ in enumerate(
+ for row, _num in enumerate(
range(lower,
upper + len(self._features.valid_special_chans) + 1)):
self._row_label_renderers.append(ChirpRowLabelRenderer())
@@ -1407,13 +1449,13 @@ class ChirpMemEdit(common.ChirpEditor, common.ChirpSyncEditor):
warnings, errors = chirp_common.split_validation_msgs(
self._radio.validate_memory(mem))
if errors:
- LOG.warning('Memory failed validation: %s' % mem)
+ LOG.warning('Memory failed validation: %r', mem)
wx.MessageBox(_('Invalid edit: %s') % '; '.join(errors),
_('Invalid Entry'))
event.Skip()
return
if warnings:
- LOG.warning('Memory validation had warnings: %s' % mem)
+ LOG.warning('Memory validation had warnings: %r', mem)
wx.MessageBox(_('Warning: %s') % '; '.join(warnings),
_('Warning'))
@@ -1460,6 +1502,13 @@ class ChirpMemEdit(common.ChirpEditor, common.ChirpSyncEditor):
for row in rows:
if not self._memory_cache[row].empty:
self.delete_memory_at(row, event)
+ elif row in self._memory_errors:
+ LOG.warning('Attempting to clear memory error '
+ '%r for memory %i at row %i with delete',
+ self._memory_errors[row], self.row2mem(row), row)
+ self.delete_memory_at(row, event)
+ else:
+ LOG.debug('Not re-deleting empty memory at row %i', row)
if not shift_up:
return
@@ -1508,7 +1557,7 @@ class ChirpMemEdit(common.ChirpEditor, common.ChirpSyncEditor):
def _do_sort_memories(self, rows, reverse, sortattr):
memories = [self._memory_cache[r] for r in rows]
LOG.debug('Sorting %s by %s%s',
- memories, reversed and '>' or '<', sortattr)
+ memories, reverse and '>' or '<', sortattr)
memories.sort(key=lambda m: getattr(m, sortattr), reverse=reverse)
for i, mem in enumerate(memories):
new_number = self.row2mem(rows[0] + i)
@@ -1961,8 +2010,7 @@ class ChirpMemEdit(common.ChirpEditor, common.ChirpSyncEditor):
def cb_delete(self):
selected_rows = self.get_selected_rows_safe()
- for row in selected_rows:
- self.delete_memory_at(row, None)
+ self._delete_memories_at(selected_rows, None)
def get_selected_rows_safe(self):
"""Return the currently-selected rows
@@ -2256,7 +2304,7 @@ class ChirpMemPropDialog(wx.Dialog):
msgs = self._radio.validate_memory(mem)
if msgs:
wx.MessageBox(_('Invalid edit: %s') % '; '.join(msgs),
- 'Invalid Entry')
+ 'Invalid Entry', parent=self)
raise errors.InvalidValueError()
def _button(self, event):
diff --git a/chirp/wxui/query_sources.py b/chirp/wxui/query_sources.py
index 7aff99e..829d6d8 100644
--- a/chirp/wxui/query_sources.py
+++ b/chirp/wxui/query_sources.py
@@ -31,6 +31,7 @@ from chirp.sources import przemienniki
from chirp.wxui import common
from chirp.wxui import config
+_ = wx.GetTranslation
CONF = config.get()
LOG = logging.getLogger(__name__)
QueryThreadEvent, EVT_QUERY_THREAD = wx.lib.newevent.NewCommandEvent()
@@ -651,7 +652,9 @@ class RRQueryDialog(QuerySourceDialog):
"<small>Premium account required</small>")
def get_link(self):
- return 'https://www.radioreference.com/apps/content/?cid=3'
+ return (
+ 'https://support.radioreference.com/hc/en-us/articles/'
+ '18860633200276-Programming-Using-the-RadioReference-Web-Service')
def _add_grid(self, grid, label, widget):
grid.Add(wx.StaticText(widget.GetParent(), label=label),
@@ -692,7 +695,7 @@ class RRQueryDialog(QuerySourceDialog):
def _call_validations(self, parent):
if parent == self:
- # If we're calling valiations at the top-level, redirect that to
+ # If we're calling validations at the top-level, redirect that to
# the start of our country-specific widgets, based on whatever tab
# is selected. This avoids trying to validate US things when
# Canada is selected and so on.
@@ -811,7 +814,7 @@ class RRQueryDialog(QuerySourceDialog):
def _selected_county(self, chosencounty):
self._ca_county_id = 0
- for _, prov, cid, county in radioreference.CA_COUNTIES:
+ for _u, _prov, cid, county in radioreference.CA_COUNTIES:
if county == chosencounty:
self._ca_county_id = cid
break
diff --git a/chirp/wxui/radioinfo.py b/chirp/wxui/radioinfo.py
index 8b7f3e9..abf99f0 100644
--- a/chirp/wxui/radioinfo.py
+++ b/chirp/wxui/radioinfo.py
@@ -37,6 +37,7 @@ class ChirpRadioInfo(common.ChirpEditor, common.ChirpSyncEditor):
self._add_features_group()
self._add_vendor()
self._add_metadata()
+ self._add_driver()
def _add_features_group(self):
pg = wx.propgrid.PropertyGrid(
@@ -55,6 +56,26 @@ class ChirpRadioInfo(common.ChirpEditor, common.ChirpSyncEditor):
pg.Sort()
+ def _add_driver(self):
+ pg = wx.propgrid.PropertyGrid(
+ self, style=wx.propgrid.PG_SPLITTER_AUTO_CENTER)
+ self._group_control.AddPage(pg, _('Driver'))
+
+ try:
+ rclass = self._radio._orig_rclass
+ except AttributeError:
+ rclass = self._radio.__class__
+
+ p = wx.propgrid.StringProperty('class', 'class',
+ rclass.__name__)
+ p.Enable(False)
+ pg.Append(p)
+ p = wx.propgrid.StringProperty('module', 'module',
+ rclass.__module__)
+ p.Enable(False)
+ pg.Append(p)
+ pg.Sort()
+
def _add_vendor(self):
# This should really be an interface on the radio, but there
# is only one example for the moment, so just cheat.
diff --git a/chirp/wxui/settingsedit.py b/chirp/wxui/settingsedit.py
index 0b6879c..944ec1a 100644
--- a/chirp/wxui/settingsedit.py
+++ b/chirp/wxui/settingsedit.py
@@ -13,6 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import copy
import logging
import wx
@@ -95,7 +96,8 @@ class ChirpSettingsEdit(common.ChirpEditor):
self._group_control.AddPage(propgrid, group.get_shortname())
for element in group.values():
- if not isinstance(element, settings.RadioSetting):
+ if not isinstance(element, (settings.RadioSetting,
+ settings.RadioSettingSubGroup)):
self._add_group(element,
parent=self._group_control.FindPage(propgrid))
@@ -116,13 +118,8 @@ class ChirpSettingsEdit(common.ChirpEditor):
values = [setting.value]
for j, value in enumerate(values):
if not value.get_mutable():
- LOG.debug('Skipping immutable setting %r' % (
- setting.get_name()))
+ # Do not update immutable settings
continue
- LOG.debug('Setting %s:%s[%i]=%r' % (page.name,
- setting.get_name(),
- j,
- val))
realname, index = name.split(common.INDEX_CHAR)
prop = page.propgrid.GetProperty(name)
if not prop:
@@ -161,10 +158,28 @@ class ChirpSettingsEdit(common.ChirpEditor):
self.refresh()
self.selected()
+ def _remove_dead_settings(self, root):
+ """Remove any settings that are immutable or uninitialized"""
+ for e in root.values():
+ if isinstance(e, settings.RadioSetting):
+ # Immutable and uninitialized settings don't get sent to the
+ # radio
+ if not e.value.get_mutable():
+ LOG.debug('Skipping immutable %s', e.get_name())
+ del root[e]
+ elif not e.value.initialized:
+ LOG.debug('Skipping uninitialized %s', e.get_name())
+ del root[e]
+ elif isinstance(e, settings.RadioSettingGroup):
+ self._remove_dead_settings(e)
+
def _changed(self, event):
if not self._apply_settings():
return
- self.do_radio(self._set_settings_cb, 'set_settings', self._settings)
+ settings = copy.deepcopy(self._settings)
+ for g in settings:
+ self._remove_dead_settings(g)
+ self.do_radio(self._set_settings_cb, 'set_settings', settings)
wx.PostEvent(self, common.EditorChanged(self.GetId()))
if self._propgrid.needs_reload:
LOG.warning('Settings grid needs a reload')
diff --git a/requirements.txt b/requirements.txt
index 3578402..8c2d059 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -2,7 +2,6 @@ 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
-future
requests
pywin32; platform_system=="Windows"
suds
diff --git a/setup.py b/setup.py
index 453813f..e773da1 100644
--- a/setup.py
+++ b/setup.py
@@ -5,14 +5,13 @@ setup(name='chirp',
description='A cross-platform cross-radio programming tool',
packages=find_packages(include=["chirp*"]),
include_package_data=True,
- version='20240122',
+ version='20240224',
url='https://chirp.danplanet.com',
python_requires=">=3.7,<4",
install_requires=[
'pyserial',
'requests',
'six',
- 'future',
'importlib-resources;python_version<"3.10"',
'yattag',
],
diff --git a/tests/Python3_Driver_Testing.md b/tests/Python3_Driver_Testing.md
index 7002a10..a7864a1 100644
--- a/tests/Python3_Driver_Testing.md
+++ b/tests/Python3_Driver_Testing.md
@@ -62,6 +62,7 @@
| <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_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_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 | |
| <a name="Baofeng_UV-17ProGPS"></a> Baofeng_UV-17ProGPS | [@vdwel](https://github.com/vdwel) | 27-Nov-2023 | Yes | |
@@ -79,7 +80,7 @@
| <a name="Baofeng_W31E"></a> Baofeng_W31E | [@KC9HI](https://github.com/KC9HI) | 14-Aug-2023 | Yes | |
| <a name="Baojie_BJ-218"></a> Baojie_BJ-218 | [Implied by LUITON_LT-725UV](#user-content-LUITON_LT-725UV) | 16-Feb-2023 | Yes | 0.29% |
| <a name="Baojie_BJ-318"></a> Baojie_BJ-318 | [@KC9HI](https://github.com/KC9HI) | 2-Jan-2023 | Yes | 0.10% |
-| <a name="Baojie_BJ-9900"></a> Baojie_BJ-9900 | | | | 0.02% |
+| <a name="Baojie_BJ-9900"></a> Baojie_BJ-9900 | | | Yes | 0.02% |
| <a name="Baojie_BJ-UV55"></a> Baojie_BJ-UV55 | | | Yes | 0.03% |
| <a name="Boblov_X3Plus"></a> Boblov_X3Plus | | | | 0.02% |
| <a name="Boristone_8RS"></a> Boristone_8RS | [Implied by Radtel_RT-490](#user-content-Radtel_RT-490) | 11-Nov-2023 | Yes | 0.00% |
@@ -153,6 +154,7 @@
| <a name="Kenwood_TH-D72_live_mode"></a> Kenwood_TH-D72_live_mode | [@kk7ds](https://github.com/kk7ds) | 21-Oct-2022 | Yes | 0.00% |
| <a name="Kenwood_TH-D74_clone_mode"></a> Kenwood_TH-D74_clone_mode | [@kk7ds](https://github.com/kk7ds) | 30-Nov-2022 | Yes | 0.00% |
| <a name="Kenwood_TH-D74_live_mode"></a> Kenwood_TH-D74_live_mode | [@kk7ds](https://github.com/kk7ds) | 20-Oct-2022 | Yes | 0.00% |
+| <a name="Kenwood_TH-D75"></a> Kenwood_TH-D75 | [Reported working](https://chirp.danplanet.com/issues/11122) | 114-Feb-2024 | Yes | |
| <a name="Kenwood_TH-D7G"></a> Kenwood_TH-D7G | [Probably works](https://github.com/kk7ds/chirp/blob/py3/chirp/drivers/kenwood_live.py) | 12-Dec-2022 | Yes | 0.00% |
| <a name="Kenwood_TH-F6"></a> Kenwood_TH-F6 | [@KC9HI](https://github.com/KC9HI) | 30-Nov-2022 | Yes | 0.03% |
| <a name="Kenwood_TH-F7"></a> Kenwood_TH-F7 | [@sv1](https://github.com/sv1) | 19-Oct-2022 | Yes | 0.03% |
@@ -230,8 +232,11 @@
| <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="Leixen_VV-898"></a> Leixen_VV-898 | [Implied by Jetstream_JT270MH](#user-content-Jetstream_JT270MH) | 13-Dec-2022 | Yes | 0.18% |
-| <a name="Leixen_VV-898S"></a> Leixen_VV-898S | [@READ10](https://github.com/READ10) | 19-Dec-2022 | Yes | 0.10% |
+| <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 | |
+| <a name="Leixen_VV-898S"></a> Leixen_VV-898S | [@READ10](https://github.com/READ10) | 19-Dec-2022 | Yes | 0.08% |
+| <a name="Leixen_VV-898S_Dual_Bank"></a> Leixen_VV-898S_Dual_Bank | [Reported working](https://chirp.danplanet.com/issues/4069) | 10-Feb-2024 | Yes | |
| <a name="MMLradio_JC-8629"></a> MMLradio_JC-8629 | [@KC9HI](https://github.com/KC9HI) | 11-Nov-2023 | Yes | 0.01% |
| <a name="MTC_UV-5R-3"></a> MTC_UV-5R-3 | [Implied by BTECH_UV-5X3](#user-content-BTECH_UV-5X3) | 9-Dec-2022 | Yes | 0.02% |
| <a name="Maverick_RA-100"></a> Maverick_RA-100 | [@cetinajero](https://github.com/cetinajero) | 7-Jul-2023 | Yes | |
@@ -255,6 +260,7 @@
| <a name="QYT_KT980PLUS"></a> QYT_KT980PLUS | [Implied by BTECH_UV-25X2](#user-content-BTECH_UV-25X2) | 11-Nov-2022 | Yes | 0.09% |
| <a name="Quansheng_TG-UV2+"></a> Quansheng_TG-UV2+ | [Reported working](https://chirp.danplanet.com/issues/10398) | 26-Feb-2023 | Yes | 0.05% |
| <a name="Quansheng_UV-K5"></a> Quansheng_UV-K5 | [@sq5bpf](https://github.com/sq5bpf) | 29-May-2023 | Yes | |
+| <a name="Quansheng_UV-K5_egzumer"></a> Quansheng_UV-K5_egzumer | [@egzumer](https://github.com/egzumer) | 23-Jan-2024 | Yes | |
| <a name="RT_Systems_CSV"></a> RT_Systems_CSV | | | | |
| <a name="Radioddity_DB25-G"></a> Radioddity_DB25-G | [@KC9HI](https://github.com/KC9HI) | 11-Nov-2022 | Yes | 0.17% |
| <a name="Radioddity_GA-2S"></a> Radioddity_GA-2S | [@KC9HI](https://github.com/KC9HI) | 4-Dec-2022 | Yes | 0.19% |
@@ -370,6 +376,7 @@
| <a name="TYT_TH9000_220"></a> TYT_TH9000_220 | [Implied by Retevis_RT9000D_220-260](#user-content-Retevis_RT9000D_220-260) | 8-Dec-2022 | Yes | 0.04% |
| <a name="TYT_TH9000_440"></a> TYT_TH9000_440 | [Implied by Retevis_RT9000D_400-490](#user-content-Retevis_RT9000D_400-490) | 8-Dec-2022 | Yes | 0.04% |
| <a name="Talkpod_A36plus"></a> Talkpod_A36plus | [@KC9HI](https://github.com/KC9HI) | 12-Jun-2023 | Yes | |
+| <a name="Talkpod_A36plus_8w"></a> Talkpod_A36plus_8w | [@KC9HI](https://github.com/KC9HI) | 16-Feb-2024 | Yes | |
| <a name="Vertex_Standard_FTL-1011"></a> Vertex_Standard_FTL-1011 | | | | 0.02% |
| <a name="Vertex_Standard_FTL-2011"></a> Vertex_Standard_FTL-2011 | | | | 0.05% |
| <a name="Vertex_Standard_FTL-7011"></a> Vertex_Standard_FTL-7011 | | | | 0.03% |
@@ -445,11 +452,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:** 442
+**Drivers:** 449
-**Tested:** 88% (389/53) (93% of usage stats)
+**Tested:** 87% (395/54) (93% of usage stats)
-**Byte clean:** 90% (402/40)
+**Byte clean:** 91% (410/39)
## Meaning of this testing
diff --git a/tests/__pycache__/test_detect.cpython-310-pytest-7.1.3.pyc b/tests/__pycache__/test_detect.cpython-310-pytest-7.1.3.pyc
index 76b5d2a..d6df127 100644
--- a/tests/__pycache__/test_detect.cpython-310-pytest-7.1.3.pyc
+++ b/tests/__pycache__/test_detect.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 1bcf167..963e1f1 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/images/BTECH_UV-25X2.img b/tests/images/BTECH_UV-25X2.img
index aec97d8..c9f47c1 100644
--- a/tests/images/BTECH_UV-25X2.img
+++ b/tests/images/BTECH_UV-25X2.img
Binary files differ
diff --git a/tests/images/BTECH_UV-50X2.img b/tests/images/BTECH_UV-50X2.img
index 6bac4fb..d772c74 100644
--- a/tests/images/BTECH_UV-50X2.img
+++ b/tests/images/BTECH_UV-50X2.img
Binary files differ
diff --git a/tests/images/BTECH_UV-5X3.img b/tests/images/BTECH_UV-5X3.img
index aa6ad8a..7c1bc11 100644
--- a/tests/images/BTECH_UV-5X3.img
+++ b/tests/images/BTECH_UV-5X3.img
Binary files differ
diff --git a/tests/images/Baofeng_5RM.img b/tests/images/Baofeng_5RM.img
index 8cff8e8..a8fe738 100644
--- a/tests/images/Baofeng_5RM.img
+++ b/tests/images/Baofeng_5RM.img
Binary files differ
diff --git a/tests/images/Baofeng_UV-13Pro.img b/tests/images/Baofeng_UV-13Pro.img
new file mode 100644
index 0000000..2382e67
--- /dev/null
+++ b/tests/images/Baofeng_UV-13Pro.img
Binary files differ
diff --git a/tests/images/Kenwood_TH-D75.img b/tests/images/Kenwood_TH-D75.img
new file mode 100644
index 0000000..39a7c28
--- /dev/null
+++ b/tests/images/Kenwood_TH-D75.img
Binary files differ
diff --git a/tests/images/Leixen_VV-898S.img b/tests/images/Leixen_VV-898S.img
index 10a264a..9196ebc 100644
--- a/tests/images/Leixen_VV-898S.img
+++ b/tests/images/Leixen_VV-898S.img
Binary files differ
diff --git a/tests/images/Quansheng_UV-K5.img b/tests/images/Quansheng_UV-K5.img
index 4bdae31..8c7e36e 100644
--- a/tests/images/Quansheng_UV-K5.img
+++ b/tests/images/Quansheng_UV-K5.img
Binary files differ
diff --git a/tests/images/Quansheng_UV-K5_egzumer.img b/tests/images/Quansheng_UV-K5_egzumer.img
new file mode 100644
index 0000000..cf67ba4
--- /dev/null
+++ b/tests/images/Quansheng_UV-K5_egzumer.img
Binary files differ
diff --git a/tests/images/Retevis_RA79.img b/tests/images/Retevis_RA79.img
index 41cc21a..0ca8019 100644
--- a/tests/images/Retevis_RA79.img
+++ b/tests/images/Retevis_RA79.img
Binary files differ
diff --git a/tests/images/Talkpod_A36plus_8w.img b/tests/images/Talkpod_A36plus_8w.img
new file mode 100644
index 0000000..166d9a5
--- /dev/null
+++ b/tests/images/Talkpod_A36plus_8w.img
Binary files differ
diff --git a/tests/py3_driver_testers.txt b/tests/py3_driver_testers.txt
index 59f2bb9..d4a1d05 100644
--- a/tests/py3_driver_testers.txt
+++ b/tests/py3_driver_testers.txt
@@ -77,6 +77,7 @@ Baofeng_UV-82HP,@KC9HI,18-Nov-2022
Baofeng_UV-82WP,@KC9HI,3-Dec-2022
Baofeng_UV-9G,@KC9HI,3-Dec-2022
Baofeng_UV-9R,@KC9HI,3-Dec-2022
+Baofeng_UV-13Pro,@vdwel,21-Feb-2024
Baofeng_UV-17,@vdwel,27-Nov-2023
Baofeng_UV-17Pro,@vdwel,27-Nov-2023
Baofeng_UV-17ProGPS,@vdwel,27-Nov-2023
@@ -144,6 +145,7 @@ Kenwood_TH-D72_clone_mode,@kk7ds,28-Nov-2022
Kenwood_TH-D72_live_mode,@kk7ds,21-Oct-2022
Kenwood_TH-D74_clone_mode,@kk7ds,30-Nov-2022
Kenwood_TH-D74_live_mode,@kk7ds,20-Oct-2022
+Kenwood_TH-D75,#11122,114-Feb-2024
Kenwood_TH-F6,@KC9HI,30-Nov-2022
Kenwood_TH-F7,@sv1,19-Oct-2022
Kenwood_TH-G71,*kenwood_live,12-Dec-2022
@@ -201,6 +203,8 @@ Kenwood_TK-868,+Kenwood_TK-760,5-Dec-2022
Kenwood_TS-2000,ZS6CRW,10-Jan-2022
Leixen_VV-898,+Jetstream_JT270MH,13-Dec-2022
Leixen_VV-898S,@READ10,19-Dec-2022
+Leixen_VV-898S_Dual_Bank,#4069,10-Feb-2024
+Leixen_VV-898E_Dual_Bank,+Leixen_VV-898S_Dual_Bank,10-Feb-2024
LUITON_LT-316,+Retevis_RT22,9-Dec-2022
LUITON_LT-580_UHF,@KC9HI,8-Dec-2022
LUITON_LT-580_VHF,@KC9HI,8-Dec-2022
@@ -218,6 +222,7 @@ Q-MAC_HF-90_v300_or_earlier,@fthain,9-Mar-2023
Q-MAC_HF-90_v301_or_later,@fthain,9-Mar-2023
Quansheng_TG-UV2+,#10398,26-Feb-2023
Quansheng_UV-K5,@sq5bpf,29-May-2023
+Quansheng_UV-K5_egzumer,@egzumer,23-Jan-2024
QYT_KT-8R,@KC9HI,11-Nov-2022
QYT_KT-UV980,+WACCOM_MINI-8900,11-Nov-2022
QYT_KT-WP12,+Anysecu_WP-9900,11-Nov-2022
@@ -315,6 +320,7 @@ SenhaiX_8800,+Radioddity_GS-5B,17-Mar-2023
Socotran_FB-8629,+Radtel_RT-490,11-Nov-2023
Socotran_JC-8629,+Radtel_RT-490,11-Nov-2023
Talkpod_A36plus,@KC9HI,12-Jun-2023
+Talkpod_A36plus_8w,@KC9HI,16-Feb-2024
TDXone_TD-Q8A,@KC9HI,18-Dec-2022
TIDRADIO_TD-H6,@kk7ds,21-Oct-2022
TIDRADIO_TD-H8,@Sandmann34,7-Feb-2023
diff --git a/tests/test_brute_force.py b/tests/test_brute_force.py
index 0ab09f7..eb5ea9b 100644
--- a/tests/test_brute_force.py
+++ b/tests/test_brute_force.py
@@ -91,8 +91,7 @@ class TestCaseBruteForce(base.DriverTest):
if 'duplex' in m.immutable:
self.skipTest('Test memory has immutable duplex')
for duplex in self.rf.valid_duplexes:
- if duplex not in ["", "-", "+", "split"]:
- continue
+ assert duplex in ["", "-", "+", "split", "off"]
if duplex == 'split':
self.assertTrue(self.rf.can_odd_split,
'Radio supports split but does not set '
diff --git a/tests/test_detect.py b/tests/test_detect.py
index 5a94cb9..8acad47 100644
--- a/tests/test_detect.py
+++ b/tests/test_detect.py
@@ -5,12 +5,17 @@ from unittest import mock
import pytest
from chirp import directory
+from chirp import logger
from tests import base
class TestCaseDetect(base.DriverTest):
def test_detect(self):
- radio = directory.get_radio_by_image(self.TEST_IMAGE)
+ with logger.log_history(logging.WARNING, 'chirp.drivers') as history:
+ radio = directory.get_radio_by_image(self.TEST_IMAGE)
+ self.assertEqual([], history.get_history(),
+ 'Drivers should not log warnings/errors for '
+ 'good images')
if hasattr(radio, '_orig_rclass'):
radio = radio._orig_rclass(self.TEST_IMAGE)
if isinstance(self.radio, radio.__class__):
diff --git a/tests/test_edges.py b/tests/test_edges.py
index 2280819..a186e18 100644
--- a/tests/test_edges.py
+++ b/tests/test_edges.py
@@ -187,3 +187,10 @@ class TestBitwiseStrict(base.DriverTest):
side_effect=_raise)
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()
+ self.assertFalse(mock_log.called,
+ [x[0][0] for x in mock_log.call_args_list])
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 398ad6b..3efe7a5 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 3334195..b47cb93 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_csv.cpython-310-pytest-7.1.3.pyc b/tests/unit/__pycache__/test_csv.cpython-310-pytest-7.1.3.pyc
index b086c48..ef21a8e 100644
--- a/tests/unit/__pycache__/test_csv.cpython-310-pytest-7.1.3.pyc
+++ b/tests/unit/__pycache__/test_csv.cpython-310-pytest-7.1.3.pyc
Binary files differ
diff --git a/tests/unit/__pycache__/test_logger.cpython-310-pytest-7.1.3.pyc b/tests/unit/__pycache__/test_logger.cpython-310-pytest-7.1.3.pyc
new file mode 100644
index 0000000..b87c99b
--- /dev/null
+++ b/tests/unit/__pycache__/test_logger.cpython-310-pytest-7.1.3.pyc
Binary files differ
diff --git a/tests/unit/__pycache__/test_settings.cpython-310-pytest-7.1.3.pyc b/tests/unit/__pycache__/test_settings.cpython-310-pytest-7.1.3.pyc
index fad2d83..09c95b4 100644
--- a/tests/unit/__pycache__/test_settings.cpython-310-pytest-7.1.3.pyc
+++ b/tests/unit/__pycache__/test_settings.cpython-310-pytest-7.1.3.pyc
Binary files differ
diff --git a/tests/unit/test_bitwise.py b/tests/unit/test_bitwise.py
index f150886..9f40dcc 100644
--- a/tests/unit/test_bitwise.py
+++ b/tests/unit/test_bitwise.py
@@ -16,6 +16,7 @@
from builtins import bytes
import unittest
+from unittest import mock
import six
@@ -97,6 +98,26 @@ class TestBitwiseBaseIntTypes(BaseTest):
obj.foo[i] = i * 2
self.assertEqual(b'\x00\x02\x04\x06', data.get_packed())
+ def test_int_array_set_raw(self):
+ data = memmap.MemoryMapBytes(bytes(b'\x00\x01\x02\x03'))
+ obj = bitwise.parse('u8 foo[4];', data)
+ obj.foo.set_raw(b'\x09\x08\x07\x06')
+ self.assertEqual(9, obj.foo[0])
+ self.assertEqual(8, obj.foo[1])
+ self.assertEqual(7, obj.foo[2])
+ self.assertEqual(6, obj.foo[3])
+
+ obj = bitwise.parse('u16 foo[2];', data)
+ obj.foo.set_raw(b'\x00\x01\x00\x02')
+ self.assertEqual(1, obj.foo[0])
+ self.assertEqual(2, obj.foo[1])
+
+ with self.assertRaises(AssertionError):
+ obj.foo.set_raw(b'123')
+
+ with self.assertRaises(AssertionError):
+ obj.foo.set_raw(b'12345')
+
class TestBitfieldTypes(BaseTest):
def test_bitfield_u8(self):
@@ -302,6 +323,42 @@ class TestBitwiseStructTypes(BaseTest):
obj.set_raw('2')
self.assertEqual(b'2', data.get_packed())
+ @mock.patch.object(bitwise.LOG, 'error')
+ def test_struct_duplicate(self, mock_log):
+ bitwise.parse('struct\n{ u8 foo; u8 foo1:2, foo:4, foo3:2;} bar;',
+ memmap.MemoryMapBytes(b'\x00' * 128))
+ bitwise.parse('struct\n{ u8 foo; u8 foo;} bar;',
+ memmap.MemoryMapBytes(b'\x00' * 128))
+ bitwise.parse('struct\n{ u8 foo; u8 foo[2];} bar;',
+ memmap.MemoryMapBytes(b'\x00' * 128))
+ self.assertEqual(3, mock_log.call_count)
+
+ def test_struct_fill_raw(self):
+ data = memmap.MemoryMapBytes(bytes(b"..."))
+ defn = "struct { u8 bar; u16 baz; } foo;"
+ obj = bitwise.parse(defn, data)
+ obj.fill_raw(b'\xAA')
+ self.assertEqual(0xAA, obj.foo.bar)
+ self.assertEqual(0xAAAA, obj.foo.baz)
+ obj.foo.fill_raw(b'\xBB')
+ self.assertEqual(0xBB, obj.foo.bar)
+ self.assertEqual(0xBBBB, obj.foo.baz)
+ obj.foo.bar.fill_raw(b'\xCC')
+ self.assertEqual(0xCC, obj.foo.bar)
+ self.assertEqual(0xBBBB, obj.foo.baz)
+
+ self.assertRaises(AssertionError, obj.fill_raw, '1')
+ self.assertRaises(AssertionError, obj.fill_raw, b'AB')
+ self.assertRaises(AssertionError, obj.fill_raw, False)
+
+
+class TestBitwisePrintoffset(BaseTest):
+ @mock.patch.object(bitwise.LOG, 'debug')
+ def test_printoffset(self, mock_log):
+ defn = 'u8 foo; u16 bar; #printoffset "bar";'
+ bitwise.parse(defn, b"abcdZ")
+ mock_log.assert_called_once_with('bar: 3 (0x00000003)')
+
class TestBitwiseSeek(BaseTest):
def test_seekto(self):
@@ -339,3 +396,23 @@ class TestBitwiseStringEncoders(BaseTest):
def test_decode_bytes(self):
self.assertEqual('foobar\x00',
bitwise.string_straight_decode(b'foobar\x00'))
+
+
+class TestPath(BaseTest):
+ def test_get_path(self):
+ fmt = ("u8 foo;"
+ "u8 bar[2];"
+ "struct {"
+ " u8 foo;"
+ " u8 bar[2];"
+ " u8 baz1:4,"
+ " baz2:4;"
+ " struct {"
+ " u16 childitem;"
+ " } child;"
+ "} structure[2];")
+ obj = bitwise.parse(fmt, memmap.MemoryMapBytes(b'\x00' * 128))
+ obj.structure[0].bar[1] = 123
+ obj.structure[1].child.childitem = 456
+ self.assertEqual(123, obj.get_path('.structure[0].bar[1]'))
+ self.assertEqual(456, obj.get_path('structure[1].child.childitem'))
diff --git a/tests/unit/test_chirp_common.py b/tests/unit/test_chirp_common.py
index fb880c9..d0f22f9 100644
--- a/tests/unit/test_chirp_common.py
+++ b/tests/unit/test_chirp_common.py
@@ -762,7 +762,9 @@ class TestOverrideRules(base.BaseTest):
'BTECH_GMRS-V2',
'BTECH_MURS-V2',
'Radioddity_DB25-G',
- 'Retevis_RB17P'
+ 'Retevis_RB17P',
+ 'Baofeng_UV-17ProGPS',
+ 'Baofeng_5RM',
]
def _test_radio_override_immutable_policy(self, rclass):
diff --git a/tests/unit/test_csv.py b/tests/unit/test_csv.py
index 68bbcb9..c8428b0 100644
--- a/tests/unit/test_csv.py
+++ b/tests/unit/test_csv.py
@@ -72,6 +72,24 @@ class TestCSV(unittest.TestCase):
self.assertEqual('5.0W', str(mem.power))
self.assertIn('UHF calling', mem.comment)
+ def test_csv_with_comments(self):
+ lines = list(CHIRP_CSV_MODERN.strip().split('\n'))
+ lines.insert(0, '# This is a comment')
+ lines.insert(0, '# Test file with comments')
+ lines.insert(4, '# Test comment in the middle')
+ lines.append('# Comment at the end')
+ with open(self.testfn, 'w', newline='') as f:
+ f.write('\r\n'.join(lines))
+ csv = generic_csv.CSVRadio(self.testfn)
+ mem = csv.get_memory(0)
+ self.assertEqual(146520000, mem.freq)
+ mem = csv.get_memory(1)
+ self.assertEqual(446000000, mem.freq)
+ csv.save(self.testfn)
+ with open(self.testfn, 'r') as f:
+ read_lines = [x.strip() for x in f.readlines()]
+ self.assertEqual(lines, read_lines)
+
def test_parse_modern_bom(self):
self.test_parse_modern(output_encoding='utf-8-sig')
diff --git a/tests/unit/test_logger.py b/tests/unit/test_logger.py
new file mode 100644
index 0000000..e4c32a9
--- /dev/null
+++ b/tests/unit/test_logger.py
@@ -0,0 +1,38 @@
+import logging
+
+from chirp import logger
+from tests.unit import base
+
+
+class TestLogger(base.BaseTest):
+ def test_log_history(self):
+ drv_log = logging.getLogger('chirp.drivers.foo')
+ ui_log = logging.getLogger('chirp.wxui.foo')
+ root_log = logging.getLogger()
+
+ root_log.setLevel(logging.DEBUG)
+
+ def log_all():
+ for log in (drv_log, ui_log, root_log):
+ log.debug('debug')
+ log.warning('warning')
+ log.error('error')
+
+ # Log to everything
+ log_all()
+
+ with logger.log_history(logging.WARNING, 'chirp.drivers') as h:
+ log_all()
+ history = h.get_history()
+
+ # We should only have the error,warning messages from drivers
+ # since we started the capture, not before
+ self.assertEqual(2, len(history))
+
+ with logger.log_history(logging.WARNING, 'chirp.drivers') as h:
+ log_all()
+ history = h.get_history()
+
+ # Make sure we only have the captured logs, not any leftover from
+ # the previous run
+ self.assertEqual(2, len(history))
diff --git a/tests/unit/test_settings.py b/tests/unit/test_settings.py
index 108fb16..3712847 100644
--- a/tests/unit/test_settings.py
+++ b/tests/unit/test_settings.py
@@ -30,24 +30,28 @@ class TestSettingValues(base.BaseTest):
def test_radio_setting_value_integer(self):
value = settings.RadioSettingValueInteger(0, 10, 5)
+ value.initialize()
self.assertEqual(value.get_value(), 5)
self._set_and_test(value, 1, 0, 10)
self._set_and_catch(value, -1, 11)
def test_radio_setting_value_float(self):
value = settings.RadioSettingValueFloat(1.0, 10.5, 5.0)
+ value.initialize()
self.assertEqual(value.get_value(), 5.0)
self._set_and_test(value, 2.5, 1.0, 10.5)
self._set_and_catch(value, 0.9, 10.6, -1.5)
def test_radio_setting_value_boolean(self):
value = settings.RadioSettingValueBoolean(True)
+ value.initialize()
self.assertTrue(value.get_value())
self._set_and_test(value, True, False)
def test_radio_setting_value_list(self):
opts = ["Abc", "Def", "Ghi"]
value = settings.RadioSettingValueList(opts, "Abc")
+ value.initialize()
self.assertEqual(value.get_value(), "Abc")
self.assertEqual(int(value), 0)
self._set_and_test(value, "Def", "Ghi", "Abc")
@@ -57,6 +61,7 @@ class TestSettingValues(base.BaseTest):
def test_radio_setting_value_list_by_index(self):
opts = ["Abc", "Def", "Ghi"]
value = settings.RadioSettingValueList(opts, current_index=1)
+ value.initialize()
self.assertEqual(value.get_value(), "Def")
self.assertEqual(int(value), 1)
self._set_and_test(value, "Def", "Ghi", "Abc")
@@ -65,6 +70,7 @@ class TestSettingValues(base.BaseTest):
# Make sure we int() the index, as we may pass a bitwise object
value = settings.RadioSettingValueList(opts, current_index='1')
+ value.initialize()
self.assertEqual(value.get_value(), "Def")
value.set_index(0)
@@ -78,6 +84,7 @@ class TestSettingValues(base.BaseTest):
def test_radio_setting_value_string(self):
value = settings.RadioSettingValueString(1, 5, "foo", autopad=False)
+ value.initialize()
self.assertEqual(value.get_value(), "foo")
self.assertEqual(str(value), "foo")
self._set_and_test(value, "a", "abc", "abdef")
@@ -88,6 +95,7 @@ class TestSettingValues(base.BaseTest):
pass
value = settings.RadioSettingValueString(0, 5, "foo", autopad=False)
+ value.initialize()
def test_validate(val):
if val == "bar":
@@ -98,6 +106,7 @@ class TestSettingValues(base.BaseTest):
def test_changed(self):
value = settings.RadioSettingValueBoolean(False)
+ value.initialize()
self.assertFalse(value.changed())
value.set_value(False)
self.assertFalse(value.changed())
@@ -171,3 +180,10 @@ class TestSettingContainers(base.BaseTest):
for c in settings.BANNED_NAME_CHARACTERS:
self.assertRaises(settings.InvalidNameError,
settings.RadioSetting, "foo%sbar" % c, "Foo")
+
+ def test_setting_deferred(self):
+ val = settings.RadioSettingValueInteger(0, 10, 12)
+ rs = settings.RadioSetting('test', 'Test', val)
+ self.assertFalse(rs.value.initialized)
+ rs.value = 1
+ self.assertTrue(rs.value.initialized)
diff --git a/tools/check_commit.sh b/tools/check_commit.sh
index 84b69db..4a6d68d 100755
--- a/tools/check_commit.sh
+++ b/tools/check_commit.sh
@@ -34,7 +34,7 @@ if grep -E '\wfuture\w' added_lines; then
fail No new uses of future
fi
-if grep -E '(from|import).*past' added_lines; then
+if grep -E '(from|import).*past(?!e)' added_lines; then
fail Use of past library not allowed
fi
@@ -46,6 +46,10 @@ if grep -E "[^_]_\([^\"']" added_lines; then
fail 'Translated strings must be literals!'
fi
+if grep -E "eval\(" added_lines; then
+ fail 'Use of eval() is dangerous and not permitted!'
+fi
+
if git diff ${BASE}.. 'tools/cpep8.manifest' | tail -n +5 | grep -q '^+'; then
fail 'Do not add new files to cpep8.manifest; no longer needed'
fi
@@ -98,4 +102,6 @@ for nf in $added_py; do
done
done
+rm -f added_lines license_lines
+
exit $RETCODE