[chirp_devel] [PATCH] [uv5r] Memorize extra-settings before erasing memory. Fix for UV-5R of issue #4121

Michael Wagner (OE4AMW)
Sun Oct 23 12:25:30 PDT 2016


# HG changeset patch
# User Michael Wagner <michael.wagner at gmx.at>
# Date 1477250713 -7200
#      Sun Oct 23 21:25:13 2016 +0200
# Node ID 08ef1c3de3998c15997513a5c199f007857c3f0c
# Parent  cc28502a220f297e56fa9d99e7ea74480e1cd15f
[uv5r] Memorize extra-settings before erasing memory. Fix for UV-5R of issue #4121
UV-5R-driver deletes the whole memory before setting the values from UI. As mem.extra is not supplied when memory is edited from the table, this resets the Extra-Settings.
This patch memorizes the values before the deletion, and restores them afterwards.

diff -r cc28502a220f -r 08ef1c3de399 chirp/drivers/uv5r.py
--- a/chirp/drivers/uv5r.py	Sun Oct 16 16:55:56 2016 -0700
+++ b/chirp/drivers/uv5r.py	Sun Oct 23 21:25:13 2016 +0200
@@ -860,6 +860,17 @@
             _nam.set_raw("\xff" * 16)
             return
 
+        wasEmpty = False
+        if _mem.get_raw()[0] == "\xff":
+            wasEmpty = True
+            LOG.debug("UV5R: this mem was empty")
+        else:
+            #memorize old extra-values before erasing the whole memory - used to solve issue 4121
+            LOG.debug("mem was not empty, memorize extra-settings")
+            prev_bcl = _mem.bcl.get_value()
+            prev_scode = _mem.scode.get_value()
+            prev_pttid = _mem.pttid.get_value()
+
         _mem.set_raw("\x00" * 16)
 
         _mem.rxfreq = mem.freq / 10
@@ -929,6 +940,12 @@
         else:
             _mem.lowpower = 0
 
+        if not wasEmpty:
+            #restoring old extra-settings (issue 4121
+            _mem.bcl.set_value(prev_bcl)
+            _mem.scode.set_value(prev_scode)
+            _mem.pttid.set_value(prev_pttid)
+
         for setting in mem.extra:
             setattr(_mem, setting.get_name(), setting.value)
 



More information about the chirp_devel mailing list