From 4311c09bef35c702fbde6aae90c506a7f091b9d1 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Tue, 31 Dec 2024 10:20:02 -0800 Subject: [PATCH] rt21: Fix DTCS decoding when stored in hex Apparently this radio has a bit for whether or not the DTCS code is stored in hex or octal. CHIRP was only supporting octal format, but radios with codes stored in hex were found in the wild and we, of course, fail to decode those. Fixes #11749 --- chirp/drivers/retevis_rt21.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/chirp/drivers/retevis_rt21.py b/chirp/drivers/retevis_rt21.py index b060eea0..abc346e9 100644 --- a/chirp/drivers/retevis_rt21.py +++ b/chirp/drivers/retevis_rt21.py @@ -839,8 +839,16 @@ def get_raw_memory(self, number): return repr(self._memobj.memory[number - 1]) def _get_tone(self, _mem, mem): + # 0xA662 = 662R = 1010 0... + # 0xA9DC = 734R = 1010 1... + # 0x29D3 = 723N - 0010 1... + def _get_dcs(val): - code = int("%03o" % (val & 0x07FF)) + if val & 0x0800: + code = int("%03o" % (val & 0x07FF)) + else: + # 0x0800 means code is stored in hex instead of ocal (?!) + code = int("%03x" % (val & 0x07FF)) pol = (val & 0x8000) and "R" or "N" return code, pol