---------- Forwarded message --------- From: Jim Unroe kc9hi@comcast.net Date: Fri, Jun 11, 2021 at 3:43 PM Subject: [PATCH 1 of 2] [RT22S] Prepare for adding Retevis RT22S To: Rock.Unroe@gmail.com
# HG changeset patch # User Jim Unroe rock.unroe@gmail.com # Date 1623440524 14400 # Fri Jun 11 15:42:04 2021 -0400 # Node ID fdea97ece7528b8162e264d31e762804c03100b8 # Parent 54895dbfcb7db8b5e5ae426ea0f51ce2e7f63a03 [RT22S] Prepare for adding Retevis RT22S
The RT22S requires support that is nearly identical to that of the Radtel T18. This patch makes changes to the T18 driver in order to make it ready to support the addition of the Retevis RT22S.
No features or settings have been modified, added or removed by this patch.
related to #7179
diff -r 54895dbfcb7d -r fdea97ece752 chirp/drivers/radtel_t18.py --- a/chirp/drivers/radtel_t18.py Tue Jun 08 13:22:20 2021 -0400 +++ b/chirp/drivers/radtel_t18.py Fri Jun 11 15:42:04 2021 -0400 @@ -43,7 +43,7 @@ unknown2:1, bcl:1; u8 unknown3[3]; -} memory[16]; +} memory[%d]; #seekto 0x03C0; struct { u8 unknown1:1, @@ -90,7 +90,7 @@ try: serial.write("\x02") time.sleep(0.1) - serial.write("1ROGRAM") + serial.write(radio._magic) ack = serial.read(1) except: raise errors.RadioError("Error communicating with radio") @@ -106,7 +106,7 @@ except: raise errors.RadioError("Error communicating with radio")
- if not ident.startswith("SMP558"): + if not ident.startswith(radio._fingerprint): LOG.debug(util.hexprint(ident)) raise errors.RadioError("Radio returned unknown identification string")
@@ -150,13 +150,13 @@ def _t18_read_block(radio, block_addr, block_size): serial = radio.pipe
- cmd = struct.pack(">cHb", 'R', block_addr, BLOCK_SIZE) + cmd = struct.pack(">cHb", 'R', block_addr, block_size) expectedresponse = "W" + cmd[1:] LOG.debug("Reading block %04x..." % (block_addr))
try: serial.write(cmd) - response = serial.read(4 + BLOCK_SIZE) + response = serial.read(4 + block_size) if response[:4] != expectedresponse: raise Exception("Error reading block %04x." % (block_addr))
@@ -176,7 +176,7 @@ def _t18_write_block(radio, block_addr, block_size): serial = radio.pipe
- cmd = struct.pack(">cHb", 'W', block_addr, BLOCK_SIZE) + cmd = struct.pack(">cHb", 'W', block_addr, block_size) data = radio.get_mmap()[block_addr:block_addr + 8]
LOG.debug("Writing Data:") @@ -253,6 +253,13 @@ MODEL = "T18" BAUD_RATE = 9600
+ _magic = "1ROGRAM" + _fingerprint = "SMP558" + "\x00\x00" + _upper = 16 + _mem_params = (_upper # number of channels + ) + _frs = False + _ranges = [ (0x0000, 0x03F0), ] @@ -280,13 +287,13 @@ rf.has_tuning_step = False rf.has_bank = False rf.has_name = False - rf.memory_bounds = (1, 16) + rf.memory_bounds = (1, self._upper) rf.valid_bands = [(400000000, 470000000)]
return rf
def process_mmap(self): - self._memobj = bitwise.parse(MEM_FORMAT, self._mmap) + self._memobj = bitwise.parse(MEM_FORMAT % self._mem_params, self._mmap)
def sync_in(self): self._mmap = do_download(self) @@ -485,17 +492,22 @@
@classmethod def match_model(cls, filedata, filename): - match_size = False - match_model = False + if cls.MODEL == "T18": + match_size = False + match_model = False
- # testing the file data size - if len(filedata) == cls._memsize: - match_size = True + # testing the file data size + if len(filedata) == cls._memsize: + match_size = True
- # testing the model fingerprint - match_model = model_match(cls, filedata) + # testing the model fingerprint + match_model = model_match(cls, filedata)
- if match_size and match_model: - return True + if match_size and match_model: + return True + else: + return False else: + # Radios that have always been post-metadata, so never do + # old-school detection return False