[chirp_devel] [PATCH] [THD72] Fix buggy memory initialization. #1611

Tom Hayward
Fri Mar 17 22:00:46 PDT 2017


# HG changeset patch
# User Tom Hayward <tom at tomh.us>
# Date 1489813179 25200
#      Fri Mar 17 21:59:39 2017 -0700
# Node ID 027d861a73342f6208f4f977d844b2caf4be5721
# Parent  6b5b397b4859dd64603d7c4a0b91ffdbdfbe2bb6
[THD72] Fix buggy memory initialization. #1611

Allows channels added by Chirp to transmit. As a side effect, transmit inhibit
is now optional (rather than compulsary).

diff -r 6b5b397b4859 -r 027d861a7334 chirp/drivers/thd72.py
--- a/chirp/drivers/thd72.py	Fri Mar 17 15:17:57 2017 -0700
+++ b/chirp/drivers/thd72.py	Fri Mar 17 21:59:39 2017 -0700
@@ -90,7 +90,7 @@
 #seekto 0x0c00;
 struct {
   u8 disabled:7,
-     unknown0:1;
+     txinhibit:1;
   u8 skip;
 } flag[1032];
 
@@ -183,9 +183,6 @@
 EXCH_R = "R\x00\x00\x00\x00"
 EXCH_W = "W\x00\x00\x00\x00"
 
-# Uploads result in "MCP Error" and garbage data in memory
-# Clone driver disabled in favor of error-checking live driver.
-
 
 @directory.register
 class THD72Radio(chirp_common.CloneModeRadio):
@@ -224,7 +221,7 @@
         rf.valid_tuning_steps = []
         rf.valid_modes = MODES_REV.keys()
         rf.valid_tmodes = TMODES_REV.keys()
-        rf.valid_duplexes = DUPLEX_REV.keys()
+        rf.valid_duplexes = DUPLEX_REV.keys() + ["off"]
         rf.valid_skips = ["", "S"]
         rf.valid_characters = chirp_common.CHARSET_ALPHANUMERIC
         rf.valid_name_length = 8
@@ -283,7 +280,7 @@
 
     def get_raw_memory(self, number):
         return repr(self._memobj.memory[number]) + \
-            repr(self._memobj.flag[(number)])
+            repr(self._memobj.flag[number])
 
     def get_memory(self, number):
         if isinstance(number, str):
@@ -315,7 +312,7 @@
         mem.rtone = chirp_common.TONES[_mem.rtone]
         mem.ctone = chirp_common.TONES[_mem.ctone]
         mem.dtcs = chirp_common.DTCS_CODES[_mem.dtcs]
-        mem.duplex = DUPLEX[int(_mem.duplex)]
+        mem.duplex = flag.txinhibit and "off" or DUPLEX[int(_mem.duplex)]
         mem.offset = int(_mem.offset)
         mem.mode = MODES[int(_mem.mode)]
 
@@ -369,7 +366,8 @@
         _mem.ctone = chirp_common.TONES.index(mem.ctone)
         _mem.dtcs = chirp_common.DTCS_CODES.index(mem.dtcs)
         _mem.cross_mode = chirp_common.CROSS_MODES.index(mem.cross_mode)
-        _mem.duplex = DUPLEX_REV[mem.duplex]
+        flag.txinhibit = mem.duplex == "off"
+        _mem.duplex = DUPLEX_REV.get(mem.duplex, 0)
         _mem.offset = mem.offset
         _mem.mode = MODES_REV[mem.mode]
 
@@ -509,9 +507,8 @@
             raise errors.RadioError("No response to ID command")
 
     def initialize(self, mmap):
-        mmap[0] = \
-            "\x80\xc8\xb3\x08\x00\x01\x00\x08" + \
-            "\x08\x00\xc0\x27\x09\x00\x00\xff"
+        mmap.set_raw("\x00\xc8\xb3\x08\x00\x01\x00\x08"
+                     "\x08\x00\xc0\x27\x09\x00\x00\x00")
 
     def _get_settings(self):
         top = RadioSettings(self._get_display_settings(),



More information about the chirp_devel mailing list