[chirp_devel] [PATCH 0 of 4] ft8x7 bug fixes (second try)
I resend the previous patches after comment from Dan. As before the patches correct some bugs on special memories management and I add another bug fix for fm only band check
# HG changeset patch # User Marco Filippi iz3gme.marco@gmail.com # Date 1334817393 -7200 # Node ID 7f126e9a9ddf42dd132a463a9d7a9e144bafc436 # Parent 62a90f40fc3661655e30a0fe683dbce5ee5c1a20 [FT857] Fix PMS memories editing Fixes #131
diff -r 62a90f40fc36 -r 7f126e9a9ddf chirp/ft857.py --- a/chirp/ft857.py gio apr 19 09:03:48 2012 -0700 +++ b/chirp/ft857.py gio apr 19 08:36:33 2012 +0200 @@ -243,7 +243,7 @@ return mem
def _set_special_pms(self, mem): - cur_mem = self._get_special(mem.extd_number) + cur_mem = self._get_special_pms(mem.extd_number)
bitindex = -38 - mem.number if mem.empty:
# HG changeset patch # User Marco Filippi iz3gme.marco@gmail.com # Date 1334855503 -7200 # Node ID ae94b6acc167801f60f24fec8f06f8ec80331df0 # Parent 7f126e9a9ddf42dd132a463a9d7a9e144bafc436 [FT857] Protected a debugging print by CHIRP_DEBUG environment variable Fix Bug #134
diff -r 7f126e9a9ddf -r ae94b6acc167 chirp/ft857.py --- a/chirp/ft857.py gio apr 19 08:36:33 2012 +0200 +++ b/chirp/ft857.py gio apr 19 19:11:43 2012 +0200 @@ -16,6 +16,7 @@
from chirp import ft817, chirp_common, errors, directory from chirp import bitwise +import os
mem_format = """ struct mem_struct{ @@ -226,7 +227,8 @@
bitindex = -38 - mem.number used = ((self._memobj.pmsvisible & self._memobj.pmsfilled) >> bitindex) & 0x01 - print "mem.number %i bitindex %i pmsvisible %i pmsfilled %i used %i" % (mem.number, bitindex, self._memobj.pmsvisible, self._memobj.pmsfilled, used) + if os.getenv("CHIRP_DEBUG"): + print "mem.number %i bitindex %i pmsvisible %i pmsfilled %i used %i" % (mem.number, bitindex, self._memobj.pmsvisible, self._memobj.pmsfilled, used) if not used: mem.empty = True return mem
# HG changeset patch # User Marco Filippi iz3gme.marco@gmail.com # Date 1334857672 -7200 # Node ID 43eba22aaf1b947bb16a893b14a3b694ede1e659 # Parent ae94b6acc167801f60f24fec8f06f8ec80331df0 [ft8x7] React correctly on deletion of special memories fix Bug #136
diff -r ae94b6acc167 -r 43eba22aaf1b chirp/ft817.py --- a/chirp/ft817.py gio apr 19 19:11:43 2012 +0200 +++ b/chirp/ft817.py gio apr 19 19:47:52 2012 +0200 @@ -232,6 +232,8 @@ FIRST_VFOA_INDEX = -21 LAST_VFOA_INDEX = -35
+ SPECIAL_MEMORIES_REV = dict(zip(SPECIAL_MEMORIES.values(), SPECIAL_MEMORIES.keys())) + def sync_in(self): try: self._mmap = clone_in(self) @@ -293,6 +295,9 @@ def get_memory(self, number): if isinstance(number, str): return self._get_special(number) + elif number < 0: + # I can't stop delete operation from loosing extd_number but I know how to get it back + return self._get_special(self.SPECIAL_MEMORIES_REV[number]) else: return self._get_normal(number)
@@ -335,15 +340,18 @@ return mem
def _set_special(self, mem): - cur_mem = self._get_special(mem.extd_number) + if mem.empty: + # can't delete special memories! + raise Exception("Sorry, special memory can't be deleted") + + cur_mem = self._get_special(self.SPECIAL_MEMORIES_REV[mem.number])
for key in cur_mem.immutable: if cur_mem.__dict__[key] != mem.__dict__[key]: raise errors.RadioError("Editing field `%s' " % key + - "is not supported on this chanel") + "is not supported on this channel")
# TODO add frequency range check for vfo and home memories - if mem.number in range(self.FIRST_VFOA_INDEX, self.LAST_VFOA_INDEX -1, -1): _mem = self._memobj.vfoa[-self.LAST_VFOA_INDEX + mem.number] elif mem.number in range(self.FIRST_VFOB_INDEX, self.LAST_VFOB_INDEX -1, -1): @@ -388,7 +396,7 @@ return
self._memobj.visible[(mem.number-1)/8] |= 1 << (mem.number-1)%8 - self._memobj.filled[(mem.number-1)/8] = self._memobj.visible[(mem.number-1)/8] + self._memobj.filled[(mem.number-1)/8] |= 1 << (mem.number-1)%8 self._set_memory(mem, _mem)
def _get_memory(self, mem, _mem): @@ -522,10 +530,10 @@ } LAST_SPECIAL60M_INDEX = -40
- def get_special_locations(self): - lista = self.SPECIAL_60M.keys() - lista.extend(FT817Radio.get_special_locations(self)) - return lista + SPECIAL_MEMORIES = dict(FT817Radio.SPECIAL_MEMORIES) + SPECIAL_MEMORIES.update(SPECIAL_60M) + + SPECIAL_MEMORIES_REV = dict(zip(SPECIAL_MEMORIES.values(), SPECIAL_MEMORIES.keys()))
def _get_special_60M(self, number): mem = chirp_common.Memory() @@ -544,7 +552,11 @@ return mem
def _set_special_60M(self, mem): - cur_mem = self._get_special_60M(mem.extd_number) + if mem.empty: + # can't delete 60M memories! + raise Exception("Sorry, 60M memory can't be deleted") + + cur_mem = self._get_special_60M(self.SPECIAL_MEMORIES_REV[mem.number])
for key in cur_mem.immutable: if cur_mem.__dict__[key] != mem.__dict__[key]: @@ -560,11 +572,14 @@ def get_memory(self, number): if number in self.SPECIAL_60M.keys(): return self._get_special_60M(number) + elif number < 0 and self.SPECIAL_MEMORIES_REV[number] in self.SPECIAL_60M.keys(): + # I can't stop delete operation from loosing extd_number but I know how to get it back + return self._get_special_60M(self.SPECIAL_MEMORIES_REV[number]) else: return FT817Radio.get_memory(self, number)
def set_memory(self, memory): - if memory.extd_number in self.SPECIAL_60M.keys(): + if memory.number in self.SPECIAL_60M.values(): return self._set_special_60M(memory) else: return FT817Radio.set_memory(self, memory) diff -r ae94b6acc167 -r 43eba22aaf1b chirp/ft857.py --- a/chirp/ft857.py gio apr 19 19:11:43 2012 +0200 +++ b/chirp/ft857.py gio apr 19 19:47:52 2012 +0200 @@ -82,20 +82,6 @@ """
-SPECIAL_PMS = { # WARNING Index are hard wired in memory management code !!! - "PMS-1L" : -47, - "PMS-1U" : -46, - "PMS-2L" : -45, - "PMS-2U" : -44, - "PMS-3L" : -43, - "PMS-3U" : -42, - "PMS-4L" : -41, - "PMS-4U" : -40, - "PMS-5L" : -39, - "PMS-5U" : -38, -} - - @directory.register class FT857Radio(ft817.FT817Radio): MODEL = "FT-857/897" @@ -182,6 +168,24 @@ FIRST_VFOA_INDEX = -22 LAST_VFOA_INDEX = -37
+ SPECIAL_PMS = { # WARNING Index are hard wired in memory management code !!! + "PMS-1L" : -47, + "PMS-1U" : -46, + "PMS-2L" : -45, + "PMS-2U" : -44, + "PMS-3L" : -43, + "PMS-3U" : -42, + "PMS-4L" : -41, + "PMS-4U" : -40, + "PMS-5L" : -39, + "PMS-5U" : -38, + } + + SPECIAL_MEMORIES = dict(ft817.FT817Radio.SPECIAL_MEMORIES) + SPECIAL_MEMORIES.update(SPECIAL_PMS) + + SPECIAL_MEMORIES_REV = dict(zip(SPECIAL_MEMORIES.values(), SPECIAL_MEMORIES.keys())) + def get_features(self): rf = ft817.FT817Radio.get_features(self) rf.has_cross = True @@ -215,22 +219,20 @@ def process_mmap(self): self._memobj = bitwise.parse(mem_format, self._mmap)
- def get_special_locations(self): - lista = SPECIAL_PMS.keys() - lista.extend(self.SPECIAL_MEMORIES) - return lista - def _get_special_pms(self, number): mem = chirp_common.Memory() - mem.number = SPECIAL_PMS[number] + mem.number = self.SPECIAL_PMS[number] mem.extd_number = number
bitindex = -38 - mem.number - used = ((self._memobj.pmsvisible & self._memobj.pmsfilled) >> bitindex) & 0x01 + used = (self._memobj.pmsvisible >> bitindex) & 0x01 + valid = (self._memobj.pmsfilled >> bitindex) & 0x01 if os.getenv("CHIRP_DEBUG"): - print "mem.number %i bitindex %i pmsvisible %i pmsfilled %i used %i" % (mem.number, bitindex, self._memobj.pmsvisible, self._memobj.pmsfilled, used) + print "mem.number %i bitindex %i pmsvisible %i pmsfilled %i used %i filled %i" % (mem.number, bitindex, self._memobj.pmsvisible, self._memobj.pmsfilled, used, valid) if not used: mem.empty = True + if not valid: + mem.empty = True return mem
_mem = self._memobj.pms[47 + mem.number] @@ -240,20 +242,25 @@ mem.immutable = ["number", "skip", "rtone", "ctone", "extd_number", "dtcs", "tmode", "cross_mode", "dtcs_polarity", "power", "duplex", "offset", - "comment", "empty"] + "comment"]
return mem
def _set_special_pms(self, mem): - cur_mem = self._get_special_pms(mem.extd_number) + cur_mem = self._get_special_pms(self.SPECIAL_MEMORIES_REV[mem.number])
bitindex = -38 - mem.number - if mem.empty: + wasused = (self._memobj.pmsvisible >> bitindex) & 0x01 + wasvalid = (self._memobj.pmsfilled >> bitindex) & 0x01 + + if mem.empty: + if wasvalid and not wasused: + self._memobj.pmsfilled &= ~ (1 << bitindex) self._memobj.pmsvisible &= ~ (1 << bitindex) - self._memobj.pmsfilled = self._memobj.pmsvisible return + self._memobj.pmsvisible |= 1 << bitindex - self._memobj.pmsfilled = self._memobj.pmsvisible + self._memobj.pmsfilled |= 1 << bitindex
for key in cur_mem.immutable: if cur_mem.__dict__[key] != mem.__dict__[key]: @@ -264,13 +271,16 @@ self._set_memory(mem, _mem)
def get_memory(self, number): - if number in SPECIAL_PMS.keys(): + if number in self.SPECIAL_PMS.keys(): return self._get_special_pms(number) + elif number < 0 and self.SPECIAL_MEMORIES_REV[number] in self.SPECIAL_PMS.keys(): + # I can't stop delete operation from loosing extd_number but I know how to get it back + return self._get_special_pms(self.SPECIAL_MEMORIES_REV[number]) else: return ft817.FT817Radio.get_memory(self, number)
def set_memory(self, memory): - if memory.extd_number in SPECIAL_PMS.keys(): + if memory.number in self.SPECIAL_PMS.values(): return self._set_special_pms(memory) else: return ft817.FT817Radio.set_memory(self, memory) @@ -297,10 +307,10 @@ } LAST_SPECIAL60M_INDEX = -52
- def get_special_locations(self): - lista = self.SPECIAL_60M.keys() - lista.extend(FT857Radio.get_special_locations(self)) - return lista + SPECIAL_MEMORIES = dict(FT857Radio.SPECIAL_MEMORIES) + SPECIAL_MEMORIES.update(SPECIAL_60M) + + SPECIAL_MEMORIES_REV = dict(zip(SPECIAL_MEMORIES.values(), SPECIAL_MEMORIES.keys()))
# this is identical to the one in FT817ND_US_Radio but we inherit from 857 def _get_special_60M(self, number): @@ -321,7 +331,11 @@
# this is identical to the one in FT817ND_US_Radio but we inherit from 857 def _set_special_60M(self, mem): - cur_mem = self._get_special_60M(mem.extd_number) + if mem.empty: + # can't delete 60M memories! + raise Exception("Sorry, 60M memory can't be deleted") + + cur_mem = self._get_special_60M(self.SPECIAL_MEMORIES_REV[mem.number])
for key in cur_mem.immutable: if cur_mem.__dict__[key] != mem.__dict__[key]: @@ -337,11 +351,14 @@ def get_memory(self, number): if number in self.SPECIAL_60M.keys(): return self._get_special_60M(number) + elif number < 0 and self.SPECIAL_MEMORIES_REV[number] in self.SPECIAL_60M.keys(): + # I can't stop delete operation from loosing extd_number but I know how to get it back + return self._get_special_60M(self.SPECIAL_MEMORIES_REV[number]) else: return FT857Radio.get_memory(self, number)
def set_memory(self, memory): - if memory.extd_number in self.SPECIAL_60M.keys(): + if memory.number in self.SPECIAL_60M.values(): return self._set_special_60M(memory) else: return FT857Radio.set_memory(self, memory)
# HG changeset patch # User Marco Filippi iz3gme.marco@gmail.com # Date 1334858850 -7200 # Node ID 669937b80341f391ba793fa1d3bf3ce40a9aa9c0 # Parent 43eba22aaf1b947bb16a893b14a3b694ede1e659 [FT8x7] Index error on fm only band check Affect whole ft8x7 family fix Bug #137
diff -r 43eba22aaf1b -r 669937b80341 chirp/ft817.py --- a/chirp/ft817.py gio apr 19 19:47:52 2012 +0200 +++ b/chirp/ft817.py gio apr 19 20:07:30 2012 +0200 @@ -490,7 +490,7 @@ def validate_memory(self, mem): msgs = yaesu_clone.YaesuCloneModeRadio.validate_memory(self, mem)
- lo, hi = self.VALID_BANDS[3] # this is fm broadcasting + lo, hi = self.VALID_BANDS[2] # this is fm broadcasting if mem.freq >= lo and mem.freq <= hi: if mem.mode != "FM": msgs.append(chirp_common.ValidationError("Only FM is supported in this band"))
participants (2)
-
Dan Smith
-
Marco Filippi IZ3GME