[chirp_devel] [PATCH 0 of 4 ] Some more fix for KG-UV8D
Working on #2143 I added the radio image for test and this revealed the need for more small fix. This suggest me that we should force developpers to add radio image at first commit for new models.
The first patch of the group contains the image alone, I used the very same format as last time, let me known if you can apply it smoothly.
73 de IZ3GME Marco
# HG changeset patch # User Marco Filippi iz3gme.marco@gmail.com # Date 1421395598 -3600 # Fri Jan 16 09:06:38 2015 +0100 # Node ID 0a9659ddd83b60e5615fd4cc82aa02843d7674d9 # Parent b3ed27f5b374361bae24b8d4d8d0c7a799bee55b [KG-UV8D] add image file for auto test
will point out #2143
diff --git a/tests/images/Wouxun_KG-UV8D.img b/tests/images/Wouxun_KG-UV8D.img new file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..1c664474053cce793cad9ab21dddd7e92cb6909f GIT binary patch literal 32768 zc%1FsPe_w-7{Kx8_r5KpO*iMi3L%d{8JqZTCRQ*Ai6{_lPPcddsTj!$>eL~E1SO=r z1a`>iRCw{yMT#yR^3tVCQ4&a$S1Av6asA$R&gKlIX4&EU+57C>^YVM1_kEwidm1dA zUT^Zr`dreRQ?fs8^hd>*yR<vIm)9!^<=%Z^ZNEwVnfCDU)=;Rav7t%78tbFco}S*` zSS%j5tVExP-P7)4x@J~pRyNju`8+>AKlj%5#*TY;#>Q@IqoX4u!^1bOr&7t}pk`T7 zt@Eti&y`aj_7~Sym$#LbM7-{Bg|BU|KjQP~ZHwFfW7XAFRh5-xWu=<WS6b@vxZQg) z+-{F-HSTS9x;=d2SnJW2P)kclYmP*^yQ9%wEf%*DThD*i@$$vY)9I<HDUoYeuV|^% z(9lrwqKFLkC*qlJ)3V|*$@DUn%GPJ*-&*d?o4*qAE#$1*E)^Aizt>w*;&BuguT6i4 z=D*WUo$Tyt4vTbjb@U}uH652z$$_7r0>OYSXs_uC9tkw8&ZjOAtPh0h>I*-=C>fAJ zc_p*zkUFgHs&VyAEg9#Gi1EyLZXPge%v<KLxls6-0OZSm;)zY|aw+`))|*izfgJjf zsYH1f7nQTlesk$4DzXzN%{0g~GnU2FCs4V^@)!>v-ON^f-KSi?T(sHse^{DWtH1yI z^&79}!Gs-lKO?B)@%dRhoc`Zc+L*3gwj-O%`%ed*$mVn7@0`fyAKONqSj_<d00000 z000000000000000000000RJZe000000000000005|6hkpI(GUt0Q^OT{{E)W=L`S< M000000Q_q|06v{_-~a#s
# HG changeset patch # User Marco Filippi iz3gme.marco@gmail.com # Date 1421396204 -3600 # Fri Jan 16 09:16:44 2015 +0100 # Node ID c70c9f0a2935d9455894e3f69ecfd46dd2eb60fb # Parent 0a9659ddd83b60e5615fd4cc82aa02843d7674d9 [KG-UV8D] Fix memory label get/set
After adding radio image, automated tests revealed that empty label chars were not handled correctly As a side effect of defining element as u8 we can now see their values in developper browser
discovered working on #2143
diff --git a/chirp/kguv8d.py b/chirp/kguv8d.py --- a/chirp/kguv8d.py +++ b/chirp/kguv8d.py @@ -246,7 +246,7 @@
#seekto 0x4780; struct { - char name[8]; + u8 name[8]; } names[1000];
#seekto 0x6700; @@ -517,7 +517,8 @@ mem.offset = abs(int(_mem.rxfreq) - int(_mem.txfreq)) * 10
for char in _nam.name: - mem.name += str(char) + if char != 0: + mem.name += chr(char) mem.name = mem.name.rstrip()
dtcs_pol = ["N", "N"] @@ -649,9 +650,11 @@ # set to mute mode to QT (not QT+DTMF or QT*DTMF) _mem.mute_mode = 0
- for i in range(0, len(mem.name)): - if mem.name[i]: - _nam.name[i] = mem.name[i] + for i in range(0, len(_nam.name)): + if i < len(mem.name) and mem.name[i]: + _nam.name[i] = ord(mem.name[i]) + else: + _nam.name[i] = 0x0 self._memobj.valid[mem.number] = MEM_VALID
def _get_settings(self):
# HG changeset patch # User Marco Filippi iz3gme.marco@gmail.com # Date 1421396615 -3600 # Fri Jan 16 09:23:35 2015 +0100 # Node ID c78b0e62a19452442f9dbb05ab422685ed94e898 # Parent c70c9f0a2935d9455894e3f69ecfd46dd2eb60fb [KG-UV8D] Fix DTCS support
Fix #2143
diff --git a/chirp/kguv8d.py b/chirp/kguv8d.py --- a/chirp/kguv8d.py +++ b/chirp/kguv8d.py @@ -27,8 +27,6 @@ else: CHIRP_DEBUG = False
-KGUV8D_DTCS = sorted(chirp_common.DTCS_CODES) - CMD_ID = 128 CMD_END = 129 CMD_RD = 130 @@ -488,6 +486,51 @@ def get_raw_memory(self, number): return repr(self._memobj.memory[number])
+ def _get_tone(self, _mem, mem): + def _get_dcs(val): + code = int("%03o" % (val & 0x07FF)) + pol = (val & 0x8000) and "R" or "N" + return code, pol + + tpol = False + if _mem.txtone != 0xFFFF and (_mem.txtone & 0x2800) == 0x2800: + tcode, tpol = _get_dcs(_mem.txtone) + mem.dtcs = tcode + txmode = "DTCS" + elif _mem.txtone != 0xFFFF and _mem.txtone != 0x0: + mem.rtone = (_mem.txtone & 0x7fff) / 10.0 + txmode = "Tone" + else: + txmode = "" + + rpol = False + if _mem.rxtone != 0xFFFF and (_mem.rxtone & 0x2800) == 0x2800: + rcode, rpol = _get_dcs(_mem.rxtone) + mem.rx_dtcs = rcode + rxmode = "DTCS" + elif _mem.rxtone != 0xFFFF and _mem.rxtone != 0x0: + mem.ctone = (_mem.rxtone & 0x7fff) / 10.0 + rxmode = "Tone" + else: + rxmode = "" + + if txmode == "Tone" and not rxmode: + mem.tmode = "Tone" + elif txmode == rxmode and txmode == "Tone" and mem.rtone == mem.ctone: + mem.tmode = "TSQL" + elif txmode == rxmode and txmode == "DTCS" and mem.dtcs == mem.rx_dtcs: + mem.tmode = "DTCS" + elif rxmode or txmode: + mem.tmode = "Cross" + mem.cross_mode = "%s->%s" % (txmode, rxmode) + + # always set it even if no dtcs is used + mem.dtcs_polarity = "%s%s" % (tpol or "N", rpol or "N") + + if os.getenv("CHIRP_DEBUG"): + print "Got TX %s (%i) RX %s (%i)" % (txmode, _mem.txtone, + rxmode, _mem.rxtone) + def get_memory(self, number): _mem = self._memobj.memory[number] _nam = self._memobj.names[number] @@ -521,51 +564,7 @@ mem.name += chr(char) mem.name = mem.name.rstrip()
- dtcs_pol = ["N", "N"] - - if _mem.txtone in [0, 0x3fff]: - txmode = "" - elif _mem.txtone >= 0x8000 and _mem.txtone < 0xc000: - txmode = "Tone" - mem.rtone = int(_mem.txtone % 16384) / 10.0 - elif _mem.txtone >= 0x4000 and _mem.txtone < 0x8000: - txmode = "DTCS" - if _mem.txtone > 0x69: - index = _mem.txtone - 0x6A - dtcs_pol[0] = "R" - else: - index = _mem.txtone - 1 - mem.dtcs = KGUV8D_DTCS[index] - else: - print "Bug: txtone is %04x" % _mem.txtone - - if _mem.rxtone in [0, 0x3fff]: - rxmode = "" - elif _mem.rxtone >= 0x0258: - rxmode = "Tone" - mem.ctone = int(_mem.rxtone % 16384) / 10.0 - elif _mem.rxtone <= 0x0258: - rxmode = "DTCS" - if _mem.rxtone >= 0x6A: - index = _mem.rxtone - 0x6A - dtcs_pol[1] = "R" - else: - index = _mem.rxtone - 1 - mem.rx_dtcs = KGUV8D_DTCS[index] - else: - print "Bug: rxtone is %04x" % _mem.rxtone - - if txmode == "Tone" and not rxmode: - mem.tmode = "Tone" - elif txmode == rxmode and txmode == "Tone" and mem.rtone == mem.ctone: - mem.tmode = "TSQL" - elif txmode == rxmode and txmode == "DTCS" and mem.dtcs == mem.rx_dtcs: - mem.tmode = "DTCS" - elif rxmode or txmode: - mem.tmode = "Cross" - mem.cross_mode = "%s->%s" % (txmode, rxmode) - - mem.dtcs_polarity = "".join(dtcs_pol) + self._get_tone(_mem, mem)
mem.skip = "" if bool(_mem.scan_add) else "S"
# HG changeset patch # User Marco Filippi iz3gme.marco@gmail.com # Date 1421400039 -3600 # Fri Jan 16 10:20:39 2015 +0100 # Node ID 76d1644976bdcbda35bd7766348f5d347c36e078 # Parent c78b0e62a19452442f9dbb05ab422685ed94e898 [KG-UV8D] Fix tone radio features
After adding radio image, automated tests revealed that valid_tmodes was missing "Cross" and valid_cross_modes was not set
discovered working on #2143
diff --git a/chirp/kguv8d.py b/chirp/kguv8d.py --- a/chirp/kguv8d.py +++ b/chirp/kguv8d.py @@ -464,7 +464,16 @@ rf.has_bank = False rf.can_odd_split = True rf.valid_skips = ["", "S"] - rf.valid_tmodes = ["", "Tone", "TSQL", "DTCS"] + rf.valid_tmodes = ["", "Tone", "TSQL", "DTCS", "Cross"] + rf.valid_cross_modes = [ + "Tone->Tone", + "Tone->DTCS", + "DTCS->Tone", + "DTCS->", + "->Tone", + "->DTCS", + "DTCS->DTCS", + ] rf.valid_modes = ["FM", "NFM"] rf.valid_power_levels = self.POWER_LEVELS rf.valid_name_length = 8 diff --git a/tests/run_tests b/tests/run_tests --- a/tests/run_tests +++ b/tests/run_tests @@ -54,7 +54,7 @@ ("Args were: %s" % self.__args) + os.linesep + \ self.__tb + os.linesep + \ "Called from:" + os.linesep + self.__mytb - +
def get_original_exception(self): return self.__exc @@ -102,7 +102,7 @@ self.open() except Exception, e: raise TestCrashError(get_tb(), e, "[Loading]") - + try: fn = getattr(self._dst, function) except KeyError: @@ -153,7 +153,7 @@
def compare_mem(self, a, b): rf = self._wrapper.do("get_features") - + if a.tmode == "Cross": tx_mode, rx_mode = a.cross_mode.split("->")
@@ -171,13 +171,13 @@ elif k == "tuning_step" and not rf.has_tuning_step: continue elif k == "rtone" and not ( - a.tmode == "Tone" or + a.tmode == "Tone" or (a.tmode == "TSQL" and not rf.has_ctone) or (a.tmode == "Cross" and tx_mode == "Tone") or (a.tmode == "Cross" and rx_mode == "Tone" and not rf.has_ctone) ): continue - elif k == "ctone" and (not rf.has_ctone or + elif k == "ctone" and (not rf.has_ctone or not ( a.tmode == "TSQL" or (a.tmode == "Cross" and rx_mode == "Tone") @@ -185,7 +185,7 @@ ): continue elif k == "dtcs" and not ( - (a.tmode == "DTCS" and not rf.has_rx_dtcs) or + (a.tmode == "DTCS" and not rf.has_rx_dtcs) or (a.tmode == "Cross" and tx_mode == "DTCS") or (a.tmode == "Cross" and rx_mode == "DTCS" and not rf.has_rx_dtcs) ): @@ -276,7 +276,7 @@ def set_and_compare(self, m): msgs = self._wrapper.do("validate_memory", m) if msgs: - + raise TestFailedError("Radio did not validate a valid memory", os.linesep.join(["%s:%s" % (k,v) for k,v in m.__dict__.items()]) + os.linesep + os.linesep.join(msgs))
@@ -362,7 +362,7 @@ m.offset = rf.valid_bands[0][1] - 100000 m.duplex = duplex self.set_and_compare(m) - + if rf.can_odd_split and "split" not in rf.valid_duplexes: raise TestFailedError("Paste error: rf.can_odd_split defined, but " "split duplex not supported.") @@ -506,7 +506,7 @@ self._wrapper.do("set_memory", m) n = self._wrapper.do("get_memory", m.number) self.compare_mem(m, n) - +
def run(self): rf = self._wrapper.do("get_features") @@ -626,7 +626,7 @@ did_error = False except Exception: did_error = True - + if not did_error: raise TestFailedError("Removing memory from non-member bank " +\ "did not raise Exception") @@ -666,7 +666,7 @@
self.do_bank_names(rf) self.do_bank_names_toolong(rf) - self.do_bank_names_no_trailing_whitespace(rf) + self.do_bank_names_no_trailing_whitespace(rf) self.do_bank_store(rf) self.do_bank_store(rf) # Again to make sure we clear bank info on delete self.do_bank_index(rf) @@ -784,7 +784,7 @@ "with %s data" % serial, "On sync_out()") elif not isinstance(error, errors.RadioError): - raise TestFailedError("Radio did not raise RadioError " + + raise TestFailedError("Radio did not raise RadioError " + "with %s data" % serial, "sync_out(): Got: %s (%s)" % (\ error.__class__.__name__, error)) @@ -1029,7 +1029,7 @@ def run_all(self): run_list = self._make_list() return self.run_list(run_list) - + def run_one(self, drv_name): return self.run_rclass_image(directory.get_radio(drv_name), os.path.join("images",
participants (1)
-
Marco Filippi IZ3GME