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

Michael Wagner (OE4AMW)
Thu Nov 3 03:42:33 PDT 2016


# HG changeset patch
# User Michael Wagner <michael.wagner at gmx.at>
# Date 1478169599 -3600
#      Thu Nov 03 11:39:59 2016 +0100
# Node ID 8dc525acb583b9dbfbd88eb10a83e52816750edd
# Parent  c386ef4dc431e5065266de2b163260e6f5637b27
[uv5r] Memorize extra-settings before erasing memory. Fix for UV-5R of issue #4121
Try two, with consistent naming of variables.

diff -r c386ef4dc431 -r 8dc525acb583 chirp/drivers/uv5r.py
--- a/chirp/drivers/uv5r.py	Tue Nov 01 18:42:18 2016 -0700
+++ b/chirp/drivers/uv5r.py	Thu Nov 03 11:39:59 2016 +0100
@@ -860,6 +860,20 @@
             _nam.set_raw("\xff" * 16)
             return
 
+        was_empty = False
+        # same method as used in get_memory to find 
+        # out whether a raw memory is empty
+        if _mem.get_raw()[0] == "\xff":
+            was_empty = 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 +943,12 @@
         else:
             _mem.lowpower = 0
 
+        if not was_empty:
+            #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