fix: ground-truth CI-V offset/tone on live ID-5100

- offset amount (0x0D) is REJECTED (NG) by the radio -> removed the offset
  codec + set_offset/get_offset; tune_repeater now sets only duplex direction
  (radio applies its configured auto-offset)
- repeater tone (0x1B/00) uses a 3-byte field (00 + 2-byte BCD); set_tone
  prepends the pad, get_tone strips it
- duplex (0x0F) and tone-switch (0x16/42) verified working
- added get_duplex; verified full tune_repeater on a live repeater (all steps OK)
This commit is contained in:
2026-06-14 16:22:19 -04:00
parent 66b368fb87
commit 69710e362a
3 changed files with 29 additions and 55 deletions
+12 -26
View File
@@ -24,15 +24,17 @@ SUB_SQL_LEVEL = 0x03
SUB_SQL_STATUS = 0x01
SUB_SMETER = 0x02
# --- repeater config (candidate commands; verify on live radio) ---
CMD_OFFSET = 0x0D # set duplex offset frequency
CMD_DUPLEX = 0x0F # set duplex direction
# --- repeater config (verified on live ID-5100 2026-06-14) ---
# NOTE: offset-amount cmd 0x0D is REJECTED (NG) by the ID-5100 — the offset
# amount is not CI-V-settable; the radio applies its configured auto-offset
# (default 0.6 MHz / 5 MHz) when a duplex direction is selected via 0x0F.
CMD_DUPLEX = 0x0F # set/read duplex direction (verified: read -> 0x10 simplex)
DUP_SIMPLEX = 0x10
DUP_MINUS = 0x11
DUP_PLUS = 0x12
CMD_TONE_PARAM = 0x1B # sub 0x00 = repeater (TX) tone frequency
CMD_TONE_PARAM = 0x1B # sub 0x00 = repeater (TX) tone freq (verified)
SUB_RPT_TONE = 0x00
CMD_TONE_SWITCH = 0x16 # sub 0x42 = tone encode on/off
CMD_TONE_SWITCH = 0x16 # sub 0x42 = tone encode on/off (verified)
SUB_TONE_ENC = 0x42
Frame = namedtuple("Frame", "to frm cn data")
@@ -77,28 +79,12 @@ def bcd_to_level(data):
return value
def offset_to_bcd(hz):
"""Duplex offset Hz -> 3-byte little-endian BCD in 100 Hz units (PROVISIONAL)."""
if hz < 0:
raise ValueError(f"offset {hz} must be >= 0")
units = round(hz / 100)
digits = f"{units:06d}"
out = bytearray()
for i in range(0, 6, 2):
out.append((int(digits[4 - i]) << 4) | int(digits[5 - i]))
return bytes(out)
def bcd_to_offset(data):
"""3-byte little-endian BCD (100 Hz units) -> Hz (PROVISIONAL)."""
units = 0
for i, byte in enumerate(data[:3]):
units += (byte & 0x0F) * (10 ** (2 * i)) + (byte >> 4) * (10 ** (2 * i + 1))
return units * 100
def tone_to_bcd(hz):
"""CTCSS tone Hz -> 2-byte BCD of tone*10 (88.5 -> 08 85)."""
"""CTCSS tone Hz -> 2-byte BCD of tone*10 (88.5 -> 08 85).
The ID-5100 wire format for cmd 0x1B/0x00 prepends a 0x00 pad byte before
these two (so 88.5 Hz reads/writes as `00 08 85`); radio.py adds/strips it.
"""
digits = f"{round(hz * 10):04d}"
return bytes([(int(digits[0]) << 4) | int(digits[1]),
(int(digits[2]) << 4) | int(digits[3])])