[chirp_devel] [PATCH] [rt22] patch radio ID for RT-622
Dmitry Baryshkov
Sun Oct 18 19:43:35 PDT 2020
# HG changeset patch
# User Dmitry Baryshkov <dbaryshkov at gmail.com>
# Date 1603075401 -10800
# Mon Oct 19 05:43:21 2020 +0300
# Node ID 1552c486144d10aff7a63ff6d0a14b38c2c52544
# Parent de5d23f4a4235f42a3dee54e2054def2ac224572
[rt22] patch radio ID for RT-622
For RT-622 to update memory correctly, radio ID has to be written at the
address 0x1b8. When reading this address reads as 0. So, patch the data during
write operation to stop Chirp from overwriting radio ID on these radios.
I don't know if this operation has to be performed for other radio IDs as well,
so this patching is limited to RT-622.
diff --git a/chirp/drivers/retevis_rt22.py b/chirp/drivers/retevis_rt22.py
--- a/chirp/drivers/retevis_rt22.py
+++ b/chirp/drivers/retevis_rt22.py
@@ -205,7 +205,15 @@
serial = radio.pipe
cmd = struct.pack(">cHb", 'W', block_addr, block_size)
- data = radio.get_mmap()[block_addr:block_addr + block_size]
+ mmap = radio.get_mmap()
+ data = mmap[block_addr:block_addr + block_size]
+
+ # For some radios (RT-622) memory at 0x1b8 reads as 0, but radio ID should
+ # be written instead
+ if block_addr == radio._patch_addr:
+ for fp in radio._patch_id:
+ if fp in mmap[0:radio._patch_len]:
+ data = mmap[0:radio._patch_len] + data[radio._patch_len:]
LOG.debug("Writing Data:")
LOG.debug(util.hexprint(cmd + data))
@@ -298,6 +306,9 @@
_memsize = 0x0400
_block_size = 0x40
_fileid = ["P32073", "P3" + "\x00\x00\x00" + "3", "P3207!"]
+ _patch_id = ["P3207!"]
+ _patch_len = 8
+ _patch_addr = 0x1b8
def get_features(self):
rf = chirp_common.RadioFeatures()
More information about the chirp_devel
mailing list