[chirp_devel] [PATCH 00/35] final style fixes
This series contains the remaining changes for bringing the CHIRP source tree into compliance with pep8.
Zachary T Welch (35): Fix style issues in some drivers (#2355) Fix style issues in ft50_ll.py (#2355) Fix style issues in ft60.py (#2355) Fix style issues in ft7800.py (#2355) Fix style issues in ft90.py (#2355) Fix style issues in ftm350.py (#2355) Fix style issues in vx170.py (#2355) Fix style issues in vx2.py (#2355) Fix style issues in vx3.py (#2355) Fix style issues in vx5.py (#2355) Fix style issues in vx510.py (#2355) Fix style issues in vx6.py (#2355) Fix style issues in vx7.py (#2355) Fix style issues in vx8.py (#2355) Fix style issues in th9800.py (#2355) Fix style issues in th_uv3r.py (#2355) Fix style issues in th_uv3r25.py (#2355) Fix style issues in th_uvf8d.py (#2355) Fix style issues in tmv71*.py (#2355) Fix style issues in ic208.py (#2355) Fix style issues in ic2100.py (#2355) Fix style issues in ic2200.py (#2355) Fix style issues in ic2720.py (#2355) Fix style issues in ic2820.py (#2355) Fix style issues in ic9x.py (#2355) Fix style issues in ic9x_icf.py (#2355) Fix style issues in ic9x_icf_ll.py (#2355) Fix style issues in ic9x_ll.py (#2355) Fix style issues in icf.py (#2355) Fix style issues in icq7.py (#2355) Fix style issues in ict70.py (#2355) Fix style issues in ict8.py (#2355) Fix style issues in icw32.py (#2355) Fix style issues in icx8x.py (#2355) Fix style issues in icx8x_ll.py (#2355)
chirp/drivers/ft1802.py | 30 +- chirp/drivers/ft2800.py | 10 +- chirp/drivers/ft50.py | 5 +- chirp/drivers/ft50_ll.py | 101 ++-- chirp/drivers/ft60.py | 316 +++++++------ chirp/drivers/ft7800.py | 231 ++++++---- chirp/drivers/ft90.py | 561 ++++++++++++----------- chirp/drivers/ftm350.py | 39 +- chirp/drivers/ic208.py | 16 +- chirp/drivers/ic2100.py | 13 +- chirp/drivers/ic2200.py | 17 +- chirp/drivers/ic2720.py | 7 +- chirp/drivers/ic2820.py | 26 +- chirp/drivers/ic9x.py | 18 +- chirp/drivers/ic9x_icf.py | 3 + chirp/drivers/ic9x_icf_ll.py | 33 +- chirp/drivers/ic9x_ll.py | 61 ++- chirp/drivers/icf.py | 81 ++-- chirp/drivers/icq7.py | 62 +-- chirp/drivers/ict70.py | 9 +- chirp/drivers/ict8.py | 1 + chirp/drivers/icw32.py | 8 +- chirp/drivers/icx8x.py | 8 +- chirp/drivers/icx8x_ll.py | 125 +++-- chirp/drivers/th9800.py | 1038 ++++++++++++++++++++++-------------------- chirp/drivers/th_uv3r.py | 11 +- chirp/drivers/th_uv3r25.py | 7 +- chirp/drivers/th_uvf8d.py | 303 ++++++------ chirp/drivers/tmv71.py | 7 +- chirp/drivers/tmv71_ll.py | 97 ++-- chirp/drivers/vx170.py | 36 +- chirp/drivers/vx2.py | 460 ++++++++++--------- chirp/drivers/vx3.py | 459 +++++++++++-------- chirp/drivers/vx5.py | 18 +- chirp/drivers/vx510.py | 6 +- chirp/drivers/vx6.py | 53 +-- chirp/drivers/vx7.py | 48 +- chirp/drivers/vx8.py | 228 +++++----- tools/cpep8.blacklist | 38 -- 39 files changed, 2552 insertions(+), 2038 deletions(-)
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID 349ea8dee133e881f58aa9bb12a57ad66b33f118
Fix style issues in some drivers (#2355)
diff --git a/chirp/drivers/ft1802.py b/chirp/drivers/ft1802.py index a491907..952a23c 100644 --- a/chirp/drivers/ft1802.py +++ b/chirp/drivers/ft1802.py @@ -94,15 +94,15 @@ class FT1802Radio(yaesu_clone.YaesuCloneModeRadio): def get_prompts(cls): rp = chirp_common.RadioPrompts() rp.pre_download = _(dedent("""\ - 1. Turn radio off. - 2. Connect cable to mic jack. - 3. Press and hold in the [LOW(A/N)] key while turning the radio on. - 4. <b>After clicking OK</b>, press the [MHz(SET)] key to send image.""")) +1. Turn radio off. +2. Connect cable to mic jack. +3. Press and hold in the [LOW(A/N)] key while turning the radio on. +4. <b>After clicking OK</b>, press the [MHz(SET)] key to send image.""")) rp.pre_upload = _(dedent("""\ - 1. Turn radio off. - 2. Connect cable to mic jack. - 3. Press and hold in the [LOW(A/N)] key while turning the radio on. - 4. Press the [D/MR(MW)] key ("--WAIT--" will appear on the LCD).""")) +1. Turn radio off. +2. Connect cable to mic jack. +3. Press and hold in the [LOW(A/N)] key while turning the radio on. +4. Press the [D/MR(MW)] key ("--WAIT--" will appear on the LCD).""")) return rp
def get_features(self): @@ -113,8 +113,8 @@ class FT1802Radio(yaesu_clone.YaesuCloneModeRadio): rf.can_odd_split = True rf.has_ctone = False rf.has_tuning_step = True - rf.has_dtcs_polarity = False # in radio settings, not per memory - rf.has_bank = False # has banks, but not implemented + rf.has_dtcs_polarity = False # in radio settings, not per memory + rf.has_bank = False # has banks, but not implemented
rf.valid_tuning_steps = STEPS rf.valid_modes = MODES @@ -162,7 +162,8 @@ class FT1802Radio(yaesu_clone.YaesuCloneModeRadio): mem.freq = chirp_common.fix_rounded_step(int(_mem.freq) * 1000) mem.offset = chirp_common.fix_rounded_step(int(_mem.offset) * 1000) mem.duplex = DUPLEX[_mem.duplex] - mem.tuning_step = _mem.step_changed and STEPS[_mem.tune_step] or STEPS[0] + mem.tuning_step = _mem.step_changed and \ + STEPS[_mem.tune_step] or STEPS[0] if _mem.tmode < TMODES.index("Cross"): mem.tmode = TMODES[_mem.tmode] mem.cross_mode = CROSS_MODES[0] @@ -196,7 +197,7 @@ class FT1802Radio(yaesu_clone.YaesuCloneModeRadio): _flag = self._memobj.flags[mem.number/2]
nibble = (mem.number % 2) and "odd" or "even" - + valid = _flag["%s_valid" % nibble] visible = _flag["%s_visible" % nibble]
@@ -228,7 +229,8 @@ class FT1802Radio(yaesu_clone.YaesuCloneModeRadio): if mem.tmode != "Cross": _mem.tmode = TMODES.index(mem.tmode) else: - _mem.tmode = TMODES.index("Cross") + CROSS_MODES.index(mem.cross_mode) + _mem.tmode = TMODES.index("Cross") + \ + CROSS_MODES.index(mem.cross_mode) _mem.tone = chirp_common.TONES.index(mem.rtone) _mem.dtcs = chirp_common.DTCS_CODES.index(mem.dtcs)
@@ -239,7 +241,7 @@ class FT1802Radio(yaesu_clone.YaesuCloneModeRadio): except IndexError: raise Exception("Character `%s' not supported") if _mem.name[0] != 0xFF: - _mem.name[0] += 0x80 # show name instead of frequency + _mem.name[0] += 0x80 # show name instead of frequency
_mem.narrow = MODES.index(mem.mode) _mem.power = 3 if mem.power is None else POWER_LEVELS.index(mem.power) diff --git a/chirp/drivers/ft2800.py b/chirp/drivers/ft2800.py index d091d7b..52efe27 100644 --- a/chirp/drivers/ft2800.py +++ b/chirp/drivers/ft2800.py @@ -23,6 +23,8 @@ from yaesu_clone import YaesuCloneModeRadio LOG = logging.getLogger(__name__)
CHUNK_SIZE = 16 + + def _send(s, data): for i in range(0, len(data), CHUNK_SIZE): chunk = data[i:i+CHUNK_SIZE] @@ -35,6 +37,7 @@ IDBLOCK = "\x0c\x01\x41\x33\x35\x02\x00\xb8" TRAILER = "\x0c\x02\x41\x33\x35\x00\x00\xb7" ACK = "\x0C\x06\x00"
+ def _download(radio): data = "" for _i in range(0, 10): @@ -60,7 +63,7 @@ def _download(radio): elif len(chunk) != 38: print "Should fail?" break - #raise Exception("Failed to get full data block") + # raise Exception("Failed to get full data block") else: cs = 0 for byte in chunk[:-1]: @@ -82,6 +85,7 @@ def _download(radio):
return memmap.MemoryMap(data)
+ def _upload(radio): for _i in range(0, 10): data = radio.pipe.read(256) @@ -157,6 +161,7 @@ POWER_LEVELS = [chirp_common.PowerLevel("Hi", watts=65), ] CHARSET = chirp_common.CHARSET_UPPER_NUMERIC + "()+-=*/???|_"
+ @directory.register class FT2800Radio(YaesuCloneModeRadio): """Yaesu FT-2800""" @@ -176,7 +181,8 @@ class FT2800Radio(YaesuCloneModeRadio): rf.has_dtcs_polarity = False rf.has_bank = False
- rf.valid_tuning_steps = [5.0, 10.0, 12.5, 15.0, 20.0, 25.0, 50.0, 100.0] + rf.valid_tuning_steps = [5.0, 10.0, 12.5, 15.0, + 20.0, 25.0, 50.0, 100.0] rf.valid_modes = MODES rf.valid_tmodes = TMODES rf.valid_bands = [(137000000, 174000000)] diff --git a/chirp/drivers/ft50.py b/chirp/drivers/ft50.py index 2f726ec..6a9cf21 100644 --- a/chirp/drivers/ft50.py +++ b/chirp/drivers/ft50.py @@ -16,8 +16,9 @@ from chirp.drivers import yaesu_clone, ft50_ll from chirp import chirp_common, directory
+ # Not working, don't register -#@directory.register +# @directory.register class FT50Radio(yaesu_clone.YaesuCloneModeRadio): BAUD_RATE = 9600 VENDOR = "Yaesu" @@ -32,7 +33,7 @@ class FT50Radio(yaesu_clone.YaesuCloneModeRadio): rf.memory_bounds = (1, 100) rf.has_dtcs_polarity = False rf.has_bank = False - rf.valid_modes = [ "FM", "WFM", "AM" ] + rf.valid_modes = ["FM", "WFM", "AM"] return rf
def _update_checksum(self): diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index fa6ebdb..81065eb 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -1,9 +1,6 @@ # cpep8.blacklist: The list of files that do not meet PEP8 standards. # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. -./chirp/drivers/ft1802.py -./chirp/drivers/ft2800.py -./chirp/drivers/ft50.py ./chirp/drivers/ft50_ll.py ./chirp/drivers/ft60.py ./chirp/drivers/ft7800.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID 3ea42ad77e56174f669e7f4ea0502435fec77e04
Fix style issues in ft50_ll.py (#2355)
diff --git a/chirp/drivers/ft50_ll.py b/chirp/drivers/ft50_ll.py index c38b4f9..7d93d62 100644 --- a/chirp/drivers/ft50_ll.py +++ b/chirp/drivers/ft50_ll.py @@ -22,34 +22,36 @@ MEM_LOC_BASE = 0x00AB MEM_LOC_SIZE = 16
POS_DUPLEX = 1 -POS_TMODE = 2 -POS_TONE = 2 -POS_DTCS = 3 -POS_MODE = 4 -POS_FREQ = 5 +POS_TMODE = 2 +POS_TONE = 2 +POS_DTCS = 3 +POS_MODE = 4 +POS_FREQ = 5 POS_OFFSET = 9 -POS_NAME = 11 +POS_NAME = 11
-POS_USED = 0x079C +POS_USED = 0x079C
CHARSET = [str(x) for x in range(0, 10)] + \ [chr(x) for x in range(ord("A"), ord("Z")+1)] + \ list(" ()+--*/???|0123456789")
+ def send(s, data): s.write(data) r = s.read(len(data)) if len(r) != len(data): raise errors.RadioError("Failed to read echo")
+ def read_exact(s, count): data = "" i = 0 while len(data) < count: if i == 3: print util.hexprint(data) - raise errors.RadioError("Failed to read %i (%i) from radio" % (count, - len(data))) + raise errors.RadioError("Failed to read %i (%i) from radio" % + (count, len(data))) elif i > 0: print "Retry %i" % i data += s.read(count - len(data)) @@ -57,6 +59,7 @@ def read_exact(s, count):
return data
+ def download(radio): data = ""
@@ -69,7 +72,7 @@ def download(radio): else: step = block for i in range(0, block, step): - #data += read_exact(radio.pipe, step) + # data += read_exact(radio.pipe, step) chunk = radio.pipe.read(step*2) print "Length of chunk: %i" % len(chunk) data += chunk @@ -92,102 +95,117 @@ def download(radio):
return memmap.MemoryMap(data)
+ def get_mem_offset(number): return MEM_LOC_BASE + (number * MEM_LOC_SIZE)
+ def get_raw_memory(map, number): pos = get_mem_offset(number) return memmap.MemoryMap(map[pos:pos+MEM_LOC_SIZE])
+ def get_freq(mmap): khz = (int("%02x" % (ord(mmap[POS_FREQ])), 10) * 100000) + \ (int("%02x" % ord(mmap[POS_FREQ+1]), 10) * 1000) + \ (int("%02x" % ord(mmap[POS_FREQ+2]), 10) * 10) return khz / 10000.0
+ def set_freq(mmap, freq): val = util.bcd_encode(int(freq * 1000), width=6)[:3] mmap[POS_FREQ] = val
+ def get_tmode(mmap): val = ord(mmap[POS_TMODE]) & 0xC0
tmodemap = { - 0x00 : "", - 0x40 : "Tone", - 0x80 : "TSQL", - 0xC0 : "DTCS", + 0x00: "", + 0x40: "Tone", + 0x80: "TSQL", + 0xC0: "DTCS", } - + return tmodemap[val]
+ def set_tmode(mmap, tmode): val = ord(mmap[POS_TMODE]) & 0x3F
tmodemap = { - "" : 0x00, - "Tone" : 0x40, - "TSQL" : 0x80, - "DTCS" : 0xC0, + "": 0x00, + "Tone": 0x40, + "TSQL": 0x80, + "DTCS": 0xC0, }
val |= tmodemap[tmode]
mmap[POS_TMODE] = val
+ def get_tone(mmap): val = ord(mmap[POS_TONE]) & 0x3F
return chirp_common.TONES[val]
+ def set_tone(mmap, tone): val = ord(mmap[POS_TONE]) & 0xC0
mmap[POS_TONE] = val | chirp_common.TONES.index(tone)
+ def get_dtcs(mmap): val = ord(mmap[POS_DTCS])
return chirp_common.DTCS_CODES[val]
+ def set_dtcs(mmap, dtcs): mmap[POS_DTCS] = chirp_common.DTCS_CODES.index(dtcs)
+ def get_offset(mmap): khz = (int("%02x" % ord(mmap[POS_OFFSET]), 10) * 10) + \ (int("%02x" % (ord(mmap[POS_OFFSET+1]) >> 4), 10) * 1)
return khz / 1000.0
+ def set_offset(mmap, offset): val = util.bcd_encode(int(offset * 1000), width=4)[:3] - print "Offfset:\n%s"% util.hexprint(val) + print "Offfset:\n%s" % util.hexprint(val) mmap[POS_OFFSET] = val
+ def get_duplex(mmap): val = ord(mmap[POS_DUPLEX]) & 0x03
dupmap = { - 0x00 : "", - 0x01 : "-", - 0x02 : "+", - 0x03 : "split", + 0x00: "", + 0x01: "-", + 0x02: "+", + 0x03: "split", }
return dupmap[val]
+ def set_duplex(mmap, duplex): val = ord(mmap[POS_DUPLEX]) & 0xFC
dupmap = { - "" : 0x00, - "-" : 0x01, - "+" : 0x02, - "split" : 0x03, + "": 0x00, + "-": 0x01, + "+": 0x02, + "split": 0x03, } - + mmap[POS_DUPLEX] = val | dupmap[duplex]
+ def get_name(mmap): name = "" for x in mmap[POS_NAME:POS_NAME+4]: @@ -196,44 +214,50 @@ def get_name(mmap): name += CHARSET[ord(x)] return name
+ def set_name(mmap, name): val = "" for i in name[:4].ljust(4): val += chr(CHARSET.index(i)) mmap[POS_NAME] = val
+ def get_mode(mmap): val = ord(mmap[POS_MODE]) & 0x03
modemap = { - 0x00 : "FM", - 0x01 : "AM", - 0x02 : "WFM", - 0x03 : "WFM", + 0x00: "FM", + 0x01: "AM", + 0x02: "WFM", + 0x03: "WFM", }
return modemap[val]
+ def set_mode(mmap, mode): val = ord(mmap[POS_MODE]) & 0xCF
modemap = { - "FM" : 0x00, - "AM" : 0x01, - "WFM" : 0x02, + "FM": 0x00, + "AM": 0x01, + "WFM": 0x02, }
mmap[POS_MODE] = val | modemap[mode]
+ def get_used(mmap, number): return ord(mmap[POS_USED + number]) & 0x01
+ def set_used(mmap, number, used): val = ord(mmap[POS_USED + number]) & 0xFC if used: val |= 0x03 mmap[POS_USED + number] = val - + + def get_memory(map, number): index = number - 1 mmap = get_raw_memory(map, index) @@ -255,6 +279,7 @@ def get_memory(map, number):
return mem
+ def set_memory(_map, mem): index = mem.number - 1 mmap = get_raw_memory(_map, index) @@ -276,10 +301,12 @@ def set_memory(_map, mem):
return _map
+ def erase_memory(map, number): set_used(map, number-1, False) return map
+ def update_checksum(map): cs = 0 for i in range(0, 3722): diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 81065eb..c584806 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -1,7 +1,6 @@ # cpep8.blacklist: The list of files that do not meet PEP8 standards. # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. -./chirp/drivers/ft50_ll.py ./chirp/drivers/ft60.py ./chirp/drivers/ft7800.py ./chirp/drivers/ft90.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID b294ec43a27202e1ac0f68cc7c071559ac363159
Fix style issues in ft60.py (#2355)
diff --git a/chirp/drivers/ft60.py b/chirp/drivers/ft60.py index 5c1edba..1dc11d5 100644 --- a/chirp/drivers/ft60.py +++ b/chirp/drivers/ft60.py @@ -13,7 +13,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-import time, os, logging +import time +import os +import logging + from chirp.drivers import yaesu_clone from chirp import chirp_common, memmap, bitwise, directory, errors from chirp.settings import RadioSetting, RadioSettingGroup, \ @@ -26,12 +29,14 @@ LOG = logging.getLogger(__name__)
ACK = "\x06"
+ def _send(pipe, data): pipe.write(data) echo = pipe.read(len(data)) if echo != data: raise errors.RadioError("Error reading echo (Bad cable?)")
+ def _download(radio): data = "" for i in range(0, 10): @@ -56,7 +61,8 @@ def _download(radio): if len(chunk) == 1 and i == 447: break elif len(chunk) != 64: - raise Exception("Reading block %i was short (%i)" % (i, len(chunk))) + raise Exception("Reading block %i was short (%i)" % + (i, len(chunk))) if radio.status_fn: status = chirp_common.Status() status.cur = i * 64 @@ -66,6 +72,7 @@ def _download(radio):
return memmap.MemoryMap(data)
+ def _upload(radio): _send(radio.pipe, radio.get_mmap()[0:8])
@@ -85,7 +92,8 @@ def _upload(radio): status.cur = offset+64 status.max = radio.get_memsize() status.msg = "Cloning to radio" - radio.status_fn(status) + radio.status_fn(status) +
def _decode_freq(freqraw): freq = int(freqraw) * 10000 @@ -101,6 +109,7 @@ def _decode_freq(freqraw):
return freq
+ def _encode_freq(freq): freqraw = freq / 10000 flags = 0x00 @@ -110,6 +119,7 @@ def _encode_freq(freq): flags += 0x40 return freqraw, flags
+ def _decode_name(mem): name = "" for i in mem: @@ -126,7 +136,7 @@ def _encode_name(mem): name = [None]*6 for i in range(0, 6): try: - name[i] = CHARSET.index(mem[i]) + name[i] = CHARSET.index(mem[i]) except IndexError: name[i] = CHARSET.index(" ")
@@ -202,7 +212,7 @@ struct { bclo:1, x3E_3:5; } settings; - + #seekto 0x09E; ul16 mbs;
@@ -214,7 +224,7 @@ struct mem { duplex:4; bbcd freq[3]; u8 unknown2:1, - step:3, + step:3, unknown2_1:1, tmode:3; bbcd tx_freq[3]; @@ -270,7 +280,7 @@ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=5.0), STEPS = [5.0, 10.0, 12.5, 15.0, 20.0, 25.0, 50.0, 100.0] SKIPS = ["", "S", "P"] CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ [?]^__|`?$%&-()*+,-,/|;/=>?@" -SPECIALS = ["%s%d" % (c,i+1) for i in range(0, 50) for c in ('L', 'U') ] +SPECIALS = ["%s%d" % (c, i + 1) for i in range(0, 50) for c in ('L', 'U')]
class FT60BankModel(chirp_common.BankModel): @@ -293,8 +303,9 @@ class FT60BankModel(chirp_common.BankModel): def remove_memory_from_mapping(self, memory, bank): number = (memory.number - 1) / 8 mask = 1 << ((memory.number - 1) & 7) - if self._radio._memobj.banks[bank.index].memory[number].get_bits(mask) != mask: - raise Exception("Memory %i is not in bank %s." % \ + m = self._radio._memobj.banks[bank.index].memory[number] + if m.get_bits(mask) != mask: + raise Exception("Memory %i is not in bank %s." % (memory.number, bank)) self._radio._memobj.banks[bank.index].memory[number].clr_bits(mask)
@@ -303,7 +314,8 @@ class FT60BankModel(chirp_common.BankModel): for i in range(*self._radio.get_features().memory_bounds): number = (i - 1) / 8 mask = 1 << ((i - 1) & 7) - if self._radio._memobj.banks[bank.index].memory[number].get_bits(mask) == mask: + m = self._radio._memobj.banks[bank.index].memory[number] + if m.get_bits(mask) == mask: memories.append(self._radio.get_memory(i)) return memories
@@ -312,10 +324,12 @@ class FT60BankModel(chirp_common.BankModel): for bank in self.get_mappings(): number = (memory.number - 1) / 8 mask = 1 << ((memory.number - 1) & 7) - if self._radio._memobj.banks[bank.index].memory[number].get_bits(mask) == mask: + m = self._radio._memobj.banks[bank.index].memory[number] + if m.get_bits(mask) == mask: banks.append(bank) return banks
+ @directory.register class FT60Radio(yaesu_clone.YaesuCloneModeRadio): """Yaesu FT-60""" @@ -330,23 +344,23 @@ class FT60Radio(yaesu_clone.YaesuCloneModeRadio): def get_prompts(cls): rp = chirp_common.RadioPrompts() rp.pre_download = _(dedent("""\ - 1. Turn radio off. - 2. Connect cable to MIC/SP jack. - 3. Press and hold in the [MONI] switch while turning the - radio on. - 4. Rotate the DIAL job to select "F8 CLONE". - 5. Press the [F/W] key momentarily. - 6. <b>After clicking OK</b>, press the [PTT] switch to send image.""")) +1. Turn radio off. +2. Connect cable to MIC/SP jack. +3. Press and hold in the [MONI] switch while turning the + radio on. +4. Rotate the DIAL job to select "F8 CLONE". +5. Press the [F/W] key momentarily. +6. <b>After clicking OK</b>, press the [PTT] switch to send image.""")) rp.pre_upload = _(dedent("""\ - 1. Turn radio off. - 2. Connect cable to MIC/SP jack. - 3. Press and hold in the [MONI] switch while turning the - radio on. - 4. Rotate the DIAL job to select "F8 CLONE". - 5. Press the [F/W] key momentarily. - 6. Press the [MONI] switch ("--RX--" will appear on the LCD).""")) +1. Turn radio off. +2. Connect cable to MIC/SP jack. +3. Press and hold in the [MONI] switch while turning the + radio on. +4. Rotate the DIAL job to select "F8 CLONE". +5. Press the [F/W] key momentarily. +6. Press the [MONI] switch ("--RX--" will appear on the LCD).""")) return rp - + def get_features(self): rf = chirp_common.RadioFeatures() rf.memory_bounds = (1, 1000) @@ -372,7 +386,7 @@ class FT60Radio(yaesu_clone.YaesuCloneModeRadio): return FT60BankModel(self)
def _checksums(self): - return [ yaesu_clone.YaesuChecksum(0x0000, 0x6FC7) ] + return [yaesu_clone.YaesuChecksum(0x0000, 0x6FC7)]
def sync_in(self): try: @@ -410,199 +424,219 @@ class FT60Radio(yaesu_clone.YaesuCloneModeRadio): misc = RadioSettingGroup("misc", "Miscellaneous Settings") mbls = RadioSettingGroup("banks", "Memory Bank Link Scan")
- setmode = RadioSettings(repeater, ctcss, arts, scan, power, wires, eai, switch, misc, mbls) + setmode = RadioSettings(repeater, ctcss, arts, scan, power, + wires, eai, switch, misc, mbls)
# APO - opts = [ "OFF" ] + [ "%0.1f" % (x * 0.5) for x in range(1, 24+1) ] - misc.append( RadioSetting("apo", "Automatic Power Off", - RadioSettingValueList(opts, opts[_settings.apo]))) + opts = ["OFF"] + ["%0.1f" % (x * 0.5) for x in range(1, 24+1)] + misc.append( + RadioSetting( + "apo", "Automatic Power Off", + RadioSettingValueList(opts, opts[_settings.apo])))
# AR.BEP - opts = [ "OFF" ] + [ "INRANG" ] + [ "ALWAYS" ] - arts.append( RadioSetting("ar_bep", "ARTS Beep", - RadioSettingValueList(opts, opts[_settings.ar_bep]))) + opts = ["OFF", "INRANG", "ALWAYS"] + arts.append( + RadioSetting( + "ar_bep", "ARTS Beep", + RadioSettingValueList(opts, opts[_settings.ar_bep])))
# AR.INT - opts = ["25 SEC"] + [ "15 SEC" ] - arts.append( RadioSetting("ar_int", "ARTS Polling Interval", - RadioSettingValueList(opts, opts[_settings.ar_int]))) + opts = ["25 SEC", "15 SEC"] + arts.append( + RadioSetting( + "ar_int", "ARTS Polling Interval", + RadioSettingValueList(opts, opts[_settings.ar_int])))
# ARS - opts = [ "OFF" ] + [ "ON" ] - repeater.append( RadioSetting("ars", "Automatic Repeater Shift", - RadioSettingValueList(opts, opts[_settings.ars]))) + opts = ["OFF", "ON"] + repeater.append( + RadioSetting( + "ars", "Automatic Repeater Shift", + RadioSettingValueList(opts, opts[_settings.ars])))
# BCLO - opts = [ "OFF" ] + [ "ON" ] - misc.append( RadioSetting("bclo", "Bush Channel Lock-Out", - RadioSettingValueList(opts, opts[_settings.bclo]))) + opts = ["OFF", "ON"] + misc.append(RadioSetting( + "bclo", "Bush Channel Lock-Out", + RadioSettingValueList(opts, opts[_settings.bclo])))
# BEEP - opts = [ "OFF" ] + [ "KEY" ] + [ "KEY+SC" ] - rs = RadioSetting("beep_key", "Enable the Beeper", - RadioSettingValueList(opts, opts[_settings.beep_key + _settings.beep_sc])) + opts = ["OFF", "KEY", "KEY+SC"] + rs = RadioSetting( + "beep_key", "Enable the Beeper", + RadioSettingValueList( + opts, opts[_settings.beep_key + _settings.beep_sc])) + def apply_beep(s, obj): - setattr(obj, "beep_key", (int(s.value) & 1) or ((int(s.value) >> 1) & 1)) + setattr(obj, "beep_key", + (int(s.value) & 1) or ((int(s.value) >> 1) & 1)) setattr(obj, "beep_sc", (int(s.value) >> 1) & 1) - rs.set_apply_callback(apply_beep, self._memobj.settings); + rs.set_apply_callback(apply_beep, self._memobj.settings) switch.append(rs)
# BELL - opts = [ "OFF" ] + [ "1T" ] + [ "3T" ] + [ "5T" ] + [ "8T" ] + [ "CONT" ] - ctcss.append( RadioSetting("bell", "Bell Repetitions", - RadioSettingValueList(opts, opts[_settings.bell]))) + opts = ["OFF", "1T", "3T", "5T", "8T", "CONT"] + ctcss.append(RadioSetting("bell", "Bell Repetitions", + RadioSettingValueList(opts, opts[_settings.bell])))
# BSY.LED - opts = [ "ON" ] + [ "OFF" ] - misc.append( RadioSetting("bsy_led", "Busy LED", - RadioSettingValueList(opts, opts[_settings.bsy_led]))) + opts = ["ON", "OFF"] + misc.append(RadioSetting("bsy_led", "Busy LED", + RadioSettingValueList(opts, opts[_settings.bsy_led])))
# DCS.NR - opts = [ "TR/X N" ] + [ "RX R" ] + [ "TX R" ] + [ "T/RX R" ] - ctcss.append( RadioSetting("dcs_nr", ""Inverted" DCS Code Decoding", - RadioSettingValueList(opts, opts[_settings.dcs_nr]))) + opts = ["TR/X N", "RX R", "TX R", "T/RX R"] + ctcss.append(RadioSetting("dcs_nr", ""Inverted" DCS Code Decoding", + RadioSettingValueList(opts, opts[_settings.dcs_nr])))
# DT.DLY - opts = [ "50 MS" ] + [ "100 MS" ] + [ "250 MS" ] + [ "450 MS" ] + \ - [ "750 MS" ]+ [ "1000 MS" ] - ctcss.append( RadioSetting("dt_dly", "DTMF Autodialer Delay Time", - RadioSettingValueList(opts, opts[_settings.dt_dly]))) + opts = ["50 MS", "100 MS", "250 MS", "450 MS", "750 MS", "1000 MS"] + ctcss.append(RadioSetting("dt_dly", "DTMF Autodialer Delay Time", + RadioSettingValueList(opts, opts[_settings.dt_dly])))
# DT.SPD - opts = [ "50 MS" ] + [ "100 MS" ] - ctcss.append( RadioSetting("dt_spd", "DTMF Autodialer Sending Speed", - RadioSettingValueList(opts, opts[_settings.dt_spd]))) + opts = ["50 MS", "100 MS"] + ctcss.append(RadioSetting("dt_spd", "DTMF Autodialer Sending Speed", + RadioSettingValueList(opts, opts[_settings.dt_spd])))
# EDG.BEP - opts = [ "OFF" ] + [ "ON" ] - misc.append( RadioSetting("edg_bep", "Band Edge Beeper", - RadioSettingValueList(opts, opts[_settings.edg_bep]))) + opts = ["OFF", "ON"] + misc.append(RadioSetting("edg_bep", "Band Edge Beeper", + RadioSettingValueList(opts, opts[_settings.edg_bep])))
# I.NET - opts = [ "OFF" ] + [ "COD" ]+ [ "MEM" ] + opts = ["OFF", "COD", "MEM"] rs = RadioSetting("inet", "Internet Link Connection", - RadioSettingValueList(opts, opts[_settings.inet - 1])) + RadioSettingValueList( + opts, opts[_settings.inet - 1])) + def apply_inet(s, obj): setattr(obj, s.get_name(), int(s.value) + 1) - rs.set_apply_callback(apply_inet, self._memobj.settings); + rs.set_apply_callback(apply_inet, self._memobj.settings) wires.append(rs)
# INT.CD - opts = [ "CODE 0" ] + [ "CODE 1" ] + [ "CODE 2" ] + [ "CODE 3" ] + [ "CODE 4" ] + \ - [ "CODE 5" ] + [ "CODE 6" ] + [ "CODE 7" ] + [ "CODE 8" ] + [ "CODE 9" ] + \ - [ "CODE A" ] + [ "CODE B" ] + [ "CODE C" ] + [ "CODE D" ] + [ "CODE E" ] + [ "CODE F" ] - wires.append( RadioSetting("int_cd", "Access Number for WiRES(TM)", - RadioSettingValueList(opts, opts[_settings.int_cd]))) + opts = ["CODE 0", "CODE 1", "CODE 2", "CODE 3", "CODE 4", + "CODE 5", "CODE 6", "CODE 7", "CODE 8", "CODE 9", + "CODE A", "CODE B", "CODE C", "CODE D", "CODE E", "CODE F"] + wires.append(RadioSetting("int_cd", "Access Number for WiRES(TM)", + RadioSettingValueList(opts, opts[_settings.int_cd])))
# INT.MR - opts = [ "d1" ] + [ "d2" ] + [ "d3" ] + [ "d4" ] + [ "d5" ] + \ - [ "d6" ] + [ "d7" ] + [ "d8" ] + [ "d9" ] - wires.append( RadioSetting("int_mr", "Access Number (DTMF) for Non-WiRES(TM)", - RadioSettingValueList(opts, opts[_settings.int_mr]))) + opts = ["d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9"] + wires.append(RadioSetting( + "int_mr", "Access Number (DTMF) for Non-WiRES(TM)", + RadioSettingValueList(opts, opts[_settings.int_mr])))
# LAMP - opts = [ "KEY" ] + [ "5SEC" ] + [ "TOGGLE" ] - switch.append( RadioSetting("lamp", "Lamp Mode", - RadioSettingValueList(opts, opts[_settings.lamp]))) + opts = ["KEY", "5SEC", "TOGGLE"] + switch.append(RadioSetting("lamp", "Lamp Mode", + RadioSettingValueList(opts, opts[_settings.lamp])))
# LOCK - opts = [ "LK KEY" ] + [ "LKDIAL" ] + [ "LK K+D" ] + [ "LK PTT" ] + [ "LP P+K" ] + \ - [ "LK P+D" ] + [ "LK ALL" ] + opts = ["LK KEY", "LKDIAL", "LK K+D", "LK PTT", + "LP P+K", "LK P+D", "LK ALL"] rs = RadioSetting("lock", "Control Locking", - RadioSettingValueList(opts, opts[_settings.lock - 1])) + RadioSettingValueList( + opts, opts[_settings.lock - 1])) + def apply_lock(s, obj): setattr(obj, s.get_name(), int(s.value) + 1) - rs.set_apply_callback(apply_lock, self._memobj.settings); + rs.set_apply_callback(apply_lock, self._memobj.settings) switch.append(rs)
# M/T-CL - opts = [ "MONI" ] + [ "T-CALL" ] - switch.append( RadioSetting("mt_cl", "MONI Switch Function", - RadioSettingValueList(opts, opts[_settings.mt_cl]))) + opts = ["MONI", "T-CALL"] + switch.append(RadioSetting("mt_cl", "MONI Switch Function", + RadioSettingValueList(opts, opts[_settings.mt_cl])))
# PAG.ABK - opts = [ "OFF" ] + [ "ON" ] - eai.append( RadioSetting("pag_abk", "Paging Answer Back", - RadioSettingValueList(opts, opts[_settings.pag_abk]))) + opts = ["OFF", "ON"] + eai.append(RadioSetting("pag_abk", "Paging Answer Back", + RadioSettingValueList(opts, opts[_settings.pag_abk])))
# RESUME - opts = [ "TIME" ] + [ "HOLD" ] + [ "BUSY" ] - scan.append( RadioSetting("resume", "Scan Resume Mode", - RadioSettingValueList(opts, opts[_settings.resume]))) + opts = ["TIME", "HOLD", "BUSY"] + scan.append(RadioSetting("resume", "Scan Resume Mode", + RadioSettingValueList(opts, opts[_settings.resume])))
# REV/HM - opts = [ "REV" ] + [ "HOME" ] - switch.append( RadioSetting("rev_hm", "HM/RV Key Function", - RadioSettingValueList(opts, opts[_settings.rev_hm]))) + opts = ["REV", "HOME"] + switch.append(RadioSetting("rev_hm", "HM/RV Key Function", + RadioSettingValueList(opts, opts[_settings.rev_hm])))
# RF.SQL - opts = [ "OFF" ] + [ "S-1" ] + [ "S-2" ] + [ "S-3" ] + [ "S-4" ] + \ - [ "S-5" ] + [ "S-6" ] + [ "S-8" ] + [ "S-FULL" ] - misc.append( RadioSetting("rf_sql", "RF Squelch Threshold", - RadioSettingValueList(opts, opts[_settings.rf_sql]))) + opts = ["OFF", "S-1", "S-2", "S-3", "S-4", "S-5", "S-6", + "S-7", "S-8", "S-FULL"] + misc.append(RadioSetting("rf_sql", "RF Squelch Threshold", + RadioSettingValueList(opts, opts[_settings.rf_sql])))
# PRI.RVT - opts = [ "OFF" ] + [ "ON" ] - scan.append( RadioSetting("pri_rvt", "Priority Revert", - RadioSettingValueList(opts, opts[_settings.pri_rvt]))) + opts = ["OFF", "ON"] + scan.append(RadioSetting("pri_rvt", "Priority Revert", + RadioSettingValueList(opts, opts[_settings.pri_rvt])))
# RXSAVE - opts = [ "OFF" ] + [ "200 MS" ] + [ "300 MS" ] + [ "500 MS" ] + [ "1 S" ] + [ "2 S" ] - power.append( RadioSetting("rxsave", "Receive Mode Batery Savery Interval", - RadioSettingValueList(opts, opts[_settings.rxsave]))) + opts = ["OFF", "200 MS", "300 MS", "500 MS", "1 S", "2 S"] + power.append(RadioSetting( + "rxsave", "Receive Mode Batery Savery Interval", + RadioSettingValueList(opts, opts[_settings.rxsave])))
# S.SRCH - opts = [ "SINGLE" ] + [ "CONT" ] - misc.append( RadioSetting("ssrch", "Smart Search Sweep Mode", - RadioSettingValueList(opts, opts[_settings.ssrch]))) + opts = ["SINGLE", "CONT"] + misc.append(RadioSetting("ssrch", "Smart Search Sweep Mode", + RadioSettingValueList(opts, opts[_settings.ssrch])))
# SCN.MD - opts = [ "MEM" ] + [ "ONLY" ] - scan.append( RadioSetting("scn_md", "Memory Scan Channel Selection Mode", - RadioSettingValueList(opts, opts[_settings.scn_md]))) + opts = ["MEM", "ONLY"] + scan.append(RadioSetting( + "scn_md", "Memory Scan Channel Selection Mode", + RadioSettingValueList(opts, opts[_settings.scn_md])))
# SCN.LMP - opts = [ "OFF" ] + [ "ON" ] - scan.append( RadioSetting("scn_lmp", "Scan Lamp", - RadioSettingValueList(opts, opts[_settings.scn_lmp]))) + opts = ["OFF", "ON"] + scan.append(RadioSetting("scn_lmp", "Scan Lamp", + RadioSettingValueList(opts, opts[_settings.scn_lmp])))
# TOT - opts = [ "OFF" ] + [ "%dMIN" % (x) for x in range(1, 30+1) ] - misc.append( RadioSetting("tot", "Timeout Timer", - RadioSettingValueList(opts, opts[_settings.tot]))) + opts = ["OFF"] + ["%dMIN" % (x) for x in range(1, 30+1)] + misc.append(RadioSetting("tot", "Timeout Timer", + RadioSettingValueList(opts, opts[_settings.tot])))
# TX.LED - opts = [ "ON" ] + [ "OFF" ] - misc.append( RadioSetting("tx_led", "TX LED", - RadioSettingValueList(opts, opts[_settings.tx_led]))) + opts = ["ON", "OFF"] + misc.append(RadioSetting("tx_led", "TX LED", + RadioSettingValueList(opts, opts[_settings.tx_led])))
# TXSAVE - opts = [ "OFF" ] + [ "ON" ] - power.append( RadioSetting("txsave", "Transmitter Battery Saver", - RadioSettingValueList(opts, opts[_settings.txsave]))) + opts = ["OFF", "ON"] + power.append(RadioSetting("txsave", "Transmitter Battery Saver", + RadioSettingValueList(opts, opts[_settings.txsave])))
# VFO.BND - opts = [ "BAND" ] + [ "ALL" ] - misc.append( RadioSetting("vfo_bnd", "VFO Band Edge Limiting", - RadioSettingValueList(opts, opts[_settings.vfo_bnd]))) + opts = ["BAND", "ALL"] + misc.append(RadioSetting("vfo_bnd", "VFO Band Edge Limiting", + RadioSettingValueList(opts, opts[_settings.vfo_bnd])))
# WX.ALT - opts = [ "OFF" ] + [ "ON" ] - scan.append( RadioSetting("wx_alt", "Weather Alert Scan", - RadioSettingValueList(opts, opts[_settings.wx_alt]))) + opts = ["OFF", "ON"] + scan.append(RadioSetting("wx_alt", "Weather Alert Scan", + RadioSettingValueList(opts, opts[_settings.wx_alt])))
# MBS for i in range(0, 10): - opts = [ "OFF" ] + [ "ON" ] + opts = ["OFF", "ON"] mbs = (self._memobj.mbs >> i) & 1 rs = RadioSetting("mbs%i" % i, "Bank %s Scan" % (i + 1), - RadioSettingValueList(opts, opts[mbs])) + RadioSettingValueList(opts, opts[mbs])) + def apply_mbs(s, index): if int(s.value): self._memobj.mbs |= (1 << index) else: - self._memobj.mbs &= ~(1 << index); - rs.set_apply_callback(apply_mbs, i); + self._memobj.mbs &= ~(1 << index) + rs.set_apply_callback(apply_mbs, i) mbls.append(rs)
return setmode @@ -638,7 +672,7 @@ class FT60Radio(yaesu_clone.YaesuCloneModeRadio): repr(self._memobj.names[number - 1])
def get_memory(self, number): - + mem = chirp_common.Memory()
if isinstance(number, str): @@ -677,11 +711,11 @@ class FT60Radio(yaesu_clone.YaesuCloneModeRadio): mem.mode = _mem.isam and "AM" or _mem.isnarrow and "NFM" or "FM" mem.tuning_step = STEPS[_mem.step]
- if not _skp is None: + if _skp is not None: skip = _skp["skip%i" % ((mem.number - 1) % 4)] mem.skip = SKIPS[skip]
- if not _nam is None: + if _nam is not None: if _nam.use_name and _nam.valid: mem.name = _decode_name(_nam.name).rstrip()
@@ -725,10 +759,10 @@ class FT60Radio(yaesu_clone.YaesuCloneModeRadio): _mem.isam = mem.mode == "AM" _mem.step = STEPS.index(mem.tuning_step)
- if not _skp is None: + if _skp is not None: _skp["skip%i" % ((mem.number - 1) % 4)] = SKIPS.index(mem.skip)
- if not _nam is None: + if _nam is not None: _nam.name = _encode_name(mem.name) _nam.use_name = mem.name.strip() and True or False _nam.valid = _nam.use_name diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index c584806..cba6d00 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -1,7 +1,6 @@ # cpep8.blacklist: The list of files that do not meet PEP8 standards. # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. -./chirp/drivers/ft60.py ./chirp/drivers/ft7800.py ./chirp/drivers/ft90.py ./chirp/drivers/ftm350.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID e7a821564ec8ecd2e7819d562a9ac351f613d45f
Fix style issues in ft7800.py (#2355)
diff --git a/chirp/drivers/ft7800.py b/chirp/drivers/ft7800.py index 8bd3303..3e21d57 100644 --- a/chirp/drivers/ft7800.py +++ b/chirp/drivers/ft7800.py @@ -13,7 +13,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-import time, logging +import time +import logging +import os +import re + from chirp.drivers import yaesu_clone from chirp import chirp_common, memmap, directory, bitwise, errors from textwrap import dedent @@ -21,7 +25,6 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ RadioSettingValueBoolean, RadioSettingValueString, \ RadioSettings -import os, re
from collections import defaultdict
@@ -147,7 +150,7 @@ u8 checksum;
MODES = ["FM", "AM", "NFM"] DUPLEX = ["", "", "-", "+", "split"] -STEPS = [5.0, 10.0, 12.5, 15.0, 20.0, 25.0, 50.0, 100.0] +STEPS = [5.0, 10.0, 12.5, 15.0, 20.0, 25.0, 50.0, 100.0] SKIPS = ["", "S", "P", ""]
CHARSET = ["%i" % int(x) for x in range(0, 10)] + \ @@ -156,7 +159,8 @@ CHARSET = ["%i" % int(x) for x in range(0, 10)] + \ list("*+,- /| [ ] _") + \ list("\x00" * 100)
-DTMFCHARSET = list("0123456789ABCD*#") +DTMFCHARSET = list("0123456789ABCD*#") +
def _send(ser, data): for i in data: @@ -166,6 +170,7 @@ def _send(ser, data): if echo != data: raise errors.RadioError("Error reading echo (Bad cable?)")
+ def _download(radio): data = ""
@@ -200,12 +205,13 @@ def _download(radio):
return memmap.MemoryMap(data)
+ def _upload(radio): cur = 0 for block in radio._block_lengths: for _i in range(0, block, radio._block_size): length = min(radio._block_size, block) - #print "i=%i length=%i range: %i-%i" % (i, length, + # print "i=%i length=%i range: %i-%i" % (i, length, # cur, cur+length) _send(radio.pipe, radio.get_mmap()[cur:cur+length]) if radio.pipe.read(1) != ACK: @@ -220,6 +226,7 @@ def _upload(radio): status.msg = "Cloning to radio" radio.status_fn(status)
+ def get_freq(rawfreq): """Decode a frequency that may include a fractional step flag""" # Ugh. The 0x80 and 0x40 indicate values to add to get the @@ -232,6 +239,7 @@ def get_freq(rawfreq):
return rawfreq
+ def set_freq(freq, obj, field): """Encode a frequency with any necessary fractional step flags""" obj[field] = freq / 10000 @@ -240,9 +248,10 @@ def set_freq(freq, obj, field):
if (freq % 10000) >= 5000: obj[field][0].set_bits(0x80) - + return freq
+ class FTx800Radio(yaesu_clone.YaesuCloneModeRadio): """Base class for FT-7800,7900,8800,8900 radios""" BAUD_RATE = 9600 @@ -251,40 +260,40 @@ class FTx800Radio(yaesu_clone.YaesuCloneModeRadio): _block_size = 64
POWER_LEVELS_VHF = [chirp_common.PowerLevel("Hi", watts=50), - chirp_common.PowerLevel("Mid1", watts=20), - chirp_common.PowerLevel("Mid2", watts=10), - chirp_common.PowerLevel("Low", watts=5)] + chirp_common.PowerLevel("Mid1", watts=20), + chirp_common.PowerLevel("Mid2", watts=10), + chirp_common.PowerLevel("Low", watts=5)]
POWER_LEVELS_UHF = [chirp_common.PowerLevel("Hi", watts=35), - chirp_common.PowerLevel("Mid1", watts=20), - chirp_common.PowerLevel("Mid2", watts=10), - chirp_common.PowerLevel("Low", watts=5)] + chirp_common.PowerLevel("Mid1", watts=20), + chirp_common.PowerLevel("Mid2", watts=10), + chirp_common.PowerLevel("Low", watts=5)]
@classmethod def get_prompts(cls): rp = chirp_common.RadioPrompts() rp.pre_download = _(dedent("""\ - 1. Turn radio off. - 2. Connect cable to DATA jack. - 3. Press and hold in the [MHz(PRI)] key while turning the - radio on. - 4. Rotate the DIAL job to select "F-7 CLONE". - 5. Press and hold in the [BAND(SET)] key. The display - will disappear for a moment, then the "CLONE" notation - will appear. - 6. <b>After clicking OK</b>, press the [V/M(MW)] key to send image.""")) +1. Turn radio off. +2. Connect cable to DATA jack. +3. Press and hold in the [MHz(PRI)] key while turning the + radio on. +4. Rotate the DIAL job to select "F-7 CLONE". +5. Press and hold in the [BAND(SET)] key. The display + will disappear for a moment, then the "CLONE" notation + will appear. +6. <b>After clicking OK</b>, press the [V/M(MW)] key to send image.""")) rp.pre_upload = _(dedent("""\ - 1. Turn radio off. - 2. Connect cable to DATA jack. - 3. Press and hold in the [MHz(PRI)] key while turning the - radio on. - 4. Rotate the DIAL job to select "F-7 CLONE". - 5. Press and hold in the [BAND(SET)] key. The display - will disappear for a moment, then the "CLONE" notation - will appear. - 6. Press the [LOW(ACC)] key ("--RX--" will appear on the display).""")) +1. Turn radio off. +2. Connect cable to DATA jack. +3. Press and hold in the [MHz(PRI)] key while turning the + radio on. +4. Rotate the DIAL job to select "F-7 CLONE". +5. Press and hold in the [BAND(SET)] key. The display + will disappear for a moment, then the "CLONE" notation + will appear. +6. Press the [LOW(ACC)] key ("--RX--" will appear on the display).""")) return rp - + def get_features(self): rf = chirp_common.RadioFeatures() rf.memory_bounds = (1, 999) @@ -304,7 +313,7 @@ class FTx800Radio(yaesu_clone.YaesuCloneModeRadio): return rf
def _checksums(self): - return [ yaesu_clone.YaesuChecksum(0x0000, 0x7B47) ] + return [yaesu_clone.YaesuChecksum(0x0000, 0x7B47)]
def sync_in(self): start = time.time() @@ -423,12 +432,12 @@ class FTx800Radio(yaesu_clone.YaesuCloneModeRadio): if self.get_features().has_tuning_step: _mem.tune_step = STEPS.index(mem.tuning_step) _mem.duplex = DUPLEX.index(mem.duplex) - _mem.split = mem.duplex == "split" and int (mem.offset / 10000) or 0 + _mem.split = mem.duplex == "split" and int(mem.offset / 10000) or 0 if mem.power: _mem.power = self.POWER_LEVELS_VHF.index(mem.power) else: _mem.power = 0 - _mem.unknown5 = 0 # Make sure we don't leave garbage here + _mem.unknown5 = 0 # Make sure we don't leave garbage here
# NB: Leave offset after mem name for the 8800! self._set_mem_name(mem, _mem) @@ -436,6 +445,7 @@ class FTx800Radio(yaesu_clone.YaesuCloneModeRadio):
self._set_mem_skip(mem, _mem)
+ class FT7800BankModel(chirp_common.BankModel): """Yaesu FT-7800/7900 bank model""" def __init__(self, radio): @@ -483,7 +493,7 @@ class FT7800BankModel(chirp_common.BankModel): if not (_bitmap.bitmap[index / 32] & (1 << ishft)): raise Exception("Memory {num} is " + "not in bank {bank}".format(num=memory.number, - bank=bank)) + bank=bank)) _bitmap.bitmap[index / 32] &= ~(1 << ishft) self.__b2m_cache[bank.index].remove(memory.number) self.__m2b_cache[memory.number].remove(bank.index) @@ -491,8 +501,9 @@ class FT7800BankModel(chirp_common.BankModel): def _get_bank_memories(self, bank): memories = [] upper = self._radio.get_features().memory_bounds[1] + c = self._radio._memobj.bank_channels[bank.index] for i in range(0, upper): - _bitmap = self._radio._memobj.bank_channels[bank.index].bitmap[i/32] + _bitmap = c.bitmap[i / 32] ishft = 31 - (i % 32) if _bitmap & (1 << ishft): memories.append(i + 1) @@ -510,6 +521,7 @@ class FT7800BankModel(chirp_common.BankModel): _banks = self.get_mappings() return [_banks[b] for b in self.__m2b_cache[memory.number]]
+ @directory.register class FT7800Radio(FTx800Radio): """Yaesu FT-7800""" @@ -520,8 +532,6 @@ class FT7800Radio(FTx800Radio): _block_lengths = [8, 31552, 1] TMODES = ["", "Tone", "TSQL", "TSQL-R", "DTCS"]
- - def get_bank_model(self): return FT7800BankModel(self)
@@ -545,8 +555,8 @@ class FT7800Radio(FTx800Radio): break outstr += CHARSET[i & 0x7F] return outstr.rstrip() - - def _encode_chars(self, instr, length = 16): + + def _encode_chars(self, instr, length=16): LOG.debug("@_encode_chars, type: %s" % type(instr)) LOG.debug(instr) outarr = [] @@ -567,70 +577,87 @@ class FT7800Radio(FTx800Radio):
top = RadioSettings(basic, dtmf, arts, prog)
- basic.append( RadioSetting("priority_revert", "Priority Revert", + basic.append(RadioSetting( + "priority_revert", "Priority Revert", RadioSettingValueBoolean(_settings.priority_revert)))
- basic.append( RadioSetting("memory_only", "Memory Only mode", + basic.append(RadioSetting( + "memory_only", "Memory Only mode", RadioSettingValueBoolean(_settings.memory_only))) - - opts = ["off"] + [ "%0.1f" % (t / 60.0) for t in range(30, 750, 30) ] - basic.append( RadioSetting("apo", "APO time (hrs)", + + opts = ["off"] + ["%0.1f" % (t / 60.0) for t in range(30, 750, 30)] + basic.append(RadioSetting( + "apo", "APO time (hrs)", RadioSettingValueList(opts, opts[_settings.apo])))
- basic.append( RadioSetting("beep_scan", "Beep: Scan", + basic.append(RadioSetting( + "beep_scan", "Beep: Scan", RadioSettingValueBoolean(_settings.beep_scan)))
- basic.append( RadioSetting("beep_edge", "Beep: Edge", + basic.append(RadioSetting( + "beep_edge", "Beep: Edge", RadioSettingValueBoolean(_settings.beep_edge)))
- basic.append( RadioSetting("beep_key", "Beep: Key", + basic.append(RadioSetting( + "beep_key", "Beep: Key", RadioSettingValueBoolean(_settings.beep_key))) - + opts = ["T/RX Normal", "RX Reverse", "TX Reverse", "T/RX Reverse"] - basic.append( RadioSetting("dcs_polarity", "DCS polarity", + basic.append(RadioSetting( + "dcs_polarity", "DCS polarity", RadioSettingValueList(opts, opts[_settings.dcs_polarity]))) - + opts = ["off", "dim 1", "dim 2", "dim 3"] - basic.append( RadioSetting("dimmer", "Dimmer", + basic.append(RadioSetting( + "dimmer", "Dimmer", RadioSettingValueList(opts, opts[_settings.dimmer])))
opts = ["manual", "auto", "1-auto"] - basic.append( RadioSetting("hyper_write", "Hyper Write", + basic.append(RadioSetting( + "hyper_write", "Hyper Write", RadioSettingValueList(opts, opts[_settings.hyper_write]))) - - opts = ["", "key", "dial", "key+dial", "ptt", + + opts = ["", "key", "dial", "key+dial", "ptt", "ptt+key", "ptt+dial", "all"] - basic.append( RadioSetting("lock", "Lock mode", - RadioSettingValueList(opts, opts[_settings.lock]))) + basic.append(RadioSetting( + "lock", "Lock mode", + RadioSettingValueList(opts, opts[_settings.lock])))
opts = ["MH-42", "MH-48"] - basic.append( RadioSetting("microphone_type", "Microphone Type", + basic.append(RadioSetting( + "microphone_type", "Microphone Type", RadioSettingValueList(opts, opts[_settings.microphone_type])))
- opts = ["off"] + ["S-%d" % n for n in range(2, 10) ] + ["S-Full"] - basic.append( RadioSetting("rf_sql", "RF Squelch", + opts = ["off"] + ["S-%d" % n for n in range(2, 10)] + ["S-Full"] + basic.append(RadioSetting( + "rf_sql", "RF Squelch", RadioSettingValueList(opts, opts[_settings.rf_sql])))
opts = ["time", "hold", "busy"] - basic.append( RadioSetting("scan_resume", "Scan Resume", + basic.append(RadioSetting( + "scan_resume", "Scan Resume", RadioSettingValueList(opts, opts[_settings.scan_resume])))
opts = ["single", "continuous"] - basic.append( RadioSetting("smart_search", "Smart Search", + basic.append(RadioSetting( + "smart_search", "Smart Search", RadioSettingValueList(opts, opts[_settings.smart_search])))
- opts = ["off"] + [ "%d" % t for t in range(1, 31) ] - basic.append( RadioSetting("tot", "Time-out timer (mins)", + opts = ["off"] + ["%d" % t for t in range(1, 31)] + basic.append(RadioSetting( + "tot", "Time-out timer (mins)", RadioSettingValueList(opts, opts[_settings.tot])))
# dtmf tab
opts = ["50", "100", "250", "450", "750", "1000"] - dtmf.append( RadioSetting("dtmf_delay", "DTMF delay (ms)", + dtmf.append(RadioSetting( + "dtmf_delay", "DTMF delay (ms)", RadioSettingValueList(opts, opts[_settings.dtmf_delay])))
opts = ["50", "75", "100"] - dtmf.append( RadioSetting("dtmf_speed", "DTMF speed (ms)", + dtmf.append(RadioSetting( + "dtmf_speed", "DTMF speed (ms)", RadioSettingValueList(opts, opts[_settings.dtmf_speed])))
for i in range(16): @@ -646,52 +673,61 @@ class FT7800Radio(FTx800Radio): dtmfentry = RadioSettingValueString(0, 16, dtmfstr) dtmfentry.set_charset(DTMFCHARSET + list(" ")) rs = RadioSetting(name, name.upper(), dtmfentry) - dtmf.append(rs) + dtmf.append(rs)
- # arts tab + # arts tab
opts = ["off", "in range", "always"] - arts.append( RadioSetting("arts_mode", "ARTS beep", + arts.append(RadioSetting( + "arts_mode", "ARTS beep", RadioSettingValueList(opts, opts[_settings.arts_mode])))
opts = ["15", "25"] - arts.append( RadioSetting("arts_interval", "ARTS interval", + arts.append(RadioSetting( + "arts_interval", "ARTS interval", RadioSettingValueList(opts, opts[_settings.arts_interval])))
- arts.append( RadioSetting("arts_cwid_enable", "CW ID", - RadioSettingValueBoolean(_settings.arts_cwid_enable))) + arts.append(RadioSetting( + "arts_cwid_enable", "CW ID", + RadioSettingValueBoolean(_settings.arts_cwid_enable)))
_arts_cwid = self._memobj.arts_cwid - cwid = RadioSettingValueString(0, 16, - self._decode_chars(_arts_cwid.get_value())) + cwid = RadioSettingValueString( + 0, 16, self._decode_chars(_arts_cwid.get_value())) cwid.set_charset(CHARSET) - arts.append( RadioSetting("arts_cwid", "CW ID", cwid )) + arts.append(RadioSetting("arts_cwid", "CW ID", cwid))
# prog buttons
opts = ["WX", "Reverse", "Repeater", "SQL Off", "Lock", "Dimmer"] - prog.append( RadioSetting("prog_panel_acc", "Prog Panel - Low(ACC)", + prog.append(RadioSetting( + "prog_panel_acc", "Prog Panel - Low(ACC)", RadioSettingValueList(opts, opts[_settings.prog_panel_acc])))
opts = ["Reverse", "Home"] - prog.append( RadioSetting("prog_tone_vm", "TONE | V/M", + prog.append(RadioSetting( + "prog_tone_vm", "TONE | V/M", RadioSettingValueList(opts, opts[_settings.prog_tone_vm])))
opts = ["" for n in range(26)] + \ - ["Priority", "Low", "Tone", "MHz", "Reverse", "Home", "Band", - "VFO/MR", "Scan", "Sql Off", "TCall", "SSCH", "ARTS", "Tone Freq", - "DCSC", "WX", "Repeater" ] + ["Priority", "Low", "Tone", "MHz", "Reverse", "Home", "Band", + "VFO/MR", "Scan", "Sql Off", "TCall", "SSCH", "ARTS", "Tone Freq", + "DCSC", "WX", "Repeater"]
- prog.append( RadioSetting("prog_p1", "P1", + prog.append(RadioSetting( + "prog_p1", "P1", RadioSettingValueList(opts, opts[_settings.prog_p1])))
- prog.append( RadioSetting("prog_p2", "P2", + prog.append(RadioSetting( + "prog_p2", "P2", RadioSettingValueList(opts, opts[_settings.prog_p2])))
- prog.append( RadioSetting("prog_p3", "P3", + prog.append(RadioSetting( + "prog_p3", "P3", RadioSettingValueList(opts, opts[_settings.prog_p3])))
- prog.append( RadioSetting("prog_p4", "P4", + prog.append(RadioSetting( + "prog_p4", "P4", RadioSettingValueList(opts, opts[_settings.prog_p4])))
return top @@ -710,7 +746,7 @@ class FT7800Radio(FTx800Radio): # set dtmf fields dtmfstr = str(element.value).strip() newval = [] - for i in range(0,16): + for i in range(0, 16): if i < len(dtmfstr): newval.append(DTMFCHARSET.index(dtmfstr[i])) else: @@ -719,7 +755,7 @@ class FT7800Radio(FTx800Radio): idx = int(setting[-2:]) _settings = self._memobj.dtmf[idx] _settings.memory = newval - continue + continue if setting == "arts_cwid": oldval = self._memobj.arts_cwid newval = self._encode_chars(newval.get_value(), 6) @@ -774,10 +810,12 @@ struct { u8 checksum; """
+ class FT8800BankModel(FT7800BankModel): def get_num_mappings(self): return 10
+ @directory.register class FT8800Radio(FTx800Radio): """Base class for Yaesu FT-8800""" @@ -801,9 +839,9 @@ class FT8800Radio(FTx800Radio): 3. Press and hold in the "left" [V/M] key while turning the radio on. 4. Rotate the "right" DIAL knob to select "CLONE START". - 5. Press the [SET] key. The display will disappear + 5. Press the [SET] key. The display will disappear for a moment, then the "CLONE" notation will appear. - 6. <b>After clicking OK</b>, press the "left" [V/M] key to + 6. <b>After clicking OK</b>, press the "left" [V/M] key to send image.""")) rp.pre_upload = _(dedent("""\ 1. Turn radio off. @@ -811,12 +849,12 @@ class FT8800Radio(FTx800Radio): 3. Press and hold in the "left" [V/M] key while turning the radio on. 4. Rotate the "right" DIAL knob to select "CLONE START". - 5. Press the [SET] key. The display will disappear + 5. Press the [SET] key. The display will disappear for a moment, then the "CLONE" notation will appear. - 6. Press the "left" [LOW] key ("CLONE -RX-" will appear on + 6. Press the "left" [LOW] key ("CLONE -RX-" will appear on the display).""")) return rp - + def get_features(self): rf = FTx800Radio.get_features(self) rf.has_sub_devices = self.VARIANT == "" @@ -831,7 +869,7 @@ class FT8800Radio(FTx800Radio): return FT8800BankModel(self)
def _checksums(self): - return [ yaesu_clone.YaesuChecksum(0x0000, 0x56C7) ] + return [yaesu_clone.YaesuChecksum(0x0000, 0x56C7)]
def process_mmap(self): if not self._memstart: @@ -879,6 +917,7 @@ class FT8800Radio(FTx800Radio): _mem.namevalid = 1 _mem.nameused = bool(mem.name.rstrip())
+ class FT8800RadioLeft(FT8800Radio): """Yaesu FT-8800 Left VFO subdevice""" VARIANT = "Left" @@ -926,6 +965,7 @@ struct { u8 checksum; """
+ @directory.register class FT8900Radio(FT8800Radio): """Yaesu FT-8900""" @@ -945,8 +985,8 @@ class FT8900Radio(FT8800Radio): rf.has_sub_devices = False rf.has_bank = False rf.valid_modes = self.MODES - rf.valid_bands = [( 28000000, 29700000), - ( 50000000, 54000000), + rf.valid_bands = [(28000000, 29700000), + (50000000, 54000000), (108000000, 180000000), (320000000, 480000000), (700000000, 985000000)] @@ -956,7 +996,7 @@ class FT8900Radio(FT8800Radio): return rf
def _checksums(self): - return [ yaesu_clone.YaesuChecksum(0x0000, 0x39C7) ] + return [yaesu_clone.YaesuChecksum(0x0000, 0x39C7)]
def _get_mem_skip(self, mem, _mem): return SKIPS[_mem.skip] @@ -981,4 +1021,3 @@ class FT8900Radio(FT8800Radio): _mem.sub_used = 0 else: _mem.sub_used = 1 - diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index cba6d00..1582188 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -1,7 +1,6 @@ # cpep8.blacklist: The list of files that do not meet PEP8 standards. # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. -./chirp/drivers/ft7800.py ./chirp/drivers/ft90.py ./chirp/drivers/ftm350.py ./chirp/drivers/ic208.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID 1999c77a04a35d8bd3df9b26ea7356bb0124b613
Fix style issues in ft90.py (#2355)
diff --git a/chirp/drivers/ft90.py b/chirp/drivers/ft90.py index dc7b658..3f5e2c6 100644 --- a/chirp/drivers/ft90.py +++ b/chirp/drivers/ft90.py @@ -20,7 +20,14 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ RadioSettingValueBoolean, RadioSettingValueString, \ RadioSettings -import time, os, traceback, string, re, logging + +import time +import os +import traceback +import string +import re +import logging + from textwrap import dedent
LOG = logging.getLogger(__name__) @@ -29,25 +36,27 @@ CMD_ACK = chr(0x06)
FT90_STEPS = [5.0, 10.0, 12.5, 15.0, 20.0, 25.0, 50.0] FT90_MODES = ["AM", "FM", "Auto"] -FT90_TMODES = ["", "Tone", "TSQL", "", "DTCS"] # idx 3 (Bell) not supported yet +# idx 3 (Bell) not supported yet +FT90_TMODES = ["", "Tone", "TSQL", "", "DTCS"] FT90_TONES = list(chirp_common.TONES) -for tone in [ 165.5, 171.3, 177.3 ]: +for tone in [165.5, 171.3, 177.3]: FT90_TONES.remove(tone) FT90_POWER_LEVELS_VHF = [chirp_common.PowerLevel("Hi", watts=50), - chirp_common.PowerLevel("Mid1", watts=20), - chirp_common.PowerLevel("Mid2", watts=10), - chirp_common.PowerLevel("Low", watts=5)] + chirp_common.PowerLevel("Mid1", watts=20), + chirp_common.PowerLevel("Mid2", watts=10), + chirp_common.PowerLevel("Low", watts=5)]
FT90_POWER_LEVELS_UHF = [chirp_common.PowerLevel("Hi", watts=35), - chirp_common.PowerLevel("Mid1", watts=20), - chirp_common.PowerLevel("Mid2", watts=10), - chirp_common.PowerLevel("Low", watts=5)] + chirp_common.PowerLevel("Mid1", watts=20), + chirp_common.PowerLevel("Mid2", watts=10), + chirp_common.PowerLevel("Low", watts=5)]
FT90_DUPLEX = ["", "-", "+", "split"] FT90_CWID_CHARS = list(string.digits) + list(string.uppercase) + list(" ") FT90_DTMF_CHARS = list("0123456789ABCD*#") -FT90_SPECIAL = [ "vfo_vhf", "home_vhf", "vfo_uhf", "home_uhf", \ - "pms_1L", "pms_1U", "pms_2L", "pms_2U"] +FT90_SPECIAL = ["vfo_vhf", "home_vhf", "vfo_uhf", "home_uhf", + "pms_1L", "pms_1U", "pms_2L", "pms_2U"] +
@directory.register class FT90Radio(yaesu_clone.YaesuCloneModeRadio): @@ -57,147 +66,146 @@ class FT90Radio(yaesu_clone.YaesuCloneModeRadio):
_memsize = 4063 # block 03 (200 Bytes long) repeats 18 times; channel memories - _block_lengths = [ 2, 232, 24 ] + ([200] * 18 ) + [205] + _block_lengths = [2, 232, 24] + ([200] * 18) + [205]
mem_format = """ - u16 id; - #seekto 0x22; - struct { - u8 dtmf_active; - u8 dtmf1_len; - u8 dtmf2_len; - u8 dtmf3_len; - u8 dtmf4_len; - u8 dtmf5_len; - u8 dtmf6_len; - u8 dtmf7_len; - u8 dtmf8_len; - u8 dtmf1[8]; - u8 dtmf2[8]; - u8 dtmf3[8]; - u8 dtmf4[8]; - u8 dtmf5[8]; - u8 dtmf6[8]; - u8 dtmf7[8]; - u8 dtmf8[8]; - char cwid[7]; - u8 unk1; - u8 scan1:2, - beep:1, - unk3:3, - rfsqlvl:2; - u8 unk4:2, - scan2:1, - cwid_en:1, - txnarrow:1, - dtmfspeed:1, - pttlock:2; - u8 dtmftxdelay:3, - fancontrol:2, - unk5:3; - u8 dimmer:3, - unk6:1, - lcdcontrast:4; - u8 dcsmode:2, - unk16:2, - tot:4; - u8 unk14; - u8 unk8:1, - ars:1, - lock:1, - txpwrsave:1, - apo:4; - u8 unk15; - u8 unk9:4, - key_lt:4; - u8 unk10:4, - key_rt:4; - u8 unk11:4, - key_p1:4; - u8 unk12:4, - key_p2:4; - u8 unk13:4, - key_acc:4; - - } settings; - - struct mem_struct { - u8 mode:2, - isUhf1:1, - unknown1:2, - step:3; - u8 artsmode:2, - unknown2:1, - isUhf2:1 - power:2, - shift:2; - u8 skip:1, - showname:1, - unknown3:1, - isUhfHi:1, - unknown4:1, - tmode:3; - u32 rxfreq; - u32 txfreqoffset; - u8 UseDefaultName:1, - ars:1, - tone:6; - u8 packetmode:1, - unknown5:1, - dcstone:6; - char name[7]; - }; - - #seekto 0x86; - struct mem_struct vfo_vhf; - struct mem_struct home_vhf; - struct mem_struct vfo_uhf; - struct mem_struct home_uhf; - - #seekto 0xEB; - u8 chan_enable[23]; - - #seekto 0x101; - struct { - u8 pms_2U_enable:1, - pms_2L_enable:1, - pms_1U_enable:1, - pms_1L_enable:1, - unknown6:4; - } special_enables; - - #seekto 0x102; - struct mem_struct memory[180]; - - #seekto 0xf12; - struct mem_struct pms_1L; - struct mem_struct pms_1U; - struct mem_struct pms_2L; - struct mem_struct pms_2U; - - #seekto 0x0F7B; - struct { - char demomsg1[50]; - char demomsg2[50]; - } demomsg; - - """ +u16 id; +#seekto 0x22; +struct { + u8 dtmf_active; + u8 dtmf1_len; + u8 dtmf2_len; + u8 dtmf3_len; + u8 dtmf4_len; + u8 dtmf5_len; + u8 dtmf6_len; + u8 dtmf7_len; + u8 dtmf8_len; + u8 dtmf1[8]; + u8 dtmf2[8]; + u8 dtmf3[8]; + u8 dtmf4[8]; + u8 dtmf5[8]; + u8 dtmf6[8]; + u8 dtmf7[8]; + u8 dtmf8[8]; + char cwid[7]; + u8 unk1; + u8 scan1:2, + beep:1, + unk3:3, + rfsqlvl:2; + u8 unk4:2, + scan2:1, + cwid_en:1, + txnarrow:1, + dtmfspeed:1, + pttlock:2; + u8 dtmftxdelay:3, + fancontrol:2, + unk5:3; + u8 dimmer:3, + unk6:1, + lcdcontrast:4; + u8 dcsmode:2, + unk16:2, + tot:4; + u8 unk14; + u8 unk8:1, + ars:1, + lock:1, + txpwrsave:1, + apo:4; + u8 unk15; + u8 unk9:4, + key_lt:4; + u8 unk10:4, + key_rt:4; + u8 unk11:4, + key_p1:4; + u8 unk12:4, + key_p2:4; + u8 unk13:4, + key_acc:4; +} settings; + +struct mem_struct { + u8 mode:2, + isUhf1:1, + unknown1:2, + step:3; + u8 artsmode:2, + unknown2:1, + isUhf2:1 + power:2, + shift:2; + u8 skip:1, + showname:1, + unknown3:1, + isUhfHi:1, + unknown4:1, + tmode:3; + u32 rxfreq; + u32 txfreqoffset; + u8 UseDefaultName:1, + ars:1, + tone:6; + u8 packetmode:1, + unknown5:1, + dcstone:6; + char name[7]; +}; + +#seekto 0x86; +struct mem_struct vfo_vhf; +struct mem_struct home_vhf; +struct mem_struct vfo_uhf; +struct mem_struct home_uhf; + +#seekto 0xEB; +u8 chan_enable[23]; + +#seekto 0x101; +struct { + u8 pms_2U_enable:1, + pms_2L_enable:1, + pms_1U_enable:1, + pms_1L_enable:1, + unknown6:4; +} special_enables; + +#seekto 0x102; +struct mem_struct memory[180]; + +#seekto 0xf12; +struct mem_struct pms_1L; +struct mem_struct pms_1U; +struct mem_struct pms_2L; +struct mem_struct pms_2U; + +#seekto 0x0F7B; +struct { + char demomsg1[50]; + char demomsg2[50]; +} demomsg; +""" + @classmethod def get_prompts(cls): rp = chirp_common.RadioPrompts() rp.pre_download = _(dedent("""\ - 1. Turn radio off. - 2. Connect mic and hold [ACC] on mic while powering on. - ("CLONE" will appear on the display) - 3. Replace mic with PC programming cable. - 4. <b>After clicking OK</b>, press the [SET] key to send image.""")) +1. Turn radio off. +2. Connect mic and hold [ACC] on mic while powering on. + ("CLONE" will appear on the display) +3. Replace mic with PC programming cable. +4. <b>After clicking OK</b>, press the [SET] key to send image.""")) rp.pre_upload = _(dedent("""\ - 1. Turn radio off. - 2. Connect mic and hold [ACC] on mic while powering on. - ("CLONE" will appear on the display) - 3. Replace mic with PC programming cable. - 4. Press the [DISP/SS] key - ("R" will appear on the lower left of LCD).""")) +1. Turn radio off. +2. Connect mic and hold [ACC] on mic while powering on. + ("CLONE" will appear on the display) +3. Replace mic with PC programming cable. +4. Press the [DISP/SS] key + ("R" will appear on the lower left of LCD).""")) rp.display_pre_upload_prompt_before_opening_port = False return rp
@@ -222,38 +230,42 @@ class FT90Radio(yaesu_clone.YaesuCloneModeRadio): rf.valid_skips = ["", "S"] rf.valid_special_chans = FT90_SPECIAL rf.memory_bounds = (1, 180) - rf.valid_bands = [(100000000, 230000000), - (300000000, 530000000), (810000000, 999975000)] + rf.valid_bands = [(100000000, 230000000), + (300000000, 530000000), + (810000000, 999975000)]
return rf
def _read(self, blocksize, blocknum): data = self.pipe.read(blocksize+2) - + # chew echo'd ack self.pipe.write(CMD_ACK) time.sleep(0.02) - self.pipe.read(1) # chew echoed ACK from 1-wire serial - - if len(data) == blocksize+2 and data[0] == chr(blocknum): + self.pipe.read(1) # chew echoed ACK from 1-wire serial + + if len(data) == blocksize + 2 and data[0] == chr(blocknum): checksum = yaesu_clone.YaesuChecksum(1, blocksize) if checksum.get_existing(data) != checksum.get_calculated(data): - raise Exception("Checksum Failed [%02X<>%02X] block %02X, data len: %i" % - (checksum.get_existing(data), - checksum.get_calculated(data), blocknum, len(data) )) - data = data[1:blocksize+1] # Chew blocknum and checksum - + raise Exception("Checksum Failed [%02X<>%02X] block %02X, " + "data len: %i" % + (checksum.get_existing(data), + checksum.get_calculated(data), + blocknum, len(data))) + data = data[1:blocksize + 1] # Chew blocknum and checksum + else: - raise Exception("Unable to read blocknum %02X expected blocksize %i got %i." % - (blocknum, blocksize+2, len(data))) + raise Exception("Unable to read blocknum %02X " + "expected blocksize %i got %i." % + (blocknum, blocksize+2, len(data))) + + return data
- return data - def _clone_in(self): # Be very patient with the radio self.pipe.setTimeout(4) start = time.time() - + data = "" blocknum = 0 status = chirp_common.Status() @@ -265,16 +277,17 @@ class FT90Radio(yaesu_clone.YaesuCloneModeRadio): blocknum += 1 status.cur = blocknum self.status_fn(status) - - print "Clone completed in %i seconds, blocks read: %i" % (time.time() - start, blocknum) - + + print "Clone completed in %i seconds, blocks read: %i" % \ + (time.time() - start, blocknum) + return memmap.MemoryMap(data) - + def _clone_out(self): looppredelay = 0.4 looppostdelay = 1.9 start = time.time() - + blocknum = 0 pos = 0 status = chirp_common.Status() @@ -287,8 +300,8 @@ class FT90Radio(yaesu_clone.YaesuCloneModeRadio): blocknumbyte = chr(blocknum) payloadbytes = self.get_mmap()[pos:pos+blocksize] checksumbyte = chr(checksum.get_calculated(self.get_mmap())) - LOG.debug("Block %i - will send from %i to %i byte " % \ - (blocknum, pos, pos + blocksize)) + LOG.debug("Block %i - will send from %i to %i byte " % + (blocknum, pos, pos + blocksize)) LOG.debug(util.hexprint(blocknumbyte)) LOG.debug(util.hexprint(payloadbytes)) LOG.debug(util.hexprint(checksumbyte)) @@ -297,11 +310,11 @@ class FT90Radio(yaesu_clone.YaesuCloneModeRadio): self.pipe.write(blocknumbyte) self.pipe.write(payloadbytes) self.pipe.write(checksumbyte) - tmp = self.pipe.read(blocksize+2) #chew echo + tmp = self.pipe.read(blocksize + 2) # chew echo LOG.debug("bytes echoed: ") LOG.debug(util.hexprint(tmp)) # radio is slow to write/ack: - time.sleep(looppostdelay) + time.sleep(looppostdelay) buf = self.pipe.read(1) LOG.debug("ack recd:") LOG.debug(util.hexprint(buf)) @@ -311,9 +324,9 @@ class FT90Radio(yaesu_clone.YaesuCloneModeRadio): blocknum += 1 status.cur = blocknum self.status_fn(status) - + print "Clone completed in %i seconds" % (time.time() - start) - + def sync_in(self): try: self._mmap = self._clone_in() @@ -321,7 +334,8 @@ class FT90Radio(yaesu_clone.YaesuCloneModeRadio): raise except Exception, e: trace = traceback.format_exc() - raise errors.RadioError("Failed to communicate with radio: %s" % trace) + raise errors.RadioError( + "Failed to communicate with radio: %s" % trace) self.process_mmap()
def sync_out(self): @@ -331,17 +345,18 @@ class FT90Radio(yaesu_clone.YaesuCloneModeRadio): raise except Exception, e: trace = traceback.format_exc() - raise errors.RadioError("Failed to communicate with radio: %s" % trace) + raise errors.RadioError( + "Failed to communicate with radio: %s" % trace)
def process_mmap(self): self._memobj = bitwise.parse(self.mem_format, self._mmap) - + def _get_chan_enable(self, number): number = number - 1 bytepos = number // 8 - bitpos = number % 8 + bitpos = number % 8 chan_enable = self._memobj.chan_enable[bytepos] - if chan_enable & ( 1 << bitpos ): + if chan_enable & (1 << bitpos): return True else: return False @@ -349,14 +364,14 @@ class FT90Radio(yaesu_clone.YaesuCloneModeRadio): def _set_chan_enable(self, number, enable): number = number - 1 bytepos = number // 8 - bitpos = number % 8 + bitpos = number % 8 chan_enable = self._memobj.chan_enable[bytepos] if enable: - chan_enable = chan_enable | ( 1 << bitpos ) # enable + chan_enable = chan_enable | (1 << bitpos) # enable else: - chan_enable = chan_enable & ~ ( 1 << bitpos ) # disable + chan_enable = chan_enable & ~(1 << bitpos) # disable self._memobj.chan_enable[bytepos] = chan_enable - + def get_memory(self, number): mem = chirp_common.Memory() if isinstance(number, str): @@ -367,7 +382,8 @@ class FT90Radio(yaesu_clone.YaesuCloneModeRadio): if re.match('^pms', mem.extd_number): # enable pms_XY channel flag _special_enables = self._memobj.special_enables - mem.empty = not getattr(_special_enables, mem.extd_number + "_enable") + mem.empty = not getattr(_special_enables, + mem.extd_number + "_enable") else: # regular memory _mem = self._memobj.memory[number-1] @@ -375,7 +391,7 @@ class FT90Radio(yaesu_clone.YaesuCloneModeRadio): mem.empty = not self._get_chan_enable(number) if mem.empty: return mem # bail out, do not parse junk - mem.freq = _mem.rxfreq * 10 + mem.freq = _mem.rxfreq * 10 mem.offset = _mem.txfreqoffset * 10 if not _mem.tmode < len(FT90_TMODES): _mem.tmode = 0 @@ -394,7 +410,8 @@ class FT90Radio(yaesu_clone.YaesuCloneModeRadio): _mem.step = 2 mem.tuning_step = FT90_STEPS[_mem.step] mem.skip = _mem.skip and "S" or "" - if not all(char in chirp_common.CHARSET_ASCII for char in str(_mem.name)): + if not all(char in chirp_common.CHARSET_ASCII + for char in str(_mem.name)): # dont display blank/junk name mem.name = "" else: @@ -403,7 +420,7 @@ class FT90Radio(yaesu_clone.YaesuCloneModeRadio):
def get_raw_memory(self, number): return repr(self._memobj.memory[number-1]) - + def set_memory(self, mem): if mem.number < 0: # special channels _mem = getattr(self._memobj, mem.extd_number) @@ -413,7 +430,7 @@ class FT90Radio(yaesu_clone.YaesuCloneModeRadio): setattr(_special_enables, mem.extd_number + "_enable", True) else: _mem = self._memobj.memory[mem.number - 1] - self._set_chan_enable( mem.number, not mem.empty ) + self._set_chan_enable(mem.number, not mem.empty) _mem.skip = mem.skip == "S" # radio has a known bug with 5khz step and dead squelch if not mem.tuning_step or mem.tuning_step == FT90_STEPS[0]: @@ -422,7 +439,7 @@ class FT90Radio(yaesu_clone.YaesuCloneModeRadio): _mem.step = FT90_STEPS.index(mem.tuning_step) _mem.rxfreq = mem.freq / 10 # vfo will unlock if not in right band? - if mem.freq > 300000000: + if mem.freq > 300000000: # uhf _mem.isUhf1 = 1 _mem.isUhf2 = 1 @@ -440,7 +457,7 @@ class FT90Radio(yaesu_clone.YaesuCloneModeRadio): _mem.tone = FT90_TONES.index(mem.rtone) _mem.tmode = FT90_TMODES.index(mem.tmode) _mem.mode = FT90_MODES.index(mem.mode) - _mem.shift = FT90_DUPLEX.index(mem.duplex) + _mem.shift = FT90_DUPLEX.index(mem.duplex) _mem.dcstone = chirp_common.DTCS_CODES.index(mem.dtcs) _mem.step = FT90_STEPS.index(mem.tuning_step) _mem.shift = FT90_DUPLEX.index(mem.duplex) @@ -474,134 +491,153 @@ class FT90Radio(yaesu_clone.YaesuCloneModeRadio): cwid += chr(FT90_CWID_CHARS.index(char)) LOG.debug(cwid) return cwid - - def _bbcd2dtmf(self, bcdarr, strlen = 16): + + def _bbcd2dtmf(self, bcdarr, strlen=16): # doing bbcd, but with support for ABCD*# LOG.debug(bcdarr.get_value()) string = ''.join("%02X" % b for b in bcdarr) LOG.debug("@_bbcd2dtmf, received: %s" % string) - string = string.replace('E','*').replace('F','#') + string = string.replace('E', '*').replace('F', '#') if strlen <= 16: string = string[:strlen] return string - + def _dtmf2bbcd(self, dtmf): dtmfstr = dtmf.get_value() dtmfstr = dtmfstr.replace('*', 'E').replace('#', 'F') - dtmfstr = str.ljust(dtmfstr.strip(), 16, "0" ) + dtmfstr = str.ljust(dtmfstr.strip(), 16, "0") bcdarr = list(bytearray.fromhex(dtmfstr)) LOG.debug("@_dtmf2bbcd, sending: %s" % bcdarr) return bcdarr - + def get_settings(self): _settings = self._memobj.settings basic = RadioSettingGroup("basic", "Basic") autodial = RadioSettingGroup("autodial", "AutoDial") keymaps = RadioSettingGroup("keymaps", "KeyMaps") - + top = RadioSettings(basic, keymaps, autodial) - - rs = RadioSetting("beep", "Beep", - RadioSettingValueBoolean(_settings.beep)) + + rs = RadioSetting( + "beep", "Beep", + RadioSettingValueBoolean(_settings.beep)) basic.append(rs) - rs = RadioSetting("lock", "Lock", - RadioSettingValueBoolean(_settings.lock)) + rs = RadioSetting( + "lock", "Lock", + RadioSettingValueBoolean(_settings.lock)) basic.append(rs) - rs = RadioSetting("ars", "Auto Repeater Shift", - RadioSettingValueBoolean(_settings.ars)) + rs = RadioSetting( + "ars", "Auto Repeater Shift", + RadioSettingValueBoolean(_settings.ars)) basic.append(rs) - rs = RadioSetting("txpwrsave", "TX Power Save", - RadioSettingValueBoolean(_settings.txpwrsave)) + rs = RadioSetting( + "txpwrsave", "TX Power Save", + RadioSettingValueBoolean(_settings.txpwrsave)) basic.append(rs) - rs = RadioSetting("txnarrow", "TX Narrow", - RadioSettingValueBoolean(_settings.txnarrow)) + rs = RadioSetting( + "txnarrow", "TX Narrow", + RadioSettingValueBoolean(_settings.txnarrow)) basic.append(rs) options = ["Off", "S-3", "S-5", "S-Full"] - rs = RadioSetting("rfsqlvl", "RF Squelch Level", - RadioSettingValueList(options, - options[_settings.rfsqlvl])) + rs = RadioSetting( + "rfsqlvl", "RF Squelch Level", + RadioSettingValueList(options, options[_settings.rfsqlvl])) basic.append(rs) options = ["Off", "Band A", "Band B", "Both"] - rs = RadioSetting("pttlock", "PTT Lock", - RadioSettingValueList(options, - options[_settings.pttlock])) + rs = RadioSetting( + "pttlock", "PTT Lock", + RadioSettingValueList(options, options[_settings.pttlock])) basic.append(rs) - - rs = RadioSetting("cwid_en", "CWID Enable", - RadioSettingValueBoolean(_settings.cwid_en)) + + rs = RadioSetting( + "cwid_en", "CWID Enable", + RadioSettingValueBoolean(_settings.cwid_en)) basic.append(rs) - + cwid = RadioSettingValueString(0, 7, self._decode_cwid(_settings.cwid)) cwid.set_charset(FT90_CWID_CHARS) rs = RadioSetting("cwid", "CWID", cwid) basic.append(rs) - + options = ["OFF"] + map(str, range(1, 12+1)) - rs = RadioSetting("apo", "APO time (hrs)", - RadioSettingValueList(options, - options[_settings.apo])) + rs = RadioSetting( + "apo", "APO time (hrs)", + RadioSettingValueList(options, options[_settings.apo])) basic.append(rs) - + options = ["Off"] + map(str, range(1, 60+1)) - rs = RadioSetting("tot", "Time Out Timer (mins)", - RadioSettingValueList(options,options[_settings.tot])) + rs = RadioSetting( + "tot", "Time Out Timer (mins)", + RadioSettingValueList(options, options[_settings.tot])) basic.append(rs) - + options = ["off", "Auto/TX", "Auto", "TX"] - rs = RadioSetting("fancontrol", "Fan Control", - RadioSettingValueList(options,options[_settings.fancontrol])) + rs = RadioSetting( + "fancontrol", "Fan Control", + RadioSettingValueList(options, options[_settings.fancontrol])) basic.append(rs) - + keyopts = ["Scan Up", "Scan Down", "Repeater", "Reverse", "Tone Burst", - "Tx Power", "Home Ch", "VFO/MR", "Tone", "Priority"] - rs = RadioSetting("key_lt", "Left Key", - RadioSettingValueList(keyopts,keyopts[_settings.key_lt])) + "Tx Power", "Home Ch", "VFO/MR", "Tone", "Priority"] + rs = RadioSetting( + "key_lt", "Left Key", + RadioSettingValueList(keyopts, keyopts[_settings.key_lt])) keymaps.append(rs) - rs = RadioSetting("key_rt", "Right Key", - RadioSettingValueList(keyopts,keyopts[_settings.key_rt])) + rs = RadioSetting( + "key_rt", "Right Key", + RadioSettingValueList(keyopts, keyopts[_settings.key_rt])) keymaps.append(rs) - rs = RadioSetting("key_p1", "P1 Key", - RadioSettingValueList(keyopts,keyopts[_settings.key_p1])) + rs = RadioSetting( + "key_p1", "P1 Key", + RadioSettingValueList(keyopts, keyopts[_settings.key_p1])) keymaps.append(rs) - rs = RadioSetting("key_p2", "P2 Key", - RadioSettingValueList(keyopts,keyopts[_settings.key_p2])) + rs = RadioSetting( + "key_p2", "P2 Key", + RadioSettingValueList(keyopts, keyopts[_settings.key_p2])) keymaps.append(rs) - rs = RadioSetting("key_acc", "ACC Key", - RadioSettingValueList(keyopts,keyopts[_settings.key_acc])) + rs = RadioSetting( + "key_acc", "ACC Key", + RadioSettingValueList(keyopts, keyopts[_settings.key_acc])) keymaps.append(rs) - - options = map(str, range(0,12+1)) - rs = RadioSetting("lcdcontrast", "LCD Contrast", - RadioSettingValueList(options,options[_settings.lcdcontrast])) + + options = map(str, range(0, 12+1)) + rs = RadioSetting( + "lcdcontrast", "LCD Contrast", + RadioSettingValueList(options, options[_settings.lcdcontrast])) basic.append(rs) - + options = ["off", "d4", "d3", "d2", "d1"] - rs = RadioSetting("dimmer", "Dimmer", - RadioSettingValueList(options,options[_settings.dimmer])) + rs = RadioSetting( + "dimmer", "Dimmer", + RadioSettingValueList(options, options[_settings.dimmer])) basic.append(rs) - + options = ["TRX Normal", "RX Reverse", "TX Reverse", "TRX Reverse"] - rs = RadioSetting("dcsmode", "DCS Mode", - RadioSettingValueList(options,options[_settings.dcsmode])) + rs = RadioSetting( + "dcsmode", "DCS Mode", + RadioSettingValueList(options, options[_settings.dcsmode])) basic.append(rs) - + options = ["50 ms", "100 ms"] - rs = RadioSetting("dtmfspeed", "DTMF Speed", - RadioSettingValueList(options,options[_settings.dtmfspeed])) + rs = RadioSetting( + "dtmfspeed", "DTMF Speed", + RadioSettingValueList(options, options[_settings.dtmfspeed])) autodial.append(rs) - + options = ["50 ms", "250 ms", "450 ms", "750 ms", "1 sec"] - rs = RadioSetting("dtmftxdelay", "DTMF TX Delay", - RadioSettingValueList(options,options[_settings.dtmftxdelay])) + rs = RadioSetting( + "dtmftxdelay", "DTMF TX Delay", + RadioSettingValueList(options, options[_settings.dtmftxdelay])) autodial.append(rs) - - options = map(str,range(1,8+1)) - rs = RadioSetting("dtmf_active", "DTMF Active", - RadioSettingValueList(options,options[_settings.dtmf_active])) + + options = map(str, range(1, 8 + 1)) + rs = RadioSetting( + "dtmf_active", "DTMF Active", + RadioSettingValueList(options, options[_settings.dtmf_active])) autodial.append(rs) - + # setup 8 dtmf autodial entries - for i in map(str, range(1,9)): + for i in map(str, range(1, 9)): objname = "dtmf" + i dtmfsetting = getattr(_settings, objname) dtmflen = getattr(_settings, objname + "_len") @@ -610,9 +646,9 @@ class FT90Radio(yaesu_clone.YaesuCloneModeRadio): dtmf.set_charset(FT90_DTMF_CHARS + list(" ")) rs = RadioSetting(objname, objname.upper(), dtmf) autodial.append(rs) - + return top - + def set_settings(self, uisettings): _settings = self._memobj.settings for element in uisettings: @@ -637,4 +673,3 @@ class FT90Radio(yaesu_clone.YaesuCloneModeRadio): except Exception, e: print element.get_name() raise - diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 1582188..12e7260 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -1,7 +1,6 @@ # cpep8.blacklist: The list of files that do not meet PEP8 standards. # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. -./chirp/drivers/ft90.py ./chirp/drivers/ftm350.py ./chirp/drivers/ic208.py ./chirp/drivers/ic2100.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID 8a697d15fb57ca5ba4ac650ada90fbeac28f23c5
Fix style issues in ftm350.py (#2355)
diff --git a/chirp/drivers/ftm350.py b/chirp/drivers/ftm350.py index 564e1a0..f1a0b69 100644 --- a/chirp/drivers/ftm350.py +++ b/chirp/drivers/ftm350.py @@ -85,9 +85,10 @@ _TMODES = ["", "Tone", "TSQL", "-RVT", "DTCS", "-PR", "-PAG"] TMODES = ["", "Tone", "TSQL", "", "DTCS", "", ""] MODES = ["FM", "AM", "NFM", "", "WFM"] DUPLEXES = ["", "", "-", "+", "split"] -#TODO: add japaneese characters (viewable in special menu, scroll backwards) -CHARSET = ('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!"' + - '#$%&`()*+,-./:;<=>?@[\]^_`{|}~?????? ' + '?' * 91) +# TODO: add japaneese characters (viewable in special menu, scroll backwards) +CHARSET = \ + ('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!"' + + '#$%&`()*+,-./:;<=>?@[\]^_`{|}~?????? ' + '?' * 91)
POWER_LEVELS = [chirp_common.PowerLevel("Hi", watts=50), chirp_common.PowerLevel("Mid", watts=20), @@ -95,6 +96,7 @@ POWER_LEVELS = [chirp_common.PowerLevel("Hi", watts=50),
SKIPS = ["", "S", "P"]
+ def aprs_call_to_str(_call): call = "" for i in str(_call): @@ -103,12 +105,14 @@ def aprs_call_to_str(_call): call += i return call
+ def _safe_read(radio, length): data = "" while len(data) < length: data += radio.pipe.read(length - len(data)) return data
+ def _clone_in(radio): data = ""
@@ -145,7 +149,8 @@ def _clone_in(radio): time.sleep(0.05)
if (last_addr + 128) != addr: - LOG.debug("Gap, expecting %04x, got %04x" % (last_addr+128, addr)) + LOG.debug("Gap, expecting %04x, got %04x" % + (last_addr+128, addr)) last_addr = addr data[addr] = block length += len(block) @@ -158,6 +163,7 @@ def _clone_in(radio):
return data
+ def _clone_out(radio): radio.pipe.setTimeout(1)
@@ -190,6 +196,7 @@ def _clone_out(radio): status.msg = "Cloning to radio" radio.status_fn(status)
+ def get_freq(rawfreq): """Decode a frequency that may include a fractional step flag""" # Ugh. The 0x80 and 0x40 indicate values to add to get the @@ -205,6 +212,7 @@ def get_freq(rawfreq):
return rawfreq
+ def set_freq(freq, obj, field): """Encode a frequency with any necessary fractional step flags""" obj[field] = freq / 10000 @@ -224,6 +232,7 @@ def set_freq(freq, obj, field):
return freq
+ @directory.register class FTM350Radio(yaesu_clone.YaesuCloneModeRadio): """Yaesu FTM-350""" @@ -243,7 +252,7 @@ class FTM350Radio(yaesu_clone.YaesuCloneModeRadio): rf.has_tuning_step = False rf.has_dtcs_polarity = False rf.has_sub_devices = self.VARIANT == "" - rf.valid_skips = [] # FIXME: Finish this + rf.valid_skips = [] # FIXME: Finish this rf.valid_tmodes = [""] + [x for x in TMODES if x] rf.valid_modes = [x for x in MODES if x] rf.valid_duplexes = DUPLEXES @@ -252,8 +261,8 @@ class FTM350Radio(yaesu_clone.YaesuCloneModeRadio): rf.valid_characters = CHARSET rf.memory_bounds = (0, 500) rf.valid_power_levels = POWER_LEVELS - rf.valid_bands = [( 500000, 1800000), - (76000000, 250000000), + rf.valid_bands = [(500000, 1800000), + (76000000, 250000000), (30000000, 1000000000)] rf.can_odd_split = True return rf @@ -282,13 +291,20 @@ class FTM350Radio(yaesu_clone.YaesuCloneModeRadio): self._memobj = bitwise.parse(mem_format, self._mmap)
def get_raw_memory(self, number): + + def identity(o): + return o + + def indexed(o): + return o[number - 1] + if number == 0: suffix = "_zero" - fn = lambda o: o + fn = identity else: suffix = "" - fn = lambda o: o[number - 1] - return (repr(fn(self._memory_obj(suffix))) + + fn = indexed + return (repr(fn(self._memory_obj(suffix))) + repr(fn(self._label_obj(suffix))))
def _memory_obj(self, suffix=""): @@ -318,7 +334,7 @@ class FTM350Radio(yaesu_clone.YaesuCloneModeRadio): if _mem.oddsplit: mem.duplex = "split" mem.offset = get_freq(int(_mem.split) * 10000) - else: + else: mem.duplex = DUPLEXES[_mem.duplex] mem.offset = int(_mem.offset) * 50000
@@ -418,6 +434,7 @@ class FTM350RadioLeft(FTM350Radio): VARIANT = "Left" _vfo = "left"
+ class FTM350RadioRight(FTM350Radio): VARIANT = "Right" _vfo = "right" diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 12e7260..01d0462 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -1,7 +1,6 @@ # cpep8.blacklist: The list of files that do not meet PEP8 standards. # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. -./chirp/drivers/ftm350.py ./chirp/drivers/ic208.py ./chirp/drivers/ic2100.py ./chirp/drivers/ic2200.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID 5aa0cd4fb8ac86fc51f59d19d1b57f8d0d283e96
Fix style issues in vx170.py (#2355)
diff --git a/chirp/drivers/vx170.py b/chirp/drivers/vx170.py index 347951d..b5aaa26 100644 --- a/chirp/drivers/vx170.py +++ b/chirp/drivers/vx170.py @@ -16,7 +16,8 @@ from chirp.drivers import yaesu_clone, ft7800 from chirp import chirp_common, directory, memmap, bitwise, errors from textwrap import dedent -import time, os +import time +import os
MEM_FORMAT = """ #seekto 0x018A; @@ -79,6 +80,7 @@ struct { } flags[50]; """
+ @directory.register class VX170Radio(ft7800.FTx800Radio): """Yaesu VX-170""" @@ -89,8 +91,8 @@ class VX170Radio(ft7800.FTx800Radio): _block_size = 32
POWER_LEVELS_VHF = [chirp_common.PowerLevel("Hi", watts=5.00), - chirp_common.PowerLevel("Med", watts=2.00), - chirp_common.PowerLevel("Lo", watts=0.50)] + chirp_common.PowerLevel("Med", watts=2.00), + chirp_common.PowerLevel("Lo", watts=0.50)]
MODES = ["FM", "NFM"] TMODES = ["", "Tone", "TSQL", "DTCS"] @@ -99,23 +101,23 @@ class VX170Radio(ft7800.FTx800Radio): def get_prompts(cls): rp = chirp_common.RadioPrompts() rp.pre_download = _(dedent("""\ - 1. Turn radio off. - 2. Connect cable to MIC/SP jack. - 3. Press and hold in the [moni] key while turning the radio on. - 4. Select CLONE in menu, then press F. Radio restarts in clone mode. - ("CLONE" will appear on the display). - 5. <b>After clicking OK</b>, breifly hold [PTT] key to send image. - ("-TX-" will appear on the LCD). """)) +1. Turn radio off. +2. Connect cable to MIC/SP jack. +3. Press and hold in the [moni] key while turning the radio on. +4. Select CLONE in menu, then press F. Radio restarts in clone mode. + ("CLONE" will appear on the display). +5. <b>After clicking OK</b>, breifly hold [PTT] key to send image. + ("-TX-" will appear on the LCD). """)) rp.pre_upload = _(dedent("""\ - 1. Turn radio off. - 3. Press and hold in the [moni] key while turning the radio on. - 4. Select CLONE in menu, then press F. Radio restarts in clone mode. - ("CLONE" will appear on the display). - 5. Press the [moni] key ("-RX-" will appear on the LCD).""")) +1. Turn radio off. +3. Press and hold in the [moni] key while turning the radio on. +4. Select CLONE in menu, then press F. Radio restarts in clone mode. + ("CLONE" will appear on the display). +5. Press the [moni] key ("-RX-" will appear on the LCD).""")) return rp - + def _checksums(self): - return [ yaesu_clone.YaesuChecksum(0x0000, self._memsize - 2) ] + return [yaesu_clone.YaesuChecksum(0x0000, self._memsize - 2)]
def process_mmap(self): self._memobj = bitwise.parse(MEM_FORMAT, self._mmap) diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 01d0462..10c27c2 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -23,7 +23,6 @@ ./chirp/drivers/th_uvf8d.py ./chirp/drivers/tmv71.py ./chirp/drivers/tmv71_ll.py -./chirp/drivers/vx170.py ./chirp/drivers/vx2.py ./chirp/drivers/vx3.py ./chirp/drivers/vx5.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID 0779315ceae063dfa08ee57a966fb4f103a8097c
Fix style issues in vx2.py (#2355)
diff --git a/chirp/drivers/vx2.py b/chirp/drivers/vx2.py index 42c7ba8..b7beec1 100644 --- a/chirp/drivers/vx2.py +++ b/chirp/drivers/vx2.py @@ -20,7 +20,10 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ RadioSettingValueBoolean, RadioSettingValueString, \ RadioSettings -import os, traceback, re, logging +import os +import traceback +import re +import logging
LOG = logging.getLogger(__name__)
@@ -94,7 +97,7 @@ struct { u8 mymenu; u8 unk14[4]; u8 emergmode; - + } settings;
#seekto 0x0192; @@ -168,22 +171,24 @@ struct mem_struct vfo[12]; """
VX2_DUPLEX = ["", "-", "+", "split"] -VX2_MODES = ["FM", "AM", "WFM", "Auto", "NFM"] # NFM handled specially in radio +# NFM handled specially in radio +VX2_MODES = ["FM", "AM", "WFM", "Auto", "NFM"] VX2_TMODES = ["", "Tone", "TSQL", "DTCS"]
-VX2_STEPS = [ 5.0, 10.0, 12.5, 15.0, 20.0, 25.0, 50.0, 100.0, 9.0 ] +VX2_STEPS = [5.0, 10.0, 12.5, 15.0, 20.0, 25.0, 50.0, 100.0, 9.0]
-CHARSET = list("0123456789" + \ - "ABCDEFGHIJKLMNOPQRSTUVWXYZ " + \ - "+-/\x00[](){}\x00\x00_" + \ - ("\x00" * 13) + "*" + "\x00\x00,'|\x00\x00\x00\x00" + \ - ("\x00" * 64)) +CHARSET = list("0123456789" + + "ABCDEFGHIJKLMNOPQRSTUVWXYZ " + + "+-/\x00[](){}\x00\x00_" + + ("\x00" * 13) + "*" + "\x00\x00,'|\x00\x00\x00\x00" + + ("\x00" * 64))
-DTMFCHARSET = list("0123456789ABCD*#") +DTMFCHARSET = list("0123456789ABCD*#")
POWER_LEVELS = [chirp_common.PowerLevel("High", watts=1.50), chirp_common.PowerLevel("Low", watts=0.10)]
+ class VX2BankModel(chirp_common.BankModel): """A VX-2 bank model"""
@@ -227,7 +232,7 @@ class VX2BankModel(chirp_common.BankModel):
_bank_used = self._radio._memobj.bank_used[bank.index] _bank_used.in_use = 0x0000 - + # also needed for unit to recognize banks? self._radio._memobj.banksoff1 = 0x00 self._radio._memobj.banksoff2 = 0x00 @@ -238,7 +243,7 @@ class VX2BankModel(chirp_common.BankModel): try: channels_in_bank.remove(memory.number) except KeyError: - raise Exception("Memory %i is not in bank %s. Cannot remove" % \ + raise Exception("Memory %i is not in bank %s. Cannot remove" % (memory.number, bank)) self._update_bank_with_channel_numbers(bank, channels_in_bank)
@@ -265,13 +270,14 @@ class VX2BankModel(chirp_common.BankModel): def _wipe_memory(mem): mem.set_raw("\x00" * (mem.size() / 8))
+ @directory.register class VX2Radio(yaesu_clone.YaesuCloneModeRadio): """Yaesu VX-2""" MODEL = "VX-2" _model = "AH015" BAUD_RATE = 19200 - _block_lengths = [ 10, 8, 32577 ] + _block_lengths = [10, 8, 32577] _memsize = 32595
def get_features(self): @@ -294,11 +300,11 @@ class VX2Radio(yaesu_clone.YaesuCloneModeRadio): return rf
def _checksums(self): - return [ yaesu_clone.YaesuChecksum(0x0000, 0x7F51) ] + return [yaesu_clone.YaesuChecksum(0x0000, 0x7F51)]
def process_mmap(self): self._memobj = bitwise.parse(MEM_FORMAT, self._mmap) - + def get_raw_memory(self, number): return repr(self._memobj.memory[number])
@@ -381,9 +387,9 @@ class VX2Radio(yaesu_clone.YaesuCloneModeRadio): _mem.txnarrow = False _mem.dcs = chirp_common.DTCS_CODES.index(mem.dtcs) _mem.tune_step = VX2_STEPS.index(mem.tuning_step) - if mem.power == POWER_LEVELS[1]: # Low + if mem.power == POWER_LEVELS[1]: # Low _mem.power = 0x00 - else: # Default to High + else: # Default to High _mem.power = 0x03
_flag["%s_pskip" % nibble] = mem.skip == "P" @@ -393,13 +399,14 @@ class VX2Radio(yaesu_clone.YaesuCloneModeRadio): _mem.name[i] = CHARSET.index(mem.name.ljust(6)[i]) if mem.name.strip(): # empty name field, disable name display - # leftmost bit of name chararr is: 1 = display freq, 0 = display name + # leftmost bit of name chararr is: + # 1 = display freq, 0 = display name _mem.name[0] |= 0x80 - + # for now, clear unknown fields - for i in range(1,7): + for i in range(1, 7): setattr(_mem, "unknown%i" % i, 0) - + def validate_memory(self, mem): msgs = yaesu_clone.YaesuCloneModeRadio.validate_memory(self, mem) return msgs @@ -416,8 +423,8 @@ class VX2Radio(yaesu_clone.YaesuCloneModeRadio): break outstr += CHARSET[i & 0x7F] return outstr.rstrip() - - def _encode_chars(self, instr, length = 16): + + def _encode_chars(self, instr, length=16): LOG.debug("@_encode_chars, type: %s" % type(instr)) LOG.debug(instr) outarr = [] @@ -428,7 +435,7 @@ class VX2Radio(yaesu_clone.YaesuCloneModeRadio): else: outarr.append(0xFF) return outarr - + def get_settings(self): _settings = self._memobj.settings basic = RadioSettingGroup("basic", "Basic") @@ -436,210 +443,255 @@ class VX2Radio(yaesu_clone.YaesuCloneModeRadio): arts = RadioSettingGroup("arts", "ARTS") top = RadioSettings(basic, arts, dtmf)
- options = [ "off", "30m", "1h", "3h", "5h", "8h" ] - rs = RadioSetting("apo", "APO time (hrs)", - RadioSettingValueList(options, - options[_settings.apo])) - basic.append(rs) - - rs = RadioSetting("ars", "Auto Repeater Shift", - RadioSettingValueBoolean(_settings.ars)) - basic.append(rs) - - rs = RadioSetting("att", "Attenuation", - RadioSettingValueBoolean(_settings.att)) - basic.append(rs) - - rs = RadioSetting("bclo", "Busy Channel Lockout", - RadioSettingValueBoolean(_settings.bclo)) - basic.append(rs) - - rs = RadioSetting("beep", "Beep", - RadioSettingValueBoolean(_settings.beep)) - basic.append(rs) - - options = [ "off", "1", "3", "5", "8", "cont"] - rs = RadioSetting("bell", "Bell", - RadioSettingValueList(options, - options[_settings.bell])) - basic.append(rs) - - rs = RadioSetting("busyled", "Busy LED", - RadioSettingValueBoolean(_settings.busyled)) - basic.append(rs) - - options = [ "5", "10", "50", "100" ] - rs = RadioSetting("chcounter", "Channel Counter (MHz)", - RadioSettingValueList(options, - options[_settings.chcounter])) - basic.append(rs) - - rs = RadioSetting("dcsrev", "DCS Reverse", - RadioSettingValueBoolean(_settings.dcsrev)) - basic.append(rs) - - options = map(str, range(0,12+1)) - rs = RadioSetting("dimmer", "Dimmer", - RadioSettingValueList(options, options[_settings.dimmer])) - basic.append(rs) - - rs = RadioSetting("edgebeep", "Edge Beep", - RadioSettingValueBoolean(_settings.edgebeep)) - basic.append(rs) - - options = [ "beep", "strobe", "bp+str", "beam", "bp+beam", "cw", "bp+cw" ] - rs = RadioSetting("emergmode", "Emergency Mode", - RadioSettingValueList(options, - options[_settings.emergmode])) - basic.append(rs) - + options = ["off", "30m", "1h", "3h", "5h", "8h"] + rs = RadioSetting( + "apo", "APO time (hrs)", + RadioSettingValueList(options, options[_settings.apo])) + basic.append(rs) + + rs = RadioSetting( + "ars", "Auto Repeater Shift", + RadioSettingValueBoolean(_settings.ars)) + basic.append(rs) + + rs = RadioSetting( + "att", "Attenuation", + RadioSettingValueBoolean(_settings.att)) + basic.append(rs) + + rs = RadioSetting( + "bclo", "Busy Channel Lockout", + RadioSettingValueBoolean(_settings.bclo)) + basic.append(rs) + + rs = RadioSetting( + "beep", "Beep", + RadioSettingValueBoolean(_settings.beep)) + basic.append(rs) + + options = ["off", "1", "3", "5", "8", "cont"] + rs = RadioSetting( + "bell", "Bell", + RadioSettingValueList(options, options[_settings.bell])) + basic.append(rs) + + rs = RadioSetting( + "busyled", "Busy LED", + RadioSettingValueBoolean(_settings.busyled)) + basic.append(rs) + + options = ["5", "10", "50", "100"] + rs = RadioSetting( + "chcounter", "Channel Counter (MHz)", + RadioSettingValueList(options, options[_settings.chcounter])) + basic.append(rs) + + rs = RadioSetting( + "dcsrev", "DCS Reverse", + RadioSettingValueBoolean(_settings.dcsrev)) + basic.append(rs) + + options = map(str, range(0, 12+1)) + rs = RadioSetting( + "dimmer", "Dimmer", + RadioSettingValueList(options, options[_settings.dimmer])) + basic.append(rs) + + rs = RadioSetting( + "edgebeep", "Edge Beep", + RadioSettingValueBoolean(_settings.edgebeep)) + basic.append(rs) + + options = ["beep", "strobe", "bp+str", "beam", + "bp+beam", "cw", "bp+cw"] + rs = RadioSetting( + "emergmode", "Emergency Mode", + RadioSettingValueList(options, options[_settings.emergmode])) + basic.append(rs) + options = ["Home", "Reverse"] - rs = RadioSetting("hmrv", "HM/RV key", - RadioSettingValueList(options, options[_settings.hmrv])) + rs = RadioSetting( + "hmrv", "HM/RV key", + RadioSettingValueList(options, options[_settings.hmrv])) basic.append(rs) - + options = ["My Menu", "Internet"] - rs = RadioSetting("internet_key", "Internet key", - RadioSettingValueList(options, options[_settings.internet_key])) - basic.append(rs) - - options = ["1 APO","2 AR BEP","3 AR INT","4 ARS","5 ATT","6 BCLO","7 BEEP","8 BELL", - "9 BSYLED","10 CH CNT","11 CK SFT","12 CW ID","13 DC VLT","14 DCS CD","15 DCS RV", - "16 DIMMER","17 DTMF","18 DTMF S","19 EDG BP","20 EMG S","21 HLFDEV","22 HM/RV", - "23 INT MD","24 LAMP","25 LOCK","26 M/T-CL","27 MW MD","28 NAME","29 NM SET", - "30 OPNMSG","31 RESUME","32 RF SQL","33 RPT","34 RX MD","35 RXSAVE","36 S SCH", - "37 SCNLMP","38 SHIFT","39 SKIP","40 SPLIT","41 SQL","42 SQL TYP","43 STEP", - "44 TN FRQ","45 TOT","46 TXSAVE","47 VFO MD", "48 TR SQL (JAPAN)", "48 WX ALT"] - - rs = RadioSetting("mymenu", "My Menu function", - RadioSettingValueList(options, options[_settings.mymenu - 9])) - basic.append(rs) - + rs = RadioSetting( + "internet_key", "Internet key", + RadioSettingValueList( + options, options[_settings.internet_key])) + basic.append(rs) + + options = ["1 APO", "2 AR BEP", "3 AR INT", "4 ARS", "5 ATT", + "6 BCLO", "7 BEEP", "8 BELL", "9 BSYLED", "10 CH CNT", + "11 CK SFT", "12 CW ID", "13 DC VLT", "14 DCS CD", + "15 DCS RV", "16 DIMMER", "17 DTMF", "18 DTMF S", + "19 EDG BP", "20 EMG S", "21 HLFDEV", "22 HM/RV", + "23 INT MD", "24 LAMP", "25 LOCK", "26 M/T-CL", + "27 MW MD", "28 NAME", "29 NM SET", "30 OPNMSG", + "31 RESUME", "32 RF SQL", "33 RPT", "34 RX MD", + "35 RXSAVE", "36 S SCH", "37 SCNLMP", "38 SHIFT", + "39 SKIP", "40 SPLIT", "41 SQL", "42 SQL TYP", + "43 STEP", "44 TN FRQ", "45 TOT", "46 TXSAVE", + "47 VFO MD", "48 TR SQL (JAPAN)", "48 WX ALT"] + + rs = RadioSetting( + "mymenu", "My Menu function", + RadioSettingValueList(options, options[_settings.mymenu - 9])) + basic.append(rs) + options = ["wires", "link"] - rs = RadioSetting("internet_mode", "Internet mode", - RadioSettingValueList(options, options[_settings.internet_mode])) + rs = RadioSetting( + "internet_mode", "Internet mode", + RadioSettingValueList( + options, options[_settings.internet_mode])) basic.append(rs) - + options = ["key", "cont", "off"] - rs = RadioSetting("lamp", "Lamp mode", - RadioSettingValueList(options, options[_settings.lamp])) + rs = RadioSetting( + "lamp", "Lamp mode", + RadioSettingValueList(options, options[_settings.lamp])) basic.append(rs) - - options = ["key", "dial", "key+dial", "ptt", "key+ptt", "dial+ptt", "all"] - rs = RadioSetting("lock", "Lock mode", - RadioSettingValueList(options, options[_settings.lock])) + + options = ["key", "dial", "key+dial", "ptt", + "key+ptt", "dial+ptt", "all"] + rs = RadioSetting( + "lock", "Lock mode", + RadioSettingValueList(options, options[_settings.lock])) basic.append(rs) - + options = ["monitor", "tone call"] - rs = RadioSetting("moni_tcall", "MONI key", - RadioSettingValueList(options, options[_settings.moni_tcall])) + rs = RadioSetting( + "moni_tcall", "MONI key", + RadioSettingValueList(options, options[_settings.moni_tcall])) basic.append(rs) - + options = ["lower", "next"] - rs = RadioSetting("mwmode", "Memory write mode", - RadioSettingValueList(options, options[_settings.mwmode])) + rs = RadioSetting( + "mwmode", "Memory write mode", + RadioSettingValueList(options, options[_settings.mwmode])) basic.append(rs) - - options = map(str, range(0,15+1)) - rs = RadioSetting("nfm_sql", "NFM Sql", - RadioSettingValueList(options, options[_settings.nfm_sql])) + + options = map(str, range(0, 15+1)) + rs = RadioSetting( + "nfm_sql", "NFM Sql", + RadioSettingValueList(options, options[_settings.nfm_sql])) basic.append(rs) - - options = map(str, range(0,8+1)) - rs = RadioSetting("wfm_sql", "WFM Sql", - RadioSettingValueList(options, options[_settings.wfm_sql])) + + options = map(str, range(0, 8+1)) + rs = RadioSetting( + "wfm_sql", "WFM Sql", + RadioSettingValueList(options, options[_settings.wfm_sql])) basic.append(rs) - + options = ["off", "dc", "msg"] - rs = RadioSetting("openmsgmode", "Opening message", - RadioSettingValueList(options, options[_settings.openmsgmode])) + rs = RadioSetting( + "openmsgmode", "Opening message", + RadioSettingValueList(options, options[_settings.openmsgmode])) basic.append(rs) - - openmsg = RadioSettingValueString(0, 6, self._decode_chars(_settings.openmsg.get_value())) + + openmsg = RadioSettingValueString( + 0, 6, self._decode_chars(_settings.openmsg.get_value())) openmsg.set_charset(CHARSET) rs = RadioSetting("openmsg", "Opening Message", openmsg) - basic.append(rs) - - options = ["3s","5s","10s","busy","hold"] - rs = RadioSetting("resume", "Resume", - RadioSettingValueList(options, options[_settings.resume])) - basic.append(rs) - - options = ["off"] + map(str,range(1,9+1)) - rs = RadioSetting("rfsql", "RF Sql", - RadioSettingValueList(options,options[_settings.rfsql])) - basic.append(rs) - - options = ["off","200ms","300ms","500ms","1s","2s"] - rs = RadioSetting("rxsave", "RX pwr save", - RadioSettingValueList(options, options[_settings.rxsave])) - basic.append(rs) - - options = ["single","cont"] - rs = RadioSetting("smartsearch", "Smart search", - RadioSettingValueList(options, options[_settings.smartsearch])) - basic.append(rs) - - rs = RadioSetting("scan_lamp", "Scan lamp", - RadioSettingValueBoolean(_settings.scan_lamp)) - basic.append(rs) - - rs = RadioSetting("split", "Split", - RadioSettingValueBoolean(_settings.split)) - basic.append(rs) - - options = ["off","1","3","5","10"] - rs = RadioSetting("tot", "TOT (mins)", - RadioSettingValueList(options, options[_settings.tot])) - basic.append(rs) - - rs = RadioSetting("txsave", "TX pwr save", - RadioSettingValueBoolean(_settings.txsave)) - basic.append(rs) - + basic.append(rs) + + options = ["3s", "5s", "10s", "busy", "hold"] + rs = RadioSetting( + "resume", "Resume", + RadioSettingValueList(options, options[_settings.resume])) + basic.append(rs) + + options = ["off"] + map(str, range(1, 9+1)) + rs = RadioSetting( + "rfsql", "RF Sql", + RadioSettingValueList(options, options[_settings.rfsql])) + basic.append(rs) + + options = ["off", "200ms", "300ms", "500ms", "1s", "2s"] + rs = RadioSetting( + "rxsave", "RX pwr save", + RadioSettingValueList(options, options[_settings.rxsave])) + basic.append(rs) + + options = ["single", "cont"] + rs = RadioSetting( + "smartsearch", "Smart search", + RadioSettingValueList(options, options[_settings.smartsearch])) + basic.append(rs) + + rs = RadioSetting( + "scan_lamp", "Scan lamp", + RadioSettingValueBoolean(_settings.scan_lamp)) + basic.append(rs) + + rs = RadioSetting( + "split", "Split", + RadioSettingValueBoolean(_settings.split)) + basic.append(rs) + + options = ["off", "1", "3", "5", "10"] + rs = RadioSetting( + "tot", "TOT (mins)", + RadioSettingValueList(options, options[_settings.tot])) + basic.append(rs) + + rs = RadioSetting( + "txsave", "TX pwr save", + RadioSettingValueBoolean(_settings.txsave)) + basic.append(rs) + options = ["all", "band"] - rs = RadioSetting("vfomode", "VFO mode", - RadioSettingValueList(options, options[_settings.vfomode])) - basic.append(rs) - - rs = RadioSetting("wx_alert", "WX Alert", - RadioSettingValueBoolean(_settings.wx_alert)) - basic.append(rs) - - #todo: priority channel - - #todo: handle WX ch labels - + rs = RadioSetting( + "vfomode", "VFO mode", + RadioSettingValueList(options, options[_settings.vfomode])) + basic.append(rs) + + rs = RadioSetting( + "wx_alert", "WX Alert", + RadioSettingValueBoolean(_settings.wx_alert)) + basic.append(rs) + + # todo: priority channel + + # todo: handle WX ch labels + # arts settings (ar beep, ar int, cwid en, cwid field) options = ["15s", "25s"] - rs = RadioSetting("artsinterval", "ARTS Interval", - RadioSettingValueList(options, options[_settings.artsinterval])) + rs = RadioSetting( + "artsinterval", "ARTS Interval", + RadioSettingValueList( + options, options[_settings.artsinterval])) arts.append(rs) - + options = ["off", "in range", "always"] - rs = RadioSetting("artsbeep", "ARTS Beep", - RadioSettingValueList(options, options[_settings.artsbeep])) + rs = RadioSetting( + "artsbeep", "ARTS Beep", + RadioSettingValueList(options, options[_settings.artsbeep])) arts.append(rs) - - rs = RadioSetting("cwid_en", "CWID Enable", - RadioSettingValueBoolean(_settings.cwid_en)) + + rs = RadioSetting( + "cwid_en", "CWID Enable", + RadioSettingValueBoolean(_settings.cwid_en)) arts.append(rs) - - cwid = RadioSettingValueString(0, 16, self._decode_chars(_settings.cwid.get_value())) + + cwid = RadioSettingValueString( + 0, 16, self._decode_chars(_settings.cwid.get_value())) cwid.set_charset(CHARSET) rs = RadioSetting("cwid", "CWID", cwid) arts.append(rs) - + # setup dtmf options = ["manual", "auto"] - rs = RadioSetting("dtmfmode", "DTMF mode", - RadioSettingValueList(options, options[_settings.dtmfmode])) + rs = RadioSetting( + "dtmfmode", "DTMF mode", + RadioSettingValueList(options, options[_settings.dtmfmode])) dtmf.append(rs) - - for i in range(0,8+1): + + for i in range(0, 8+1): name = "dtmf" + str(i+1) dtmfsetting = self._memobj.dtmf[i] - #dtmflen = getattr(_settings, objname + "_len") + # dtmflen = getattr(_settings, objname + "_len") dtmfstr = "" for c in dtmfsetting.digits: if c < len(DTMFCHARSET): @@ -648,10 +700,10 @@ class VX2Radio(yaesu_clone.YaesuCloneModeRadio): dtmfentry = RadioSettingValueString(0, 16, dtmfstr) dtmfentry.set_charset(DTMFCHARSET + list(" ")) rs = RadioSetting(name, name.upper(), dtmfentry) - dtmf.append(rs) - + dtmf.append(rs) + return top - + def set_settings(self, uisettings): for element in uisettings: if not isinstance(element, RadioSetting): @@ -666,7 +718,7 @@ class VX2Radio(yaesu_clone.YaesuCloneModeRadio): # set dtmf fields dtmfstr = str(element.value).strip() newval = [] - for i in range(0,16): + for i in range(0, 16): if i < len(dtmfstr): newval.append(DTMFCHARSET.index(dtmfstr[i])) else: @@ -679,13 +731,13 @@ class VX2Radio(yaesu_clone.YaesuCloneModeRadio): if setting == "prioritychan": # prioritychan is top-level member, fix 0 index element.value -= 1 - _settings = self._memobj + _settings = self._memobj if setting == "mymenu": - opts = element.value.get_options() + opts = element.value.get_options() optsidx = opts.index(element.value.get_value()) - idx = optsidx + 9 + idx = optsidx + 9 setattr(_settings, "mymenu", idx) - continue + continue oldval = getattr(_settings, setting) newval = element.value if setting == "cwid": @@ -697,5 +749,3 @@ class VX2Radio(yaesu_clone.YaesuCloneModeRadio): except Exception, e: print element.get_name() raise - - diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 10c27c2..4174064 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -23,7 +23,6 @@ ./chirp/drivers/th_uvf8d.py ./chirp/drivers/tmv71.py ./chirp/drivers/tmv71_ll.py -./chirp/drivers/vx2.py ./chirp/drivers/vx3.py ./chirp/drivers/vx5.py ./chirp/drivers/vx510.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID 79edc144ef3b7b06edd6464c964322c598a0c60f
Fix style issues in vx3.py (#2355)
diff --git a/chirp/drivers/vx3.py b/chirp/drivers/vx3.py index 6bd2973..b18e056 100644 --- a/chirp/drivers/vx3.py +++ b/chirp/drivers/vx3.py @@ -21,15 +21,17 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueBoolean, RadioSettingValueString, \ RadioSettings from textwrap import dedent -import os, re, logging +import os +import re +import logging
LOG = logging.getLogger(__name__)
-#interesting offsets which may be checksums needed later -#0x0393 checksum1? -#0x0453 checksum1a? -#0x0409 checksum2? -#0x04C9 checksum2a? +# interesting offsets which may be checksums needed later +# 0x0393 checksum1? +# 0x0453 checksum1a? +# 0x0409 checksum2? +# 0x04C9 checksum2a?
MEM_FORMAT = """ #seekto 0x7F4A; @@ -45,7 +47,7 @@ struct { u8 unk02; u8 apo; u8 arts_beep; - u8 unk04_1; + u8 unk04_1; u8 beep_level; u8 beep_mode; u8 unk04_2; @@ -212,33 +214,34 @@ struct { } memory[999]; """
-#fix auto mode setting and auto step setting +# fix auto mode setting and auto step setting
DUPLEX = ["", "-", "+", "split"] -MODES = ["FM", "AM", "WFM", "Auto", "NFM"] # NFM handled specially in radio +MODES = ["FM", "AM", "WFM", "Auto", "NFM"] # NFM handled specially in radio TMODES = ["", "Tone", "TSQL", "DTCS"] -## TODO: TMODES = ["", "Tone, "TSQL", "DTCS", "Rev Tone", "User Tone", "Pager", -## "Message", "D Code", "Tone/DTCS", "DTCS/Tone"] - -#still need to verify 9 is correct, and add auto: look at byte 1 and 20 -STEPS = [ 5.0, 9, 10.0, 12.5, 15.0, 20.0, 25.0, 50.0, 100.0 ] -#STEPS = list(chirp_common.TUNING_STEPS) -#STEPS.remove(6.25) -#STEPS.remove(30.0) -#STEPS.append(100.0) -#STEPS.append(9.0) #this fails because 9 is out of order in the list - -#Empty char should be 0xFF but right now we are coding in a space -CHARSET = list("0123456789" + \ - "ABCDEFGHIJKLMNOPQRSTUVWXYZ " + \ - "+-/\x00[](){}\x00\x00_" + \ - ("\x00" * 13) + "*" + "\x00\x00,'|\x00\x00\x00\x00" + \ - ("\x00" * 64)) - -DTMFCHARSET = list("0123456789ABCD*#") +# TODO: TMODES = ["", "Tone, "TSQL", "DTCS", "Rev Tone", "User Tone", "Pager", +# "Message", "D Code", "Tone/DTCS", "DTCS/Tone"] + +# still need to verify 9 is correct, and add auto: look at byte 1 and 20 +STEPS = [5.0, 9, 10.0, 12.5, 15.0, 20.0, 25.0, 50.0, 100.0] +# STEPS = list(chirp_common.TUNING_STEPS) +# STEPS.remove(6.25) +# STEPS.remove(30.0) +# STEPS.append(100.0) +# STEPS.append(9.0) #this fails because 9 is out of order in the list + +# Empty char should be 0xFF but right now we are coding in a space +CHARSET = list("0123456789" + + "ABCDEFGHIJKLMNOPQRSTUVWXYZ " + + "+-/\x00[](){}\x00\x00_" + + ("\x00" * 13) + "*" + "\x00\x00,'|\x00\x00\x00\x00" + + ("\x00" * 64)) + +DTMFCHARSET = list("0123456789ABCD*#") POWER_LEVELS = [chirp_common.PowerLevel("High", watts=1.50), chirp_common.PowerLevel("Low", watts=0.10)]
+ class VX3Bank(chirp_common.NamedBank): """A VX3 Bank""" def get_name(self): @@ -255,6 +258,7 @@ class VX3Bank(chirp_common.NamedBank): _bank = self._model._radio._memobj.bank_names[self.index] _bank.name = [CHARSET.index(x) for x in name.ljust(6)[:6]]
+ class VX3BankModel(chirp_common.BankModel): """A VX-3 bank model"""
@@ -303,7 +307,7 @@ class VX3BankModel(chirp_common.BankModel): try: channels_in_bank.remove(memory.number) except KeyError: - raise Exception("Memory %i is not in bank %s. Cannot remove" % \ + raise Exception("Memory %i is not in bank %s. Cannot remove" % (memory.number, bank)) self._update_bank_with_channel_numbers(bank, channels_in_bank)
@@ -326,15 +330,17 @@ class VX3BankModel(chirp_common.BankModel):
return banks
+ def _wipe_memory(mem): mem.set_raw("\x00" * (mem.size() / 8)) - #the following settings are set to match the defaults - #on the radio, some of these fields are unknown + # the following settings are set to match the defaults + # on the radio, some of these fields are unknown mem.name = [0xFF for _i in range(0, 6)] - mem.unknown5 = 0x0D #not sure what this is + mem.unknown5 = 0x0D # not sure what this is mem.unknown7a = 0b0 mem.unknown7b = 0b1 - mem.automode = 0x01 #autoselect mode + mem.automode = 0x01 # autoselect mode +
@directory.register class VX3Radio(yaesu_clone.YaesuCloneModeRadio): @@ -346,29 +352,29 @@ class VX3Radio(yaesu_clone.YaesuCloneModeRadio): # 41 48 30 32 38 _model = "AH028" _memsize = 32587 - _block_lengths = [ 10, 32577 ] - #right now this reads in 45 seconds and writes in 41 seconds + _block_lengths = [10, 32577] + # right now this reads in 45 seconds and writes in 41 seconds _block_size = 32
@classmethod def get_prompts(cls): rp = chirp_common.RadioPrompts() rp.pre_download = _(dedent("""\ - 1. Turn radio off. - 2. Connect cable to MIC/SP jack. - 3. Press and hold in the [F/W] key while turning the radio on - ("CLONE" will appear on the display). - 4. <b>After clicking OK</b>, press the [BAND] key to send image.""")) +1. Turn radio off. +2. Connect cable to MIC/SP jack. +3. Press and hold in the [F/W] key while turning the radio on + ("CLONE" will appear on the display). +4. <b>After clicking OK</b>, press the [BAND] key to send image.""")) rp.pre_upload = _(dedent("""\ - 1. Turn radio off. - 2. Connect cable to MIC/SP jack. - 3. Press and hold in the [F/W] key while turning the radio on - ("CLONE" will appear on the display). - 4. Press the [V/M] key ("-WAIT-" will appear on the LCD).""")) +1. Turn radio off. +2. Connect cable to MIC/SP jack. +3. Press and hold in the [F/W] key while turning the radio on + ("CLONE" will appear on the display). +4. Press the [V/M] key ("-WAIT-" will appear on the LCD).""")) return rp - + def _checksums(self): - return [ yaesu_clone.YaesuChecksum(0x0000, 0x7F49) ] + return [yaesu_clone.YaesuChecksum(0x0000, 0x7F49)]
def process_mmap(self): self._memobj = bitwise.parse(MEM_FORMAT, self._mmap) @@ -426,7 +432,7 @@ class VX3Radio(yaesu_clone.YaesuCloneModeRadio): if _mem.txnarrow and _mem.mode == MODES.index("FM"): # FM narrow mem.mode = "NFM" - else: + else: mem.mode = MODES[_mem.mode] mem.dtcs = chirp_common.DTCS_CODES[_mem.dcs] mem.tuning_step = STEPS[_mem.tune_step] @@ -445,7 +451,7 @@ class VX3Radio(yaesu_clone.YaesuCloneModeRadio): _flag = self._memobj.flags[(mem.number-1)/2]
nibble = ((mem.number-1) % 2) and "even" or "odd" - + used = _flag["%s_masked" % nibble] valid = _flag["%s_valid" % nibble]
@@ -475,9 +481,9 @@ class VX3Radio(yaesu_clone.YaesuCloneModeRadio): _mem.txnarrow = False _mem.dcs = chirp_common.DTCS_CODES.index(mem.dtcs) _mem.tune_step = STEPS.index(mem.tuning_step) - if mem.power == POWER_LEVELS[1]: # Low + if mem.power == POWER_LEVELS[1]: # Low _mem.power = 0x00 - else: # Default to High + else: # Default to High _mem.power = 0x03
_flag["%s_pskip" % nibble] = mem.skip == "P" @@ -487,7 +493,7 @@ class VX3Radio(yaesu_clone.YaesuCloneModeRadio): _mem.name[i] = CHARSET.index(mem.name.ljust(6)[i]) if mem.name.strip(): _mem.name[0] |= 0x80 - + def validate_memory(self, mem): msgs = yaesu_clone.YaesuCloneModeRadio.validate_memory(self, mem) return msgs @@ -504,8 +510,8 @@ class VX3Radio(yaesu_clone.YaesuCloneModeRadio): break outstr += CHARSET[i & 0x7F] return outstr.rstrip() - - def _encode_chars(self, instr, length = 16): + + def _encode_chars(self, instr, length=16): LOG.debug("@_encode_chars, type: %s" % type(instr)) LOG.debug(instr) outarr = [] @@ -516,7 +522,7 @@ class VX3Radio(yaesu_clone.YaesuCloneModeRadio): else: outarr.append(0xFF) return outarr - + def get_settings(self): _settings = self._memobj.settings basic = RadioSettingGroup("basic", "Basic") @@ -528,186 +534,233 @@ class VX3Radio(yaesu_clone.YaesuCloneModeRadio):
top = RadioSettings(basic, sound, arts, dtmf, eai, msg)
- basic.append( RadioSetting("att_wx", "Attenuation WX", + basic.append(RadioSetting( + "att_wx", "Attenuation WX", RadioSettingValueBoolean(_settings.att_wx)))
- basic.append( RadioSetting("att_marine", "Attenuation Marine", + basic.append(RadioSetting( + "att_marine", "Attenuation Marine", RadioSettingValueBoolean(_settings.att_marine)))
- basic.append( RadioSetting("att_broadcast", "Attenuation Broadcast", + basic.append(RadioSetting( + "att_broadcast", "Attenuation Broadcast", RadioSettingValueBoolean(_settings.att_broadcast)))
- basic.append( RadioSetting("ars", "Auto Repeater Shift", + basic.append(RadioSetting( + "ars", "Auto Repeater Shift", RadioSettingValueBoolean(_settings.ars))) - - basic.append( RadioSetting("home_vfo", "Home->VFO", + + basic.append(RadioSetting( + "home_vfo", "Home->VFO", RadioSettingValueBoolean(_settings.home_vfo))) - - basic.append( RadioSetting("bclo", "Busy Channel Lockout", + + basic.append(RadioSetting( + "bclo", "Busy Channel Lockout", RadioSettingValueBoolean(_settings.bclo)))
- basic.append( RadioSetting("busyled", "Busy LED", + basic.append(RadioSetting( + "busyled", "Busy LED", RadioSettingValueBoolean(_settings.busy_led)))
- basic.append( RadioSetting("fast_tone_search", "Fast Tone search", + basic.append(RadioSetting( + "fast_tone_search", "Fast Tone search", RadioSettingValueBoolean(_settings.fast_tone_search)))
- basic.append( RadioSetting("priority_revert", "Priority Revert", + basic.append(RadioSetting( + "priority_revert", "Priority Revert", RadioSettingValueBoolean(_settings.priority_revert)))
- basic.append( RadioSetting("protect_memory", "Protect memory", + basic.append(RadioSetting( + "protect_memory", "Protect memory", RadioSettingValueBoolean(_settings.protect_memory)))
- basic.append( RadioSetting("scan_lamp", "Scan Lamp", + basic.append(RadioSetting( + "scan_lamp", "Scan Lamp", RadioSettingValueBoolean(_settings.scan_lamp)))
- basic.append( RadioSetting("split_tone", "Split tone", + basic.append(RadioSetting( + "split_tone", "Split tone", RadioSettingValueBoolean(_settings.split_tone)))
- basic.append( RadioSetting("tone_search_mute", "Tone search mute", + basic.append(RadioSetting( + "tone_search_mute", "Tone search mute", RadioSettingValueBoolean(_settings.tone_search_mute)))
- basic.append( RadioSetting("txsave", "TX save", + basic.append(RadioSetting( + "txsave", "TX save", RadioSettingValueBoolean(_settings.txsave)))
- basic.append( RadioSetting("wx_alert", "WX Alert", + basic.append(RadioSetting( + "wx_alert", "WX Alert", RadioSettingValueBoolean(_settings.wx_alert)))
opts = ["Bar Int", "Bar Ext"] - basic.append( RadioSetting("am_antenna", "AM antenna", + basic.append(RadioSetting( + "am_antenna", "AM antenna", RadioSettingValueList(opts, opts[_settings.am_antenna])))
opts = ["Ext Ant", "Earphone"] - basic.append( RadioSetting("fm_antenna", "FM antenna", + basic.append(RadioSetting( + "fm_antenna", "FM antenna", RadioSettingValueList(opts, opts[_settings.fm_antenna])))
- opts = ["off"] + [ "%0.1f" % (t / 60.0) for t in range(30, 750, 30) ] - basic.append( RadioSetting("apo", "APO time (hrs)", + opts = ["off"] + ["%0.1f" % (t / 60.0) for t in range(30, 750, 30)] + basic.append(RadioSetting( + "apo", "APO time (hrs)", RadioSettingValueList(opts, opts[_settings.apo]))) - + opts = ["+/- 5 MHZ", "+/- 10 MHZ", "+/- 50 MHZ", "+/- 100 MHZ"] - basic.append( RadioSetting("channel_counter", "Channel counter", + basic.append(RadioSetting( + "channel_counter", "Channel counter", RadioSettingValueList(opts, opts[_settings.channel_counter])))
opts = ["0.3", "0.5", "0.7", "1.0", "1.5"] - basic.append( RadioSetting("fw_key_timer", "FW key timer (s)", + basic.append(RadioSetting( + "fw_key_timer", "FW key timer (s)", RadioSettingValueList(opts, opts[_settings.fw_key_timer])))
opts = ["Home", "Reverse"] - basic.append( RadioSetting("hm_rv", "HM/RV key", + basic.append(RadioSetting( + "hm_rv", "HM/RV key", RadioSettingValueList(opts, opts[_settings.hm_rv])))
- opts = [ "%d" % t for t in range(2, 11) ] + ["continuous", "off"] - basic.append( RadioSetting("lamp", "Lamp Timer (s)", + opts = ["%d" % t for t in range(2, 11)] + ["continuous", "off"] + basic.append(RadioSetting( + "lamp", "Lamp Timer (s)", RadioSettingValueList(opts, opts[_settings.lamp])))
- basic.append( RadioSetting("lock", "Lock", - RadioSettingValueBoolean(_settings.lock))) + basic.append(RadioSetting( + "lock", "Lock", + RadioSettingValueBoolean(_settings.lock)))
opts = ["key", "ptt", "key+ptt"] - basic.append( RadioSetting("lock_mode", "Lock mode", - RadioSettingValueList(opts, opts[_settings.lock_mode]))) + basic.append(RadioSetting( + "lock_mode", "Lock mode", + RadioSettingValueList(opts, opts[_settings.lock_mode])))
opts = ["10", "20", "50", "100"] - basic.append( RadioSetting("mem_ch_step", "Memory Chan step", + basic.append(RadioSetting( + "mem_ch_step", "Memory Chan step", RadioSettingValueList(opts, opts[_settings.mem_ch_step])))
opts = ["lower", "next"] - basic.append( RadioSetting("mem_storage", "Memory storage mode", + basic.append(RadioSetting( + "mem_storage", "Memory storage mode", RadioSettingValueList(opts, opts[_settings.mem_storage])))
- opts = [ "%d" % t for t in range(1, 10) ] - basic.append( RadioSetting("mic_gain", "Mic gain", + opts = ["%d" % t for t in range(1, 10)] + basic.append(RadioSetting( + "mic_gain", "Mic gain", RadioSettingValueList(opts, opts[_settings.mic_gain])))
opts = ["monitor", "tone call"] - basic.append( RadioSetting("moni_tcall", "Moni/TCall button", + basic.append(RadioSetting( + "moni_tcall", "Moni/TCall button", RadioSettingValueList(opts, opts[_settings.moni_tcall])))
opts = ["off"] + \ - [ "%02d:%02d" % (t / 60, t % 60) for t in range(10, 1450, 10) ] - basic.append( RadioSetting("on_timer", "On Timer (hrs)", + ["%02d:%02d" % (t / 60, t % 60) for t in range(10, 1450, 10)] + basic.append(RadioSetting( + "on_timer", "On Timer (hrs)", RadioSettingValueList(opts, opts[_settings.on_timer])))
opts2 = ["off"] + \ - [ "0.%d" % t for t in range(1, 10) ] + \ - [ "%1.1f" % (t / 10.0) for t in range(10, 105, 5) ] - basic.append( RadioSetting("priority_time", "Priority time", + ["0.%d" % t for t in range(1, 10)] + \ + ["%1.1f" % (t / 10.0) for t in range(10, 105, 5)] + basic.append(RadioSetting( + "priority_time", "Priority time", RadioSettingValueList(opts2, opts2[_settings.priority_time]))) - + opts = ["off", "20", "50", "100", "200"] - basic.append( RadioSetting("ptt_delay", "PTT delay (ms)", + basic.append(RadioSetting( + "ptt_delay", "PTT delay (ms)", RadioSettingValueList(opts, opts[_settings.ptt_delay])))
- basic.append( RadioSetting("rx_save", "RX save (s)", + basic.append(RadioSetting( + "rx_save", "RX save (s)", RadioSettingValueList(opts2, opts2[_settings.rx_save])))
- basic.append( RadioSetting("scan_restart", "Scan restart (s)", + basic.append(RadioSetting( + "scan_restart", "Scan restart (s)", RadioSettingValueList(opts2, opts2[_settings.scan_restart])))
- opts = [ "%1.1f" % (t / 10.0) for t in range(20, 105, 5) ] + \ - ["busy", "hold"] - basic.append( RadioSetting("scan_resume", "Scan resume (s)", + opts = ["%1.1f" % (t / 10.0) for t in range(20, 105, 5)] + \ + ["busy", "hold"] + basic.append(RadioSetting( + "scan_resume", "Scan resume (s)", RadioSettingValueList(opts, opts[_settings.scan_resume])))
opts = ["single", "continuous"] - basic.append( RadioSetting("smart_search", "Smart search", + basic.append(RadioSetting( + "smart_search", "Smart search", RadioSettingValueList(opts, opts[_settings.smart_search]))) - - opts = ["off"] + [ "TRX %d" % t for t in range(1, 11)] + ["hold"] + \ - [ "TX %d" % t for t in range(1, 11)] - basic.append( RadioSetting("sub_rx_timer", "Sub RX timer", + + opts = ["off"] + ["TRX %d" % t for t in range(1, 11)] + ["hold"] + \ + ["TX %d" % t for t in range(1, 11)] + basic.append(RadioSetting( + "sub_rx_timer", "Sub RX timer", RadioSettingValueList(opts, opts[_settings.sub_rx_timer])))
opts = ["C", "F"] - basic.append( RadioSetting("temp_unit", "Temperature unit", + basic.append(RadioSetting( + "temp_unit", "Temperature unit", RadioSettingValueList(opts, opts[_settings.temp_unit])))
- opts = ["off"] + [ "%1.1f" % (t / 10.0) for t in range(5, 105, 5) ] - basic.append( RadioSetting("tot", "Time-out timer (mins)", + opts = ["off"] + ["%1.1f" % (t / 10.0) for t in range(5, 105, 5)] + basic.append(RadioSetting( + "tot", "Time-out timer (mins)", RadioSettingValueList(opts, opts[_settings.tot])))
opts = ["all", "band"] - basic.append( RadioSetting("vfo_mode", "VFO mode", + basic.append(RadioSetting( + "vfo_mode", "VFO mode", RadioSettingValueList(opts, opts[_settings.vfo_mode])))
- opts = ["off"] + [ "%d" % t for t in range(5, 65, 5) ] + ["EAI"] - basic.append( RadioSetting("wake_up", "Wake up (s)", + opts = ["off"] + ["%d" % t for t in range(5, 65, 5)] + ["EAI"] + basic.append(RadioSetting( + "wake_up", "Wake up (s)", RadioSettingValueList(opts, opts[_settings.wake_up])))
opts = ["hold", "3 secs"] - basic.append( RadioSetting("vol_key_mode", "Volume key mode", + basic.append(RadioSetting( + "vol_key_mode", "Volume key mode", RadioSettingValueList(opts, opts[_settings.vol_key_mode]))) - + # subgroup programmable keys
opts = ["INTNET", "INT MR", "Set Mode (my key)"] - basic.append( RadioSetting("internet_key", "Internet key", + basic.append(RadioSetting( + "internet_key", "Internet key", RadioSettingValueList(opts, opts[_settings.internet_key])))
- keys = [ "Antenna AM", "Antenna FM", "Antenna Attenuator", "Auto Power Off", - "Auto Repeater Shift", "ARTS Beep", "ARTS Interval", "Busy Channel Lockout", - "Bell Ringer", "Bell Select", "Bank Name", "Band Edge Beep", "Beep Level", - "Beep Select", "Beep User", "Busy LED", "Channel Counter", "Clock Shift", - "CW ID", "CW Learning", "CW Pitch", "CW Training", "DC Voltage", - "DCS Code", "DCS Reverse", "DTMF A/M", "DTMF Delay", "DTMF Set", - "DTMF Speed", "EAI Timer", "Emergency Alarm", "Ext Menu", "FW Key", - "Half Deviation", "Home/Reverse", "Home > VFO", "INT Code", - "INT Conn Mode", "INT A/M", "INT Set", "INT Key", "INTNET", "Lamp", - "LED Light", "Lock", "Moni/T-Call", "Mic Gain", "Memory Display", - "Memory Write Mode", "Memory Channel Step", "Memory Name Write", - "Memory Protect", "Memory Skip", "Message List", "Message Reg", - "Message Set", "On Timer", "Open Message", "Pager Answer Back", - "Pager Receive Code", "Pager Transmit Code", "Pager Frequency", - "Priority Revert", "Priority Timer", "Password", "PTT Delay", - "Repeater Shift Direction", "Repeater Shift", "Receive Mode", - "Smart Search", "Save Rx", "Save Tx", "Scan Lamp", "Scan Resume", - "Scan Restart", "Speaker Out", "Squelch Level", "Squelch Type", - "Squelch S Meter", "Squelch Split Tone", "Step", "Stereo", "Sub Rx", - "Temp", "Tone Frequency", "Time Out Timer", "Tone Search Mute", - "Tone Search Speed", "VFO Band", "VFO Skip", "Volume Mode", "Wake Up", - "Weather Alert" ] - rs = RadioSetting("my_key", "My key", + keys = ["Antenna AM", "Antenna FM", "Antenna Attenuator", + "Auto Power Off", "Auto Repeater Shift", "ARTS Beep", + "ARTS Interval", "Busy Channel Lockout", "Bell Ringer", + "Bell Select", "Bank Name", "Band Edge Beep", "Beep Level", + "Beep Select", "Beep User", "Busy LED", "Channel Counter", + "Clock Shift", "CW ID", "CW Learning", "CW Pitch", + "CW Training", "DC Voltage", "DCS Code", "DCS Reverse", + "DTMF A/M", "DTMF Delay", "DTMF Set", "DTMF Speed", + "EAI Timer", "Emergency Alarm", "Ext Menu", "FW Key", + "Half Deviation", "Home/Reverse", "Home > VFO", "INT Code", + "INT Conn Mode", "INT A/M", "INT Set", "INT Key", "INTNET", + "Lamp", "LED Light", "Lock", "Moni/T-Call", "Mic Gain", + "Memory Display", "Memory Write Mode", "Memory Channel Step", + "Memory Name Write", "Memory Protect", "Memory Skip", + "Message List", "Message Reg", "Message Set", "On Timer", + "Open Message", "Pager Answer Back", "Pager Receive Code", + "Pager Transmit Code", "Pager Frequency", "Priority Revert", + "Priority Timer", "Password", "PTT Delay", + "Repeater Shift Direction", "Repeater Shift", "Receive Mode", + "Smart Search", "Save Rx", "Save Tx", "Scan Lamp", + "Scan Resume", "Scan Restart", "Speaker Out", + "Squelch Level", "Squelch Type", "Squelch S Meter", + "Squelch Split Tone", "Step", "Stereo", "Sub Rx", "Temp", + "Tone Frequency", "Time Out Timer", "Tone Search Mute", + "Tone Search Speed", "VFO Band", "VFO Skip", "Volume Mode", + "Wake Up", "Weather Alert"] + rs = RadioSetting( + "my_key", "My key", RadioSettingValueList(keys, keys[_settings.my_key - 16])) # TODO: fix keys list isnt exactly right order # leave disabled in settings for now @@ -715,63 +768,79 @@ class VX3Radio(yaesu_clone.YaesuCloneModeRadio):
# sound tab
- sound.append( RadioSetting("band_edge_beep", "Band edge beep", - RadioSettingValueBoolean(_settings.band_edge_beep))) + sound.append(RadioSetting( + "band_edge_beep", "Band edge beep", + RadioSettingValueBoolean(_settings.band_edge_beep)))
opts = ["off", "key+scan", "key"] - sound.append( RadioSetting("beep_mode", "Beep mode", + sound.append(RadioSetting( + "beep_mode", "Beep mode", RadioSettingValueList(opts, opts[_settings.beep_mode])))
_volumes = self._memobj.volumes
- opts = map(str, range(0,33)) - sound.append( RadioSetting("speaker_vol", "Speaker volume", + opts = map(str, range(0, 33)) + sound.append(RadioSetting( + "speaker_vol", "Speaker volume", RadioSettingValueList(opts, opts[_volumes.speaker])))
- sound.append( RadioSetting("earphone_vol", "Earphone volume", - RadioSettingValueList(opts, opts[_volumes.earphone]))) + sound.append(RadioSetting( + "earphone_vol", "Earphone volume", + RadioSettingValueList(opts, opts[_volumes.earphone])))
opts = ["auto", "speaker"] - sound.append( RadioSetting("fm_speaker_out", "FM Speaker out", + sound.append(RadioSetting( + "fm_speaker_out", "FM Speaker out", RadioSettingValueList(opts, opts[_settings.fm_speaker_out])))
opts = ["mono", "stereo"] - sound.append( RadioSetting("fm_broadcast_mode", "FM broadcast mode", - RadioSettingValueList(opts, opts[_settings.fm_broadcast_mode]))) + sound.append(RadioSetting( + "fm_broadcast_mode", "FM broadcast mode", + RadioSettingValueList( + opts, opts[_settings.fm_broadcast_mode])))
opts = map(str, range(16)) - sound.append( RadioSetting("sql_fm", "Squelch level (FM)", + sound.append(RadioSetting( + "sql_fm", "Squelch level (FM)", RadioSettingValueList(opts, opts[_settings.sql_fm])))
opts = map(str, range(9)) - sound.append( RadioSetting("sql_wfm", "Squelch level (WFM)", + sound.append(RadioSetting( + "sql_wfm", "Squelch level (WFM)", RadioSettingValueList(opts, opts[_settings.sql_wfm])))
opts = map(str, range(16)) - sound.append( RadioSetting("radio_am_sql", "Squelch level (Broadcast Radio AM)", + sound.append(RadioSetting( + "radio_am_sql", "Squelch level (Broadcast Radio AM)", RadioSettingValueList(opts, opts[_settings.radio_am_sql])))
opts = map(str, range(9)) - sound.append( RadioSetting("radio_fm_sql", "Squelch level (Broadcast Radio FM)", - RadioSettingValueList(opts, opts[_settings.radio_fm_sql]))) + sound.append(RadioSetting( + "radio_fm_sql", "Squelch level (Broadcast Radio FM)", + RadioSettingValueList(opts, opts[_settings.radio_fm_sql])))
# dtmf tab
opts = ["manual", "auto"] - dtmf.append( RadioSetting("dtmf_autodialer", "DTMF autodialer mode", + dtmf.append(RadioSetting( + "dtmf_autodialer", "DTMF autodialer mode", RadioSettingValueList(opts, opts[_settings.dtmf_autodialer])))
opts = ["50", "250", "450", "750", "1000"] - dtmf.append( RadioSetting("dtmf_delay", "DTMF delay (ms)", + dtmf.append(RadioSetting( + "dtmf_delay", "DTMF delay (ms)", RadioSettingValueList(opts, opts[_settings.dtmf_delay])))
opts = ["50", "100"] - dtmf.append( RadioSetting("dtmf_speed", "DTMF speed (ms)", + dtmf.append(RadioSetting( + "dtmf_speed", "DTMF speed (ms)", RadioSettingValueList(opts, opts[_settings.dtmf_speed])))
opts = map(str, range(10)) - dtmf.append( RadioSetting("dtmf_chan_active", "DTMF active", - RadioSettingValueList(opts, opts[_settings.dtmf_chan_active]))) + dtmf.append(RadioSetting( + "dtmf_chan_active", "DTMF active", + RadioSettingValueList( + opts, opts[_settings.dtmf_chan_active])))
for i in range(10): name = "dtmf" + str(i) @@ -784,56 +853,67 @@ class VX3Radio(yaesu_clone.YaesuCloneModeRadio): dtmfentry = RadioSettingValueString(0, 16, dtmfstr) dtmfentry.set_charset(DTMFCHARSET + list(" ")) rs = RadioSetting(name, name.upper(), dtmfentry) - dtmf.append(rs) + dtmf.append(rs)
# arts tab - arts.append( RadioSetting("arts", "ARTS", - RadioSettingValueBoolean(_settings.arts))) + arts.append(RadioSetting( + "arts", "ARTS", + RadioSettingValueBoolean(_settings.arts)))
opts = ["off", "in range", "always"] - arts.append( RadioSetting("arts_beep", "ARTS beep", + arts.append(RadioSetting( + "arts_beep", "ARTS beep", RadioSettingValueList(opts, opts[_settings.arts_beep])))
opts = ["15", "25"] - arts.append( RadioSetting("arts_interval", "ARTS interval", + arts.append(RadioSetting( + "arts_interval", "ARTS interval", RadioSettingValueList(opts, opts[_settings.arts_interval])))
- arts.append( RadioSetting("arts_cwid_enable", "CW ID", - RadioSettingValueBoolean(_settings.arts_cwid_enable))) + arts.append(RadioSetting( + "arts_cwid_enable", "CW ID", + RadioSettingValueBoolean(_settings.arts_cwid_enable)))
- cwid = RadioSettingValueString(0, 16, - self._decode_chars(_settings.arts_cwid.get_value())) + cwid = RadioSettingValueString( + 0, 16, self._decode_chars(_settings.arts_cwid.get_value())) cwid.set_charset(CHARSET) - arts.append( RadioSetting("arts_cwid", "CW ID", cwid )) + arts.append(RadioSetting("arts_cwid", "CW ID", cwid))
# EAI tab - - eai.append( RadioSetting("emergency_eai", "EAI", + + eai.append(RadioSetting( + "emergency_eai", "EAI", RadioSettingValueBoolean(_settings.emergency_eai)))
- opts = [ "interval %dm" % t for t in range(1, 10) ] + \ - [ "interval %dm" % t for t in range(10, 55, 5) ] + \ - [ "continuous %dm" % t for t in range(1, 10) ] + \ - [ "continuous %dm" % t for t in range(10, 55, 5) ] + opts = ["interval %dm" % t for t in range(1, 10)] + \ + ["interval %dm" % t for t in range(10, 55, 5)] + \ + ["continuous %dm" % t for t in range(1, 10)] + \ + ["continuous %dm" % t for t in range(10, 55, 5)]
- eai.append( RadioSetting("emergency_eai_time", "EAI time", - RadioSettingValueList(opts, opts[_settings.emergency_eai_time]))) + eai.append(RadioSetting( + "emergency_eai_time", "EAI time", + RadioSettingValueList( + opts, opts[_settings.emergency_eai_time])))
- opts = ["beep", "strobe", "beep+strobe", "beam", "beep+beam", "cw", "beep+cw", "cwt"] - eai.append( RadioSetting("emergency_signal", "emergency signal", - RadioSettingValueList(opts, opts[_settings.emergency_signal]))) + opts = ["beep", "strobe", "beep+strobe", "beam", + "beep+beam", "cw", "beep+cw", "cwt"] + eai.append(RadioSetting( + "emergency_signal", "emergency signal", + RadioSettingValueList( + opts, opts[_settings.emergency_signal])))
# msg tab
opts = ["off", "dc voltage", "message"] - msg.append( RadioSetting("openmsg_mode", "Opening message mode", + msg.append(RadioSetting( + "openmsg_mode", "Opening message mode", RadioSettingValueList(opts, opts[_settings.openmsg_mode])))
- openmsg = RadioSettingValueString(0, 6, - self._decode_chars(_settings.openmsg.get_value())) + openmsg = RadioSettingValueString( + 0, 6, self._decode_chars(_settings.openmsg.get_value())) openmsg.set_charset(CHARSET) - msg.append( RadioSetting("openmsg", "Opening Message", openmsg )) - + msg.append(RadioSetting("openmsg", "Opening Message", openmsg)) + return top
def set_settings(self, uisettings): @@ -850,7 +930,7 @@ class VX3Radio(yaesu_clone.YaesuCloneModeRadio): # set dtmf fields dtmfstr = str(element.value).strip() newval = [] - for i in range(0,16): + for i in range(0, 16): if i < len(dtmfstr): newval.append(DTMFCHARSET.index(dtmfstr[i])) else: @@ -862,14 +942,14 @@ class VX3Radio(yaesu_clone.YaesuCloneModeRadio): continue if re.match('.*_vol$', setting): # volume fields - voltype = re.sub('_vol$','', setting) + voltype = re.sub('_vol$', '', setting) setattr(self._memobj.volumes, voltype, element.value) continue if setting == "my_key": # my_key is memory is off by 9 from list, beware hacks! opts = element.value.get_options() optsidx = opts.index(element.value.get_value()) - idx = optsidx + 16 + idx = optsidx + 16 setattr(_settings, "my_key", idx) continue oldval = getattr(_settings, setting) @@ -883,4 +963,3 @@ class VX3Radio(yaesu_clone.YaesuCloneModeRadio): except Exception, e: print element.get_name() raise - diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 4174064..3b4be01 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -23,7 +23,6 @@ ./chirp/drivers/th_uvf8d.py ./chirp/drivers/tmv71.py ./chirp/drivers/tmv71_ll.py -./chirp/drivers/vx3.py ./chirp/drivers/vx5.py ./chirp/drivers/vx510.py ./chirp/drivers/vx6.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID ef062c8bf30cef7dd94912c4ff5f52babbf3941f
Fix style issues in vx5.py (#2355)
diff --git a/chirp/drivers/vx5.py b/chirp/drivers/vx5.py index 61bce15..1afe676 100644 --- a/chirp/drivers/vx5.py +++ b/chirp/drivers/vx5.py @@ -81,6 +81,7 @@ POWER_LEVELS = [chirp_common.PowerLevel("Hi", watts=5.00), chirp_common.PowerLevel("L2", watts=1.00), chirp_common.PowerLevel("L1", watts=0.05)]
+ class VX5BankModel(chirp_common.BankModel): def get_num_mappings(self): return 5 @@ -98,7 +99,7 @@ class VX5BankModel(chirp_common.BankModel): _bank_used = self._radio._memobj.bank_used[bank.index] for i in range(0, len(_members)): if _members[i].status == 0xFF: - #print "empty found, inserting %d at %d" % (memory.number, i) + # print "empty found, inserting %d at %d" % (memory.number, i) if self._radio._memobj.current_bank == 0xFF: self._radio._memobj.current_bank = bank.index _members[i].status = 0x00 @@ -151,6 +152,7 @@ class VX5BankModel(chirp_common.BankModel): banks.append(bank) return banks
+ @directory.register class VX5Radio(yaesu_clone.YaesuCloneModeRadio): """Yaesu VX-5""" @@ -164,7 +166,7 @@ class VX5Radio(yaesu_clone.YaesuCloneModeRadio): _block_size = 8
def _checksums(self): - return [ yaesu_clone.YaesuChecksum(0x0000, 0x1FB9) ] + return [yaesu_clone.YaesuChecksum(0x0000, 0x1FB9)]
def get_features(self): rf = chirp_common.RadioFeatures() @@ -176,8 +178,8 @@ class VX5Radio(yaesu_clone.YaesuCloneModeRadio): rf.valid_tmodes = TMODES rf.valid_duplexes = DUPLEX rf.memory_bounds = (1, 220) - rf.valid_bands = [( 500000, 16000000), - ( 48000000, 729000000), + rf.valid_bands = [(500000, 16000000), + (48000000, 729000000), (800000000, 999000000)] rf.valid_skips = ["", "S", "P"] rf.valid_power_levels = POWER_LEVELS @@ -213,7 +215,7 @@ class VX5Radio(yaesu_clone.YaesuCloneModeRadio): mem.tuning_step = STEPS[_mem.tuning_step] mem.offset = int(_mem.offset) * 1000 mem.power = POWER_LEVELS[3 - _mem.power] - mem.tmode = TMODES[_mem.tmode & 0x3] # masked so bad mems can be read + mem.tmode = TMODES[_mem.tmode & 0x3] # masked so bad mems can be read if mem.duplex == "split": mem.offset = chirp_common.fix_rounded_step(mem.offset) mem.rtone = mem.ctone = chirp_common.OLD_TONES[_mem.tone] @@ -226,7 +228,7 @@ class VX5Radio(yaesu_clone.YaesuCloneModeRadio): def set_memory(self, mem): _mem = self._memobj.memory[mem.number-1] _flg = self._memobj.flag[mem.number-1] - + # initialize new channel to safe defaults if not mem.empty and not _flg.used: _flg.used = True @@ -234,11 +236,11 @@ class VX5Radio(yaesu_clone.YaesuCloneModeRadio): _mem.unknown2 = 0x00 _mem.unknown3 = 0x00 _mem.unknown4 = 0x00 - _mem.icon = 12 # file cabinet icon + _mem.icon = 12 # file cabinet icon _mem.unknown7 = 0x00 _mem.unknown8 = 0x00 _mem.unknown9 = 0x00 - + if mem.empty and _flg.used and not _flg.visible: _flg.used = False return diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 3b4be01..dcf1129 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -23,7 +23,6 @@ ./chirp/drivers/th_uvf8d.py ./chirp/drivers/tmv71.py ./chirp/drivers/tmv71_ll.py -./chirp/drivers/vx5.py ./chirp/drivers/vx510.py ./chirp/drivers/vx6.py ./chirp/drivers/vx7.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID 98f337a0e9a562c8908ed45fee519fcf2dea2199
Fix style issues in vx510.py (#2355)
diff --git a/chirp/drivers/vx510.py b/chirp/drivers/vx510.py index 16a9026..49570e2 100644 --- a/chirp/drivers/vx510.py +++ b/chirp/drivers/vx510.py @@ -162,9 +162,11 @@ class VX510Radio(yaesu_clone.YaesuCloneModeRadio):
if tmode_tx == "Tone" and not tmode_rx: mem.tmode = "Tone" - elif tmode_tx == tmode_rx and tmode_tx == "Tone" and mem.rtone == mem.ctone: + elif tmode_tx == tmode_rx and tmode_tx == "Tone" and \ + mem.rtone == mem.ctone: mem.tmode = "TSQL" - elif tmode_tx == tmode_rx and tmode_tx == "DTCS" and mem.dtcs == mem.rx_dtcs: + elif tmode_tx == tmode_rx and tmode_tx == "DTCS" and \ + mem.dtcs == mem.rx_dtcs: mem.tmode = "DTCS" elif tmode_rx or tmode_tx: mem.tmode = "Cross" diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index dcf1129..79121ec 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -23,7 +23,6 @@ ./chirp/drivers/th_uvf8d.py ./chirp/drivers/tmv71.py ./chirp/drivers/tmv71_ll.py -./chirp/drivers/vx510.py ./chirp/drivers/vx6.py ./chirp/drivers/vx7.py ./chirp/drivers/vx8.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID 23c413dd5afbe7f7360f8d1b09441ce31f1fc512
Fix style issues in vx6.py (#2355)
diff --git a/chirp/drivers/vx6.py b/chirp/drivers/vx6.py index 467c9de..d37a94a 100644 --- a/chirp/drivers/vx6.py +++ b/chirp/drivers/vx6.py @@ -93,10 +93,10 @@ struct { """
DUPLEX = ["", "-", "+", "split"] -MODES = ["FM", "AM", "WFM", "FM"] # last is auto +MODES = ["FM", "AM", "WFM", "FM"] # last is auto TMODES = ["", "Tone", "TSQL", "DTCS"] -STEPS = [5.0, 10.0, 12.5, 15.0, 20.0, 25.0, 50.0, 100.0, - 9.0, 200.0, 5.0] # last is auto, 9.0k and 200.0k are unadvertised +STEPS = [5.0, 10.0, 12.5, 15.0, 20.0, 25.0, 50.0, 100.0, + 9.0, 200.0, 5.0] # last is auto, 9.0k and 200.0k are unadvertised
CHARSET = ["%i" % int(x) for x in range(0, 10)] + \ @@ -109,10 +109,11 @@ POWER_LEVELS = [chirp_common.PowerLevel("Hi", watts=5.00), chirp_common.PowerLevel("L2", watts=1.00), chirp_common.PowerLevel("L1", watts=0.30)] POWER_LEVELS_220 = [chirp_common.PowerLevel("Hi", watts=1.50), - chirp_common.PowerLevel("L3", watts=1.00), - chirp_common.PowerLevel("L2", watts=0.50), - chirp_common.PowerLevel("L1", watts=0.20)] - + chirp_common.PowerLevel("L3", watts=1.00), + chirp_common.PowerLevel("L2", watts=0.50), + chirp_common.PowerLevel("L1", watts=0.20)] + + class VX6Bank(chirp_common.NamedBank): """A VX6 Bank""" def get_name(self): @@ -129,6 +130,7 @@ class VX6Bank(chirp_common.NamedBank): _bank = self._model._radio._memobj.bank_names[self.index] _bank.name = [CHARSET.index(x) for x in name.ljust(6)[:6]]
+ class VX6BankModel(chirp_common.BankModel): """A VX-6 bank model"""
@@ -170,25 +172,25 @@ class VX6BankModel(chirp_common.BankModel): channels_in_bank.add(memory.number) self._update_bank_with_channel_numbers(bank, channels_in_bank) _bank_used = self._radio._memobj.bank_used[bank.index] - _bank_used.in_use = 0x0000 # enable + _bank_used.in_use = 0x0000 # enable
# also needed for unit to recognize any banks? self._radio._memobj.banksoff1 = 0x0000 self._radio._memobj.banksoff2 = 0x0000 # TODO: turn back off (0xFFFF) when all banks are empty? - + def remove_memory_from_mapping(self, memory, bank): channels_in_bank = self._get_channel_numbers_in_bank(bank) try: channels_in_bank.remove(memory.number) except KeyError: - raise Exception("Memory %i is not in bank %s. Cannot remove" % \ + raise Exception("Memory %i is not in bank %s. Cannot remove" % (memory.number, bank)) self._update_bank_with_channel_numbers(bank, channels_in_bank)
if not channels_in_bank: _bank_used = self._radio._memobj.bank_used[bank.index] - _bank_used.in_use = 0xFFFF # disable bank + _bank_used.in_use = 0xFFFF # disable bank
def get_mapping_memories(self, bank): memories = [] @@ -205,6 +207,7 @@ class VX6BankModel(chirp_common.BankModel):
return banks
+ @directory.register class VX6Radio(yaesu_clone.YaesuCloneModeRadio): """Yaesu VX-6""" @@ -221,21 +224,21 @@ class VX6Radio(yaesu_clone.YaesuCloneModeRadio): def get_prompts(cls): rp = chirp_common.RadioPrompts() rp.pre_download = _(dedent("""\ - 1. Turn radio off. - 2. Connect cable to MIC/SP jack. - 3. Press and hold in the [F/W] key while turning the radio on - ("CLONE" will appear on the display). - 4. <b>After clicking OK</b>, press the [BAND] key to send image.""")) +1. Turn radio off. +2. Connect cable to MIC/SP jack. +3. Press and hold in the [F/W] key while turning the radio on + ("CLONE" will appear on the display). +4. <b>After clicking OK</b>, press the [BAND] key to send image.""")) rp.pre_upload = _(dedent("""\ - 1. Turn radio off. - 2. Connect cable to MIC/SP jack. - 3. Press and hold in the [F/W] key while turning the radio on - ("CLONE" will appear on the display). - 4. Press the [V/M] key ("-WAIT-" will appear on the LCD).""")) +1. Turn radio off. +2. Connect cable to MIC/SP jack. +3. Press and hold in the [F/W] key while turning the radio on + ("CLONE" will appear on the display). +4. Press the [V/M] key ("-WAIT-" will appear on the LCD).""")) return rp - + def _checksums(self): - return [ yaesu_clone.YaesuChecksum(0x0000, 0x7F49) ] + return [yaesu_clone.YaesuChecksum(0x0000, 0x7F49)]
def process_mmap(self): self._memobj = bitwise.parse(MEM_FORMAT, self._mmap) @@ -293,7 +296,7 @@ class VX6Radio(yaesu_clone.YaesuCloneModeRadio): mem.dtcs = chirp_common.DTCS_CODES[_mem.dcs & 0x7f] mem.tuning_step = STEPS[_mem.tune_step] mem.skip = pskip and "P" or skip and "S" or "" - + if mem.freq > 220000000 and mem.freq < 225000000: mem.power = POWER_LEVELS_220[3 - _mem.power] else: @@ -364,5 +367,3 @@ class VX6Radio(yaesu_clone.YaesuCloneModeRadio):
def get_bank_model(self): return VX6BankModel(self) - - diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 79121ec..a82ea1a 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -23,6 +23,5 @@ ./chirp/drivers/th_uvf8d.py ./chirp/drivers/tmv71.py ./chirp/drivers/tmv71_ll.py -./chirp/drivers/vx6.py ./chirp/drivers/vx7.py ./chirp/drivers/vx8.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID bc9105eada58bca60a06d21be0b56c330f2d8c70
Fix style issues in vx7.py (#2355)
diff --git a/chirp/drivers/vx7.py b/chirp/drivers/vx7.py index d63bf32..8aab994 100644 --- a/chirp/drivers/vx7.py +++ b/chirp/drivers/vx7.py @@ -75,7 +75,7 @@ struct { """
DUPLEX = ["", "-", "+", "split"] -MODES = ["FM", "AM", "WFM", "Auto"] +MODES = ["FM", "AM", "WFM", "Auto"] TMODES = ["", "Tone", "TSQL", "DTCS", "Cross"] CROSS_MODES = ["DTCS->", "Tone->DTCS", "DTCS->Tone"] STEPS = list(chirp_common.TUNING_STEPS) @@ -99,9 +99,11 @@ POWER_LEVELS = [chirp_common.PowerLevel("L1", watts=0.05), POWER_LEVELS_220 = [chirp_common.PowerLevel("L1", watts=0.05), chirp_common.PowerLevel("L2", watts=0.30)]
+ def _is220(freq): return freq >= 222000000 and freq <= 225000000
+ class VX7BankModel(chirp_common.BankModel): """A VX-7 Bank model""" def get_num_mappings(self): @@ -140,7 +142,7 @@ class VX7BankModel(chirp_common.BankModel): if not found: raise Exception("Memory {num} not in " + "bank {bank}".format(num=memory.number, - bank=bank)) + bank=bank)) if not remaining_members: _bank_used.in_use = 0xFFFF
@@ -167,11 +169,13 @@ class VX7BankModel(chirp_common.BankModel): banks.append(bank) return banks
+ def _wipe_memory(mem): mem.set_raw("\x00" * (mem.size() / 8)) mem.unknown1 = 0x05 mem.ones = 0x03
+ @directory.register class VX7Radio(yaesu_clone.YaesuCloneModeRadio): """Yaesu VX-7""" @@ -181,31 +185,31 @@ class VX7Radio(yaesu_clone.YaesuCloneModeRadio):
_model = "" _memsize = 16211 - _block_lengths = [ 10, 8, 16193 ] + _block_lengths = [10, 8, 16193] _block_size = 8
@classmethod def get_prompts(cls): rp = chirp_common.RadioPrompts() rp.pre_download = _(dedent("""\ - 1. Turn radio off. - 2. Connect cable to MIC/SP jack. - 3. Press and hold in the [MON-F] key while turning the radio on - ("CLONE" will appear on the display). - 4. <b>After clicking OK</b>, press the [BAND] key to send image.""")) +1. Turn radio off. +2. Connect cable to MIC/SP jack. +3. Press and hold in the [MON-F] key while turning the radio on + ("CLONE" will appear on the display). +4. <b>After clicking OK</b>, press the [BAND] key to send image.""")) rp.pre_upload = _(dedent("""\ - 1. Turn radio off. - 2. Connect cable to MIC/SP jack. - 3. Press and hold in the [MON-F] key while turning the radio on - ("CLONE" will appear on the display). - 4. Press the [V/M] key ("CLONE WAIT" will appear on the LCD).""")) +1. Turn radio off. +2. Connect cable to MIC/SP jack. +3. Press and hold in the [MON-F] key while turning the radio on + ("CLONE" will appear on the display). +4. Press the [V/M] key ("CLONE WAIT" will appear on the LCD).""")) return rp - + def _checksums(self): - return [ yaesu_clone.YaesuChecksum(0x0592, 0x0610), - yaesu_clone.YaesuChecksum(0x0612, 0x0690), - yaesu_clone.YaesuChecksum(0x0000, 0x3F51), - ] + return [yaesu_clone.YaesuChecksum(0x0592, 0x0610), + yaesu_clone.YaesuChecksum(0x0612, 0x0690), + yaesu_clone.YaesuChecksum(0x0000, 0x3F51), + ]
def process_mmap(self): self._memobj = bitwise.parse(MEM_FORMAT, self._mmap) @@ -293,7 +297,7 @@ class VX7Radio(yaesu_clone.YaesuCloneModeRadio): _flag = self._memobj.flags[(mem.number-1)/2]
nibble = ((mem.number-1) % 2) and "even" or "odd" - + valid = _flag["%s_valid" % nibble] used = _flag["%s_masked" % nibble]
@@ -339,14 +343,14 @@ class VX7Radio(yaesu_clone.YaesuCloneModeRadio):
for i in range(0, 8): _mem.name[i] = CHARSET.index(mem.name.ljust(8)[i]) - + def validate_memory(self, mem): msgs = yaesu_clone.YaesuCloneModeRadio.validate_memory(self, mem)
if _is220(mem.freq): if str(mem.power) not in [str(l) for l in POWER_LEVELS_220]: - msgs.append(chirp_common.ValidationError(\ - "Power level %s not supported on 220MHz band" % \ + msgs.append(chirp_common.ValidationError( + "Power level %s not supported on 220MHz band" % mem.power))
return msgs diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index a82ea1a..cb89d2d 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -23,5 +23,4 @@ ./chirp/drivers/th_uvf8d.py ./chirp/drivers/tmv71.py ./chirp/drivers/tmv71_ll.py -./chirp/drivers/vx7.py ./chirp/drivers/vx8.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID db79c159c9e963ebdd10a526d65136fe29c9f22d
Fix style issues in vx8.py (#2355)
diff --git a/chirp/drivers/vx8.py b/chirp/drivers/vx8.py index 7f6a752..e35d05c 100644 --- a/chirp/drivers/vx8.py +++ b/chirp/drivers/vx8.py @@ -44,7 +44,7 @@ struct {
#seekto 0x04bf; struct { - u8 beep; + u8 beep; } beep_select;
#seekto 0x04cc; @@ -326,17 +326,17 @@ u8 checksum;
TMODES = ["", "Tone", "TSQL", "DTCS"] DUPLEX = ["", "-", "+", "split"] -MODES = ["FM", "AM", "WFM"] +MODES = ["FM", "AM", "WFM"] STEPS = list(chirp_common.TUNING_STEPS) STEPS.remove(30.0) STEPS.append(100.0) -STEPS.insert(2, 0.0) # There is a skipped tuning step at index 2 (?) +STEPS.insert(2, 0.0) # There is a skipped tuning step at index 2 (?) SKIPS = ["", "S", "P"] VX8_DTMF_CHARS = list("0123456789ABCD*#-")
CHARSET = ["%i" % int(x) for x in range(0, 10)] + \ [chr(x) for x in range(ord("A"), ord("Z")+1)] + \ - [" ",] + \ + [" "] + \ [chr(x) for x in range(ord("a"), ord("z")+1)] + \ list(".,:;*#_-/&()@!?^ ") + list("\x00" * 100)
@@ -345,13 +345,14 @@ POWER_LEVELS = [chirp_common.PowerLevel("Hi", watts=5.00), chirp_common.PowerLevel("L2", watts=1.00), chirp_common.PowerLevel("L1", watts=0.05)]
+ class VX8Bank(chirp_common.NamedBank): """A VX-8 bank"""
def get_name(self): _bank = self._model._radio._memobj.bank_info[self.index] _bank_used = self._model._radio._memobj.bank_used[self.index] - + name = "" for i in _bank.name: if i == 0xFF: @@ -363,6 +364,7 @@ class VX8Bank(chirp_common.NamedBank): _bank = self._model._radio._memobj.bank_info[self.index] _bank.name = [CHARSET.index(x) for x in name.ljust(16)[:16]]
+ class VX8BankModel(chirp_common.BankModel): """A VX-8 bank model""" def __init__(self, radio, name='Banks'): @@ -408,28 +410,28 @@ class VX8BankModel(chirp_common.BankModel): break
for vfo_index in (0, 1): - # 3 VFO info structs are stored as 3 pairs of (master, backup) - vfo = self._radio._memobj.vfo_info[vfo_index * 2] - vfo_bak = self._radio._memobj.vfo_info[(vfo_index * 2) + 1] - - if vfo.checksum != vfo_bak.checksum: - print "Warning: VFO settings are inconsistent with backup" - else: - if ((chosen_bank[vfo_index] is None) and - (vfo.bank_index != 0xFFFF)): - print "Disabling banks for VFO %d" % vfo_index - vfo.bank_index = 0xFFFF - vfo.mr_index = 0xFFFF - vfo.bank_enable = 0xFFFF - elif ((chosen_bank[vfo_index] is not None) and - (vfo.bank_index == 0xFFFF)): - print "Enabling banks for VFO %d" % vfo_index - vfo.bank_index = chosen_bank[vfo_index] - vfo.mr_index = chosen_mr[vfo_index] - vfo.bank_enable = 0x0000 - vfo_bak.bank_index = vfo.bank_index - vfo_bak.mr_index = vfo.mr_index - vfo_bak.bank_enable = vfo.bank_enable + # 3 VFO info structs are stored as 3 pairs of (master, backup) + vfo = self._radio._memobj.vfo_info[vfo_index * 2] + vfo_bak = self._radio._memobj.vfo_info[(vfo_index * 2) + 1] + + if vfo.checksum != vfo_bak.checksum: + print "Warning: VFO settings are inconsistent with backup" + else: + if ((chosen_bank[vfo_index] is None) and + (vfo.bank_index != 0xFFFF)): + print "Disabling banks for VFO %d" % vfo_index + vfo.bank_index = 0xFFFF + vfo.mr_index = 0xFFFF + vfo.bank_enable = 0xFFFF + elif ((chosen_bank[vfo_index] is not None) and + (vfo.bank_index == 0xFFFF)): + print "Enabling banks for VFO %d" % vfo_index + vfo.bank_index = chosen_bank[vfo_index] + vfo.mr_index = chosen_mr[vfo_index] + vfo.bank_enable = 0x0000 + vfo_bak.bank_index = vfo.bank_index + vfo_bak.mr_index = vfo.mr_index + vfo_bak.bank_enable = vfo.bank_enable
def _update_bank_with_channel_numbers(self, bank, channels_in_bank): _members = self._radio._memobj.bank_members[bank.index] @@ -458,7 +460,7 @@ class VX8BankModel(chirp_common.BankModel): try: channels_in_bank.remove(memory.number) except KeyError: - raise Exception("Memory %i is not in bank %s. Cannot remove" % \ + raise Exception("Memory %i is not in bank %s. Cannot remove" % (memory.number, bank)) self._update_bank_with_channel_numbers(bank, channels_in_bank)
@@ -483,10 +485,12 @@ class VX8BankModel(chirp_common.BankModel):
return banks
+ def _wipe_memory(mem): mem.set_raw("\x00" * (mem.size() / 8)) mem.unknown1 = 0x05
+ @directory.register class VX8Radio(yaesu_clone.YaesuCloneModeRadio): """Yaesu VX-8""" @@ -497,13 +501,13 @@ class VX8Radio(yaesu_clone.YaesuCloneModeRadio):
_model = "AH029" _memsize = 65227 - _block_lengths = [ 10, 65217 ] + _block_lengths = [10, 65217] _block_size = 32 - _mem_params = (0xC24A, # APRS beacon metadata address. - 40, # Number of beacons stored. - 0xC60A, # APRS beacon content address. - 194, # Length of beacon data stored. - 40) # Number of beacons stored. + _mem_params = (0xC24A, # APRS beacon metadata address. + 40, # Number of beacons stored. + 0xC60A, # APRS beacon content address. + 194, # Length of beacon data stored. + 40) # Number of beacons stored. _has_vibrate = False _has_af_dual = True
@@ -511,17 +515,17 @@ class VX8Radio(yaesu_clone.YaesuCloneModeRadio): def get_prompts(cls): rp = chirp_common.RadioPrompts() rp.pre_download = _(dedent("""\ - 1. Turn radio off. - 2. Connect cable to DATA jack. - 3. Press and hold in the [FW] key while turning the radio on - ("CLONE" will appear on the display). - 4. <b>After clicking OK</b>, press the [BAND] key to send image.""")) +1. Turn radio off. +2. Connect cable to DATA jack. +3. Press and hold in the [FW] key while turning the radio on + ("CLONE" will appear on the display). +4. <b>After clicking OK</b>, press the [BAND] key to send image.""")) rp.pre_upload = _(dedent("""\ - 1. Turn radio off. - 2. Connect cable to DATA jack. - 3. Press and hold in the [FW] key while turning the radio on - ("CLONE" will appear on the display). - 4. Press the [MODE] key ("-WAIT-" will appear on the LCD).""")) +1. Turn radio off. +2. Connect cable to DATA jack. +3. Press and hold in the [FW] key while turning the radio on + ("CLONE" will appear on the display). +4. Press the [MODE] key ("-WAIT-" will appear on the LCD).""")) return rp
def process_mmap(self): @@ -549,11 +553,11 @@ class VX8Radio(yaesu_clone.YaesuCloneModeRadio): return repr(self._memobj.memory[number])
def _checksums(self): - return [ yaesu_clone.YaesuChecksum(0x064A, 0x06C8), - yaesu_clone.YaesuChecksum(0x06CA, 0x0748), - yaesu_clone.YaesuChecksum(0x074A, 0x07C8), - yaesu_clone.YaesuChecksum(0x07CA, 0x0848), - yaesu_clone.YaesuChecksum(0x0000, 0xFEC9) ] + return [yaesu_clone.YaesuChecksum(0x064A, 0x06C8), + yaesu_clone.YaesuChecksum(0x06CA, 0x0748), + yaesu_clone.YaesuChecksum(0x074A, 0x07C8), + yaesu_clone.YaesuChecksum(0x07CA, 0x0848), + yaesu_clone.YaesuChecksum(0x0000, 0xFEC9)]
@staticmethod def _add_ff_pad(val, length): @@ -621,9 +625,9 @@ class VX8Radio(yaesu_clone.YaesuCloneModeRadio): if mem.freq < 30000000 or \ (mem.freq > 88000000 and mem.freq < 108000000) or \ mem.freq > 580000000: - flag.nosubvfo = True # Masked from VFO B + flag.nosubvfo = True # Masked from VFO B else: - flag.nosubvfo = False # Available in both VFOs + flag.nosubvfo = False # Available in both VFOs
_mem.freq = int(mem.freq / 1000) _mem.offset = int(mem.offset / 1000) @@ -650,19 +654,20 @@ class VX8Radio(yaesu_clone.YaesuCloneModeRadio): def get_bank_model(self): return VX8BankModel(self)
+ @directory.register class VX8DRadio(VX8Radio): """Yaesu VX-8DR""" _model = "AH29D" - _mem_params = (0xC24A, # APRS beacon metadata address. - 50, # Number of beacons stored. - 0xC6FA, # APRS beacon content address. - 146, # Length of beacon data stored. - 50) # Number of beacons stored. + _mem_params = (0xC24A, # APRS beacon metadata address. + 50, # Number of beacons stored. + 0xC6FA, # APRS beacon content address. + 146, # Length of beacon data stored. + 50) # Number of beacons stored. VARIANT = "DR"
_SG_RE = re.compile(r"(?P<sign>[-+NESW]?)(?P<d>[\d]+)[\s.,]*" - "(?P<m>[\d]*)[\s']*(?P<s>[\d]*)") + "(?P<m>[\d]*)[\s']*(?P<s>[\d]*)")
_RX_BAUD = ("off", "1200 baud", "9600 baud") _TX_DELAY = ("100ms", "150ms", "200ms", "250ms", "300ms", @@ -708,16 +713,17 @@ class VX8DRadio(VX8Radio): "every 5 minutes", "every 6 minutes", "every 7 minutes", "every 8 minutes", "every 9 minutes", "every 10 minutes") _BEEP_SELECT = ("Off", "Key+Scan", "Key") - _SQUELCH = ["%d" % x for x in range (0,16)] - _VOLUME = ["%d" % x for x in range (0,33)] + _SQUELCH = ["%d" % x for x in range(0, 16)] + _VOLUME = ["%d" % x for x in range(0, 33)] _OPENING_MESSAGE = ("Off", "DC", "Message", "Normal") - _SCAN_RESUME = ["%.1fs" % (0.5 * x) for x in range(4,21)] + \ + _SCAN_RESUME = ["%.1fs" % (0.5 * x) for x in range(4, 21)] + \ ["Busy", "Hold"] - _SCAN_RESTART = ["%.1fs" % (0.1 * x) for x in range(1,10)] + \ - ["%.1fs" % (0.5 * x) for x in range(2,21)] - _LAMP_KEY = ["Key %d sec" % x for x in range(2,11)] + ["Continuous", "OFF"] - _LCD_CONTRAST = ["Level %d" % x for x in range(1,16)] - _LCD_DIMMER = ["Level %d" % x for x in range(1,5)] + _SCAN_RESTART = ["%.1fs" % (0.1 * x) for x in range(1, 10)] + \ + ["%.1fs" % (0.5 * x) for x in range(2, 21)] + _LAMP_KEY = ["Key %d sec" % x for x in range(2, 11)] + \ + ["Continuous", "OFF"] + _LCD_CONTRAST = ["Level %d" % x for x in range(1, 16)] + _LCD_DIMMER = ["Level %d" % x for x in range(1, 5)] _TOT_TIME = ["Off"] + ["%.1f min" % (0.5 * x) for x in range(1, 21)] _OFF_ON = ("Off", "On") _VOL_MODE = ("Normal", "Auto Back") @@ -811,8 +817,8 @@ class VX8DRadio(VX8Radio): menu = RadioSettingGroup("aprs_general", "APRS General") aprs = self._memobj.aprs
- val = RadioSettingValueString(0, 6, - str(aprs.my_callsign.callsign).rstrip("\xFF")) + val = RadioSettingValueString( + 0, 6, str(aprs.my_callsign.callsign).rstrip("\xFF")) rs = RadioSetting("aprs.my_callsign.callsign", "My Callsign", val) rs.set_apply_callback(self.apply_callsign, aprs.my_callsign) menu.append(rs) @@ -831,8 +837,8 @@ class VX8DRadio(VX8Radio): symbols = list(chirp_common.APRS_SYMBOLS) selected = aprs.custom_symbol if aprs.custom_symbol >= len(chirp_common.APRS_SYMBOLS): - symbols.append("%d" % aprs.custom_symbol) - selected = len(symbols) - 1 + symbols.append("%d" % aprs.custom_symbol) + selected = len(symbols) - 1 val = RadioSettingValueList(symbols, symbols[selected]) rs = RadioSetting("aprs.custom_symbol_text", "User Selected Symbol", val) @@ -861,8 +867,8 @@ class VX8DRadio(VX8Radio): # TODO: Rebuild this when latitude/longitude change. # TODO: Add saved positions p1 - p10 to memory map. position_str = list(self._POSITIONS) - #position_str[1] = "%s %s" % (latitude, longitude) - #position_str[2] = "%s %s" % (latitude, longitude) + # position_str[1] = "%s %s" % (latitude, longitude) + # position_str[2] = "%s %s" % (latitude, longitude) val = RadioSettingValueList(position_str, position_str[aprs.selected_position]) rs = RadioSetting("aprs.selected_position", "My Position", val) @@ -878,8 +884,8 @@ class VX8DRadio(VX8Radio): rs.set_apply_callback(self.apply_lat_long, aprs) menu.append(rs)
- val = RadioSettingValueList(self._TIME_SOURCE, - self._TIME_SOURCE[aprs.set_time_manually]) + val = RadioSettingValueList( + self._TIME_SOURCE, self._TIME_SOURCE[aprs.set_time_manually]) rs = RadioSetting("aprs.set_time_manually", "Time Source", val) menu.append(rs)
@@ -887,59 +893,62 @@ class VX8DRadio(VX8Radio): rs = RadioSetting("aprs.timezone", "Timezone", val) menu.append(rs)
- val = RadioSettingValueList(self._SPEED_UNITS, - self._SPEED_UNITS[aprs.aprs_units_speed]) + val = RadioSettingValueList( + self._SPEED_UNITS, self._SPEED_UNITS[aprs.aprs_units_speed]) rs = RadioSetting("aprs.aprs_units_speed", "APRS Speed Units", val) menu.append(rs)
- val = RadioSettingValueList(self._SPEED_UNITS, - self._SPEED_UNITS[aprs.gps_units_speed]) + val = RadioSettingValueList( + self._SPEED_UNITS, self._SPEED_UNITS[aprs.gps_units_speed]) rs = RadioSetting("aprs.gps_units_speed", "GPS Speed Units", val) menu.append(rs)
- val = RadioSettingValueList(self._ALT_UNITS, - self._ALT_UNITS[aprs.aprs_units_altitude_ft]) + val = RadioSettingValueList( + self._ALT_UNITS, self._ALT_UNITS[aprs.aprs_units_altitude_ft]) rs = RadioSetting("aprs.aprs_units_altitude_ft", "APRS Altitude Units", val) menu.append(rs)
- val = RadioSettingValueList(self._ALT_UNITS, - self._ALT_UNITS[aprs.gps_units_altitude_ft]) + val = RadioSettingValueList( + self._ALT_UNITS, self._ALT_UNITS[aprs.gps_units_altitude_ft]) rs = RadioSetting("aprs.gps_units_altitude_ft", "GPS Altitude Units", val) menu.append(rs)
- val = RadioSettingValueList(self._POS_UNITS, - self._POS_UNITS[aprs.aprs_units_position_mmss]) + val = RadioSettingValueList( + self._POS_UNITS, + self._POS_UNITS[aprs.aprs_units_position_mmss]) rs = RadioSetting("aprs.aprs_units_position_mmss", "APRS Position Format", val) menu.append(rs)
- val = RadioSettingValueList(self._POS_UNITS, - self._POS_UNITS[aprs.gps_units_position_sss]) + val = RadioSettingValueList( + self._POS_UNITS, self._POS_UNITS[aprs.gps_units_position_sss]) rs = RadioSetting("aprs.gps_units_position_sss", "GPS Position Format", val) menu.append(rs)
- val = RadioSettingValueList(self._DIST_UNITS, - self._DIST_UNITS[aprs.aprs_units_distance_m]) + val = RadioSettingValueList( + self._DIST_UNITS, + self._DIST_UNITS[aprs.aprs_units_distance_m]) rs = RadioSetting("aprs.aprs_units_distance_m", "APRS Distance Units", val) menu.append(rs)
- val = RadioSettingValueList(self._WIND_UNITS, - self._WIND_UNITS[aprs.aprs_units_wind_mph]) + val = RadioSettingValueList( + self._WIND_UNITS, self._WIND_UNITS[aprs.aprs_units_wind_mph]) rs = RadioSetting("aprs.aprs_units_wind_mph", "APRS Wind Speed Units", val) menu.append(rs)
- val = RadioSettingValueList(self._RAIN_UNITS, - self._RAIN_UNITS[aprs.aprs_units_rain_inch]) + val = RadioSettingValueList( + self._RAIN_UNITS, self._RAIN_UNITS[aprs.aprs_units_rain_inch]) rs = RadioSetting("aprs.aprs_units_rain_inch", "APRS Rain Units", val) menu.append(rs)
- val = RadioSettingValueList(self._TEMP_UNITS, - self._TEMP_UNITS[aprs.aprs_units_temperature_f]) + val = RadioSettingValueList( + self._TEMP_UNITS, + self._TEMP_UNITS[aprs.aprs_units_temperature_f]) rs = RadioSetting("aprs.aprs_units_temperature_f", "APRS Temperature Units", val) menu.append(rs) @@ -1060,20 +1069,20 @@ class VX8DRadio(VX8Radio): menu = RadioSettingGroup("aprs_tx", "APRS Transmit") aprs = self._memobj.aprs
- beacon_type = (aprs.tx_smartbeacon << 1) | aprs.tx_interval_beacon; - val = RadioSettingValueList(self._BEACON_TYPE, - self._BEACON_TYPE[beacon_type]) + beacon_type = (aprs.tx_smartbeacon << 1) | aprs.tx_interval_beacon + val = RadioSettingValueList( + self._BEACON_TYPE, self._BEACON_TYPE[beacon_type]) rs = RadioSetting("aprs.transmit", "TX Beacons", val) rs.set_apply_callback(self.apply_beacon_type, aprs) menu.append(rs)
- val = RadioSettingValueList(self._TX_DELAY, - self._TX_DELAY[aprs.tx_delay]) + val = RadioSettingValueList( + self._TX_DELAY, self._TX_DELAY[aprs.tx_delay]) rs = RadioSetting("aprs.tx_delay", "TX Delay", val) menu.append(rs)
- val = RadioSettingValueList(self._BEACON_INT, - self._BEACON_INT[aprs.beacon_interval]) + val = RadioSettingValueList( + self._BEACON_INT, self._BEACON_INT[aprs.beacon_interval]) rs = RadioSetting("aprs.beacon_interval", "Beacon Interval", val) menu.append(rs)
@@ -1137,11 +1146,11 @@ class VX8DRadio(VX8Radio):
# Show friendly messages for empty slots rather than blanks. # TODO: Rebuild this when digi_path_[34567] change. - #path_str[3] = path_str[3] or self._DIGI_PATHS[3] - #path_str[4] = path_str[4] or self._DIGI_PATHS[4] - #path_str[5] = path_str[5] or self._DIGI_PATHS[5] - #path_str[6] = path_str[6] or self._DIGI_PATHS[6] - #path_str[7] = path_str[7] or self._DIGI_PATHS[7] + # path_str[3] = path_str[3] or self._DIGI_PATHS[3] + # path_str[4] = path_str[4] or self._DIGI_PATHS[4] + # path_str[5] = path_str[5] or self._DIGI_PATHS[5] + # path_str[6] = path_str[6] or self._DIGI_PATHS[6] + # path_str[7] = path_str[7] or self._DIGI_PATHS[7] path_str[3] = self._DIGI_PATHS[3] path_str[4] = self._DIGI_PATHS[4] path_str[5] = self._DIGI_PATHS[5] @@ -1222,13 +1231,15 @@ class VX8DRadio(VX8Radio): val = RadioSettingValueList( self._DTMF_SPEED, self._DTMF_SPEED[dtmf.dtmf_speed]) - rs = RadioSetting("scan_settings.dtmf_speed", "DTMF AutoDial Speed", val) + rs = RadioSetting("scan_settings.dtmf_speed", + "DTMF AutoDial Speed", val) menu.append(rs)
val = RadioSettingValueList( self._DTMF_DELAY, self._DTMF_DELAY[dtmf.dtmf_delay]) - rs = RadioSetting("scan_settings.dtmf_delay", "DTMF AutoDial Delay", val) + rs = RadioSetting("scan_settings.dtmf_delay", + "DTMF AutoDial Delay", val) menu.append(rs)
for i in range(10): @@ -1297,7 +1308,7 @@ class VX8DRadio(VX8Radio): val = RadioSettingValueString(0, 16, msg) rs = RadioSetting("opening_message.message.padded_yaesu", "Opening Message", val) - rs.set_apply_callback(self.apply_ff_padded_yaesu, + rs.set_apply_callback(self.apply_ff_padded_yaesu, opening_message.message) menu.append(rs)
@@ -1538,6 +1549,7 @@ class VX8DRadio(VX8Radio): val.append(0xFF) cls._memobj.dtmf[i].memory = val
+ @directory.register class VX8GERadio(VX8DRadio): """Yaesu VX-8GE""" diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index cb89d2d..8fda851 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -23,4 +23,3 @@ ./chirp/drivers/th_uvf8d.py ./chirp/drivers/tmv71.py ./chirp/drivers/tmv71_ll.py -./chirp/drivers/vx8.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID 7021be6b7f7cb65e9694b85b4ff72ab54b2b3683
Fix style issues in th9800.py (#2355)
diff --git a/chirp/drivers/th9800.py b/chirp/drivers/th9800.py index 1f1d498..2d7e3c6 100644 --- a/chirp/drivers/th9800.py +++ b/chirp/drivers/th9800.py @@ -161,489 +161,526 @@ POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=5.00), chirp_common.PowerLevel("Mid1", watts=20.00), chirp_common.PowerLevel("High", watts=50.00)] BUSY_LOCK = ["off", "Carrier", "2 tone"] -MICKEYFUNC = ["None","SCAN","SQL.OFF","TCALL","PPTR","PRI","LOW","TONE", - "MHz","REV","HOME","BAND","VFO/MR"] +MICKEYFUNC = ["None", "SCAN", "SQL.OFF", "TCALL", "PPTR", "PRI", "LOW", "TONE", + "MHz", "REV", "HOME", "BAND", "VFO/MR"] SQLPRESET = ["Off", "2", "5", "9", "Full"] BANDS = ["30MHz", "50MHz", "60MHz", "108MHz", "150MHz", "250MHz", "350MHz", "450MHz", "850MHz"] -STEPS = [ 2.5, 5.0, 6.25, 7.5, 8.33, 10.0, 12.5, - 15.0, 20.0, 25.0, 30.0, 50.0, 100.0 ] - +STEPS = [2.5, 5.0, 6.25, 7.5, 8.33, 10.0, 12.5, + 15.0, 20.0, 25.0, 30.0, 50.0, 100.0] + + class TYTTH9800Base(chirp_common.Radio): - """Base class for TYT TH-9800""" - VENDOR = "TYT" - def get_features(self): - rf = chirp_common.RadioFeatures() - rf.memory_bounds = (1, 800) - rf.has_bank = False - rf.has_tuning_step = True - rf.valid_tuning_steps = STEPS - rf.can_odd_split = True - rf.valid_duplexes = ["", "-", "+", "split", "off"] - rf.valid_tmodes = TMODES - rf.has_ctone = False - rf.valid_power_levels = POWER_LEVELS - rf.valid_characters = chirp_common.CHARSET_UPPER_NUMERIC + "#*-+" - rf.valid_bands = [( 26000000, 33000000), - ( 47000000, 54000000), - (108000000, 180000000), - (350000000, 399000000), - (430000000, 512000000), - (750000000, 947000000)] - rf.valid_skips = SCAN_MODES - rf.valid_modes = MODES + ["AM"] - rf.valid_name_length = 6 - rf.has_settings = True - return rf - - def process_mmap(self): - self._memobj = bitwise.parse( TH9800_MEM_FORMAT % - (self._mmap_offset, self._scanlimits_offset, self._settings_offset, - self._chan_active_offset, self._info_offset), self._mmap) - - def get_active(self, banktype, num): - """get active flag for channel active, scan enable, or priority banks""" - bank = getattr(self._memobj, banktype) - index = (num - 1) / 8 - bitpos = (num - 1) % 8 - mask = 2**bitpos - enabled = bank[index] & mask - if enabled: - return True - else: - return False - - def set_active(self, banktype, num, enable = True): - """set active flag for channel active, scan enable, or priority banks""" - bank = getattr(self._memobj, banktype) - index = (num - 1) / 8 - bitpos = (num - 1) % 8 - mask = 2**bitpos - if enable: - bank[index] |= mask - else: - bank[index] &= ~mask - - def get_raw_memory(self, number): - return repr(self._memobj.memory[number - 1]) - - def get_memory(self, number): - _mem = self._memobj.memory[number - 1] - mem = chirp_common.Memory() - mem.number = number - - mem.empty = not self.get_active("chan_active", number) - if mem.empty: - return mem - - mem.freq = int(_mem.rx_freq) * 10 - - txfreq = int(_mem.tx_freq) * 10 - if txfreq == mem.freq: - mem.duplex = "" - elif txfreq == 0: - mem.duplex = "off" - mem.offset = 0 - elif abs(txfreq - mem.freq) > 70000000: - mem.duplex = "split" - mem.offset = txfreq - elif txfreq < mem.freq: - mem.duplex = "-" - mem.offset = mem.freq - txfreq - elif txfreq > mem.freq: - mem.duplex = "+" - mem.offset = txfreq - mem.freq - - mem.dtcs_polarity = DTCS_POLARITY[_mem.dtcs_pol] - - mem.tmode = TMODES[int(_mem.tmode)] - mem.ctone = mem.rtone = int(_mem.ctcss) / 10.0 - mem.dtcs = int(_mem.dtcs) - - mem.name = str(_mem.name) - mem.name = mem.name.replace("\xFF", " ").rstrip() - - if not self.get_active("scan_enable", number): - mem.skip = "S" - elif self.get_active("priority", number): - mem.skip = "P" - else: - mem.skip = "" - - mem.mode = _mem.am and "AM" or MODES[int(_mem.fmdev)] - - mem.power = POWER_LEVELS[_mem.power] - mem.tuning_step = STEPS[_mem.step] - - mem.extra = RadioSettingGroup("extra", "Extra") - - opts = ["Frequency", "Name"] - display = RadioSetting("display", "Display", - RadioSettingValueList(opts, opts[_mem.display])) - mem.extra.append(display) - - bclo = RadioSetting("bclo", "Busy Lockout", - RadioSettingValueList(BUSY_LOCK, - BUSY_LOCK[_mem.bclo])) - bclo.set_doc("Busy Lockout") - mem.extra.append(bclo) - - emphasis = RadioSetting("emphasis", "Emphasis", - RadioSettingValueBoolean(bool(_mem.emphasis))) - emphasis.set_doc("Boosts 300Hz to 2500Hz mic response") - mem.extra.append(emphasis) - - compand = RadioSetting("compand", "Compand", - RadioSettingValueBoolean(bool(_mem.compand))) - compand.set_doc("Compress Audio") - mem.extra.append(compand) - - BeatShift = RadioSetting("BeatShift", "BeatShift", - RadioSettingValueBoolean(bool(_mem.BeatShift))) - BeatShift.set_doc("Beat Shift") - mem.extra.append(BeatShift) - - TalkAround = RadioSetting("talkaround", "Talk Around", - RadioSettingValueBoolean(bool(_mem.talkaround))) - TalkAround.set_doc("Simplex mode when out of range of repeater") - mem.extra.append(TalkAround) - - scramb = RadioSetting("scramb", "Scramble", - RadioSettingValueBoolean(bool(_mem.scramb))) - scramb.set_doc("Frequency inversion Scramble") - mem.extra.append(scramb) - - return mem - - def set_memory(self, mem): - _mem = self._memobj.memory[mem.number - 1] - - _prev_active = self.get_active("chan_active", mem.number) - self.set_active("chan_active", mem.number, not mem.empty) - if mem.empty or not _prev_active: - LOG.debug("initializing memory channel %d" % mem.number) - _mem.set_raw(BLANK_MEMORY) - - if mem.empty: - return - - _mem.rx_freq = mem.freq / 10 - if mem.duplex == "split": - _mem.tx_freq = mem.offset / 10 - elif mem.duplex == "-": - _mem.tx_freq = (mem.freq - mem.offset) / 10 - elif mem.duplex == "+": - _mem.tx_freq = (mem.freq + mem.offset) / 10 - elif mem.duplex == "off": - _mem.tx_freq = 0 - _mem.offset = 0 - else: - _mem.tx_freq = mem.freq / 10 - - _mem.tmode = TMODES.index(mem.tmode) - _mem.ctcss = mem.rtone * 10 - _mem.dtcs = mem.dtcs - _mem.dtcs_pol = DTCS_POLARITY.index(mem.dtcs_polarity) - - _mem.name = mem.name.ljust(6, "\xFF") - - # autoset display to name if filled, else show frequency - if mem.extra: - # mem.extra only seems to be populated when called from edit panel - display = mem.extra["display"] - else: - display = None - if mem.name: - _mem.display = True - if display and not display.changed(): - display.value = "Name" - else: - _mem.display = False - if display and not display.changed(): - display.value = "Frequency" - - _mem.scan = SCAN_MODES.index(mem.skip) - if mem.skip == "P": - self.set_active("priority", mem.number, True) - self.set_active("scan_enable", mem.number, True) - elif mem.skip == "S": - self.set_active("priority", mem.number, False) - self.set_active("scan_enable", mem.number, False) - elif mem.skip == "": - self.set_active("priority", mem.number, False) - self.set_active("scan_enable", mem.number, True) - - if mem.mode == "AM": - _mem.am = True - _mem.fmdev = 0 - else: - _mem.am = False - _mem.fmdev = MODES.index(mem.mode) - - if mem.power: - _mem.power = POWER_LEVELS.index(mem.power) - else: - _mem.power = 0 # low - _mem.step = STEPS.index(mem.tuning_step) - - for setting in mem.extra: - LOG.debug("@set_mem:", setting.get_name(), setting.value) - setattr(_mem, setting.get_name(), setting.value) - - def get_settings(self): - _settings = self._memobj.settings - _info = self._memobj.info - _bandlimits = self._memobj.bandlimits - basic = RadioSettingGroup("basic", "Basic") - info = RadioSettingGroup("info", "Model Info") - top = RadioSettings(basic, info) - basic.append( RadioSetting("beep", "Beep", - RadioSettingValueBoolean(_settings.beep))) - basic.append( RadioSetting("beep_vol", "Beep Volume", - RadioSettingValueInteger(0, 15,_settings.beep_vol))) - basic.append( RadioSetting("keylock", "Key Lock", - RadioSettingValueBoolean(_settings.keylock))) - basic.append( RadioSetting("ani_display", "ANI Display", - RadioSettingValueBoolean(_settings.ani_display))) - basic.append( RadioSetting("auto_xfer", "Auto Transfer", - RadioSettingValueBoolean(_settings.auto_xfer))) - basic.append( RadioSetting("auto_contact", - "Auto Contact Always Remind", - RadioSettingValueBoolean(_settings.auto_contact))) - basic.append( RadioSetting("auto_am", "Auto AM", - RadioSettingValueBoolean(_settings.auto_am))) - basic.append( RadioSetting("left_sql", "Left Squelch", - RadioSettingValueList(SQLPRESET, - SQLPRESET[_settings.left_sql]))) - basic.append( RadioSetting("right_sql", "Right Squelch", - RadioSettingValueList(SQLPRESET, - SQLPRESET[_settings.right_sql]))) -# basic.append( RadioSetting("apo", "Auto Power off (0.1h)", -# RadioSettingValueInteger(0, 20,_settings.apo))) - opts = ["Off"] + ["%0.1f" % (t / 10.0) for t in range(1,21,1) ] - basic.append( RadioSetting("apo", "Auto Power off (Hours)", - RadioSettingValueList(opts, opts[_settings.apo]))) - opts = ["Off", "1", "2", "3", "Full"] - basic.append( RadioSetting("backlight", "Display Backlight", - RadioSettingValueList(opts, opts[_settings.backlight]))) - opts = ["Off", "Right", "Left", "Both"] - basic.append( RadioSetting("pttlock", "PTT Lock", - RadioSettingValueList(opts, opts[_settings.pttlock]))) - opts = ["Manual", "Auto"] - basic.append( RadioSetting("hyper_chan", "Hyper Channel", - RadioSettingValueList(opts, opts[_settings.hyper_chan]))) - opts = ["Key 1", "Key 2"] - basic.append( RadioSetting("right_func_key", "Right Function Key", - RadioSettingValueList(opts, opts[_settings.right_func_key]))) - opts = ["1000Hz", "1450Hz", "1750Hz", "2100Hz"] - basic.append( RadioSetting("tbst_freq", "Tone Burst Frequency", - RadioSettingValueList(opts, opts[_settings.tbst_freq]))) - opts = ["Off", "TX", "RX", "TX RX"] - basic.append( RadioSetting("mute_mode", "Mute Mode", - RadioSettingValueList(opts, opts[_settings.mute_mode]))) - opts = ["MEM", "MSM"] - scanmode = RadioSetting("scan_mode", "Scan Mode", - RadioSettingValueList(opts, opts[_settings.scan_mode])) - scanmode.set_doc("MEM = Normal scan, bypass channels marked skip. " \ - " MSM = Scan only channels marked priority.") - basic.append(scanmode) - opts = ["TO", "CO"] - basic.append( RadioSetting("scan_resume", "Scan Resume", - RadioSettingValueList(opts, opts[_settings.scan_resume]))) - opts = ["%0.1f" % (t / 10.0) for t in range(0,51,1) ] - basic.append( RadioSetting("exit_delay", "Span Transit Exit Delay", - RadioSettingValueList(opts, opts[_settings.exit_delay]))) - basic.append( RadioSetting("tot", "Time Out Timer (minutes)", - RadioSettingValueInteger(0, 30,_settings.tot))) - basic.append( RadioSetting("tot_alert", - "Time Out Timer Pre Alert(seconds)", - RadioSettingValueInteger(0, 15,_settings.tot_alert))) - basic.append( RadioSetting("tot_rekey", "Time Out Rekey (seconds)", - RadioSettingValueInteger(0, 15,_settings.tot_rekey))) - basic.append( RadioSetting("tot_reset", "Time Out Reset(seconds)", - RadioSettingValueInteger(0, 15,_settings.tot_reset))) - basic.append( RadioSetting("p1", "P1 Function", - RadioSettingValueList(MICKEYFUNC, MICKEYFUNC[_settings.p1]))) - basic.append( RadioSetting("p2", "P2 Function", - RadioSettingValueList(MICKEYFUNC, MICKEYFUNC[_settings.p2]))) - basic.append( RadioSetting("p3", "P3 Function", - RadioSettingValueList(MICKEYFUNC, MICKEYFUNC[_settings.p3]))) - basic.append( RadioSetting("p4", "P4 Function", - RadioSettingValueList(MICKEYFUNC, MICKEYFUNC[_settings.p4]))) + """Base class for TYT TH-9800""" + VENDOR = "TYT" + + def get_features(self): + rf = chirp_common.RadioFeatures() + rf.memory_bounds = (1, 800) + rf.has_bank = False + rf.has_tuning_step = True + rf.valid_tuning_steps = STEPS + rf.can_odd_split = True + rf.valid_duplexes = ["", "-", "+", "split", "off"] + rf.valid_tmodes = TMODES + rf.has_ctone = False + rf.valid_power_levels = POWER_LEVELS + rf.valid_characters = chirp_common.CHARSET_UPPER_NUMERIC + "#*-+" + rf.valid_bands = [(26000000, 33000000), + (47000000, 54000000), + (108000000, 180000000), + (350000000, 399000000), + (430000000, 512000000), + (750000000, 947000000)] + rf.valid_skips = SCAN_MODES + rf.valid_modes = MODES + ["AM"] + rf.valid_name_length = 6 + rf.has_settings = True + return rf + + def process_mmap(self): + self._memobj = bitwise.parse( + TH9800_MEM_FORMAT % + (self._mmap_offset, self._scanlimits_offset, self._settings_offset, + self._chan_active_offset, self._info_offset), self._mmap) + + def get_active(self, banktype, num): + """get active flag for channel active, + scan enable, or priority banks""" + bank = getattr(self._memobj, banktype) + index = (num - 1) / 8 + bitpos = (num - 1) % 8 + mask = 2**bitpos + enabled = bank[index] & mask + if enabled: + return True + else: + return False + + def set_active(self, banktype, num, enable=True): + """set active flag for channel active, + scan enable, or priority banks""" + bank = getattr(self._memobj, banktype) + index = (num - 1) / 8 + bitpos = (num - 1) % 8 + mask = 2**bitpos + if enable: + bank[index] |= mask + else: + bank[index] &= ~mask + + def get_raw_memory(self, number): + return repr(self._memobj.memory[number - 1]) + + def get_memory(self, number): + _mem = self._memobj.memory[number - 1] + mem = chirp_common.Memory() + mem.number = number + + mem.empty = not self.get_active("chan_active", number) + if mem.empty: + return mem + + mem.freq = int(_mem.rx_freq) * 10 + + txfreq = int(_mem.tx_freq) * 10 + if txfreq == mem.freq: + mem.duplex = "" + elif txfreq == 0: + mem.duplex = "off" + mem.offset = 0 + elif abs(txfreq - mem.freq) > 70000000: + mem.duplex = "split" + mem.offset = txfreq + elif txfreq < mem.freq: + mem.duplex = "-" + mem.offset = mem.freq - txfreq + elif txfreq > mem.freq: + mem.duplex = "+" + mem.offset = txfreq - mem.freq + + mem.dtcs_polarity = DTCS_POLARITY[_mem.dtcs_pol] + + mem.tmode = TMODES[int(_mem.tmode)] + mem.ctone = mem.rtone = int(_mem.ctcss) / 10.0 + mem.dtcs = int(_mem.dtcs) + + mem.name = str(_mem.name) + mem.name = mem.name.replace("\xFF", " ").rstrip() + + if not self.get_active("scan_enable", number): + mem.skip = "S" + elif self.get_active("priority", number): + mem.skip = "P" + else: + mem.skip = "" + + mem.mode = _mem.am and "AM" or MODES[int(_mem.fmdev)] + + mem.power = POWER_LEVELS[_mem.power] + mem.tuning_step = STEPS[_mem.step] + + mem.extra = RadioSettingGroup("extra", "Extra") + + opts = ["Frequency", "Name"] + display = RadioSetting( + "display", "Display", + RadioSettingValueList(opts, opts[_mem.display])) + mem.extra.append(display) + + bclo = RadioSetting( + "bclo", "Busy Lockout", + RadioSettingValueList(BUSY_LOCK, BUSY_LOCK[_mem.bclo])) + bclo.set_doc("Busy Lockout") + mem.extra.append(bclo) + + emphasis = RadioSetting( + "emphasis", "Emphasis", + RadioSettingValueBoolean(bool(_mem.emphasis))) + emphasis.set_doc("Boosts 300Hz to 2500Hz mic response") + mem.extra.append(emphasis) + + compand = RadioSetting( + "compand", "Compand", + RadioSettingValueBoolean(bool(_mem.compand))) + compand.set_doc("Compress Audio") + mem.extra.append(compand) + + BeatShift = RadioSetting( + "BeatShift", "BeatShift", + RadioSettingValueBoolean(bool(_mem.BeatShift))) + BeatShift.set_doc("Beat Shift") + mem.extra.append(BeatShift) + + TalkAround = RadioSetting( + "talkaround", "Talk Around", + RadioSettingValueBoolean(bool(_mem.talkaround))) + TalkAround.set_doc("Simplex mode when out of range of repeater") + mem.extra.append(TalkAround) + + scramb = RadioSetting( + "scramb", "Scramble", + RadioSettingValueBoolean(bool(_mem.scramb))) + scramb.set_doc("Frequency inversion Scramble") + mem.extra.append(scramb) + + return mem + + def set_memory(self, mem): + _mem = self._memobj.memory[mem.number - 1] + + _prev_active = self.get_active("chan_active", mem.number) + self.set_active("chan_active", mem.number, not mem.empty) + if mem.empty or not _prev_active: + LOG.debug("initializing memory channel %d" % mem.number) + _mem.set_raw(BLANK_MEMORY) + + if mem.empty: + return + + _mem.rx_freq = mem.freq / 10 + if mem.duplex == "split": + _mem.tx_freq = mem.offset / 10 + elif mem.duplex == "-": + _mem.tx_freq = (mem.freq - mem.offset) / 10 + elif mem.duplex == "+": + _mem.tx_freq = (mem.freq + mem.offset) / 10 + elif mem.duplex == "off": + _mem.tx_freq = 0 + _mem.offset = 0 + else: + _mem.tx_freq = mem.freq / 10 + + _mem.tmode = TMODES.index(mem.tmode) + _mem.ctcss = mem.rtone * 10 + _mem.dtcs = mem.dtcs + _mem.dtcs_pol = DTCS_POLARITY.index(mem.dtcs_polarity) + + _mem.name = mem.name.ljust(6, "\xFF") + + # autoset display to name if filled, else show frequency + if mem.extra: + # mem.extra only seems to be populated when called from edit panel + display = mem.extra["display"] + else: + display = None + if mem.name: + _mem.display = True + if display and not display.changed(): + display.value = "Name" + else: + _mem.display = False + if display and not display.changed(): + display.value = "Frequency" + + _mem.scan = SCAN_MODES.index(mem.skip) + if mem.skip == "P": + self.set_active("priority", mem.number, True) + self.set_active("scan_enable", mem.number, True) + elif mem.skip == "S": + self.set_active("priority", mem.number, False) + self.set_active("scan_enable", mem.number, False) + elif mem.skip == "": + self.set_active("priority", mem.number, False) + self.set_active("scan_enable", mem.number, True) + + if mem.mode == "AM": + _mem.am = True + _mem.fmdev = 0 + else: + _mem.am = False + _mem.fmdev = MODES.index(mem.mode) + + if mem.power: + _mem.power = POWER_LEVELS.index(mem.power) + else: + _mem.power = 0 # low + _mem.step = STEPS.index(mem.tuning_step) + + for setting in mem.extra: + LOG.debug("@set_mem:", setting.get_name(), setting.value) + setattr(_mem, setting.get_name(), setting.value) + + def get_settings(self): + _settings = self._memobj.settings + _info = self._memobj.info + _bandlimits = self._memobj.bandlimits + basic = RadioSettingGroup("basic", "Basic") + info = RadioSettingGroup("info", "Model Info") + top = RadioSettings(basic, info) + basic.append(RadioSetting( + "beep", "Beep", + RadioSettingValueBoolean(_settings.beep))) + basic.append(RadioSetting( + "beep_vol", "Beep Volume", + RadioSettingValueInteger(0, 15, _settings.beep_vol))) + basic.append(RadioSetting( + "keylock", "Key Lock", + RadioSettingValueBoolean(_settings.keylock))) + basic.append(RadioSetting( + "ani_display", "ANI Display", + RadioSettingValueBoolean(_settings.ani_display))) + basic.append(RadioSetting( + "auto_xfer", "Auto Transfer", + RadioSettingValueBoolean(_settings.auto_xfer))) + basic.append(RadioSetting( + "auto_contact", "Auto Contact Always Remind", + RadioSettingValueBoolean(_settings.auto_contact))) + basic.append(RadioSetting( + "auto_am", "Auto AM", + RadioSettingValueBoolean(_settings.auto_am))) + basic.append(RadioSetting( + "left_sql", "Left Squelch", + RadioSettingValueList( + SQLPRESET, SQLPRESET[_settings.left_sql]))) + basic.append(RadioSetting( + "right_sql", "Right Squelch", + RadioSettingValueList( + SQLPRESET, SQLPRESET[_settings.right_sql]))) +# basic.append(RadioSetting("apo", "Auto Power off (0.1h)", +# RadioSettingValueInteger(0, 20, _settings.apo))) + opts = ["Off"] + ["%0.1f" % (t / 10.0) for t in range(1, 21, 1)] + basic.append(RadioSetting( + "apo", "Auto Power off (Hours)", + RadioSettingValueList(opts, opts[_settings.apo]))) + opts = ["Off", "1", "2", "3", "Full"] + basic.append(RadioSetting( + "backlight", "Display Backlight", + RadioSettingValueList(opts, opts[_settings.backlight]))) + opts = ["Off", "Right", "Left", "Both"] + basic.append(RadioSetting( + "pttlock", "PTT Lock", + RadioSettingValueList(opts, opts[_settings.pttlock]))) + opts = ["Manual", "Auto"] + basic.append(RadioSetting( + "hyper_chan", "Hyper Channel", + RadioSettingValueList(opts, opts[_settings.hyper_chan]))) + opts = ["Key 1", "Key 2"] + basic.append(RadioSetting( + "right_func_key", "Right Function Key", + RadioSettingValueList(opts, opts[_settings.right_func_key]))) + opts = ["1000Hz", "1450Hz", "1750Hz", "2100Hz"] + basic.append(RadioSetting( + "tbst_freq", "Tone Burst Frequency", + RadioSettingValueList(opts, opts[_settings.tbst_freq]))) + opts = ["Off", "TX", "RX", "TX RX"] + basic.append(RadioSetting( + "mute_mode", "Mute Mode", + RadioSettingValueList(opts, opts[_settings.mute_mode]))) + opts = ["MEM", "MSM"] + scanmode = RadioSetting( + "scan_mode", "Scan Mode", + RadioSettingValueList(opts, opts[_settings.scan_mode])) + scanmode.set_doc("MEM = Normal scan, bypass channels marked skip. " + " MSM = Scan only channels marked priority.") + basic.append(scanmode) + opts = ["TO", "CO"] + basic.append(RadioSetting( + "scan_resume", "Scan Resume", + RadioSettingValueList(opts, opts[_settings.scan_resume]))) + opts = ["%0.1f" % (t / 10.0) for t in range(0, 51, 1)] + basic.append(RadioSetting( + "exit_delay", "Span Transit Exit Delay", + RadioSettingValueList(opts, opts[_settings.exit_delay]))) + basic.append(RadioSetting( + "tot", "Time Out Timer (minutes)", + RadioSettingValueInteger(0, 30, _settings.tot))) + basic.append(RadioSetting( + "tot_alert", "Time Out Timer Pre Alert(seconds)", + RadioSettingValueInteger(0, 15, _settings.tot_alert))) + basic.append(RadioSetting( + "tot_rekey", "Time Out Rekey (seconds)", + RadioSettingValueInteger(0, 15, _settings.tot_rekey))) + basic.append(RadioSetting( + "tot_reset", "Time Out Reset(seconds)", + RadioSettingValueInteger(0, 15, _settings.tot_reset))) + basic.append(RadioSetting( + "p1", "P1 Function", + RadioSettingValueList(MICKEYFUNC, MICKEYFUNC[_settings.p1]))) + basic.append(RadioSetting( + "p2", "P2 Function", + RadioSettingValueList(MICKEYFUNC, MICKEYFUNC[_settings.p2]))) + basic.append(RadioSetting( + "p3", "P3 Function", + RadioSettingValueList(MICKEYFUNC, MICKEYFUNC[_settings.p3]))) + basic.append(RadioSetting( + "p4", "P4 Function", + RadioSettingValueList(MICKEYFUNC, MICKEYFUNC[_settings.p4]))) # opts = ["0", "1"] -# basic.append( RadioSetting("x", "Desc", +# basic.append(RadioSetting("x", "Desc", # RadioSettingValueList(opts, opts[_settings.x])))
- def _filter(name): - filtered = "" - for char in str(name): - if char in chirp_common.CHARSET_ASCII: - filtered += char - else: - filtered += " " - return filtered - - rsvs = RadioSettingValueString(0, 8, _filter(_info.sn)) - rsvs.set_mutable(False) - rs = RadioSetting("sn", "Serial Number", rsvs) - info.append(rs) - - rsvs = RadioSettingValueString(0, 8, _filter(_info.model)) - rsvs.set_mutable(False) - rs = RadioSetting("model", "Model Name", rsvs) - info.append(rs) - - rsvs = RadioSettingValueString(0, 16, _filter(_info.code)) - rsvs.set_mutable(False) - rs = RadioSetting("code", "Model Code", rsvs) - info.append(rs) - - progdate = "%d/%d/%d" % (_info.prog_mon, _info.prog_day, - _info.prog_yr ) - rsvs = RadioSettingValueString(0, 10, progdate) - rsvs.set_mutable(False) - rs = RadioSetting("progdate", "Last Program Date", rsvs) - info.append(rs) - - # 9 band limits - for i in range(0,9): - objname = BANDS[i] + "lorx" - objnamepp = BANDS[i] + " Rx Start" - #rsv = RadioSettingValueInteger(0,100000000, - # int(_bandlimits[i].lorx)) - rsv = RadioSettingValueString(0,10, - format_freq(int(_bandlimits[i].lorx)*10)) - rsv.set_mutable(False) - rs = RadioSetting(objname, objnamepp, rsv) - info.append(rs) - objname = BANDS[i] + "hirx" - objnamepp = BANDS[i] + " Rx end" - rsv = RadioSettingValueString(0,10, - format_freq(int(_bandlimits[i].hirx)*10)) - rsv.set_mutable(False) - rs = RadioSetting(objname, objnamepp, rsv) - info.append(rs) - objname = BANDS[i] + "lotx" - objnamepp = BANDS[i] + " Tx Start" - rsv = RadioSettingValueString(0,10, - format_freq(int(_bandlimits[i].lotx)*10)) - rsv.set_mutable(False) - rs = RadioSetting(objname, objnamepp, rsv) - info.append(rs) - objname = BANDS[i] + "hitx" - objnamepp = BANDS[i] + " Tx end" - rsv = RadioSettingValueString(0,10, - format_freq(int(_bandlimits[i].hitx)*10)) - rsv.set_mutable(False) - rs = RadioSetting(objname, objnamepp, rsv) - info.append(rs) - - return top - - def set_settings(self, settings): - _settings = self._memobj.settings - _info = self._memobj.info - _bandlimits = self._memobj.bandlimits - for element in settings: - if not isinstance(element, RadioSetting): - self.set_settings(element) - continue - if not element.changed(): - continue - try: - setting = element.get_name() - oldval = getattr(_settings, setting) - newval = element.value - - LOG.debug("Setting %s(%s) <= %s" % (setting, oldval, newval)) - setattr(_settings, setting, newval) - except Exception, e: - print element.get_name() - raise + def _filter(name): + filtered = "" + for char in str(name): + if char in chirp_common.CHARSET_ASCII: + filtered += char + else: + filtered += " " + return filtered + + rsvs = RadioSettingValueString(0, 8, _filter(_info.sn)) + rsvs.set_mutable(False) + rs = RadioSetting("sn", "Serial Number", rsvs) + info.append(rs) + + rsvs = RadioSettingValueString(0, 8, _filter(_info.model)) + rsvs.set_mutable(False) + rs = RadioSetting("model", "Model Name", rsvs) + info.append(rs) + + rsvs = RadioSettingValueString(0, 16, _filter(_info.code)) + rsvs.set_mutable(False) + rs = RadioSetting("code", "Model Code", rsvs) + info.append(rs) + + progdate = "%d/%d/%d" % (_info.prog_mon, _info.prog_day, + _info.prog_yr) + rsvs = RadioSettingValueString(0, 10, progdate) + rsvs.set_mutable(False) + rs = RadioSetting("progdate", "Last Program Date", rsvs) + info.append(rs) + + # 9 band limits + for i in range(0, 9): + objname = BANDS[i] + "lorx" + objnamepp = BANDS[i] + " Rx Start" + # rsv = RadioSettingValueInteger(0, 100000000, + # int(_bandlimits[i].lorx)) + rsv = RadioSettingValueString( + 0, 10, format_freq(int(_bandlimits[i].lorx)*10)) + rsv.set_mutable(False) + rs = RadioSetting(objname, objnamepp, rsv) + info.append(rs) + objname = BANDS[i] + "hirx" + objnamepp = BANDS[i] + " Rx end" + rsv = RadioSettingValueString( + 0, 10, format_freq(int(_bandlimits[i].hirx)*10)) + rsv.set_mutable(False) + rs = RadioSetting(objname, objnamepp, rsv) + info.append(rs) + objname = BANDS[i] + "lotx" + objnamepp = BANDS[i] + " Tx Start" + rsv = RadioSettingValueString( + 0, 10, format_freq(int(_bandlimits[i].lotx)*10)) + rsv.set_mutable(False) + rs = RadioSetting(objname, objnamepp, rsv) + info.append(rs) + objname = BANDS[i] + "hitx" + objnamepp = BANDS[i] + " Tx end" + rsv = RadioSettingValueString( + 0, 10, format_freq(int(_bandlimits[i].hitx)*10)) + rsv.set_mutable(False) + rs = RadioSetting(objname, objnamepp, rsv) + info.append(rs) + + return top + + def set_settings(self, settings): + _settings = self._memobj.settings + _info = self._memobj.info + _bandlimits = self._memobj.bandlimits + for element in settings: + if not isinstance(element, RadioSetting): + self.set_settings(element) + continue + if not element.changed(): + continue + try: + setting = element.get_name() + oldval = getattr(_settings, setting) + newval = element.value + + LOG.debug("Setting %s(%s) <= %s" % (setting, oldval, newval)) + setattr(_settings, setting, newval) + except Exception, e: + print element.get_name() + raise +
@directory.register class TYTTH9800File(TYTTH9800Base, chirp_common.FileBackedRadio): - """TYT TH-9800 .dat file""" - MODEL = "TH-9800 File" + """TYT TH-9800 .dat file""" + MODEL = "TH-9800 File"
- FILE_EXTENSION = "dat" + FILE_EXTENSION = "dat"
- _memsize = 69632 - _mmap_offset = 0x1100 - _scanlimits_offset = 0xC800 + _mmap_offset - _settings_offset = 0xCB20 + _mmap_offset - _chan_active_offset = 0xCB80 + _mmap_offset - _info_offset = 0xfe00 + _mmap_offset - - def __init__(self, pipe): - self.errors = [] - self._mmap = None + _memsize = 69632 + _mmap_offset = 0x1100 + _scanlimits_offset = 0xC800 + _mmap_offset + _settings_offset = 0xCB20 + _mmap_offset + _chan_active_offset = 0xCB80 + _mmap_offset + _info_offset = 0xfe00 + _mmap_offset
- if isinstance(pipe, str): - self.pipe = None - self.load_mmap(pipe) - else: - chirp_common.FileBackedRadio.__init__(self, pipe) + def __init__(self, pipe): + self.errors = [] + self._mmap = None
- @classmethod - def match_model(cls, filedata, filename): - return len(filedata) == cls._memsize and filename.endswith('.dat') + if isinstance(pipe, str): + self.pipe = None + self.load_mmap(pipe) + else: + chirp_common.FileBackedRadio.__init__(self, pipe) + + @classmethod + def match_model(cls, filedata, filename): + return len(filedata) == cls._memsize and filename.endswith('.dat')
def _identify(radio): - """Do identify handshake with TYT""" - try: - radio.pipe.write("\x02PROGRA") - ack = radio.pipe.read(1) - if ack != "A": - util.hexprint(ack) - raise errors.RadioError("Radio did not ACK first command: %x" - % ord(ack)) - except: - print util.hexprint(ack) - raise errors.RadioError("Unable to communicate with the radio") - - radio.pipe.write("M\x02") - ident = radio.pipe.read(16) - radio.pipe.write("A") - r = radio.pipe.read(1) - if r != "A": - raise errors.RadioError("Ack failed") - return ident - - -def _download(radio, memsize = 0x10000, blocksize = 0x80): - """Download from TYT TH-9800""" - data = _identify(radio) - print "ident:", util.hexprint(data) - offset = 0x100 - for addr in range(offset, memsize, blocksize): - msg = struct.pack(">cHB", "R", addr, blocksize) - radio.pipe.write(msg) - block = radio.pipe.read(blocksize + 4) - if len(block) != (blocksize + 4): - print util.hexprint(block) - raise errors.RadioError("Radio sent a short block") - radio.pipe.write("A") - ack = radio.pipe.read(1) - if ack != "A": + """Do identify handshake with TYT""" + try: + radio.pipe.write("\x02PROGRA") + ack = radio.pipe.read(1) + if ack != "A": + util.hexprint(ack) + raise errors.RadioError("Radio did not ACK first command: %x" + % ord(ack)) + except: print util.hexprint(ack) - raise errors.RadioError("Radio NAKed block") - data += block[4:] + raise errors.RadioError("Unable to communicate with the radio")
- if radio.status_fn: - status = chirp_common.Status() - status.cur = addr - status.max = memsize - status.msg = "Cloning from radio" - radio.status_fn(status) + radio.pipe.write("M\x02") + ident = radio.pipe.read(16) + radio.pipe.write("A") + r = radio.pipe.read(1) + if r != "A": + raise errors.RadioError("Ack failed") + return ident
- radio.pipe.write("ENDR")
- return memmap.MemoryMap(data) +def _download(radio, memsize=0x10000, blocksize=0x80): + """Download from TYT TH-9800""" + data = _identify(radio) + print "ident:", util.hexprint(data) + offset = 0x100 + for addr in range(offset, memsize, blocksize): + msg = struct.pack(">cHB", "R", addr, blocksize) + radio.pipe.write(msg) + block = radio.pipe.read(blocksize + 4) + if len(block) != (blocksize + 4): + print util.hexprint(block) + raise errors.RadioError("Radio sent a short block") + radio.pipe.write("A") + ack = radio.pipe.read(1) + if ack != "A": + print util.hexprint(ack) + raise errors.RadioError("Radio NAKed block") + data += block[4:]
+ if radio.status_fn: + status = chirp_common.Status() + status.cur = addr + status.max = memsize + status.msg = "Cloning from radio" + radio.status_fn(status)
-def _upload(radio, memsize = 0xF400, blocksize = 0x80): + radio.pipe.write("ENDR") + + return memmap.MemoryMap(data) + + +def _upload(radio, memsize=0xF400, blocksize=0x80): """Upload to TYT TH-9800""" data = _identify(radio)
@@ -651,8 +688,9 @@ def _upload(radio, memsize = 0xF400, blocksize = 0x80):
if data != radio._mmap[:radio._mmap_offset]: raise errors.RadioError( - "Model mis-match: \n%s\n%s" % (util.hexprint(data), - util.hexprint(radio._mmap[:radio._mmap_offset]))) + "Model mis-match: \n%s\n%s" % + (util.hexprint(data), + util.hexprint(radio._mmap[:radio._mmap_offset]))) # in the factory software they update the last program date when # they upload, So let's do the same today = date.today() @@ -664,8 +702,8 @@ def _upload(radio, memsize = 0xF400, blocksize = 0x80): ly = _info.prog_yr lm = _info.prog_mon ld = _info.prog_day - LOG.debug("Updating last program date:%d/%d/%d" % (lm,ld,ly)) - LOG.debug(" to today:%d/%d/%d" % (m,d,y)) + LOG.debug("Updating last program date:%d/%d/%d" % (lm, ld, ly)) + LOG.debug(" to today:%d/%d/%d" % (m, d, y))
_info.prog_yr = y _info.prog_mon = m @@ -675,14 +713,14 @@ def _upload(radio, memsize = 0xF400, blocksize = 0x80): for addr in range(offset, memsize, blocksize): mapaddr = addr + radio._mmap_offset - offset LOG.debug("addr: 0x%04X, mmapaddr: 0x%04X" % (addr, mapaddr)) - msg = struct.pack(">cHB", "W", addr, blocksize) + msg = struct.pack(">cHB", "W", addr, blocksize) msg += radio._mmap[mapaddr:(mapaddr + blocksize)] print util.hexprint(msg) radio.pipe.write(msg) ack = radio.pipe.read(1) if ack != "A": - print util.hexprint(ack) - raise errors.RadioError("Radio did not ack block 0x%04X" % addr) + print util.hexprint(ack) + raise errors.RadioError("Radio did not ack block 0x%04X" % addr)
if radio.status_fn: status = chirp_common.Status() @@ -698,47 +736,47 @@ def _upload(radio, memsize = 0xF400, blocksize = 0x80): final_data = radio.pipe.read(3) LOG.debug("final:", util.hexprint(final_data))
+ @directory.register class TYTTH9800Radio(TYTTH9800Base, chirp_common.CloneModeRadio, chirp_common.ExperimentalRadio): - VENDOR = "TYT" - MODEL = "TH-9800" - BAUD_RATE = 38400 - - _memsize = 65296 - _mmap_offset = 0x0010 - _scanlimits_offset = 0xC800 + _mmap_offset - _settings_offset = 0xCB20 + _mmap_offset - _chan_active_offset = 0xCB80 + _mmap_offset - _info_offset = 0xfe00 + _mmap_offset - - @classmethod - def match_model(cls, filedata, filename): - return len(filedata) == cls._memsize - - @classmethod - def get_prompts(cls): - rp = chirp_common.RadioPrompts() - rp.experimental = ( - 'This is experimental support for TH-9800 ' - 'which is still under development.\n' - 'Please ensure you have a good backup with OEM software.\n' - 'Also please send in bug and enhancement requests!\n' - 'You have been warned. Proceed at your own risk!') - return rp - - def sync_in(self): + VENDOR = "TYT" + MODEL = "TH-9800" + BAUD_RATE = 38400 + + _memsize = 65296 + _mmap_offset = 0x0010 + _scanlimits_offset = 0xC800 + _mmap_offset + _settings_offset = 0xCB20 + _mmap_offset + _chan_active_offset = 0xCB80 + _mmap_offset + _info_offset = 0xfe00 + _mmap_offset + + @classmethod + def match_model(cls, filedata, filename): + return len(filedata) == cls._memsize + + @classmethod + def get_prompts(cls): + rp = chirp_common.RadioPrompts() + rp.experimental = ( + 'This is experimental support for TH-9800 ' + 'which is still under development.\n' + 'Please ensure you have a good backup with OEM software.\n' + 'Also please send in bug and enhancement requests!\n' + 'You have been warned. Proceed at your own risk!') + return rp + + def sync_in(self): try: self._mmap = _download(self) except Exception, e: - raise errors.RadioError( \ - "Failed to communicate with the radio: %s" % e) + raise errors.RadioError( + "Failed to communicate with the radio: %s" % e) self.process_mmap()
- def sync_out(self): + def sync_out(self): try: _upload(self) except Exception, e: - raise errors.RadioError( \ - "Failed to communicate with the radio: %s" % e) - + raise errors.RadioError( + "Failed to communicate with the radio: %s" % e) diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 8fda851..a92e97b 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -17,7 +17,6 @@ ./chirp/drivers/icw32.py ./chirp/drivers/icx8x.py ./chirp/drivers/icx8x_ll.py -./chirp/drivers/th9800.py ./chirp/drivers/th_uv3r.py ./chirp/drivers/th_uv3r25.py ./chirp/drivers/th_uvf8d.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID eae989439f8e28bbc7d91ebc53c88403728654e3
Fix style issues in th_uv3r.py (#2355)
diff --git a/chirp/drivers/th_uv3r.py b/chirp/drivers/th_uv3r.py index 77df451..f01b6d5 100644 --- a/chirp/drivers/th_uv3r.py +++ b/chirp/drivers/th_uv3r.py @@ -19,6 +19,7 @@ import os from chirp import chirp_common, bitwise, errors, directory from chirp.drivers.wouxun import do_download, do_upload
+ def tyt_uv3r_prep(radio): try: radio.pipe.write("PROGRAMa") @@ -28,10 +29,12 @@ def tyt_uv3r_prep(radio): except: raise errors.RadioError("Unable to communicate with the radio")
+ def tyt_uv3r_download(radio): tyt_uv3r_prep(radio) return do_download(radio, 0x0000, 0x0910, 0x0010)
+ def tyt_uv3r_upload(radio): tyt_uv3r_prep(radio) return do_upload(radio, 0x0000, 0x0910, 0x0010) @@ -64,6 +67,8 @@ THUV3R_CHARSET = "".join([chr(ord("0") + x) for x in range(0, 10)] + [" -*+"] + [chr(ord("A") + x) for x in range(0, 26)] + ["_/"]) + + @directory.register class TYTUV3RRadio(chirp_common.CloneModeRadio): VENDOR = "TYT" @@ -147,7 +152,7 @@ class TYTUV3RRadio(chirp_common.CloneModeRadio): if rx_mode == "Tone": mem.ctone = rx_tone elif rx_mode == "DTCS": - mem.dtcs = rx_tone # No support for different codes yet + mem.dtcs = rx_tone # No support for different codes yet
def _encode_tone(self, mem, _mem): if mem.tmode == "": @@ -156,6 +161,7 @@ class TYTUV3RRadio(chirp_common.CloneModeRadio):
def _tone(val): return int("%i" % (val * 10), 16) + def _dcs(val, pol): polmask = pol == "R" and 0xC000 or 0x8000 return int("%i" % (val), 16) | polmask @@ -185,7 +191,7 @@ class TYTUV3RRadio(chirp_common.CloneModeRadio): rx_tone = _tone(mem.ctone)
_mem.rx_tone = rx_tone - _mem.tx_tone = tx_tone + _mem.tx_tone = tx_tone
def get_memory(self, number): _mem = self._memobj.memory[number - 1] @@ -259,4 +265,3 @@ class TYTUV3RRadio(chirp_common.CloneModeRadio): @classmethod def match_model(cls, filedata, filename): return len(filedata) == 2320 - diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index a92e97b..274879b 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -17,7 +17,6 @@ ./chirp/drivers/icw32.py ./chirp/drivers/icx8x.py ./chirp/drivers/icx8x_ll.py -./chirp/drivers/th_uv3r.py ./chirp/drivers/th_uv3r25.py ./chirp/drivers/th_uvf8d.py ./chirp/drivers/tmv71.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID 55fa8bef229cbba3f2ccb42c00b85dc3c465886e
Fix style issues in th_uv3r25.py (#2355)
diff --git a/chirp/drivers/th_uv3r25.py b/chirp/drivers/th_uv3r25.py index 35a3fa4..bba73d4 100644 --- a/chirp/drivers/th_uv3r25.py +++ b/chirp/drivers/th_uv3r25.py @@ -64,6 +64,7 @@ u8 skipflags[16];
VOICE_MODE_LIST = ["Compander", "Scrambler", "None"]
+ @directory.register class TYTUV3R25Radio(TYTUV3RRadio): MODEL = "TH-UV3R-25" @@ -144,8 +145,9 @@ class TYTUV3R25Radio(TYTUV3RRadio): mem.extra.append(rs)
rs = RadioSetting("voice_mode", "Voice Mode", - RadioSettingValueList(VOICE_MODE_LIST, - VOICE_MODE_LIST[_mem.voice_mode-1])) + RadioSettingValueList( + VOICE_MODE_LIST, + VOICE_MODE_LIST[_mem.voice_mode-1])) mem.extra.append(rs)
return mem @@ -202,7 +204,6 @@ class TYTUV3R25Radio(TYTUV3RRadio): else: setattr(_mem, element.get_name(), element.value)
- @classmethod def match_model(cls, filedata, filename): return len(filedata) == cls._memsize diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 274879b..73329ba 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -17,7 +17,6 @@ ./chirp/drivers/icw32.py ./chirp/drivers/icx8x.py ./chirp/drivers/icx8x_ll.py -./chirp/drivers/th_uv3r25.py ./chirp/drivers/th_uvf8d.py ./chirp/drivers/tmv71.py ./chirp/drivers/tmv71_ll.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID d3df19e5320a92442a0567fffb119228799bf074
Fix style issues in th_uvf8d.py (#2355)
diff --git a/chirp/drivers/th_uvf8d.py b/chirp/drivers/th_uvf8d.py index f0ebaca..c0ffa10 100644 --- a/chirp/drivers/th_uvf8d.py +++ b/chirp/drivers/th_uvf8d.py @@ -1,4 +1,5 @@ -# Copyright 2013 Dan Smith dsmith@danplanet.com, Eric Allen eric@hackerengineer.net +# Copyright 2013 Dan Smith dsmith@danplanet.com +# Eric Allen eric@hackerengineer.net # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -37,7 +38,8 @@ def uvf8d_identify(radio): radio.pipe.write("\x02PROGRAM") ack = radio.pipe.read(2) if ack != "PG": - raise errors.RadioError("Radio did not ACK first command: %x" % ord(ack)) + raise errors.RadioError("Radio did not ACK first command: %x" % + ord(ack)) except: raise errors.RadioError("Unable to communicate with the radio")
@@ -83,8 +85,9 @@ def tyt_uvf8d_upload(radio): radio.pipe.setTimeout(1)
if data != radio._mmap[:32]: - raise errors.RadioError("Model mis-match: \n%s\n%s" % (util.hexprint(data), - util.hexprint(radio._mmap[:32]))) + raise errors.RadioError("Model mis-match: \n%s\n%s" % + (util.hexprint(data), + util.hexprint(radio._mmap[:32])))
for i in range(0, 0x4000, 0x20): addr = i + 0x20 @@ -248,8 +251,10 @@ APRO_LIST = ["Off", "Compander", "Scramble 1", "Scramble 2", "Scramble 3", "Scramble 8"] LOCK_MODE_LIST = ["PTT", "Key", "Key+S", "All"]
-TUNING_STEPS_LIST = ["2.5", "5.0", "6.25", "10.0", "12.5", "25.0", "50.0", "100.0"] -BACKLIGHT_TIMEOUT_LIST = ["1s", "2s", "3s", "4s", "5s", "6s", "7s", "8s", "9s", "10s"] +TUNING_STEPS_LIST = ["2.5", "5.0", "6.25", "10.0", "12.5", + "25.0", "50.0", "100.0"] +BACKLIGHT_TIMEOUT_LIST = ["1s", "2s", "3s", "4s", "5s", + "6s", "7s", "8s", "9s", "10s"]
SPECIALS = { "VFO1": -2, @@ -271,7 +276,8 @@ class TYTUVF8DRadio(chirp_common.CloneModeRadio): rf.has_cross = False rf.has_rx_dtcs = True rf.has_settings = True - rf.can_odd_split = False # it may actually be supported, but I haven't tested + # it may actually be supported, but I haven't tested + rf.can_odd_split = False rf.valid_duplexes = THUVF8D_DUPLEX rf.valid_tmodes = ["", "Tone", "TSQL", "DTCS", "Cross"] rf.valid_characters = chirp_common.CHARSET_UPPER_NUMERIC + "-" @@ -363,15 +369,17 @@ class TYTUVF8DRadio(chirp_common.CloneModeRadio): return mem
if isinstance(number, int): - enabled = self._memobj.enable[(number - 1) / 8].flags[7 - ((number - 1) % 8)] - dont_skip = self._memobj.skip[(number - 1) / 8].flags[7 - ((number - 1) % 8)] + e = self._memobj.enable[(number - 1) / 8] + enabled = e.flags[7 - ((number - 1) % 8)] + s = self._memobj.skip[(number - 1) / 8] + dont_skip = s.flags[7 - ((number - 1) % 8)] else: enabled = True dont_skip = True
if not enabled: - mem.empty = True - return mem + mem.empty = True + return mem
mem.freq = int(_mem.rx_freq) * 10
@@ -382,8 +390,8 @@ class TYTUVF8DRadio(chirp_common.CloneModeRadio): rxmode, rxval, rxpol = self._decode_tone(_mem.rx_tone)
chirp_common.split_tone_decode(mem, - (txmode, txval, txpol), - (rxmode, rxval, rxpol)) + (txmode, txval, txpol), + (rxmode, rxval, rxpol))
mem.name = str(_mem.name).rstrip('\xFF ')
@@ -423,13 +431,15 @@ class TYTUVF8DRadio(chirp_common.CloneModeRadio): def set_memory(self, mem): _mem, _name = self._get_memobjs(mem.number)
+ e = self._memobj.enable[(mem.number - 1) / 8] + s = self._memobj.skip[(mem.number - 1) / 8] if mem.empty: _mem.set_raw("\xFF" * 32) - self._memobj.enable[(mem.number - 1) / 8].flags[7 - ((mem.number - 1) % 8)] = False - self._memobj.skip[(mem.number - 1) / 8].flags[7 - ((mem.number - 1) % 8)] = False + e.flags[7 - ((mem.number - 1) % 8)] = False + s.flags[7 - ((mem.number - 1) % 8)] = False return else: - self._memobj.enable[(mem.number - 1) / 8].flags[7 - ((mem.number - 1) % 8)] = True + e.flags[7 - ((mem.number - 1) % 8)] = True
if _mem.get_raw() == ("\xFF" * 32): print "Initializing empty memory" @@ -455,7 +465,7 @@ class TYTUVF8DRadio(chirp_common.CloneModeRadio): _mem.name = mem.name.rstrip(' ').ljust(7, "\xFF")
flag_index = 7 - ((mem.number - 1) % 8) - self._memobj.skip[(mem.number - 1) / 8].flags[flag_index] = (mem.skip == "") + s.flags[flag_index] = (mem.skip == "") _mem.wideband = mem.mode == "FM" _mem.ishighpower = mem.power == POWER_LEVELS[0]
@@ -468,140 +478,139 @@ class TYTUVF8DRadio(chirp_common.CloneModeRadio): group = RadioSettingGroup("basic", "Basic") top = RadioSettings(basic)
- group.append( - RadioSetting("mode", "Mode", - RadioSettingValueList(MODE_LIST, - MODE_LIST[_settings.mode]))) - - group.append( - RadioSetting("ab_switch", "A/B", - RadioSettingValueList(AB_LIST, - AB_LIST[_settings.ab_switch]))) - - group.append( - RadioSetting("a_channel", "A Selected Memory", - RadioSettingValueInteger(1, 128, _settings.a_channel + 1))) - - group.append( - RadioSetting("b_channel", "B Selected Memory", - RadioSettingValueInteger(1, 128, _settings.b_channel + 1))) - - group.append( - RadioSetting("a_display", "A Channel Display", - RadioSettingValueList(DISPLAY_LIST, - DISPLAY_LIST[_settings.a_display]))) - group.append( - RadioSetting("b_display", "B Channel Display", - RadioSettingValueList(DISPLAY_LIST, - DISPLAY_LIST[_settings.b_display]))) - group.append( - RadioSetting("tx_sel", "Priority Transmit", - RadioSettingValueList(TXSEL_LIST, - TXSEL_LIST[_settings.tx_sel]))) - group.append( - RadioSetting("vox_level", "VOX Level", - RadioSettingValueList(VOX_LIST, - VOX_LIST[_settings.vox_level]))) - - group.append( - RadioSetting("squelch", "Squelch Level", - RadioSettingValueInteger(0, 9, _settings.squelch))) - - group.append( - RadioSetting("dwait", "Dual Wait", - RadioSettingValueBoolean(_settings.dwait))) - - group.append( - RadioSetting("led", "LED Mode", - RadioSettingValueList(LED_LIST, - LED_LIST[_settings.led]))) - - group.append( - RadioSetting("light", "Light Color", - RadioSettingValueList(LIGHT_LIST, - LIGHT_LIST[_settings.light]))) - - group.append( - RadioSetting("beep", "Beep", - RadioSettingValueBoolean(_settings.beep))) - - group.append( - RadioSetting("ani", "ANI", - RadioSettingValueBoolean(_settings.ani))) - - group.append( - RadioSetting("tot", "Timeout Timer", - RadioSettingValueList(TOT_LIST, - TOT_LIST[_settings.tot]))) - - group.append( - RadioSetting("roger", "Roger Beep", - RadioSettingValueBoolean(_settings.roger))) - - group.append( - RadioSetting("dw", "Dual Watch", - RadioSettingValueBoolean(_settings.dw))) - - group.append( - RadioSetting("rxsave", "RX Save", - RadioSettingValueBoolean(_settings.rxsave))) + group.append(RadioSetting( + "mode", "Mode", + RadioSettingValueList( + MODE_LIST, MODE_LIST[_settings.mode]))) + + group.append(RadioSetting( + "ab_switch", "A/B", + RadioSettingValueList( + AB_LIST, AB_LIST[_settings.ab_switch]))) + + group.append(RadioSetting( + "a_channel", "A Selected Memory", + RadioSettingValueInteger(1, 128, _settings.a_channel + 1))) + + group.append(RadioSetting( + "b_channel", "B Selected Memory", + RadioSettingValueInteger(1, 128, _settings.b_channel + 1))) + + group.append(RadioSetting( + "a_display", "A Channel Display", + RadioSettingValueList( + DISPLAY_LIST, DISPLAY_LIST[_settings.a_display]))) + group.append(RadioSetting( + "b_display", "B Channel Display", + RadioSettingValueList( + DISPLAY_LIST, DISPLAY_LIST[_settings.b_display]))) + group.append(RadioSetting( + "tx_sel", "Priority Transmit", + RadioSettingValueList( + TXSEL_LIST, TXSEL_LIST[_settings.tx_sel]))) + group.append(RadioSetting( + "vox_level", "VOX Level", + RadioSettingValueList( + VOX_LIST, VOX_LIST[_settings.vox_level]))) + + group.append(RadioSetting( + "squelch", "Squelch Level", + RadioSettingValueInteger(0, 9, _settings.squelch))) + + group.append(RadioSetting( + "dwait", "Dual Wait", + RadioSettingValueBoolean(_settings.dwait))) + + group.append(RadioSetting( + "led", "LED Mode", + RadioSettingValueList(LED_LIST, LED_LIST[_settings.led]))) + + group.append(RadioSetting( + "light", "Light Color", + RadioSettingValueList( + LIGHT_LIST, LIGHT_LIST[_settings.light]))) + + group.append(RadioSetting( + "beep", "Beep", + RadioSettingValueBoolean(_settings.beep))) + + group.append(RadioSetting( + "ani", "ANI", + RadioSettingValueBoolean(_settings.ani))) + + group.append(RadioSetting( + "tot", "Timeout Timer", + RadioSettingValueList(TOT_LIST, TOT_LIST[_settings.tot]))) + + group.append(RadioSetting( + "roger", "Roger Beep", + RadioSettingValueBoolean(_settings.roger))) + + group.append(RadioSetting( + "dw", "Dual Watch", + RadioSettingValueBoolean(_settings.dw))) + + group.append(RadioSetting( + "rxsave", "RX Save", + RadioSettingValueBoolean(_settings.rxsave)))
def _filter(name): return str(name).rstrip("\xFF").rstrip()
- group.append( - RadioSetting("ponmsg", "Power-On Message", - RadioSettingValueString(0, 7, - _filter(_settings.ponmsg)))) - - group.append( - RadioSetting("scan_mode", "Scan Mode", - RadioSettingValueList(SCAN_MODE_LIST, - SCAN_MODE_LIST[_settings.scan_mode]))) - - group.append( - RadioSetting("autolk", "Auto Lock", - RadioSettingValueBoolean(_settings.autolk))) - - group.append( - RadioSetting("lock_mode", "Keypad Lock Mode", - RadioSettingValueList(LOCK_MODE_LIST, - LOCK_MODE_LIST[_settings.lock_mode]))) - - group.append( - RadioSetting("voice", "Voice Prompt", - RadioSettingValueBoolean(_settings.voice))) - - group.append( - RadioSetting("opnmsg", "Opening Message", - RadioSettingValueList(OPNMSG_LIST, - OPNMSG_LIST[_settings.opnmsg]))) - - group.append( - RadioSetting("tuning_step", "Tuning Step", - RadioSettingValueList(TUNING_STEPS_LIST, - TUNING_STEPS_LIST[_settings.tuning_step]))) - - group.append( - RadioSetting("lamp_t", "Backlight Timeout", - RadioSettingValueList(BACKLIGHT_TIMEOUT_LIST, - BACKLIGHT_TIMEOUT_LIST[_settings.lamp_t]))) - - group.append( - RadioSetting("a_work_area", "A Work Area", - RadioSettingValueList(AB_LIST, - AB_LIST[_settings.a_work_area]))) - - group.append( - RadioSetting("b_work_area", "B Work Area", - RadioSettingValueList(AB_LIST, - AB_LIST[_settings.b_work_area]))) + group.append(RadioSetting( + "ponmsg", "Power-On Message", + RadioSettingValueString(0, 7, _filter(_settings.ponmsg)))) + + group.append(RadioSetting( + "scan_mode", "Scan Mode", + RadioSettingValueList( + SCAN_MODE_LIST, SCAN_MODE_LIST[_settings.scan_mode]))) + + group.append(RadioSetting( + "autolk", "Auto Lock", + RadioSettingValueBoolean(_settings.autolk))) + + group.append(RadioSetting( + "lock_mode", "Keypad Lock Mode", + RadioSettingValueList( + LOCK_MODE_LIST, LOCK_MODE_LIST[_settings.lock_mode]))) + + group.append(RadioSetting( + "voice", "Voice Prompt", + RadioSettingValueBoolean(_settings.voice))) + + group.append(RadioSetting( + "opnmsg", "Opening Message", + RadioSettingValueList( + OPNMSG_LIST, OPNMSG_LIST[_settings.opnmsg]))) + + group.append(RadioSetting( + "tuning_step", "Tuning Step", + RadioSettingValueList( + TUNING_STEPS_LIST, + TUNING_STEPS_LIST[_settings.tuning_step]))) + + group.append(RadioSetting( + "lamp_t", "Backlight Timeout", + RadioSettingValueList( + BACKLIGHT_TIMEOUT_LIST, + BACKLIGHT_TIMEOUT_LIST[_settings.lamp_t]))) + + group.append(RadioSetting( + "a_work_area", "A Work Area", + RadioSettingValueList( + AB_LIST, AB_LIST[_settings.a_work_area]))) + + group.append(RadioSetting( + "b_work_area", "B Work Area", + RadioSettingValueList( + AB_LIST, AB_LIST[_settings.b_work_area])))
return top
- group.append( - RadioSetting("disnm", "Display Name", - RadioSettingValueBoolean(_settings.disnm))) + group.append(RadioSetting( + "disnm", "Display Name", + RadioSettingValueBoolean(_settings.disnm)))
return group
@@ -616,9 +625,9 @@ class TYTUVF8DRadio(chirp_common.CloneModeRadio): _settings.rxsave = 0 continue if element.get_name().endswith('_channel'): - print element.value, type(element.value) - setattr(_settings, element.get_name(), int(element.value) - 1) - continue + print element.value, type(element.value) + setattr(_settings, element.get_name(), int(element.value) - 1) + continue if not isinstance(element, RadioSetting): self.set_settings(element) continue diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 73329ba..765b7a8 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -17,6 +17,5 @@ ./chirp/drivers/icw32.py ./chirp/drivers/icx8x.py ./chirp/drivers/icx8x_ll.py -./chirp/drivers/th_uvf8d.py ./chirp/drivers/tmv71.py ./chirp/drivers/tmv71_ll.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID 4c2c12250b64b3ddab5a98dd6729e3089b5694f2
Fix style issues in tmv71*.py (#2355)
diff --git a/chirp/drivers/tmv71.py b/chirp/drivers/tmv71.py index cca737a..94c97a9 100644 --- a/chirp/drivers/tmv71.py +++ b/chirp/drivers/tmv71.py @@ -16,6 +16,7 @@ from chirp import chirp_common, errors, util from chirp.drivers import tmv71_ll
+ class TMV71ARadio(chirp_common.CloneModeRadio): BAUD_RATE = 9600 VENDOR = "Kenwood" @@ -23,7 +24,7 @@ class TMV71ARadio(chirp_common.CloneModeRadio):
mem_upper_limit = 1022 _memsize = 32512 - _model = "" # FIXME: REMOVE + _model = "" # FIXME: REMOVE
def get_features(self): rf = chirp_common.RadioFeatures() @@ -55,8 +56,8 @@ class TMV71ARadio(chirp_common.CloneModeRadio): try: number = tmv71_ll.V71_SPECIAL[number] except KeyError: - raise errors.InvalidMemoryLocation("Unknown channel %s" % \ - number) + raise errors.InvalidMemoryLocation("Unknown channel %s" % + number)
return tmv71_ll.get_memory(self._mmap, number)
diff --git a/chirp/drivers/tmv71_ll.py b/chirp/drivers/tmv71_ll.py index 201412e..2fd4d86 100644 --- a/chirp/drivers/tmv71_ll.py +++ b/chirp/drivers/tmv71_ll.py @@ -13,18 +13,20 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-import struct, time, logging +import struct +import time +import logging
from chirp import memmap, chirp_common, errors
LOG = logging.getLogger(__name__)
-POS_MODE = 5 -POS_DUP = 6 -POS_TMODE = 6 -POS_RTONE = 7 -POS_CTONE = 8 -POS_DTCS = 9 +POS_MODE = 5 +POS_DUP = 6 +POS_TMODE = 6 +POS_RTONE = 7 +POS_CTONE = 8 +POS_DTCS = 9 POS_OFFSET = 10
MEM_LOC_BASE = 0x1700 @@ -43,9 +45,10 @@ V71_SPECIAL["C VHF"] = 1030 V71_SPECIAL["C UHF"] = 1031
V71_SPECIAL_REV = {} -for k,v in V71_SPECIAL.items(): +for k, v in V71_SPECIAL.items(): V71_SPECIAL_REV[v] = k
+ def command(s, cmd, timeout=0.5): start = time.time()
@@ -57,6 +60,7 @@ def command(s, cmd, timeout=0.5): LOG.debug("V71->PC: %s" % data.strip()) return data.strip()
+ def get_id(s): r = command(s, "ID") if r.startswith("ID "): @@ -67,6 +71,7 @@ def get_id(s): EXCH_R = "R\x00\x00\x00" EXCH_W = "W\x00\x00\x00"
+ def read_block(s, block, count=256): s.write(struct.pack("<cHB", "R", block, 0)) r = s.read(4) @@ -87,6 +92,7 @@ def read_block(s, block, count=256):
return data
+ def write_block(s, block, map): s.write(struct.pack("<cHB", "W", block, 0)) base = block * 256 @@ -96,6 +102,7 @@ def write_block(s, block, map):
return ack == chr(0x06)
+ def download(radio): if command(radio.pipe, "0M PROGRAM") != "0M": raise errors.RadioError("No response from radio") @@ -114,6 +121,7 @@ def download(radio):
return memmap.MemoryMap(data)
+ def upload(radio): if command(radio.pipe, "0M PROGRAM") != "0M": raise errors.RadioError("No response from radio") @@ -131,20 +139,24 @@ def upload(radio):
radio.pipe.write("E")
+ def get_mem_offset(number): return MEM_LOC_BASE + (MEM_LOC_SIZE * number)
+ def get_raw_mem(map, number): base = get_mem_offset(number) - #print "Offset for %i is %04x" % (number, base) + # print "Offset for %i is %04x" % (number, base) return map[base:base+MEM_LOC_SIZE]
+ def get_used(map, number): pos = MEM_FLG_BASE + (number * 2) flag = ord(map[pos]) print "Flag byte is %02x" % flag return not (flag & 0x80)
+ def set_used(map, number, freq): pos = MEM_FLG_BASE + (number * 2) if freq == 0: @@ -155,6 +167,7 @@ def set_used(map, number, freq): elif int(freq / 100) == 4: map[pos] = "\x08\x00"
+ def get_skip(map, number): pos = MEM_FLG_BASE + (number * 2) flag = ord(map[pos+1]) @@ -163,6 +176,7 @@ def get_skip(map, number): else: return ""
+ def set_skip(map, number, skip): pos = MEM_FLG_BASE + (number * 2) flag = ord(map[pos+1]) @@ -172,111 +186,128 @@ def set_skip(map, number, skip): flag &= ~0x01 map[pos+1] = flag
+ def get_freq(mmap): freq, = struct.unpack("<I", mmap[0:4]) return freq / 1000000.0
+ def set_freq(mmap, freq): mmap[0] = struct.pack("<I", int(freq * 1000000))
+ def get_name(map, number): base = MEM_TAG_BASE + (8 * number) return map[base:base+6].replace("\xff", "")
+ def set_name(mmap, number, name): base = MEM_TAG_BASE + (8 * number) mmap[base] = name.ljust(6)[:6].upper()
+ def get_tmode(mmap): val = ord(mmap[POS_TMODE]) & 0x70
tmodemap = { - 0x00 : "", - 0x40 : "Tone", - 0x20 : "TSQL", - 0x10 : "DTCS", + 0x00: "", + 0x40: "Tone", + 0x20: "TSQL", + 0x10: "DTCS", }
return tmodemap[val]
+ def set_tmode(mmap, tmode): val = ord(mmap[POS_TMODE]) & 0x8F
tmodemap = { - "" : 0x00, - "Tone" : 0x40, - "TSQL" : 0x20, - "DTCS" : 0x10, + "": 0x00, + "Tone": 0x40, + "TSQL": 0x20, + "DTCS": 0x10, }
mmap[POS_TMODE] = val | tmodemap[tmode]
+ def get_tone(mmap, offset): val = ord(mmap[offset])
return chirp_common.TONES[val]
+ def set_tone(mmap, tone, offset): print tone mmap[offset] = chirp_common.TONES.index(tone)
+ def get_dtcs(mmap): val = ord(mmap[POS_DTCS])
return chirp_common.DTCS_CODES[val]
+ def set_dtcs(mmap, dtcs): mmap[POS_DTCS] = chirp_common.DTCS_CODES.index(dtcs)
+ def get_duplex(mmap): val = ord(mmap[POS_DUP]) & 0x03
dupmap = { - 0x00 : "", - 0x01 : "+", - 0x02 : "-", + 0x00: "", + 0x01: "+", + 0x02: "-", }
return dupmap[val]
+ def set_duplex(mmap, duplex): val = ord(mmap[POS_DUP]) & 0xFC
dupmap = { - "" : 0x00, - "+" : 0x01, - "-" : 0x02, + "": 0x00, + "+": 0x01, + "-": 0x02, }
mmap[POS_DUP] = val | dupmap[duplex]
+ def get_offset(mmap): val, = struct.unpack("<I", mmap[POS_OFFSET:POS_OFFSET+4]) return val / 1000000.0
+ def set_offset(mmap, offset): mmap[POS_OFFSET] = struct.pack("<I", int(offset * 1000000))
+ def get_mode(mmap): val = ord(mmap[POS_MODE]) & 0x03 modemap = { - 0x00 : "FM", - 0x01 : "NFM", - 0x02 : "AM", + 0x00: "FM", + 0x01: "NFM", + 0x02: "AM", }
return modemap[val]
+ def set_mode(mmap, mode): val = ord(mmap[POS_MODE]) & 0xFC modemap = { - "FM" : 0x00, + "FM": 0x00, "NFM": 0x01, - "AM" : 0x02, + "AM": 0x02, }
mmap[POS_MODE] = val | modemap[mode]
+ def get_memory(map, number): if number < 0 or number > (max(V71_SPECIAL.values()) + 1): raise errors.InvalidMemoryLocation("Number must be between 0 and 999") @@ -308,15 +339,17 @@ def get_memory(map, number): if number > 999: mem.immutable = ["number", "bank", "extd_number", "name"] if number > 1020 and number < 1030: - mem.immutable += ["freq"] # FIXME: ALL + mem.immutable += ["freq"] # FIXME: ALL
return mem
+ def initialize(mmap): mmap[0] = \ "\x80\xc8\xb3\x08\x00\x01\x00\x08" + \ "\x08\x00\xc0\x27\x09\x00\x00\xff"
+ def set_memory(map, mem): if mem.number < 0 or mem.number > (max(V71_SPECIAL.values()) + 1): raise errors.InvalidMemoryLocation("Number must be between 0 and 999") @@ -346,13 +379,13 @@ def set_memory(map, mem):
return map
+ if __name__ == "__main__": import sys import serial s = serial.Serial(port=sys.argv[1], baudrate=9600, dsrdtr=True, timeout=0.25) - #s.write("\r\r") - #print get_id(s) + # s.write("\r\r") + # print get_id(s) data = download(s) file(sys.argv[2], "wb").write(data) - diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 765b7a8..9181e9c 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -17,5 +17,3 @@ ./chirp/drivers/icw32.py ./chirp/drivers/icx8x.py ./chirp/drivers/icx8x_ll.py -./chirp/drivers/tmv71.py -./chirp/drivers/tmv71_ll.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID d7bbc12464c1d3a2e2c703e128bd8bcef948b084
Fix style issues in ic208.py (#2355)
diff --git a/chirp/drivers/ic208.py b/chirp/drivers/ic208.py index 9c3bbaa..b327371 100644 --- a/chirp/drivers/ic208.py +++ b/chirp/drivers/ic208.py @@ -19,7 +19,7 @@ from chirp import chirp_common, errors, directory, bitwise MEM_FORMAT = """ struct memory { u24 freq; - u16 offset; + u16 offset; u8 power:2, rtone:6; u8 duplex:2, @@ -75,12 +75,13 @@ for i in range(1, 6): IC208_SPECIAL.append("%iA" % i) IC208_SPECIAL.append("%iB" % i)
-CHARSET = dict(zip([0x00, 0x08, 0x09, 0x0a, 0x0b, 0x0d, 0x0f], " ()*+-/") + - zip(range(0x10, 0x1a), "0123456789") + - [(0x1c,'|'), (0x1d,'=')] + - zip(range(0x21, 0x3b), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")) +CHARSET = dict(zip([0x00, 0x08, 0x09, 0x0a, 0x0b, 0x0d, 0x0f], " ()*+-/") + + zip(range(0x10, 0x1a), "0123456789") + + [(0x1c, '|'), (0x1d, '=')] + + zip(range(0x21, 0x3b), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")) CHARSET_REV = dict(zip(CHARSET.values(), CHARSET.keys()))
+ def get_name(_mem): """Decode the name from @_mem""" def _get_char(val): @@ -97,6 +98,7 @@ def get_name(_mem):
return name.rstrip()
+ def set_name(_mem, name): """Encode @name in @_mem""" def _get_index(char): @@ -118,6 +120,7 @@ def set_name(_mem, name): _mem.name5 = _get_index(name[4]) _mem.name6 = _get_index(name[5])
+ @directory.register class IC208Radio(icf.IcomCloneModeRadio): """Icom IC800""" @@ -157,7 +160,6 @@ class IC208Radio(icf.IcomCloneModeRadio): def process_mmap(self): self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
- def _get_bank(self, loc): _flg = self._memobj.flags[loc-1] if _flg.bank >= 0x0A: @@ -194,7 +196,6 @@ class IC208Radio(icf.IcomCloneModeRadio):
return _mem, _flg, index
- def get_memory(self, number): _mem, _flg, index = self._get_memory(number)
@@ -258,4 +259,3 @@ class IC208Radio(icf.IcomCloneModeRadio): if not isinstance(mem.number, str): _flg.skip = mem.skip == "S" _flg.pskip = mem.skip == "P" - diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 9181e9c..75faa3a 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -1,7 +1,6 @@ # cpep8.blacklist: The list of files that do not meet PEP8 standards. # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. -./chirp/drivers/ic208.py ./chirp/drivers/ic2100.py ./chirp/drivers/ic2200.py ./chirp/drivers/ic2720.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID 5e18f6ecdc3ee6977aad73f10b710c939bdb5a5d
Fix style issues in ic2100.py (#2355)
diff --git a/chirp/drivers/ic2100.py b/chirp/drivers/ic2100.py index 8babe50..7525ebf 100644 --- a/chirp/drivers/ic2100.py +++ b/chirp/drivers/ic2100.py @@ -90,10 +90,11 @@ struct {
TMODES = ["", "Tone", "", "TSQL"] DUPLEX = ["", "", "+", "-"] -STEPS = [5.0, 10.0, 12.5, 15.0, 20.0, 25.0, 30.0, 50.0] +STEPS = [5.0, 10.0, 12.5, 15.0, 20.0, 25.0, 30.0, 50.0] +
def _get_special(): - special = { "C": 506 } + special = {"C": 506} for i in range(0, 3): ida = "%iA" % (i + 1) idb = "%iB" % (i + 1) @@ -103,6 +104,7 @@ def _get_special():
return special
+ def _get_freq(mem): freq = (int(mem.freq) * 100000) + \ (mem.freq_10khz * 10000) + \ @@ -122,6 +124,7 @@ def _get_freq(mem):
return freq
+ def _set_freq(mem, freq): mem.freq = freq / 100000 mem.freq_10khz = (freq / 10000) % 10 @@ -129,6 +132,7 @@ def _set_freq(mem, freq): mem.freq_1khz = khz mem.is_12_5 = chirp_common.is_12_5(freq)
+ def _get_offset(mem): raw = memmap.MemoryMap(mem.get_raw()) if ord(raw[5]) & 0x0A: @@ -141,6 +145,7 @@ def _get_offset(mem): else: return int(mem.offset) * 1000
+ def _set_offset(mem, offset): if (offset % 10) == 5000: extra = 0x0A @@ -153,9 +158,11 @@ def _set_offset(mem, offset): raw[5] = ord(raw[5]) | extra mem.set_raw(raw.get_packed())
+ def _wipe_memory(mem, char): mem.set_raw(char * (mem.size() / 8))
+ @directory.register class IC2100Radio(icf.IcomCloneModeRadio): """Icom IC-2100""" @@ -227,7 +234,7 @@ class IC2100Radio(icf.IcomCloneModeRadio): mem.ctone = chirp_common.TONES[_mem.ctone] mem.tmode = TMODES[_mem.tmode] mem.duplex = DUPLEX[_mem.duplex] - + mem.extra = RadioSettingGroup("Extra", "extra")
rs = RadioSetting("anm", "Alphanumeric Name", diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 75faa3a..bc24f43 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -1,7 +1,6 @@ # cpep8.blacklist: The list of files that do not meet PEP8 standards. # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. -./chirp/drivers/ic2100.py ./chirp/drivers/ic2200.py ./chirp/drivers/ic2720.py ./chirp/drivers/ic2820.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID be4a80848d48e6fa038566f3d93c5da7cd283955
Fix style issues in ic2200.py (#2355)
diff --git a/chirp/drivers/ic2200.py b/chirp/drivers/ic2200.py index e059f59..cb5d66e 100644 --- a/chirp/drivers/ic2200.py +++ b/chirp/drivers/ic2200.py @@ -75,16 +75,17 @@ struct {
TMODES = ["", "Tone", "TSQL", "DTCS"] DUPLEX = ["", "-", "+"] -DTCSP = ["NN", "NR", "RN", "RR"] -STEPS = [5.0, 10.0, 12.5, 15.0, 20.0, 25.0, 30.0, 50.0] +DTCSP = ["NN", "NR", "RN", "RR"] +STEPS = [5.0, 10.0, 12.5, 15.0, 20.0, 25.0, 30.0, 50.0]
POWER_LEVELS = [chirp_common.PowerLevel("High", watts=65), chirp_common.PowerLevel("Mid", watts=25), chirp_common.PowerLevel("MidLow", watts=10), chirp_common.PowerLevel("Low", watts=5)]
+ def _get_special(): - special = { "C" : 206 } + special = {"C": 206} for i in range(0, 3): ida = "%iA" % (i+1) idb = "%iB" % (i+1) @@ -94,9 +95,11 @@ def _get_special():
return special
+ def _wipe_memory(mem, char): mem.set_raw(char * (mem.size() / 8))
+ @directory.register class IC2200Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport): """Icom IC-2200""" @@ -128,8 +131,8 @@ class IC2200Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport): (0x1AB8, 0x1AC0, 8), ]
- MYCALL_LIMIT = (0, 6) - URCALL_LIMIT = (0, 6) + MYCALL_LIMIT = (0, 6) + URCALL_LIMIT = (0, 6) RPTCALL_LIMIT = (0, 6)
def _get_bank(self, loc): @@ -145,7 +148,7 @@ class IC2200Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport): _flag.bank = 0x0A else: _flag.bank = bank - + def get_features(self): rf = chirp_common.RadioFeatures() rf.memory_bounds = (0, 199) @@ -173,7 +176,7 @@ class IC2200Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport):
if _mem.mode_dv and not _flag.empty: mem = chirp_common.DVMemory() - mem.dv_urcall = \ + mem.dv_urcall = \ str(self._memobj.urcalls[_mem.urcall].call).rstrip() mem.dv_rpt1call = \ str(self._memobj.rptcalls[_mem.r1call].call).rstrip() diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index bc24f43..6d40bcf 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -1,7 +1,6 @@ # cpep8.blacklist: The list of files that do not meet PEP8 standards. # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. -./chirp/drivers/ic2200.py ./chirp/drivers/ic2720.py ./chirp/drivers/ic2820.py ./chirp/drivers/ic9x.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID 54660081115fa0d765b9edf27c1a1a4e6d2d68fe
Fix style issues in ic2720.py (#2355)
diff --git a/chirp/drivers/ic2720.py b/chirp/drivers/ic2720.py index 462c616..30f4a8e 100644 --- a/chirp/drivers/ic2720.py +++ b/chirp/drivers/ic2720.py @@ -67,12 +67,13 @@ POWER_LEVELS_UHF = [chirp_common.PowerLevel("High", watts=35), chirp_common.PowerLevel("Low", watts=5), chirp_common.PowerLevel("Mid", watts=15)]
+ @directory.register class IC2720Radio(icf.IcomCloneModeRadio): """Icom IC-2720""" VENDOR = "Icom" MODEL = "IC-2720H" - + _model = "\x24\x92\x00\x01" _memsize = 5152 _endframe = "Icom Inc\x2eA0" @@ -161,7 +162,7 @@ class IC2720Radio(icf.IcomCloneModeRadio): _mem = self._memobj.memory[mem.number] _skp = self._memobj.skips[bytepos] _usd = self._memobj.used[bytepos] - + if mem.empty: _usd |= bitpos self._set_bank(mem.number, None) @@ -178,7 +179,7 @@ class IC2720Radio(icf.IcomCloneModeRadio): _mem.tuning_step = STEPS.index(mem.tuning_step) _mem.is_fm = mem.mode == "FM" _mem.duplex = DUPLEX.index(mem.duplex) - + if mem.skip == "S": _skp |= bitpos else: diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 6d40bcf..1895c15 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -1,7 +1,6 @@ # cpep8.blacklist: The list of files that do not meet PEP8 standards. # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. -./chirp/drivers/ic2720.py ./chirp/drivers/ic2820.py ./chirp/drivers/ic9x.py ./chirp/drivers/ic9x_icf.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID a04cae6e0167ccd14e0da8aad157f0fdb7084108
Fix style issues in ic2820.py (#2355)
diff --git a/chirp/drivers/ic2820.py b/chirp/drivers/ic2820.py index 8b507d9..37b996d 100644 --- a/chirp/drivers/ic2820.py +++ b/chirp/drivers/ic2820.py @@ -78,12 +78,13 @@ struct { """
TMODES = ["", "Tone", "??0", "TSQL", "??1", "??2", "DTCS"] -DUPLEX = ["", "-", "+", "+"] # Not sure about index 3 -MODES = ["FM", "NFM", "AM", "??", "DV"] -DTCSP = ["NN", "NR", "RN", "RR"] +DUPLEX = ["", "-", "+", "+"] # Not sure about index 3 +MODES = ["FM", "NFM", "AM", "??", "DV"] +DTCSP = ["NN", "NR", "RN", "RR"]
MEM_LOC_SIZE = 48
+ class IC2820Bank(icf.IcomNamedBank): """An IC2820 bank""" def get_name(self): @@ -94,9 +95,10 @@ class IC2820Bank(icf.IcomNamedBank): _banks = self._model._radio._memobj.bank_names _banks[self.index].name = str(name).ljust(8)[:8]
+ def _get_special(): - special = {"C0" : 500 + 20, - "C1" : 500 + 21} + special = {"C0": 500 + 20, + "C1": 500 + 21}
for i in range(0, 10): ida = "%iA" % i @@ -106,15 +108,18 @@ def _get_special():
return special
+ def _resolve_memory_number(number): if isinstance(number, str): return _get_special()[number] else: return number
+ def _wipe_memory(mem, char): mem.set_raw(char * (mem.size() / 8))
+ @directory.register class IC2820Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport): """Icom IC-2820""" @@ -129,7 +134,8 @@ class IC2820Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport): (0x6960, 0x6980, 16), (0x6980, 0x7160, 32), (0x7160, 0x7180, 16), - (0x7180, 0xACC0, 32),] + (0x7180, 0xACC0, 32), + ]
_num_banks = 26 _bank_class = IC2820Bank @@ -231,7 +237,7 @@ class IC2820Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport): mem.dtcs = chirp_common.DTCS_CODES[_mem.dtcs] mem.dtcs_polarity = DTCSP[_mem.dtcs_polarity] if _mem.tune_step > 8: - mem.tuning_step = 5.0 # Sometimes TS is garbage? + mem.tuning_step = 5.0 # Sometimes TS is garbage? else: mem.tuning_step = chirp_common.TUNING_STEPS[_mem.tune_step] mem.name = str(_mem.name).rstrip() @@ -285,10 +291,10 @@ class IC2820Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport): _mem.urcall = mem.dv_urcall.ljust(8) _mem.r1call = mem.dv_rpt1call.ljust(8) _mem.r2call = mem.dv_rpt2call.ljust(8) - + def get_raw_memory(self, number): return repr(self._memobj.memory[number]) - + def get_urcall_list(self): _calls = self._memobj.urcall calls = [] @@ -310,7 +316,7 @@ class IC2820Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport): def get_mycall_list(self): _calls = self._memobj.mycall calls = [] - + for i in range(*self.MYCALL_LIMIT): calls.append(str(_calls[i-1].call))
diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 1895c15..b15e6c5 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -1,7 +1,6 @@ # cpep8.blacklist: The list of files that do not meet PEP8 standards. # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. -./chirp/drivers/ic2820.py ./chirp/drivers/ic9x.py ./chirp/drivers/ic9x_icf.py ./chirp/drivers/ic9x_icf_ll.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID 0518541d76df55cb292432deae4a0e9516b612e0
Fix style issues in ic9x.py (#2355)
diff --git a/chirp/drivers/ic9x.py b/chirp/drivers/ic9x.py index 5726b09..405b114 100644 --- a/chirp/drivers/ic9x.py +++ b/chirp/drivers/ic9x.py @@ -49,6 +49,7 @@ CHARSET = chirp_common.CHARSET_ALPHANUMERIC + \
LOCK = threading.Lock()
+ class IC9xBank(icf.IcomNamedBank): """Icom 9x Bank""" def get_name(self): @@ -60,6 +61,7 @@ class IC9xBank(icf.IcomNamedBank): banks[self.index] = name self._model._radio._ic9x_set_banks(banks)
+ @directory.register class IC9xRadio(icf.IcomLiveRadio): """Base class for Icom IC-9x radios""" @@ -120,7 +122,7 @@ class IC9xRadio(icf.IcomLiveRadio): if number < -2 or number > 999: raise errors.InvalidValueError("Number must be between 0 and 999")
- if self.__memcache.has_key(number): + if number in self.__memcache: return self.__memcache[number]
self._lock.acquire() @@ -242,12 +244,12 @@ class IC9xRadio(icf.IcomLiveRadio): def _ic9x_set_banks(self, banks):
if len(banks) != len(self.__bankcache.keys()): - raise errors.InvalidDataError("Invalid bank list length (%i:%i)" %\ - (len(banks), - len(self.__bankcache.keys()))) + raise errors.InvalidDataError("Invalid bank list length (%i:%i)" % + (len(banks), + len(self.__bankcache.keys())))
- cached_names = [str(self.__bankcache[x]) \ - for x in sorted(self.__bankcache.keys())] + cached_names = [str(self.__bankcache[x]) + for x in sorted(self.__bankcache.keys())]
need_update = False for i in range(0, 26): @@ -279,6 +281,7 @@ class IC9xRadio(icf.IcomLiveRadio):
return rf
+ class IC9xRadioA(IC9xRadio): """IC9x Band A subdevice""" VARIANT = "Band A" @@ -301,6 +304,7 @@ class IC9xRadioA(IC9xRadio): rf.valid_name_length = 8 return rf
+ class IC9xRadioB(IC9xRadio, chirp_common.IcomDstarSupport): """IC9x Band B subdevice""" VARIANT = "Band B" @@ -406,6 +410,7 @@ class IC9xRadioB(IC9xRadio, chirp_common.IcomDstarSupport): self.RPTCALL_LIMIT[1], calls)
+ def _test(): import serial ser = IC9xRadioB(serial.Serial(port="/dev/ttyUSB1", @@ -414,5 +419,6 @@ def _test(): print "-- FOO --" ser.set_urcall_list(["K7TAY", "FOOBAR", "BAZ"])
+ if __name__ == "__main__": _test() diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index b15e6c5..6d3cf8f 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -1,7 +1,6 @@ # cpep8.blacklist: The list of files that do not meet PEP8 standards. # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. -./chirp/drivers/ic9x.py ./chirp/drivers/ic9x_icf.py ./chirp/drivers/ic9x_icf_ll.py ./chirp/drivers/ic9x_ll.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID 8623aeeb537412d6b35f90ba10b13c635daec41d
Fix style issues in ic9x_icf.py (#2355)
diff --git a/chirp/drivers/ic9x_icf.py b/chirp/drivers/ic9x_icf.py index 666307b..3e3e3d5 100644 --- a/chirp/drivers/ic9x_icf.py +++ b/chirp/drivers/ic9x_icf.py @@ -16,6 +16,7 @@ from chirp.drivers import icf, ic9x_icf_ll from chirp import chirp_common, util, directory, errors
+ # Don't register as this module is used to load icf file from File-Open menu # see do_open in mainapp.py class IC9xICFRadio(chirp_common.CloneModeRadio): @@ -53,6 +54,7 @@ class IC9xICFRadio(chirp_common.CloneModeRadio): return [IC9xICFRadioA(self._mmap), IC9xICFRadioB(self._mmap)]
+ class IC9xICFRadioA(IC9xICFRadio): VARIANT = "ICF File Band A"
@@ -64,6 +66,7 @@ class IC9xICFRadioA(IC9xICFRadio):
return ic9x_icf_ll.get_memory(self._mmap, number)
+ class IC9xICFRadioB(IC9xICFRadio): VARIANT = "ICF File Band B"
diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 6d3cf8f..1573e99 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -1,7 +1,6 @@ # cpep8.blacklist: The list of files that do not meet PEP8 standards. # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. -./chirp/drivers/ic9x_icf.py ./chirp/drivers/ic9x_icf_ll.py ./chirp/drivers/ic9x_ll.py ./chirp/drivers/icf.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID 717073835c3fb70eb69b98317b6499db7e6b97be
Fix style issues in ic9x_icf_ll.py (#2355)
diff --git a/chirp/drivers/ic9x_icf_ll.py b/chirp/drivers/ic9x_icf_ll.py index 30376d7..e1619d5 100644 --- a/chirp/drivers/ic9x_icf_ll.py +++ b/chirp/drivers/ic9x_icf_ll.py @@ -20,15 +20,16 @@ from chirp.memmap import MemoryMap MEM_LOC_SIZE_A = 20 MEM_LOC_SIZE_B = MEM_LOC_SIZE_A + 1 + (3 * 8)
-POS_FREQ = 0 -POS_OFFSET = 3 -POS_TONE = 5 -POS_MODE = 6 -POS_DTCS = 7 -POS_TS = 8 -POS_DTCSPOL = 11 -POS_DUPLEX = 11 -POS_NAME = 12 +POS_FREQ = 0 +POS_OFFSET = 3 +POS_TONE = 5 +POS_MODE = 6 +POS_DTCS = 7 +POS_TS = 8 +POS_DTCSPOL = 11 +POS_DUPLEX = 11 +POS_NAME = 12 +
def get_mem_offset(number): """Get the offset into the memory map for memory @number""" @@ -37,6 +38,7 @@ def get_mem_offset(number): else: return (MEM_LOC_SIZE_A * 850) + (MEM_LOC_SIZE_B * (number - 850))
+ def get_raw_memory(mmap, number): """Return a raw representation of memory @number""" offset = get_mem_offset(number) @@ -46,6 +48,7 @@ def get_raw_memory(mmap, number): size = MEM_LOC_SIZE_A return MemoryMap(mmap[offset:offset+size])
+ def get_freq(mmap): """Return the memory frequency""" if ord(mmap[10]) & 0x10: @@ -55,26 +58,31 @@ def get_freq(mmap): val, = struct.unpack(">I", "\x00" + mmap[POS_FREQ:POS_FREQ+3]) return val * mult
+ def get_offset(mmap): """Return the memory offset""" val, = struct.unpack(">H", mmap[POS_OFFSET:POS_OFFSET+2]) return val * 5000
+ def get_rtone(mmap): """Return the memory rtone""" val = (ord(mmap[POS_TONE]) & 0xFC) >> 2 return chirp_common.TONES[val]
+ def get_ctone(mmap): """Return the memory ctone""" val = (ord(mmap[POS_TONE]) & 0x03) | ((ord(mmap[POS_TONE+1]) & 0xF0) >> 4) return chirp_common.TONES[val]
+ def get_dtcs(mmap): """Return the memory dtcs value""" val = ord(mmap[POS_DTCS]) >> 1 return chirp_common.DTCS_CODES[val]
+ def get_mode(mmap): """Return the memory mode""" val = ord(mmap[POS_MODE]) & 0x07 @@ -83,11 +91,12 @@ def get_mode(mmap):
return modemap[val]
+ def get_ts(mmap): """Return the memory tuning step""" val = (ord(mmap[POS_TS]) & 0xF0) >> 4 if val == 14: - return 5.0 # Coerce "Auto" to 5.0 + return 5.0 # Coerce "Auto" to 5.0
icf_ts = list(chirp_common.TUNING_STEPS) icf_ts.insert(2, 8.33) @@ -98,6 +107,7 @@ def get_ts(mmap):
return icf_ts[val]
+ def get_dtcs_polarity(mmap): """Return the memory dtcs polarity""" val = (ord(mmap[POS_DTCSPOL]) & 0x03) @@ -106,6 +116,7 @@ def get_dtcs_polarity(mmap):
return pols[val]
+ def get_duplex(mmap): """Return the memory duplex""" val = (ord(mmap[POS_DUPLEX]) & 0x0C) >> 2 @@ -114,10 +125,12 @@ def get_duplex(mmap):
return dup[val]
+ def get_name(mmap): """Return the memory name""" return mmap[POS_NAME:POS_NAME+8]
+ def get_memory(_mmap, number): """Get memory @number from global memory map @_mmap""" mmap = get_raw_memory(_mmap, number) diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 1573e99..6cca27c 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -1,7 +1,6 @@ # cpep8.blacklist: The list of files that do not meet PEP8 standards. # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. -./chirp/drivers/ic9x_icf_ll.py ./chirp/drivers/ic9x_ll.py ./chirp/drivers/icf.py ./chirp/drivers/icq7.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID 604a5b1688d04c6379f025c5f13423ad256cfabe
Fix style issues in ic9x_ll.py (#2355)
diff --git a/chirp/drivers/ic9x_ll.py b/chirp/drivers/ic9x_ll.py index 42a40ed..c23ab10 100644 --- a/chirp/drivers/ic9x_ll.py +++ b/chirp/drivers/ic9x_ll.py @@ -30,20 +30,26 @@ DTCS_POL = ["NN", "NR", "RN", "RR"] MEM_LEN = 34 DV_MEM_LEN = 60
+ # Dirty hack until I clean up this IC9x mess class IC9xMemory(chirp_common.Memory): """A dirty hack to stash bank information in a memory""" _bank = None _bank_index = 0 + def __init__(self): chirp_common.Memory.__init__(self) + + class IC9xDVMemory(chirp_common.DVMemory): """See above dirty hack""" _bank = None _bank_index = 0 + def __init__(self): chirp_common.DVMemory.__init__(self)
+ def _ic9x_parse_frames(buf): frames = []
@@ -65,10 +71,11 @@ def _ic9x_parse_frames(buf): except errors.InvalidDataError, e: print "Broken frame: %s" % e
- #print "Parsed %i frames" % len(frames) + # print "Parsed %i frames" % len(frames)
return frames
+ def ic9x_send(pipe, buf): """Send @buf to @pipe, wrapped in a header and trailer. Attempt to read any response frames, which are returned as a list""" @@ -76,7 +83,7 @@ def ic9x_send(pipe, buf): # Add header and trailer realbuf = "\xfe\xfe" + buf + "\xfd"
- #print "Sending:\n%s" % util.hexprint(realbuf) + # print "Sending:\n%s" % util.hexprint(realbuf)
pipe.write(realbuf) pipe.flush() @@ -91,6 +98,7 @@ def ic9x_send(pipe, buf):
return _ic9x_parse_frames(data)
+ class IC92Frame: """IC9x frame base class""" def get_vfo(self): @@ -149,7 +157,8 @@ class IC92Frame:
def __getslice__(self, start, end): return self._map[start+4:end+4] - + + class IC92GetBankFrame(IC92Frame): """A frame for requesting bank information""" def __init__(self): @@ -163,6 +172,7 @@ class IC92GetBankFrame(IC92Frame):
return rframes
+ class IC92BankFrame(IC92Frame): """A frame for bank information""" def __init__(self): @@ -186,6 +196,7 @@ class IC92BankFrame(IC92Frame): """Set the letter for the bank (A-Z)""" self[0] = ident[0]
+ class IC92MemClearFrame(IC92Frame): """A frame for clearing (erasing) a memory""" def __init__(self, loc): @@ -195,6 +206,7 @@ class IC92MemClearFrame(IC92Frame):
self[0] = struct.pack(">BHB", 1, int("%i" % loc, 16), 0xFF)
+ class IC92MemGetFrame(IC92Frame): """A frame for requesting a memory""" def __init__(self, loc, iscall=False): @@ -208,6 +220,7 @@ class IC92MemGetFrame(IC92Frame):
self[0] = struct.pack(">BH", call, int("%i" % loc, 16))
+ class IC92GetCallsignFrame(IC92Frame): """A frame for getting callsign information""" def __init__(self, calltype, number): @@ -215,9 +228,10 @@ class IC92GetCallsignFrame(IC92Frame):
self[0] = chr(number)
+ class IC92CallsignFrame(IC92Frame): """A frame to communicate callsign information""" - command = 0 # Invalid + command = 0 # Invalid width = 8
def __init__(self, number=0, callsign=""): @@ -231,18 +245,21 @@ class IC92CallsignFrame(IC92Frame): """Return the actual callsign""" return self[1:self.width+1].rstrip()
+ class IC92YourCallsignFrame(IC92CallsignFrame): """URCALL frame""" - command = 6 # Your + command = 6 # Your +
class IC92RepeaterCallsignFrame(IC92CallsignFrame): """RPTCALL frame""" - command = 7 # Repeater + command = 7 # Repeater +
class IC92MyCallsignFrame(IC92CallsignFrame): """MYCALL frame""" - command = 8 # My - width = 12 # 4 bytes for /STID + command = 8 # My + width = 12 # 4 bytes for /STID
MEMORY_FRAME_FORMAT = """ struct { @@ -276,6 +293,7 @@ struct { } mem[1]; """
+ class IC92MemoryFrame(IC92Frame): """A frame for communicating memory information""" def __init__(self): @@ -393,6 +411,7 @@ class IC92MemoryFrame(IC92Frame):
return mem
+ def _send_magic_4800(pipe): cmd = "\x01\x80\x19" magic = ("\xFE" * 25) + cmd @@ -402,9 +421,10 @@ def _send_magic_4800(pipe): return resp[0].get_raw()[0] == "\x80" return True
+ def _send_magic_38400(pipe): cmd = "\x01\x80\x19" - #rsp = "\x80\x01\x19" + # rsp = "\x80\x01\x19" magic = ("\xFE" * 400) + cmd for _i in [0, 1]: resp = ic9x_send(pipe, magic) @@ -412,6 +432,7 @@ def _send_magic_38400(pipe): return resp[0].get_raw()[0] == "\x80" return False
+ def send_magic(pipe): """Send the magic incantation to wake up an ic9x radio""" if pipe.getBaudrate() == 38400: @@ -437,8 +458,9 @@ def send_magic(pipe): pipe.setBaudrate(4800) raise errors.RadioError("Radio not responding") else: - raise errors.InvalidDataError("Radio in unknown state (%i)" % \ - pipe.getBaudrate()) + raise errors.InvalidDataError("Radio in unknown state (%i)" % + pipe.getBaudrate()) +
def get_memory_frame(pipe, vfo, number): """Get the memory frame for @vfo and @number via @pipe""" @@ -453,6 +475,7 @@ def get_memory_frame(pipe, vfo, number):
return frame.send(pipe)
+ def get_memory(pipe, vfo, number): """Get a memory object for @vfo and @number via @pipe""" rframe = get_memory_frame(pipe, vfo, number) @@ -468,20 +491,22 @@ def get_memory(pipe, vfo, number):
return mf.get_memory()
+ def set_memory(pipe, vfo, memory): """Set memory @memory on @vfo via @pipe""" frame = IC92MemoryFrame() frame.set_memory(memory) frame.set_vfo(vfo)
- #print "Sending (%i):" % (len(frame.get_raw())) - #print util.hexprint(frame.get_raw()) + # print "Sending (%i):" % (len(frame.get_raw())) + # print util.hexprint(frame.get_raw())
rframe = frame.send(pipe)
if rframe.get_raw()[2] != "\xfb": - raise errors.InvalidDataError("Radio reported error:\n%s" %\ - util.hexprint(rframe.get_payload())) + raise errors.InvalidDataError("Radio reported error:\n%s" % + util.hexprint(rframe.get_payload())) +
def erase_memory(pipe, vfo, number): """Erase memory @number on @vfo via @pipe""" @@ -492,6 +517,7 @@ def erase_memory(pipe, vfo, number): if rframe.get_raw()[2] != "\xfb": raise errors.InvalidDataError("Radio reported error")
+ def get_banks(pipe, vfo): """Get banks for @vfo via @pipe""" frame = IC92GetBankFrame() @@ -511,9 +537,10 @@ def get_banks(pipe, vfo): bframe.from_frame(rframes[i])
banks.append(bframe.get_name().rstrip()) - + return banks
+ def set_banks(pipe, vfo, banks): """Set banks for @vfo via @pipe""" for i in range(0, 26): @@ -526,6 +553,7 @@ def set_banks(pipe, vfo, banks): if rframe.get_payload() != "\xfb": raise errors.InvalidDataError("Radio reported error")
+ def get_call(pipe, cstype, number): """Get @cstype callsign @number via @pipe""" cframe = IC92GetCallsignFrame(cstype.command, number) @@ -537,6 +565,7 @@ def get_call(pipe, cstype, number):
return cframe.get_callsign()
+ def set_call(pipe, cstype, number, call): """Set @cstype @call at position @number via @pipe""" cframe = cstype(number, call) diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 6cca27c..f88f718 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -1,7 +1,6 @@ # cpep8.blacklist: The list of files that do not meet PEP8 standards. # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. -./chirp/drivers/ic9x_ll.py ./chirp/drivers/icf.py ./chirp/drivers/icq7.py ./chirp/drivers/ict70.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID a5082b8f73767bc7d39b51a452c0930ff780fb54
Fix style issues in icf.py (#2355)
diff --git a/chirp/drivers/icf.py b/chirp/drivers/icf.py index dad20ca..06e7b2b 100644 --- a/chirp/drivers/icf.py +++ b/chirp/drivers/icf.py @@ -22,12 +22,13 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueBoolean, RadioSettings
CMD_CLONE_OUT = 0xE2 -CMD_CLONE_IN = 0xE3 +CMD_CLONE_IN = 0xE3 CMD_CLONE_DAT = 0xE4 -CMD_CLONE_END = 0xE5 +CMD_CLONE_END = 0xE5
SAVE_PIPE = None
+ class IcfFrame: """A single ICF communication frame""" src = 0 @@ -37,15 +38,15 @@ class IcfFrame: payload = ""
def __str__(self): - addrs = { 0xEE : "PC", - 0xEF : "Radio"} - cmds = {0xE0 : "ID", - 0xE1 : "Model", - 0xE2 : "Clone out", - 0xE3 : "Clone in", - 0xE4 : "Clone data", - 0xE5 : "Clone end", - 0xE6 : "Clone result"} + addrs = {0xEE: "PC", + 0xEF: "Radio"} + cmds = {0xE0: "ID", + 0xE1: "Model", + 0xE2: "Clone out", + 0xE3: "Clone in", + 0xE4: "Clone data", + 0xE5: "Clone end", + 0xE6: "Clone result"}
return "%s -> %s [%s]:\n%s" % (addrs[self.src], addrs[self.dst], cmds[self.cmd], @@ -54,6 +55,7 @@ class IcfFrame: def __init__(self): pass
+ def parse_frame_generic(data): """Parse an ICF frame of unknown type from the beginning of @data""" frame = IcfFrame() @@ -71,6 +73,7 @@ def parse_frame_generic(data):
return frame, data[end+1:]
+ class RadioStream: """A class to make reading a stream of IcfFrames easier""" def __init__(self, pipe): @@ -81,7 +84,7 @@ class RadioStream: if not self.data.startswith("\xFE\xFE"): raise errors.InvalidDataError("Out of sync with radio") elif len(self.data) < 5: - return [] # Not enough data for a full frame + return [] # Not enough data for a full frame
frames = []
@@ -89,7 +92,7 @@ class RadioStream: try: cmd = ord(self.data[4]) except IndexError: - break # Out of data + break # Out of data
try: frame, rest = parse_frame_generic(self.data) @@ -118,19 +121,20 @@ class RadioStream: self.data += _data
if not nolimit and len(self.data) > 128 and "\xFD" in self.data: - break # Give us a chance to do some status + break # Give us a chance to do some status if len(self.data) > 1024: - break # Avoid an endless loop of chewing garbage + break # Avoid an endless loop of chewing garbage
if not self.data: return []
return self._process_frames()
+ def get_model_data(pipe, mdata="\x00\x00\x00\x00"): """Query the radio connected to @pipe for its model data""" send_clone_frame(pipe, 0xe0, mdata, raw=True) - + stream = RadioStream(pipe) frames = stream.get_frames()
@@ -139,6 +143,7 @@ def get_model_data(pipe, mdata="\x00\x00\x00\x00"):
return frames[0].payload
+ def get_clone_resp(pipe, length=None): """Read the response to a clone frame""" def exit_criteria(buf, length): @@ -155,6 +160,7 @@ def get_clone_resp(pipe, length=None):
return resp
+ def send_clone_frame(pipe, cmd, data, raw=False, checksum=False): """Send a clone frame with @cmd and @data to the radio attached to @pipe""" @@ -181,17 +187,18 @@ def send_clone_frame(pipe, cmd, data, raw=False, checksum=False): print "Saving data..." SAVE_PIPE.write(frame)
- #print "Sending:\n%s" % util.hexprint(frame) - #print "Sending:\n%s" % util.hexprint(hed[6:]) + # print "Sending:\n%s" % util.hexprint(frame) + # print "Sending:\n%s" % util.hexprint(hed[6:]) if cmd == 0xe4: # Uncomment to avoid cloning to the radio # return frame pass - + pipe.write(frame)
return frame
+ def process_bcd(bcddata): """Convert BCD-encoded data to raw""" data = "" @@ -207,6 +214,7 @@ def process_bcd(bcddata):
return data
+ def process_data_frame(frame, _mmap): """Process a data frame, adding the payload to @_mmap""" _data = process_bcd(frame.payload) @@ -226,6 +234,7 @@ def process_data_frame(frame, _mmap): (bytes, saddr, len(_mmap)) return saddr, saddr + length
+ def start_hispeed_clone(radio, cmd): """Send the magic incantation to the radio to go fast""" buf = ("\xFE" * 20) + \ @@ -250,6 +259,7 @@ def start_hispeed_clone(radio, cmd): radio.pipe.write(buf) radio.pipe.flush()
+ def _clone_from_radio(radio): md = get_model_data(radio.pipe)
@@ -261,7 +271,8 @@ def _clone_from_radio(radio): if radio.is_hispeed(): start_hispeed_clone(radio, CMD_CLONE_OUT) else: - send_clone_frame(radio.pipe, CMD_CLONE_OUT, radio.get_model(), raw=True) + send_clone_frame(radio.pipe, CMD_CLONE_OUT, + radio.get_model(), raw=True)
print "Sent clone frame"
@@ -300,6 +311,7 @@ def _clone_from_radio(radio):
return _mmap
+ def clone_from_radio(radio): """Do a full clone out of the radio's memory""" try: @@ -307,6 +319,7 @@ def clone_from_radio(radio): except Exception, e: raise errors.RadioError("Failed to communicate with the radio: %s" % e)
+ def send_mem_chunk(radio, start, stop, bs=32): """Send a single chunk of the radio's memory from @start-@stop""" _mmap = radio.get_mmap() @@ -338,6 +351,7 @@ def send_mem_chunk(radio, start, stop, bs=32):
return True
+ def _clone_to_radio(radio): global SAVE_PIPE
@@ -387,6 +401,7 @@ def _clone_to_radio(radio):
return result.payload[0] == '\x00'
+ def clone_to_radio(radio): """Initiate a full memory clone out to @radio""" try: @@ -394,6 +409,7 @@ def clone_to_radio(radio): except Exception, e: raise errors.RadioError("Failed to communicate with the radio: %s" % e)
+ def convert_model(mod_str): """Convert an ICF-style model string into what we get from the radio""" data = "" @@ -404,6 +420,7 @@ def convert_model(mod_str):
return data
+ def convert_data_line(line): """Convert an ICF data line to raw memory format""" if line.startswith("#"): @@ -433,13 +450,14 @@ def convert_data_line(line):
return _mmap
+ def read_file(filename): """Read an ICF file and return the model string and memory data""" f = file(filename)
mod_str = f.readline() dat = f.readlines() - + model = convert_model(mod_str.strip())
_mmap = "" @@ -449,6 +467,7 @@ def read_file(filename):
return model, memmap.MemoryMap(_mmap)
+ def is_9x_icf(filename): """Returns True if @filename is an IC9x ICF file""" f = file(filename) @@ -457,6 +476,7 @@ def is_9x_icf(filename):
return mdata in ["30660000", "28880000"]
+ def is_icf_file(filename): """Returns True if @filename is an ICF file""" f = file(filename) @@ -468,18 +488,21 @@ def is_icf_file(filename):
return bool(re.match("^[0-9]{8}#", data))
+ class IcomBank(chirp_common.Bank): """A bank that works for all Icom radios""" # Integral index of the bank (not to be confused with per-memory # bank indexes index = 0
+ class IcomNamedBank(IcomBank): """A bank with an adjustable name""" def set_name(self, name): """Set the name of the bank""" pass
+ class IcomBankModel(chirp_common.BankModel): """Icom radios all have pretty much the same simple bank model. This central implementation can, with a few icom-specific radio interfaces @@ -490,7 +513,7 @@ class IcomBankModel(chirp_common.BankModel):
def get_mappings(self): banks = [] - + for i in range(0, self._radio._num_banks): index = chr(ord("A") + i) bank = self._radio._bank_class(self, index, "BANK-%s" % index) @@ -503,8 +526,8 @@ class IcomBankModel(chirp_common.BankModel):
def remove_memory_from_mapping(self, memory, bank): if self._radio._get_bank(memory.number) != bank.index: - raise Exception("Memory %i not in bank %s. Cannot remove." % \ - (memory.number, bank)) + raise Exception("Memory %i not in bank %s. Cannot remove." % + (memory.number, bank))
self._radio._set_bank(memory.number, None)
@@ -521,7 +544,8 @@ class IcomBankModel(chirp_common.BankModel): return [] else: return [self.get_mappings()[index]] - + + class IcomIndexedBankModel(IcomBankModel, chirp_common.MappingModelIndexInterface): """Generic bank model for Icom radios with indexed banks""" @@ -545,13 +569,13 @@ class IcomIndexedBankModel(IcomBankModel, for i in range(*self._radio.get_features().memory_bounds): if self._radio._get_bank(i) == bank.index: indexes.append(self._radio._get_bank_index(i)) - + for i in range(0, 256): if i not in indexes: return i
raise errors.RadioError("Out of slots in this bank") - +
class IcomCloneModeRadio(chirp_common.CloneModeRadio): """Base class for Icom clone-mode radios""" @@ -619,6 +643,7 @@ class IcomCloneModeRadio(chirp_common.CloneModeRadio): def set_settings(self, settings): return honor_speed_switch_setting(self, settings)
+ class IcomLiveRadio(chirp_common.LiveRadio): """Base class for an Icom Live-mode radio""" VENDOR = "Icom" @@ -638,6 +663,7 @@ class IcomLiveRadio(chirp_common.LiveRadio): else: return None
+ def make_speed_switch_setting(radio): if not radio.__class__._can_hispeed: return {} @@ -648,6 +674,7 @@ def make_speed_switch_setting(radio): drvopts.append(rs) return top
+ def honor_speed_switch_setting(radio, settings): for element in settings: if element.get_name() == "drvopts": diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index f88f718..2e913b8 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -1,7 +1,6 @@ # cpep8.blacklist: The list of files that do not meet PEP8 standards. # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. -./chirp/drivers/icf.py ./chirp/drivers/icq7.py ./chirp/drivers/ict70.py ./chirp/drivers/ict8.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID 67a0ae57a46857e6b40acf476a446e5c7ca51599
Fix style issues in icq7.py (#2355)
diff --git a/chirp/drivers/icq7.py b/chirp/drivers/icq7.py index ed74f19..44ec43e 100644 --- a/chirp/drivers/icq7.py +++ b/chirp/drivers/icq7.py @@ -74,10 +74,10 @@ u8 lockgroup;
"""
-TMODES = ["", "", "Tone", "TSQL", "TSQL"] # last one is pocket beep +TMODES = ["", "", "Tone", "TSQL", "TSQL"] # last one is pocket beep DUPLEX = ["", "", "-", "+"] -MODES = ["FM", "WFM", "AM", "Auto"] -STEPS = [5.0, 6.25, 10.0, 12.5, 15.0, 20.0, 25.0, 30.0, 50.0, 100.0] +MODES = ["FM", "WFM", "AM", "Auto"] +STEPS = [5.0, 6.25, 10.0, 12.5, 15.0, 20.0, 25.0, 30.0, 50.0, 100.0] AUTORP_LIST = ["Off", "Duplex Only", "Duplex and Tone"] LOCKGROUP_LIST = ["Normal", "No Squelch", "No Volume", "All"] SQUELCH_LIST = ["Open", "Auto"] + ["L%s" % x for x in range(1, 10)] @@ -91,6 +91,7 @@ RESUME_LIST = ["%s sec" % x for x in range(0, 6)] APOFF_LIST = ["Off"] + ["%s min" % x for x in range(30, 150, 30)] D_SEL_LIST = ["100 KHz", "1 MHz", "10 MHz"]
+ @directory.register class ICQ7Radio(icf.IcomCloneModeRadio): """Icom IC-Q7A""" @@ -111,8 +112,8 @@ class ICQ7Radio(icf.IcomCloneModeRadio): rf.valid_tmodes = list(TMODES) rf.valid_duplexes = list(DUPLEX) rf.valid_tuning_steps = list(STEPS) - rf.valid_bands = [( 1000000, 823995000), - (849000000, 868995000), + rf.valid_bands = [(1000000, 823995000), + (849000000, 868995000), (894000000, 1309995000)] rf.valid_skips = ["", "S", "P"] rf.has_dtcs = False @@ -170,12 +171,12 @@ class ICQ7Radio(icf.IcomCloneModeRadio): def set_memory(self, mem): _mem = self._memobj.memory[mem.number] _flag = self._memobj.flags[mem.number] - + if mem.empty: self._memobj.flags_whole[mem.number] = 0xFF return - - _mem.set_raw("\x00" * 8) + + _mem.set_raw("\x00" * 8)
if mem.freq > to_GHz(1): _mem.freq = (mem.freq / 1000) - to_GHz(1) @@ -213,8 +214,8 @@ class ICQ7Radio(icf.IcomCloneModeRadio): basic.append(rs)
rs = RadioSetting("autorp", "Auto Repeater Function", - RadioSettingValueList(AUTORP_LIST, - AUTORP_LIST[_settings.autorp])) + RadioSettingValueList( + AUTORP_LIST, AUTORP_LIST[_settings.autorp])) basic.append(rs)
rs = RadioSetting("ritfunct", "RIT Runction", @@ -230,27 +231,30 @@ class ICQ7Radio(icf.IcomCloneModeRadio): basic.append(rs)
rs = RadioSetting("lockgroup", "Lock Group", - RadioSettingValueList(LOCKGROUP_LIST, + RadioSettingValueList( + LOCKGROUP_LIST, LOCKGROUP_LIST[_settings.lockgroup])) basic.append(rs)
rs = RadioSetting("squelch", "Squelch", - RadioSettingValueList(SQUELCH_LIST, - SQUELCH_LIST[_settings.squelch])) + RadioSettingValueList( + SQUELCH_LIST, SQUELCH_LIST[_settings.squelch])) basic.append(rs)
rs = RadioSetting("monitor", "Monitor Switch Function", - RadioSettingValueList(MONITOR_LIST, + RadioSettingValueList( + MONITOR_LIST, MONITOR_LIST[_settings.monitor])) basic.append(rs)
rs = RadioSetting("light", "Display Backlighting", - RadioSettingValueList(LIGHT_LIST, - LIGHT_LIST[_settings.light])) + RadioSettingValueList( + LIGHT_LIST, LIGHT_LIST[_settings.light])) basic.append(rs)
rs = RadioSetting("priority", "Priority Watch Operation", - RadioSettingValueList(PRIORITY_LIST, + RadioSettingValueList( + PRIORITY_LIST, PRIORITY_LIST[_settings.priority])) basic.append(rs)
@@ -259,23 +263,24 @@ class ICQ7Radio(icf.IcomCloneModeRadio): basic.append(rs)
rs = RadioSetting("bnk_scan", "Memory Bank Scan Selection", - RadioSettingValueList(BANKSCAN_LIST, + RadioSettingValueList( + BANKSCAN_LIST, BANKSCAN_LIST[_settings.bnk_scan])) basic.append(rs)
rs = RadioSetting("edge", "Band Edge Scan Selection", - RadioSettingValueList(EDGE_LIST, - EDGE_LIST[_settings.edge])) + RadioSettingValueList( + EDGE_LIST, EDGE_LIST[_settings.edge])) basic.append(rs)
rs = RadioSetting("pause", "Scan Pause Time", - RadioSettingValueList(PAUSE_LIST, - PAUSE_LIST[_settings.pause])) + RadioSettingValueList( + PAUSE_LIST, PAUSE_LIST[_settings.pause])) basic.append(rs)
rs = RadioSetting("resume", "Scan Resume Time", - RadioSettingValueList(RESUME_LIST, - RESUME_LIST[_settings.resume])) + RadioSettingValueList( + RESUME_LIST, RESUME_LIST[_settings.resume])) basic.append(rs)
rs = RadioSetting("p_save", "Power Saver", @@ -283,8 +288,8 @@ class ICQ7Radio(icf.IcomCloneModeRadio): basic.append(rs)
rs = RadioSetting("ap_off", "Auto Power-off Function", - RadioSettingValueList(APOFF_LIST, - APOFF_LIST[_settings.ap_off])) + RadioSettingValueList( + APOFF_LIST, APOFF_LIST[_settings.ap_off])) basic.append(rs)
rs = RadioSetting("speed", "Dial Speed Acceleration", @@ -292,8 +297,8 @@ class ICQ7Radio(icf.IcomCloneModeRadio): basic.append(rs)
rs = RadioSetting("d_sel", "Dial Select Step", - RadioSettingValueList(D_SEL_LIST, - D_SEL_LIST[_settings.d_sel])) + RadioSettingValueList( + D_SEL_LIST, D_SEL_LIST[_settings.d_sel])) basic.append(rs)
return group @@ -331,4 +336,3 @@ class ICQ7Radio(icf.IcomCloneModeRadio): except Exception, e: print element.get_name() raise - diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 2e913b8..e412e4b 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -1,7 +1,6 @@ # cpep8.blacklist: The list of files that do not meet PEP8 standards. # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. -./chirp/drivers/icq7.py ./chirp/drivers/ict70.py ./chirp/drivers/ict8.py ./chirp/drivers/icw32.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID 6a7c733ac5c64830044316e62b7a52c05e757255
Fix style issues in ict70.py (#2355)
diff --git a/chirp/drivers/ict70.py b/chirp/drivers/ict70.py index eb81d7e..4066c69 100644 --- a/chirp/drivers/ict70.py +++ b/chirp/drivers/ict70.py @@ -69,6 +69,7 @@ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=5), chirp_common.PowerLevel("Mid", watts=1.0), ]
+ class ICT70Bank(icf.IcomBank): """ICT70 bank""" def get_name(self): @@ -79,6 +80,7 @@ class ICT70Bank(icf.IcomBank): _bank = self._model._radio._memobj.bank_names[self.index] _bank.name = name.ljust(6)[:6]
+ @directory.register class ICT70Radio(icf.IcomCloneModeRadio): """Icom IC-T70""" @@ -93,7 +95,7 @@ class ICT70Radio(icf.IcomCloneModeRadio):
_num_banks = 26 _bank_class = ICT70Bank - + def _get_bank(self, loc): _bank = self._memobj.banks[loc] if _bank.bank != 0xFF: @@ -115,7 +117,7 @@ class ICT70Radio(icf.IcomCloneModeRadio): def _set_bank_index(self, loc, index): _bank = self._memobj.banks[loc] _bank.index = index - + def get_features(self): rf = chirp_common.RadioFeatures() rf.memory_bounds = (0, 299) @@ -171,7 +173,7 @@ class ICT70Radio(icf.IcomCloneModeRadio): mem.dtcs_polarity = DTCS_POLARITY[_mem.dtcs_polarity] mem.tmode = TMODES[_mem.tmode] mem.skip = (_psk & bit and "P") or (_skp & bit and "S") or "" - + return mem
def set_memory(self, mem): @@ -219,4 +221,3 @@ class ICT70Radio(icf.IcomCloneModeRadio): else: _skp &= ~bit _psk &= ~bit - diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index e412e4b..9e6f852 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -1,7 +1,6 @@ # cpep8.blacklist: The list of files that do not meet PEP8 standards. # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. -./chirp/drivers/ict70.py ./chirp/drivers/ict8.py ./chirp/drivers/icw32.py ./chirp/drivers/icx8x.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID b2c1a57defead31d8f9232fd24cec77e6ff51693
Fix style issues in ict8.py (#2355)
diff --git a/chirp/drivers/ict8.py b/chirp/drivers/ict8.py index ea3d82a..742bc73 100644 --- a/chirp/drivers/ict8.py +++ b/chirp/drivers/ict8.py @@ -42,6 +42,7 @@ struct flags flags[100]; DUPLEX = ["", "", "-", "+"] TMODES = ["", "", "Tone", "TSQL"]
+ @directory.register class ICT8ARadio(icf.IcomCloneModeRadio): """Icom IC-T8A""" diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 9e6f852..31d7067 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -1,7 +1,6 @@ # cpep8.blacklist: The list of files that do not meet PEP8 standards. # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. -./chirp/drivers/ict8.py ./chirp/drivers/icw32.py ./chirp/drivers/icx8x.py ./chirp/drivers/icx8x_ll.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID 31886abc676b9b0a4e2d7b292091ea768fad1937
Fix style issues in icw32.py (#2355)
diff --git a/chirp/drivers/icw32.py b/chirp/drivers/icw32.py index 601f113..356d81a 100644 --- a/chirp/drivers/icw32.py +++ b/chirp/drivers/icw32.py @@ -61,12 +61,14 @@ struct { DUPLEX = ["", "", "-", "+"] TONE = ["", "", "Tone", "TSQL"]
+ def _get_special(): special = {} for i in range(0, 5): special["M%iA" % (i+1)] = 100 + i*2 special["M%iB" % (i+1)] = 100 + i*2 + 1 - return special + return special +
@directory.register class ICW32ARadio(icf.IcomCloneModeRadio): @@ -94,7 +96,7 @@ class ICW32ARadio(icf.IcomCloneModeRadio): rf.valid_tmodes = ["", "Tone", "TSQL"] rf.valid_name_length = 8 rf.valid_special_chans = sorted(_get_special().keys()) - + rf.has_sub_devices = self.VARIANT == "" rf.has_ctone = True rf.has_dtcs = False @@ -187,12 +189,14 @@ class ICW32ARadio(icf.IcomCloneModeRadio): return False return filedata[-16:] == "IcomCloneFormat3"
+ class ICW32ARadioVHF(ICW32ARadio): """ICW32 VHF subdevice""" VARIANT = "VHF" _limits = (118000000, 174000000) _mem_positions = (0x0000, 0x0DC0)
+ class ICW32ARadioUHF(ICW32ARadio): """ICW32 UHF subdevice""" VARIANT = "UHF" diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 31d7067..d4143c2 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -1,6 +1,5 @@ # cpep8.blacklist: The list of files that do not meet PEP8 standards. # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. -./chirp/drivers/icw32.py ./chirp/drivers/icx8x.py ./chirp/drivers/icx8x_ll.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID 92fe9e79fb4736e6f0633b78b06d56578da686c2
Fix style issues in icx8x.py (#2355)
diff --git a/chirp/drivers/icx8x.py b/chirp/drivers/icx8x.py index 776bd74..bf17f1a 100644 --- a/chirp/drivers/icx8x.py +++ b/chirp/drivers/icx8x.py @@ -16,6 +16,7 @@ from chirp.drivers import icf, icx8x_ll from chirp import chirp_common, errors, directory
+ def _isuhf(pipe): try: md = icf.get_model_data(pipe) @@ -28,6 +29,7 @@ def _isuhf(pipe):
return uhf
+ @directory.register class ICx8xRadio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport): """Icom IC-V/U82""" @@ -100,7 +102,7 @@ class ICx8xRadio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport): # that flag. if isinstance(pipe, str): self._isuhf = (ord(self._mmap[0x1930]) != 0) - #print "Found %s image" % (self.isUHF and "UHF" or "VHF") + # print "Found %s image" % (self.isUHF and "UHF" or "VHF") else: self._isuhf = None
@@ -126,8 +128,8 @@ class ICx8xRadio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport): try: number = icx8x_ll.ICx8x_SPECIAL[number] except KeyError: - raise errors.InvalidMemoryLocation("Unknown channel %s" % \ - number) + raise errors.InvalidMemoryLocation("Unknown channel %s" % + number)
return icx8x_ll.get_memory(self._mmap, number, base)
diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index d4143c2..5ced208 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -1,5 +1,4 @@ # cpep8.blacklist: The list of files that do not meet PEP8 standards. # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. -./chirp/drivers/icx8x.py ./chirp/drivers/icx8x_ll.py
# HG changeset patch # User Zachary T Welch zach@mandolincreekfarm.com # Fake Node ID 79b8111a466b0b5f3c10e5882fd75c1b82f34172
Fix style issues in icx8x_ll.py (#2355)
diff --git a/chirp/drivers/icx8x_ll.py b/chirp/drivers/icx8x_ll.py index 92f2d9c..ffbfa12 100644 --- a/chirp/drivers/icx8x_ll.py +++ b/chirp/drivers/icx8x_ll.py @@ -20,32 +20,32 @@ from chirp.memmap import MemoryMap from chirp.chirp_common import to_MHz
POS_FREQ_START = 0 -POS_FREQ_END = 2 -POS_OFFSET = 2 +POS_FREQ_END = 2 +POS_OFFSET = 2 POS_NAME_START = 4 -POS_NAME_END = 9 -POS_RTONE = 9 -POS_CTONE = 10 -POS_DTCS = 11 -POS_TUNE_STEP = 17 -POS_TMODE = 21 -POS_MODE = 21 -POS_MULT_FLAG = 21 -POS_DTCS_POL = 22 -POS_DUPLEX = 22 -POS_DIG = 23 -POS_TXI = 23 - -POS_FLAGS_START= 0x1370 -POS_MYCALL = 0x15E0 -POS_URCALL = 0x1640 -POS_RPCALL = 0x16A0 -POS_RP2CALL = 0x1700 - -MEM_LOC_SIZE = 24 - -ICx8x_SPECIAL = { "C" : 206 } -ICx8x_SPECIAL_REV = { 206 : "C" } +POS_NAME_END = 9 +POS_RTONE = 9 +POS_CTONE = 10 +POS_DTCS = 11 +POS_TUNE_STEP = 17 +POS_TMODE = 21 +POS_MODE = 21 +POS_MULT_FLAG = 21 +POS_DTCS_POL = 22 +POS_DUPLEX = 22 +POS_DIG = 23 +POS_TXI = 23 + +POS_FLAGS_START = 0x1370 +POS_MYCALL = 0x15E0 +POS_URCALL = 0x1640 +POS_RPCALL = 0x16A0 +POS_RP2CALL = 0x1700 + +MEM_LOC_SIZE = 24 + +ICx8x_SPECIAL = {"C": 206} +ICx8x_SPECIAL_REV = {206: "C"}
for i in range(0, 3): idA = "%iA" % i @@ -56,10 +56,12 @@ for i in range(0, 3): ICx8x_SPECIAL_REV[num] = idA ICx8x_SPECIAL_REV[num+1] = idB
+ def bank_name(index): char = chr(ord("A") + index) return "BANK-%s" % char
+ def get_freq(mmap, base): if (ord(mmap[POS_MULT_FLAG]) & 0x80) == 0x80: mult = 6250 @@ -70,6 +72,7 @@ def get_freq(mmap, base):
return (val * mult) + to_MHz(base)
+ def set_freq(mmap, freq, base): tflag = ord(mmap[POS_MULT_FLAG]) & 0x7F
@@ -84,65 +87,78 @@ def set_freq(mmap, freq, base): mmap[POS_MULT_FLAG] = tflag mmap[POS_FREQ_START] = struct.pack("<H", value)
+ def get_name(mmap): return mmap[POS_NAME_START:POS_NAME_END].strip()
+ def set_name(mmap, name): mmap[POS_NAME_START] = name.ljust(5)[:5]
+ def get_rtone(mmap): idx, = struct.unpack("B", mmap[POS_RTONE])
return chirp_common.TONES[idx]
+ def set_rtone(mmap, tone): mmap[POS_RTONE] = chirp_common.TONES.index(tone)
+ def get_ctone(mmap): idx, = struct.unpack("B", mmap[POS_CTONE])
return chirp_common.TONES[idx]
+ def set_ctone(mmap, tone): mmap[POS_CTONE] = chirp_common.TONES.index(tone)
+ def get_dtcs(mmap): idx, = struct.unpack("B", mmap[POS_DTCS])
return chirp_common.DTCS_CODES[idx]
+ def set_dtcs(mmap, code): mmap[POS_DTCS] = chirp_common.DTCS_CODES.index(code)
+ def get_dtcs_polarity(mmap): val = struct.unpack("B", mmap[POS_DTCS_POL])[0] & 0xC0
pol_values = { - 0x00 : "NN", - 0x40 : "NR", - 0x80 : "RN", - 0xC0 : "RR" } + 0x00: "NN", + 0x40: "NR", + 0x80: "RN", + 0xC0: "RR"}
return pol_values[val]
+ def set_dtcs_polarity(mmap, polarity): val = struct.unpack("B", mmap[POS_DTCS_POL])[0] & 0x3F - pol_values = { "NN" : 0x00, - "NR" : 0x40, - "RN" : 0x80, - "RR" : 0xC0 } + pol_values = {"NN": 0x00, + "NR": 0x40, + "RN": 0x80, + "RR": 0xC0} val |= pol_values[polarity]
mmap[POS_DTCS_POL] = val
+ def get_dup_offset(mmap): val = struct.unpack("<H", mmap[POS_OFFSET:POS_OFFSET+2])[0] return val * 5000
+ def set_dup_offset(mmap, offset): val = struct.pack("<H", offset / 5000) mmap[POS_OFFSET] = val
+ def get_duplex(mmap): val = struct.unpack("B", mmap[POS_DUPLEX])[0] & 0x30
@@ -153,6 +169,7 @@ def get_duplex(mmap): else: return ""
+ def set_duplex(mmap, duplex): val = struct.unpack("B", mmap[POS_DUPLEX])[0] & 0xCF
@@ -163,6 +180,7 @@ def set_duplex(mmap, duplex):
mmap[POS_DUPLEX] = val
+ def get_tone_enabled(mmap): val = struct.unpack("B", mmap[POS_TMODE])[0] & 0x03
@@ -175,6 +193,7 @@ def get_tone_enabled(mmap): else: return ""
+ def set_tone_enabled(mmap, tmode): val = struct.unpack("B", mmap[POS_TMODE])[0] & 0xFC
@@ -187,6 +206,7 @@ def set_tone_enabled(mmap, tmode):
mmap[POS_TMODE] = val
+ def get_tune_step(mmap): tsidx = struct.unpack("B", mmap[POS_TUNE_STEP])[0] & 0xF0 tsidx >>= 4 @@ -196,8 +216,9 @@ def get_tune_step(mmap): try: return icx8x_ts[tsidx] except IndexError: - raise errors.InvalidDataError("TS index %i out of range (%i)" % (tsidx, - len(icx8x_ts))) + raise errors.InvalidDataError("TS index %i out of range (%i)" % + (tsidx, len(icx8x_ts))) +
def set_tune_step(mmap, tstep): val = struct.unpack("B", mmap[POS_TUNE_STEP])[0] & 0x0F @@ -207,7 +228,8 @@ def set_tune_step(mmap, tstep): tsidx = icx8x_ts.index(tstep) val |= (tsidx << 4)
- mmap[POS_TUNE_STEP] = val + mmap[POS_TUNE_STEP] = val +
def get_mode(mmap): val = struct.unpack("B", mmap[POS_DIG])[0] & 0x08 @@ -222,6 +244,7 @@ def get_mode(mmap): else: return "FM"
+ def set_mode(mmap, mode): dig = struct.unpack("B", mmap[POS_DIG])[0] & 0xF7
@@ -239,12 +262,14 @@ def set_mode(mmap, mode): mmap[POS_DIG] = dig mmap[POS_MODE] = val
+ def is_used(mmap, number): if number == ICx8x_SPECIAL["C"]: return True
return (ord(mmap[POS_FLAGS_START + number]) & 0x20) == 0
+ def set_used(mmap, number, used=True): if number == ICx8x_SPECIAL["C"]: return @@ -256,6 +281,7 @@ def set_used(mmap, number, used=True):
mmap[POS_FLAGS_START + number] = val
+ def get_skip(mmap, number): val = struct.unpack("B", mmap[POS_FLAGS_START + number])[0] & 0x10
@@ -264,6 +290,7 @@ def get_skip(mmap, number): else: return ""
+ def set_skip(mmap, number, skip): if skip == "P": raise errors.InvalidDataError("PSKIP not supported by this model") @@ -275,11 +302,13 @@ def set_skip(mmap, number, skip):
mmap[POS_FLAGS_START + number] = val
+ def get_call_indices(mmap): return ord(mmap[18]) & 0x0F, \ (ord(mmap[19]) & 0xF0) >> 4, \ ord(mmap[19]) & 0x0F
+ def set_call_indices(_map, mmap, urcall, r1call, r2call): ulist = [] for i in range(0, 6): @@ -318,13 +347,16 @@ def set_call_indices(_map, mmap, urcall, r1call, r2call):
# --
+ def get_mem_offset(number): return number * MEM_LOC_SIZE
+ def get_raw_memory(mmap, number): offset = get_mem_offset(number) return MemoryMap(mmap[offset:offset + MEM_LOC_SIZE])
+ def get_bank(mmap, number): val = ord(mmap[POS_FLAGS_START + number]) & 0x0F
@@ -333,6 +365,7 @@ def get_bank(mmap, number): else: return val
+ def set_bank(mmap, number, bank): if bank > 9: raise errors.InvalidDataError("Invalid bank number %i" % bank) @@ -344,7 +377,8 @@ def set_bank(mmap, number, bank):
val = ord(mmap[POS_FLAGS_START + number]) & 0xF0 val |= index - mmap[POS_FLAGS_START + number] = val + mmap[POS_FLAGS_START + number] = val +
def _get_memory(_map, mmap, base): if get_mode(mmap) == "DV": @@ -370,6 +404,7 @@ def _get_memory(_map, mmap, base):
return mem
+ def get_memory(_map, number, base): if not is_used(_map, number): mem = chirp_common.Memory() @@ -391,11 +426,13 @@ def get_memory(_map, number, base):
return mem
+ def clear_tx_inhibit(mmap): txi = struct.unpack("B", mmap[POS_TXI])[0] txi |= 0x40 mmap[POS_TXI] = txi
+ def set_memory(_map, memory, base): mmap = get_raw_memory(_map, memory.number)
@@ -428,14 +465,17 @@ def set_memory(_map, memory, base):
return _map
+ def erase_memory(_map, number): set_used(_map, number, False)
return _map
+ def call_location(base, index): return base + (16 * index)
+ def get_urcall(mmap, index): if index > 5: raise errors.InvalidDataError("URCALL index %i must be <= 5" % index) @@ -444,6 +484,7 @@ def get_urcall(mmap, index):
return mmap[start:start+8].rstrip()
+ def get_rptcall(mmap, index): if index > 5: raise errors.InvalidDataError("RPTCALL index %i must be <= 5" % index) @@ -452,6 +493,7 @@ def get_rptcall(mmap, index):
return mmap[start:start+8].rstrip()
+ def get_mycall(mmap, index): if index > 5: raise errors.InvalidDataError("MYCALL index %i must be <= 5" % index) @@ -460,6 +502,7 @@ def get_mycall(mmap, index):
return mmap[start:start+8].rstrip()
+ def set_urcall(mmap, index, call): if index > 5: raise errors.InvalidDataError("URCALL index %i must be <= 5" % index) @@ -467,9 +510,10 @@ def set_urcall(mmap, index, call): start = call_location(POS_URCALL, index)
mmap[start] = call.ljust(12) - + return mmap
+ def set_rptcall(mmap, index, call): if index > 5: raise errors.InvalidDataError("RPTCALL index %i must be <= 5" % index) @@ -479,9 +523,10 @@ def set_rptcall(mmap, index, call):
start = call_location(POS_RP2CALL, index) mmap[start] = call.ljust(12) - + return mmap
+ def set_mycall(mmap, index, call): if index > 5: raise errors.InvalidDataError("MYCALL index %i must be <= 5" % index) @@ -489,5 +534,5 @@ def set_mycall(mmap, index, call): start = call_location(POS_MYCALL, index)
mmap[start] = call.ljust(12) - + return mmap diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 5ced208..6a98e72 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -1,4 +1,3 @@ # cpep8.blacklist: The list of files that do not meet PEP8 standards. # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. -./chirp/drivers/icx8x_ll.py
participants (1)
-
Zachary T Welch