summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2019-12-30 13:46:42 +0100
committerChristoph Berg <myon@debian.org>2019-12-30 13:46:42 +0100
commit141c4b78d5a8be746a70ac0f4bf205a8f775c2bb (patch)
tree64cf3c3f5712a720475f51956650ada8f26e4a2f
parent68cb0c45ae8490db4dd6cc67f76b8389db06f513 (diff)
New upstream version 20191221upstream/20191221
-rw-r--r--PKG-INFO2
-rw-r--r--chirp/__init__.py2
-rw-r--r--chirp/drivers/baofeng_wp970i.py125
-rw-r--r--chirp/drivers/btech.py3
-rw-r--r--chirp/drivers/ft1500m.py235
-rw-r--r--chirp/drivers/ft2d.py10
-rw-r--r--chirp/drivers/ft4.py1
-rw-r--r--chirp/drivers/ftm350.py3
-rw-r--r--chirp/drivers/h777.py16
-rw-r--r--chirp/drivers/ic2730.py1
-rw-r--r--chirp/drivers/icf.py49
-rw-r--r--chirp/drivers/kenwood_live.py472
-rw-r--r--chirp/drivers/kguv8dplus.py1
-rw-r--r--chirp/drivers/kguv9dplus.py4
-rw-r--r--chirp/drivers/puxing_px888k.py1
-rw-r--r--chirp/drivers/radioddity_r2.py1
-rw-r--r--chirp/drivers/tk270.py1
-rw-r--r--chirp/drivers/tk8180.py1
-rw-r--r--chirp/drivers/ts480.py1144
-rw-r--r--chirp/drivers/ts590.py1684
-rw-r--r--chirp/drivers/uv5r.py15
-rw-r--r--chirp/drivers/wouxun.py2
-rw-r--r--stock_configs/US FRS and GMRS Channels.csv74
23 files changed, 3732 insertions, 115 deletions
diff --git a/PKG-INFO b/PKG-INFO
index c67e386..e2107b3 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: chirp
-Version: daily-20190718
+Version: daily-20191221
Summary: UNKNOWN
Home-page: UNKNOWN
Author: UNKNOWN
diff --git a/chirp/__init__.py b/chirp/__init__.py
index 8772324..acae797 100644
--- a/chirp/__init__.py
+++ b/chirp/__init__.py
@@ -17,7 +17,7 @@ import os
import sys
from glob import glob
-CHIRP_VERSION="daily-20190718"
+CHIRP_VERSION="daily-20191221"
module_dir = os.path.dirname(sys.modules["chirp"].__file__)
__all__ = []
diff --git a/chirp/drivers/baofeng_wp970i.py b/chirp/drivers/baofeng_wp970i.py
index 95949cd..7eb1fb2 100644
--- a/chirp/drivers/baofeng_wp970i.py
+++ b/chirp/drivers/baofeng_wp970i.py
@@ -19,8 +19,6 @@ import struct
import logging
import re
-LOG = logging.getLogger(__name__)
-
from chirp.drivers import baofeng_common
from chirp import chirp_common, directory, memmap
from chirp import bitwise, errors, util
@@ -31,7 +29,9 @@ from chirp.settings import RadioSettingGroup, RadioSetting, \
InvalidValueError
from textwrap import dedent
-##### MAGICS #########################################################
+LOG = logging.getLogger(__name__)
+
+# #### MAGICS #########################################################
# Baofeng WP970I magic string
MSTRING_WP970I = "\x50\xBB\xFF\x20\x14\x04\x13"
@@ -64,6 +64,7 @@ LIST_TXPOWER = ["High", "Mid", "Low"]
LIST_VOICE = ["Off", "English", "Chinese"]
LIST_WORKMODE = ["Frequency", "Channel"]
+
def model_match(cls, data):
"""Match the opened/downloaded image to the correct version"""
@@ -107,12 +108,13 @@ class WP970I(baofeng_common.BaofengCommonHT):
POWER_LEVELS = [chirp_common.PowerLevel("High", watts=5.00),
chirp_common.PowerLevel("Med", watts=3.00),
chirp_common.PowerLevel("Low", watts=1.00)]
- VALID_BANDS = [(130000000, 180000000),
- (400000000, 521000000)]
+ _vhf_range = (130000000, 180000000)
+ _uhf_range = (400000000, 521000000)
+ VALID_BANDS = [_vhf_range,
+ _uhf_range]
PTTID_LIST = LIST_PTTID
SCODE_LIST = LIST_SCODE
-
MEM_FORMAT = """
#seekto 0x0000;
struct {
@@ -141,19 +143,19 @@ class WP970I(baofeng_common.BaofengCommonHT):
u8 code[5];
u8 unused[11];
} pttid[15];
-
+
#seekto 0x0CAA;
struct {
- u8 code[5];
- u8 unused1:6,
- aniid:2;
- u8 unknown[2];
- u8 dtmfon;
- u8 dtmfoff;
- } ani;
-
- #seekto 0x0E20;
- struct {
+ u8 code[5];
+ u8 unused1:6,
+ aniid:2;
+ u8 unknown[2];
+ u8 dtmfon;
+ u8 dtmfoff;
+ } ani;
+
+ #seekto 0x0E20;
+ struct {
u8 squelch;
u8 step;
u8 unknown1;
@@ -206,17 +208,17 @@ class WP970I(baofeng_common.BaofengCommonHT):
u8 keylock;
} settings;
- #seekto 0x0E76;
- struct {
- u8 unused1:1,
- mrcha:7;
- u8 unused2:1,
- mrchb:7;
- } wmchannel;
-
- struct vfo {
- u8 unknown0[8];
- u8 freq[8];
+ #seekto 0x0E76;
+ struct {
+ u8 unused1:1,
+ mrcha:7;
+ u8 unused2:1,
+ mrchb:7;
+ } wmchannel;
+
+ struct vfo {
+ u8 unknown0[8];
+ u8 freq[8];
u8 offset[6];
ul16 rxtone;
ul16 txtone;
@@ -224,45 +226,45 @@ class WP970I(baofeng_common.BaofengCommonHT):
band:1;
u8 unknown3;
u8 unused2:2,
- sftd:2,
+ sftd:2,
scode:4;
- u8 unknown4;
+ u8 unknown4;
u8 unused3:1
- step:3,
- unused4:4;
+ step:3,
+ unused4:4;
u8 unused5:1,
widenarr:1,
- unused6:4,
- txpower3:2;
- };
-
- #seekto 0x0F00;
- struct {
+ unused6:4,
+ txpower3:2;
+ };
+
+ #seekto 0x0F00;
+ struct {
struct vfo a;
struct vfo b;
} vfo;
-
+
#seekto 0x0F4E;
u16 fm_presets;
-
+
#seekto 0x1000;
struct {
char name[7];
u8 unknown1[9];
} names[128];
-
+
#seekto 0x1ED0;
struct {
char line1[7];
char line2[7];
} sixpoweron_msg;
-
+
#seekto 0x1EE0;
struct {
char line1[7];
char line2[7];
} poweron_msg;
-
+
#seekto 0x1EF0;
struct {
char line1[7];
@@ -281,7 +283,7 @@ class WP970I(baofeng_common.BaofengCommonHT):
u8 sql8;
u8 sql9;
};
-
+
#seekto 0x1F60;
struct {
struct squelch vhf;
@@ -395,7 +397,7 @@ class WP970I(baofeng_common.BaofengCommonHT):
basic.append(rs)
rs = RadioSetting("settings.beep", "Beep",
- RadioSettingValueBoolean(_mem.settings.beep))
+ RadioSettingValueBoolean(_mem.settings.beep))
basic.append(rs)
if _mem.settings.timeout > 0x27:
@@ -497,7 +499,7 @@ class WP970I(baofeng_common.BaofengCommonHT):
val = _mem.settings.rpste
rs = RadioSetting("settings.rpste",
"Squelch Tail Eliminate (repeater)",
- RadioSettingValueList(
+ RadioSettingValueList(
LIST_RPSTE, LIST_RPSTE[val]))
basic.append(rs)
@@ -619,12 +621,12 @@ class WP970I(baofeng_common.BaofengCommonHT):
rs = RadioSetting("wmchannel.mrcha", "MR A Channel",
RadioSettingValueInteger(0, 127,
- _mem.wmchannel.mrcha))
+ _mem.wmchannel.mrcha))
work.append(rs)
rs = RadioSetting("wmchannel.mrchb", "MR B Channel",
RadioSettingValueInteger(0, 127,
- _mem.wmchannel.mrchb))
+ _mem.wmchannel.mrchb))
work.append(rs)
def convert_bytes_to_freq(bytes):
@@ -819,7 +821,8 @@ class WP970I(baofeng_common.BaofengCommonHT):
elif band == "uhf":
_obj = self._memobj.squelch.uhf
val = RadioSettingValueInteger(0, 123,
- getattr(_obj, "sql%i" % (index)))
+ getattr(
+ _obj, "sql%i" % (index)))
if index == 0:
val.set_mutable(False)
name = "%s Squelch %i" % (band.upper(), index)
@@ -845,10 +848,17 @@ class WP970I(baofeng_common.BaofengCommonHT):
else:
return False
+
class RH5XAlias(chirp_common.Alias):
VENDOR = "Rugged"
MODEL = "RH5X"
+
+class UV82IIIAlias(chirp_common.Alias):
+ VENDOR = "Baofeng"
+ MODEL = "UV-82III"
+
+
@directory.register
class BFA58(WP970I):
"""Baofeng BF-A58"""
@@ -858,20 +868,37 @@ class BFA58(WP970I):
_fileid = ["BFT515 ", "BFT517 "]
+
@directory.register
class UV82WP(WP970I):
"""Baofeng UV82-WP"""
VENDOR = "Baofeng"
MODEL = "UV-82WP"
+
@directory.register
class GT3WP(WP970I):
"""Baofeng GT-3WP"""
VENDOR = "Baofeng"
MODEL = "GT-3WP"
+
@directory.register
class RT6(WP970I):
"""Retevis RT6"""
VENDOR = "Retevis"
MODEL = "RT6"
+
+
+@directory.register
+class BFA58S(WP970I):
+ VENDOR = "Baofeng"
+ MODEL = "BF-A58S"
+ ALIASES = [UV82IIIAlias]
+
+ def get_features(self):
+ rf = WP970I.get_features(self)
+ rf.valid_bands = [self._vhf_range,
+ (200000000, 260000000),
+ self._uhf_range]
+ return rf
diff --git a/chirp/drivers/btech.py b/chirp/drivers/btech.py
index ac9f4c6..460c309 100644
--- a/chirp/drivers/btech.py
+++ b/chirp/drivers/btech.py
@@ -228,6 +228,7 @@ KT8900R_id2 = "\x05\x58\x3d\xf0\x10"
# KT7900D (quad band)
KT7900D_fp = "VC4004"
KT7900D_fp1 = "VC4284"
+KT7900D_fp2 = "VC4264"
# QB25 (quad band) - a clone of KT7900D
QB25_fp = "QB-25"
@@ -3817,7 +3818,7 @@ class KT7900D(BTechColor):
_uhf_range = (400000000, 481000000)
_350_range = (350000000, 371000000)
_magic = MSTRING_KT8900D
- _fileid = [KT7900D_fp, KT7900D_fp1, QB25_fp, ]
+ _fileid = [KT7900D_fp, KT7900D_fp1, KT7900D_fp2, QB25_fp, ]
# Clones
ALIASES = [SKT8900D, QB25, ]
diff --git a/chirp/drivers/ft1500m.py b/chirp/drivers/ft1500m.py
new file mode 100644
index 0000000..16778f4
--- /dev/null
+++ b/chirp/drivers/ft1500m.py
@@ -0,0 +1,235 @@
+# Copyright 2019 Josh Small VK2HFF <chirp@vk2hff.ampr.org>
+# - Derived from ./ft1802.py Copyright 2012 Tom Hayward <tom@tomh.us>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# FT-1500M Clone Proceedure
+# 1. Turn radio off.
+# 2. Connect cable to mic jack.
+# 3. Press and hold in the [MHz],[LOW] and [D/MR] keys
+# while turning the radio on.
+# 4. In Chirp, choose Download from Radio.
+# 5. Press the [MHz(SET)] key to send image.
+# or
+# 4. Press the [D/MR(MW)] key ("--WAIT--" will appear on the LCD).
+# 5. In Chirp, choose Upload to Radio.
+
+from chirp.drivers import yaesu_clone
+from chirp import chirp_common, bitwise, directory
+from chirp.settings import RadioSetting, RadioSettingGroup, \
+ RadioSettingValueBoolean, RadioSettings
+from textwrap import dedent
+
+MEM_FORMAT = """
+#seekto 0x002a;
+struct {
+ u8 unknown_f:4,
+ pskip:1,
+ skip:1,
+ visible:1,
+ valid:1;
+} flags[130];
+
+#seekto 0x00ca;
+struct {
+ u8 unknown1a:2,
+ narrow:1,
+ clk_shift:1,
+ unknown1b:4;
+ u8 unknown2a:3,
+ unknown2b:2,
+ tune_step:3;
+ bbcd freq[3];
+ u8 tone;
+ u8 name[6];
+ u8 unknown3;
+ u8 offset;
+ u8 unknown4a:1,
+ unknown4b:1,
+ unknown4c:2,
+ unknown4d:4;
+ u8 unknown5a:2,
+ tmode:2,
+ power:2,
+ duplex:2;
+} memory[130];
+"""
+
+
+MODES = ["FM", "NFM"]
+TMODES = ["", "Tone", "TSQL"]
+DUPLEX = ["", "-", "+"]
+STEPS = [5.0, 10.0, 12.5, 15.0, 20.0, 25.0, 50.0, 100.0]
+POWER_LEVELS = [chirp_common.PowerLevel("LOW1", watts=5),
+ chirp_common.PowerLevel("LOW2", watts=10),
+ chirp_common.PowerLevel("LOW3", watts=25),
+ chirp_common.PowerLevel("HIGH", watts=50),
+ ]
+CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ +-/?()?_"
+
+
+@directory.register
+class FT1500Radio(yaesu_clone.YaesuCloneModeRadio):
+ """Yaesu FT-1500M"""
+ VENDOR = "Yaesu"
+ MODEL = "FT-1500M"
+ BAUD_RATE = 9600
+
+ _model = "AH4N0"
+ _block_lengths = [10, 16, 3953]
+ _memsize = 3979
+
+ @classmethod
+ def get_prompts(cls):
+ rp = chirp_common.RadioPrompts()
+ rp.pre_download = _(dedent("""\
+1. Turn radio off.
+2. Connect cable to mic jack.
+3. Press and hold in the [MHz], [LOW], and [D/MR] keys
+ while turning the radio on.
+4. <b>After clicking OK</b>, press the [MHz(SET)] key to send image."""))
+ rp.pre_upload = _(dedent("""\
+1. Turn radio off.
+2. Connect cable to mic jack.
+3. Press and hold in the [MHz], [LOW], and [D/MR] keys
+ while turning the radio on.
+4. Press the [D/MR(MW)] key ("--WAIT--" will appear on the LCD)."""))
+ return rp
+
+ def get_features(self):
+ rf = chirp_common.RadioFeatures()
+
+ rf.memory_bounds = (0, 129)
+
+ rf.can_odd_split = False
+ rf.has_ctone = False
+ rf.has_tuning_step = True
+ rf.has_dtcs_polarity = False
+ rf.has_bank = False
+
+ rf.valid_tuning_steps = STEPS
+ rf.valid_modes = MODES
+ rf.valid_tmodes = TMODES
+ rf.valid_bands = [(137000000, 174000000)]
+ rf.valid_power_levels = POWER_LEVELS
+ rf.valid_duplexes = DUPLEX
+ rf.valid_skips = ["", "S", "P"]
+ rf.valid_name_length = 6
+ rf.valid_characters = CHARSET
+ rf.has_cross = False
+
+ return rf
+
+ def _checksums(self):
+ return [yaesu_clone.YaesuChecksum(0, self._memsize-2)]
+
+ def process_mmap(self):
+ self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
+
+ def get_raw_memory(self, number):
+ return repr(self._memobj.memory[number]) + \
+ repr(self._memobj.flags[number])
+
+ def get_memory(self, number):
+ _mem = self._memobj.memory[number]
+ _flag = self._memobj.flags[number]
+ visible = _flag["visible"]
+ valid = _flag["valid"]
+ skip = _flag["skip"]
+ pskip = _flag["pskip"]
+ mem = chirp_common.Memory()
+ mem.number = number
+
+ if not visible:
+ mem.empty = True
+ if not valid:
+ mem.empty = True
+ return mem
+
+ mem.freq = chirp_common.fix_rounded_step(int(_mem.freq) * 1000)
+ mem.offset = chirp_common.fix_rounded_step(int(_mem.offset) * 100000)
+ mem.duplex = DUPLEX[_mem.duplex]
+ mem.tuning_step = STEPS[_mem.tune_step] or STEPS[0]
+ mem.tmode = TMODES[_mem.tmode]
+ mem.rtone = chirp_common.TONES[_mem.tone]
+ for i in _mem.name:
+ if i == 0xFF:
+ break
+ if i & 0x80 == 0x80:
+ mem.name += CHARSET[0x80 ^ int(i)]
+ else:
+ mem.name += CHARSET[i]
+ mem.name = mem.name.rstrip()
+ mem.mode = _mem.narrow and "NFM" or "FM"
+ mem.skip = pskip and "P" or skip and "S" or ""
+ mem.power = POWER_LEVELS[_mem.power]
+
+ mem.extra = RadioSettingGroup("extra", "Extra Settings")
+ rs = RadioSetting("clk_shift", "Clock Shift",
+ RadioSettingValueBoolean(_mem.clk_shift))
+ mem.extra.append(rs)
+ return mem
+
+ def set_memory(self, mem):
+ _mem = self._memobj.memory[mem.number]
+ _flag = self._memobj.flags[mem.number]
+ valid = _flag["valid"]
+ visible = _flag["visible"]
+
+ if not mem.empty and not valid:
+ _flag["valid"] = True
+ _mem.unknown1a = 0x00
+ _mem.clk_shift = 0x00
+ _mem.unknown1b = 0x00
+ _mem.unknown2a = 0x00
+ _mem.unknown2b = 0x00
+ _mem.unknown3 = 0x00
+ _mem.unknown4a = 0x00
+ _mem.unknown4b = 0x00
+ _mem.unknown4c = 0x00
+ _mem.unknown4d = 0x00
+ _mem.unknown5a = 0x00
+
+ if mem.empty and valid and not visible:
+ _flag["valid"] = False
+ return
+ _flag["visible"] = not mem.empty
+
+ if mem.empty:
+ return
+
+ _flag["valid"] = True
+
+ _mem.freq = mem.freq / 1000
+ _mem.offset = mem.offset / 100000
+ _mem.duplex = DUPLEX.index(mem.duplex)
+ _mem.tune_step = STEPS.index(mem.tuning_step)
+ _mem.tmode = TMODES.index(mem.tmode)
+ _mem.tone = chirp_common.TONES.index(mem.rtone)
+
+ _mem.name = [0xFF] * 6
+ for i in range(0, len(mem.name)):
+ try:
+ _mem.name[i] = CHARSET.index(mem.name[i])
+ except IndexError:
+ raise Exception("Character `%s' not supported")
+
+ _mem.narrow = MODES.index(mem.mode)
+ _mem.power = 3 if mem.power is None else POWER_LEVELS.index(mem.power)
+
+ _flag["pskip"] = mem.skip == "P"
+ _flag["skip"] = mem.skip == "S"
+
+ for element in mem.extra:
+ setattr(_mem, element.get_name(), element.value)
diff --git a/chirp/drivers/ft2d.py b/chirp/drivers/ft2d.py
index f832af8..6c15f16 100644
--- a/chirp/drivers/ft2d.py
+++ b/chirp/drivers/ft2d.py
@@ -87,7 +87,7 @@ class FT2D(ft1d.FT1Radio):
2. Connect cable to DATA terminal.
3. Press and hold [DISP] key while turning on radio
("CLONE" will appear on the display).
- 4. <b>After clicking OK here in chirp</b>,
+ 4. <b>After clicking OK here in chirp</b>,
press the [Send] screen button."""))
rp.pre_upload = _(dedent("""\
1. Turn radio off.
@@ -156,3 +156,11 @@ class FT2Dv2(FT2D):
VARIANT = "Rv2"
_model = "AH60G"
+
+@directory.register
+class FT3D(FT2D):
+ """Yaesu FT-3D"""
+ MODEL = "FT3D"
+ VARIANT = "R"
+
+ _model = "AH72M"
diff --git a/chirp/drivers/ft4.py b/chirp/drivers/ft4.py
index 26b550c..e3f41df 100644
--- a/chirp/drivers/ft4.py
+++ b/chirp/drivers/ft4.py
@@ -669,6 +669,7 @@ class YaesuSC35GenericRadio(chirp_common.CloneModeRadio,
rf.has_dtcs_polarity = False # REV TN reverses the tone, not the dcs
rf.has_cross = True
rf.has_settings = True
+ rf.valid_tuning_steps = self.legal_steps
return rf
diff --git a/chirp/drivers/ftm350.py b/chirp/drivers/ftm350.py
index fc4839f..ea5bc2f 100644
--- a/chirp/drivers/ftm350.py
+++ b/chirp/drivers/ftm350.py
@@ -265,6 +265,9 @@ class FTM350Radio(yaesu_clone.YaesuCloneModeRadio):
(76000000, 250000000),
(30000000, 1000000000)]
rf.can_odd_split = True
+ rf.valid_tuning_steps = [5.0, 6.25, 8.33, 10.0, 12.5, 15.0, 20.0,
+ 25.0, 50.0, 100.0, 200.0]
+
return rf
def get_sub_devices(self):
diff --git a/chirp/drivers/h777.py b/chirp/drivers/h777.py
index dc689f5..36284f2 100644
--- a/chirp/drivers/h777.py
+++ b/chirp/drivers/h777.py
@@ -82,7 +82,6 @@ UPLOAD_BLOCKS = [range(0x0000, 0x0110, 8),
H777_POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=1.00),
chirp_common.PowerLevel("High", watts=5.00)]
VOICE_LIST = ["English", "Chinese"]
-SIDEKEYFUNCTION_LIST = ["Off", "Monitor", "Transmit Power", "Alarm"]
TIMEOUTTIMER_LIST = ["Off", "30 seconds", "60 seconds", "90 seconds",
"120 seconds", "150 seconds", "180 seconds",
"210 seconds", "240 seconds", "270 seconds",
@@ -252,6 +251,11 @@ class A8SAlias(chirp_common.Alias):
MODEL = 'A-8S'
+class TenwayTW325Alias(chirp_common.Alias):
+ VENDOR = 'Tenway'
+ MODEL = 'TW-325'
+
+
@directory.register
class H777Radio(chirp_common.CloneModeRadio):
"""HST H-777"""
@@ -261,7 +265,9 @@ class H777Radio(chirp_common.CloneModeRadio):
MODEL = "BF-888"
BAUD_RATE = 9600
- ALIASES = [ArcshellAR5, ArcshellAR6, GV8SAlias, GV9SAlias, A8SAlias]
+ ALIASES = [ArcshellAR5, ArcshellAR6, GV8SAlias, GV9SAlias, A8SAlias,
+ TenwayTW325Alias]
+ SIDEKEYFUNCTION_LIST = ["Off", "Monitor", "Transmit Power", "Alarm"]
# This code currently requires that ranges start at 0x0000
# and are continious. In the original program 0x0388 and 0x03C8
@@ -515,8 +521,8 @@ class H777Radio(chirp_common.CloneModeRadio):
if self._has_sidekey:
rs = RadioSetting("settings2.sidekeyfunction", "Side key function",
RadioSettingValueList(
- SIDEKEYFUNCTION_LIST,
- SIDEKEYFUNCTION_LIST[
+ self.SIDEKEYFUNCTION_LIST,
+ self.SIDEKEYFUNCTION_LIST[
self._memobj.settings2.sidekeyfunction]))
basic.append(rs)
@@ -612,7 +618,7 @@ class ROGA2SRadio(H777Radio):
VENDOR = "Radioddity"
MODEL = "GA-2S"
_has_fm = False
- _has_sidekey = False
+ SIDEKEYFUNCTION_LIST = ["Off", "Monitor", "Unused", "Alarm"]
@classmethod
def match_model(cls, filedata, filename):
diff --git a/chirp/drivers/ic2730.py b/chirp/drivers/ic2730.py
index c3d192f..84d5e63 100644
--- a/chirp/drivers/ic2730.py
+++ b/chirp/drivers/ic2730.py
@@ -312,6 +312,7 @@ class IC2730Radio(icf.IcomRawCloneModeRadio):
def _get_bank(self, loc):
_bank = self._memobj.bank_info[loc]
+ _bank.bank = _bank.bank & 0x1F # Bad index filter, fix issue #7031
if _bank.bank == 0x1F:
return None
else:
diff --git a/chirp/drivers/icf.py b/chirp/drivers/icf.py
index 30eabcb..816771a 100644
--- a/chirp/drivers/icf.py
+++ b/chirp/drivers/icf.py
@@ -148,20 +148,24 @@ def get_model_data(radio, mdata="\x00\x00\x00\x00"):
return frames[0].payload
-def get_clone_resp(pipe, length=None):
+def get_clone_resp(pipe, length=None, max_count=None):
"""Read the response to a clone frame"""
- def exit_criteria(buf, length):
+ def exit_criteria(buf, length, cnt, max_count):
"""Stop reading a clone response if we have enough data or encounter
the end of a frame"""
+ if max_count is not None:
+ if cnt >= max_count:
+ return True
if length is None:
return buf.endswith("\xfd")
else:
return len(buf) == length
resp = ""
- while not exit_criteria(resp, length):
+ cnt = 0
+ while not exit_criteria(resp, length, cnt, max_count):
resp += pipe.read(1)
-
+ cnt += 1
return resp
@@ -183,6 +187,9 @@ def send_clone_frame(radio, cmd, data, raw=False, checksum=False):
pass
radio.pipe.write(frame)
+ if radio.MUNCH_CLONE_RESP:
+ # Do max 2*len(frame) read(1) calls
+ get_clone_resp(radio.pipe, max_count=2*len(frame))
return frame
@@ -190,15 +197,36 @@ def send_clone_frame(radio, cmd, data, raw=False, checksum=False):
def process_data_frame(radio, frame, _mmap):
"""Process a data frame, adding the payload to @_mmap"""
_data = radio.process_frame_payload(frame.payload)
- if len(_mmap) >= 0x10000:
+ # Checksum logic added by Rick DeWitt, 9/2019, issue # 7075
+ if len(_mmap) >= 0x10000: # This map size not tested for checksum
saddr, = struct.unpack(">I", _data[0:4])
length, = struct.unpack("B", _data[4])
data = _data[5:5+length]
- else:
+ sumc, = struct.unpack("B", _data[5+length])
+ addr1, = struct.unpack("B", _data[0])
+ addr2, = struct.unpack("B", _data[1])
+ addr3, = struct.unpack("B", _data[2])
+ addr4, = struct.unpack("B", _data[3])
+ else: # But this one has been tested for raw mode radio (IC-2730)
saddr, = struct.unpack(">H", _data[0:2])
length, = struct.unpack("B", _data[2])
data = _data[3:3+length]
+ sumc, = struct.unpack("B", _data[3+length])
+ addr1, = struct.unpack("B", _data[0])
+ addr2, = struct.unpack("B", _data[1])
+ addr3 = 0
+ addr4 = 0
+ cs = addr1 + addr2 + addr3 + addr4 + length
+ for byte in data:
+ cs += ord(byte)
+ vx = ((cs ^ 0xFFFF) + 1) & 0xFF
+ if sumc != vx:
+ LOG.error("Bad checksum in address %04X frame: %02x "
+ "calculated, %02x sent!" % (saddr, vx, sumc))
+ raise errors.InvalidDataError(
+ "Checksum error in download! "
+ "Try disabling High Speed Clone option in Settings.")
try:
_mmap[saddr] = data
except IndexError:
@@ -560,6 +588,15 @@ class IcomCloneModeRadio(chirp_common.CloneModeRadio):
"""Base class for Icom clone-mode radios"""
VENDOR = "Icom"
BAUDRATE = 9600
+ # Ideally, the driver should read clone response after each clone frame
+ # is sent, but for some reason it hasn't behaved this way for years.
+ # So not to break the existing tested drivers the MUNCH_CLONE_RESP flag
+ # was added. It's False by default which brings the old behavior,
+ # i.e. clone response is not read. The expectation is that new Icom
+ # drivers will use MUNCH_CLONE_RESP = True and old drivers will be
+ # gradually migrated to this. Once all Icom drivers will use
+ # MUNCH_CLONE_RESP = True, this flag will be removed.
+ MUNCH_CLONE_RESP = False
_model = "\x00\x00\x00\x00" # 4-byte model string
_endframe = "" # Model-unique ending frame
diff --git a/chirp/drivers/kenwood_live.py b/chirp/drivers/kenwood_live.py
index face3fe..6117fd7 100644
--- a/chirp/drivers/kenwood_live.py
+++ b/chirp/drivers/kenwood_live.py
@@ -45,9 +45,13 @@ KENWOOD_TONES.remove(199.5)
THF6_MODES = ["FM", "WFM", "AM", "LSB", "USB", "CW"]
+
RADIO_IDS = {
"ID019": "TS-2000",
"ID009": "TS-850",
+ "ID020": "TS-480_LiveMode",
+ "ID021": "TS-590S/SG_LiveMode", # S-model uses same class
+ "ID023": "TS-590S/SG_LiveMode" # as SG
}
LOCK = threading.Lock()
@@ -55,8 +59,9 @@ COMMAND_RESP_BUFSIZE = 8
LAST_BAUD = 4800
LAST_DELIMITER = ("\r", " ")
-# The Kenwood TS-2000 & TS-850 uses ";" as a CAT command message delimiter,
-# and all others use "\n". Also, TS-2000 doesn't space delimite the command
+# The Kenwood TS-2000, TS-480, TS-590 & TS-850 use ";"
+# as a CAT command message delimiter, and all others use "\n".
+# Also, TS-2000 and TS-590 don't space delimite the command
# fields, but others do.
@@ -68,11 +73,13 @@ def command(ser, cmd, *args):
LOCK.acquire()
+ # TODO: This global use of LAST_DELIMITER breaks reentrancy
+ # and needs to be fixed.
if args:
cmd += LAST_DELIMITER[1] + LAST_DELIMITER[1].join(args)
cmd += LAST_DELIMITER[0]
- LOG.debug("PC->RADIO: %s" % cmd.strip())
+ LOG.debug("PC->RADIO: %r" % cmd.strip())
ser.write(cmd)
result = ""
@@ -83,7 +90,7 @@ def command(ser, cmd, *args):
break
if result.endswith(LAST_DELIMITER[0]):
- LOG.debug("RADIO->PC: %s" % result.strip())
+ LOG.debug("RADIO->PC: %r" % result.strip())
result = result[:-1]
else:
LOG.error("Giving up")
@@ -96,15 +103,18 @@ def command(ser, cmd, *args):
def get_id(ser):
"""Get the ID of the radio attached to @ser"""
global LAST_BAUD
- bauds = [4800, 9600, 19200, 38400, 57600]
+ bauds = [4800, 9600, 19200, 38400, 57600, 115200]
bauds.remove(LAST_BAUD)
- bauds.insert(0, LAST_BAUD)
+ # Make sure LAST_BAUD is last so that it is tried first below
+ bauds.append(LAST_BAUD)
global LAST_DELIMITER
command_delimiters = [("\r", " "), (";", "")]
- for i in bauds:
- for delimiter in command_delimiters:
+ for delimiter in command_delimiters:
+ # Process the baud options in reverse order so that we try the
+ # last one first, and then start with the high-speed ones next
+ for i in reversed(bauds):
LAST_DELIMITER = delimiter
LOG.info("Trying ID at baud %i with delimiter \"%s\"" %
(i, repr(delimiter)))
@@ -118,6 +128,16 @@ def get_id(ser):
LAST_BAUD = i
return resp.split(" ")[1]
+ # Radio responded in the right baud rate,
+ # but threw an error because of all the crap
+ # we have been hurling at it. Retry the ID at this
+ # baud rate, which will almost definitely work.
+ if "?" in resp:
+ resp = command(ser, "ID")
+ LAST_BAUD = i
+ if " " in resp:
+ return resp.split(" ")[1]
+
# Kenwood radios that return ID numbers
if resp in RADIO_IDS.keys():
return RADIO_IDS[resp]
@@ -322,9 +342,14 @@ class KenwoodLiveRadio(chirp_common.LiveRadio):
if isinstance(element.value, RadioSettingValueBoolean):
self._kenwood_set_bool(element.get_name(), element.value)
elif isinstance(element.value, RadioSettingValueList):
- options = self._SETTINGS_OPTIONS[element.get_name()]
+ options = self._get_setting_options(element.get_name())
+ if len(options) > 9:
+ digits = 2
+ else:
+ digits = 1
self._kenwood_set_int(element.get_name(),
- options.index(str(element.value)))
+ options.index(str(element.value)),
+ digits)
elif isinstance(element.value, RadioSettingValueInteger):
if element.value.get_max() > 9:
digits = 2
@@ -361,9 +386,13 @@ class THD7Radio(KenwoodOldLiveRadio):
_kenwood_split = True
+ _BEP_OPTIONS = ["Off", "Key", "Key+Data", "All"]
+ _POSC_OPTIONS = ["Off Duty", "Enroute", "In Service", "Returning",
+ "Committed", "Special", "Priority", "Emergency"]
+
_SETTINGS_OPTIONS = {
"BAL": ["4:0", "3:1", "2:2", "1:3", "0:4"],
- "BEP": ["Off", "Key", "Key+Data", "All"],
+ "BEP": None,
"BEPT": ["Off", "Mine", "All New"], # D700 has fourth "All"
"DS": ["Data Band", "Both Bands"],
"DTB": ["A", "B"],
@@ -373,8 +402,7 @@ class THD7Radio(KenwoodOldLiveRadio):
"Plane", "Speedboat", "Car", "Bicycle"],
"MNF": ["Name", "Frequency"],
"PKSA": ["1200", "9600"],
- "POSC": ["Off Duty", "Enroute", "In Service", "Returning",
- "Committed", "Special", "Priority", "Emergency"],
+ "POSC": None,
"PT": ["100ms", "200ms", "500ms", "750ms",
"1000ms", "1500ms", "2000ms"],
"SCR": ["Time", "Carrier", "Seek"],
@@ -403,6 +431,7 @@ class THD7Radio(KenwoodOldLiveRadio):
rf.valid_characters = \
chirp_common.CHARSET_ALPHANUMERIC + "/.-+*)('&%$#! ~}|{"
rf.valid_name_length = 7
+ rf.valid_tuning_steps = STEPS
rf.memory_bounds = (1, self._upper)
return rf
@@ -454,6 +483,22 @@ class THD7Radio(KenwoodOldLiveRadio):
return mem
+ EXTRA_BOOL_SETTINGS = {
+ 'main': [("LMP", "Lamp")],
+ 'dtmf': [("TXH", "TX Hold")],
+ }
+ EXTRA_LIST_SETTINGS = {
+ 'main': [("BAL", "Balance"),
+ ("MNF", "Memory Display Mode")],
+ 'save': [("SV", "Battery Save")],
+ }
+
+ def _get_setting_options(self, setting):
+ opts = self._SETTINGS_OPTIONS[setting]
+ if opts is None:
+ opts = getattr(self, '_%s_OPTIONS' % setting)
+ return opts
+
def get_settings(self):
main = RadioSettingGroup("main", "Main")
aux = RadioSettingGroup("aux", "Aux")
@@ -476,9 +521,7 @@ class THD7Radio(KenwoodOldLiveRadio):
# ("DIG", aprs, "APRS Digipeater"),
("DL", main, "Dual"),
("LK", main, "Lock"),
- ("LMP", main, "Lamp"),
("TSP", dtmf, "DTMF Fast Transmission"),
- ("TXH", dtmf, "TX Hold"),
]
for setting, group, name in bools:
@@ -487,19 +530,16 @@ class THD7Radio(KenwoodOldLiveRadio):
RadioSettingValueBoolean(value))
group.append(rs)
- lists = [("BAL", main, "Balance"),
- ("BEP", aux, "Beep"),
+ lists = [("BEP", aux, "Beep"),
("BEPT", aprs, "APRS Beep"),
("DS", tnc, "Data Sense"),
("DTB", tnc, "Data Band"),
("DTBA", aprs, "APRS Data Band"),
("DTX", aprs, "APRS Data TX"),
# ("ICO", aprs, "APRS Icon"),
- ("MNF", main, "Memory Display Mode"),
("PKSA", aprs, "APRS Packet Speed"),
("POSC", aprs, "APRS Position Comment"),
("PT", dtmf, "DTMF Speed"),
- ("SV", save, "Battery Save"),
("TEMP", aprs, "APRS Temperature Units"),
("TXI", aprs, "APRS Transmit Interval"),
# ("UNIT", aprs, "APRS Display Units"),
@@ -508,12 +548,29 @@ class THD7Radio(KenwoodOldLiveRadio):
for setting, group, name in lists:
value = self._kenwood_get_int(setting)
- options = self._SETTINGS_OPTIONS[setting]
+ options = self._get_setting_options(setting)
rs = RadioSetting(setting, name,
RadioSettingValueList(options,
options[value]))
group.append(rs)
+ for group_name, settings in self.EXTRA_BOOL_SETTINGS.items():
+ group = locals()[group_name]
+ for setting, name in settings:
+ value = self._kenwood_get_bool(setting)
+ rs = RadioSetting(setting, name,
+ RadioSettingValueBoolean(value))
+ group.append(rs)
+
+ for group_name, settings in self.EXTRA_LIST_SETTINGS.items():
+ group = locals()[group_name]
+ for setting, name in settings:
+ value = self._kenwood_get_int(setting)
+ options = self._get_setting_options(setting)
+ rs = RadioSetting(setting, name,
+ RadioSettingValueBoolean(value))
+ group.append(rs)
+
ints = [("CNT", display, "Contrast", 1, 16),
]
for setting, group, name, minv, maxv in ints:
@@ -550,25 +607,35 @@ class THD7GRadio(THD7Radio):
@directory.register
-class TMD700Radio(KenwoodOldLiveRadio):
+class TMD700Radio(THD7Radio):
"""Kenwood TH-D700"""
MODEL = "TM-D700"
_kenwood_split = True
+ _BEP_OPTIONS = ["Off", "Key"]
+ _POSC_OPTIONS = ["Off Duty", "Enroute", "In Service", "Returning",
+ "Committed", "Special", "Priority", "CUSTOM 0",
+ "CUSTOM 1", "CUSTOM 2", "CUSTOM 4", "CUSTOM 5",
+ "CUSTOM 6", "Emergency"]
+ EXTRA_BOOL_SETTINGS = {}
+ EXTRA_LIST_SETTINGS = {}
+
def get_features(self):
rf = chirp_common.RadioFeatures()
+ rf.has_settings = True
rf.has_dtcs = True
rf.has_dtcs_polarity = False
rf.has_bank = False
- rf.has_mode = False
+ rf.has_mode = True
rf.has_tuning_step = False
rf.can_odd_split = True
rf.valid_duplexes = ["", "-", "+", "split"]
- rf.valid_modes = ["FM"]
+ rf.valid_modes = ["FM", "AM"]
rf.valid_tmodes = ["", "Tone", "TSQL", "DTCS"]
rf.valid_characters = chirp_common.CHARSET_ALPHANUMERIC
rf.valid_name_length = 8
+ rf.valid_tuning_steps = STEPS
rf.memory_bounds = (1, self._upper)
return rf
@@ -636,6 +703,7 @@ class TMV7Radio(KenwoodOldLiveRadio):
rf.valid_tmodes = ["", "Tone", "TSQL"]
rf.valid_characters = chirp_common.CHARSET_ALPHANUMERIC
rf.valid_name_length = 7
+ rf.valid_tuning_steps = STEPS
rf.has_sub_devices = True
rf.memory_bounds = (1, self._upper)
return rf
@@ -994,6 +1062,7 @@ class THF7ERadio(THF6ARadio):
"""Kenwood TH-F7"""
MODEL = "TH-F7"
+
D710_DUPLEX = ["", "+", "-", "split"]
D710_MODES = ["FM", "NFM", "AM"]
D710_SKIP = ["", "S"]
@@ -1335,3 +1404,360 @@ class TM471Radio(THK2Radio):
def _cmd_set_memory_name(self, number, name):
return "MN", "%03i,%s" % (number, name)
+
+
+@directory.register
+class TS590Radio(KenwoodLiveRadio):
+ """Kenwood TS-590S/SG"""
+ MODEL = "TS-590S/SG_LiveMode"
+
+ _kenwood_valid_tones = list(KENWOOD_TONES)
+ _kenwood_valid_tones.append(1750)
+
+ _upper = 99
+ _duplex = ["", "-", "+"]
+ _skip = ["", "S"]
+ _modes = ["LSB", "USB", "CW", "FM", "AM", "FSK", "CW-R",
+ "FSK-R", "Data+LSB", "Data+USB", "Data+FM"]
+ _bands = [(1800000, 2000000), # 160M Band
+ (3500000, 4000000), # 80M Band
+ (5167500, 5450000), # 60M Band
+ (7000000, 7300000), # 40M Band
+ (10100000, 10150000), # 30M Band
+ (14000000, 14350000), # 20M Band
+ (18068000, 18168000), # 17M Band
+ (21000000, 21450000), # 15M Band
+ (24890000, 24990000), # 12M Band
+ (28000000, 29700000), # 10M Band
+ (50000000, 54000000)] # 6M Band
+
+ def get_features(self):
+ rf = chirp_common.RadioFeatures()
+
+ rf.can_odd_split = False
+ rf.has_bank = False
+ rf.has_ctone = True
+ rf.has_dtcs = False
+ rf.has_dtcs_polarity = False
+ rf.has_name = True
+ rf.has_settings = False
+ rf.has_offset = True
+ rf.has_mode = True
+ rf.has_tuning_step = False
+ rf.has_nostep_tuning = True
+ rf.has_cross = True
+ rf.has_comment = False
+
+ rf.memory_bounds = (0, self._upper)
+
+ rf.valid_bands = self._bands
+ rf.valid_characters = chirp_common.CHARSET_UPPER_NUMERIC + "*+-/"
+ rf.valid_duplexes = ["", "-", "+"]
+ rf.valid_modes = self._modes
+ rf.valid_skips = ["", "S"]
+ rf.valid_tmodes = ["", "Tone", "TSQL", "Cross"]
+ rf.valid_cross_modes = ["Tone->Tone", "->Tone"]
+ rf.valid_name_length = 8 # 8 character channel names
+
+ return rf
+
+ def _my_val_list(setting, opts, obj, atrb):
+ """Callback:from ValueList. Set the integer index."""
+ value = opts.index(str(setting.value))
+ setattr(obj, atrb, value)
+ return
+
+ def get_memory(self, number):
+ """Convert ascii channel data spec into UI columns (mem)"""
+ mem = chirp_common.Memory()
+ mem.extra = RadioSettingGroup("extra", "Extra")
+ # Read the base and split MR strings
+ mem.number = number
+ spec0 = command(self.pipe, "MR0 %02i" % mem.number)
+ spec1 = command(self.pipe, "MR1 %02i" % mem.number)
+ mem.name = spec0[41:49] # Max 8-Char Name if assigned
+ mem.name = mem.name.strip()
+ mem.name = mem.name.upper()
+ _p4 = int(spec0[6:17]) # Rx Frequency
+ _p4s = int(spec1[6:17]) # Offset freq (Tx)
+ _p5 = int(spec0[17]) # Mode
+ _p6 = int(spec0[18]) # Data Mode
+ _p7 = int(spec0[19]) # Tone Mode
+ _p8 = int(spec0[20:22]) # Tone Frequency Index
+ _p9 = int(spec0[22:24]) # CTCSS Frequency Index
+ _p11 = int(spec0[27]) # Filter A/B
+ _p14 = int(spec0[38:40]) # FM Mode
+ _p15 = int(spec0[40]) # Chan Lockout (Skip)
+ if _p4 == 0:
+ mem.empty = True
+ return mem
+ mem.empty = False
+ mem.freq = _p4
+ mem.duplex = self._duplex[0] # None by default
+ mem.offset = 0
+ if _p4 < _p4s: # + shift
+ mem.duplex = self._duplex[2]
+ mem.offset = _p4s - _p4
+ if _p4 > _p4s: # - shift
+ mem.duplex = self._duplex[1]
+ mem.offset = _p4 - _p4s
+ mx = _p5 - 1 # CAT modes start at 1
+ if _p5 == 9: # except CAT FSK-R is 9, there is no 8
+ mx = 7
+ if _p6: # LSB+Data= 8, USB+Data= 9, FM+Data= 10
+ if _p5 == 1: # CAT LSB
+ mx = 8
+ elif _p5 == 2: # CAT USB
+ mx = 9
+ elif _p5 == 4: # CAT FM
+ mx = 10
+ mem.mode = self._modes[mx]
+ mem.tmode = ""
+ mem.cross_mode = "Tone->Tone"
+ mem.ctone = self._kenwood_valid_tones[_p9]
+ mem.rtone = self._kenwood_valid_tones[_p8]
+ if _p7 == 1:
+ mem.tmode = "Tone"
+ elif _p7 == 2:
+ mem.tmode = "TSQL"
+ elif _p7 == 3:
+ mem.tmode = "Cross"
+ mem.skip = self._skip[_p15]
+
+ rx = RadioSettingValueBoolean(bool(_p14))
+ rset = RadioSetting("fmnrw", "FM Narrow mode (off = Wide)", rx)
+ mem.extra.append(rset)
+ return mem
+
+ def erase_memory(self, number):
+ """ Send the blank string to MW0 """
+ mem = chirp_common.Memory()
+ mem.empty = True
+ mem.freq = 0
+ mem.offset = 0
+ spx = "MW0%03i00000000000000000000000000000000000" % number
+ rx = command(self.pipe, spx) # Send MW0
+ return mem
+
+ def set_memory(self, mem):
+ """Send UI column data (mem) to radio"""
+ pfx = "MW0%03i" % mem.number
+ xmode = 0
+ xtmode = 0
+ xrtone = 8
+ xctone = 8
+ xdata = 0
+ xfltr = 0
+ xfm = 0
+ xskip = 0
+ xfreq = mem.freq
+ if xfreq > 0: # if empty; use those defaults
+ ix = self._modes.index(mem.mode)
+ xmode = ix + 1 # stored as CAT values, LSB= 1
+ if ix == 7: # FSK-R
+ xmode = 9 # There is no CAT 8
+ if ix > 7: # a Data mode
+ xdata = 1
+ if ix == 8:
+ xmode = 1 # LSB
+ elif ix == 9:
+ xmode = 2 # USB
+ elif ix == 10:
+ xmode = 4 # FM
+ if mem.tmode == "Tone":
+ xtmode = 1
+ xrtone = self._kenwood_valid_tones.index(mem.rtone)
+ if mem.tmode == "TSQL" or mem.tmode == "Cross":
+ xtmode = 2
+ if mem.tmode == "Cross":
+ xtmode = 3
+ xctone = self._kenwood_valid_tones.index(mem.ctone)
+ for setting in mem.extra:
+ if setting.get_name() == "fmnrw":
+ xfm = setting.value
+ if mem.skip == "S":
+ xskip = 1
+ spx = "%011i%1i%1i%1i%02i%02i000%1i0000000000%02i%1i%s" \
+ % (xfreq, xmode, xdata, xtmode, xrtone,
+ xctone, xfltr, xfm, xskip, mem.name)
+ rx = command(self.pipe, pfx, spx) # Send MW0
+ if mem.offset != 0:
+ pfx = "MW1%03i" % mem.number
+ xfreq = mem.freq - mem.offset
+ if mem.duplex == "+":
+ xfreq = mem.freq + mem.offset
+ spx = "%011i%1i%1i%1i%02i%02i000%1i0000000000%02i%1i%s" \
+ % (xfreq, xmode, xdata, xtmode, xrtone,
+ xctone, xfltr, xfm, xskip, mem.name)
+ rx = command(self.pipe, pfx, spx) # Send MW1
+
+
+@directory.register
+class TS480Radio(KenwoodLiveRadio):
+ """Kenwood TS-480"""
+ MODEL = "TS-480_LiveMode"
+
+ _kenwood_valid_tones = list(KENWOOD_TONES)
+ _kenwood_valid_tones.append(1750)
+
+ _upper = 99
+ _duplex = ["", "-", "+"]
+ _skip = ["", "S"]
+ _modes = ["LSB", "USB", "CW", "FM", "AM", "FSK", "CW-R", "N/A",
+ "FSK-R"]
+ _bands = [(1800000, 2000000), # 160M Band
+ (3500000, 4000000), # 80M Band
+ (5167500, 5450000), # 60M Band
+ (7000000, 7300000), # 40M Band
+ (10100000, 10150000), # 30M Band
+ (14000000, 14350000), # 20M Band
+ (18068000, 18168000), # 17M Band
+ (21000000, 21450000), # 15M Band
+ (24890000, 24990000), # 12M Band
+ (28000000, 29700000), # 10M Band
+ (50000000, 54000000)] # 6M Band
+
+ _tsteps = [0.5, 1.0, 2.5, 5.0, 6.25, 10.0, 12.5,
+ 15.0, 20.0, 25.0, 30.0, 50.0, 100.0]
+
+ def get_features(self):
+ rf = chirp_common.RadioFeatures()
+
+ rf.can_odd_split = False
+ rf.has_bank = False
+ rf.has_ctone = True
+ rf.has_dtcs = False
+ rf.has_dtcs_polarity = False
+ rf.has_name = True
+ rf.has_settings = False
+ rf.has_offset = True
+ rf.has_mode = True
+ rf.has_tuning_step = True
+ rf.has_nostep_tuning = True
+ rf.has_cross = True
+ rf.has_comment = False
+
+ rf.memory_bounds = (0, self._upper)
+
+ rf.valid_bands = self._bands
+ rf.valid_characters = chirp_common.CHARSET_UPPER_NUMERIC + "*+-/"
+ rf.valid_duplexes = ["", "-", "+"]
+ rf.valid_modes = self._modes
+ rf.valid_skips = ["", "S"]
+ rf.valid_tmodes = ["", "Tone", "TSQL", "Cross"]
+ rf.valid_cross_modes = ["Tone->Tone", "->Tone"]
+ rf.valid_name_length = 8 # 8 character channel names
+ rf.valid_tuning_steps = self._tsteps
+
+ return rf
+
+ def _my_val_list(setting, opts, obj, atrb):
+ """Callback:from ValueList. Set the integer index."""
+ value = opts.index(str(setting.value))
+ setattr(obj, atrb, value)
+ return
+
+ def get_memory(self, number):
+ """Convert ascii channel data spec into UI columns (mem)"""
+ mem = chirp_common.Memory()
+ # Read the base and split MR strings
+ mem.number = number
+ spec0 = command(self.pipe, "MR0%03i" % mem.number)
+ spec1 = command(self.pipe, "MR1%03i" % mem.number)
+ # Add 1 to string idecis if refering to CAT manual
+ mem.name = spec0[41:49] # Max 8-Char Name if assigned
+ mem.name = mem.name.strip()
+ mem.name = mem.name.upper()
+ _p4 = int(spec0[6:17]) # Rx Frequency
+ _p4s = int(spec1[6:17]) # Offset freq (Tx)
+ _p5 = int(spec0[17]) # Mode
+ _p6 = int(spec0[18]) # Chan Lockout (Skip)
+ _p7 = int(spec0[19]) # Tone Mode
+ _p8 = int(spec0[20:22]) # Tone Frequency Index
+ _p9 = int(spec0[22:24]) # CTCSS Frequency Index
+ _p14 = int(spec0[38:40]) # Tune Step
+ if _p4 == 0:
+ mem.empty = True
+ return mem
+ mem.empty = False
+ mem.freq = _p4
+ mem.duplex = self._duplex[0] # None by default
+ mem.offset = 0
+ if _p4 < _p4s: # + shift
+ mem.duplex = self._duplex[2]
+ mem.offset = _p4s - _p4
+ if _p4 > _p4s: # - shift
+ mem.duplex = self._duplex[1]
+ mem.offset = _p4 - _p4s
+ mx = _p5 - 1 # CAT modes start at 1
+ mem.mode = self._modes[mx]
+ mem.tmode = ""
+ mem.cross_mode = "Tone->Tone"
+ mem.ctone = self._kenwood_valid_tones[_p9]
+ mem.rtone = self._kenwood_valid_tones[_p8]
+ if _p7 == 1:
+ mem.tmode = "Tone"
+ elif _p7 == 2:
+ mem.tmode = "TSQL"
+ elif _p7 == 3:
+ mem.tmode = "Cross"
+ mem.skip = self._skip[_p6]
+ # Tuning step depends on mode
+ options = [0.5, 1.0, 2.5, 5.0, 10.0] # SSB/CS/FSK
+ if _p14 == 4 or _p14 == 5: # AM/FM
+ options = self._tsteps[3:]
+ mem.tuning_step = options[_p14]
+
+ return mem
+
+ def erase_memory(self, number):
+ mem = chirp_common.Memory()
+ mem.empty = True
+ mem.freq = 0
+ mem.offset = 0
+ spx = "MW0%03i00000000000000000000000000000000000" % number
+ rx = command(self.pipe, spx) # Send MW0
+ return mem
+
+ def set_memory(self, mem):
+ """Send UI column data (mem) to radio"""
+ pfx = "MW0%03i" % mem.number
+ xtmode = 0
+ xdata = 0
+ xrtone = 8
+ xctone = 8
+ xskip = 0
+ xstep = 0
+ xfreq = mem.freq
+ if xfreq > 0: # if empty, use those defaults
+ ix = self._modes.index(mem.mode)
+ xmode = ix + 1 # stored as CAT values, LSB= 1
+ if ix == 7: # FSK-R
+ xmode = 9 # There is no CAT 8
+ if mem.tmode == "Tone":
+ xtmode = 1
+ xrtone = self._kenwood_valid_tones.index(mem.rtone)
+ if mem.tmode == "TSQL" or mem.tmode == "Cross":
+ xtmode = 2
+ if mem.tmode == "Cross":
+ xtmode = 3
+ xctone = self._kenwood_valid_tones.index(mem.ctone)
+ if mem.skip == "S":
+ xskip = 1
+ options = [0.5, 1.0, 2.5, 5.0, 10.0] # SSB/CS/FSK
+ if xmode == 4 or xmode == 5:
+ options = self._tsteps[3:]
+ xstep = options.index(mem.tuning_step)
+ spx = "%011i%1i%1i%1i%02i%02i00000000000000%02i%s" \
+ % (xfreq, xmode, xskip, xtmode, xrtone,
+ xctone, xstep, mem.name)
+ rx = command(self.pipe, pfx, spx) # Send MW0
+ if mem.offset != 0: # Don't send MW1 if empty
+ pfx = "MW1%03i" % mem.number
+ xfreq = mem.freq - mem.offset
+ if mem.duplex == "+":
+ xfreq = mem.freq + mem.offset
+ spx = "%011i%1i%1i%1i%02i%02i00000000000000%02i%s" \
+ % (xfreq, xmode, xskip, xtmode, xrtone,
+ xctone, xstep, mem.name)
+ rx = command(self.pipe, pfx, spx) # Send MW1
diff --git a/chirp/drivers/kguv8dplus.py b/chirp/drivers/kguv8dplus.py
index 227f3fe..b4a0cb8 100644
--- a/chirp/drivers/kguv8dplus.py
+++ b/chirp/drivers/kguv8dplus.py
@@ -519,6 +519,7 @@ class KGUV8DPlusRadio(chirp_common.CloneModeRadio,
rf.valid_bands = [(134000000, 175000000), # supports 2m
(400000000, 520000000)] # supports 70cm
rf.valid_characters = chirp_common.CHARSET_ASCII
+ rf.valid_tuning_steps = STEPS
rf.memory_bounds = (1, 999) # 999 memories
return rf
diff --git a/chirp/drivers/kguv9dplus.py b/chirp/drivers/kguv9dplus.py
index c08dc92..b836af6 100644
--- a/chirp/drivers/kguv9dplus.py
+++ b/chirp/drivers/kguv9dplus.py
@@ -1096,7 +1096,9 @@ class KGUV9DPlusRadio(chirp_common.CloneModeRadio,
mem = chirp_common.Memory()
mem.number = number
_valid = _mem.state
- if _valid != MEM_VALID:
+ if _valid != MEM_VALID and _valid != 0 and _valid != 2:
+ # In Issue #6995 we can find _valid values of 0 and 2 in the IMG
+ # so these values should be treated like MEM_VALID.
mem.empty = True
return mem
else:
diff --git a/chirp/drivers/puxing_px888k.py b/chirp/drivers/puxing_px888k.py
index cc6f3c5..78f49a6 100644
--- a/chirp/drivers/puxing_px888k.py
+++ b/chirp/drivers/puxing_px888k.py
@@ -1143,6 +1143,7 @@ class Puxing_PX888K_Radio(chirp_common.CloneModeRadio):
rf.valid_cross_modes = CROSS_MODES
rf.memory_bounds = (1, 128)
rf.valid_special_chans = SPECIAL_CHANNELS.keys()
+ rf.valid_tuning_steps = [5.0, 6.25, 10.0, 12.5, 25.0]
return rf
def sync_in(self):
diff --git a/chirp/drivers/radioddity_r2.py b/chirp/drivers/radioddity_r2.py
index c0b2778..ca2a13e 100644
--- a/chirp/drivers/radioddity_r2.py
+++ b/chirp/drivers/radioddity_r2.py
@@ -350,6 +350,7 @@ class RadioddityR2Radio(chirp_common.CloneModeRadio):
rf.valid_skips = []
rf.valid_bands = [self._range]
rf.memory_bounds = (1, self._upper)
+ rf.valid_tuning_steps = [2.5, 5.0, 6.25, 10.0, 12.5, 25.0]
return rf
def process_mmap(self):
diff --git a/chirp/drivers/tk270.py b/chirp/drivers/tk270.py
index 766b8d2..b7927d2 100644
--- a/chirp/drivers/tk270.py
+++ b/chirp/drivers/tk270.py
@@ -382,6 +382,7 @@ class Kenwood_P60_Radio(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
rf.valid_dtcs_codes = DTCS_CODES
rf.valid_bands = [self._range]
rf.memory_bounds = (1, self._upper)
+ rf.valid_tuning_steps = [2.5, 5.0, 6.25, 10.0, 12.5, 25.0]
return rf
def sync_in(self):
diff --git a/chirp/drivers/tk8180.py b/chirp/drivers/tk8180.py
index d52a69c..594abac 100644
--- a/chirp/drivers/tk8180.py
+++ b/chirp/drivers/tk8180.py
@@ -335,7 +335,6 @@ def do_upload(radio):
status.max = radio._memsize
status.msg = "Cloning to radio"
radio.status_fn(status)
- LOG.debug('Radio address 0x%04x' % len(data))
for block in range(0, 0xBF + 1):
addr = block * 0x100
diff --git a/chirp/drivers/ts480.py b/chirp/drivers/ts480.py
new file mode 100644
index 0000000..47b1757
--- /dev/null
+++ b/chirp/drivers/ts480.py
@@ -0,0 +1,1144 @@
+# Copyright 2019 Rick DeWitt <aa0rd@yahoo.com>
+# Implementing mem as Clone Mode
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import time
+import struct
+import logging
+import re
+import math
+import threading
+from chirp import chirp_common, directory, memmap
+from chirp import bitwise, errors, util
+from chirp.settings import RadioSettingGroup, RadioSetting, \
+ RadioSettingValueBoolean, RadioSettingValueList, \
+ RadioSettingValueString, RadioSettingValueInteger, \
+ RadioSettingValueFloat, RadioSettings, InvalidValueError
+from textwrap import dedent
+
+LOG = logging.getLogger(__name__)
+
+MEM_FORMAT = """
+#seekto 0x0000;
+struct { // 20 bytes per chan
+ u32 rxfreq;
+ u32 txfreq;
+ u8 xmode; // param stored as CAT value
+ u8 tmode;
+ u8 rtone;
+ u8 ctone;
+ u8 skip;
+ u8 step;
+ char name[8];
+} ch_mem[110]; // 100 normal + 10 P-type
+
+struct { // 5 bytes each
+ u32 asfreq;
+ u8 asmode:4, // param stored as CAT value (0 -9)
+ asdata:2,
+ asnu:2;
+} asf[32];
+
+struct { // 10 x 5 4-byte frequencies
+ u32 ssfreq;
+} ssf[50];
+
+struct {
+ u8 ag;
+ u8 an;
+ u32 fa;
+ u32 fb;
+ u8 mf;
+ u8 mg;
+ u8 pc;
+ u8 rg;
+ u8 ty;
+} settings;
+
+struct { // Menu A/B settings
+ char ex000;
+ u8 ex003; // These params stored as nibbles
+ u8 ex007;
+ u8 ex008;
+ u8 ex009;
+ u8 ex010;
+ u8 ex011;
+ u8 ex012;
+ u8 ex013;
+ u8 ex014;
+ u8 ex021;
+ u8 ex022;
+ u8 ex048;
+ u8 ex049;
+ u8 ex050;
+ u8 ex051;
+ u8 ex052;
+} exset[2];
+
+ char mdl_name[9]; // appended model name, first 9 chars
+
+"""
+
+STIMEOUT = 0.6
+LOCK = threading.Lock()
+BAUD = 0 # Initial baud rate
+MEMSEL = 0 # Default Menu A
+BEEPVOL = 5 # Default beep level
+W8S = 0.01 # short wait, secs
+W8L = 0.05 # long wait
+
+TS480_DUPLEX = ["", "-", "+"]
+TS480_SKIP = ["", "S"]
+
+# start at 0:LSB
+TS480_MODES = ["LSB", "USB", "CW", "FM", "AM", "FSK", "CW-R", "FSK-R"]
+EX_MODES = ["FSK-R", "CW-R"]
+for ix in EX_MODES:
+ if ix not in chirp_common.MODES:
+ chirp_common.MODES.append(ix)
+
+TS480_TONES = list(chirp_common.TONES)
+TS480_TONES.append(1750.0)
+
+TS480_BANDS = [(50000, 24999999), # VFO Rx range. TX has lockouts
+ (25000000, 59999999)]
+
+TS480_TUNE_STEPS = [0.5, 1.0, 2.5, 5.0, 6.25, 10.0, 12.5,
+ 15.0, 20.0, 25.0, 30.0, 50.0, 100.0]
+
+RADIO_IDS = { # From kenwood_live.py; used to report wrong radio
+ "ID019;": "TS-2000",
+ "ID009;": "TS-850",
+ "ID020:": "TS-480",
+ "ID021;": "TS-590S",
+ "ID023;": "TS-590SG"
+}
+
+
+def command(ser, cmd, rsplen, w8t=0.01, exts=""):
+ """Send @cmd to radio via @ser"""
+ # cmd is output string without ; terminator
+ # rsplen is expected response char count, including terminator
+ # If rsplen = 0 then do not read after write
+
+ start = time.time()
+ # LOCK.acquire()
+ stx = cmd # preserve cmd for response check
+ stx = stx + exts + ";" # append arguments
+ ser.write(stx)
+ LOG.debug("PC->RADIO [%s]" % stx)
+ ts = time.time() # implement the wait after command
+ while (time.time() - ts) < w8t:
+ ix = 0 # NOP
+ result = ""
+ if rsplen > 0: # read response
+ result = ser.read(rsplen)
+ LOG.debug("RADIO->PC [%s]" % result)
+ result = result[:-1] # remove terminator
+ # LOCK.release()
+ return result.strip()
+
+
+def _connect_radio(radio):
+ """Determine baud rate and verify radio on-line"""
+ global BAUD # Allows modification
+ bauds = [9600, 115200, 57600, 38400, 19200, 4800]
+ if BAUD > 0:
+ bauds.insert(0, BAUD) # Make the detected one first
+ # Flush the input buffer
+ radio.pipe.timeout = 0.005
+ junk = radio.pipe.read(256)
+ radio.pipe.timeout = STIMEOUT
+
+ for bd in bauds:
+ radio.pipe.baudrate = bd
+ BAUD = bd
+ radio.pipe.write(";")
+ radio.pipe.write(";")
+ resp = radio.pipe.read(4)
+ radio.pipe.write("ID;")
+ resp = radio.pipe.read(6)
+ if resp == radio.ID: # Good comms
+ resp = command(radio.pipe, "AI0", 0, W8L)
+ return
+ elif resp in RADIO_IDS.keys():
+ msg = "Radio reported as model %s, not %s!" % \
+ (RADIO_IDS[resp], radio.MODEL)
+ raise errors.RadioError(msg)
+ raise errors.RadioError("No response from radio")
+ return
+
+
+def read_str(radio, trm=";"):
+ """ Read chars until terminator """
+ stq = ""
+ ctq = ""
+ while ctq != trm:
+ ctq = radio.pipe.read(1)
+ stq += ctq
+ LOG.debug(" + [%s]" % stq)
+ return stq[:-1] # Return without trm
+
+
+def _read_mem(radio):
+ """Get the memory map"""
+ global BEEPVOL
+ # UI progress
+ status = chirp_common.Status()
+ status.cur = 0
+ status.max = radio._upper + 10 # 10 P chans
+ status.msg = "Reading Channel Memory..."
+ radio.status_fn(status)
+
+ result0 = command(radio.pipe, "EX0120000", 12, W8S)
+ BEEPVOL = int(result0[6:12])
+ result0 = command(radio.pipe, "EX01200000", 0, W8L) # Silence beeps
+ data = ""
+ mrlen = 41 # Expected fixed return string length
+ for chn in range(0, (radio._upper + 11)): # Loop stops at +10
+ # Request this mem chn
+ r0ch = 999
+ r1ch = r0ch
+ # return results can come back out of order
+ while (r0ch != chn):
+ # simplex
+ result0 = command(radio.pipe, "MR0%03i" % chn,
+ mrlen, W8S)
+ result0 += read_str(radio)
+ r0ch = int(result0[3:6])
+ while (r1ch != chn):
+ # split
+ result1 = command(radio.pipe, "MR1%03i" % chn,
+ mrlen, W8S)
+ result1 += read_str(radio)
+ r1ch = int(result1[3:6])
+ data += radio._parse_mem_spec(result0, result1)
+ # UI Update
+ status.cur = chn
+ status.msg = "Reading Channel Memory..."
+ radio.status_fn(status)
+
+ if len(data) == 0: # To satisfy run_tests
+ raise errors.RadioError('No data received.')
+ return data
+
+
+def _make_dat(sx, nb):
+ """ Split the string sx into nb binary bytes """
+ vx = int(sx)
+ dx = ""
+ if nb > 3:
+ dx += chr((vx >> 24) & 0xFF)
+ if nb > 2:
+ dx += chr((vx >> 16) & 0xFF)
+ if nb > 1:
+ dx += chr((vx >> 8) & 0xFF)
+ dx += chr(vx & 0xFF)
+ return dx
+
+
+def _sets_val(stx, nv, nb):
+ """ Split string stx into nv nb-bit values in 1 byte """
+ # Right now: hardcoded for nv:3 values of nb:2 bits each
+ v1 = int(stx[0]) << 6
+ v1 = v1 | (int(stx[1]) << 4)
+ v1 = v1 | (int(stx[2]) << 2)
+ return chr(v1)
+
+
+def _sets_asf(stx):
+ """ Process AS0 auto-mode setting """
+ asm = _make_dat(stx[0:11], 4) # 11-bit freq
+ a1 = int(stx[11]) # 4-bit mode
+ a2 = 0 # not used in TS-480
+ asm += chr((a1 << 4) | (a2 << 2))
+ return asm
+
+
+def my_val_list(setting, opts, obj, atrb, fix=0, ndx=-1):
+ """Callback:from ValueList. Set the integer index."""
+ # This function is here to be available to get_mem and get_set
+ # fix is optional additive offset to the list index
+ # ndx is optional obj[ndx] array index
+ value = opts.index(str(setting.value))
+ value += fix
+ if ndx >= 0: # indexed obj
+ setattr(obj[ndx], atrb, value)
+ else:
+ setattr(obj, atrb, value)
+ return
+
+
+def _read_settings(radio):
+ """ Continue filling memory map"""
+ global MEMSEL
+ # setc: the list of CAT commands for downloaded settings
+ # Block paramters first. In the exact order of MEM_FORMAT
+ setc = radio.SETC
+ setc.extend(radio.EX) # Menu A EX params
+ setc.extend(radio.EX) # Menu B
+ status = chirp_common.Status()
+ status.cur = 0
+ status.max = 32 + 50 + 8 + 17 + 17
+ status.msg = "Reading Settings..."
+ radio.status_fn(status)
+
+ setts = ""
+ nc = 0
+ for cmc in setc:
+ skipme = False
+ argx = "" # Extended arguments
+ if cmc == "AS0":
+ skipme = True # flag to disable further processing
+ for ix in range(32): # 32 AS params
+ result0 = command(radio.pipe, cmc, 19, W8S,
+ "%02i" % ix)
+ xc = len(cmc) + 2
+ result0 = result0[xc:]
+ setts += _sets_asf(result0)
+ nc += 1
+ status.cur = nc
+ radio.status_fn(status)
+ elif cmc == "SS":
+ skipme = True
+ for ix in range(10): # 10 chans
+ for nx in range(5): # 5 spots
+ result0 = command(radio.pipe, cmc, 16, W8S,
+ "%1i%1i" % (ix, nx))
+ setts += _make_dat(result0[4:], 4)
+ nc += 1
+ status.cur = nc
+ radio.status_fn(status)
+ elif (cmc == "MF0") or (cmc == "MF1"):
+ result0 = command(radio.pipe, cmc, 0, W8S)
+ skipme = True # cmd only, no response
+ else: # issue the cmc cmd as-is with argx
+ if str(cmc).startswith("EX"):
+ argx = "0000"
+ result0 = command(radio.pipe, cmc, 0, W8S, argx)
+ result0 = read_str(radio) # various length responses
+ # strip the cmd echo
+ xc = len(cmc)
+ result0 = result0[xc:]
+ # Cmd has been sent, process the result
+ if (cmc == "FA") or (cmc == "FB"): # Response is 11-bit frq
+ skipme = True
+ setts += _make_dat(result0, 4) # 11-bit freq
+ elif (cmc == "MF0") or (cmc == "MF1"): # No stored response
+ skipme = True
+ # Generic single byte processing
+ if not skipme:
+ setts += chr(int(result0))
+ if cmc == "MF": # Save the initial Menu selection
+ MEMSEL = int(result0)
+ nc += 1
+ status.cur = nc
+ radio.status_fn(status)
+ setts += radio.MODEL.ljust(9)
+ # Now set the initial menu selection back
+ result0 = command(radio.pipe, "MF", 0, W8L, "%1i" % MEMSEL)
+ # And the original Beep Volume
+ result0 = command(radio.pipe, "EX0120000%i" % BEEPVOL, 0, W8L)
+ return setts
+
+
+def _write_mem(radio):
+ """ Send MW commands for each channel """
+ global BEEPVOL
+ # UI progress
+ status = chirp_common.Status()
+ status.cur = 0
+ status.max = radio._upper + 10 # 10 P chans
+ status.msg = "Writing Channel Memory"
+ radio.status_fn(status)
+
+ result0 = command(radio.pipe, "EX0120000", 12, W8S)
+ BEEPVOL = int(result0[6:12])
+ result0 = command(radio.pipe, "EX01200000", 0, W8L) # Silence beeps
+
+ for chn in range(0, (radio._upper + 11)): # Loop stops at +20
+ _mem = radio._memobj.ch_mem[chn]
+ cmx = "MW0%03i" % chn
+ stm = cmx + radio._make_base_spec(_mem, _mem.rxfreq)
+ result0 = command(radio.pipe, stm, 0, W8L) # No response
+ if _mem.txfreq > 0: # Don't write MW1 if empty/deleted
+ cmx = "MW1%03i" % chn
+ stm = cmx + radio._make_base_spec(_mem, _mem.txfreq)
+ result0 = command(radio.pipe, stm, 0, W8L)
+ status.cur = chn
+ radio.status_fn(status)
+ return
+
+
+def _write_sets(radio):
+ """ Send settings and Menu a/b """
+ status = chirp_common.Status()
+ status.cur = 0
+ status.max = 124 # Total to send
+ status.msg = "Writing Settings"
+ radio.status_fn(status)
+ # Define mem struct shortcuts
+ _sets = radio._memobj.settings
+ _asf = radio._memobj.asf
+ _ssf = radio._memobj.ssf
+ _mex = radio._memobj.exset
+ snx = 0 # Settings status counter
+ stlen = 0 # No response count
+ # Send 32 AS
+ for ix in range(32):
+ scm = "AS0%02i%011i%1i%1i" % (ix, _asf[ix].asfreq,
+ _asf[ix].asmode, _asf[ix].asdata)
+ result0 = command(radio.pipe, scm, stlen, W8S)
+ snx += 1
+ status.cur = snx
+ radio.status_fn(status)
+ # Send 50 SS
+ for ix in range(10):
+ for kx in range(5):
+ nx = ix * 5 + kx
+ scm = "SS%1i%1i%011i" % (ix, kx, _ssf[nx].ssfreq)
+ result0 = command(radio.pipe, scm, stlen, W8S)
+ snx += 1
+ status.cur = snx
+ radio.status_fn(status)
+ # Send 8 thingies
+ scm = "AG0%03i" % _sets.ag
+ result0 = command(radio.pipe, scm, stlen, W8S)
+ scm = "AN%1i" % _sets.an
+ result0 = command(radio.pipe, scm, stlen, W8S)
+ scm = "FA%011i" % _sets.fa
+ result0 = command(radio.pipe, scm, stlen, W8S)
+ scm = "FB%011i" % _sets.fb
+ result0 = command(radio.pipe, scm, stlen, W8S)
+ scm = "MG%03i" % _sets.mg
+ result0 = command(radio.pipe, scm, stlen, W8S)
+ scm = "PC%03i" % _sets.pc
+ result0 = command(radio.pipe, scm, stlen, W8S)
+ scm = "RG%03i" % _sets.rg
+ result0 = command(radio.pipe, scm, stlen, W8S)
+ # TY cmd is firmware read-only
+ scm = "MF0" # Select menu A/B
+ result0 = command(radio.pipe, scm, stlen, W8S)
+ snx += 8
+ status.cur = snx
+ radio.status_fn(status)
+ # Send 17 Menu A EX
+ setc = radio.EX # list of EX cmds
+ for ix in range(2):
+ for cmx in setc:
+ if str(cmx)[0:2] == "MF":
+ scm = cmx
+ else: # The EX cmds
+ scm = "%s0000%i" % (cmx, getattr(_mex[ix],
+ cmx.lower()))
+ result0 = command(radio.pipe, scm, stlen, W8S)
+ snx += 1
+ status.cur = snx
+ radio.status_fn(status)
+ # Now set the initial menu selection back
+ result0 = command(radio.pipe, "MF", 0, W8L, "%1i" % _sets.mf)
+ # And the original Beep Volume
+ result0 = command(radio.pipe, "EX0120000%i" % BEEPVOL, 0, W8L)
+ return
+
+
+@directory.register
+class TS480Radio(chirp_common.CloneModeRadio):
+ """Kenwood TS-590"""
+ VENDOR = "Kenwood"
+ MODEL = "TS-480_CloneMode"
+ ID = "ID020;"
+ # Settings read/write cmd sequence list
+ SETC = ["AS0", "SS", "AG0", "AN", "FA", "FB",
+ "MF", "MG", "PC", "RG", "TY", "MF0"]
+ # This is the TS-590SG MENU A/B read_settings paramter tuple list
+ # The order is mandatory; to match the Mem_Format sequence
+ EX = ["EX000", "EX003", "EX007", "EX008", "EX009", "EX010", "EX011",
+ "EX012", "EX013", "EX014", "EX021", "EX022", "EX048", "EX049",
+ "EX050", "EX051", "EX052", "MF1"]
+ # EX menu settings label dictionary. Key is the EX number
+ EX_LBL = {0: " Display brightness",
+ 3: " Tuning control adj rate (Hz)",
+ 12: " Beep volume",
+ 13: " Sidetone volume",
+ 14: " Message playback volume",
+ 7: " Temporary MR Chan freq allowed",
+ 8: " Program Scan slowdown",
+ 9: " Program Scan slowdown range (Hz)",
+ 10: " Program Scan hold",
+ 11: " Scan Resume method",
+ 21: " TX Power fine adjust",
+ 22: " Timeout timer (Secs)",
+ 48: " Panel PF-A function",
+ 49: " MIC PF1 function",
+ 50: " MIC PF2 function",
+ 51: " MIC PF3 function",
+ 52: " MIC PF4 function"}
+
+ _upper = 99
+
+ def get_features(self):
+ rf = chirp_common.RadioFeatures()
+
+ rf.can_odd_split = False
+ rf.has_bank = False
+ rf.has_ctone = True
+ rf.has_dtcs = False
+ rf.has_dtcs_polarity = False
+ rf.has_name = True
+ rf.has_settings = True
+ rf.has_offset = True
+ rf.has_mode = True
+ rf.has_tuning_step = True
+ rf.has_nostep_tuning = True # Radio accepts any entered freq
+ rf.has_cross = False
+ rf.has_comment = False
+ rf.memory_bounds = (0, self._upper)
+ rf.valid_bands = TS480_BANDS
+ rf.valid_characters = chirp_common.CHARSET_UPPER_NUMERIC + "*+-/"
+ rf.valid_duplexes = TS480_DUPLEX
+ rf.valid_modes = TS480_MODES
+ rf.valid_skips = TS480_SKIP
+ rf.valid_tuning_steps = TS480_TUNE_STEPS
+ rf.valid_tmodes = ["", "Tone", "TSQL"]
+ rf.valid_name_length = 8 # 8 character channel names
+
+ return rf
+
+ @classmethod
+ def get_prompts(cls):
+ rp = chirp_common.RadioPrompts()
+ rp.info = _(dedent("""\
+ P-VFO channels 100-109 are considered Settings.\n
+ Only a subset of the over 130 available radio settings
+ are supported in this release.\n
+ """))
+ rp.pre_download = _(dedent("""\
+ Follow these instructions to download the radio memory:
+ 1 - Connect your interface cable
+ 2 - Radio > Download from radio: Don't adjust any settings
+ on the radio head!
+ 3 - Disconnect your interface cable
+ """))
+ rp.pre_upload = _(dedent("""\
+ Follow these instructions to upload the radio memory:
+ 1 - Connect your interface cable
+ 2 - Radio > Upload to radio: Don't adjust any settings
+ on the radio head!
+ 3 - Disconnect your interface cable
+ """))
+ return rp
+
+ def sync_in(self):
+ """Download from radio"""
+ try:
+ _connect_radio(self)
+ data = _read_mem(self)
+ data += _read_settings(self)
+ except errors.RadioError:
+ # Pass through any real errors we raise
+ raise
+ except Exception:
+ # If anything unexpected happens, make sure we raise
+ # a RadioError and log the problem
+ LOG.exception('Unexpected error during download')
+ raise errors.RadioError('Unexpected error communicating '
+ 'with the radio')
+
+ self._mmap = memmap.MemoryMap(data)
+ self.process_mmap()
+ return
+
+ def sync_out(self):
+ """Upload to radio"""
+ try:
+ _connect_radio(self)
+ _write_mem(self)
+ _write_sets(self)
+ except Exception:
+ # If anything unexpected happens, make sure we raise
+ # a RadioError and log the problem
+ LOG.exception('Unexpected error during upload')
+ raise errors.RadioError('Unexpected error communicating '
+ 'with the radio')
+ return
+
+ def process_mmap(self):
+ """Process the mem map into the mem object"""
+ self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
+ return
+
+ def get_memory(self, number):
+ """Convert raw channel data (_mem) into UI columns (mem)"""
+ mem = chirp_common.Memory()
+ if number > 99 and number < 110:
+ return # Don't show VFO edges as mem chans
+ _mem = self._memobj.ch_mem[number]
+ mem.number = number
+ mnx = ""
+ for char in _mem.name:
+ mnx += chr(char)
+ mem.name = mnx.strip()
+ mem.name = mem.name.upper()
+ if _mem.rxfreq == 0:
+ mem.empty = True
+ return mem
+ mem.empty = False
+ mem.freq = int(_mem.rxfreq)
+ mem.duplex = TS480_DUPLEX[0] # None by default
+ mem.offset = 0
+ if _mem.rxfreq < _mem.txfreq: # + shift
+ mem.duplex = TS480_DUPLEX[2]
+ mem.offset = _mem.txfreq - _mem.rxfreq
+ if _mem.rxfreq > _mem.txfreq: # - shift
+ mem.duplex = TS480_DUPLEX[1]
+ mem.offset = _mem.rxfreq - _mem.txfreq
+ if _mem.txfreq == 0:
+ # leave offset alone, or run_tests will bomb
+ mem.duplex = TS480_DUPLEX[0]
+ mx = _mem.xmode - 1 # CAT modes start at 1
+ if _mem.xmode == 9: # except there is no xmode 9
+ mx = 7
+ mem.mode = TS480_MODES[mx]
+ mem.tmode = ""
+ mem.cross_mode = "Tone->Tone"
+ mem.ctone = TS480_TONES[_mem.ctone]
+ mem.rtone = TS480_TONES[_mem.rtone]
+ if _mem.tmode == 1:
+ mem.tmode = "Tone"
+ elif _mem.tmode == 2:
+ mem.tmode = "TSQL"
+ elif _mem.tmode == 3:
+ mem.tmode = "Cross"
+ mem.skip = TS480_SKIP[_mem.skip]
+ # Tuning step depends on mode
+ options = [0.5, 1.0, 2.5, 5.0, 10.0] # SSB/CS/FSK
+ if _mem.xmode == 4 or _mem.xmode == 5: # AM/FM
+ options = TS480_TUNE_STEPS[3:]
+ mem.tuning_step = options[_mem.step]
+ return mem
+
+ def set_memory(self, mem):
+ """Convert UI column data (mem) into MEM_FORMAT memory (_mem)"""
+ _mem = self._memobj.ch_mem[mem.number]
+ if mem.empty:
+ _mem.rxfreq = 0
+ _mem.txfreq = 0
+ _mem.xmode = 0
+ _mem.step = 0
+ _mem.tmode = 0
+ _mem.rtone = 0
+ _mem.ctone = 0
+ _mem.skip = 0
+ _mem.name = " "
+ return
+
+ if mem.number > self._upper: # Specials: No Name changes
+ ix = 0
+ # LOG.warning("Special Chan set_mem @ %i" % mem.number)
+ else:
+ nx = len(mem.name)
+ for ix in range(8):
+ if ix < nx:
+ _mem.name[ix] = mem.name[ix].upper()
+ else:
+ _mem.name[ix] = " " # assignment needs 8 chrs
+ _mem.rxfreq = mem.freq
+ _mem.txfreq = 0
+ if mem.duplex == "+":
+ _mem.txfreq = mem.freq + mem.offset
+ if mem.duplex == "-":
+ _mem.txfreq = mem.freq - mem.offset
+ ix = TS480_MODES.index(mem.mode)
+ _mem.xmode = ix + 1 # stored as CAT values, LSB= 1
+ if ix == 7: # FSK-R
+ _mem.xmode = 9 # There is no CAT 8
+ _mem.tmode = 0
+ _mem.rtone = TS480_TONES.index(mem.rtone)
+ _mem.ctone = TS480_TONES.index(mem.ctone)
+ if mem.tmode == "Tone":
+ _mem.tmode = 1
+ if mem.tmode == "TSQL":
+ _mem.tmode = 2
+ _mem.skip = 0
+ if mem.skip == "S":
+ _mem.skip = 1
+ options = [0.5, 1.0, 2.5, 5.0, 10.0] # SSB/CS/FSK steps
+ if _mem.xmode == 4 or _mem.xmode == 5: # AM/FM
+ options = TS480_TUNE_STEPS[3:]
+ _mem.step = options.index(mem.tuning_step)
+ return
+
+ def _parse_mem_spec(self, spec0, spec1):
+ """ Extract ascii memory paramters; build data string """
+ # spec0 is simplex result, spec1 is split
+ # pad string so indexes match Kenwood docs
+ spec0 = "x" + spec0 # match CAT document 1-based description
+ ix = len(spec0)
+ # _pxx variables are STRINGS
+ _p1 = spec0[3] # P1 Split Specification
+ _p3 = spec0[5:7] # P3 Memory Channel
+ _p4 = spec0[7:18] # P4 Frequency
+ _p5 = spec0[18] # P5 Mode
+ _p6 = spec0[19] # P6 Chan Lockout (Skip)
+ _p7 = spec0[20] # P7 Tone Mode
+ _p8 = spec0[21:23] # P8 Tone Frequency Index
+ if _p8 == "00":
+ _p8 = "08"
+ _p9 = spec0[23:25] # P9 CTCSS Frequency Index
+ if _p9 == "00":
+ _p9 = "08"
+ _p14 = spec0[39:41] # P14 Step Size
+ _p16 = spec0[41:50] # P16 Max 8-Char Name if assigned
+
+ spec1 = "x" + spec1
+ _p4s = int(spec1[7:18]) # P4: Offset freq
+
+ datm = "" # Fill in MEM_FORMAT sequence
+ datm += _make_dat(_p4, 4) # rxreq: u32, 4 bytes/chars
+ datm += _make_dat(_p4s, 4) # tx freq
+ datm += chr(int(_p5)) # xmode: 0-9
+ datm += chr(int(_p7)) # Tmode: 0-3
+ datm += chr(int(_p8)) # rtone: 00-41
+ datm += chr(int(_p9)) # ctone: 00-41
+ datm += chr(int(_p6)) # skip: 0/1
+ datm += chr(int(_p14)) # step: 0-9
+ v1 = len(_p16)
+ for ix in range(8):
+ if ix < v1:
+ datm += _p16[ix]
+ else:
+ datm += " "
+ return datm
+
+ def _make_base_spec(self, mem, freq):
+ spec = "%011i%1i%1i%1i%02i%02i00000000000000%02i0%s" \
+ % (freq, mem.xmode, mem.skip, mem.tmode, mem.rtone,
+ mem.ctone, mem.step, mem.name)
+
+ return spec.strip()
+
+ def get_settings(self):
+ """Translate the MEM_FORMAT structs into settings in the UI"""
+ # Define mem struct write-back shortcuts
+ _sets = self._memobj.settings
+ _asf = self._memobj.asf
+ _ssf = self._memobj.ssf
+ _mex = self._memobj.exset
+ _chm = self._memobj.ch_mem
+ basic = RadioSettingGroup("basic", "Basic Settings")
+ pvfo = RadioSettingGroup("pvfo", "VFO Band Edges")
+ mena = RadioSettingGroup("mena", "Menu A")
+ menb = RadioSettingGroup("menb", "Menu B")
+ amode = RadioSettingGroup("amode", "Auto Mode")
+ ssc = RadioSettingGroup("ssc", "Slow Scan")
+ group = RadioSettings(basic, pvfo, mena, menb, amode, ssc)
+
+ mhz1 = 1000000.
+
+ # Callback functions
+ def _my_readonly(setting, obj, atrb):
+ """NOP callback, prevents writing the setting"""
+ vx = 0
+ return
+
+ def my_adjraw(setting, obj, atrb, fix=0, ndx=-1):
+ """Callback for Integer add or subtract fix from value."""
+ vx = int(str(setting.value))
+ value = vx + int(fix)
+ if value < 0:
+ value = 0
+ if ndx < 0:
+ setattr(obj, atrb, value)
+ else:
+ setattr(obj[ndx], atrb, value)
+ return
+
+ def my_mhz_val(setting, obj, atrb, ndx=-1):
+ """ Callback to set freq back to Htz"""
+ vx = float(str(setting.value))
+ vx = int(vx * mhz1)
+ if ndx < 0:
+ setattr(obj, atrb, vx)
+ else:
+ setattr(obj[ndx], atrb, vx)
+ return
+
+ def my_bool(setting, obj, atrb, ndx=-1):
+ """ Callback to properly set boolean """
+ # set_settings is not setting [indexed] booleans???
+ vx = 0
+ if str(setting.value) == "True":
+ vx = 1
+ if ndx < 0:
+ setattr(obj, atrb, vx)
+ else:
+ setattr(obj[ndx], atrb, vx)
+ return
+
+ def my_asf_mode(setting, obj, nx=0):
+ """ Callback to extract mode and create asmode, asdata """
+ v1 = TS480_MODES.index(str(setting.value))
+ v2 = 0 # asdata
+ vx = v1 + 1 # stored as CAT values, same as xmode
+ if v1 == 7:
+ vx = 9
+ if v1 > 7: # a Data mode
+ v2 = 1
+ if v1 == 8:
+ vx = 1 # LSB
+ elif v1 == 9:
+ vx = 2 # USB
+ elif v1 == 10:
+ vx = 4 # FM
+ setattr(obj[nx], "asdata", v2)
+ setattr(obj[nx], "asmode", vx)
+ return
+
+ def my_fnctns(setting, obj, ndx, atrb):
+ """ Filter only valid key function assignments """
+ vx = int(str(setting.value))
+ if vx > 79:
+ vx = 99 # Off
+ setattr(obj[ndx], atrb, vx)
+ return
+
+ def my_labels(kx):
+ lbl = "%03i:" % kx # SG EX number
+ lbl += self.EX_LBL[kx] # and the label to match
+ return lbl
+
+ # ===== BASIC GROUP =====
+
+ options = ["TS-480HX (200W)", "TS-480SAT (100W + AT)",
+ "Japanese 50W type", "Japanese 20W type"]
+ rx = RadioSettingValueString(14, 22, options[_sets.ty])
+ rset = RadioSetting("settings.ty", "FirmwareVersion", rx)
+ rset.set_apply_callback(_my_readonly, _sets, "ty")
+ basic.append(rset)
+
+ rx = RadioSettingValueInteger(0, 255, _sets.ag)
+ rset = RadioSetting("settings.ag", "AF Gain", rx)
+ # rset.set_apply_callback(my_adjraw, _sets, "ag", -1)
+ basic.append(rset)
+
+ rx = RadioSettingValueInteger(0, 100, _sets.rg)
+ rset = RadioSetting("settings.rg", "RF Gain", rx)
+ # rset.set_apply_callback(my_adjraw, _sets, "rg", -1)
+ basic.append(rset)
+
+ options = ["ANT1", "ANT2"]
+ # CAUTION: an has value of 1 or 2
+ rx = RadioSettingValueList(options, options[_sets.an - 1])
+ rset = RadioSetting("settings.an", "Antenna Selected", rx)
+ # Add 1 to the changed value. S/b 1/2
+ rset.set_apply_callback(my_val_list, options, _sets, "an", 1)
+ basic.append(rset)
+
+ rx = RadioSettingValueInteger(0, 100, _sets.mg)
+ rset = RadioSetting("settings.mg", "Microphone gain", rx)
+ basic.append(rset)
+
+ nx = 5 # Coarse step
+ if bool(_mex[0].ex021): # Power Fine enabled in menu A
+ nx = 1
+ vx = _sets.pc # Trap invalid values from run_tests.py
+ if vx < 5:
+ vx = 5
+ options = [200, 100, 50, 20] # subject to firmware
+ rx = RadioSettingValueInteger(5, options[_sets.ty], vx, nx)
+ sx = "TX Output power (Watts)"
+ rset = RadioSetting("settings.pc", sx, rx)
+ basic.append(rset)
+
+ val = _sets.fa / mhz1 # valid range is for receiver
+ rx = RadioSettingValueFloat(0.05, 60.0, val, 0.001, 3)
+ sx = "VFO-A Frequency (MHz)"
+ rset = RadioSetting("settings.fa", sx, rx)
+ rset.set_apply_callback(my_mhz_val, _sets, "fa")
+ basic.append(rset)
+
+ val = _sets.fb / mhz1
+ rx = RadioSettingValueFloat(0.05, 60.0, val, 0.001, 3)
+ sx = "VFO-B Frequency (MHz)"
+ rset = RadioSetting("settings.fb", sx, rx)
+ rset.set_apply_callback(my_mhz_val, _sets, "fb")
+ basic.append(rset)
+
+ options = ["Menu A", "Menu B"]
+ rx = RadioSettingValueList(options, options[_sets.mf])
+ sx = "Menu Selected"
+ rset = RadioSetting("settings.mf", sx, rx)
+ rset.set_apply_callback(my_val_list, options, _sets, "mf")
+ basic.append(rset)
+
+ # ==== VFO Edges Group ================
+
+ for mx in range(100, 110):
+ val = _chm[mx].rxfreq / mhz1
+ if val < 1.8: # Many operators never use this
+ val = 1.8 # So default is 0.0
+ rx = RadioSettingValueFloat(1.8, 54.0, val, 0.001, 3)
+ sx = "VFO-Band %i lower limit (MHz)" % (mx - 100)
+ rset = RadioSetting("ch_mem.rxfreq/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_mhz_val, _chm, "rxfreq", mx)
+ pvfo.append(rset)
+
+ val = _chm[mx].txfreq / mhz1
+ if val < 1.8:
+ val = 54.0
+ rx = RadioSettingValueFloat(1.8, 54.0, val, 0.001, 3)
+ sx = " VFO-Band %i upper limit (MHz)" % (mx - 100)
+ rset = RadioSetting("ch_mem.txfreq/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_mhz_val, _chm, "txfreq", mx)
+ pvfo.append(rset)
+
+ kx = _chm[mx].xmode
+ options = ["None", "LSB", "USB", "CW", "FM", "AM", "FSK",
+ "CW-R", "N/A", "FSK-R"]
+ rx = RadioSettingValueList(options, options[kx])
+ sx = " VFO-Band %i Tx/Rx Mode" % (mx - 100)
+ rset = RadioSetting("ch_mem.xmode/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_val_list, options, _chm,
+ "xmode", 0, mx)
+ pvfo.append(rset)
+
+ # ==== Menu A/B Group =================
+
+ for mx in range(2): # A/B index
+ sx = my_labels(0)
+ rx = RadioSettingValueInteger(0, 4, _mex[mx].ex000)
+ rset = RadioSetting("exset.ex000", sx, rx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueInteger(0, 9, _mex[mx].ex012)
+ sx = my_labels(12)
+ rset = RadioSetting("exset.ex012", sx, rx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ sx = my_labels(13)
+ rx = RadioSettingValueInteger(0, 9, _mex[mx].ex013)
+ rset = RadioSetting("exset.ex013", sx, rx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ sx = my_labels(14)
+ rx = RadioSettingValueInteger(0, 9, _mex[mx].ex014)
+ rset = RadioSetting("exset.ex014", sx, rx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ options = ["250", "500", "1000"]
+ rx = RadioSettingValueList(options, options[_mex[mx].ex003])
+ sx = my_labels(3)
+ rset = RadioSetting("exset.ex003/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_val_list, options, _mex,
+ "ex003", 0, mx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_mex[mx].ex007))
+ sx = my_labels(7)
+ rset = RadioSetting("exset.ex007/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_bool, _mex, "ex007", mx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_mex[mx].ex008))
+ sx = my_labels(8)
+ rset = RadioSetting("exset.ex008/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_bool, _mex, "ex008", mx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ options = ["100", "200", "300", "400", "500"]
+ rx = RadioSettingValueList(options, options[_mex[mx].ex009])
+ sx = my_labels(9)
+ rset = RadioSetting("exset.ex009/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_val_list, options, _mex,
+ "ex009", 0, mx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_mex[mx].ex010))
+ sx = my_labels(10)
+ rset = RadioSetting("exset.ex010/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_bool, _mex, "ex010", mx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ options = ["TO", "CO"]
+ rx = RadioSettingValueList(options, options[_mex[mx].ex011])
+ sx = my_labels(11)
+ rset = RadioSetting("exset.ex011/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_val_list, options, _mex,
+ "ex011", 0, mx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_mex[mx].ex021))
+ sx = my_labels(21)
+ rset = RadioSetting("exset.ex021/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_bool, _mex, "ex021", mx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ options = ["Off", "3", "5", "10", "20", "30"]
+ rx = RadioSettingValueList(options, options[_mex[mx].ex022])
+ sx = my_labels(22)
+ rset = RadioSetting("exset.ex022/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_val_list, options, _mex,
+ "ex022", 0, mx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueInteger(0, 99, _mex[mx].ex048)
+ sx = my_labels(48)
+ rset = RadioSetting("exset.ex048/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_fnctns, _mex, mx, "ex048")
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueInteger(0, 99, _mex[mx].ex049)
+ sx = my_labels(49)
+ rset = RadioSetting("exset.ex049/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_fnctns, _mex, mx, "ex049")
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueInteger(0, 99, _mex[mx].ex050)
+ sx = my_labels(50)
+ rset = RadioSetting("exset.ex050/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_fnctns, _mex, mx, "ex050")
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueInteger(0, 99, _mex[mx].ex051)
+ sx = my_labels(51)
+ rset = RadioSetting("exset.ex051/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_fnctns, _mex, mx, "ex051")
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueInteger(0, 99, _mex[mx].ex052)
+ sx = my_labels(52)
+ rset = RadioSetting("exset.ex052/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_fnctns, _mex, mx, "ex052")
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+ # End of for mx loop
+
+ # ==== Auto Scan Params (amode) ==============
+ for ix in range(32):
+ val = _asf[ix].asfreq / mhz1
+ rx = RadioSettingValueFloat(0.03, 60.0, val, 0.001, 3)
+ rset = RadioSetting("asf.asfreq/%d" % ix,
+ "Scan %02i Freq (MHz)" % ix, rx)
+ rset.set_apply_callback(my_mhz_val, _asf, "asfreq", ix)
+ amode.append(rset)
+
+ mx = _asf[ix].asmode - 1 # Same logic as xmode
+ if _asf[ix].asmode == 9:
+ mx = 7
+ rx = RadioSettingValueList(TS480_MODES, TS480_MODES[mx])
+ rset = RadioSetting("asf.asmode/%d" % ix, " Mode", rx)
+ rset.set_apply_callback(my_asf_mode, _asf, ix)
+ amode.append(rset)
+
+ # ==== Slow Scan Settings ===
+ for ix in range(10): # Chans
+ for nx in range(5): # spots
+ px = ((ix * 5) + nx)
+ val = _ssf[px].ssfreq / mhz1
+ stx = " - - - Slot %02i Freq (MHz)" % nx
+ if nx == 0:
+ stx = "Slow Scan %02i, Slot 0 Freq (MHz" % ix
+ rx = RadioSettingValueFloat(0, 54.0, val, 0.001, 3)
+ rset = RadioSetting("ssf.ssfreq/%d" % px, stx, rx)
+ rset.set_apply_callback(my_mhz_val, _ssf, "ssfreq", px)
+ ssc.append(rset)
+
+ return group # END get_settings()
+
+ def set_settings(self, settings):
+ _settings = self._memobj.settings
+ _mem = self._memobj
+ for element in settings:
+ if not isinstance(element, RadioSetting):
+ self.set_settings(element)
+ 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, e:
+ LOG.debug(element.get_name())
+ raise
+ return
diff --git a/chirp/drivers/ts590.py b/chirp/drivers/ts590.py
new file mode 100644
index 0000000..497aac3
--- /dev/null
+++ b/chirp/drivers/ts590.py
@@ -0,0 +1,1684 @@
+# Copyright 2019 Rick DeWitt <aa0rd@yahoo.com>
+# Version 1.0: CatClone- Implementing fake memory image
+# Version 2.0: No Live Mode library links. Implementing mem as Clone Mode
+# Having fun with Dictionaries
+# Version 2.1: Adding match_model function to fix File>New issue #7409
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import time
+import struct
+import logging
+import re
+import math
+import threading
+from chirp import chirp_common, directory, memmap
+from chirp import bitwise, errors, util
+from chirp.settings import RadioSettingGroup, RadioSetting, \
+ RadioSettingValueBoolean, RadioSettingValueList, \
+ RadioSettingValueString, RadioSettingValueInteger, \
+ RadioSettingValueFloat, RadioSettings, InvalidValueError
+from textwrap import dedent
+
+LOG = logging.getLogger(__name__)
+
+MEM_FORMAT = """
+#seekto 0x0000;
+struct { // 20 bytes per chan
+ u32 rxfreq;
+ u32 txfreq;
+ u8 xmode:4, // param stored as CAT value
+ data:2,
+ tmode:2;
+ u8 rtone;
+ u8 ctone;
+ u8 filter:1,
+ fmnrw:1,
+ skip:1,
+ nu:5;
+ char name[8];
+} ch_mem[120]; // 100 normal + 10 P-type + 10 EXT
+
+struct { // 5 bytes each
+ u32 asfreq;
+ u8 asmode:4, // param stored as CAT value
+ asdata:2,
+ asnu:2;
+} asf[32];
+
+struct { // 10 x 5 4-byte frequencies
+ u32 ssfreq;
+} ssf[50];
+
+struct { // 16 bytes
+ u8 txeq;
+ u8 rxeq;
+} eqx[8];
+
+struct { // Common to S and SG models
+ u8 ag;
+ u8 an1:2,
+ an2:2,
+ an3:2,
+ anu:2;
+ u32 fa;
+ u32 fb;
+ char fv[4];
+ u8 mf;
+ u8 mg;
+ u8 pc;
+ u8 rg;
+ u8 tp;
+} settings;
+
+struct { // Menu A/B settings by TS-590SG names
+ char ex001[8]; // 590S values get put in SG equiv
+ u8 ex002; // These params stored as nibbles
+ u8 ex003;
+ u8 ex005;
+ u8 ex006;
+ u8 ex007;
+ u8 ex008;
+ u8 ex009;
+ u8 ex010;
+ u8 ex011;
+ u8 ex012;
+ u8 ex013;
+ u8 ex016;
+ u8 ex017;
+ u8 ex018;
+ u8 ex019;
+ u8 ex021;
+ u8 ex022;
+ u8 ex023;
+ u8 ex024;
+ u8 ex025;
+ u8 ex026;
+ u8 ex054;
+ u8 ex055;
+ u8 ex076;
+ u8 ex077;
+ u8 ex087;
+ u8 ex088;
+ u8 ex089;
+ u8 ex090;
+ u8 ex091;
+ u8 ex092;
+ u8 ex093;
+ u8 ex094;
+ u8 ex095;
+ u8 ex096;
+ u8 ex097;
+ u8 ex098;
+ u8 ex099;
+} exset[2];
+
+ char mdl_name[9]; // appended model name, first 9 chars
+
+"""
+
+STIMEOUT = 2
+LOCK = threading.Lock()
+BAUD = 0 # Initial baud rate
+MEMSEL = 0 # Default Menu A
+BEEPVOL = 4 # Default beep volume
+W8S = 0.01 # short wait, secs
+W8L = 0.05 # long wait
+
+TS590_DUPLEX = ["", "-", "+"]
+TS590_SKIP = ["", "S"]
+
+# start at 0:LSB
+TS590_MODES = ["LSB", "USB", "CW", "FM", "AM", "FSK", "CW-R",
+ "FSK-R", "Data+LSB", "Data+USB", "Data+FM"]
+EX_MODES = ["FSK-R", "CW-R", "Data+LSB", "Data+USB", "Data+FM"]
+for ix in EX_MODES:
+ if ix not in chirp_common.MODES:
+ chirp_common.MODES.append(ix)
+
+TS590_TONES = list(chirp_common.TONES)
+TS590_TONES.append(1750.0)
+
+RADIO_IDS = { # From kenwood_live.py; used to report wrong radio
+ "ID019;": "TS-2000",
+ "ID009;": "TS-850",
+ "ID020;": "TS-480",
+ "ID021;": "TS-590S",
+ "ID023;": "TS-590SG"
+}
+
+
+def command(ser, cmd, rsplen, w8t=0.01, exts=""):
+ """Send @cmd to radio via @ser"""
+ # cmd is output string without ; terminator
+ # rsplen is expected response char count, including terminator
+ # If rsplen = 0 then do not read after write
+
+ start = time.time()
+ # LOCK.acquire()
+ stx = cmd # preserve cmd for response check
+ stx = stx + exts + ";" # append arguments
+ ser.write(stx)
+ LOG.debug("PC->RADIO [%s]" % stx)
+ ts = time.time() # implement the wait after command
+ while (time.time() - ts) < w8t:
+ ix = 0 # NOP
+ result = ""
+ if rsplen > 0: # read response
+ result = ser.read(rsplen)
+ LOG.debug("RADIO->PC [%s]" % result)
+ result = result[:-1] # remove terminator
+ # LOCK.release()
+ return result.strip()
+
+
+def _connect_radio(radio):
+ """Determine baud rate and verify radio on-line"""
+ global BAUD # Allows modification
+ bauds = [115200, 57600, 38400, 19200, 9600, 4800]
+ if BAUD > 0:
+ bauds.insert(0, BAUD) # Make the detected one first
+ # Flush the input buffer
+ radio.pipe.timeout = 0.005
+ radio.pipe.baudrate = 9600
+ junk = radio.pipe.read(256)
+ radio.pipe.timeout = STIMEOUT
+
+ for bd in bauds:
+ radio.pipe.baudrate = bd
+ BAUD = bd
+ radio.pipe.write(";")
+ radio.pipe.write(";")
+ resp = radio.pipe.read(4)
+ radio.pipe.write("ID;")
+ resp = radio.pipe.read(6)
+
+ if resp == radio.ID: # Good comms
+ resp = command(radio.pipe, "AI0", 0, W8L)
+ return
+ elif resp in RADIO_IDS.keys():
+ msg = "Radio reported as model %s, not %s!" % \
+ (RADIO_IDS[resp], radio.MODEL)
+ raise errors.RadioError(msg)
+ raise errors.RadioError("No response from radio")
+ return
+
+
+def read_str(radio, trm=";"):
+ """ Read chars until terminator """
+ stq = ""
+ ctq = ""
+ while ctq != trm:
+ ctq = radio.pipe.read(1)
+ stq += ctq
+ LOG.debug(" + [%s]" % stq)
+ return stq[:-1] # Return without trm
+
+
+def _read_mem(radio):
+ """Get the memory map"""
+ global BEEPVOL
+ # UI progress
+ status = chirp_common.Status()
+ status.cur = 0
+ status.max = radio._upper + 20 # 10 P chans and 10 EXT
+ status.msg = "Reading Channel Memory..."
+ radio.status_fn(status)
+
+ result0 = command(radio.pipe, "EX0050000", 9, W8S)
+ result0 += read_str(radio)
+ BEEPVOL = int(result0[6:])
+ result0 = command(radio.pipe, "EX005000000", 0, W8L) # Silence beeps
+
+ data = ""
+ mrlen = 41 # Expected fixed return string length
+ for chn in range(0, (radio._upper + 21)): # Loop stops at +20
+ # Request this mem chn
+ r0ch = 999
+ r1ch = r0ch
+ # return results can come back out of order
+ while (r0ch != chn):
+ # simplex
+ if chn < 100:
+ result0 = command(radio.pipe, "MR0 %02i" % chn,
+ mrlen, W8S)
+ result0 += read_str(radio)
+ else:
+ result0 = command(radio.pipe, "MR0%03i" % chn,
+ mrlen, W8S)
+ result0 += read_str(radio)
+ r0ch = int(result0[3:6])
+ while (r1ch != chn):
+ # split
+ if chn < 100:
+ result1 = command(radio.pipe, "MR1 %02i" % chn,
+ mrlen, W8S)
+ result1 += read_str(radio)
+ else:
+ result1 = command(radio.pipe, "MR1%03i" % chn,
+ mrlen, W8S)
+ result1 += read_str(radio)
+ r1ch = int(result1[3:6])
+ data += radio._parse_mem_spec(result0, result1)
+ # UI Update
+ status.cur = chn
+ status.msg = "Reading Channel Memory..."
+ radio.status_fn(status)
+
+ if len(data) == 0: # To satisfy run_tests
+ raise errors.RadioError('No data received.')
+ return data
+
+
+def _make_dat(sx, nb):
+ """ Split the string sx into nb binary bytes """
+ vx = int(sx)
+ dx = ""
+ if nb > 3:
+ dx += chr((vx >> 24) & 0xFF)
+ if nb > 2:
+ dx += chr((vx >> 16) & 0xFF)
+ if nb > 1:
+ dx += chr((vx >> 8) & 0xFF)
+ dx += chr(vx & 0xFF)
+ return dx
+
+
+def _sets_val(stx, nv=3, nb=2):
+ """ Split string stx into nv nb-bit values in 1 byte """
+ # Right now: hardcoded for nv:3 values of nb:2 bits each
+ v1 = int(stx[0]) << 6
+ v1 = v1 | (int(stx[1]) << 4)
+ v1 = v1 | (int(stx[2]) << 2)
+ return chr(v1)
+
+
+def _sets_asf(stx):
+ """ Process AS0 auto-mode setting """
+ asm = _make_dat(stx[0:11], 4) # 11-bit freq
+ a1 = int(stx[11]) # 4-bit mode
+ a2 = int(stx[12]) # 2-bit data
+ asm += chr((a1 << 4) | (a2 << 2))
+ return asm
+
+
+def my_val_list(setting, opts, obj, atrb, fix=0, ndx=-1):
+ """Callback:from ValueList. Set the integer index."""
+ # This function is here to be available to get_mem and get_set
+ # fix is optional additive offset to the list index
+ # ndx is optional obj[ndx] array index
+ value = opts.index(str(setting.value))
+ value += fix
+ if ndx >= 0: # indexed obj
+ setattr(obj[ndx], atrb, value)
+ else:
+ setattr(obj, atrb, value)
+ return
+
+
+def _read_settings(radio):
+ """ Continue filling memory map"""
+ global MEMSEL
+ # setc: the list of CAT commands for downloaded settings
+ # Block paramters first. In the exact order of MEM_FORMAT
+ setc = radio.SETC
+ setc.extend(radio.EX) # Menu A EX params
+ setc.extend(radio.EX) # Menu B
+ status = chirp_common.Status()
+ status.cur = 0
+ status.max = 32 + 50 + 8 + 11 + 39 + 39
+ status.msg = "Reading Settings..."
+ radio.status_fn(status)
+
+ setts = ""
+ nc = 0
+ for cmc in setc:
+ skipme = False
+ argx = "" # Extended arguments
+ if cmc == "AS0":
+ skipme = True # flag to disable further processing
+ for ix in range(32): # 32 AS params
+ result0 = command(radio.pipe, cmc, 19, W8S,
+ "%02i" % ix)
+ xc = len(cmc) + 2
+ result0 = result0[xc:]
+ setts += _sets_asf(result0)
+ nc += 1
+ status.cur = nc
+ radio.status_fn(status)
+ elif cmc == "SS":
+ skipme = True
+ for ix in range(10): # 10 chans
+ for nx in range(5): # 5 spots
+ result0 = command(radio.pipe, cmc, 16, W8S,
+ "%1i%1i" % (ix, nx))
+ setts += _make_dat(result0[4:], 4)
+ nc += 1
+ status.cur = nc
+ radio.status_fn(status)
+ elif cmc == "EQ":
+ skipme = True
+ for ix in range(8):
+ result0 = command(radio.pipe, cmc, 6, W8S, "0%1i"
+ % ix) # Tx eq
+ setts += chr(int(result0[4:])) # 'EQ13x", want the x
+ result0 = command(radio.pipe, cmc, 6, W8S, "1%1i"
+ % ix) # Rx eq
+ setts += chr(int(result0[4:]))
+ nc += 1
+ status.cur = nc
+ radio.status_fn(status)
+ elif ((not radio.SG) and (cmc == "EX087")) \
+ or (radio.SG and (cmc == "EX001")):
+ result0 = command(radio.pipe, cmc, 9, W8S, "0000")
+ result0 += read_str(radio) # Read pwron message
+ result0 = result0[8:]
+ nx = len(result0)
+ for ix in range(8):
+ if ix < nx:
+ sx = result0[ix] # may need to test valid char
+ setts += sx
+ else:
+ setts += chr(0)
+ skipme = True
+ nc += 1
+ status.cur = nc
+ radio.status_fn(status)
+ elif (cmc == "MF0") or (cmc == "MF1"):
+ result0 = command(radio.pipe, cmc, 0, W8S)
+ skipme = True # cmd only, no response
+ else: # issue the cmc cmd as-is with argx
+ if str(cmc).startswith("EX"):
+ argx = "0000"
+ result0 = command(radio.pipe, cmc, 0, W8S, argx)
+ result0 = read_str(radio) # various length responses
+ # strip the cmd echo
+ xc = len(cmc)
+ result0 = result0[xc:]
+ # Cmd has been sent, process the result
+ if cmc == "FV": # all chars
+ skipme = True
+ setts += result0
+ elif cmc == "AN": # Antenna selection has 3 values
+ skipme = True
+ setts += _sets_val(result0, 3, 2) # store as 2-bits each
+ elif (cmc == "FA") or (cmc == "FB"): # Response is 11-bit frq
+ skipme = True
+ setts += _make_dat(result0, 4) # 11-bit freq
+ elif (cmc == "MF0") or (cmc == "MF1"): # No stored response
+ skipme = True
+ # Generic single byte processing
+ if not skipme:
+ setts += chr(int(result0))
+ if cmc == "MF": # Save the initial Menu selection
+ MEMSEL = int(result0)
+ nc += 1
+ status.cur = nc
+ radio.status_fn(status)
+ setts += radio.MODEL.ljust(9)
+ # Now set the inidial menu selection back
+ result0 = command(radio.pipe, "MF", 0, W8L, "%1i" % MEMSEL)
+ # And the original Beep Volume
+ result0 = command(radio.pipe, "EX0050000%2i" % BEEPVOL, 0, W8L)
+ return setts
+
+
+def _write_mem(radio):
+ """ Send MW commands for each channel """
+ global BEEPVOL
+ # UI progress
+ status = chirp_common.Status()
+ status.cur = 0
+ status.max = radio._upper + 20 # 10 P chans and 10 EXT
+ status.msg = "Writing Channel Memory"
+ radio.status_fn(status)
+
+ result0 = command(radio.pipe, "EX0050000", 9, W8S)
+ result0 += read_str(radio)
+ BEEPVOL = int(result0[6:])
+ result0 = command(radio.pipe, "EX005000000", 0, W8L) # Silence beeps
+
+ for chn in range(0, (radio._upper + 21)): # Loop stops at +20
+ _mem = radio._memobj.ch_mem[chn]
+ cmx = "MW0 %02i" % chn
+ if chn > 99:
+ cmx = "MW0%03i" % chn
+ stm = cmx + radio._make_base_spec(_mem, _mem.rxfreq)
+ result0 = command(radio.pipe, stm, 0, W8L) # No response
+ cmx = "MW1 %02i" % chn
+ if chn > 99:
+ cmx = "MW1%03i" % chn
+ stm = cmx + radio._make_base_spec(_mem, _mem.txfreq)
+ if _mem.rxfreq > 0: # Dont write MW1 if empty
+ result0 = command(radio.pipe, stm, 0, W8L)
+ # UI Update
+ status.cur = chn
+ radio.status_fn(status)
+ return
+
+
+def _write_sets(radio):
+ """ Send settings and Menu a/b """
+ status = chirp_common.Status()
+ status.cur = 0
+ status.max = 187 # Total to send
+ status.msg = "Writing Settings"
+ radio.status_fn(status)
+ # Define mem struct shortcuts
+ _sets = radio._memobj.settings
+ _asf = radio._memobj.asf
+ _ssf = radio._memobj.ssf
+ _eqx = radio._memobj.eqx
+ _mex = radio._memobj.exset
+ snx = 0 # Settings status counter
+ stlen = 0 # No response count
+ # Send 32 AS
+ for ix in range(32):
+ scm = "AS0%02i%011i%1i%1i" % (ix, _asf[ix].asfreq,
+ _asf[ix].asmode, _asf[ix].asdata)
+ result0 = command(radio.pipe, scm, stlen, W8S)
+ snx += 1
+ status.cur = snx
+ radio.status_fn(status)
+ # Send 50 SS
+ for ix in range(10):
+ for kx in range(5):
+ nx = ix * 5 + kx
+ scm = "SS%1i%1i%011i" % (ix, kx, _ssf[nx].ssfreq)
+ result0 = command(radio.pipe, scm, stlen, W8S)
+ snx += 1
+ status.cur = snx
+ radio.status_fn(status)
+ # Send 16 EQ
+ for ix in range(8):
+ scm = "EQ0%1i%1i" % (ix, _eqx[ix].txeq)
+ result0 = command(radio.pipe, scm, stlen, W8S)
+ scm = "EQ1%1i%1i" % (ix, _eqx[ix].rxeq)
+ result0 = command(radio.pipe, scm, stlen, W8S)
+ snx += 2
+ status.cur = snx
+ radio.status_fn(status)
+ # Send 11 thingies
+ scm = "AG0%03i" % _sets.ag
+ result0 = command(radio.pipe, scm, stlen, W8S)
+ scm = "AN%1i%1i%1i" % (_sets.an1, _sets.an2, _sets.an3)
+ result0 = command(radio.pipe, scm, stlen, W8S)
+ scm = "FA%011i" % _sets.fa
+ result0 = command(radio.pipe, scm, stlen, W8S)
+ scm = "FB%011i" % _sets.fb
+ result0 = command(radio.pipe, scm, stlen, W8S)
+ scm = "MG%03i" % _sets.mg
+ result0 = command(radio.pipe, scm, stlen, W8S)
+ scm = "PC%03i" % _sets.pc
+ result0 = command(radio.pipe, scm, stlen, W8S)
+ scm = "RG%03i" % _sets.rg
+ result0 = command(radio.pipe, scm, stlen, W8S)
+ scm = "TP%03i" % _sets.tp
+ result0 = command(radio.pipe, scm, stlen, W8S)
+ scm = "MF0" # Select menu A/B
+ result0 = command(radio.pipe, scm, stlen, W8S)
+ snx += 11
+ status.cur = snx
+ radio.status_fn(status)
+ # Send 38 Menu A EX
+ setc = radio.EX # list of EX cmds
+ for ix in range(2):
+ for cmx in setc:
+ if str(cmx)[0:2] == "MF":
+ scm = cmx
+ else: # The EX cmds
+ # Test for the power-on string
+ if (radio.SG and cmx == "EX001") or \
+ ((not radio.SG) and cmx == "EX087"):
+ scm = cmx + "0000"
+ for chx in _mex[ix].ex001: # Both get string here
+ scm += chr(chx)
+ scm = scm.strip()
+ scm = scm.strip(chr(0)) # in case any got thru
+ # Now for the other EX cmds
+ else:
+ if radio.SG:
+ scm = "%s0000%i" % (cmx, getattr(_mex[ix],
+ cmx.lower()))
+ else: # Gotta use the cross reference dict for cmd
+ scm = "%s0000%i" % (cmx, getattr(_mex[ix],
+ radio.EX_X[cmx].lower()))
+ result0 = command(radio.pipe, scm, stlen, W8S)
+ snx += 1
+ status.cur = snx
+ radio.status_fn(status)
+ # Now set the inidial menu selection back
+ result0 = command(radio.pipe, "MF", 0, W8L, "%1i" % _sets.mf)
+ # And the original Beep Volume
+ result0 = command(radio.pipe, "EX0050000%2i" % BEEPVOL, 0, W8L)
+ return
+
+
+@directory.register
+class TS590Radio(chirp_common.CloneModeRadio):
+ """Kenwood TS-590"""
+ VENDOR = "Kenwood"
+ MODEL = "TS-590SG_CloneMode"
+ ID = "ID023;"
+ SG = True
+ # Settings read/write cmd sequence list
+ SETC = ["AS0", "SS", "EQ", "AG0", "AN", "FA", "FB",
+ "FV", "MF", "MG", "PC", "RG", "TP", "MF0"]
+ # This is the TS-590SG MENU A/B read_settings paramter tuple list
+ # The order is mandatory; to match the Mem_Format sequence
+ EX = ["EX001", "EX002", "EX003", "EX005", "EX006", "EX007",
+ "EX008", "EX009", "EX010", "EX011", "EX012", "EX013", "EX016",
+ "EX017", "EX018", "EX019", "EX021", "EX022", "EX023", "EX024",
+ "EX025", "EX026", "EX054", "EX055", "EX076", "EX077", "EX087",
+ "EX088", "EX089", "EX090", "EX091", "EX092", "EX093", "EX094",
+ "EX095", "EX096", "EX097", "EX098", "EX099", "MF1"]
+ # EX menu settings label dictionary. Key is the EX number
+ EX_LBL = {2: " Display brightness",
+ 1: " Power-On message",
+ 3: " Backlight color",
+ 5: " Beep volume",
+ 6: " Sidetone volume",
+ 7: " Message playback volume",
+ 8: " Voice guide volume",
+ 9: " Voice guide speed",
+ 10: " Voice guide language",
+ 11: " Auto Announcement",
+ 12: " MHz step",
+ 13: " Tuning control adj rate (Hz)",
+ 16: " SSB tune step (KHz)",
+ 17: " CW/FSK tune step (KHz)",
+ 18: " AM tune step (KHz)",
+ 19: " FM tune step (KHz)",
+ 21: " Max number of Quick Mem chans",
+ 22: " Temporary MR Chan freq allowed",
+ 23: " Program Scan slowdown",
+ 24: " Program Scan slowdown range (Hz)",
+ 25: " Program Scan hold",
+ 26: " Scan Resume method",
+ 54: " TX Power fine adjust",
+ 55: " Timeout timer (Secs)",
+ 76: " Data VOX",
+ 77: " Data VOX delay (x30 mSecs)",
+ 87: " Panel PF-A function",
+ 88: " Panel PF-B function",
+ 89: " RIT key function",
+ 90: " XIT key function",
+ 91: " CL key function",
+ 92: " Front panel MULTI/CH key (non-CW mode)",
+ 93: " Front panel MULTI/CH key (CW mode)",
+ 94: " MIC PF1 function",
+ 95: " MIC PF2 function",
+ 96: " MIC PF3 function",
+ 97: " MIC PF4 function",
+ 98: " MIC PF (DWN) function",
+ 99: " MIC PF (UP) function"}
+
+ BAUD_RATE = 115200
+ _upper = 99
+
+ # Special Channels Declaration
+ # WARNING Indecis are hard wired in get/set_memory code !!!
+ # Channels print in + increasing index order
+ SPECIAL_MEMORIES = {"EXT 0": 110,
+ "EXT 1": 111,
+ "EXT 2": 112,
+ "EXT 3": 113,
+ "EXT 4": 114,
+ "EXT 5": 115,
+ "EXT 6": 116,
+ "EXT 7": 117,
+ "EXT 8": 118,
+ "EXT 9": 119}
+
+ def get_features(self):
+ rf = chirp_common.RadioFeatures()
+
+ rf.can_odd_split = False
+ rf.has_bank = False
+ rf.has_ctone = True
+ rf.has_dtcs = False
+ rf.has_dtcs_polarity = False
+ rf.has_name = True
+ rf.has_settings = True
+ rf.has_offset = True
+ rf.has_mode = True
+ rf.has_tuning_step = False # Not in mem chan
+ rf.has_nostep_tuning = True # Radio accepts any entered freq
+ rf.has_cross = True
+ rf.has_comment = False
+ rf.memory_bounds = (0, self._upper)
+ rf.valid_bands = [(30000, 24999999), (25000000, 59999999)]
+ rf.valid_characters = chirp_common.CHARSET_UPPER_NUMERIC + "*+-/"
+ rf.valid_duplexes = TS590_DUPLEX
+ rf.valid_modes = TS590_MODES
+ rf.valid_skips = TS590_SKIP
+ rf.valid_tuning_steps = [0.5, 1.0, 2.5, 5.0, 6.25, 10.0, 12.5,
+ 15.0, 20.0, 25.0, 30.0, 50.0, 100.0]
+ rf.valid_tmodes = ["", "Tone", "TSQL", "Cross"]
+ rf.valid_cross_modes = ["Tone->Tone"]
+ rf.valid_name_length = 8 # 8 character channel names
+ rf.valid_special_chans = sorted(self.SPECIAL_MEMORIES.keys())
+
+ return rf
+
+ @classmethod
+ def get_prompts(cls):
+ rp = chirp_common.RadioPrompts()
+ rp.info = _(dedent("""\
+ Click on the "Special Channels" toggle-button of the memory
+ editor to see/set the EXT channels. P-VFO channels 100-109
+ are considered Settings.\n
+ Only a subset of the over 200 available radio settings
+ are supported in this release.\n
+ Ignore the beeps from the radio on upload and download.
+ """))
+ rp.pre_download = _(dedent("""\
+ Follow these instructions to download the radio memory:
+ 1 - Connect your interface cable
+ 2 - Radio > Download from radio: DO NOT mess with the radio
+ during download!
+ 3 - Disconnect your interface cable
+ """))
+ rp.pre_upload = _(dedent("""\
+ Follow these instructions to upload the radio memory:
+ 1 - Connect your interface cable
+ 2 - Radio > Upload to radio: DO NOT mess with the radio
+ during upload!
+ 3 - Disconnect your interface cable
+ """))
+ return rp
+
+ def sync_in(self):
+ """Download from radio"""
+ try:
+ _connect_radio(self)
+ data = _read_mem(self)
+ data += _read_settings(self)
+ except errors.RadioError:
+ # Pass through any real errors we raise
+ raise
+ except Exception:
+ # If anything unexpected happens, make sure we raise
+ # a RadioError and log the problem
+ LOG.exception('Unexpected error during download')
+ raise errors.RadioError('Unexpected error communicating '
+ 'with the radio')
+
+ self._mmap = memmap.MemoryMap(data)
+ self.process_mmap()
+ return
+
+ def sync_out(self):
+ """Upload to radio"""
+ try:
+ _connect_radio(self)
+ _write_mem(self)
+ _write_sets(self)
+ except Exception:
+ # If anything unexpected happens, make sure we raise
+ # a RadioError and log the problem
+ LOG.exception('Unexpected error during upload')
+ raise errors.RadioError('Unexpected error communicating '
+ 'with the radio')
+ return
+
+ def process_mmap(self):
+ """Process the mem map into the mem object"""
+ self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
+ return
+
+ def get_memory(self, number):
+ """Convert raw channel data (_mem) into UI columns (mem)"""
+ mem = chirp_common.Memory()
+ mem.extra = RadioSettingGroup("extra", "Extra")
+ if isinstance(number, str):
+ mem.name = number # Spcl chns 1st var
+ mem.number = self.SPECIAL_MEMORIES[number]
+ _mem = self._memobj.ch_mem[mem.number]
+ else: # Normal mem chans and VFO edges
+ if number > 99 and number < 110:
+ return # Don't show VFO edges as mem chans
+ _mem = self._memobj.ch_mem[number]
+ mem.number = number
+ mnx = ""
+ for char in _mem.name:
+ mnx += chr(char)
+ mem.name = mnx.strip()
+ mem.name = mem.name.upper()
+ # From here on is common to both types
+ if _mem.rxfreq == 0:
+ _mem.txfreq = 0
+ mem.empty = True
+ mem.freq = 0
+ mem.mode = "LSB"
+ mem.offset = 0
+ return mem
+ mem.empty = False
+ mem.freq = int(_mem.rxfreq)
+ mem.duplex = TS590_DUPLEX[0] # None by default
+ mem.offset = 0
+ if _mem.rxfreq < _mem.txfreq: # + shift
+ mem.duplex = TS590_DUPLEX[2]
+ mem.offset = _mem.txfreq - _mem.rxfreq
+ if _mem.rxfreq > _mem.txfreq: # - shift
+ mem.duplex = TS590_DUPLEX[1]
+ mem.offset = _mem.rxfreq - _mem.txfreq
+ if _mem.txfreq == 0:
+ # leave offset alone, or run_tests will bomb
+ mem.duplex = TS590_DUPLEX[0]
+ mx = _mem.xmode - 1 # CAT modes start at 1
+ if _mem.xmode == 9: # except CAT FSK-R is 9, there is no 8
+ mx = 7
+ if _mem.data: # LSB+Data= 8, USB+Data= 9, FM+Data= 10
+ if _mem.xmode == 1: # CAT LSB
+ mx = 8
+ elif _mem.xmode == 2: # CAT USB
+ mx = 9
+ elif _mem.xmode == 4: # CAT FM
+ mx = 10
+ mem.mode = TS590_MODES[mx]
+ mem.tmode = ""
+ mem.cross_mode = "Tone->Tone"
+ mem.ctone = TS590_TONES[_mem.ctone]
+ mem.rtone = TS590_TONES[_mem.rtone]
+ if _mem.tmode == 1:
+ mem.tmode = "Tone"
+ elif _mem.tmode == 2:
+ mem.tmode = "TSQL"
+ elif _mem.tmode == 3:
+ mem.tmode = "Cross"
+ mem.skip = TS590_SKIP[_mem.skip]
+
+ # Channel Extra settings: Only Boolean & List methods, no call-backs
+ options = ["Wide", "Narrow"]
+ rx = RadioSettingValueList(options, options[_mem.fmnrw])
+ # NOTE: first param of RadioSetting is the object attribute name
+ rset = RadioSetting("fmnrw", "FM mode", rx)
+ rset.set_apply_callback(my_val_list, options, _mem, "fmnrw")
+ mem.extra.append(rset)
+
+ options = ["Filter A", "Filter B"]
+ rx = RadioSettingValueList(options, options[_mem.filter])
+ rset = RadioSetting("filter", "Filter A/B", rx)
+ rset.set_apply_callback(my_val_list, options, _mem, "filter")
+ mem.extra.append(rset)
+
+ return mem
+
+ def set_memory(self, mem):
+ """Convert UI column data (mem) into MEM_FORMAT memory (_mem)"""
+ _mem = self._memobj.ch_mem[mem.number]
+ if mem.empty:
+ _mem.rxfreq = 0
+ _mem.txfreq = 0
+ _mem.xmode = 0
+ _mem.data = 0
+ _mem.tmode = 0
+ _mem.rtone = 0
+ _mem.ctone = 0
+ _mem.filter = 0
+ _mem.skip = 0
+ _mem.fmnrw = 0
+ _mem.name = " "
+ return
+
+ if mem.number > self._upper: # Specials: No Name changes
+ ix = 0
+ # LOG.warning("Special Chan set_mem @ %i" % mem.number)
+ else:
+ nx = len(mem.name)
+ for ix in range(8):
+ if ix < nx:
+ _mem.name[ix] = mem.name[ix].upper()
+ else:
+ _mem.name[ix] = " " # assignment needs 8 chrs
+ _mem.rxfreq = mem.freq
+ _mem.txfreq = 0
+ if mem.duplex == "+":
+ _mem.txfreq = mem.freq + mem.offset
+ if mem.duplex == "-":
+ _mem.txfreq = mem.freq - mem.offset
+ ix = TS590_MODES.index(mem.mode)
+ _mem.data = 0
+ _mem.xmode = ix + 1 # stored as CAT values, LSB= 1
+ if ix == 7: # FSK-R
+ _mem.xmode = 9 # There is no CAT 8
+ if ix > 7: # a Data mode
+ _mem.data = 1
+ if ix == 8:
+ _mem.xmode = 1 # LSB
+ elif ix == 9:
+ _mem.xmode = 2 # USB
+ elif ix == 10:
+ _mem.xmode = 4 # FM
+ _mem.tmode = 0
+ _mem.rtone = TS590_TONES.index(mem.rtone)
+ _mem.ctone = TS590_TONES.index(mem.ctone)
+ if mem.tmode == "Tone":
+ _mem.tmode = 1
+ if mem.tmode == "TSQL":
+ _mem.tmode = 2
+ if mem.tmode == "Cross" or mem.tmode == "Tone->Tone":
+ _mem.tmode = 3
+ _mem.skip = 0
+ if mem.skip == "S":
+ _mem.skip = 1
+ for setting in mem.extra:
+ setattr(_mem, setting.get_name(), setting.value)
+ return
+
+ def _parse_mem_spec(self, spec0, spec1):
+ """ Extract ascii memory paramters; build data string """
+ # spec0 is simplex result, spec1 is split
+ # pad string so indexes match Kenwood docs
+ spec0 = "x" + spec0 # match CAT document 1-based description
+ ix = len(spec0)
+ # _pxx variables are STRINGS
+ _p1 = spec0[3] # P1 Split Specification
+ _p3 = spec0[4:7] # P3 Memory Channel
+ _p4 = spec0[7:18] # P4 Frequency
+ _p5 = spec0[18] # P5 Mode
+ _p6 = spec0[19] # P6 Data Mode
+ _p7 = spec0[20] # P7 Tone Mode
+ _p8 = spec0[21:23] # P8 Tone Frequency Index
+ if _p8 == "00": # Can't be 0 at upload
+ _p8 = "08"
+ _p9 = spec0[23:25] # P9 CTCSS Frequency Index
+ if _p9 == "00":
+ _p9 = "08"
+ _p10 = spec0[25:28] # P10 Always 0
+ _p11 = spec0[28] # P11 Filter A/B
+ _p12 = spec0[29] # P12 Always 0
+ _p13 = spec0[30:38] # P13 Always 0
+ _p14 = spec0[38:40] # P14 FM Mode
+ _p15 = spec0[40] # P15 Chan Lockout (Skip)
+ _p16 = spec0[41:49] # P16 Max 8-Char Name if assigned
+
+ spec1 = "x" + spec1
+ _p4s = int(spec1[7:18]) # P4: Offset freq
+
+ datm = "" # Fill in MEM_FORMAT sequence
+ datm += _make_dat(_p4, 4) # rxreq: u32, 4 bytes/chars
+ datm += _make_dat(_p4s, 4) # tx freq
+ v1 = int(_p5) << 4 # xMode: 0-9, upper 4 bits
+ v1 = v1 | (int(_p6) << 2) # Data: 0/1
+ v1 = v1 | int(_p7) # Tmode: 0-3
+ datm += chr(v1)
+ datm += chr(int(_p8)) # rtone: 00-42
+ datm += chr(int(_p9)) # ctone
+ v1 = int(_p11) << 7 # Filter A/B 1 bit msb
+ v1 = v1 | (int(_p14) << 6) # fmwide: 1 bit
+ v1 = v1 | (int(_p15) << 5) # skip: 1 bit
+ datm += chr(v1)
+ v1 = len(_p16)
+ for ix in range(8):
+ if ix < v1:
+ datm += _p16[ix]
+ else:
+ datm += " "
+
+ return datm
+
+ def _make_base_spec(self, mem, freq):
+ """ Generate memory channel parameter string """
+ spec = "%011i%1i%1i%1i%02i%02i000%1i0000000000%02i%1i%s" \
+ % (freq, mem.xmode, mem.data, mem.tmode, mem.rtone,
+ mem.ctone, mem.filter, mem.fmnrw, mem.skip, mem.name)
+
+ return spec.strip()
+
+ def get_settings(self):
+ """Translate the MEM_FORMAT structs into settings in the UI"""
+ # Define mem struct write-back shortcuts
+ _sets = self._memobj.settings
+ _asf = self._memobj.asf
+ _ssf = self._memobj.ssf
+ _eqx = self._memobj.eqx
+ _mex = self._memobj.exset
+ _chm = self._memobj.ch_mem
+ basic = RadioSettingGroup("basic", "Basic Settings")
+ pvfo = RadioSettingGroup("pvfo", "VFO Band Edges")
+ mena = RadioSettingGroup("mena", "Menu A")
+ menb = RadioSettingGroup("menb", "Menu B")
+ equ = RadioSettingGroup("equ", "Equalizers")
+ amode = RadioSettingGroup("amode", "Auto Mode")
+ ssc = RadioSettingGroup("ssc", "Slow Scan")
+ group = RadioSettings(basic, pvfo, mena, menb, equ, amode, ssc)
+
+ mhz1 = 1000000.
+ nsg = not self.SG
+ if nsg: # Make reverse EX_X dictionary
+ x_ex = dict(zip(self.EX_X.values(), self.EX_X.keys()))
+
+ # Callback functions
+ def _my_readonly(setting, obj, atrb):
+ """NOP callback, prevents writing the setting"""
+ vx = 0
+ return
+
+ def my_adjraw(setting, obj, atrb, fix=0, ndx=-1):
+ """Callback for Integer add or subtract fix from value."""
+ vx = int(str(setting.value))
+ value = vx + int(fix)
+ if value < 0:
+ value = 0
+ if ndx < 0:
+ setattr(obj, atrb, value)
+ else:
+ setattr(obj[ndx], atrb, value)
+ return
+
+ def my_mhz_val(setting, obj, atrb, ndx=-1):
+ """ Callback to set freq back to Htz"""
+ vx = float(str(setting.value))
+ vx = int(vx * mhz1)
+ if ndx < 0:
+ setattr(obj, atrb, vx)
+ else:
+ setattr(obj[ndx], atrb, vx)
+ return
+
+ def my_bool(setting, obj, atrb, ndx=-1):
+ """ Callback to properly set boolean """
+ # set_settings is not setting [indexed] booleans???
+ vx = 0
+ if str(setting.value) == "True":
+ vx = 1
+ if ndx < 0:
+ setattr(obj, atrb, vx)
+ else:
+ setattr(obj[ndx], atrb, vx)
+ return
+
+ def my_asf_mode(setting, obj, nx=0):
+ """ Callback to extract mode and create asmode, asdata """
+ v1 = TS590_MODES.index(str(setting.value))
+ v2 = 0 # asdata
+ vx = v1 + 1 # stored as CAT values, same as xmode
+ if v1 == 7:
+ vx = 9
+ if v1 > 7: # a Data mode
+ v2 = 1
+ if v1 == 8:
+ vx = 1 # LSB
+ elif v1 == 9:
+ vx = 2 # USB
+ elif v1 == 10:
+ vx = 4 # FM
+ setattr(obj[nx], "asdata", v2)
+ setattr(obj[nx], "asmode", vx)
+ return
+
+ def my_fnctns(setting, obj, ndx, atrb):
+ """ Filter only valid key function assignments """
+ vx = int(str(setting.value))
+ if self.SG:
+ vmx = 210
+ if (vx > 99 and vx < 120) or (vx > 170 and vx < 200):
+ raise errors.RadioError(" %i Change Ignored for %s."
+ % (vx, atrb))
+ return # not valid, ignored
+ else:
+ vmx = 208
+ if (vx > 87 and vx < 100) or (vx > 134 and vx < 200):
+ raise errors.RadioError(" %i Change Ignored for %s."
+ % (vx, atrb))
+ return
+ if vx > vmx:
+ vx = 255 # Off
+ setattr(obj[ndx], atrb, vx)
+ return
+
+ def my_labels(kx): # nsg and x_ex defined above
+ lbl = "%03i:" % kx # SG EX number
+ if nsg:
+ lbl = x_ex["EX%03i" % kx][2:] + ":" # S-model EX num
+ lbl += self.EX_LBL[kx] # and the label to match
+ return lbl
+
+ # ===== BASIC GROUP =====
+ sx = ""
+ for i in range(4):
+ sx += chr(_sets.fv[i])
+ rx = RadioSettingValueString(0, 4, sx)
+ rset = RadioSetting("settings.fv", "FirmwareVersion", rx)
+ rset.set_apply_callback(_my_readonly, _sets, "fv")
+ basic.append(rset)
+
+ rx = RadioSettingValueInteger(0, 255, _sets.ag + 1)
+ rset = RadioSetting("settings.ag", "AF Gain", rx)
+ rset.set_apply_callback(my_adjraw, _sets, "ag", -1)
+ basic.append(rset)
+
+ rx = RadioSettingValueInteger(0, 255, _sets.rg + 1)
+ rset = RadioSetting("settings.rg", "RF Gain", rx)
+ rset.set_apply_callback(my_adjraw, _sets, "rg", -1)
+ basic.append(rset)
+
+ options = ["ANT1", "ANT2"]
+ # CAUTION: an1 has value of 1 or 2
+ rx = RadioSettingValueList(options, options[_sets.an1 - 1])
+ rset = RadioSetting("settings.an1", "Antenna Selected", rx)
+ # Add 1 to the changed value. S/b 1/2
+ rset.set_apply_callback(my_val_list, options, _sets, "an1", 1)
+ basic.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_sets.an2))
+ rset = RadioSetting("settings.an2", "Recv Antenna is used", rx)
+ basic.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_sets.an3))
+ rset = RadioSetting("settings.an3", "Drive Out On", rx)
+ basic.append(rset)
+
+ rx = RadioSettingValueInteger(0, 100, _sets.mg)
+ rset = RadioSetting("settings.mg", "Microphone gain", rx)
+ basic.append(rset)
+
+ nx = 5 # Coarse step
+ if bool(_mex[0].ex054): # Power Fine enabled in menu A
+ nx = 1
+ vx = _sets.pc # Trap invalid values from run_tests.py
+ if vx < 5:
+ vx = 5
+ rx = RadioSettingValueInteger(5, 100, vx, nx)
+ sx = "TX Output power (Watts)"
+ rset = RadioSetting("settings.pc", sx, rx)
+ basic.append(rset)
+
+ vx = _sets.tp
+ rx = RadioSettingValueInteger(5, 100, vx, nx)
+ sx = "TX Tuning power (Watts)"
+ rset = RadioSetting("settings.tp", sx, rx)
+ basic.append(rset)
+
+ val = _sets.fa / mhz1 # Allow Rx freq range
+ rx = RadioSettingValueFloat(0.3, 60.0, val, 0.001, 3)
+ sx = "VFO-A Frequency (MHz)"
+ rset = RadioSetting("settings.fa", sx, rx)
+ rset.set_apply_callback(my_mhz_val, _sets, "fa")
+ basic.append(rset)
+
+ val = _sets.fb / mhz1
+ rx = RadioSettingValueFloat(0.3, 60.0, val, 0.001, 3)
+ sx = "VFO-B Frequency (MHz)"
+ rset = RadioSetting("settings.fb", sx, rx)
+ rset.set_apply_callback(my_mhz_val, _sets, "fb")
+ basic.append(rset)
+
+ options = ["Menu A", "Menu B"]
+ rx = RadioSettingValueList(options, options[_sets.mf])
+ sx = "Menu Selected"
+ rset = RadioSetting("settings.mf", sx, rx)
+ rset.set_apply_callback(my_val_list, options, _sets, "mf")
+ basic.append(rset)
+
+ # ==== VFO Edges Group ================
+
+ for mx in range(100, 110):
+ val = _chm[mx].rxfreq / mhz1
+ if val < 1.8: # Many operators never use this
+ val = 1.8 # So default is 0.0
+ rx = RadioSettingValueFloat(1.8, 54.0, val, 0.001, 3)
+ sx = "VFO-Band %i lower limit (MHz)" % (mx - 100)
+ rset = RadioSetting("ch_mem.rxfreq/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_mhz_val, _chm, "rxfreq", mx)
+ pvfo.append(rset)
+
+ val = _chm[mx].txfreq / mhz1
+ if val < 1.8:
+ val = 54.0
+ rx = RadioSettingValueFloat(1.8, 54.0, val, 0.001, 3)
+ sx = " VFO-Band %i upper limit (MHz)" % (mx - 100)
+ rset = RadioSetting("ch_mem.txfreq/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_mhz_val, _chm, "txfreq", mx)
+ pvfo.append(rset)
+
+ kx = _chm[mx].xmode
+ options = ["None", "LSB", "USB", "CW", "FM", "AM", "FSK",
+ "CW-R", "N/A", "FSK-R"]
+ rx = RadioSettingValueList(options, options[kx])
+ sx = " VFO-Band %i Tx/Rx Mode" % (mx - 100)
+ rset = RadioSetting("ch_mem.xmode/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_val_list, options, _chm,
+ "xmode", 0, mx)
+ pvfo.append(rset)
+
+ # ==== Menu A/B Group =================
+
+ for mx in range(2): # A/B index
+ sx = ""
+ for i in range(8):
+ if int(_mex[mx].ex001[i]) != 0:
+ sx += chr(_mex[mx].ex001[i])
+ sx = sx.strip()
+ rx = RadioSettingValueString(0, 8, sx)
+ sx = my_labels(1) # Proper label for EX001
+ rset = RadioSetting("exset.ex001/%d" % mx, sx, rx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ sx = my_labels(2)
+ rx = RadioSettingValueInteger(0, 6, _mex[mx].ex002)
+ rset = RadioSetting("exset.ex002", sx, rx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ nx = 2
+ if self.SG:
+ nx = 10
+ vx = _mex[mx].ex003 + 1 # radio rtns 0-9
+ rx = RadioSettingValueInteger(1, nx, vx)
+ sx = my_labels(3)
+ rset = RadioSetting("exset.ex003", sx, rx)
+ rset.set_apply_callback(my_adjraw, _mex, "ex003", -1, mx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ nx = 9
+ if self.SG:
+ nx = 20
+ rx = RadioSettingValueInteger(0, nx, _mex[mx].ex005)
+ sx = my_labels(5)
+ rset = RadioSetting("exset.ex005", sx, rx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ sx = my_labels(6)
+ rx = RadioSettingValueInteger(0, nx, _mex[mx].ex006)
+ rset = RadioSetting("exset.ex006", sx, rx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ sx = my_labels(7)
+ rx = RadioSettingValueInteger(0, nx, _mex[mx].ex007)
+ rset = RadioSetting("exset.ex007", sx, rx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ nx = 7
+ if self.SG:
+ nx = 20
+ sx = my_labels(8)
+ rx = RadioSettingValueInteger(0, nx, _mex[mx].ex008)
+ rset = RadioSetting("exset.ex008", sx, rx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ sx = my_labels(9)
+ rx = RadioSettingValueInteger(0, 4, _mex[mx].ex009)
+ rset = RadioSetting("exset.ex009", sx, rx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ options = ["English", "Japanese"]
+ rx = RadioSettingValueList(options, options[_mex[mx].ex010])
+ sx = my_labels(10)
+ rset = RadioSetting("exset.ex010/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_val_list, options, _mex,
+ "ex010", 0, mx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ options = ["Off", "1", "2"]
+ rx = RadioSettingValueList(options, options[_mex[mx].ex011])
+ sx = my_labels(11)
+ rset = RadioSetting("exset.ex011/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_val_list, options, _mex,
+ "ex011", 0, mx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ options = ["0.1", "0.5", "1.0"]
+ rx = RadioSettingValueList(options, options[_mex[mx].ex012])
+ sx = my_labels(12)
+ rset = RadioSetting("exset.ex012", sx, rx)
+ rset.set_apply_callback(my_val_list, options, _mex,
+ "ex012", 0, mx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ options = ["250", "500", "1000"]
+ rx = RadioSettingValueList(options, options[_mex[mx].ex013])
+ sx = my_labels(13)
+ rset = RadioSetting("exset.ex013/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_val_list, options, _mex,
+ "ex013", 0, mx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ # S and SG have different ranges for control steps
+ options = ["0.5", "1.0", "2.5", "5.0", "10.0"]
+ if self.SG:
+ options = ["Off", "0.5", "0.5", "1.0", "2.5",
+ "5.0", "10.0"]
+ rx = RadioSettingValueList(options, options[_mex[mx].ex016])
+ sx = my_labels(16)
+ if nsg:
+ sx = "014: Tuning step for SSB/CW/FSK (KHz)"
+ rset = RadioSetting("exset.ex016/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_val_list, options, _mex,
+ "ex016", 0, mx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ if self.SG: # this setting only for SG
+ rx = RadioSettingValueList(options,
+ options[_mex[mx].ex017])
+
+ sx = my_labels(17)
+ rset = RadioSetting("exset.ex017/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_val_list, options, _mex,
+ "ex017", 0, mx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ options = ["Off", "5.0", "6.25", "10.0", "12.5", "15.0",
+ "20.0", "25.0", "30.0", "50.0", "100.0"]
+ if self.SG:
+ options.remove("Off")
+ rx = RadioSettingValueList(options, options[_mex[mx].ex018])
+ sx = my_labels(18)
+ rset = RadioSetting("exset.ex018/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_val_list, options, _mex,
+ "ex018", 0, mx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueList(options, options[_mex[mx].ex019])
+ sx = my_labels(19)
+ rset = RadioSetting("exset.ex019/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_val_list, options, _mex,
+ "ex019", 0, mx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ options = ["3", "5", "10"]
+ rx = RadioSettingValueList(options, options[_mex[mx].ex021])
+ sx = my_labels(21)
+ rset = RadioSetting("exset.ex021/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_val_list, options, _mex,
+ "ex021", 0, mx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_mex[mx].ex022))
+ sx = my_labels(22)
+ rset = RadioSetting("exset.ex022/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_bool, _mex, "ex022", mx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_mex[mx].ex023))
+ sx = my_labels(23)
+ rset = RadioSetting("exset.ex023/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_bool, _mex, "ex023", mx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ options = ["100", "200", "300", "400", "500"]
+ rx = RadioSettingValueList(options, options[_mex[mx].ex024])
+ sx = my_labels(24)
+ rset = RadioSetting("exset.ex024/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_val_list, options, _mex,
+ "ex024", 0, mx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_mex[mx].ex025))
+ sx = my_labels(25)
+ rset = RadioSetting("exset.ex025/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_bool, _mex, "ex025", mx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ options = ["TO", "CO"]
+ rx = RadioSettingValueList(options, options[_mex[mx].ex026])
+ sx = my_labels(26)
+ rset = RadioSetting("exset.ex026/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_val_list, options, _mex,
+ "ex026", 0, mx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_mex[mx].ex054))
+ sx = my_labels(54)
+ rset = RadioSetting("exset.ex054/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_bool, _mex, "ex054", mx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ options = ["Off", "3", "5", "10", "20", "30"]
+ rx = RadioSettingValueList(options, options[_mex[mx].ex055])
+ sx = my_labels(55)
+ rset = RadioSetting("exset.ex055/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_val_list, options, _mex,
+ "ex055", 0, mx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_mex[mx].ex076))
+ sx = my_labels(76)
+ rset = RadioSetting("exset.ex076/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_bool, _mex, "ex076", mx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueInteger(0, 100, _mex[mx].ex077, 5)
+ sx = my_labels(77)
+ rset = RadioSetting("exset.ex077/%d" % mx, sx, rx)
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueInteger(0, 256, _mex[mx].ex087)
+ sx = my_labels(87)
+ rset = RadioSetting("exset.ex087/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_fnctns, _mex, mx, "ex087")
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueInteger(0, 256, _mex[mx].ex088)
+ sx = my_labels(88)
+ rset = RadioSetting("exset.ex088/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_fnctns, _mex, mx, "ex088")
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ if self.SG: # Next 5 settings not supported in 590S
+ rx = RadioSettingValueInteger(0, 256, _mex[mx].ex089)
+ sx = my_labels(89)
+ rset = RadioSetting("exset.ex089/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_fnctns, _mex, mx, "ex089")
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueInteger(0, 256, _mex[mx].ex090)
+ sx = my_labels(90)
+ rset = RadioSetting("exset.ex090/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_fnctns, _mex, mx, "ex090")
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueInteger(0, 256, _mex[mx].ex091)
+ sx = my_labels(91)
+ rset = RadioSetting("exset.ex091/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_fnctns, _mex, mx, "ex091")
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueInteger(0, 256, _mex[mx].ex092)
+ sx = my_labels(92)
+ rset = RadioSetting("exset.ex092/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_fnctns, _mex, mx, "ex092")
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueInteger(0, 256, _mex[mx].ex093)
+ sx = my_labels(93)
+ rset = RadioSetting("exset.ex093/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_fnctns, _mex, mx, "ex093")
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ # Now both S and SG models
+ rx = RadioSettingValueInteger(0, 256, _mex[mx].ex094)
+ sx = my_labels(94)
+ rset = RadioSetting("exset.ex094/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_fnctns, _mex, mx, "ex094")
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueInteger(0, 256, _mex[mx].ex095)
+ sx = my_labels(95)
+ rset = RadioSetting("exset.ex095/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_fnctns, _mex, mx, "ex095")
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueInteger(0, 256, _mex[mx].ex096)
+ sx = my_labels(96)
+ rset = RadioSetting("exset.ex096/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_fnctns, _mex, mx, "ex096")
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueInteger(0, 256, _mex[mx].ex097)
+ sx = my_labels(97)
+ rset = RadioSetting("exset.ex097/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_fnctns, _mex, mx, "ex097")
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueInteger(0, 256, _mex[mx].ex098)
+ sx = my_labels(98)
+ rset = RadioSetting("exset.ex098/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_fnctns, _mex, mx, "ex098")
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+
+ rx = RadioSettingValueInteger(0, 256, _mex[mx].ex099)
+ sx = my_labels(99)
+ rset = RadioSetting("exset.ex099/%d" % mx, sx, rx)
+ rset.set_apply_callback(my_fnctns, _mex, mx, "ex099")
+ if mx == 0:
+ mena.append(rset)
+ else:
+ menb.append(rset)
+ # End of for mx loop
+
+ # ==== Auto Scan Params (amode) ==============
+ for ix in range(32):
+ val = _asf[ix].asfreq / mhz1
+ rx = RadioSettingValueFloat(0.03, 60.0, val, 0.001, 3)
+ rset = RadioSetting("asf.asfreq/%d" % ix,
+ "Scan %02i Freq (MHz)" % ix, rx)
+ rset.set_apply_callback(my_mhz_val, _asf, "asfreq", ix)
+ amode.append(rset)
+
+ mx = _asf[ix].asmode - 1 # Same logic as xmode
+ if _asf[ix].asmode == 9:
+ mx = 7
+ if _asf[ix].asdata:
+ if _asf[ix].asmode == 1:
+ mx = 8
+ elif _asf[ix].asmode == 2:
+ mx = 9
+ elif _asf[ix].asmode == 4:
+ mx = 10
+ rx = RadioSettingValueList(TS590_MODES, TS590_MODES[mx])
+ rset = RadioSetting("asf.asmode/%d" % ix, " Mode", rx)
+ rset.set_apply_callback(my_asf_mode, _asf, ix)
+ amode.append(rset)
+
+ # ==== Slow Scan Settings ===
+ for ix in range(10): # Chans
+ for nx in range(5): # spots
+ px = ((ix * 5) + nx)
+ val = _ssf[px].ssfreq / mhz1
+ stx = " - - - Slot %02i Freq (MHz)" % nx
+ if nx == 0:
+ stx = "Slow Scan %02i, Slot 0 Freq (MHz" % ix
+ rx = RadioSettingValueFloat(0, 54.0, val, 0.001, 3)
+ rset = RadioSetting("ssf.ssfreq/%d" % px, stx, rx)
+ rset.set_apply_callback(my_mhz_val, _ssf, "ssfreq", px)
+ ssc.append(rset)
+
+ # ==== Equalizer subgroup =====
+ mohd = ["SSB", "SSB-DATA", "CW/CW-R", "FM", "FM-DATA", "AM",
+ "AM-DATA", "FSK/FSK-R"]
+ tcurves = ["Off", "HB1", "HB2", "FP", "BB1", "BB2",
+ "C", "U"]
+ rcurves = ["Off", "HB1", "HB2", "FP", "BB1", "BB2",
+ "FLAT", "U"]
+ for ix in range(8):
+ rx = RadioSettingValueList(tcurves, tcurves[_eqx[ix].txeq])
+ rset = RadioSetting("eqx.txeq/%d" % ix, "TX %s Equalizer"
+ % mohd[ix], rx)
+ rset.set_apply_callback(my_val_list, tcurves, _eqx,
+ "txeq", 0, ix)
+ equ.append(rset)
+
+ rx = RadioSettingValueList(rcurves, rcurves[_eqx[ix].rxeq])
+ rset = RadioSetting("eqx.rxeq/%d" % ix, "RX %s Equalizer"
+ % mohd[ix], rx)
+ rset.set_apply_callback(my_val_list, rcurves, _eqx,
+ "rxeq", 0, ix)
+ equ.append(rset)
+
+ return group # END get_settings()
+
+ def set_settings(self, settings):
+ _settings = self._memobj.settings
+ _mem = self._memobj
+ for element in settings:
+ if not isinstance(element, RadioSetting):
+ self.set_settings(element)
+ 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, e:
+ LOG.debug(element.get_name())
+ raise
+
+ @classmethod
+ def match_model(cls, fdata, fyle):
+ """ Included to prevent 'File > New' error """
+ return False
+
+
+@directory.register
+class TS590SRadio(TS590Radio):
+ """ Kenwood TS-590S variant of the TS590 """
+ VENDOR = "Kenwood"
+ MODEL = "TS-590S_CloneMode"
+ ID = "ID021;"
+ SG = False
+ # This is the equivalent Menu A/B list for the TS-590S
+ # The equivalnt S param is stored in the SG Mem_Format slot
+ EX = ["EX087", "EX000", "EX001", "EX003", "EX004", "EX005",
+ "EX006", "EX007", "EX008", "EX009", "EX010", "EX011", "EX014",
+ "EX014", "EX015", "EX016", "EX017", "EX018", "EX019", "EX020",
+ "EX021", "EX022", "EX048", "EX049", "EX069", "EX070", "EX079",
+ "EX080", "EX080", "EX080", "EX080", "EX080", "EX080", "EX081",
+ "EX082", "EX083", "EX084", "EX085", "EX086", "MF1"]
+ # EX cross reference dictionary- key is S param, value is the SG
+ EX_X = {"EX087": "EX001", "EX000": "EX002", "EX001": "EX003",
+ "EX003": "EX005", "EX004": "EX006", "EX005": "EX007",
+ "EX006": "EX008", "EX007": "EX009", "EX008": "EX010",
+ "EX009": "EX011", "EX010": "EX012", "EX011": "EX013",
+ "EX014": "EX016", "EX015": "EX018", "EX081": "EX094",
+ "EX016": "EX019", "EX017": "EX021", "EX018": "EX022",
+ "EX019": "EX023",
+ "EX020": "EX024", "EX021": "EX025", "EX022": "EX026",
+ "EX048": "EX054", "EX049": "EX055", "EX069": "EX076",
+ "EX070": "EX077", "EX079": "EX087", "EX080": "EX088",
+ "EX082": "EX095", "EX083": "EX096", "EX084": "EX097",
+ "EX085": "EX098", "EX086": "EX099"}
diff --git a/chirp/drivers/uv5r.py b/chirp/drivers/uv5r.py
index 737c1f6..1e2b5cc 100644
--- a/chirp/drivers/uv5r.py
+++ b/chirp/drivers/uv5r.py
@@ -288,9 +288,10 @@ BASETYPE_UV6 = ["BF1", "UV6"]
BASETYPE_KT980HP = ["BFP3V3 B"]
BASETYPE_F8HP = ["BFP3V3 F", "N5R-3", "N5R3", "F5R3", "BFT"]
BASETYPE_UV82HP = ["N82-3", "N823", "N5R2"]
+BASETYPE_UV82X3 = ["HN5RV01"]
BASETYPE_LIST = BASETYPE_UV5R + BASETYPE_F11 + BASETYPE_UV82 + \
BASETYPE_BJ55 + BASETYPE_UV6 + BASETYPE_KT980HP + \
- BASETYPE_F8HP + BASETYPE_UV82HP
+ BASETYPE_F8HP + BASETYPE_UV82HP + BASETYPE_UV82X3
AB_LIST = ["A", "B"]
ALMOD_LIST = ["Site", "Tone", "Code"]
@@ -552,7 +553,7 @@ def _do_download(radio):
# then append that model type to the end of the image so it can
# be properly detected when loaded.
append_model = True
- elif "\xFF" * 14 in radio_version:
+ elif "\xFF" * 7 in radio_version:
# A radio UV-5R style radio that reports no firmware version has
# been detected.
# We are going to count on the user to make the right choice and
@@ -633,7 +634,7 @@ def _do_upload(radio):
if image_version.startswith("HN5RV"):
ranges_main = _ranges_main_default
ranges_aux = _ranges_aux_default + _ranges_aux_extra
- elif image_version == 0xFF * 14:
+ elif image_version == 0xFF * 7:
ranges_main = _ranges_main_default
ranges_aux = _ranges_aux_default + _ranges_aux_extra
else:
@@ -1765,10 +1766,15 @@ class A5RAlias(chirp_common.Alias):
MODEL = "A-5R"
+class TenwayUV5RPro(chirp_common.Alias):
+ VENDOR = 'Tenway'
+ MODEL = 'UV-5R Pro'
+
+
@directory.register
class BaofengUV5RGeneric(BaofengUV5R):
ALIASES = [UV5XAlias, RT5RAlias, RT5RVAlias, RT5Alias, RH5RAlias,
- ROUV5REXAlias, A5RAlias]
+ ROUV5REXAlias, A5RAlias, TenwayUV5RPro]
@directory.register
@@ -1801,6 +1807,7 @@ class BaofengUV82Radio(BaofengUV5R):
class Radioddity82X3Radio(BaofengUV82Radio):
VENDOR = "Radioddity"
MODEL = "UV-82X3"
+ _basetype = BASETYPE_UV82X3
def get_features(self):
rf = BaofengUV5R.get_features(self)
diff --git a/chirp/drivers/wouxun.py b/chirp/drivers/wouxun.py
index ade91de..21a1767 100644
--- a/chirp/drivers/wouxun.py
+++ b/chirp/drivers/wouxun.py
@@ -1068,6 +1068,8 @@ class KGUV6DRadio(KGUVD1PRadio):
def get_features(self):
rf = KGUVD1PRadio.get_features(self)
rf.memory_bounds = (1, 199)
+ rf.valid_tuning_steps = [2.5, 5.0, 6.25, 10.0, 12.5, 25.0, 50.0,
+ 100.0]
return rf
def get_settings(self):
diff --git a/stock_configs/US FRS and GMRS Channels.csv b/stock_configs/US FRS and GMRS Channels.csv
index f32fbc7..76a58ac 100644
--- a/stock_configs/US FRS and GMRS Channels.csv
+++ b/stock_configs/US FRS and GMRS Channels.csv
@@ -1,23 +1,53 @@
Location,Name,Frequency,Duplex,Offset,Tone,rToneFreq,cToneFreq,DtcsCode,DtcsPolarity,Mode,TStep,Skip,Comment,URCALL,RPT1CALL,RPT2CALL
-1,FRS1,462.562500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
-2,FRS2,462.587500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
-3,FRS3,462.612500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
-4,FRS4,462.637500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
-5,FRS5,462.662500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
-6,FRS6,462.687500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
-7,FRS7,462.712500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
-8,FRS8,467.562500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
-9,FRS9,467.587500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
-10,FRS10,467.612500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
-11,FRS11,467.637500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
-12,FRS12,467.662500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
-13,FRS13,467.687500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
-14,FRS14,467.712500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
-15,GMRS1,462.550000,,5.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-16,GMRS2,462.575000,,5.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-17,GMRS3,462.600000,,5.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-18,GMRS4,462.625000,,5.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-19,GMRS5,462.650000,,5.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-20,GMRS6,462.675000,,5.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-21,GMRS7,462.700000,,5.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
-22,GMRS8,462.725000,,5.000000,,88.5,88.5,023,NN,FM,25.00,,,,,
+1,FRS 1,462.562500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+2,FRS 2,462.587500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+3,FRS 3,462.612500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+4,FRS 4,462.637500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+5,FRS 5,462.662500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+6,FRS 6,462.687500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+7,FRS 7,462.712500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+8,FRS 8,467.562500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+9,FRS 9,467.587500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+10,FRS 10,467.612500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+11,FRS 11,467.637500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+12,FRS 12,467.662500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+13,FRS 13,467.687500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+14,FRS 14,467.712500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+15,FRS 15,462.550000,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+16,FRS 16,462.575000,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+17,FRS 17,462.600000,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+18,FRS 18,462.625000,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+19,FRS 19,462.650000,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+20,FRS 20,462.675000,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+21,FRS 21,462.700000,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+22,FRS 22,462.725000,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+23,GMRS 1,462.562500,,5.000000,,88.5,88.5,023,NN,FM,12.50,,,,,
+24,GMRS 2,462.587500,,5.000000,,88.5,88.5,023,NN,FM,12.50,,,,,
+25,GMRS 3,462.612500,,5.000000,,88.5,88.5,023,NN,FM,12.50,,,,,
+26,GMRS 4,462.637500,,5.000000,,88.5,88.5,023,NN,FM,12.50,,,,,
+27,GMRS 5,462.662500,,5.000000,,88.5,88.5,023,NN,FM,12.50,,,,,
+28,GMRS 6,462.687500,,5.000000,,88.5,88.5,023,NN,FM,12.50,,,,,
+29,GMRS 7,462.712500,,5.000000,,88.5,88.5,023,NN,FM,12.50,,,,,
+30,GMRS 8,467.562500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+31,GMRS 9,467.587500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+32,GMRS 10,467.612500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+33,GMRS 11,467.637500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+34,GMRS 12,467.662500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+35,GMRS 13,467.687500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+36,GMRS 14,467.712500,,5.000000,,88.5,88.5,023,NN,NFM,12.50,,,,,
+37,GMRS 15,462.550000,,5.000000,,88.5,88.5,023,NN,FM,12.50,,,,,
+38,GMRS 16,462.575000,,5.000000,,88.5,88.5,023,NN,FM,12.50,,,,,
+39,GMRS 17,462.600000,,5.000000,,88.5,88.5,023,NN,FM,12.50,,,,,
+40,GMRS 18,462.625000,,5.000000,,88.5,88.5,023,NN,FM,12.50,,,,,
+41,GMRS 19,462.650000,,5.000000,,88.5,88.5,023,NN,FM,12.50,,,,,
+42,GMRS 20,462.675000,,5.000000,,88.5,88.5,023,NN,FM,12.50,,,,,
+43,GMRS 21,462.700000,,5.000000,,88.5,88.5,023,NN,FM,12.50,,,,,
+44,GMRS 22,462.725000,,5.000000,,88.5,88.5,023,NN,FM,12.50,,,,,
+45,GMRS 550/15R,462.550000,+,5.000000,,88.5,88.5,023,NN,FM,12.50,,,,,
+46,GMRS 575/16R,462.575000,+,5.000000,,88.5,88.5,023,NN,FM,12.50,,,,,
+47,GMRS 600/17R,462.600000,+,5.000000,,88.5,88.5,023,NN,FM,12.50,,,,,
+48,GMRS 625/18R,462.625000,+,5.000000,,88.5,88.5,023,NN,FM,12.50,,,,,
+49,GMRS 650/19R,462.650000,+,5.000000,,88.5,88.5,023,NN,FM,12.50,,,,,
+50,GMRS 675/20R,462.675000,+,5.000000,,88.5,88.5,023,NN,FM,12.50,,,,,
+51,GMRS 700/21R,462.700000,+,5.000000,,88.5,88.5,023,NN,FM,12.50,,,,,
+52,GMRS 725/22R,462.725000,+,5.000000,,88.5,88.5,023,NN,FM,12.50,,,,,