Skip to content

Commit

Permalink
rt21: Fix DTCS decoding when stored in hex
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kk7ds committed Dec 31, 2024
1 parent 4344962 commit 4311c09
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion chirp/drivers/retevis_rt21.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 4311c09

Please sign in to comment.