[chirp_devel] [PATCH] [tg_uv2p] (revision 3) Inhibit keypad lock when in dual watch or crossmode. Fixes forth issue in #9939

Ran Katz
Sun Aug 21 14:23:04 PDT 2022


# HG changeset patch
# User Ran Katz <rankatz at gmail.com>
# Date 1661116800 -10800
#      Mon Aug 22 00:20:00 2022 +0300
# Node ID fe2bf00b162b84524e7b8fc8bde066b24c320576
# Parent  6cabd29d939775b729e2ccf0441aabf82595bb2a
[tg_uv2p] (revision 3) Inhibit keypad lock when in dual watch or crossmode. Fixes forth issue in #9939
Added logical tests to raise exception only on user changes to the relevant settings
(and not on "static" settings e.g. do to downloaded radio with such a configuration)
Also removed the explicit settings on error on both keyunlocked and rx_mode settings

diff --git a/chirp/drivers/tg_uv2p.py b/chirp/drivers/tg_uv2p.py
--- a/chirp/drivers/tg_uv2p.py
+++ b/chirp/drivers/tg_uv2p.py
@@ -728,9 +728,27 @@
                                                        not int(element.value)))
                         setattr(obj, setting, not int(element.value))
                     elif setting == "keyunlocked":
+                        # keypad currently unlocked being set to locked
+                        # and rx_mode is currently not "Normal":
+                        if getattr(obj, "keyunlocked") and int(element.value) \
+                                and (getattr(obj, "rxmode") != 0x02):
+                            raise errors.InvalidValueError(
+                                "Keypad lock not allowed in "
+                                "Dual-Watch or CrossBand")
                         LOG.debug("Setting %s = %s" % (setting,
                                                        not int(element.value)))
                         setattr(obj, setting, not int(element.value))
+                    elif setting == "rxmode":
+                        # rx_mode was normal, now being set otherwise
+                        # and keypad is locked:
+                        if (getattr(obj, "rxmode") == 0x02) \
+                                and (int(element.value) != 2) \
+                                and not (getattr(obj, "keyunlocked")):
+                            raise errors.InvalidValueError(
+                                "Dual-Watch or CrossBand can not be set "
+                                "when keypad is locked")
+                        LOG.debug("Setting %s = %s" % (setting, element.value))
+                        setattr(obj, setting, element.value)
                     elif setting == "priority_channel":
                         _check = self._validate_priority_ch(int(element.value))
                         if _check:




More information about the chirp_devel mailing list