From d8cc8c9860d38ea5246d82b30e718253633a67c1 Mon Sep 17 00:00:00 2001 From: Jim Unroe Date: Wed, 28 Dec 2022 19:23:17 -0500 Subject: [PATCH] Driver update: mursv1.py * Switch frequency tables to Hz based * Remove no longer needed validate_memory() code --- chirp/drivers/mursv1.py | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/chirp/drivers/mursv1.py b/chirp/drivers/mursv1.py index bed2bc597..b1235399c 100644 --- a/chirp/drivers/mursv1.py +++ b/chirp/drivers/mursv1.py @@ -67,7 +67,7 @@ LIST_VOICE = ["Off", "English", "Chinese"] LIST_WORKMODE = ["Frequency", "Channel"] -MURS_FREQS = [151.820, 151.880, 151.940, 154.570, 154.600] * 3 +MURS_FREQS = [151820000, 151880000, 151940000, 154570000, 154600000] * 3 FM_MODE = [3, 4, 8, 9, 13, 14] @@ -378,8 +378,16 @@ def get_memory(self, number): mem = chirp_common.Memory() mem.number = number + if _mem.get_raw()[0] == "\xff": + mem.empty = True + return mem + mem.freq = int(_mem.rxfreq) * 10 + if int(_mem.rxfreq) == int(_mem.txfreq): + mem.duplex = "" + mem.offset = 0 + for char in _nam.name: if str(char) == "\xFF": char = " " # The OEM software may have 0xFF mid-name @@ -469,22 +477,28 @@ def _set_mem(self, number): def _set_nam(self, number): return self._memobj.names[number - 1] - def validate_memory(self, mem): - msgs = baofeng_common.BaofengCommonHT.validate_memory(self, mem) + def set_memory(self, mem): + _mem = self._set_mem(mem.number) + _nam = self._set_nam(mem.number) - if mem.freq != int(MURS_FREQS[mem.number - 1] * 1000000): - msgs.append(chirp_common.ValidationError( - 'Memory location cannot change frequency')) + if mem.empty: + _mem.set_raw("\xff" * 16) + _nam.set_raw("\xff" * 16) + return + _mem.set_raw("\x00" * 16) + + if mem.freq not in MURS_FREQS: + MURS_FREQ = MURS_FREQS[mem.number - 1] + mem.freq = MURS_FREQ + mem.duplex = '' + mem.offset = 0 if mem.mode == "FM" and (mem.number - 1) not in FM_MODE: - msgs.append(chirp_common.ValidationError( - 'Memory location only supports NFM')) + mem.mode = "NFM" - return msgs + _mem.rxfreq = mem.freq / 10 - def set_memory(self, mem): - _mem = self._set_mem(mem.number) - _nam = self._set_nam(mem.number) + _mem.txfreq = mem.freq / 10 _namelength = self.get_features().valid_name_length for i in range(_namelength):