[chirp_devel] [PATCH] Added support for Radioddity R2 #6063
# HG changeset patch # User Klaus Ruebsam dg5eau@ruebsam.eu # Date 1536177614 -7200 # Wed Sep 05 22:00:14 2018 +0200 # Node ID 4b15c76e5cbcf9eb411ec2657ce8778fd178f258 # Parent 26da631376cd1b9c349e26a5ffe6b787712df1ad Added support for Radioddity R2 #6063 * * * Add support for Radioddity R2 & remove unnecessary try except #6063
diff --git a/chirp/drivers/radioddity_r2.py b/chirp/drivers/radioddity_r2.py --- a/chirp/drivers/radioddity_r2.py +++ b/chirp/drivers/radioddity_r2.py @@ -1,4 +1,4 @@ -# Copyright August 2018 Klaus Ruebsam chirp.dev@ruebsam.eu +# Copyright August 2018 Klaus Ruebsam dg5eau@ruebsam.eu # # 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 @@ -49,7 +49,7 @@
# the last three bytes of every channel are identical # to the first three bytes of the next channel in row. -# Might be used for skipping a channel. Will have to test +# However it will automatically be filled by the radio itself
MEM_FORMAT = """ #seekto 0x0010; @@ -66,7 +66,7 @@ mode:1, unknown2:1, bclo:1; - u8 unknown3 [3]; + u8 unknown3[3]; } memory[16];
#seekto 0x03C0; @@ -103,7 +103,6 @@ MODE_LIST = ["WFM", "NFM"]
TONES = chirp_common.TONES -#TONES.remove(254.1) DTCS_CODES = chirp_common.DTCS_CODES
SETTING_LISTS = { @@ -129,19 +128,14 @@ for j in range(0, len(magic)): serial.write(magic[j]) ack = serial.read(1) - - try: - if ack == CMD_ACK: - exito = True - break - except: - LOG.debug("Attempt #%s, failed, trying again" % i) - pass + if ack == CMD_ACK: + exito = True + break
# check if we had EXITO if exito is False: msg = "The radio did not accept program mode after five tries.\n" - msg += "Check you interface cable and power cycle your radio." + msg += "Check your interface cable and power cycle your radio." raise errors.RadioError(msg)
try: @@ -194,6 +188,7 @@ _r2_exit_programming_mode(radio) raise errors.RadioError("Radio refused to enter programming mode 2")
+ def _r2_exit_programming_mode(radio): serial = radio.pipe try: @@ -304,17 +299,17 @@
def model_match(cls, data): """Match the opened/downloaded image to the correct version""" - + if len(data) == 0x0408: rid = data[0x0400:0x0408] # DEBUG - #print ("Full ident string is %s" % util.hexprint(rid)) + # print ("Full ident string is %s" % util.hexprint(rid)) return rid.startswith(cls.MODEL) else: return False
+ @directory.register - class RadioddityR2Radio(chirp_common.CloneModeRadio): """Radioddity R2""" VENDOR = "Radioddity" @@ -324,8 +319,7 @@ # definitions on how to read StartAddr EndAddr BlockZize _ranges = [ (0x0000, 0x01F8, 0x08), - (0x01F8, 0x0200, 0x08), - (0x0200, 0x0340, 0x10) + (0x01F8, 0x03F0, 0x08) ] _memsize = 0x03F0 # never read more than 8 bytes at once @@ -371,7 +365,7 @@ """Process the mem map into the mem object""" self._memobj = bitwise.parse(MEM_FORMAT, self._mmap) # to set the vars on the class to the correct ones - + def sync_in(self): """Download from radio""" try: @@ -402,7 +396,6 @@ def get_raw_memory(self, number): return repr(self._memobj.memory[number - 1])
- def decode_tone(self, val): """Parse the tone data to decode from mem, it returns: Mode (''|DTCS|Tone), Value (None|###), Polarity (None,N,R)""" @@ -457,7 +450,8 @@ elif txfreq == 0: mem.duplex = "off" mem.offset = 0 - # 166666665*10 is the equivalent for FF FF FF FF storesd in the TX field + # 166666665*10 is the equivalent for FF FF FF FF + # stored in the TX field elif txfreq == 1666666650: mem.duplex = "off" mem.offset = 0 @@ -470,13 +464,13 @@
# get bandwith FM or NFM mem.mode = MODE_LIST[_mem.mode] - + # tone data rxtone = txtone = None txtone = self.decode_tone(_mem.tx_tone) rxtone = self.decode_tone(_mem.rx_tone) chirp_common.split_tone_decode(mem, txtone, rxtone) - + mem.power = POWER_LEVELS[_mem.power]
# add extra channel settings to the OTHER tab of the properties @@ -484,33 +478,28 @@ mem.extra = RadioSettingGroup("extra", "Extra")
scanadd = RadioSetting("scanadd", "Scan Add", - RadioSettingValueBoolean( - not bool(_mem.scanadd))) + RadioSettingValueBoolean(not bool(_mem.scanadd))) scanadd.set_doc("Add channel for scanning") mem.extra.append(scanadd)
bclo = RadioSetting("bclo", "Busy Lockout", - RadioSettingValueBoolean( - not bool(_mem.bclo))) + RadioSettingValueBoolean(not bool(_mem.bclo))) bclo.set_doc("Busy Lockout") mem.extra.append(bclo)
scramb = RadioSetting("scramb", "Scramble", - RadioSettingValueBoolean( - not bool(_mem.scramb))) + RadioSettingValueBoolean(not bool(_mem.scramb))) scramb.set_doc("Scramble Audio Signal") mem.extra.append(scramb)
compand = RadioSetting("compand", "Compander", - RadioSettingValueBoolean( - not bool(_mem.compand))) + RadioSettingValueBoolean(not bool(_mem.compand))) compand.set_doc("Compress Audio for TX") mem.extra.append(compand)
return mem
def set_memory(self, mem): - bitpos = (1 << ((mem.number - 1) % 8)) bytepos = ((mem.number - 1) / 8) LOG.debug("bitpos %s" % bitpos) @@ -543,7 +532,7 @@ _mem.power = POWER_LEVELS.index(mem.power) else: _mem.power = 0 # low - + # tone data ((txmode, txtone, txpol), (rxmode, rxtone, rxpol)) = \ chirp_common.split_tone_encode(mem) @@ -556,8 +545,7 @@ for setting in mem.extra: LOG.debug("@set_mem:", setting.get_name(), setting.value) setattr(_mem, setting.get_name(), not setting.value) - - + def get_settings(self): _settings = self._memobj.settings basic = RadioSettingGroup("basic", "Basic Settings") @@ -575,7 +563,8 @@
rs = RadioSetting("settings.scanmode", "Scan Mode", RadioSettingValueList( - SCANMODE_LIST, SCANMODE_LIST[_settings.scanmode])) + SCANMODE_LIST, + SCANMODE_LIST[_settings.scanmode])) basic.append(rs)
rs = RadioSetting("settings.voice", "Voice Prompts", @@ -602,7 +591,6 @@ RadioSettingValueBoolean(_settings.beep)) basic.append(rs)
- def _filter(name): filtered = "" for char in str(name): @@ -645,7 +633,7 @@ # testing the file data size if len(filedata) in [0x0408, ]: match_size = True - + # testing the model fingerprint match_model = model_match(cls, filedata)
@@ -653,4 +641,3 @@ return True else: return False -
participants (1)
-
Klaus Ruebsam