[chirp_devel] [PATCH] Added support for Radioddity R2 #6063

Klaus Ruebsam
Tue Aug 28 23:55:59 PDT 2018


# HG changeset patch
# User Klaus Ruebsam <dg5eau at ruebsam.eu>
# Date 1535524994 -7200
#      Wed Aug 29 08:43:14 2018 +0200
# Node ID 4a521109cd4b190107ce73e1f68413d5c4c7e1fe
# Parent  26da631376cd1b9c349e26a5ffe6b787712df1ad
Added support for Radioddity R2 #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
@@ -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 = {
@@ -194,6 +193,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 +304,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 +324,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 +370,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 +401,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 +455,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 +469,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 +483,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 +537,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 +550,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 +568,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 +596,6 @@
                           RadioSettingValueBoolean(_settings.beep))
         basic.append(rs)
 
-
         def _filter(name):
             filtered = ""
             for char in str(name):
@@ -645,7 +638,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 +646,3 @@
             return True
         else:
             return False
-



More information about the chirp_devel mailing list