[chirp_devel] Re: [PATCH] [FT-60] Fix Memory Bounds and Seek Offsets

stickpatrick at gmail.com
Sat Jan 10 22:09:04 PST 2015


I'll give this a try tomorrow, but 2 questions:

From the radio standpoint, is the memory laid out as 000-999, or 1-999, then 000?

Or to put it another way - will CHIRP display the radio's 000 as 1000 or 0?




(this one is for Dan) - it looks like this replaces invalid characters with ' 'rather than truncating them.  Is this the desired behavior?  When I fixed a similar bug for the TH-D7, I preserved the existing truncation behavior rather than replacing with ' ‘




Sent from Windows Mail





From: Kosta Arvanitis
Sent: ‎Saturday‎, ‎January‎ ‎10‎, ‎2015 ‎7‎:‎40‎ ‎PM
To: chirp_devel at intrepid.danplanet.com





# HG changeset patch
# User K. Arvanitis <kosta at alumni.uvic.ca>
# Date 1420442263 28800
#      Sun Jan 04 23:17:43 2015 -0800
# Node ID 15c8e53a218702d708f5a018c115965dd2fdbb0c
# Parent  9e67e7ba60e0fd2accd89d899735b5040da8032b
[FT-60] Fix Memory Bounds and Seek Offsets

This adjusts the memory bounds of the Yaesu FT-60 to include all 1000 memory channels, in addition the seek offsets were adjusted to align correctly to their appropriate memory locations.

diff -r 9e67e7ba60e0 -r 15c8e53a2187 chirp/ft60.py
--- a/chirp/ft60.py Sun Jan 04 23:15:45 2015 -0800
+++ b/chirp/ft60.py Sun Jan 04 23:17:43 2015 -0800
@@ -104,9 +104,31 @@
         flags += 0x40
     return freqraw, flags
 
+def _decode_name(mem):
+    name = ""
+    for i in mem:
+        if i == 0xFF:
+            break
+        try:
+            name += CHARSET[i]
+        except IndexError:
+            print "Unknown char index: %i " % (i)
+    return name
+
+
+def _encode_name(mem):
+    name = [None]*6
+    for i in range(0, 6):
+        try:
+            name[i] = CHARSET.index(mem[i]) 
+        except IndexError:
+            name[i] = CHARSET.index(" ")
+
+    return name
+
 
 MEM_FORMAT = """
-#seekto 0x0238;
+#seekto 0x0248;
 struct {
   u8 used:1,
      unknown1:1,
@@ -129,7 +151,7 @@
 } memory[1000];
 
 #seekto 0x6EC8;
-// skips:2 for Memory M in [1, 1000] is in skipflags[(M-1)/4].skip((M-1)%4).
+// skips:2 for Memory M in [1, 1000] is in flags[(M-1)/4].skip((M-1)%4).
 // Interpret with SKIPS[].
 // PMS memories L0 - U50 aka memory 1001 - 1100 don't have skip flags.
 struct {
@@ -137,9 +159,9 @@
      skip2:2,
      skip1:2,
      skip0:2;
-} skipflags[250];
+} flags[250];
 
-#seekto 0x4700;
+#seekto 0x4708;
 struct {
   u8 name[6];
   u8 use_name:1,
@@ -239,7 +261,7 @@
         
     def get_features(self):
         rf = chirp_common.RadioFeatures()
-        rf.memory_bounds = (1, 999)
+        rf.memory_bounds = (1, 1000)
         rf.valid_duplexes = DUPLEX
         rf.valid_tmodes = TMODES
         rf.valid_power_levels = POWER_LEVELS
@@ -285,18 +307,16 @@
         self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
 
     def get_raw_memory(self, number):
-        _array_index = number - 1
-        return repr(self._memobj.memory[number]) + \
-            repr(self._memobj.skipflags[_array_index/4]) + \
-            repr(self._memobj.names[number])
+        return repr(self._memobj.memory[number - 1]) + \
+            repr(self._memobj.flags[(number - 1) / 4]) + \
+            repr(self._memobj.names[number - 1])
 
     def get_memory(self, number):
-        _array_index = number - 1
-        _mem = self._memobj.memory[number]
-        _skp = self._memobj.skipflags[_array_index/4]
-        _nam = self._memobj.names[number]
+        _mem = self._memobj.memory[number - 1]
+        _skp = self._memobj.flags[(number - 1) / 4]
+        _nam = self._memobj.names[number - 1]
 
-        skip = _skp["skip%i" % (_array_index%4)]
+        skip = _skp["skip%i" % ((number - 1) % 4)]
 
         mem = chirp_common.Memory()
         mem.number = number
@@ -320,22 +340,14 @@
         mem.skip = SKIPS[skip]
 
         if _nam.use_name and _nam.valid:
-            for i in _nam.name:
-                if i == 0xFF:
-                    break
-                try:
-                    mem.name += CHARSET[i]
-                except IndexError:
-                    print "Memory %i: Unknown char index: %i " % (number, i)
-            mem.name = mem.name.rstrip()
+            mem.name = _decode_name(_nam.name).rstrip()
 
         return mem
 
     def set_memory(self, mem):
-        _array_index = mem.number - 1
-        _mem = self._memobj.memory[mem.number]
-        _skp = self._memobj.skipflags[_array_index/4]
-        _nam = self._memobj.names[mem.number]
+        _mem = self._memobj.memory[mem.number - 1]
+        _skp = self._memobj.flags[(mem.number - 1) / 4]
+        _nam = self._memobj.names[mem.number - 1]
 
         if mem.empty:
             _mem.used = False
@@ -364,13 +376,8 @@
         _mem.isam = mem.mode == "AM"
         _mem.step = STEPS.index(mem.tuning_step)
 
-        _skp["skip%i" % (_array_index%4)] = SKIPS.index(mem.skip)
+        _skp["skip%i" % ((mem.number - 1) % 4)] = SKIPS.index(mem.skip)
 
-        for i in range(0, 6):
-            try:
-                _nam.name[i] = CHARSET.index(mem.name[i])
-            except IndexError:
-                _nam.name[i] = CHARSET.index(" ")
-            
+        _nam.name = _encode_name(mem.name)
         _nam.use_name = mem.name.strip() and True or False
         _nam.valid = _nam.use_name            
_______________________________________________
chirp_devel mailing list
chirp_devel at intrepid.danplanet.com
http://intrepid.danplanet.com/mailman/listinfo/chirp_devel
Developer docs: http://chirp.danplanet.com/projects/chirp/wiki/Developers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://intrepid.danplanet.com/pipermail/chirp_devel/attachments/20150111/75df7d31/attachment-0001.html 


More information about the chirp_devel mailing list