diff --git a/README.md b/README.md
index f579045..155d6ee 100644
--- a/README.md
+++ b/README.md
@@ -55,6 +55,11 @@ including programming several different radios from the same codeplug.
| **Baofeng UV-28Plus** | Experimental (CHIRP-based) | Analog FM/NFM/AM | 136–174 / 220–260 / 400–480 MHz TX, 108–174 / 220–260 / 350–390 / 400–520 MHz RX | Programming cable — read, write, settings | 1000 channels, High / Medium / Low power; 105 settings — the UV-17Pro GPS's plus Bluetooth |
| **Baofeng UV-32** | Experimental (CHIRP-based) | Analog FM/NFM/AM | 136–174 / 200–260 / 400–520 MHz TX, 108–174 / 200–260 / 350–390 / 400–520 MHz RX | Programming cable — read, write, settings | 1000 channels, High / Medium / Low power; the UV-17Pro GPS's 104 settings |
| **TIDRADIO TD-H3** | ✓ | Analog FM/NFM/AM | VHF / UHF / 1.25 m | Direct USB — read, write, settings | 200 channels, tri-band |
+| **TIDRADIO TD-H8** | Experimental (CHIRP-based) | Analog FM/NFM | 136–175 / 400–521 MHz | Programming cable — read, write, settings | 1st / 2nd generation, unrestricted. 199 channels with 8-character names, Low / Mid / High power; 57 settings, including the VFO power and bandwidth, the four programmable key presses and the DTMF group and PTT-ID codes. The FM radio's work-mode and receive labels follow TIDRADIO's and Radtel's programmers, which both contradict CHIRP's; that is not measured on this model. The TD-H3's clone protocol with the TD-H8's own magic and memory map, ported from CHIRP's `tdh8.py` |
+| **TIDRADIO TD-H8 HAM** | Experimental (CHIRP-based) | Analog FM/NFM | 144–149 / 420–451 MHz TX, 136–174 / 400–521 MHz RX | Programming cable — read, write, settings | The HAM-locked 1st / 2nd generation (it identifies differently, and the app refuses the other model's radio). The TD-H8's 57 settings plus time-out timer and language, 59 in all, checked against TIDRADIO's own programmer for this model, which also corrected CHIRP's FM-radio work mode and receive labels and its power-on display label, and added a 50 kHz VFO A step. Channels outside the TX bands are programmed receive-only |
+| **TIDRADIO TD-H8 3rd Gen** | Experimental (CHIRP-based) | Analog FM/NFM/AM | 136–600 MHz TX, 18–600 MHz RX | Programming cable — read, write, settings | The third generation, on the TD-H3's memory layout. 199 channels, Low / Mid / High (2 / 6 / 10 W); the TD-H8's 57 settings, as CHIRP offers them for this model, with the TD-H8's FM-radio labels (not measured on this model). Air-band channels are programmed AM and receive-only |
+| **TIDRADIO TD-H8 3rd Gen HAM** | Experimental (CHIRP-based) | Analog FM/NFM/AM | 144–149 / 420–451 MHz TX, 18–136 / 144–420 / 420–600 MHz RX | Programming cable — read, write, settings | The HAM-locked third generation; as the 3rd Gen otherwise. CHIRP gives this model no receive coverage at 136–144 MHz, so channels there are left out |
+| **Radtel RT-730** | Experimental (CHIRP-based) | Analog FM/NFM/AM | 136–630 MHz TX, 10–630 MHz RX | Programming cable — read, write, settings | 199 channels, Low / Mid / High power; 30 settings, including four power-on message lines and the PF-key presses. Checked against Radtel's own programmer, which corrected three of CHIRP's FM-radio labels and added Priority TX. The TD-H8's protocol with a memory layout of its own. Bands as CHIRP gives them; retailers also sell a build that transmits only on 144–148 / 420–450 MHz, which the radio itself enforces |
| **AnyTone AT-D890UV** | ✓ | DMR + Analog | VHF / UHF | Direct USB — channels, zones, scan lists, settings, call-sign DB | 4000 channels; full DMR: zones, talkgroups, 308k-entry caller-ID database |
| **AnyTone AT-D578UV** | ✓ | DMR + Analog mobile | 2 m / 1.25 m / 70 cm | Direct USB — channels, zones, scan lists, talkgroups, settings, call-sign DB | 4000 channels in 250 zones; 264 menu settings including the FM and DMR APRS setup; 500k-entry caller-ID database. AM channels in 108–136 MHz go to the air-band memory, which only the D578UV **PLUS** receives — that part is written to the published map but has not been checked on a PLUS. Same protocol as the D890UV over a different memory map |
| **AnyTone AT-D868UV** | ✓ | DMR + Analog handheld | VHF / UHF | Direct USB — channels, zones, scan lists, talkgroups, settings, call-sign DB | 4000 channels in 250 zones; 156 settings including the DMR APRS position setup and the 5-Tone, 2-Tone, DTMF and alarm setup; 200k-entry caller-ID database. The D578UV's memory map (the D868UV is the base of that family), so the same programmer writes both. Hardware V1.1 / firmware 2.x radios (`V102`); the older V1.0 / firmware 1.xx units have no published map and are refused |
@@ -86,11 +91,12 @@ the app's; the differences are listed in the family's notes. Save a backup from
If you own one, an issue saying what works and what doesn't is what moves it to ✓. See
[docs/radios/baofeng-uv5r-family.md](docs/radios/baofeng-uv5r-family.md) and
[docs/radios/baofeng-uv17pro-family.md](docs/radios/baofeng-uv17pro-family.md) for the Baofeng
-families' evidence.
+families' evidence, and [docs/radios/tidradio-tdh8-family.md](docs/radios/tidradio-tdh8-family.md)
+for the TIDRADIO TD-H8 family and the Radtel RT-730.
Direct USB and cable programming reads the radio's current image, applies your changes, backs up
the original, writes, and can verify the result byte-for-byte. On the Baofeng UV-5R and UV-17Pro
-families a backup can also be put back whole, and that includes a `.img` saved by CHIRP, which is accepted only for
+families and the TD-H8 family a backup can also be put back whole, and that includes a `.img` saved by CHIRP, which is accepted only for
the model CHIRP's own metadata in the file names. The Kenwood TM-D710 and the Yaesu
FT-891 have no image to clone: they are programmed live, one memory at a time, and each memory is
read back after it is written. The ID-5100 clones its whole
@@ -145,7 +151,8 @@ bench. If you own one of these and want to help measure or test it, say so on it
models the UV-82, UV-82HP, UV-82X3, BF-F8HP, UV-6, GT-5R, UV-5G, BF-A58, BF-A58S, UV-82WP,
GT-3WP, UV-S9X3, 5RX, UV-9R, UV-9G, UV-17Pro, UV-21Pro V2, UV-25, UV-17R Plus, 5RM,
K5-Plus, UV-5RH, UV-5RM Plus, UV-17Pro GPS, UV-21Pro GPS, UV-28Plus and UV-32, the Retevis RT6
- and the MaxTalker P15 and MT-5RM; TIDRADIO TD-H3,
+ and the MaxTalker P15 and MT-5RM; TIDRADIO TD-H3, and as Experimental models the TD-H8, TD-H8 HAM,
+ TD-H8 3rd Gen and 3rd Gen HAM and the Radtel RT-730;
AnyTone D890UV, D578UV and D868UV, Binteradio BT-9000, Icom ID-5100, Kenwood TH-D72 and TM-D710,
Quansheng UV-K5 (stock and egzumer), TYT MD-380, Yaesu FT-857D / FT-897 and FT-891) with backup, write, and
read-back verify.
diff --git a/docs/manual/Codeplug-Magic-Guide.pdf b/docs/manual/Codeplug-Magic-Guide.pdf
index d5ab54e..1553992 100644
Binary files a/docs/manual/Codeplug-Magic-Guide.pdf and b/docs/manual/Codeplug-Magic-Guide.pdf differ
diff --git a/docs/manual/manual.html b/docs/manual/manual.html
index ab9181f..cfcfe9c 100644
--- a/docs/manual/manual.html
+++ b/docs/manual/manual.html
@@ -386,19 +386,34 @@
How each radio is programmed
TIDRADIO TD-H3 Analog USB programming cable 200 memories. Its Program dialog adds a Radio Options tab.
AnyTone AT-D890UV DMR + analog USB Channels, zones, scan lists, talkgroups, settings, call-sign database.
AnyTone AT-D578UV DMR + analog USB 4000 channels in 250 zones; settings incl. APRS; call-sign database.
+ AnyTone AT-D868UV DMR + analog USB 4000 channels in 250 zones; settings incl. DMR APRS; call-sign database.
TYT MD-380 DMR + analog USB (the radio itself) Zones of 16, talkgroup contacts, scan lists.
Binteradio BT-9000 Analog USB programming cable 960 memories in 15 fixed zones. Also sold as Radtel RT-950 Pro.
Kenwood TH-D72 APRS + analog USB 1000 memories; menu settings.
+ Quansheng UV-K5 Analog USB programming cable 200 memories; menu settings. Stock firmware, or egzumer's as a model of its own.
+ Yaesu FT-857D / FT-897 Analog incl. SSB, CW Data cable, CAT/LINEAR jack 200 memories incl. SSB, CW and AM; menu settings.
+ Yaesu FT-891 Analog incl. SSB, CW USB 99 memories with 12-character tags; menu settings.
Kenwood TM-D710 APRS + analog Serial, operation-panel port Programmed one memory at a time; settings incl. APRS.
Icom ID-5100 D-STAR + analog Data cable 1000 memories in named banks A–Z; settings in the same upload.
Yaesu FT5D Fusion + analog microSD: BACKUP.dat 900 memories in 24 banks; settings.
Yaesu FTM-300DR Fusion + analog microSD: CLNFTM300D.dat 999 memories, no banks; one M-GRP memory group; settings incl. APRS.
+ Yaesu FTM-400DR / XDR Fusion + analog microSD 500 memories on each band, the codeplug written to both; settings incl. APRS.
+ Yaesu FTM-510DR Fusion + analog microSD 999 memories; settings incl. APRS.
+ Icom ID-51 Plus D-STAR + analog microSD: .icf 500 memories in 26 named banks; settings.
Icom ID-52 D-STAR + analog microSD: .icf 1000 memories in 100 groups; settings.
Kenwood TH-D75 D-STAR + APRS + analog microSD: .d75 1000 memories in 30 groups; settings incl. APRS.
+ Baofeng UV-5R family Experimental Analog USB programming cable UV-82, UV-82HP, UV-82X3, BF-F8HP, UV-6, GT-5R, UV-5G, BF-A58, BF-A58S, UV-82WP, GT-3WP, Retevis RT6, UV-S9X3, 5RX, UV-9R, UV-9G. 128 memories; settings.
+ Baofeng UV-17Pro family Experimental Analog USB programming cable UV-17Pro, UV-21Pro V2, UV-25, UV-17R Plus, 5RM, MaxTalker P15 and MT-5RM, K5-Plus, UV-5RH, UV-5RM Plus, UV-17Pro GPS, UV-21Pro GPS, UV-28Plus, UV-32. 1000 memories; settings.
+ TIDRADIO TD-H8 family Experimental Analog USB programming cable TD-H8, TD-H8 HAM, TD-H8 3rd Gen, 3rd Gen HAM, and the Radtel RT-730. 199 memories; settings.
Anything else — Export a CHIRP CSV Program it with CHIRP.
+
+ Experimental radios
+ A radio marked Experimental is supported from published research and CHIRP's driver, checked against the maker's own programming software where it could be had, but has not yet been tested on a real radio here. The app labels these models and warns before every write. Every write still saves a backup of the radio first and reads the radio back to confirm. If you program one, please report how it went.
+
+
Cable radios
Choose the serial port and click Program radio . Every cable write saves a backup of the radio first. Where the radio offers them, Identify , Download backup and Restore backup… sit beside it. AnyTone radios reboot after a write; rescan the port and run Verify .
diff --git a/docs/radios/tidradio-tdh8-family.md b/docs/radios/tidradio-tdh8-family.md
new file mode 100644
index 0000000..e506c1f
--- /dev/null
+++ b/docs/radios/tidradio-tdh8-family.md
@@ -0,0 +1,393 @@
+# TIDRADIO TD-H8 family — the Experimental models (#168)
+
+Five radios on one driver (`src-tauri/src/radios/tidradio_tdh8`), which speaks
+the hardware-verified **TD-H3**'s clone protocol. Each has a model folder of its
+own. **All five are Experimental**: they are ported from CHIRP's
+`chirp/drivers/tdh8.py` (b63b38d1, 2026-11-29; GPLv2-or-later), and nobody here
+owns one. Nothing about any of them has been confirmed on hardware. The app
+labels them and warns before every write.
+
+| Model | `driver_key` | CHIRP class / MODEL | Magic | Ident | Layout | Power | Bands (MHz) | AM | Settings |
+|---|---|---|---|---|---|---|---|---|---|
+| TIDRADIO TD-H8 | `tidradio_tdh8` | `TDH8` / `TD-H8` | `PVOJH\x1c\x14` | `P31183` | H8 | Low / Med / High | 136–175, 400–521 | no | 57 |
+| TIDRADIO TD-H8 HAM | `tidradio_tdh8ham` | `TDH8_HAM` / `TD-H8-HAM` | `PVOJH\x1c\x14` | `P31185` | H8 | Low / Med / High | TX 144–149, 420–451; RX 136–174, 400–521 | no | 59 |
+| TIDRADIO TD-H8 3rd Gen | `tidradio_tdh8g3` | `TDH8_3rd_Gen` / `TD-H8` | `PVOJH\x3c\x14` | `P31183` | H3 | Low / Med / High | TX 136–600; RX 18–600 | yes | 57 |
+| TIDRADIO TD-H8 3rd Gen HAM | `tidradio_tdh8g3ham` | `TDH8_3rd_Gen_HAM` / `TD-H8-HAM` | `PVOJH\x3c\x14` | `P31185` | H3 | Low / Med / High | TX 144–149, 420–451; RX 18–136, 144–149, 149.99–419.99, 420–600 | yes | 57 |
+| Radtel RT-730 | `radtel_rt730` | `RT730` / `RT-730` | `PGOJH\xc3D` | `P31183` | RT730 | Low / Med / High | TX 136–630; RX 10–630 | yes | 30 |
+
+Bands are CHIRP's `valid_bands` with the transmit limits CHIRP's own
+`get_tx_bands` applies; they are not the manufacturers' spec sheets. A channel
+outside the TX bands is programmed receive-only, as CHIRP does. **The RT-730's
+retailers advertise TX 144–148 and 420–450 only**; CHIRP lets it transmit from
+136 to 630, and the seed follows CHIRP (Tim, 2026-12-04: keep CHIRP's bands). Its
+manual prints no band table.
+
+**Not added:**
+
+- **TD-UV68.** Deferred. CHIRP's `get_settings` crashes on this model: its
+ MODEL is in neither `H8_LIST` nor `H3_LIST`, so it falls into a branch that
+ reads `mic`, a field its `MEM_FORMAT` does not have. Its settings path has
+ never run upstream, so there is nothing to port it against.
+- **The GMRS units** (ident `P31184`: TD-H8-GMRS and the 3rd-gen GMRS) are
+ skipped. GMRS channel rules are not something this app models. A GMRS radio
+ is refused at the ident with a message saying so.
+
+## Protocol
+
+The protocol is the TD-H3's (`tidradio_tdh3`, hardware-verified): 38400 8N1.
+The model's 7-byte magic is answered `06`; `02` returns the 8-byte ident; `06`
+is answered `06`. Reads are `R hi lo 20`. Writes are `W hi lo 20 <32 bytes>
+`, each answered `06`, and `E` ends a write. The TD-H3's functions are
+reused with the magic and the range as parameters (`do_ident_with`,
+`download_to`, `upload_to`, `reident_with`); the TD-H3 itself still calls them
+with its own constants, so its behaviour is unchanged.
+
+The ident decides which model a radio is:
+
+- `P31183` is unrestricted.
+- `P31185` is HAM-locked.
+- `P31184` is GMRS.
+
+A HAM radio on a non-HAM model, or the other way round, is refused before any
+read, with a hint toward the right model. The magic separates the generations
+and the RT-730. All eight bytes are compared, as CHIRP's upload compares its whole
+`ident_mode` (the model code, then `FF FF`). A radio whose model code matches
+but whose last two bytes differ is refused too, so an unknown firmware is not
+written to.
+
+### Image
+
+Image offsets include the 8-byte ident.
+
+| Layout | Models | Image | Name stride | Used / scan bitmaps |
+|---|---|---|---|---|
+| H8 | TD-H8, TD-H8 HAM | 0x1F08 | 16 | 0x1A08 / 0x1A28 |
+| H3 | TD-H8 3rd Gen (+ HAM): **the TD-H3's own layout** | 0x2008 | 8 | 0x1908 / 0x1928 |
+| RT730 | RT-730 | 0x6408 | 8 | 0x1A08 / 0x1A28 |
+
+Channels 1–199 are 16-byte records at 0x0008 + 16·N, with names at 0x0D48 (8
+characters). The record is the TD-H3's: LBCD RX and TX, tone words, and
+byte 14 holding power in bits 5–4 and narrow in bit 3. AM is not a stored mode:
+CHIRP decodes 108–136 MHz as AM, and so do we.
+
+**Empty slots follow CHIRP.** CHIRP fills the record with `FF` and clears the
+used bit, but leaves the name and scan bit as they were. A filled slot is
+zeroed, named (`00`-padded), and gets its used and scan bits set. The per-channel
+PTT-ID (record bits CHIRP exposes as a memory extra) is not a field of the
+app's channel, so it is written 0, as CHIRP writes a fresh memory.
+
+### Writing
+
+The write covers the whole range, as CHIRP writes it and as the TD-H3 has been
+proven to accept it. It is skipped when nothing differs from the backup taken
+before it. Every write first reads a backup, checks the ident against the
+model, and afterwards reads the radio back and compares every byte after the
+ident. Settings travel in the same image (`carries_profile_settings`).
+
+### Restore
+
+A restore file must:
+
+- carry CHIRP's trailer magic at the image length, with its metadata model in
+ the variant's `chirp_models`
+- be exactly that length
+- start with the model's ident
+
+The file-name gate refuses a backup made under any other family prefix. The
+prefixes listed are both the short `file_prefix` and the `driver_key`, because
+the generic Download names files by driver key. The TD-H3 is in the list too:
+its image is the same length as a 3rd Gen's, and a TD-H3 backup was the leak
+this closed.
+
+## Settings (generated)
+
+`scripts/tidradio_tdh8_family/gen_settings.py` **measures** CHIRP's
+`set_settings` instead of reading its source. For each setting and each option,
+it sets the value on two images: one with the bytes under the setting forced to
+`00`, one forced to `FF`. The bits whose result does not depend on the fill are
+the setting's mask, and the result is its value. Three kinds come out:
+
+- **Choice**: a mask and one value per option.
+- **DTMF**: digits `0-9 A-D`, padded `FF`.
+- **Text**: padded with spaces.
+
+From that it emits `settings_table.rs` and the form schemas in
+`src-tauri/src/tdh8_family/`.
+
+| Schema | Models | Fields |
+|---|---|---|
+| `tidradio_tdh8.json` | TD-H8, TD-H8 3rd Gen, TD-H8 3rd Gen HAM | 57 (two tables: H8 and H3 offsets); CHIRP's, with the FM radio labels both vendor programmers gave (see below) |
+| `tidradio_tdh8ham.json` | TD-H8 HAM | 59 (CHIRP's 57, corrected and extended by TIDRADIO's programmer; see below) |
+| `radtel_rt730.json` | RT-730 | 30 (CHIRP's 29, corrected and extended by Radtel's programmer; see below) |
+
+The 3rd Gen gets the H8's menu set on the H3's layout, because CHIRP's class has
+MODEL `TD-H8` and so takes the `H8_LIST` branch. Its H3-offset table is checked
+in a test against the hardware-verified TD-H3 settings encoder, field by field
+where the two share a key.
+
+**Withheld**, and their bytes left as the radio has them:
+
+- The VFO frequencies `rxfreqa` and `rxfreqb`, and `a`, `b`, `dira` and `dirb`
+ (CHIRP sets these through callbacks, not values).
+- `fmvfo`.
+- The 25 FM presets (`block00`–`block24`).
+
+CHIRP quirks the table reproduces:
+
+- `sync` is stored inverted.
+- The group code maps blank to `00`, Off to `FF`, `*` to `0E`, `#` to `0F`, and
+ A–D to `0A`–`0D`.
+
+A blank text field, or an option the table does not know, leaves the radio's
+bytes alone. This departs from CHIRP, which would write the blank. A DTMF code
+with a gap in it decodes as blank.
+
+### Menu census (2026-12-04)
+
+The manual notes are in `scratchpad/tidradio_tdh8/manuals/`, gitignored.
+
+**TD-H8: 42 menus (0–41)** in TIDRADIO's *TD-H8 User Manual (Ham) ver 2.0*.
+That manual fits the 2nd-gen HAM unit; no 1st-gen manual was found. Against the
+57-field schema:
+
+- **21 are reached.**
+ - squelch (0), step (1), VFO power (2), power save (3), VOX (4),
+ bandwidth (5), backlight (6), dual watch (7), beep (8), voice (14)
+ - TX-SEL (15), scan mode (17), both display modes (19, 20), VFO BCL (21),
+ auto lock (22), roger (31), sync (36), DTMF side tone (38)
+ - likely, not confirmed: FM-DW (18) is the FM radio's receive switch, and
+ ANI-ID (39) is CHIRP's ID Code
+- **5 are actions**: store (25), delete (26), the two tone seeks (28, 29) and
+ reset (35).
+- **6 belong to a channel**: the four tone menus (10–13), scan add (16) and
+ PTT-ID (37).
+- **2 are VFO shift**: direction (23) and offset (24), both withheld above.
+- **8 are not reached**: TOT (9), alarm mode (27), TAIL (30), R-TONE (32),
+ language (33), hopping (34), RP-STE (40) and RPT-RL (41).
+ - CHIRP's `MEM_FORMAT` names `tot`, `lang`, `alarm` and `tailclean` bytes in
+ the H8 layout, but its `get_settings` offers them only for the TD-H3. That
+ is not evidence that they mean the same thing on the H8. **Not inferred.**
+ - **The TD-H8 HAM reaches TOT (9) and language (33)** as well, from
+ TIDRADIO's own programmer (below): 23 of 42 on that model. The plain TD-H8
+ and the 3rd Gen stay at 21.
+
+The other 36 schema fields are things the menus do not list:
+
+- the side and top keys
+- the power-on message and display
+- the LCD-on-TX/RX and breathing LEDs
+- channel-only mode
+- the VFOs' work modes and special QT
+- the FM radio
+- the DTMF codes
+
+**The manual and CHIRP disagree** on several option lists. In each case the app
+follows CHIRP, because the manual is a 2nd-gen one and CHIRP's image may come
+from other firmware:
+
+| Menu | Manual | CHIRP |
+|---|---|---|
+| VOX | Off, 1–9 (§7.3 says 1–5) | Off, 1–5 |
+| Step | also 20 and 50 kHz | 6 steps, without them |
+| Backlight | always on, or 1–10 s | CONT / 5 / 10 / 15 / 30 s |
+| Power save | Off, 1–4 | Off, 1:1 / 1:2 / 1:3 / 1:4 / 1:8 |
+
+**TD-H8 3rd Gen: no manual found.**
+
+**RT-730: 37 menus (1–37)** in Radtel's multi-language manual. Against the
+30-field schema:
+
+- **23 are reached.**
+ - roger (1), backlight (2), power save (3), squelch (5), beep (6), TDR (9),
+ language (14), TOT (15), scan mode (17), STE (18), voice (19)
+ - channel name display (22), RX and TX LCD (24, 25), auto lock (26),
+ VOX gain and delay (27, 28), TX-SEL (30, Priority TX: from Radtel's
+ programmer), FM-RX (31), the four PF key menus (34–37)
+- **3 are actions**: name edit (23), store (32) and delete (33).
+- **5 belong to a channel**: power (4), bandwidth (7), the two tone menus (10,
+ 11) and BCL (16).
+- **6 are not reached**: step (8), scrambler (12), offset and shift (20, 21),
+ warn type (29), and DQT Hop (13). Radtel's programmer has none of the
+ first five in its settings dialog either.
+ - DQT Hop may be CHIRP's "Hop Type" (A–D), but the manual prints On / Off.
+ It is not claimed.
+
+The other 7 schema fields are the four power-on message lines and the FM
+radio's work mode, channel and receive.
+
+Disagreements with the manual:
+
+- **VOX delay**: the manual prints 0.5 / 1 / 1.5 / 2 s, and CHIRP has
+ 0.5 / 1.0 / 2.0 / 3.0 s.
+- **PF keys**: CHIRP adds a "Copy CH" option that the manual does not list.
+
+The app follows CHIRP in both cases, and Radtel's own programmer offers
+exactly CHIRP's lists for both.
+
+## Radtel's programmer (2026-12-04)
+
+Radtel's software page (radtels.com/pages/software-download) links
+"Radtel RT-730 10w Radio pc programming software": `RT-730_setup231113.exe`,
+an MFC program, run in the Windows VM. Nothing here touched a radio.
+
+**Agrees with us:**
+
+- **The start-up string.** The program carries `PGOJH\xc3D`, the magic CHIRP
+ uses for the RT-730.
+- **The memory map.** Its files are the radio's memory without the 8-byte
+ ident, saved as `*.txt`, 28 800 bytes. The factory file in Radtel's download
+ (`730 default factory freq.txt`) holds the same 199 channel records as
+ CHIRP's `Radtel_RT-730.img`, byte for byte.
+- **Channels.** Our channel matrix, opened in the programmer, reads row by
+ row as written:
+ - frequencies, splits and the 29.6 MHz receive-only row
+ - CTCSS, and DCS with both polarities
+ - both cross-tone directions
+ - all three power levels, narrow, and 8-character names
+
+ Saving it back changes one byte: the scan bit of an empty slot, which we
+ keep and the programmer clears. (The grid first drew our Mid channel as
+ High; its editor, its redraw and its saved byte all say Mid.)
+- **Settings.** Our settings image re-saves with 0 bytes changed. Every field
+ in its Optional Features dialog shows the value we wrote, and its option
+ lists are CHIRP's, including the two the manual disagrees with.
+
+**Disagrees with CHIRP, and the app follows Radtel.** Each of these was
+measured by changing one control in the programmer and diffing its save:
+
+| Setting | Bits | Radtel | CHIRP |
+|---|---|---|---|
+| FM radio work mode | 0x0CAA bit 7 | 0 = CH, 1 = VFO | the reverse |
+| FM radio receive | 0x0CAA bit 3 | 1 = **Forbid** receive | 1 = "Allow Receive" |
+| FM radio channel | 0x0CAE | 1–25, stored 0–24 | "0"–"25", one past the last preset |
+| Priority TX (menu 30, TX-SEL) | 0x0CA8 bit 0 | Edit 0 / Busy 1 | marked unused |
+
+The bytes for the three FM settings are unchanged; only the labels differ.
+`scripts/tidradio_tdh8_family/vendor.py` corrects CHIRP's `RT730` class.
+`gen_settings.py` measures the corrected class and `chirp_oracle.py` compares
+against it, so the schema and the oracle still agree byte for byte.
+
+The TD-H8 models use the same CHIRP code for their FM settings. A Radtel
+finding is not evidence about TIDRADIO's firmware, so they were not changed on
+its strength alone. The TD-H8 HAM was then measured in TIDRADIO's own
+programmer (next section), which found the same two FM label errors.
+
+Radtel's `config.ini` ships a 136–174 / 400–480 MHz band setting. Opening an
+image switches the program to the band setting stored in that image (CHIRP's
+RT-730 image shows 10–300 / 300–630 MHz). The app's bands follow CHIRP's
+(Tim, 2026-12-04).
+
+## TIDRADIO's programmer (2026-12-04)
+
+TIDRADIO's site sends its TD-H8 programmers only by email. A UK dealer
+(M7SPI) publishes the 2nd-generation TD-H8 HAM one:
+`TIDRADIO_H8HAM_setup230912.zip` (sha256 `e363af7c…`), holding
+`TIDRADIO_H8(HAM)_setup230912.exe`. It is an MFC program from the same
+codebase as Radtel's, run in the Windows VM. Nothing here touched a radio. It
+covers **the TD-H8 HAM only**: the plain TD-H8 and both 3rd Gen models have
+not been checked against TIDRADIO's software.
+
+**Agrees with us:**
+
+- **The start-up string** `PVOJH\x1c\x14`, CHIRP's for the TD-H8 HAM. Its
+ `config.ini` and status bar say 144M–148M / 420M–450M.
+- **The memory map.** Files are the radio's memory without the 8-byte ident,
+ saved as `*.txt`, 7 600 bytes (CHIRP's image up to 0x1DB8). The DTMF codes
+ (0x1E28 onward) are outside it, so the programmer's DTMF dialog cannot be
+ checked against a file. Its default file's channel records equal CHIRP's
+ `TIDRADIO_TD-H8-HAM.img`.
+- **Channels.** All 13 matrix rows read as written, Mid power included. Names
+ are 8 characters at most. On saving, the programmer clears the scan bit of
+ empty slots, and writes `00` at the ninth name byte where we keep CHIRP's
+ `FF` (the grid draws our `FF` as a trailing dot). Neither is changed.
+- **Settings.** Our settings image re-saves with 0 bytes changed. The A/B
+ Channel dialog (both VFOs' power, bandwidth, busy lock, special QT, work
+ mode) shows the values we wrote. Our image as the oracle writes it, opened
+ in the programmer, shows every changed field below as set. Priority TX
+ (0x0CA8 bit 0) measures as on the RT-730, Edit 0 / Busy 1, and CHIRP already
+ had it right here.
+
+**Disagrees with CHIRP, and the app follows TIDRADIO** (TD-H8 HAM only). Each
+was measured by changing one control and diffing the save:
+
+| Setting | Bits | TIDRADIO | CHIRP |
+|---|---|---|---|
+| FM radio work mode | 0x0CAA bit 7 | 0 = CH, 1 = VFO | the reverse |
+| FM radio receive | 0x0CAA bit 3 | 1 = **Forbid** receive | 1 = "Allow Receive" |
+| Power-On Display | 0x0CAB bits 7–6 | 0 = **Full** | 0 = "Off" |
+| Power save | 0x0CB4 | Off, 1:1 … 1:4 (1:4 = 4 measured), as the manual | adds 1:8 |
+| VFO A step | 0x0CB0 bits 7–4 | adds 50.00K, stored 6 (12.50K = 4 also measured) | stops at 25.0 |
+| Time-Out Timer (menu 9) | 0x0CB2 | OFF, 30S … 210S, stored 0–7 (OFF, 30S, 210S measured) | not offered on the TD-H8 |
+| Language (menu 33) | 0x0CB3 **bit 1** | Chinese / English | not offered on the TD-H8 |
+
+Language is one bit. The programmer showed a byte of `01` as Chinese and `03` as
+English, and switching writes only bit 1. CHIRP's TD-H3 code treats the same
+byte as an index (English = 1). It would read the TD-H8 HAM's English as
+Chinese, so the H3 meaning was not borrowed.
+
+The FM channel is **not** the RT-730's case: TIDRADIO stores channels 1–25 as
+1–25, which is what CHIRP's labels say.
+
+**Kept as CHIRP has them, where TIDRADIO offers less:**
+
+- the FM channel's "0"
+- Monitor on the side keys' short press (TIDRADIO offers it on long press only)
+- VFO B's step, which TIDRADIO's programmer does not show
+
+The layout's table is shared with the plain TD-H8: one value per option index.
+Dropping the FM "0" or Monitor would shift every later option's index, so the
+two models cannot differ there. Dropping the last option, as power save does,
+shifts nothing, which is why that one could follow TIDRADIO. None of the kept
+options is known to be wrong.
+
+**Bands.** TIDRADIO's programmer says 144–148 / 420–450 MHz. The app keeps
+CHIRP's TX bands for this model, 144–149 / 420–451, as it does for the RT-730.
+(Tim, 2026-12-04: keep CHIRP's bands.)
+
+MIC GAIN (0–32) is in the programmer's dialog but not in its file. It is
+not offered.
+
+### The FM labels on the other TD-H8 models (Tim, 2026-12-04)
+
+The plain TD-H8 and both 3rd Gen models take the **FM radio work mode** (CH 0 /
+VFO 1) and **"Forbid FM Radio Receive"** labels too. Nothing else is carried
+over to them: not TOT, Language, Power-On Display, the 50 kHz step or the
+power-save list.
+
+This was **not measured on those models**. TIDRADIO's programmers for them are
+email-only. The labels follow because two vendor programmers, measured
+independently, both contradict CHIRP on the same two bits, and every one of
+these CHIRP classes runs CHIRP's one FM settings code. The stored bits are
+unchanged; only what the form calls them is different. It is the one place
+the TD-H8 family's settings rest on analogy, and it was Tim's decision.
+
+## Evidence
+
+| Check | Result |
+|---|---|
+| CHIRP oracle, memories: a 13–17-memory matrix per model (simplex, ±, split, Tone, TSQL, DTCS N/R, cross, NFM, every power level, an 8-character name, NOAA, and air band on the AM models). It is set into channels 1–N of the radio-authored base, with every other channel emptied through CHIRP's own `set_memory`. | **whole image byte-identical**, all five models. CHIRP reads ours back as the same memories |
+| Anchor decode: our decode of CHIRP's radio-authored `tests/images` (`TIDRADIO_TD-H8.img`, `TIDRADIO_TD-H8-HAM.img`, `TIDRADIO_TD-H8-HAM_G3.img`, `Radtel_RT-730.img`) against CHIRP's | 5, 41, 30, 30 and 18 memories, all equal. CHIRP shows 11 NOAA memories on the HAM image as duplex off, because they are outside the TX bands. They were compared by their record, which stores TX = RX. |
+| CHIRP oracle, settings: every schema field set, through CHIRP's own `get_settings` / `set_settings`, to a value the base does not hold | whole image byte-identical: 57 / 59 / 57 / 57 / 30 fields (every model through `vendor.py`: the TD-H8 HAM and the RT-730 with their vendors' corrections, the others with the FM labels). No field of ours is missing from CHIRP, and every CHIRP setting is in our schema except the withheld ones |
+| Sabotage: one memory byte and one settings byte flipped in our TD-H8 output | the oracle reports 3 problems, so it can fail |
+| Restore gate, run over 465 real files (the prod and dev `radio-backups`, and every CHIRP test image) | each model accepts only its own CHIRP image, and nothing else |
+| The H3 table against the TD-H3's settings encoder | agree |
+| Mock radio (`tidradio_tdh8/fake_tests.rs`). It checks that: a download reads every block; a wrong ident is refused before any read; a write covers the whole range, ends with `E` and reads back; and a refused block stops the write | pass |
+| Radtel's RT-730 programmer, in the Windows VM (see below) | channels: every matrix row reads as written, and its re-save changes one byte (a scan bit on an empty slot). Settings: our settings image re-saves with 0 bytes changed, every field shows the value we wrote, and its option lists are CHIRP's. Three FM labels and Priority TX disagree with CHIRP, and the app follows Radtel |
+| TIDRADIO's TD-H8 HAM programmer (a dealer's copy), in the Windows VM (see above) | channels: every matrix row reads as written; on re-save it clears empty slots' scan bits and writes `00` in names' ninth byte. Settings: our settings image re-saves with 0 bytes changed and shows every value we wrote. FM work mode and receive, Power-On Display's 0, a 50 kHz step, TOT and Language disagree with or extend CHIRP, and the app follows TIDRADIO |
+| TIDRADIO's programmers for the TD-H8 and the 3rd Gen | **not run**: TIDRADIO sends them only by email |
+| Hardware ladder | **skipped: nobody here owns one** |
+
+The oracle proves the port matches CHIRP. It cannot show that CHIRP's map is
+right for any of these radios, and the mock radio only replays what CHIRP
+believes. The TD-H3 has proven the protocol, but each model's magic, ident and
+image length are CHIRP's word only.
+
+Run it:
+
+```sh
+CHIRP_SRC=… TDH8_OUT=/tmp/tdh8-oracle \
+ cargo test --lib tidradio_tdh8::oracle::oracle -- --ignored --nocapture
+CHIRP_SRC=… python3.12 -I scripts/tidradio_tdh8_family/chirp_oracle.py /tmp/tdh8-oracle
+TDH8_GATE_DIRS=dir1:dir2 \
+ cargo test --lib tidradio_tdh8::oracle::restore_gate_on_real_files -- --ignored --nocapture
+```
diff --git a/scripts/tidradio_tdh8_family/chirp_oracle.py b/scripts/tidradio_tdh8_family/chirp_oracle.py
new file mode 100644
index 0000000..2ce8de2
--- /dev/null
+++ b/scripts/tidradio_tdh8_family/chirp_oracle.py
@@ -0,0 +1,200 @@
+"""CHIRP oracle for the TD-H8 family's Experimental models (#168).
+
+For each model directory the Rust harness (`tidradio_tdh8::oracle`) wrote:
+ 1. load base.bin into CHIRP's class for that model, set the matrix memories
+ into channels 1..N and empty every other channel 1-199 through CHIRP's
+ own set_memory, and diff the WHOLE image against ours.bin; then read our
+ memories back through CHIRP;
+ 2. decode base.bin (radio-authored, from CHIRP's tests/images) through CHIRP
+ and compare it with our decode of the same bytes;
+ 3. load base.bin again, set every value in settings.json through CHIRP's
+ own get_settings()/set_settings() — the changed settings only, so CHIRP
+ re-applying a setting it cannot round-trip does not count against us —
+ and diff the WHOLE image against settings_ours.bin.
+
+ CHIRP_SRC= python3.12 -I chirp_oracle.py [model_key ...]
+
+Evidence in docs/radios/tidradio-tdh8-family.md was taken at CHIRP b63b38d1.
+Proves the port matches CHIRP, nothing about the radios.
+"""
+import json, os, sys
+CHIRP_SRC = os.environ.get('CHIRP_SRC') or sys.exit('set CHIRP_SRC to a CHIRP checkout')
+sys.path.insert(0, CHIRP_SRC)
+import builtins; builtins._ = lambda s: s
+import logging; logging.disable(logging.CRITICAL)
+from chirp import memmap, chirp_common
+from chirp.settings import RadioSetting, RadioSettingValueList, RadioSettingValueBoolean
+from chirp.drivers import tdh8 as m
+sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
+from vendor import vendor_class # noqa: E402
+
+# gen_settings.py's WITHHELD, plus the FM presets: CHIRP offering one is
+# expected, not a gap.
+WITHHELD = {'rxfreqa', 'rxfreqb', 'a', 'b', 'dira', 'dirb', 'fmvfo'}
+
+
+def withheld(name):
+ return name in WITHHELD or name.startswith('block')
+
+
+def radio(cls, img):
+ r = cls(None)
+ r._mmap = memmap.MemoryMapBytes(bytes(img))
+ r.process_mmap()
+ return r
+
+
+def walk(group):
+ for el in group:
+ if isinstance(el, RadioSetting):
+ yield el
+ else:
+ yield from walk(el)
+
+
+def diff(a, b, label):
+ if len(a) != len(b):
+ print(f" {label}: lengths {len(a)} vs {len(b)}")
+ return 1
+ out = [i for i in range(len(a)) if a[i] != b[i]]
+ if out:
+ print(f" {label}: {len(out)} bytes differ, first at image 0x{out[0]:04X}")
+ for i in out[:12]:
+ print(f" 0x{i:04X} ours {a[i]:02X} chirp {b[i]:02X}")
+ return len(out)
+
+
+def channels(d, cls):
+ base = open(os.path.join(d, 'base.bin'), 'rb').read()
+ ours = open(os.path.join(d, 'ours.bin'), 'rb').read()
+ matrix = {e['number']: e for e in json.load(open(os.path.join(d, 'matrix.json')))}
+ r = radio(cls, base)
+ levels = {str(p): p for p in r.get_features().valid_power_levels}
+ lo, hi = r.get_features().memory_bounds
+ for n in range(lo, hi + 1):
+ mm = chirp_common.Memory()
+ mm.number = n
+ e = matrix.get(n)
+ if e is None:
+ mm.empty = True
+ else:
+ mm.freq = e['freq']; mm.duplex = e['duplex']; mm.offset = e['offset']
+ mm.tmode = e['tmode']; mm.rtone = e['rtone']; mm.ctone = e['ctone']
+ mm.dtcs = e['dtcs']; mm.rx_dtcs = e['rx_dtcs']; mm.dtcs_polarity = e['dtcs_polarity']
+ mm.cross_mode = e['cross_mode']; mm.mode = e['mode']
+ mm.power = levels[e['power']]; mm.name = e['name']
+ r.set_memory(mm)
+ theirs = r.get_mmap().get_packed()
+ bad = diff(ours, theirs, 'memories (whole image)')
+ rr = radio(cls, ours)
+ for n, e in matrix.items():
+ mm = rr.get_memory(n)
+ want = (e['freq'], e['name'][:8].rstrip(), e['mode'], e['power'])
+ got = (mm.freq, mm.name, mm.mode, str(mm.power))
+ if got != want:
+ bad += 1
+ print(f" readback mem {n}: {got} != {want}")
+ return len(matrix), bad
+
+
+def anchor(d, cls):
+ img = open(os.path.join(d, 'base.bin'), 'rb').read()
+ ours = {x['n']: x for x in json.load(open(os.path.join(d, 'anchor_ours.json')))}
+ r = radio(cls, img)
+ lo, hi = r.get_features().memory_bounds
+ theirs = {}
+ for n in range(lo, hi + 1):
+ mm = r.get_memory(n)
+ if not mm.empty:
+ theirs[n] = mm
+ bad = 0
+ if set(ours) != set(theirs):
+ bad += 1
+ print(" anchor: different slots", sorted(set(ours) ^ set(theirs))[:20])
+ names = {'Low': 'Low', 'Mid': 'Med', 'High': 'High'}
+ shown_off = []
+ for n in sorted(set(ours) & set(theirs)):
+ o, c = ours[n], theirs[n]
+ tx = None if c.duplex == 'off' else (
+ c.freq + c.offset if c.duplex == '+' else c.freq - c.offset if c.duplex == '-'
+ else c.offset if c.duplex == 'split' else c.freq)
+ otx = None if o['tx'] is None else round(o['tx'] * 1e6)
+ # CHIRP's get_memory DISPLAYS a memory outside the model's TX bands as
+ # duplex "off" whatever the record holds (the HAM image's NOAA channels
+ # store TX = RX). Ours decodes the record; compare with the record.
+ if c.duplex == 'off' and not chirp_common.in_range(c.freq, r.get_tx_bands()):
+ raw = r._memobj.memory[n].txfreq
+ tx = None if raw.get_raw() == b'\xff\xff\xff\xff' else int(raw) * 10
+ shown_off.append(n)
+ if (round(o['freq'] * 1e6) != c.freq or o['name'] != c.name.rstrip()
+ or o['power'] != names[str(c.power)] or o['mode'] != c.mode or otx != tx):
+ bad += 1
+ print(f" anchor mem {n}: ours {o} chirp {c.freq} {tx} {c.name!r} {c.power} {c.mode}")
+ if shown_off:
+ print(f" ({len(shown_off)} memories CHIRP shows as duplex off, off the TX bands, "
+ f"compared by their record: {shown_off})")
+ return len(theirs), bad
+
+
+def settings(d, cls):
+ base = open(os.path.join(d, 'base.bin'), 'rb').read()
+ ours = open(os.path.join(d, 'settings_ours.bin'), 'rb').read()
+ spec = json.load(open(os.path.join(d, 'settings.json')))
+ r = radio(cls, base)
+ by_name = {s.get_name(): s for s in walk(r.get_settings())}
+ applied, missing, changed = 0, [], []
+ for key, val in spec['values'].items():
+ s = by_name.get(key)
+ if s is None:
+ missing.append(key)
+ continue
+ v = s.value
+ if isinstance(v, RadioSettingValueBoolean):
+ v.set_value(bool(val))
+ elif isinstance(v, RadioSettingValueList):
+ v.set_value(val)
+ else:
+ v.set_value(str(val))
+ changed.append(s)
+ applied += 1
+ r.set_settings(changed)
+ theirs = r.get_mmap().get_packed()
+ bad = diff(ours, theirs, 'settings image')
+ chirp_only = sorted(n for n in by_name if n not in spec['values'] and not withheld(n))
+ return applied, missing, chirp_only, bad
+
+
+def main():
+ d = sys.argv[1]
+ keys = sys.argv[2:] or sorted(k for k in os.listdir(d) if os.path.isdir(os.path.join(d, k)))
+ # Comparing nothing is not a match: an empty output directory (the Rust half
+ # failed, or wrote elsewhere) must fail, as must a run missing a model.
+ every = json.load(open(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..',
+ 'src-tauri', 'src', 'tdh8_family', 'models.json')))
+ absent = [k for k in (sys.argv[2:] or every) if not os.path.isfile(os.path.join(d, k, 'settings.json'))]
+ if not keys or absent:
+ sys.exit(f"RESULT: nothing to compare for {absent or 'any model'} in {d} "
+ "(run the Rust half first: TDH8_OUT=… cargo test … oracle -- --ignored)")
+ total_bad = 0
+ for key in keys:
+ kd = os.path.join(d, key)
+ spec = json.load(open(os.path.join(kd, 'settings.json')))
+ cls = vendor_class(m, spec['class'])
+ print(f"== {key} ({cls.VENDOR} {cls.MODEL} {getattr(cls, 'VARIANT', '')})")
+ n, bad = channels(kd, cls)
+ print(f" memories: {n}, {bad} differing bytes/readbacks")
+ an, abad = anchor(kd, cls)
+ print(f" anchor decode: {an} memories, {abad} differing")
+ applied, missing, chirp_only, sbad = settings(kd, cls)
+ print(f" settings: {applied} applied through CHIRP, {sbad} differing bytes")
+ if missing:
+ print(f" ours, not offered by CHIRP for this model: {missing}")
+ if chirp_only:
+ print(f" CHIRP offers, not in our schema: {chirp_only}")
+ total_bad += bad + abad + sbad + len(missing) + len(chirp_only)
+ print("RESULT:", "MATCH" if total_bad == 0 else f"{total_bad} problems")
+ sys.exit(0 if total_bad == 0 else 1)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/scripts/tidradio_tdh8_family/gen_settings.py b/scripts/tidradio_tdh8_family/gen_settings.py
new file mode 100644
index 0000000..1de1093
--- /dev/null
+++ b/scripts/tidradio_tdh8_family/gen_settings.py
@@ -0,0 +1,338 @@
+#!/usr/bin/env python3
+"""Generate the TD-H8 family's settings tables and form schemas (#168).
+
+One source for both ends: CHIRP's own `chirp/drivers/tdh8.py`, run headless,
+and MEASURED rather than read. Where Radtel's own programmer disagrees with
+CHIRP about the RT-730, `vendor.py` corrects CHIRP's class first, and the
+generator measures the corrected class. CHIRP's `set_settings` for this driver is a
+long chain of special cases (inverted `sync`, a mapped group code, codes
+written digit by digit), so instead of reading the bitwise element behind each
+name, every list and switch is driven through CHIRP one option at a time and
+the bytes it writes are recorded:
+
+ * the base image's byte under the setting is forced to 0x00 and then 0xFF,
+ and each option is set through `set_settings([that one setting])`;
+ * the bits whose result does not depend on the base are the bits CHIRP owns
+ (the mask), and their value for each option is that option's stored value;
+ * a setting that touches more than one byte, or whose options do not land
+ on distinct values, stops the run.
+
+Text settings (power-on messages, DTMF codes) are classified by name, and the
+oracle (`chirp_oracle.py`) proves their encoding byte for byte. Anything the
+generator cannot classify stops the run rather than being guessed. Settings
+deliberately not emitted are listed in WITHHELD with why.
+
+Emits:
+ * `src-tauri/src/radios/tidradio_tdh8/settings_table.rs` — one table per
+ memory layout (H8, H3, RT-730), every key any model on it offers;
+ * one form schema per distinct settings set,
+ `src-tauri/src/tdh8_family/.json`, plus `models.json`.
+
+ CHIRP_SRC= python3.12 -I scripts/tidradio_tdh8_family/gen_settings.py
+
+Evidence in docs/radios/tidradio-tdh8-family.md was taken at CHIRP b63b38d1.
+"""
+import json, os, sys
+from pathlib import Path
+
+CHIRP_SRC = os.environ.get('CHIRP_SRC') or sys.exit('set CHIRP_SRC to a CHIRP checkout')
+sys.path.insert(0, CHIRP_SRC)
+import builtins; builtins._ = lambda s: s
+import logging; logging.disable(logging.CRITICAL)
+from chirp import memmap
+from chirp.settings import RadioSetting, RadioSettingValueList, RadioSettingValueBoolean, \
+ RadioSettingValueString
+from chirp.drivers import tdh8 as m
+sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
+from vendor import vendor_class # noqa: E402
+
+ROOT = Path(__file__).resolve().parents[2]
+TABLE = ROOT / 'src-tauri/src/radios/tidradio_tdh8/settings_table.rs'
+SCHEMAS = ROOT / 'src-tauri/src/tdh8_family'
+IMAGES = Path(CHIRP_SRC) / 'tests/images'
+
+# (driver_key, CHIRP class, layout, radio-authored base image), family order.
+MODELS = [
+ ('tidradio_tdh8', 'TDH8', 'H8', 'TIDRADIO_TD-H8.img'),
+ ('tidradio_tdh8ham', 'TDH8_HAM', 'H8', 'TIDRADIO_TD-H8-HAM.img'),
+ ('tidradio_tdh8g3', 'TDH8_3rd_Gen', 'H3', 'TIDRADIO_TD-H8-HAM_G3.img'),
+ ('tidradio_tdh8g3ham', 'TDH8_3rd_Gen_HAM', 'H3', 'TIDRADIO_TD-H8-HAM_G3.img'),
+ ('radtel_rt730', 'RT730', 'RT730', 'Radtel_RT-730.img'),
+]
+
+# Settings CHIRP offers that are deliberately not emitted, with why.
+# `chirp_oracle.py` reads this list.
+WITHHELD = {
+ 'rxfreqa': 'VFO frequency: not ported in this pass (CHIRP range-checks it against bands of its own)',
+ 'rxfreqb': 'VFO frequency: not ported in this pass (CHIRP pads the B frequency with ljust)',
+ 'a': 'VFO offset: an apply callback; not ported in this pass',
+ 'b': 'VFO offset: an apply callback; not ported in this pass',
+ 'dira': 'VFO offset direction: its callback recomputes the VFO TX frequency',
+ 'dirb': 'VFO offset direction: its callback recomputes the VFO TX frequency',
+ 'fmvfo': 'FM broadcast VFO: not ported in this pass',
+}
+# The 25 FM broadcast presets (block00..block24): channel-like data, as on the TD-H3.
+WITHHELD_PREFIX = ('block',)
+
+# Labels where CHIRP's short name says little on its own.
+LABEL = {
+ 'ligcon': 'Backlight Time', 'keyautolock': 'Auto Keypad Lock', 'mdfa': 'Display Mode A',
+ 'mdfb': 'Display Mode B', 'sync': 'A/B Sync', 'dbrx': 'Dual Receive', 'btnvoice': 'Key Beep',
+ 'rogerprompt': 'Roger Beep', 'press.rogerprompt': 'Roger Beep', 'txled': 'Display LCD on TX',
+ 'rxled': 'Display LCD on RX', 'onlychmode': 'Channel Mode Only', 'ssidekey1': 'PF1 Short Press',
+ 'lsidekey3': 'PF1 Long Press', 'stopkey1': 'Top Key Short Press', 'ltopkey2': 'Top Key Long Press',
+ 'ssidekey2': 'PF2 Short Press', 'lsidekey4': 'PF2 Long Press', 'press.ssidekey1': 'PF1 Short Press',
+ 'press.lsidekey1': 'PF1 Long Press', 'press.ssidekey2': 'PF2 Short Press',
+ 'press.lsidekey2': 'PF2 Long Press', 'breathled': 'Breathing LED', 'ponmsg': 'Power-On Display',
+ 'lowpower': 'VFO A TX Power', 'wide': 'VFO A Bandwidth', 'bcl': 'VFO A Busy Lock',
+ 'specialqta': 'VFO A Special QT/DQT', 'aworkmode': 'VFO A Work Mode', 'lowpowerb': 'VFO B TX Power',
+ 'wideb': 'VFO B Bandwidth', 'bclb': 'VFO B Busy Lock', 'specialqtb': 'VFO B Special QT/DQT',
+ 'bworkmode': 'VFO B Work Mode', 'astep': 'VFO A Step (kHz)', 'bstep': 'VFO B Step (kHz)',
+ 'fmworkmode': 'FM Radio Work Mode', 'fmroad': 'FM Radio Channel', 'fmrec': 'FM Radio Receive',
+ 'group1': 'Group Call 1', 'group2': 'Group Call 2', 'group3': 'Group Call 3',
+ 'group4': 'Group Call 4', 'group5': 'Group Call 5', 'group6': 'Group Call 6',
+ 'group7': 'Group Call 7', 'group8': 'Group Call 8', 'scode': 'PTT ID Start (BOT)',
+ 'ecode': 'PTT ID End (EOT)', 'tailclean': 'QT/DQT Tail Elimination', 'hoptype': 'Hop Type',
+}
+
+# Which tab (SETTINGS_GROUPS in src/lib/profiles.ts) each key lands on.
+GROUP = {
+ 'General': ['save', 'keyautolock', 'onlychmode', 'lang', 'sync', 'pritx'],
+ 'Display': ['ligcon', 'mdfa', 'mdfb', 'txled', 'rxled', 'breathled', 'ponmsg',
+ 'poweron_msg.msg1', 'poweron_msg.msg2', 'poweron_msg.msg3', 'poweron_msg.msg4'],
+ 'Sounds': ['voiceprompt', 'btnvoice', 'rogerprompt', 'press.rogerprompt'],
+ 'Transmit & Receive': ['squelch', 'dbrx', 'voxgain', 'voxdelay', 'tot', 'tailclean', 'hoptype'],
+ 'Memory & VFO': ['lowpower', 'wide', 'bcl', 'specialqta', 'aworkmode', 'astep', 'lowpowerb',
+ 'wideb', 'bclb', 'specialqtb', 'bworkmode', 'bstep', 'fmworkmode', 'fmroad',
+ 'fmrec'],
+ 'Scan': ['scanmode'],
+ 'Keys': ['ssidekey1', 'lsidekey3', 'stopkey1', 'ltopkey2', 'ssidekey2', 'lsidekey4',
+ 'press.ssidekey1', 'press.lsidekey1', 'press.ssidekey2', 'press.lsidekey2'],
+ 'DTMF & Signaling': ['gcode', 'icode', 'group1', 'group2', 'group3', 'group4', 'group5',
+ 'group6', 'group7', 'group8', 'scode', 'ecode', 'dtmfst'],
+}
+ORDER = list(GROUP)
+
+# Text settings, by name: (kind, image offset per layout, length).
+TEXT = {
+ 'poweron_msg.msg1': 'Text', 'poweron_msg.msg2': 'Text', 'poweron_msg.msg3': 'Text',
+ 'poweron_msg.msg4': 'Text', 'icode': 'Dtmf', 'group1': 'Dtmf', 'group2': 'Dtmf',
+ 'group3': 'Dtmf', 'group4': 'Dtmf', 'group5': 'Dtmf', 'group6': 'Dtmf', 'group7': 'Dtmf',
+ 'group8': 'Dtmf', 'scode': 'Dtmf', 'ecode': 'Dtmf',
+}
+
+
+def group_of(key):
+ for g, names in GROUP.items():
+ if key in names:
+ return g
+ sys.exit(f'no group for {key}')
+
+
+def walk(g):
+ for el in g:
+ if isinstance(el, RadioSetting):
+ yield el
+ else:
+ yield from walk(el)
+
+
+def radio(cls, data):
+ r = cls(None)
+ r._mmap = memmap.MemoryMapBytes(bytes(data))
+ r.process_mmap()
+ return r
+
+
+def find(r, name):
+ for s in walk(r.get_settings()):
+ if s.get_name() == name:
+ return s
+ return None
+
+
+def written(cls, data, name, value):
+ """The image after CHIRP sets `name` to `value`, alone."""
+ r = radio(cls, data)
+ s = find(r, name)
+ if s is None:
+ return None
+ s.value.set_value(value)
+ r.set_settings([s])
+ return r.get_mmap().get_packed()
+
+
+def measure_choice(cls, base, name, options):
+ """(offset, mask, values) for a list or switch, or exit."""
+ touched = set()
+ for o in options:
+ out = written(cls, base, name, o)
+ touched |= {j for j in range(len(base)) if out[j] != base[j]}
+ # An option equal to what the base holds writes nothing: probe the byte
+ # with both fills so the setting's byte is found even then.
+ if not touched:
+ sys.exit(f'{name}: no option changes the image')
+ if len(touched) != 1:
+ sys.exit(f'{name}: touches {sorted(hex(t) for t in touched)}, not one byte')
+ at = touched.pop()
+ res = {}
+ for fill in (0x00, 0xFF):
+ b = bytearray(base)
+ b[at] = fill
+ outs = []
+ for o in options:
+ out = written(cls, b, name, o)
+ if out is None:
+ outs = None
+ break
+ other = [j for j in range(len(b)) if j != at and out[j] != b[j]]
+ if other:
+ sys.exit(f'{name}: with 0x{fill:02X} under it, also wrote {other[:4]}')
+ outs.append(out[at])
+ res[fill] = outs
+ if res[0x00] is None or res[0xFF] is None:
+ sys.exit(f'{name}: CHIRP cannot show it with the byte filled')
+ mask = 0xFF
+ for a, b in zip(res[0x00], res[0xFF]):
+ mask &= ~(a ^ b) & 0xFF
+ values = [a & mask for a in res[0x00]]
+ if len(set(values)) != len(values):
+ sys.exit(f'{name}: options share a stored value {values} (mask 0x{mask:02X})')
+ return at, mask, values
+
+
+def measure_text(cls, base, name, kind):
+ """(offset, length) of a text setting: where CHIRP writes a full-length value."""
+ # Two full-length probes that differ in every position: whatever the base
+ # holds, each byte of the field differs from it under one of them.
+ probes = (('ABCDEFGHIJKLMNOP', 'QRSTUVWXYZQRSTUV') if kind == 'Text'
+ else ('1111111111111111', '2222222222222222'))
+ r = radio(cls, base)
+ s = find(r, name)
+ n = s.value._maxlength
+ d = set()
+ for probe in probes:
+ out = written(cls, base, name, probe[:n])
+ d |= {j for j in range(len(base)) if out[j] != base[j]}
+ d = sorted(d)
+ if d and d != list(range(d[0], d[-1] + 1)):
+ sys.exit(f'{name}: wrote a scattered span {d}')
+ if not d:
+ sys.exit(f'{name}: writing it changed nothing')
+ at, end = d[0], d[-1] + 1
+ if end - at > n:
+ sys.exit(f'{name}: wrote {end - at} bytes for a {n}-character value')
+ return at, n
+
+
+def main():
+ tables = {} # layout -> key -> (rust kind, at, len)
+ per_model = [] # (driver_key, schema)
+ for key_, cls_name, layout, img in MODELS:
+ cls = vendor_class(m, cls_name)
+ base = (IMAGES / img).read_bytes()[:cls._memsize + 8]
+ r = radio(cls, base)
+ table = tables.setdefault(layout, {})
+ fields = {g: [] for g in ORDER}
+ for s in walk(r.get_settings()):
+ name = s.get_name()
+ if name in WITHHELD or name.startswith(WITHHELD_PREFIX):
+ continue
+ v = s.value
+ label = getattr(cls, 'VENDOR_LABEL', {}).get(name) or LABEL.get(name, s.get_shortname())
+ if isinstance(v, (RadioSettingValueList, RadioSettingValueBoolean)):
+ boolean = isinstance(v, RadioSettingValueBoolean)
+ options = [False, True] if boolean else list(v.get_options())
+ at, mask, values = measure_choice(cls, base, name, options)
+ rust = (f'Kind::Choice {{ mask: 0x{mask:02X}, values: &['
+ + ', '.join(f'0x{x:02X}' for x in values) + '] }')
+ entry = (rust, at, 1)
+ f = {'key': name, 'label': label, 'type': 'boolean' if boolean else 'select'}
+ if not boolean:
+ f['options'] = options
+ elif isinstance(v, RadioSettingValueString) and name in TEXT:
+ at, n = measure_text(cls, base, name, TEXT[name])
+ entry = (f'Kind::{TEXT[name]}', at, n)
+ f = {'key': name, 'label': label, 'type': 'text', 'max_length': n}
+ else:
+ sys.exit(f'{key_}: {name} ({type(v).__name__}) cannot be classified')
+ if name in table and table[name] != entry:
+ # Same key, same layout, different bytes: only a list that grew
+ # on one model may differ, and then only in its value list.
+ old = table[name]
+ if old[1:] != entry[1:] or not (old[0].rstrip('] }') in entry[0] or
+ entry[0].rstrip('] }') in old[0]):
+ sys.exit(f'{name}: {old} on one {layout} model, {entry} on {key_}')
+ entry = max(old, entry, key=lambda e: len(e[0]))
+ table[name] = entry
+ fields[group_of(name)].append(f)
+ schema = []
+ for g in ORDER:
+ if fields[g]:
+ schema.append({'key': 'section-' + g.lower().replace(' & ', '-').replace(' ', '-'),
+ 'label': g, 'type': 'section', 'group': g})
+ schema.extend(fields[g])
+ per_model.append((key_, schema))
+
+ SCHEMAS.mkdir(exist_ok=True)
+ for old in SCHEMAS.glob('*.json'):
+ old.unlink()
+ files = {}
+ for key_, schema in per_model:
+ text = json.dumps(schema, indent=1) + '\n'
+ if text not in files:
+ files[text] = key_
+ (SCHEMAS / f'{key_}.json').write_text(text)
+ assign = {key_: files[json.dumps(schema, indent=1) + '\n'] for key_, schema in per_model}
+ (SCHEMAS / 'models.json').write_text(json.dumps(assign, indent=1) + '\n')
+
+ blocks = ''
+ for layout in ('H8', 'H3', 'RT730'):
+ rows = ''.join(f' Field {{ key: "{k}", at: 0x{at:04X}, len: {ln}, kind: {rust} }},\n'
+ for k, (rust, at, ln) in sorted(tables[layout].items(),
+ key=lambda kv: (kv[1][1], kv[0])))
+ blocks += (f'\n/// The {layout} layout: {len(tables[layout])} keys.\n'
+ f'pub(crate) const FIELDS_{layout}: &[Field] = &[\n{rows}];\n')
+ withheld = ', '.join(list(WITHHELD) + ['block00..block24'])
+ TABLE.write_text(f'''//! TD-H8 family settings tables — GENERATED by
+//! `scripts/tidradio_tdh8_family/gen_settings.py`, do not edit.
+//!
+//! Every setting CHIRP's `tdh8.py` (b63b38d1) offers on any model in the
+//! family, measured by driving CHIRP's own `set_settings` one setting and one
+//! option at a time: where it writes, which bits it owns, and the value each
+//! option stores. One table per memory layout — a key names different bytes on
+//! each. Which keys a model has, and each select's option list, are in its form
+//! schema (`src-tauri/src/tdh8_family/`), generated in the same run.
+//! Not emitted: {withheld}.
+
+/// How a field is stored.
+#[derive(Clone, Copy, PartialEq, Eq, Debug)]
+pub(crate) enum Kind {{
+ /// One byte; the bits in `mask` hold `values[i]` for option `i` (a switch
+ /// is options false, true). Every other bit is left as read.
+ Choice {{ mask: u8, values: &'static [u8] }},
+ /// DTMF digits 0-9 and A-D, one per byte as its value, padded 0xFF.
+ Dtmf,
+ /// ASCII text, padded with spaces.
+ Text,
+}}
+
+/// One setting.
+pub(crate) struct Field {{
+ /// CHIRP's setting name, which is also the form schema's key.
+ pub key: &'static str,
+ /// Image offset (the image starts with the 8-byte ident).
+ pub at: usize,
+ /// Bytes.
+ pub len: usize,
+ pub kind: Kind,
+}}
+{blocks}''')
+ for layout, t in tables.items():
+ print(f'{layout}: {len(t)} keys')
+ for text, key_ in files.items():
+ n = sum(1 for f in json.loads(text) if f['type'] != 'section')
+ print(f' {key_}.json {n} fields <- ' + ', '.join(k for k, v in assign.items() if v == key_))
+
+
+main()
diff --git a/scripts/tidradio_tdh8_family/vendor.py b/scripts/tidradio_tdh8_family/vendor.py
new file mode 100644
index 0000000..e8c01e7
--- /dev/null
+++ b/scripts/tidradio_tdh8_family/vendor.py
@@ -0,0 +1,192 @@
+"""Vendor overrides of CHIRP classes shared by gen_settings.py and chirp_oracle.py.
+
+Where Radtel's own RT-730 programmer (RT-730_setup231113, from radtels.com's
+software page; docs/radios/tidradio-tdh8-family.md, "Radtel's programmer")
+disagrees with CHIRP's `RT730`, the app follows Radtel. Each row below was
+measured in that programmer, one control changed per save, the saved file
+diffed:
+
+ * FM work mode (0x0CAA bit 7): Radtel stores CH as 0 and VFO as 1; CHIRP's
+ list says the reverse. Same bit, labels swapped.
+ * FM receive (0x0CAA bit 3): Radtel calls a set bit "Forbid Receive"; CHIRP
+ calls it "Allow Receive". Same bit, meaning inverted.
+ * FM channel (0x0CAE): Radtel offers channels 1-25 stored as 0-24; CHIRP
+ offers "0".."25", one past the last preset. Same bytes, labels shifted.
+ * Priority TX (0x0CA8 bit 0, Edit 0 / Busy 1): Radtel's programmer has it,
+ as does the manual (menu 30, TX-SEL); CHIRP's map marks the bit unused.
+
+TIDRADIO's own programmer for the 2nd-generation TD-H8 HAM
+(TIDRADIO_H8(HAM)_setup230912, a dealer's copy; docs, "TIDRADIO's
+programmer") was measured the same way. Where it disagrees with CHIRP's
+`TDH8_HAM`, the app follows TIDRADIO:
+
+ * FM work mode (0x0CAA bit 7) and FM receive (bit 3): as on the RT-730, CH is
+ 0 and VFO 1, and a set bit is "Forbid Receive". FM channel is NOT the
+ RT-730's case: TIDRADIO stores channels 1-25 as 1-25, so CHIRP's labels are
+ right (CHIRP also offers a "0" TIDRADIO does not; kept).
+ * Power-On Display (0x0CAB bits 7-6): TIDRADIO calls 0 "Full", CHIRP "Off".
+ * VFO A step (0x0CB0 bits 7-4): TIDRADIO's one step control adds 50.00K,
+ stored 6 (measured, as was 12.50K = 4); CHIRP stops at 25.0. Its list is
+ otherwise CHIRP's. VFO B's step is not in TIDRADIO's programmer and keeps
+ CHIRP's list.
+ * Power save (0x0CB4): TIDRADIO's list, like the manual's, stops at 1:4
+ (stored 4, measured); CHIRP adds 1:8. The HAM's list drops it, which keeps
+ the other options' values, so the shared table is unchanged.
+ * Time-Out Timer (0x0CB2, OFF/30S..210S stored 0-7; OFF, 30S and 210S
+ measured) and Language (0x0CB3 bit 1 alone: TIDRADIO shows a byte of 1 as
+ Chinese and 3 as English): TIDRADIO's programmer has both; CHIRP offers
+ neither on the TD-H8.
+
+Only `TDH8_HAM` takes all of these. TIDRADIO's programmers for the plain TD-H8
+and the 3rd Gen are sent by email only and have not been run.
+
+The FM radio's work mode and receive labels alone are carried to the plain
+TD-H8 and both 3rd Gen models (Tim, 2026-12-04). This is NOT measured on
+them: two vendor programmers, Radtel's and TIDRADIO's, measured independently,
+both contradict CHIRP's labels on the same bits, and all of these classes run
+CHIRP's one FM settings code. Nothing else is carried over.
+
+Both scripts take CHIRP's class through `vendor_class`, so the schema the
+generator emits and the bytes the oracle compares agree.
+"""
+from chirp.settings import RadioSetting, RadioSettingGroup, RadioSettingValueList
+
+PRITX_AT = 0x0CA8 # image offset (the image starts with the 8-byte ident)
+
+TOT_AT = 0x0CB2
+LANG_AT = 0x0CB3
+LANG_BIT = 0x02
+
+# Labels the schema shows where CHIRP's are wrong for the model.
+RT730_LABEL = {'fmrec': 'Forbid FM Radio Receive', 'pritx': 'Priority TX'}
+FM_LABEL = {'fmrec': 'Forbid FM Radio Receive'}
+TDH8_HAM_LABEL = {'fmrec': 'Forbid FM Radio Receive', 'tot': 'Time-Out Timer',
+ 'lang': 'Language'}
+
+
+def _replace(group, name, make):
+ """Swap the setting called `name`, wherever it sits, for make(old)."""
+ if not hasattr(group, '_elements'): # the top-level RadioSettings list
+ return any(_replace(g, name, make) for g in group)
+ for key, el in list(group._elements.items()):
+ if isinstance(el, RadioSetting) and el.get_name() == name:
+ group._elements[key] = make(el)
+ return True
+ if isinstance(el, RadioSettingGroup) and not isinstance(el, RadioSetting):
+ if _replace(el, name, make):
+ return True
+ return False
+
+
+def _flatten(settings):
+ for el in settings:
+ if isinstance(el, RadioSetting):
+ yield el
+ else:
+ yield from _flatten(el)
+
+
+def _fm_work_mode(top, s):
+ _replace(top, 'fmworkmode', lambda old: RadioSetting(
+ 'fmworkmode', old.get_shortname(),
+ RadioSettingValueList(['CH', 'VFO'], current_index=int(s.fmworkmode))))
+
+
+def vendor_class(m, name):
+ cls = getattr(m, name)
+ if name == 'TDH8_HAM':
+ return _tdh8_ham(cls)
+ if name in ('TDH8', 'TDH8_3rd_Gen', 'TDH8_3rd_Gen_HAM'):
+ return _fm_only(cls)
+ if name != 'RT730':
+ return cls
+
+ class RT730(cls):
+ VENDOR_LABEL = RT730_LABEL
+
+ def get_settings(self):
+ top = super().get_settings()
+ s = self._memobj.settings
+ _fm_work_mode(top, s)
+ _replace(top, 'fmroad', lambda old: RadioSetting(
+ 'fmroad', old.get_shortname(),
+ RadioSettingValueList([str(i) for i in range(1, 26)],
+ current_index=min(int(s.fmroad), 24))))
+ first = next(iter(top))
+ first.append(RadioSetting(
+ 'pritx', 'Priority TX',
+ RadioSettingValueList(['Edit', 'Busy'],
+ current_index=self._mmap[PRITX_AT][0] & 1)))
+ return top
+
+ def set_settings(self, settings):
+ rest = []
+ for el in _flatten(settings):
+ if el.get_name() == 'pritx':
+ old = self._mmap[PRITX_AT][0]
+ self._mmap[PRITX_AT] = bytes([(old & 0xFE) | int(el.value)])
+ else:
+ rest.append(el)
+ super().set_settings(rest)
+
+ return RT730
+
+
+def _tdh8_ham(cls):
+ class TDH8_HAM(cls):
+ VENDOR_LABEL = TDH8_HAM_LABEL
+
+ def get_settings(self):
+ top = super().get_settings()
+ s = self._memobj.settings
+ _fm_work_mode(top, s)
+ _replace(top, 'ponmsg', lambda old: RadioSetting(
+ 'ponmsg', old.get_shortname(),
+ RadioSettingValueList(['Full', 'Msg', 'Icon'],
+ current_index=min(int(s.ponmsg), 2))))
+ _replace(top, 'astep', lambda old: RadioSetting(
+ 'astep', old.get_shortname(),
+ RadioSettingValueList(list(old.value.get_options()) + ['50.0'],
+ current_index=min(int(s.astep), 6))))
+ _replace(top, 'save', lambda old: RadioSetting(
+ 'save', old.get_shortname(),
+ RadioSettingValueList(list(old.value.get_options())[:5],
+ current_index=min(int(s.save), 4))))
+ first = next(iter(top))
+ first.append(RadioSetting(
+ 'tot', 'Time-Out Timer',
+ RadioSettingValueList(['OFF', '30S', '60S', '90S', '120S', '150S', '180S', '210S'],
+ current_index=min(self._mmap[TOT_AT][0], 7))))
+ first.append(RadioSetting(
+ 'lang', 'Language',
+ RadioSettingValueList(['Chinese', 'English'],
+ current_index=int(bool(self._mmap[LANG_AT][0] & LANG_BIT)))))
+ return top
+
+ def set_settings(self, settings):
+ rest = []
+ for el in _flatten(settings):
+ if el.get_name() == 'tot':
+ self._mmap[TOT_AT] = bytes([int(el.value)])
+ elif el.get_name() == 'lang':
+ old = self._mmap[LANG_AT][0]
+ self._mmap[LANG_AT] = bytes([(old & ~LANG_BIT & 0xFF) | (LANG_BIT * int(el.value))])
+ else:
+ rest.append(el)
+ super().set_settings(rest)
+
+ return TDH8_HAM
+
+
+def _fm_only(cls):
+ """The FM radio's work mode and receive labels, and nothing else."""
+ class FmFixed(cls):
+ VENDOR_LABEL = FM_LABEL
+
+ def get_settings(self):
+ top = super().get_settings()
+ _fm_work_mode(top, self._memobj.settings)
+ return top
+
+ FmFixed.__name__ = cls.__name__
+ return FmFixed
diff --git a/src-tauri/src/commands/radio_backups.rs b/src-tauri/src/commands/radio_backups.rs
index b05e640..28a010e 100644
--- a/src-tauri/src/commands/radio_backups.rs
+++ b/src-tauri/src/commands/radio_backups.rs
@@ -116,6 +116,11 @@ fn label_for(key: &str) -> String {
"uv21progps" | "baofeng_uv21progps" => "Baofeng UV-21Pro GPS",
"uv28plus" | "baofeng_uv28plus" => "Baofeng UV-28Plus",
"uv32" | "baofeng_uv32" => "Baofeng UV-32",
+ "tdh8" | "tidradio_tdh8" => "TIDRADIO TD-H8",
+ "tdh8ham" | "tidradio_tdh8ham" => "TIDRADIO TD-H8 HAM",
+ "tdh8g3" | "tidradio_tdh8g3" => "TIDRADIO TD-H8 3rd Gen",
+ "tdh8g3ham" | "tidradio_tdh8g3ham" => "TIDRADIO TD-H8 3rd Gen HAM",
+ "rt730" | "radtel_rt730" => "Radtel RT-730",
other => return other.to_string(),
}
.to_string()
diff --git a/src-tauri/src/db.rs b/src-tauri/src/db.rs
index 00b2d42..06678c9 100644
--- a/src-tauri/src/db.rs
+++ b/src-tauri/src/db.rs
@@ -64,7 +64,7 @@ mod tests {
// the Binteradio BT-9000, Kenwood TM-D710, Icom ID-5100, TYT MD-380 and Yaesu
// FTM-300DR, FTM-400 and FTM-510DR, the FT-857D, FT-897D and FT-891, the Icom ID-51 Plus, the Quansheng UV-K5 (stock and egzumer), and
// the UV-5R family's sixteen Experimental models and the UV-17Pro
- // family's fourteen (#168). (0015
+ // family's fourteen and the TD-H8 family's five (#168). (0015
// removed the Vero VR-N76 placeholder.) None of the last five has a
// migration of its own — seeding INSERTs new (manufacturer, model)
// rows, so a new model reaches existing databases on the next startup
@@ -74,12 +74,12 @@ mod tests {
.await
.unwrap();
assert_eq!(
- count.0, 52,
+ count.0, 57,
"expected the UV-5R, TD-H3, AT-D890UV, AT-D578UV, AT-D868UV, FT5D, ID-52, TH-D75, TH-D72, BT-9000, \
TM-D710, ID-5100, MD-380, FTM-300DR, FTM-400, FTM-510DR, FT-857D, FT-897D, FT-891, ID-51 Plus, UV-K5, UV-K5 (egzumer), \
UV-82, UV-82HP, UV-82X3, BF-F8HP, UV-6, GT-5R, UV-5G, BF-A58, UV-82WP, GT-3WP, RT6, BF-A58S, UV-S9X3, 5RX, UV-9R, UV-9G, \
UV-17Pro, UV-21Pro V2, UV-25, UV-17R Plus, 5RM, P15, MT-5RM, K5-Plus, UV-5RH, UV-5RM Plus, UV-17Pro GPS, \
- UV-21Pro GPS, UV-28Plus and UV-32 seeded models"
+ UV-21Pro GPS, UV-28Plus, UV-32, TD-H8, TD-H8 HAM, TD-H8 3rd Gen, TD-H8 3rd Gen HAM and RT-730 seeded models"
);
let models: Vec<(String,)> =
@@ -93,7 +93,7 @@ mod tests {
vec![
"5RM", "5RX", "AT-D578UV", "AT-D868UV", "AT-D890UV", "BF-A58", "BF-A58S", "BF-F8HP", "BT-9000", "FT-857D", "FT-891", "FT-897D",
"FT5D", "FTM-300DR", "FTM-400", "FTM-510DR", "GT-3WP", "GT-5R", "ID-51 Plus", "ID-5100", "ID-52", "K5-Plus", "MD-380", "MT-5RM",
- "P15", "RT6", "TD-H3", "TH-D72", "TH-D75", "TM-D710", "UV-17Pro", "UV-17Pro GPS", "UV-17R Plus", "UV-21Pro GPS", "UV-21Pro V2",
+ "P15", "RT-730", "RT6", "TD-H3", "TD-H8", "TD-H8 3rd Gen", "TD-H8 3rd Gen HAM", "TD-H8 HAM", "TH-D72", "TH-D75", "TM-D710", "UV-17Pro", "UV-17Pro GPS", "UV-17R Plus", "UV-21Pro GPS", "UV-21Pro V2",
"UV-25", "UV-28Plus", "UV-32", "UV-5G", "UV-5R", "UV-5RH", "UV-5RM Plus", "UV-6", "UV-82", "UV-82HP", "UV-82WP", "UV-82X3", "UV-9G",
"UV-9R", "UV-K5", "UV-K5 (egzumer)", "UV-S9X3"
]
@@ -105,7 +105,7 @@ mod tests {
.fetch_one(&pool)
.await
.unwrap();
- assert_eq!(count2.0, 52, "seeding should be idempotent");
+ assert_eq!(count2.0, 57, "seeding should be idempotent");
// A new database starts with NO talkgroups. The BrandMeister list used
// to be compiled in and seeded here; it is downloaded on request now,
diff --git a/src-tauri/src/radios/mod.rs b/src-tauri/src/radios/mod.rs
index 7b1be33..2375fe2 100644
--- a/src-tauri/src/radios/mod.rs
+++ b/src-tauri/src/radios/mod.rs
@@ -89,6 +89,11 @@ pub(crate) mod quansheng_uvk5_egzumer;
pub(crate) mod registry;
pub(crate) mod settings_bounds;
pub(crate) mod tidradio_tdh3;
+pub(crate) mod tidradio_tdh8;
+pub(crate) mod tidradio_tdh8ham;
+pub(crate) mod tidradio_tdh8g3;
+pub(crate) mod tidradio_tdh8g3ham;
+pub(crate) mod radtel_rt730;
pub(crate) mod tyt_md380;
#[cfg(test)]
mod wiring;
diff --git a/src-tauri/src/radios/radtel_rt730/mod.rs b/src-tauri/src/radios/radtel_rt730/mod.rs
new file mode 100644
index 0000000..4ab966a
--- /dev/null
+++ b/src-tauri/src/radios/radtel_rt730/mod.rs
@@ -0,0 +1,30 @@
+//! Radtel RT-730 (`driver_key = "radtel_rt730"`) — Experimental (#168).
+//!
+//! CHIRP `RT730` (`chirp/drivers/tdh8.py`). Radtel's RT-730 on the TD-H8's protocol with a memory layout of its own: transmit 136-630 MHz, receive from 10 MHz (AM in the air band), Low / Mid / High as CHIRP lists it (inherited from the TD-H8; 1 / 4 / 8 W there). 199 channels, as CHIRP maps it.
+//!
+//! Everything else is the TD-H8 family's session code in `radios/tidradio_tdh8`,
+//! ported from CHIRP (GPLv2-or-later, by the CHIRP contributors). Nobody here
+//! owns one: nothing about this model has been confirmed on a radio, so it ships
+//! Experimental and the app warns before every write. See
+//! `docs/radios/tidradio-tdh8-family.md`.
+
+use crate::radios::tidradio_tdh8::{
+ TidradioTdh8, Variant, IDENT_OPEN, LAYOUT_RT730, MAGIC_RT730, POWER_LMH,
+};
+
+pub(crate) static VARIANT: Variant = Variant {
+ key: "radtel_rt730",
+ display_name: "Radtel RT-730",
+ short: "RT-730",
+ magic: MAGIC_RT730,
+ ident: IDENT_OPEN,
+ layout: &LAYOUT_RT730,
+ power: POWER_LMH,
+ am: true,
+ chirp_models: &["RT-730"],
+ file_prefix: "rt730",
+ hardware_verified: false,
+};
+
+/// Registry entry (see `radios/registry.rs`).
+pub(crate) static DRIVER: TidradioTdh8 = TidradioTdh8(&VARIANT);
diff --git a/src-tauri/src/radios/registry.rs b/src-tauri/src/radios/registry.rs
index ab56a9a..1310a33 100644
--- a/src-tauri/src/radios/registry.rs
+++ b/src-tauri/src/radios/registry.rs
@@ -23,7 +23,7 @@ use crate::models::RadioModel;
/// Every driver compiled into the app. Order is not significant — lookups are
/// by `key()`, which is unique. (A static array rather than a slice literal:
/// references to statics aren't const-promotable inside a returned temporary.)
-static DRIVERS: [&dyn RadioDriver; 51] = [
+static DRIVERS: [&dyn RadioDriver; 56] = [
&super::baofeng_uv5r::DRIVER,
&super::baofeng_uv82::DRIVER,
&super::baofeng_uv82hp::DRIVER,
@@ -57,6 +57,11 @@ static DRIVERS: [&dyn RadioDriver; 51] = [
&super::baofeng_uv32::DRIVER,
&super::binteradio_bt9000::DRIVER,
&super::tidradio_tdh3::DRIVER,
+ &super::tidradio_tdh8::DRIVER,
+ &super::tidradio_tdh8ham::DRIVER,
+ &super::tidradio_tdh8g3::DRIVER,
+ &super::tidradio_tdh8g3ham::DRIVER,
+ &super::radtel_rt730::DRIVER,
&super::anytone_atd890uv::DRIVER,
&super::anytone_atd578uv::DRIVER,
&super::anytone_atd868uv::DRIVER,
@@ -121,6 +126,11 @@ mod tests {
"baofeng_uv5r",
"binteradio_bt9000",
"tidradio_tdh3",
+ "tidradio_tdh8",
+ "tidradio_tdh8ham",
+ "tidradio_tdh8g3",
+ "tidradio_tdh8g3ham",
+ "radtel_rt730",
"anytone_atd890uv",
"anytone_atd578uv",
"anytone_atd868uv",
@@ -331,6 +341,11 @@ mod tests {
| "baofeng_uv28plus"
| "baofeng_uv32"
| "tidradio_tdh3"
+ | "tidradio_tdh8"
+ | "tidradio_tdh8ham"
+ | "tidradio_tdh8g3"
+ | "tidradio_tdh8g3ham"
+ | "radtel_rt730"
| "kenwood_thd72"
| "binteradio_bt9000"
| "icom_id5100"
diff --git a/src-tauri/src/radios/tidradio_tdh3/mod.rs b/src-tauri/src/radios/tidradio_tdh3/mod.rs
index d49318d..efc2ea7 100644
--- a/src-tauri/src/radios/tidradio_tdh3/mod.rs
+++ b/src-tauri/src/radios/tidradio_tdh3/mod.rs
@@ -409,10 +409,22 @@ fn read_exact(p: &mut dyn SerialPort, n: usize) -> Result, String> {
/// TIDRADIO clone-mode handshake. Returns the ident bytes the radio reports.
pub(crate) fn do_ident(p: &mut dyn SerialPort) -> Result, String> {
+ do_ident_with(p, MAGIC, "TD-H3")
+}
+
+/// [`do_ident`] with another model's magic (the TD-H8 family, `tidradio_tdh8`).
+/// `model` only names the radio in the error.
+pub(crate) fn do_ident_with(
+ p: &mut dyn SerialPort,
+ magic: &[u8],
+ model: &str,
+) -> Result, String> {
let _ = p.clear(ClearBuffer::All);
- p.write_all(MAGIC).estr()?;
+ p.write_all(magic).estr()?;
if read_byte(p)? != Some(0x06) {
- return Err("no response to identify (radio off, wrong cable/port, or not a TD-H3?)".into());
+ return Err(format!(
+ "no response to identify (radio off, wrong cable/port, or not a {model}?)"
+ ));
}
p.write_all(&[0x02]).estr()?;
@@ -456,7 +468,7 @@ pub(crate) fn do_ident(p: &mut dyn SerialPort) -> Result, String> {
/// Read one memory block: `R` + addr(BE) + size, then header `W`+addr+size,
/// `size` data bytes, and a trailing checksum byte (verified).
-fn read_block(p: &mut dyn SerialPort, start: u16, size: u8) -> Result, String> {
+pub(crate) fn read_block(p: &mut dyn SerialPort, start: u16, size: u8) -> Result, String> {
let msg = [b'R', (start >> 8) as u8, (start & 0xFF) as u8, size];
p.write_all(&msg).estr()?;
@@ -484,9 +496,18 @@ fn read_block(p: &mut dyn SerialPort, start: u16, size: u8) -> Result, S
/// Faithful port of `_do_download`: ident prefix, then 0x20-byte blocks from
/// radio 0x0000 up to `_memsize` (the final block reads to a 0x2000 span).
pub(crate) fn download(p: &mut dyn SerialPort, ident: &[u8]) -> Result, String> {
+ download_to(p, ident, MEMSIZE)
+}
+
+/// [`download`] up to another model's `_memsize`.
+pub(crate) fn download_to(
+ p: &mut dyn SerialPort,
+ ident: &[u8],
+ memsize: u16,
+) -> Result, String> {
let mut data = ident.to_vec();
let mut addr = 0u16;
- while addr < MEMSIZE {
+ while addr < memsize {
data.extend(read_block(p, addr, BLOCK as u8)?);
addr += BLOCK;
}
@@ -600,7 +621,7 @@ fn decode_tone_field(val: u32) -> String {
}
/// Combine the decoded RX/TX tone fields into one summary cell.
-fn decode_tone_summary(rxtone: u32, txtone: u32) -> String {
+pub(crate) fn decode_tone_summary(rxtone: u32, txtone: u32) -> String {
let tx = decode_tone_field(txtone);
let rx = decode_tone_field(rxtone);
match (tx.is_empty(), rx.is_empty()) {
@@ -614,7 +635,7 @@ fn decode_tone_summary(rxtone: u32, txtone: u32) -> String {
/// Little-endian BCD (CHIRP `lbcd`): byte[0] is the least-significant digit
/// pair; within a byte the high nibble is tens, the low nibble is ones.
-fn lbcd_to_u32(b: &[u8]) -> u32 {
+pub(crate) fn lbcd_to_u32(b: &[u8]) -> u32 {
let mut v = 0u32;
let mut mult = 1u32;
for &byte in b {
@@ -676,11 +697,20 @@ pub(crate) fn slug_label(label: &str) -> String {
/// Re-establish a clone session, retrying over a few seconds since the radio can
/// still be settling right after a full read.
pub(crate) fn reident(p: &mut dyn SerialPort) -> Result, String> {
+ reident_with(p, MAGIC, "TD-H3")
+}
+
+/// [`reident`] with another model's magic.
+pub(crate) fn reident_with(
+ p: &mut dyn SerialPort,
+ magic: &[u8],
+ model: &str,
+) -> Result, String> {
const ATTEMPTS: usize = 5;
let mut last = String::from("no contact with radio");
for attempt in 0..ATTEMPTS {
let _ = p.clear(ClearBuffer::All);
- match do_ident(p) {
+ match do_ident_with(p, magic, model) {
Ok(ident) => return Ok(ident),
Err(e) => {
last = e;
@@ -805,7 +835,7 @@ fn name_bytes(name: &str) -> [u8; NAME_LEN] {
}
/// Encode RX/TX frequency (MHz) as the radio's little-endian BCD (freq/10 Hz).
-fn freq_to_lbcd(mhz: f64) -> [u8; 4] {
+pub(crate) fn freq_to_lbcd(mhz: f64) -> [u8; 4] {
let mut value = (mhz * 100_000.0).round() as u32; // MHz -> units of 10 Hz
let mut out = [0u8; 4];
for b in out.iter_mut() {
@@ -873,7 +903,7 @@ fn tone_dtcs(code: &Option, reverse: bool) -> [u8; 2] {
/// (rxtone, txtone) field pair using the TD-H3 BCD tone encoding. tone_mode
/// follows the project's universal scheme (off/Tone/TSQL/DTCS/Cross); the
/// per-side split mirrors CHIRP `split_tone_encode` (see the UV-5R `encode_tones`).
-fn encode_tones(c: &Channel) -> ([u8; 2], [u8; 2]) {
+pub(crate) fn encode_tones(c: &Channel) -> ([u8; 2], [u8; 2]) {
let pol = c.dcs_polarity.as_bytes();
let tx_rev = pol.first() == Some(&b'R');
let rx_rev = pol.get(1) == Some(&b'R');
@@ -915,8 +945,13 @@ fn encode_tones(c: &Channel) -> ([u8; 2], [u8; 2]) {
/// Upload the whole main range in 0x20-byte `W` blocks (data + 1 checksum byte),
/// then send `E` to leave programming mode. Buffer offset = radio address + 8.
pub(crate) fn upload(p: &mut dyn SerialPort, image: &[u8]) -> Result<(), String> {
+ upload_to(p, image, UPLOAD_END)
+}
+
+/// [`upload`] up to another model's end of range (CHIRP `_ranges_main`).
+pub(crate) fn upload_to(p: &mut dyn SerialPort, image: &[u8], end: u16) -> Result<(), String> {
let mut addr = 0u16;
- while addr < UPLOAD_END {
+ while addr < end {
let off = addr as usize + 8;
send_block(p, addr, &image[off..off + BLOCK as usize])?;
addr += BLOCK;
diff --git a/src-tauri/src/radios/tidradio_tdh8/fake_tests.rs b/src-tauri/src/radios/tidradio_tdh8/fake_tests.rs
new file mode 100644
index 0000000..6251a3c
--- /dev/null
+++ b/src-tauri/src/radios/tidradio_tdh8/fake_tests.rs
@@ -0,0 +1,203 @@
+//! The TD-H8 family's clone session against a mock radio (#168).
+//!
+//! [`FakeTdh8`] answers the protocol CHIRP's `tdh8.py` speaks — the model's
+//! magic, `0x02` for the ident, the second `0x06`, then `R` / `W` blocks of
+//! 0x20 with a one-byte sum — and records what it was sent. It proves the
+//! SEQUENCING: that the whole range is read, that a program writes the whole
+//! range and ends with `E` only when something changed, that a refused block
+//! stops the write, that a radio answering another ident is refused before a
+//! byte is read.
+//!
+//! ⚠ It cannot prove the wire format or that a model is right: it replays what
+//! CHIRP (and the hardware-proven TD-H3) believe. Nobody here has put one of
+//! these radios on a cable.
+
+use super::*;
+use crate::radios::fake_port::{FakePort, FakeRadio};
+
+pub(crate) struct FakeTdh8 {
+ magic: &'static [u8],
+ ident: [u8; 8],
+ /// Radio address space.
+ pub mem: Vec,
+ pub reads: Vec,
+ pub writes: Vec,
+ pub ends: usize,
+ pub idents: usize,
+ /// Refuse (answer 0x15 to) a write of this address.
+ pub refuse_write: Option,
+ /// 0 = idle, 1 = magic acked, 2 = ident sent, 3 = clone mode.
+ state: u8,
+}
+
+impl FakeTdh8 {
+ pub fn new(v: &Variant, ident: &[u8; 6]) -> Self {
+ let mut id = [0xFFu8; 8];
+ id[..6].copy_from_slice(ident);
+ let mut mem = vec![0xFFu8; 0x10000];
+ mem[0x0CA9] = 0x05; // something that is not 0xFF in the settings
+ Self {
+ magic: v.magic,
+ ident: id,
+ mem,
+ reads: Vec::new(),
+ writes: Vec::new(),
+ ends: 0,
+ idents: 0,
+ refuse_write: None,
+ state: 0,
+ }
+ }
+
+ /// The image a download of `v` should produce.
+ pub fn image(&self, v: &Variant) -> Vec {
+ let mut out = self.ident.to_vec();
+ out.extend_from_slice(&self.mem[..v.layout.image_len() - IDENT_LEN]);
+ out
+ }
+}
+
+impl FakeRadio for FakeTdh8 {
+ fn step(&mut self, req: &[u8], out: &mut Vec) -> usize {
+ if req.is_empty() {
+ return 0;
+ }
+ // The TD-H3 is re-identified with no `E` after a read: a magic is taken
+ // in any state, as the real one evidently does.
+ if req[0] == b'P' {
+ if req.len() < self.magic.len() {
+ return 0;
+ }
+ if &req[..self.magic.len()] == self.magic {
+ out.push(0x06);
+ self.state = 1;
+ self.idents += 1;
+ }
+ return self.magic.len();
+ }
+ match (self.state, req[0]) {
+ (1, 0x02) => {
+ out.extend_from_slice(&self.ident);
+ self.state = 2;
+ 1
+ }
+ (2, 0x06) => {
+ out.push(0x06);
+ self.state = 3;
+ 1
+ }
+ (3, b'R') => {
+ if req.len() < 4 {
+ return 0;
+ }
+ let addr = u16::from_be_bytes([req[1], req[2]]);
+ let n = req[3] as usize;
+ self.reads.push(addr);
+ let data = &self.mem[addr as usize..addr as usize + n];
+ out.extend_from_slice(&[b'W', req[1], req[2], req[3]]);
+ out.extend_from_slice(data);
+ out.push(data.iter().fold(0u8, |a, &b| a.wrapping_add(b)));
+ 4
+ }
+ (3, b'W') => {
+ if req.len() < 4 {
+ return 0;
+ }
+ let n = req[3] as usize;
+ if req.len() < 4 + n + 1 {
+ return 0;
+ }
+ let addr = u16::from_be_bytes([req[1], req[2]]);
+ let data = &req[4..4 + n];
+ let sum = data.iter().fold(0u8, |a, &b| a.wrapping_add(b));
+ assert_eq!(sum, req[4 + n], "bad checksum on the block at 0x{addr:04X}");
+ if self.refuse_write == Some(addr) {
+ out.push(0x15);
+ } else {
+ self.mem[addr as usize..addr as usize + n].copy_from_slice(data);
+ self.writes.push(addr);
+ out.push(0x06);
+ }
+ 5 + n
+ }
+ (3, b'E') => {
+ self.ends += 1;
+ self.state = 0;
+ 1
+ }
+ (s, b) => panic!("byte 0x{b:02X} in state {s}"),
+ }
+ }
+}
+
+fn port(r: FakeTdh8) -> FakePort {
+ FakePort::new(r)
+}
+
+#[test]
+fn a_download_reads_every_block_below_memsize() {
+ for v in family() {
+ let mut p = port(FakeTdh8::new(v, v.ident));
+ let id = ident(&mut p, v).unwrap();
+ let image = download(&mut p, v, &id).unwrap();
+ assert_eq!(image.len(), v.layout.image_len(), "{}", v.key);
+ assert_eq!(image, p.radio.image(v), "{}", v.key);
+ let want: Vec = (0..v.layout.memsize).step_by(BLOCK).collect();
+ assert_eq!(p.radio.reads, want, "{}", v.key);
+ }
+}
+
+#[test]
+fn a_radio_answering_another_ident_is_refused_before_a_read() {
+ let mut p = port(FakeTdh8::new(&TDH8, IDENT_HAM));
+ let e = ident(&mut p, &TDH8).unwrap_err();
+ assert!(e.contains("HAM model"), "{e}");
+ assert!(p.radio.reads.is_empty());
+}
+
+#[test]
+fn a_write_covers_the_whole_range_ends_with_e_and_reads_back() {
+ for v in family() {
+ let mut p = port(FakeTdh8::new(v, v.ident));
+ let id = ident(&mut p, v).unwrap();
+ let base = download(&mut p, v, &id).unwrap();
+ let mut image = base.clone();
+ image[CHANNEL_BASE + ENTRY_LEN] = 0x00; // channel 1's first byte
+ let (ok, note) = write_and_verify(&mut p, v, &image).unwrap();
+ assert!(ok, "{}: {note:?}", v.key);
+ let want: Vec = (0..v.layout.memsize).step_by(BLOCK).collect();
+ assert_eq!(p.radio.writes, want, "{}", v.key);
+ assert_eq!(p.radio.ends, 1, "{}", v.key);
+ assert_eq!(p.radio.image(v), image, "{}", v.key);
+ }
+}
+
+#[test]
+fn a_refused_block_stops_the_write() {
+ let v = &TDH8;
+ let mut p = port(FakeTdh8::new(v, v.ident));
+ p.radio.refuse_write = Some(0x0100);
+ let id = ident(&mut p, v).unwrap();
+ let mut image = download(&mut p, v, &id).unwrap();
+ image[0x0200] ^= 0xFF;
+ let e = write_and_verify(&mut p, v, &image).unwrap_err();
+ assert!(e.contains("0x0100"), "{e}");
+ assert_eq!(p.radio.writes.last(), Some(&0x00E0), "stopped at the refusal");
+}
+
+#[test]
+fn a_read_back_that_differs_is_reported_not_hidden() {
+ // A radio that takes a block but keeps something else: the fake stores
+ // what it is sent, so make the image the radio "keeps" differ by writing
+ // a byte the driver never sends — the ident region is not compared, so
+ // use a mismatch the comparison must see.
+ let v = &TDH8;
+ let mut p = port(FakeTdh8::new(v, v.ident));
+ let id = ident(&mut p, v).unwrap();
+ let base = download(&mut p, v, &id).unwrap();
+ assert!(compare(&base, &base).is_none());
+ let mut other = base.clone();
+ other[0x0CA9] ^= 0x01;
+ let why = compare(&base, &other).unwrap();
+ assert!(why.contains("0x0CA1"), "{why}"); // radio address = image offset - 8
+}
diff --git a/src-tauri/src/radios/tidradio_tdh8/mod.rs b/src-tauri/src/radios/tidradio_tdh8/mod.rs
new file mode 100644
index 0000000..d587fbb
--- /dev/null
+++ b/src-tauri/src/radios/tidradio_tdh8/mod.rs
@@ -0,0 +1,930 @@
+//! TIDRADIO TD-H8 family (`driver_key = "tidradio_tdh8"` and its siblings) —
+//! Experimental (#168).
+//!
+//! Ported from CHIRP's `chirp/drivers/tdh8.py` (GPLv2-or-later, by the CHIRP
+//! contributors; CHIRP b63b38d1). Nobody here owns one of these radios: nothing
+//! about them has been confirmed on hardware, so every model ships Experimental
+//! and the app warns before every write. See `docs/radios/tidradio-tdh8-family.md`.
+//!
+//! One `Variant` per CHIRP class, each in a folder of its own holding a
+//! `Variant` and a [`TidradioTdh8`] around it (the UV-17Pro family's pattern).
+//!
+//! ## The clone session
+//!
+//! The TD-H3's, which is hardware-proven here (`radios/tidradio_tdh3`): 38400
+//! 8N1; a 7-byte magic answered `0x06`, `0x02` answered with the 8-byte ident,
+//! `0x06` answered `0x06`; then `R hi lo 20` reads and `W hi lo 20 `
+//! writes of 0x20 bytes, from 0 up to the model's `_memsize`, and `E` at the end
+//! of a write. This driver calls the TD-H3's own functions with each model's
+//! magic and memory size ([`tidradio_tdh3::do_ident_with`] and friends) — the
+//! same bytes CHIRP sends, the only difference between the models on the wire.
+//!
+//! ## Three memory layouts
+//!
+//! | layout | models | image | names | used / scan bitmaps |
+//! |---|---|---|---|---|
+//! | H8 | TD-H8 (1st/2nd gen), TD-H8 HAM | 8 + 0x1F00 | 16-byte cells at 0x0D48 | 0x1A08 / 0x1A28 |
+//! | H3 | TD-H8 3rd Gen (+ HAM) — the TD-H3's own layout | 8 + 0x2000 | 8-byte cells at 0x0D48 | 0x1908 / 0x1928 |
+//! | RT-730 | Radtel RT-730 | 8 + 0x6400 | 8-byte cells at 0x0D48 | 0x1A08 / 0x1A28 |
+//!
+//! Image offsets include the 8-byte ident the image starts with (CHIRP's
+//! `#seekto` values). The 16-byte channel record at `0x0008 + 16 × N` is the
+//! same in all three for every bit this driver writes. Channel N (1-199) keeps
+//! its name and flags at N-1, as on the TD-H3.
+//!
+//! ⚠ What a mock radio proves here is the port, not the radio: the session is
+//! tested against a fake that answers the protocol CHIRP believes in.
+
+pub(crate) mod settings;
+pub(crate) mod settings_table;
+
+#[cfg(test)]
+mod fake_tests;
+#[cfg(test)]
+mod oracle;
+
+use std::time::Duration;
+
+use serde::Serialize;
+use serialport::SerialPort;
+
+use crate::commands::export;
+use crate::commands::export::SlotChannel;
+use crate::models::{Channel, RadioModel};
+use crate::radios::baofeng_uv5r::{chirp_metadata_model, CHIRP_METADATA_MAGIC};
+use crate::radios::driver::{
+ CodeplugProgramReport, DecodedChannelSample, ImageProgramRequest, ImageProgrammer, ImageReader,
+ ImageRestorer, RadioDriver, RadioIdentity,
+};
+use crate::radios::tidradio_tdh3 as tdh3;
+
+use settings_table::{Field, FIELDS_H3, FIELDS_H8, FIELDS_RT730};
+
+/// Between one clone session and the next. The TD-H3's program flow waits one
+/// second before re-identifying and retries for several more.
+const SETTLE: Duration = Duration::from_secs(1);
+const BLOCK: usize = 0x20;
+const IDENT_LEN: usize = 8;
+const CHANNEL_BASE: usize = 0x0008;
+const ENTRY_LEN: usize = 16;
+const NAME_BASE: usize = 0x0D48;
+const NAME_LEN: usize = 8;
+/// Channels 1-199 (CHIRP `memory_bounds = (1, 199)`; `memory[0]` is unused).
+pub(crate) const MAX_CHANNEL: usize = 199;
+
+/// One of CHIRP's three memory formats.
+pub(crate) struct Layout {
+ pub name: &'static str,
+ /// CHIRP `_memsize`: reads run in 0x20 blocks from 0 while below it, and a
+ /// write covers the same range (`_ranges_main`).
+ pub memsize: u16,
+ /// Distance between two names (`names[200]`): 16 on the H8, whose name cell
+ /// is followed by 8 bytes CHIRP does not map.
+ pub name_stride: usize,
+ /// `lbit usedflags[200]`.
+ pub used_base: usize,
+ /// `lbit scanadd[200]`.
+ pub scan_base: usize,
+ pub fields: &'static [Field],
+}
+
+impl Layout {
+ /// The whole image: the ident, then every block a download reads.
+ pub(crate) const fn image_len(&self) -> usize {
+ IDENT_LEN + (self.memsize as usize).div_ceil(BLOCK) * BLOCK
+ }
+}
+
+/// CHIRP `MEM_FORMAT`: the 1st/2nd generation TD-H8.
+pub(crate) static LAYOUT_H8: Layout = Layout {
+ name: "H8",
+ memsize: 0x1EEF,
+ name_stride: 16,
+ used_base: 0x1A08,
+ scan_base: 0x1A28,
+ fields: FIELDS_H8,
+};
+
+/// CHIRP `MEM_FORMAT_H3`: the TD-H3's layout, used by the TD-H8 3rd Gen.
+pub(crate) static LAYOUT_H3: Layout = Layout {
+ name: "H3",
+ memsize: 0x1FEF,
+ name_stride: 8,
+ used_base: 0x1908,
+ scan_base: 0x1928,
+ fields: FIELDS_H3,
+};
+
+/// CHIRP `MEM_FORMAT_RT730`.
+pub(crate) static LAYOUT_RT730: Layout = Layout {
+ name: "RT-730",
+ memsize: 0x6400,
+ name_stride: 8,
+ used_base: 0x1A08,
+ scan_base: 0x1A28,
+ fields: FIELDS_RT730,
+};
+
+/// CHIRP `TD_H8 = b'PVOJH\x1c\x14'`.
+pub(crate) const MAGIC_H8: &[u8] = b"PVOJH\x1c\x14";
+/// CHIRP `TD_H8_G3 = b'PVOJH<\x14'`.
+pub(crate) const MAGIC_H8_G3: &[u8] = b"PVOJH\x3c\x14";
+/// CHIRP `RT_730 = b'PGOJH\xc3D'`.
+pub(crate) const MAGIC_RT730: &[u8] = b"PGOJH\xc3D";
+
+/// The ident CHIRP's unrestricted classes expect (`ident_mode`, first six bytes).
+pub(crate) const IDENT_OPEN: &[u8; 6] = b"P31183";
+/// The ident of the HAM-locked units.
+pub(crate) const IDENT_HAM: &[u8; 6] = b"P31185";
+/// The GMRS units' ident: not supported (#168 skips GMRS radios).
+const IDENT_GMRS: &[u8; 6] = b"P31184";
+
+/// Low, Mid, High as stored (CHIRP `_tx_power`), in the app's spelling.
+pub(crate) const POWER_LMH: &[&str] = &["Low", "Med", "High"];
+
+/// One model.
+pub(crate) struct Variant {
+ /// `driver_key`, which is also the folder name.
+ pub key: &'static str,
+ /// What the app and the README call it.
+ pub display_name: &'static str,
+ /// Short model name for messages.
+ pub short: &'static str,
+ /// The handshake magic (CHIRP `_idents[0]`).
+ pub magic: &'static [u8],
+ /// The ident this model answers (CHIRP `ident_mode`). A radio answering the
+ /// magic with another is refused before anything is read.
+ pub ident: &'static [u8; 6],
+ pub layout: &'static Layout,
+ /// Power labels in stored order.
+ pub power: &'static [&'static str],
+ /// The model receives the 108-136 MHz air band (AM there, as CHIRP decodes).
+ pub am: bool,
+ /// The model names CHIRP writes in an `.img`'s metadata for this radio.
+ pub chirp_models: &'static [&'static str],
+ /// Backup file-name prefix (`tdh8-prewrite-….img`).
+ pub file_prefix: &'static str,
+ /// [`RadioDriver::hardware_verified`].
+ pub hardware_verified: bool,
+}
+
+/// The TD-H8 (1st / 2nd generation), unrestricted.
+pub(crate) static TDH8: Variant = Variant {
+ key: "tidradio_tdh8",
+ display_name: "TIDRADIO TD-H8",
+ short: "TD-H8",
+ magic: MAGIC_H8,
+ ident: IDENT_OPEN,
+ layout: &LAYOUT_H8,
+ power: POWER_LMH,
+ am: false,
+ chirp_models: &["TD-H8"],
+ file_prefix: "tdh8",
+ hardware_verified: false,
+};
+
+/// Registry entry for the TD-H8 itself.
+pub(crate) static DRIVER: TidradioTdh8 = TidradioTdh8(&TDH8);
+
+/// Every backup prefix in the family, and the TD-H3's: a sibling's backup is
+/// the same shape (the TD-H3's and the 3rd Gen's are the same length and
+/// ident), so a restore refuses it by name. Each model is listed twice: the
+/// program and settings paths name a backup by `file_prefix`, the generic
+/// Download by `driver_key` (`tidradio_tdh3-20260821-172203.img`).
+const FAMILY_PREFIXES: &[(&str, &str)] = &[
+ ("tdh8", "TD-H8"),
+ ("tidradio_tdh8", "TD-H8"),
+ ("tdh8ham", "TD-H8 HAM"),
+ ("tidradio_tdh8ham", "TD-H8 HAM"),
+ ("tdh8g3", "TD-H8 3rd Gen"),
+ ("tidradio_tdh8g3", "TD-H8 3rd Gen"),
+ ("tdh8g3ham", "TD-H8 3rd Gen HAM"),
+ ("tidradio_tdh8g3ham", "TD-H8 3rd Gen HAM"),
+ ("rt730", "RT-730"),
+ ("radtel_rt730", "RT-730"),
+ ("tdh3", "TD-H3"),
+ ("tidradio_tdh3", "TD-H3"),
+];
+
+/// Every family member, for tests that must cover them all.
+#[cfg(test)]
+pub(crate) fn family() -> Vec<&'static Variant> {
+ vec![
+ &TDH8,
+ &crate::radios::tidradio_tdh8ham::VARIANT,
+ &crate::radios::tidradio_tdh8g3::VARIANT,
+ &crate::radios::tidradio_tdh8g3ham::VARIANT,
+ &crate::radios::radtel_rt730::VARIANT,
+ ]
+}
+
+/// The driver: a [`Variant`] and the shared session code.
+pub(crate) struct TidradioTdh8(pub &'static Variant);
+
+impl RadioDriver for TidradioTdh8 {
+ fn key(&self) -> &'static str {
+ self.0.key
+ }
+
+ fn display_name(&self) -> &'static str {
+ self.0.display_name
+ }
+
+ fn hardware_verified(&self) -> bool {
+ self.0.hardware_verified
+ }
+
+ fn baud(&self) -> u32 {
+ 38400
+ }
+
+ fn analog_modes(&self) -> &'static [&'static str] {
+ if self.0.am {
+ &["FM", "NFM", "AM"]
+ } else {
+ &["FM", "NFM"]
+ }
+ }
+
+ fn identify(&self, port: &str) -> Result {
+ let mut p = tdh3::open_port(port)?;
+ let ident = ident(&mut *p, self.0)?;
+ Ok(identity(&ident))
+ }
+
+ fn as_image_programmer(&self) -> Option<&dyn ImageProgrammer> {
+ Some(self)
+ }
+
+ fn as_image_restorer(&self) -> Option<&dyn ImageRestorer> {
+ Some(self)
+ }
+
+ fn as_settings_reader(&self) -> Option<&dyn crate::radios::driver::SettingsReader> {
+ Some(self)
+ }
+
+ fn as_settings_writer(&self) -> Option<&dyn crate::radios::driver::SettingsWriter> {
+ Some(self)
+ }
+}
+
+fn identity(ident: &[u8]) -> RadioIdentity {
+ RadioIdentity {
+ matched: tdh3::ascii(&ident[..6.min(ident.len())]),
+ ident_hex: tdh3::hex(ident),
+ ident_ascii: Some(tdh3::ascii(ident)),
+ }
+}
+
+impl ImageRestorer for TidradioTdh8 {
+ fn check_restore_image(&self, image: &[u8]) -> Result<(), String> {
+ check_restore_image_for(self.0, &restore_image_for(self.0, image)?)
+ }
+
+ /// CHIRP's trailer is not sent.
+ fn restore_len(&self, image: &[u8]) -> usize {
+ restore_image_for(self.0, image).map_or(image.len(), |i| i.len())
+ }
+
+ fn check_restore_file_name(&self, file_name: &str) -> Result<(), String> {
+ check_restore_file_name_for(self.0, file_name)
+ }
+
+ /// The whole range back, as CHIRP's upload writes it, then a read-back.
+ fn restore_image(&self, port: &str, image: &[u8]) -> Result<(), String> {
+ let image = restore_image_for(self.0, image)?;
+ check_restore_image_for(self.0, &image)?;
+ let v = self.0;
+ let mut p = tdh3::open_port(port)?;
+ ident(&mut *p, v)?;
+ tdh3::upload_to(&mut *p, &image, v.layout.memsize)?;
+ std::thread::sleep(SETTLE);
+ // Every block was acknowledged by now: a read-back that cannot run must
+ // say so, or it reads as a restore that never happened.
+ let back = reident(&mut *p, v).and_then(|i| download(&mut *p, v, &i)).map_err(|e| {
+ format!(
+ "the radio acknowledged every block of the restore, but it could not be read \
+ back to confirm ({e}). Power-cycle the radio and use Download to check it \
+ before restoring again."
+ )
+ })?;
+ match compare(&image, &back) {
+ None => Ok(()),
+ Some(why) => Err(format!(
+ "the radio acknowledged the restore, but {why}. The radio does NOT hold this \
+ backup. Power-cycle it and try the restore again."
+ )),
+ }
+ }
+}
+
+impl ImageReader for TidradioTdh8 {
+ fn download_image(&self, port: &str) -> Result<(RadioIdentity, Vec), String> {
+ let mut p = tdh3::open_port(port)?;
+ let id = ident(&mut *p, self.0)?;
+ let image = download(&mut *p, self.0, &id)?;
+ Ok((identity(&id), image))
+ }
+
+ fn decode_sample(&self, image: &[u8]) -> Vec {
+ decode_channels(self.0, image).into_iter().map(decoded_to_sample).collect()
+ }
+}
+
+impl ImageProgrammer for TidradioTdh8 {
+ /// Yes: the settings sit in the range a program writes anyway, and the
+ /// encoder is a patch — a key the profile does not carry stays as read.
+ fn carries_profile_settings(&self) -> bool {
+ true
+ }
+
+ fn upload_image(&self, port: &str, image: &[u8]) -> Result<(), String> {
+ check_restore_image_for(self.0, image)?;
+ let mut p = tdh3::open_port(port)?;
+ ident(&mut *p, self.0)?;
+ tdh3::upload_to(&mut *p, image, self.0.layout.memsize)
+ }
+
+ fn build_image(
+ &self,
+ model: &RadioModel,
+ channels: &[SlotChannel],
+ base: &[u8],
+ ) -> Result, String> {
+ let v = self.0;
+ let len = v.layout.image_len();
+ if base.len() != len {
+ return Err(format!(
+ "base image is {} bytes, not a {} image ({len}).",
+ base.len(),
+ v.short
+ ));
+ }
+ if channels.len() > MAX_CHANNEL {
+ return Err(format!(
+ "{} channels exceed the {}'s {MAX_CHANNEL} memories.",
+ channels.len(),
+ v.short
+ ));
+ }
+ let mut image = base.to_vec();
+ patch_image(v, model, &mut image, channels);
+ Ok(image)
+ }
+
+ /// Download and back up, patch channels (and the profile's settings) into
+ /// that image so every byte not owned goes back as read, write the range,
+ /// read back and compare.
+ fn program_codeplug(
+ &self,
+ port: &str,
+ req: &ImageProgramRequest,
+ ) -> Result {
+ let v = self.0;
+ if req.channels.len() > MAX_CHANNEL {
+ return Err(format!(
+ "Codeplug has {} programmable channels, but the {} holds only {MAX_CHANNEL}.",
+ req.channels.len(),
+ v.short
+ ));
+ }
+ let stamp = chrono::Local::now().format("%Y%m%d-%H%M%S");
+ let backup_path = req.backup_dir.join(backup_filename(v, "prewrite", req.label, &stamp));
+
+ // 1. Download + back up.
+ let mut p = tdh3::open_port(port)?;
+ let id = ident(&mut *p, v)?;
+ let base = download(&mut *p, v, &id)?;
+ std::fs::write(&backup_path, &base)
+ .map_err(|e| format!("could not write backup {}: {e}", backup_path.display()))?;
+
+ // 2. Patch channels, then the profile's settings, into what was read.
+ let mut image = base.clone();
+ let channels_written = req.channels.len();
+ patch_image(v, req.model, &mut image, req.channels);
+ let settings_written = match req.settings {
+ Some((settings, schema)) => {
+ let settings_json = serde_json::to_string(settings)
+ .map_err(|e| format!("invalid profile settings: {e}"))?;
+ Some(settings::apply_profile_settings_for(v, &mut image, schema, &settings_json)?)
+ }
+ None => None,
+ };
+
+ // 3. Write, in a fresh session, unless nothing changed.
+ let (verified, note) = if image == base {
+ (true, Some("The radio already held this codeplug — nothing was written.".into()))
+ } else {
+ let restore_hint = |e: String| {
+ crate::radios::driver::with_restore_hint(
+ e,
+ &backup_path,
+ "Restore it with \"Restore backup…\" in the Program dialog and pick that \
+ file. Do not program again first — a second write would overwrite the \
+ half-written contents with a fresh backup of them.",
+ )
+ };
+ write_and_verify(&mut *p, v, &image).map_err(restore_hint)?
+ };
+
+ Ok(CodeplugProgramReport {
+ channels_written,
+ slots_cleared: MAX_CHANNEL - channels_written,
+ settings_written,
+ verified: Some(verified),
+ note,
+ backup_path: backup_path.to_string_lossy().to_string(),
+ channels: decode_channels(v, &image).into_iter().map(decoded_to_sample).collect(),
+ zones_written: 0,
+ zones_cleared: 0,
+ banks_written: 0,
+ scan_lists_written: 0,
+ scan_lists_cleared: 0,
+ contacts_written: 0,
+ contacts_cleared: 0,
+ expected_path: None,
+ windows_written: Vec::new(),
+ skipped: Vec::new(),
+ warnings: Vec::new(),
+ })
+ }
+}
+
+/// Re-identify, write the whole range, read back and compare. An error means
+/// the write itself failed; a read-back that cannot run or that differs is a
+/// `(false, note)`, since every block was acknowledged.
+///
+/// The whole range goes out, as CHIRP writes it and as the TD-H3 is proven to
+/// take it. Nobody has measured whether one of these radios commits a block
+/// written alone, so a narrower write would be the untested path.
+fn write_and_verify(
+ p: &mut dyn SerialPort,
+ v: &Variant,
+ image: &[u8],
+) -> Result<(bool, Option), String> {
+ std::thread::sleep(SETTLE);
+ reident(p, v)?;
+ tdh3::upload_to(p, image, v.layout.memsize)?;
+ std::thread::sleep(SETTLE);
+ Ok(match reident(p, v).and_then(|i| download(p, v, &i)) {
+ Ok(back) => match compare(image, &back) {
+ None => (true, None),
+ Some(why) => (
+ false,
+ Some(format!(
+ "Read-back differs from what was written: {why}. The backup is saved if \
+ you need to revert."
+ )),
+ ),
+ },
+ Err(e) => (
+ false,
+ Some(format!(
+ "Write completed, but read-back verification could not run ({e}). \
+ Power-cycle the radio and use Download to confirm."
+ )),
+ ),
+ })
+}
+
+// ============================================================
+// Session (the TD-H3's functions, with this model's magic and size)
+// ============================================================
+
+/// Handshake with the model's magic and refuse a radio answering another
+/// model's ident. Reads no memory.
+pub(crate) fn ident(p: &mut dyn SerialPort, v: &Variant) -> Result, String> {
+ let id = tdh3::do_ident_with(p, v.magic, v.short)?;
+ check_ident(v, &id)?;
+ Ok(id)
+}
+
+/// [`ident`] for the second session of a program, which may find the radio
+/// still settling after a full read.
+fn reident(p: &mut dyn SerialPort, v: &Variant) -> Result, String> {
+ let id = tdh3::reident_with(p, v.magic, v.short)?;
+ check_ident(v, &id)?;
+ Ok(id)
+}
+
+/// The two bytes after the model code in every CHIRP `ident_mode`
+/// (`b'P31183\xff\xff'`).
+const IDENT_TAIL: &[u8; 2] = b"\xff\xff";
+
+/// CHIRP's upload refuses a radio whose ident is not the class's whole 8-byte
+/// `ident_mode` ("Model mismatch!"); this refuses it before the first read as
+/// well.
+pub(crate) fn check_ident(v: &Variant, id: &[u8]) -> Result<(), String> {
+ if id.len() == IDENT_LEN && &id[..6] == v.ident && &id[6..] == IDENT_TAIL {
+ return Ok(());
+ }
+ let seen = tdh3::ascii(id);
+ let hint = if id.starts_with(v.ident) {
+ " The model code matches, but the ident's last bytes are not the FF FF CHIRP expects \
+ (another firmware?), so it is not treated as this model."
+ } else if id.starts_with(IDENT_HAM) {
+ " That is the ident of a HAM-locked unit: pick the HAM model of this radio."
+ } else if id.starts_with(IDENT_OPEN) {
+ " That is the ident of an unrestricted unit: pick the model without HAM in its name."
+ } else if id.starts_with(IDENT_GMRS) {
+ " That is the ident of a GMRS unit, which CodePlug Magic does not support."
+ } else {
+ ""
+ };
+ Err(format!(
+ "the radio identifies as \"{seen}\" ({}), not the {} this model expects (\"{}\" FF FF). \
+ Nothing was read or written.{hint}",
+ tdh3::hex(id),
+ v.short,
+ tdh3::ascii(v.ident)
+ ))
+}
+
+/// The whole image, ident first: CHIRP's `_do_download`.
+pub(crate) fn download(p: &mut dyn SerialPort, v: &Variant, id: &[u8]) -> Result, String> {
+ let image = tdh3::download_to(p, id, v.layout.memsize)?;
+ if image.len() != v.layout.image_len() {
+ return Err(format!(
+ "the read came back {} bytes, not the {} of a {} image (CHIRP's {} layout)",
+ image.len(),
+ v.layout.image_len(),
+ v.short,
+ v.layout.name
+ ));
+ }
+ Ok(image)
+}
+
+/// `None` when every byte past the ident matches, else how many and where.
+fn compare(want: &[u8], got: &[u8]) -> Option {
+ if want.len() != got.len() {
+ return Some(format!("{} bytes came back for {}", got.len(), want.len()));
+ }
+ let differ: Vec = (IDENT_LEN..want.len()).filter(|&i| want[i] != got[i]).collect();
+ differ.first().map(|&i| {
+ format!(
+ "{} byte(s) read back differently, first at radio address 0x{:04X} (wrote 0x{:02X}, \
+ read back 0x{:02X})",
+ differ.len(),
+ i - IDENT_LEN,
+ want[i],
+ got[i]
+ )
+ })
+}
+
+// ============================================================
+// Restore files
+// ============================================================
+
+/// A file picked for restore, as this driver's image. A CHIRP-saved `.img` is
+/// the image followed by CHIRP's metadata trailer, which is dropped; the file
+/// is refused unless the metadata names one of this model's
+/// [`Variant::chirp_models`].
+pub(crate) fn restore_image_for<'a>(
+ v: &Variant,
+ file: &'a [u8],
+) -> Result, String> {
+ let n = v.layout.image_len();
+ if file.len() <= n || !file[n..].starts_with(CHIRP_METADATA_MAGIC) {
+ return Ok(std::borrow::Cow::Borrowed(file));
+ }
+ let model = chirp_metadata_model(&file[n + CHIRP_METADATA_MAGIC.len()..]).ok_or_else(|| {
+ "this file has CHIRP's metadata, but it does not say which radio it came from, so it \
+ is not written to one."
+ .to_string()
+ })?;
+ if !v.chirp_models.iter().any(|m| m.eq_ignore_ascii_case(&model)) {
+ return Err(format!(
+ "CHIRP saved this file as a {model}, not a {}. Pick a backup taken from a {}.",
+ v.short, v.short
+ ));
+ }
+ Ok(std::borrow::Cow::Borrowed(&file[..n]))
+}
+
+/// Exactly the model's image length, starting with this model's ident.
+pub(crate) fn check_restore_image_for(v: &Variant, image: &[u8]) -> Result<(), String> {
+ let n = v.layout.image_len();
+ let short = v.short;
+ if image.len() != n {
+ return Err(format!(
+ "this file is {} bytes — a {short} backup is exactly {n}. Pick a .img taken from a \
+ {short} (radio-backups/ also holds images for other radios, which must not be \
+ written to this one).",
+ image.len()
+ ));
+ }
+ if &image[..6] != v.ident {
+ return Err(format!(
+ "this file starts with the ident \"{}\", not the {short}'s \"{}\" — it was taken \
+ from another radio and is not written to this one.",
+ tdh3::ascii(&image[..6]),
+ tdh3::ascii(v.ident)
+ ));
+ }
+ Ok(())
+}
+
+/// A backup this app took from a sibling (or from a TD-H3) can be the same
+/// shape as this model's own; refuse it by the prefix in its name. A name with
+/// no family prefix (a CHIRP `.img`, a renamed file) is allowed.
+pub(crate) fn check_restore_file_name_for(v: &Variant, file_name: &str) -> Result<(), String> {
+ let lower = file_name.to_ascii_lowercase();
+ let writer = FAMILY_PREFIXES
+ .iter()
+ .filter(|(prefix, _)| lower.starts_with(&format!("{prefix}-")))
+ .max_by_key(|(prefix, _)| prefix.len());
+ match writer {
+ Some((prefix, model)) if *prefix != v.file_prefix && *prefix != v.key => Err(format!(
+ "{file_name} is a backup this app took from a {model}, not a {}. It is not written \
+ to this radio. Pick a {}-… backup.",
+ v.short, v.file_prefix
+ )),
+ _ => Ok(()),
+ }
+}
+
+pub(crate) fn backup_filename(
+ v: &Variant,
+ kind: &str,
+ label: &str,
+ stamp: &impl std::fmt::Display,
+) -> String {
+ let slug = tdh3::slug_label(label);
+ if slug.is_empty() {
+ format!("{}-{kind}-{stamp}.img", v.file_prefix)
+ } else {
+ format!("{}-{kind}-{slug}-{stamp}.img", v.file_prefix)
+ }
+}
+
+// ============================================================
+// Channels (CHIRP `get_memory` / `set_memory`)
+// ============================================================
+
+/// One memory as decoded from an image.
+#[derive(Debug, Clone, PartialEq, Serialize)]
+pub struct DecodedChannel {
+ pub index: usize,
+ pub name: String,
+ pub rx_mhz: f64,
+ /// `None` = no transmit frequency (CHIRP duplex "off").
+ pub tx_mhz: Option,
+ pub tone: String,
+ pub power: String,
+ pub mode: String,
+}
+
+/// CHIRP `AIRBAND = (108000000, 135999999)`: AM whatever the record says.
+fn in_airband(mhz: f64) -> bool {
+ (108.0..136.0).contains(&mhz)
+}
+
+fn name_at(v: &Variant, n: usize) -> usize {
+ NAME_BASE + (n - 1) * v.layout.name_stride
+}
+
+pub(crate) fn decode_channels(v: &Variant, image: &[u8]) -> Vec {
+ let mut out = Vec::new();
+ for n in 1..=MAX_CHANNEL {
+ let at = CHANNEL_BASE + n * ENTRY_LEN;
+ let m = &image[at..at + ENTRY_LEN];
+ if m[0] == 0xFF {
+ continue; // CHIRP: an empty slot starts with 0xFF
+ }
+ let rx_mhz = tdh3::lbcd_to_u32(&m[0..4]) as f64 / 100_000.0;
+ let tx_mhz = if m[4..8] == [0xFF; 4] {
+ None
+ } else {
+ Some(tdh3::lbcd_to_u32(&m[4..8]) as f64 / 100_000.0)
+ };
+ let rxtone = tdh3::lbcd_to_u32(&m[8..10]);
+ let txtone = tdh3::lbcd_to_u32(&m[10..12]);
+ // CHIRP falls back to the first level when the index is out of range.
+ let power = v.power.get(((m[14] >> 4) & 0x03) as usize).unwrap_or(&v.power[0]);
+ let mode = if in_airband(rx_mhz) {
+ "AM"
+ } else if m[14] & 0x08 != 0 {
+ "NFM"
+ } else {
+ "FM"
+ };
+ let na = name_at(v, n);
+ let name = image[na..na + NAME_LEN]
+ .iter()
+ .take_while(|&&b| b != 0x00 && b != 0xFF)
+ .map(|&b| if (0x20..0x7F).contains(&b) { b as char } else { ' ' })
+ .collect::()
+ .trim_end()
+ .to_string();
+ out.push(DecodedChannel {
+ index: n,
+ name,
+ rx_mhz,
+ tx_mhz,
+ tone: tdh3::decode_tone_summary(rxtone, txtone),
+ power: power.to_string(),
+ mode: mode.to_string(),
+ });
+ }
+ out
+}
+
+/// CHIRP's `TDH8_CHARSET`: letters, digits, space and these.
+const NAME_PUNCT: &str = "!@#$%^&*()+-=[]:\";'<>?,./";
+
+/// The 8 name cells as CHIRP's `set_memory` writes them: the name, then 0x00.
+/// A character outside CHIRP's set becomes a space.
+fn name_bytes(name: &str) -> [u8; NAME_LEN] {
+ let mut out = [0u8; NAME_LEN];
+ for (i, ch) in name.chars().take(NAME_LEN).enumerate() {
+ out[i] = if ch.is_ascii_alphanumeric() || ch == ' ' || NAME_PUNCT.contains(ch) {
+ ch as u8
+ } else {
+ b' '
+ };
+ }
+ out
+}
+
+/// The stored power index. CHIRP stores `_tx_power.index(mem.power or
+/// _tx_power[-1])`: unset is the top level. "Mid" and "Medium" are this
+/// family's Med.
+fn power_index(v: &Variant, c: &Channel) -> u8 {
+ let p = c.power.as_deref().unwrap_or("");
+ let p = if p.eq_ignore_ascii_case("Mid") || p.eq_ignore_ascii_case("Medium") { "Med" } else { p };
+ v.power
+ .iter()
+ .position(|l| l.eq_ignore_ascii_case(p))
+ .unwrap_or(v.power.len() - 1) as u8
+}
+
+/// One 16-byte record as CHIRP's `set_memory` builds it with no extras: zeros,
+/// then frequencies, tones, bandwidth and power. PTT-ID, BCL and frequency hop
+/// stay zero.
+fn encode_channel(v: &Variant, c: &Channel, rx_only: bool) -> [u8; ENTRY_LEN] {
+ let mut m = [0u8; ENTRY_LEN];
+ m[0..4].copy_from_slice(&tdh3::freq_to_lbcd(c.rx_freq));
+ if rx_only {
+ m[4..8].fill(0xFF); // CHIRP duplex "off", and any frequency off the TX bands
+ } else {
+ m[4..8].copy_from_slice(&tdh3::freq_to_lbcd(export::tx_frequency(c)));
+ }
+ let (rxtone, txtone) = tdh3::encode_tones(c);
+ m[8..10].copy_from_slice(&rxtone);
+ m[10..12].copy_from_slice(&txtone);
+ // CHIRP: `wide = 0` for FM, 1 for anything else (NFM, and AM in the air band).
+ let fm = c.mode.as_deref().is_none_or(|s| s.eq_ignore_ascii_case("FM"));
+ m[14] = (power_index(v, c) << 4) | (u8::from(!fm) << 3);
+ m
+}
+
+/// Set or clear bit `k` of an `lbit` bitmap.
+fn set_flag(image: &mut [u8], base: usize, k: usize, on: bool) {
+ let mask = 1u8 << (k % 8);
+ if on {
+ image[base + k / 8] |= mask;
+ } else {
+ image[base + k / 8] &= !mask;
+ }
+}
+
+/// Lay the channels into their slots (slot s = channel s + 1); every other
+/// channel is emptied as CHIRP empties one — the record to 0xFF and its used
+/// flag cleared, its name and scan flag left as they were.
+pub(crate) fn patch_image(v: &Variant, model: &RadioModel, image: &mut [u8], slots: &[SlotChannel]) {
+ let mut assigned: Vec> = vec![None; MAX_CHANNEL + 1];
+ for s in slots {
+ if s.slot < MAX_CHANNEL {
+ assigned[s.slot + 1] = Some(s);
+ }
+ }
+ for (n, slot) in assigned.iter().enumerate().skip(1) {
+ let at = CHANNEL_BASE + n * ENTRY_LEN;
+ let k = n - 1;
+ match slot {
+ Some(s) => {
+ let rx_only = matches!(
+ export::channel_fit(&s.channel, model),
+ export::ChannelFit::ReceiveOnly(_)
+ );
+ image[at..at + ENTRY_LEN].copy_from_slice(&encode_channel(v, &s.channel, rx_only));
+ let na = name_at(v, n);
+ image[na..na + NAME_LEN].copy_from_slice(&name_bytes(&s.name));
+ set_flag(image, v.layout.used_base, k, true);
+ set_flag(image, v.layout.scan_base, k, true);
+ }
+ None => {
+ image[at..at + ENTRY_LEN].fill(0xFF);
+ set_flag(image, v.layout.used_base, k, false);
+ }
+ }
+ }
+}
+
+fn decoded_to_sample(c: DecodedChannel) -> DecodedChannelSample {
+ DecodedChannelSample {
+ index: c.index,
+ name: c.name,
+ rx_mhz: c.rx_mhz,
+ shift: Some(match c.tx_mhz {
+ None => "RX-only".to_string(),
+ Some(tx) if (tx - c.rx_mhz).abs() < 1e-9 => String::new(),
+ Some(tx) => format!("{:+.3}", tx - c.rx_mhz),
+ }),
+ tone: c.tone,
+ power: c.power,
+ mode: Some(c.mode),
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn image_lengths_are_chirps() {
+ // CHIRP's images: 8-byte ident + every 0x20 block below _memsize.
+ assert_eq!(LAYOUT_H8.image_len(), 0x1F08);
+ assert_eq!(LAYOUT_H3.image_len(), 0x2008);
+ assert_eq!(LAYOUT_RT730.image_len(), 0x6408);
+ // The 3rd Gen is the TD-H3's layout, so the TD-H3's image length.
+ assert_eq!(LAYOUT_H3.image_len(), tdh3::MEMSIZE as usize + 8 + 0x11);
+ }
+
+ #[test]
+ fn family_prefixes_and_keys_are_unique_and_listed() {
+ let mut keys = std::collections::HashSet::new();
+ let mut prefixes = std::collections::HashSet::new();
+ for v in family() {
+ assert!(keys.insert(v.key), "{} twice", v.key);
+ assert!(prefixes.insert(v.file_prefix), "{} twice", v.file_prefix);
+ assert!(
+ FAMILY_PREFIXES.iter().any(|(p, _)| *p == v.file_prefix),
+ "{} not in FAMILY_PREFIXES",
+ v.file_prefix
+ );
+ assert!(!v.hardware_verified, "{} is Experimental", v.key);
+ }
+ }
+
+ #[test]
+ fn a_wrong_ident_is_refused_with_the_model_to_pick() {
+ let e = check_ident(&TDH8, b"P31185\xff\xff").unwrap_err();
+ assert!(e.contains("HAM model"), "{e}");
+ let e = check_ident(&crate::radios::tidradio_tdh8ham::VARIANT, b"P31183\xff\xff").unwrap_err();
+ assert!(e.contains("without HAM"), "{e}");
+ assert!(check_ident(&TDH8, b"P31184\xff\xff").unwrap_err().contains("GMRS"));
+ assert!(check_ident(&TDH8, b"P31183\xff\xff").is_ok());
+ // CHIRP compares all eight bytes, so does this.
+ let e = check_ident(&TDH8, b"P31183\x01\xff").unwrap_err();
+ assert!(e.contains("last bytes"), "{e}");
+ assert!(check_ident(&TDH8, b"P31183").is_err());
+ }
+
+ #[test]
+ fn restore_refuses_a_td_h3_backup_on_the_3rd_gen() {
+ let g3 = &crate::radios::tidradio_tdh8g3::VARIANT;
+ assert!(check_restore_file_name_for(g3, "tdh3-prewrite-20260821.img").is_err());
+ // The generic Download names a backup by driver key.
+ assert!(check_restore_file_name_for(g3, "tidradio_tdh3-20260821-172203.img").is_err());
+ assert!(check_restore_file_name_for(g3, "tidradio_tdh8g3-20261204-120000.img").is_ok());
+ assert!(check_restore_file_name_for(&TDH8, "tidradio_tdh8g3-20261204.img").is_err());
+ assert!(check_restore_file_name_for(g3, "tdh8g3-prewrite-20261204.img").is_ok());
+ // `tdh8-` is a prefix of `tdh8g3-` and `tdh8ham-`: the longest one wins.
+ assert!(check_restore_file_name_for(&TDH8, "tdh8g3-prewrite-x.img").is_err());
+ assert!(check_restore_file_name_for(&TDH8, "tdh8-prewrite-x.img").is_ok());
+ assert!(check_restore_file_name_for(&TDH8, "TIDRADIO_TD-H8.img").is_ok());
+ }
+
+ #[test]
+ fn power_unset_is_high_and_mid_is_med() {
+ let mut c = Channel { rx_freq: 146.52, ..Default::default() };
+ assert_eq!(power_index(&TDH8, &c), 2);
+ c.power = Some("Mid".into());
+ assert_eq!(power_index(&TDH8, &c), 1);
+ c.power = Some("Low".into());
+ assert_eq!(power_index(&TDH8, &c), 0);
+ }
+
+ #[test]
+ fn an_air_band_channel_decodes_as_am() {
+ let v = &crate::radios::tidradio_tdh8g3::VARIANT;
+ let mut image = vec![0xFFu8; v.layout.image_len()];
+ let c = Channel {
+ rx_freq: 121.5,
+ mode: Some("AM".into()),
+ dcs_polarity: "NN".into(),
+ ..Default::default()
+ };
+ let at = CHANNEL_BASE + ENTRY_LEN;
+ image[at..at + ENTRY_LEN].copy_from_slice(&encode_channel(v, &c, true));
+ let d = decode_channels(v, &image);
+ assert_eq!(d.len(), 1);
+ assert_eq!(d[0].mode, "AM");
+ assert_eq!(d[0].tx_mhz, None);
+ assert_eq!(image[at + 14] & 0x08, 0x08, "CHIRP sets `wide` for AM");
+ }
+}
diff --git a/src-tauri/src/radios/tidradio_tdh8/oracle.rs b/src-tauri/src/radios/tidradio_tdh8/oracle.rs
new file mode 100644
index 0000000..1f683ec
--- /dev/null
+++ b/src-tauri/src/radios/tidradio_tdh8/oracle.rs
@@ -0,0 +1,283 @@
+//! The CHIRP oracle for the TD-H8 family (#168).
+//!
+//! For each model, on CHIRP's radio-authored image for that class: our image
+//! of a fixed channel matrix laid over all 199 channels (the rest emptied), and
+//! our image of a settings pass that sets every field in the model's schema to
+//! a value the base does not hold. `scripts/tidradio_tdh8_family/chirp_oracle.py`
+//! makes CHIRP's `tdh8.py` do the same on the same base and diffs the WHOLE
+//! image. It proves the PORT matches CHIRP — not that CHIRP's map is right for
+//! any of these radios; only a radio can say that.
+//!
+//! ```sh
+//! CHIRP_SRC=… TDH8_OUT=/tmp/tdh8-oracle \
+//! cargo test --lib tidradio_tdh8::oracle -- --ignored --nocapture
+//! CHIRP_SRC=… python3.12 -I ../scripts/tidradio_tdh8_family/chirp_oracle.py /tmp/tdh8-oracle
+//! ```
+
+use serde_json::{json, Value};
+
+use super::*;
+
+/// (seed model name, variant, CHIRP class name, CHIRP test image)
+fn models() -> Vec<(&'static str, &'static Variant, &'static str, &'static str)> {
+ vec![
+ ("TD-H8", &TDH8, "TDH8", "TIDRADIO_TD-H8.img"),
+ ("TD-H8 HAM", &crate::radios::tidradio_tdh8ham::VARIANT, "TDH8_HAM", "TIDRADIO_TD-H8-HAM.img"),
+ ("TD-H8 3rd Gen", &crate::radios::tidradio_tdh8g3::VARIANT, "TDH8_3rd_Gen", "TIDRADIO_TD-H8-HAM_G3.img"),
+ (
+ "TD-H8 3rd Gen HAM",
+ &crate::radios::tidradio_tdh8g3ham::VARIANT,
+ "TDH8_3rd_Gen_HAM",
+ "TIDRADIO_TD-H8-HAM_G3.img",
+ ),
+ ("RT-730", &crate::radios::radtel_rt730::VARIANT, "RT730", "Radtel_RT-730.img"),
+ ]
+}
+
+struct Row {
+ name: &'static str,
+ ch: Channel,
+ /// The same memory in CHIRP's terms (`chirp_common.Memory` fields).
+ chirp: Value,
+}
+
+fn c(rx: f64) -> Channel {
+ Channel { rx_freq: rx, mode: Some("FM".into()), dcs_polarity: "NN".into(), ..Default::default() }
+}
+
+fn mem(freq: f64, duplex: &str, offset: f64) -> Value {
+ json!({"freq": (freq * 1e6).round() as u64, "duplex": duplex,
+ "offset": (offset * 1e6).round() as u64, "tmode": "", "rtone": 88.5, "ctone": 88.5,
+ "dtcs": 23, "rx_dtcs": 23, "dtcs_polarity": "NN", "cross_mode": "Tone->Tone",
+ "mode": "FM", "power": "High"})
+}
+
+fn matrix() -> Vec {
+ let row = |name, ch, chirp| Row { name, ch, chirp };
+ let mut m = Vec::new();
+ m.push(row("Simplex", c(146.52), mem(146.52, "", 0.0)));
+
+ let mut x = c(146.94);
+ x.duplex = Some("-".into());
+ x.offset = Some(0.6);
+ x.tone_mode = Some("Tone".into());
+ x.ctcss_uplink = Some(100.0);
+ let mut j = mem(146.94, "-", 0.6);
+ j["tmode"] = json!("Tone");
+ j["rtone"] = json!(100.0);
+ m.push(row("RPT-", x, j));
+
+ let mut x = c(147.3);
+ x.duplex = Some("+".into());
+ x.offset = Some(0.6);
+ x.tone_mode = Some("TSQL".into());
+ x.ctcss_downlink = Some(103.5);
+ x.mode = Some("NFM".into());
+ x.power = Some("Low".into());
+ let mut j = mem(147.3, "+", 0.6);
+ j["tmode"] = json!("TSQL");
+ j["ctone"] = json!(103.5);
+ j["mode"] = json!("NFM");
+ j["power"] = json!("Low");
+ m.push(row("TSQL", x, j));
+
+ let mut x = c(444.0);
+ x.duplex = Some("+".into());
+ x.offset = Some(5.0);
+ x.tone_mode = Some("DTCS".into());
+ x.dcs_code = Some("023".into());
+ let mut j = mem(444.0, "+", 5.0);
+ j["tmode"] = json!("DTCS");
+ m.push(row("DCS", x, j));
+
+ let mut x = c(443.5);
+ x.duplex = Some("+".into());
+ x.offset = Some(5.0);
+ x.tone_mode = Some("DTCS".into());
+ x.dcs_code = Some("754".into());
+ x.dcs_polarity = "RN".into();
+ let mut j = mem(443.5, "+", 5.0);
+ j["tmode"] = json!("DTCS");
+ j["dtcs"] = json!(754);
+ j["rx_dtcs"] = json!(754);
+ j["dtcs_polarity"] = json!("RN");
+ m.push(row("DCS-R", x, j));
+
+ let mut x = c(145.2);
+ x.tone_mode = Some("Cross".into());
+ x.cross_mode = "DTCS->Tone".into();
+ x.dcs_code = Some("645".into());
+ x.ctcss_downlink = Some(88.5);
+ let mut j = mem(145.2, "", 0.0);
+ j["tmode"] = json!("Cross");
+ j["cross_mode"] = json!("DTCS->Tone");
+ j["dtcs"] = json!(645);
+ m.push(row("X-DT 645", x, j));
+
+ let mut x = c(146.0);
+ x.tone_mode = Some("Cross".into());
+ x.cross_mode = "Tone->DTCS".into();
+ x.ctcss_uplink = Some(123.0);
+ x.dcs_rx_code = Some("025".into());
+ x.dcs_polarity = "NR".into();
+ let mut j = mem(146.0, "", 0.0);
+ j["tmode"] = json!("Cross");
+ j["cross_mode"] = json!("Tone->DTCS");
+ j["rtone"] = json!(123.0);
+ j["rx_dtcs"] = json!(25);
+ j["dtcs_polarity"] = json!("NR");
+ m.push(row("x-td low", x, j));
+
+ let mut x = c(446.0);
+ x.tx_freq = Some(146.0);
+ x.duplex = Some("split".into());
+ m.push(row("SPLIT", x, mem(446.0, "split", 146.0)));
+
+ let mut x = c(146.6);
+ x.power = Some("Med".into());
+ let mut j = mem(146.6, "", 0.0);
+ j["power"] = json!("Mid");
+ m.push(row("MID", x, j));
+
+ m.push(row("WX1", c(162.55), mem(162.55, "", 0.0)));
+ m.push(row("Long name here", c(440.0), mem(440.0, "", 0.0)));
+ m.push(row("UHF500", c(500.0), mem(500.0, "", 0.0)));
+ m.push(row("220", c(223.5), mem(223.5, "", 0.0)));
+ m.push(row("GMRS", c(462.5625), mem(462.5625, "", 0.0)));
+
+ let mut x = c(121.5);
+ x.mode = Some("AM".into());
+ let mut j = mem(121.5, "", 0.0);
+ j["mode"] = json!("AM");
+ m.push(row("AIR", x, j));
+ m.push(row("UHF350", c(360.0), mem(360.0, "", 0.0)));
+ m.push(row("HF", c(29.6), mem(29.6, "", 0.0)));
+ m
+}
+
+/// A value for every schema field that is not what the base holds, so every
+/// field the settings pass claims to write has to land.
+fn settings_for(v: &Variant, schema: &str, base: &[u8]) -> Value {
+ let decoded = settings::decode_settings_from_image(v, base, schema).unwrap();
+ let fields: Value = serde_json::from_str(schema).unwrap();
+ let mut out = serde_json::Map::new();
+ for f in fields.as_array().unwrap() {
+ let key = f["key"].as_str().unwrap();
+ let val = match f["type"].as_str().unwrap() {
+ "section" => continue,
+ "boolean" => json!(!decoded.get(key).and_then(Value::as_bool).unwrap_or(false)),
+ "select" => {
+ let opts = f["options"].as_array().unwrap();
+ let cur = decoded.get(key).cloned().unwrap_or(Value::Null);
+ let pick = if opts[1] != cur { &opts[1] } else { opts.last().unwrap() };
+ pick.clone()
+ }
+ _ => match key {
+ k if k.starts_with("poweron_msg.") => json!("Hello CPM"),
+ "icode" => json!("1A3"),
+ k if k.starts_with("group") => json!("12AB"),
+ "scode" => json!("7D0"),
+ "ecode" => json!("90C1234"),
+ k => panic!("no oracle value for text field {k}"),
+ },
+ };
+ out.insert(key.to_string(), val);
+ }
+ Value::Object(out)
+}
+
+#[test]
+#[ignore]
+fn oracle() {
+ let chirp = std::env::var("CHIRP_SRC").expect("set CHIRP_SRC");
+ let out = std::path::PathBuf::from(std::env::var("TDH8_OUT").expect("set TDH8_OUT"));
+ std::fs::create_dir_all(&out).unwrap();
+
+ for (model, v, class, file) in models() {
+ let raw = std::fs::read(std::path::Path::new(&chirp).join("tests/images").join(file)).unwrap();
+ let base = raw[..v.layout.image_len()].to_vec(); // a CHIRP .img carries a trailer
+
+ let seed = crate::seed::test_model(model);
+ // Only rows the model can hold at all: an excluded channel never
+ // reaches the encoder in the app.
+ let rows: Vec = matrix()
+ .into_iter()
+ .filter(|r| !matches!(export::channel_fit(&r.ch, &seed), export::ChannelFit::Excluded(_)))
+ .collect();
+ let slots: Vec = rows
+ .iter()
+ .enumerate()
+ .map(|(i, r)| SlotChannel { slot: i, name: r.name.to_string(), channel: r.ch.clone() })
+ .collect();
+ let mut img = base.clone();
+ patch_image(v, &seed, &mut img, &slots);
+
+ let chirp_rows: Vec = rows
+ .iter()
+ .enumerate()
+ .map(|(i, r)| {
+ let mut j = r.chirp.clone();
+ j["number"] = json!(i + 1);
+ j["name"] = json!(r.name);
+ // Our encoder decided receive-only by the seed's bands; tell
+ // CHIRP the same, as its duplex "off".
+ let rec = CHANNEL_BASE + (i + 1) * ENTRY_LEN;
+ if img[rec + 4..rec + 8] == [0xFF; 4] {
+ j["duplex"] = json!("off");
+ j["offset"] = json!(0);
+ }
+ j
+ })
+ .collect();
+
+ let schema = seed.non_channel_settings_schema.clone().unwrap();
+ let wanted = settings_for(v, &schema, &base);
+ let mut set = base.clone();
+ let n = settings::apply_profile_settings_for(v, &mut set, &schema, &wanted.to_string()).unwrap();
+
+ let dir = out.join(v.key);
+ std::fs::create_dir_all(&dir).unwrap();
+ let anchor: Vec = decode_channels(v, &base)
+ .into_iter()
+ .map(|d| json!({"n": d.index, "name": d.name, "freq": d.rx_mhz, "tx": d.tx_mhz,
+ "power": d.power, "mode": d.mode, "tone": d.tone}))
+ .collect();
+ std::fs::write(dir.join("base.bin"), &base).unwrap();
+ std::fs::write(dir.join("anchor_ours.json"), serde_json::to_string_pretty(&anchor).unwrap()).unwrap();
+ std::fs::write(dir.join("ours.bin"), &img).unwrap();
+ std::fs::write(dir.join("settings_ours.bin"), &set).unwrap();
+ std::fs::write(dir.join("matrix.json"), serde_json::to_string_pretty(&chirp_rows).unwrap()).unwrap();
+ std::fs::write(
+ dir.join("settings.json"),
+ serde_json::to_string_pretty(&json!({"class": class, "values": wanted})).unwrap(),
+ )
+ .unwrap();
+ println!("{model:18} {} memories, {n} settings -> {}", chirp_rows.len(), dir.display());
+ }
+}
+
+/// The restore gate against real files: every `.img` in the directories named
+/// by `TDH8_GATE_DIRS` (`:`-separated), under every family model. Prints which
+/// models would take each file; a person reads the table.
+#[test]
+#[ignore]
+fn restore_gate_on_real_files() {
+ let dirs = std::env::var("TDH8_GATE_DIRS").expect("set TDH8_GATE_DIRS");
+ for dir in dirs.split(':') {
+ let mut names: Vec<_> = std::fs::read_dir(dir).unwrap().flatten().map(|e| e.path()).collect();
+ names.sort();
+ for p in names.into_iter().filter(|p| p.extension().is_some_and(|e| e == "img")) {
+ let file = std::fs::read(&p).unwrap();
+ let name = p.file_name().unwrap().to_string_lossy().into_owned();
+ let takers: Vec<&str> = family()
+ .iter()
+ .filter(|v| {
+ restore_image_for(v, &file).is_ok_and(|i| check_restore_image_for(v, &i).is_ok())
+ && check_restore_file_name_for(v, &name).is_ok()
+ })
+ .map(|v| v.key)
+ .collect();
+ println!("{name:48} {:6} {}", file.len(), if takers.is_empty() { "-".into() } else { takers.join(",") });
+ }
+ }
+}
diff --git a/src-tauri/src/radios/tidradio_tdh8/settings.rs b/src-tauri/src/radios/tidradio_tdh8/settings.rs
new file mode 100644
index 0000000..eeb1a93
--- /dev/null
+++ b/src-tauri/src/radios/tidradio_tdh8/settings.rs
@@ -0,0 +1,405 @@
+//! TD-H8 family non-channel settings: read out of, and written into, the
+//! clone image.
+//!
+//! The tables in `settings_table.rs` and each model's form schema come from one
+//! run of `scripts/tidradio_tdh8_family/gen_settings.py`, which measured what
+//! CHIRP's `tdh8.py` writes for every option. The encoder writes exactly that
+//! (the oracle proves it); where it departs, it says so:
+//!
+//! - a blank text field (power-on message, DTMF code) leaves the radio's bytes
+//! alone. CHIRP writes it as spaces / 0xFF; a blank field here is "not set",
+//! not a value (the same rule as the Baofeng families);
+//! - a select label the schema does not list is left alone;
+//! - a DTMF code read back with a gap in it (a digit after a 0xFF) decodes as
+//! blank, so it is never rewritten without the gap.
+//!
+//! The write is a patch: a key the profile does not carry stays as read.
+
+use std::collections::HashMap;
+
+use serde_json::{json, Value};
+
+use crate::radios::driver::{SettingsCapture, SettingsReader, SettingsWriteReport, SettingsWriter};
+use crate::radios::tidradio_tdh3 as tdh3;
+
+use super::settings_table::{Field, Kind};
+use super::{backup_filename, download, ident, write_and_verify, TidradioTdh8, Variant};
+
+/// The DTMF digits CHIRP's `dtmfcharsani` allows: stored as their value.
+const DTMF_CHARS: &[u8] = b"0123456789ABCD";
+
+impl SettingsReader for TidradioTdh8 {
+ /// One session: the image read doubles as the backup.
+ fn read_settings(&self, port: &str, schema_json: &str) -> Result {
+ let mut p = tdh3::open_port(port)?;
+ let id = ident(&mut *p, self.0)?;
+ let image = download(&mut *p, self.0, &id)?;
+ let settings = decode_settings_from_image(self.0, &image, schema_json)?;
+ Ok(SettingsCapture { settings, backup: image, backup_ext: "img" })
+ }
+}
+
+impl SettingsWriter for TidradioTdh8 {
+ /// The profile's settings alone, channels untouched: download and back up,
+ /// apply, write the range (channels inside it go back as read), read back
+ /// and compare.
+ fn write_settings(
+ &self,
+ port: &str,
+ settings: &Value,
+ schema_json: &str,
+ backup_dir: &std::path::Path,
+ ) -> Result {
+ let v = self.0;
+ let stamp = chrono::Local::now().format("%Y%m%d-%H%M%S");
+ let backup_path = backup_dir.join(backup_filename(v, "presettings", "", &stamp));
+ let mut p = tdh3::open_port(port)?;
+ let id = ident(&mut *p, v)?;
+ let base = download(&mut *p, v, &id)?;
+ std::fs::write(&backup_path, &base)
+ .map_err(|e| format!("could not write backup {}: {e}", backup_path.display()))?;
+
+ let mut image = base.clone();
+ let settings_json =
+ serde_json::to_string(settings).map_err(|e| format!("invalid profile settings: {e}"))?;
+ let fields_written = apply_profile_settings_for(v, &mut image, schema_json, &settings_json)?;
+ let report = |verified, note| SettingsWriteReport {
+ fields_written,
+ verified: Some(verified),
+ note,
+ backup_path: backup_path.to_string_lossy().to_string(),
+ expected_path: None,
+ windows_written: Vec::new(),
+ };
+ if image == base {
+ return Ok(report(
+ true,
+ Some("every setting already matched the radio — nothing was written".into()),
+ ));
+ }
+ let restore_hint = |e: String| {
+ crate::radios::driver::with_restore_hint(
+ e,
+ &backup_path,
+ "Restore it with \"Restore backup…\" in the Program dialog and pick that file.",
+ )
+ };
+ let (ok, note) = write_and_verify(&mut *p, v, &image).map_err(restore_hint)?;
+ Ok(report(ok, note))
+ }
+}
+
+fn field(v: &Variant, key: &str) -> Option<&'static Field> {
+ v.layout.fields.iter().find(|f| f.key == key)
+}
+
+/// The schema's fields that are not section headers, with their options.
+struct SchemaField {
+ key: String,
+ options: Vec,
+}
+
+fn parse_schema(schema_json: &str) -> Result, String> {
+ let schema: Value =
+ serde_json::from_str(schema_json).map_err(|e| format!("invalid settings schema: {e}"))?;
+ let arr = schema.as_array().ok_or("settings schema is not a list")?;
+ Ok(arr
+ .iter()
+ .filter(|f| f.get("type").and_then(Value::as_str) != Some("section"))
+ .filter_map(|f| {
+ let key = f.get("key")?.as_str()?.to_string();
+ let options = f
+ .get("options")
+ .and_then(Value::as_array)
+ .map(|o| o.iter().filter_map(|x| x.as_str().map(str::to_string)).collect())
+ .unwrap_or_default();
+ Some(SchemaField { key, options })
+ })
+ .collect())
+}
+
+// ============================================================
+// Decode
+// ============================================================
+
+/// Every schema field read out of an image. A byte that is not one of the
+/// field's values comes back `null` (blank in the form), never a guess.
+pub(crate) fn decode_settings_from_image(
+ v: &Variant,
+ image: &[u8],
+ schema_json: &str,
+) -> Result {
+ let mut out = serde_json::Map::new();
+ for sf in parse_schema(schema_json)? {
+ let Some(f) = field(v, &sf.key) else { continue };
+ out.insert(sf.key.clone(), read_value(image, f, &sf.options));
+ }
+ Ok(Value::Object(out))
+}
+
+fn read_value(image: &[u8], f: &Field, options: &[String]) -> Value {
+ let raw = &image[f.at..f.at + f.len];
+ match f.kind {
+ Kind::Choice { mask, values } => {
+ let Some(i) = values.iter().position(|&x| x == raw[0] & mask) else {
+ return Value::Null;
+ };
+ if options.is_empty() {
+ // A switch: options false, true.
+ json!(i == 1)
+ } else {
+ options.get(i).map_or(Value::Null, |o| json!(o))
+ }
+ }
+ Kind::Dtmf => {
+ let used = raw.iter().position(|&b| b == 0xFF).unwrap_or(raw.len());
+ if raw[used..].iter().any(|&b| b != 0xFF) {
+ return Value::Null; // a gap: see the module notes
+ }
+ let digits: Option = raw[..used]
+ .iter()
+ .map(|&b| DTMF_CHARS.get(b as usize).map(|&c| c as char))
+ .collect();
+ digits.map_or(Value::Null, |s| json!(s))
+ }
+ // Printable ASCII padded with spaces is the text, trailing spaces off
+ // (writing it back pads it the same way). Nothing printable at all —
+ // a factory 0x00 / 0xFF fill — is blank. Text mixed with other bytes
+ // comes back null: shown, it could only be rewritten without them.
+ Kind::Text => {
+ let printable = |b: &u8| (0x20..0x7F).contains(b);
+ if raw.iter().all(printable) {
+ json!(String::from_utf8_lossy(raw).trim_end())
+ } else if raw.iter().all(|b| *b == 0x20 || !printable(b)) {
+ json!("")
+ } else {
+ Value::Null
+ }
+ }
+ }
+}
+
+// ============================================================
+// Encode
+// ============================================================
+
+/// Apply the profile's values to `image`. Returns how many of the profile's
+/// fields this encoder placed (changed, or already as asked).
+pub(crate) fn apply_profile_settings_for(
+ v: &Variant,
+ image: &mut [u8],
+ schema_json: &str,
+ settings_json: &str,
+) -> Result {
+ let values: HashMap =
+ serde_json::from_str(settings_json).map_err(|e| format!("invalid profile settings: {e}"))?;
+ let mut placed = 0;
+ for sf in parse_schema(schema_json)? {
+ let (Some(f), Some(value)) = (field(v, &sf.key), values.get(&sf.key)) else { continue };
+ if put(image, f, &sf.options, value) {
+ placed += 1;
+ }
+ }
+ Ok(placed)
+}
+
+fn put(image: &mut [u8], f: &Field, options: &[String], value: &Value) -> bool {
+ let at = f.at;
+ match f.kind {
+ Kind::Choice { mask, values } => {
+ let i = if options.is_empty() {
+ value.as_bool().map(usize::from)
+ } else {
+ value.as_str().and_then(|s| options.iter().position(|o| o == s))
+ };
+ match i.and_then(|i| values.get(i)) {
+ Some(&x) => {
+ image[at] = (image[at] & !mask) | x;
+ true
+ }
+ None => false,
+ }
+ }
+ Kind::Dtmf => {
+ let Some(code) = value.as_str().map(str::trim).filter(|s| !s.is_empty()) else {
+ return false;
+ };
+ if code.len() > f.len {
+ return false;
+ }
+ let mut out = vec![0xFFu8; f.len];
+ for (i, c) in code.bytes().enumerate() {
+ match DTMF_CHARS.iter().position(|&d| d == c.to_ascii_uppercase()) {
+ Some(d) => out[i] = d as u8,
+ None => return false,
+ }
+ }
+ image[at..at + f.len].copy_from_slice(&out);
+ true
+ }
+ Kind::Text => {
+ let Some(text) = value.as_str().filter(|s| !s.trim().is_empty()) else {
+ return false;
+ };
+ if text.len() > f.len || !text.bytes().all(|b| (0x20..0x7F).contains(&b)) {
+ return false;
+ }
+ let mut out = vec![b' '; f.len];
+ out[..text.len()].copy_from_slice(text.as_bytes());
+ image[at..at + f.len].copy_from_slice(&out);
+ true
+ }
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use crate::radios::tidradio_tdh8::{family, LAYOUT_H3, TDH8};
+
+ #[test]
+ fn every_schema_key_is_in_its_layouts_table() {
+ for v in family() {
+ let schema = crate::seed::tdh8_family_schema(v.key);
+ for sf in parse_schema(schema).unwrap() {
+ assert!(field(v, &sf.key).is_some(), "{}: {} has no table entry", v.key, sf.key);
+ }
+ }
+ }
+
+ #[test]
+ fn every_table_key_is_on_some_model() {
+ for v in family() {
+ let keys: Vec = family()
+ .into_iter()
+ .filter(|w| std::ptr::eq(w.layout, v.layout))
+ .flat_map(|w| parse_schema(crate::seed::tdh8_family_schema(w.key)).unwrap())
+ .map(|sf| sf.key)
+ .collect();
+ for f in v.layout.fields {
+ assert!(keys.iter().any(|k| k == f.key), "{}: {} is on no form", v.layout.name, f.key);
+ }
+ }
+ }
+
+ #[test]
+ fn select_option_counts_match_the_measured_values() {
+ for v in family() {
+ for sf in parse_schema(crate::seed::tdh8_family_schema(v.key)).unwrap() {
+ let f = field(v, &sf.key).unwrap();
+ if let Kind::Choice { values, .. } = f.kind {
+ // A list may be longer on one model of a layout than on
+ // another (the TD-H8 HAM's step adds 50 kHz from TIDRADIO's
+ // programmer); the table carries the longest, and a shorter
+ // list is its prefix. Every option must have a value.
+ let n = if sf.options.is_empty() { 2 } else { sf.options.len() };
+ assert!(n <= values.len(), "{}: {}", v.key, sf.key);
+ // ...and some model on the layout offers every value.
+ let longest = family()
+ .into_iter()
+ .filter(|w| std::ptr::eq(w.layout, v.layout))
+ .flat_map(|w| parse_schema(crate::seed::tdh8_family_schema(w.key)).unwrap())
+ .filter(|o| o.key == sf.key)
+ .map(|o| if o.options.is_empty() { 2 } else { o.options.len() })
+ .max()
+ .unwrap();
+ assert_eq!(longest, values.len(), "{}: {}", v.layout.name, sf.key);
+ }
+ }
+ }
+ }
+
+ /// The H3 layout is the TD-H3's, whose settings were checked against real
+ /// TD-H3 backups (`tidradio_tdh3::settings`, hand-written from CHIRP). The
+ /// keys both tables carry must name the same bits — a free cross-check of
+ /// the measured table against the one radio of this family on a desk here.
+ #[test]
+ fn the_h3_table_agrees_with_the_td_h3_driver() {
+ let image = vec![0u8; LAYOUT_H3.image_len()];
+ let mut checked = 0;
+ for key in ["squelch", "ligcon", "voxgain", "voxdelay", "scanmode", "ponmsg", "save",
+ "breathled", "mdfa", "mdfb", "btnvoice", "voiceprompt", "keyautolock", "dbrx"]
+ {
+ let f = LAYOUT_H3.fields.iter().find(|f| f.key == key).unwrap();
+ let Kind::Choice { mask, values } = f.kind else { panic!("{key}") };
+ for (i, &x) in values.iter().enumerate() {
+ let mut ours = image.clone();
+ ours[f.at] = x;
+ let label = if key == "btnvoice" || key == "voiceprompt" || key == "keyautolock"
+ || key == "dbrx"
+ {
+ json!(i == 1)
+ } else {
+ json!(i)
+ };
+ let mut theirs = image.clone();
+ let schema = format!(
+ r#"[{{"key": "{key}", "type": "{}"}}]"#,
+ if label.is_boolean() { "boolean" } else { "number" }
+ );
+ tdh3::settings::apply_profile_settings(
+ &mut theirs,
+ &schema,
+ &json!({ key: label }).to_string(),
+ )
+ .unwrap();
+ assert_eq!(theirs[f.at] & mask, ours[f.at], "{key} option {i}");
+ checked += 1;
+ }
+ }
+ assert!(checked > 40);
+ }
+
+ #[test]
+ fn blank_text_and_unknown_labels_leave_the_image_alone() {
+ let schema = crate::seed::tdh8_family_schema(TDH8.key);
+ let mut image = vec![0x5Au8; LAYOUT_H3.image_len().max(TDH8.layout.image_len())];
+ let before = image.clone();
+ let n = apply_profile_settings_for(
+ &TDH8,
+ &mut image,
+ schema,
+ r#"{"icode": "", "poweron_msg.msg1": " ", "squelch": "Nope", "group1": "12*"}"#,
+ )
+ .unwrap();
+ assert_eq!(n, 0);
+ assert_eq!(image, before);
+ }
+
+ #[test]
+ fn a_switch_and_an_inverted_switch_round_trip() {
+ let schema = crate::seed::tdh8_family_schema(TDH8.key);
+ let mut image = vec![0u8; TDH8.layout.image_len()];
+ apply_profile_settings_for(&TDH8, &mut image, schema, r#"{"sync": true, "dbrx": true}"#)
+ .unwrap();
+ // CHIRP stores `sync` inverted: true is the bit CLEAR.
+ assert_eq!(image[0x0CAA] & 0x40, 0x00);
+ assert_eq!(image[0x0CAB] & 0x04, 0x04);
+ let back = decode_settings_from_image(&TDH8, &image, schema).unwrap();
+ assert_eq!(back["sync"], json!(true));
+ assert_eq!(back["dbrx"], json!(true));
+ }
+
+ #[test]
+ fn decode_then_encode_is_a_no_op_on_chirps_images() {
+ let Ok(chirp) = std::env::var("CHIRP_SRC") else { return };
+ let images = [
+ ("tidradio_tdh8", "TIDRADIO_TD-H8.img"),
+ ("tidradio_tdh8ham", "TIDRADIO_TD-H8-HAM.img"),
+ ("tidradio_tdh8g3", "TIDRADIO_TD-H8-HAM_G3.img"),
+ ("tidradio_tdh8g3ham", "TIDRADIO_TD-H8-HAM_G3.img"),
+ ("radtel_rt730", "Radtel_RT-730.img"),
+ ];
+ for (key, file) in images {
+ let v = family().into_iter().find(|v| v.key == key).unwrap();
+ let path = std::path::Path::new(&chirp).join("tests/images").join(file);
+ let Ok(bytes) = std::fs::read(path) else { continue };
+ let image = bytes[..v.layout.image_len()].to_vec();
+ let schema = crate::seed::tdh8_family_schema(key);
+ let decoded = decode_settings_from_image(v, &image, schema).unwrap();
+ let mut again = image.clone();
+ apply_profile_settings_for(v, &mut again, schema, &decoded.to_string()).unwrap();
+ assert!(again == image, "{key}: re-encoding its own settings changed the image");
+ }
+ }
+}
diff --git a/src-tauri/src/radios/tidradio_tdh8/settings_table.rs b/src-tauri/src/radios/tidradio_tdh8/settings_table.rs
new file mode 100644
index 0000000..9b6b487
--- /dev/null
+++ b/src-tauri/src/radios/tidradio_tdh8/settings_table.rs
@@ -0,0 +1,191 @@
+//! TD-H8 family settings tables — GENERATED by
+//! `scripts/tidradio_tdh8_family/gen_settings.py`, do not edit.
+//!
+//! Every setting CHIRP's `tdh8.py` (b63b38d1) offers on any model in the
+//! family, measured by driving CHIRP's own `set_settings` one setting and one
+//! option at a time: where it writes, which bits it owns, and the value each
+//! option stores. One table per memory layout — a key names different bytes on
+//! each. Which keys a model has, and each select's option list, are in its form
+//! schema (`src-tauri/src/tdh8_family/`), generated in the same run.
+//! Not emitted: rxfreqa, rxfreqb, a, b, dira, dirb, fmvfo, block00..block24.
+
+/// How a field is stored.
+#[derive(Clone, Copy, PartialEq, Eq, Debug)]
+pub(crate) enum Kind {
+ /// One byte; the bits in `mask` hold `values[i]` for option `i` (a switch
+ /// is options false, true). Every other bit is left as read.
+ Choice { mask: u8, values: &'static [u8] },
+ /// DTMF digits 0-9 and A-D, one per byte as its value, padded 0xFF.
+ Dtmf,
+ /// ASCII text, padded with spaces.
+ Text,
+}
+
+/// One setting.
+pub(crate) struct Field {
+ /// CHIRP's setting name, which is also the form schema's key.
+ pub key: &'static str,
+ /// Image offset (the image starts with the 8-byte ident).
+ pub at: usize,
+ /// Bytes.
+ pub len: usize,
+ pub kind: Kind,
+}
+
+/// The H8 layout: 59 keys.
+pub(crate) const FIELDS_H8: &[Field] = &[
+ Field { key: "dtmfst", at: 0x0CA8, len: 1, kind: Kind::Choice { mask: 0x02, values: &[0x00, 0x02] } },
+ Field { key: "pritx", at: 0x0CA8, len: 1, kind: Kind::Choice { mask: 0x01, values: &[0x00, 0x01] } },
+ Field { key: "rxled", at: 0x0CA8, len: 1, kind: Kind::Choice { mask: 0x40, values: &[0x00, 0x40] } },
+ Field { key: "txled", at: 0x0CA8, len: 1, kind: Kind::Choice { mask: 0x80, values: &[0x00, 0x80] } },
+ Field { key: "btnvoice", at: 0x0CA9, len: 1, kind: Kind::Choice { mask: 0x04, values: &[0x00, 0x04] } },
+ Field { key: "keyautolock", at: 0x0CA9, len: 1, kind: Kind::Choice { mask: 0x10, values: &[0x00, 0x10] } },
+ Field { key: "scanmode", at: 0x0CA9, len: 1, kind: Kind::Choice { mask: 0xC0, values: &[0x00, 0x40, 0x80] } },
+ Field { key: "voiceprompt", at: 0x0CA9, len: 1, kind: Kind::Choice { mask: 0x01, values: &[0x00, 0x01] } },
+ Field { key: "aworkmode", at: 0x0CAA, len: 1, kind: Kind::Choice { mask: 0x03, values: &[0x00, 0x01, 0x02] } },
+ Field { key: "fmrec", at: 0x0CAA, len: 1, kind: Kind::Choice { mask: 0x08, values: &[0x00, 0x08] } },
+ Field { key: "fmworkmode", at: 0x0CAA, len: 1, kind: Kind::Choice { mask: 0x80, values: &[0x00, 0x80] } },
+ Field { key: "mdfa", at: 0x0CAA, len: 1, kind: Kind::Choice { mask: 0x04, values: &[0x00, 0x04] } },
+ Field { key: "sync", at: 0x0CAA, len: 1, kind: Kind::Choice { mask: 0x40, values: &[0x40, 0x00] } },
+ Field { key: "bworkmode", at: 0x0CAB, len: 1, kind: Kind::Choice { mask: 0x03, values: &[0x00, 0x01, 0x02] } },
+ Field { key: "dbrx", at: 0x0CAB, len: 1, kind: Kind::Choice { mask: 0x04, values: &[0x00, 0x04] } },
+ Field { key: "mdfb", at: 0x0CAB, len: 1, kind: Kind::Choice { mask: 0x10, values: &[0x00, 0x10] } },
+ Field { key: "ponmsg", at: 0x0CAB, len: 1, kind: Kind::Choice { mask: 0xC0, values: &[0x00, 0x40, 0x80] } },
+ Field { key: "fmroad", at: 0x0CAE, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19] } },
+ Field { key: "rogerprompt", at: 0x0CAF, len: 1, kind: Kind::Choice { mask: 0x20, values: &[0x00, 0x20] } },
+ Field { key: "voxgain", at: 0x0CAF, len: 1, kind: Kind::Choice { mask: 0x07, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05] } },
+ Field { key: "astep", at: 0x0CB0, len: 1, kind: Kind::Choice { mask: 0xF0, values: &[0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60] } },
+ Field { key: "bstep", at: 0x0CB0, len: 1, kind: Kind::Choice { mask: 0x0F, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05] } },
+ Field { key: "squelch", at: 0x0CB1, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09] } },
+ Field { key: "tot", at: 0x0CB2, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07] } },
+ Field { key: "lang", at: 0x0CB3, len: 1, kind: Kind::Choice { mask: 0x02, values: &[0x00, 0x02] } },
+ Field { key: "save", at: 0x0CB4, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05] } },
+ Field { key: "ligcon", at: 0x0CB5, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04] } },
+ Field { key: "voxdelay", at: 0x0CB6, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02] } },
+ Field { key: "breathled", at: 0x0CB7, len: 1, kind: Kind::Choice { mask: 0x70, values: &[0x00, 0x10, 0x20, 0x30, 0x40] } },
+ Field { key: "onlychmode", at: 0x0CB7, len: 1, kind: Kind::Choice { mask: 0x80, values: &[0x00, 0x80] } },
+ Field { key: "bcl", at: 0x1B65, len: 1, kind: Kind::Choice { mask: 0x04, values: &[0x00, 0x04] } },
+ Field { key: "specialqta", at: 0x1B65, len: 1, kind: Kind::Choice { mask: 0x20, values: &[0x00, 0x20] } },
+ Field { key: "lowpower", at: 0x1B66, len: 1, kind: Kind::Choice { mask: 0x30, values: &[0x00, 0x10, 0x20] } },
+ Field { key: "wide", at: 0x1B66, len: 1, kind: Kind::Choice { mask: 0x08, values: &[0x00, 0x08] } },
+ Field { key: "bclb", at: 0x1B75, len: 1, kind: Kind::Choice { mask: 0x04, values: &[0x00, 0x04] } },
+ Field { key: "specialqtb", at: 0x1B75, len: 1, kind: Kind::Choice { mask: 0x20, values: &[0x00, 0x20] } },
+ Field { key: "lowpowerb", at: 0x1B76, len: 1, kind: Kind::Choice { mask: 0x30, values: &[0x00, 0x10, 0x20] } },
+ Field { key: "wideb", at: 0x1B76, len: 1, kind: Kind::Choice { mask: 0x08, values: &[0x00, 0x08] } },
+ Field { key: "poweron_msg.msg1", at: 0x1C08, len: 16, kind: Kind::Text },
+ Field { key: "poweron_msg.msg2", at: 0x1C18, len: 16, kind: Kind::Text },
+ Field { key: "poweron_msg.msg3", at: 0x1C28, len: 16, kind: Kind::Text },
+ Field { key: "stopkey1", at: 0x1CC8, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06] } },
+ Field { key: "ssidekey1", at: 0x1CC9, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06] } },
+ Field { key: "ssidekey2", at: 0x1CCA, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06] } },
+ Field { key: "ltopkey2", at: 0x1CCB, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06] } },
+ Field { key: "lsidekey3", at: 0x1CCC, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06] } },
+ Field { key: "lsidekey4", at: 0x1CCD, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06] } },
+ Field { key: "icode", at: 0x1E28, len: 3, kind: Kind::Dtmf },
+ Field { key: "gcode", at: 0x1E31, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0xFF, 0x0E, 0x0F, 0x0A, 0x0B, 0x0C, 0x0D] } },
+ Field { key: "group1", at: 0x1E38, len: 7, kind: Kind::Dtmf },
+ Field { key: "group2", at: 0x1E48, len: 7, kind: Kind::Dtmf },
+ Field { key: "group3", at: 0x1E58, len: 7, kind: Kind::Dtmf },
+ Field { key: "group4", at: 0x1E68, len: 7, kind: Kind::Dtmf },
+ Field { key: "group5", at: 0x1E78, len: 7, kind: Kind::Dtmf },
+ Field { key: "group6", at: 0x1E88, len: 7, kind: Kind::Dtmf },
+ Field { key: "group7", at: 0x1E98, len: 7, kind: Kind::Dtmf },
+ Field { key: "group8", at: 0x1EA8, len: 7, kind: Kind::Dtmf },
+ Field { key: "scode", at: 0x1EC8, len: 7, kind: Kind::Dtmf },
+ Field { key: "ecode", at: 0x1ED8, len: 7, kind: Kind::Dtmf },
+];
+
+/// The H3 layout: 57 keys.
+pub(crate) const FIELDS_H3: &[Field] = &[
+ Field { key: "stopkey1", at: 0x0C98, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06] } },
+ Field { key: "ssidekey1", at: 0x0C99, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06] } },
+ Field { key: "ssidekey2", at: 0x0C9A, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06] } },
+ Field { key: "ltopkey2", at: 0x0C9B, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06] } },
+ Field { key: "lsidekey3", at: 0x0C9C, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06] } },
+ Field { key: "lsidekey4", at: 0x0C9D, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06] } },
+ Field { key: "dtmfst", at: 0x0CA8, len: 1, kind: Kind::Choice { mask: 0x02, values: &[0x00, 0x02] } },
+ Field { key: "pritx", at: 0x0CA8, len: 1, kind: Kind::Choice { mask: 0x01, values: &[0x00, 0x01] } },
+ Field { key: "rxled", at: 0x0CA8, len: 1, kind: Kind::Choice { mask: 0x40, values: &[0x00, 0x40] } },
+ Field { key: "txled", at: 0x0CA8, len: 1, kind: Kind::Choice { mask: 0x80, values: &[0x00, 0x80] } },
+ Field { key: "btnvoice", at: 0x0CA9, len: 1, kind: Kind::Choice { mask: 0x04, values: &[0x00, 0x04] } },
+ Field { key: "keyautolock", at: 0x0CA9, len: 1, kind: Kind::Choice { mask: 0x10, values: &[0x00, 0x10] } },
+ Field { key: "scanmode", at: 0x0CA9, len: 1, kind: Kind::Choice { mask: 0xC0, values: &[0x00, 0x40, 0x80] } },
+ Field { key: "voiceprompt", at: 0x0CA9, len: 1, kind: Kind::Choice { mask: 0x01, values: &[0x00, 0x01] } },
+ Field { key: "aworkmode", at: 0x0CAA, len: 1, kind: Kind::Choice { mask: 0x03, values: &[0x00, 0x01, 0x02] } },
+ Field { key: "fmrec", at: 0x0CAA, len: 1, kind: Kind::Choice { mask: 0x08, values: &[0x00, 0x08] } },
+ Field { key: "fmworkmode", at: 0x0CAA, len: 1, kind: Kind::Choice { mask: 0x80, values: &[0x00, 0x80] } },
+ Field { key: "mdfa", at: 0x0CAA, len: 1, kind: Kind::Choice { mask: 0x04, values: &[0x00, 0x04] } },
+ Field { key: "sync", at: 0x0CAA, len: 1, kind: Kind::Choice { mask: 0x40, values: &[0x40, 0x00] } },
+ Field { key: "bworkmode", at: 0x0CAB, len: 1, kind: Kind::Choice { mask: 0x03, values: &[0x00, 0x01, 0x02] } },
+ Field { key: "dbrx", at: 0x0CAB, len: 1, kind: Kind::Choice { mask: 0x04, values: &[0x00, 0x04] } },
+ Field { key: "mdfb", at: 0x0CAB, len: 1, kind: Kind::Choice { mask: 0x10, values: &[0x00, 0x10] } },
+ Field { key: "ponmsg", at: 0x0CAB, len: 1, kind: Kind::Choice { mask: 0xC0, values: &[0x00, 0x40, 0x80] } },
+ Field { key: "fmroad", at: 0x0CAE, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19] } },
+ Field { key: "voxgain", at: 0x0CAF, len: 1, kind: Kind::Choice { mask: 0x07, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05] } },
+ Field { key: "astep", at: 0x0CB0, len: 1, kind: Kind::Choice { mask: 0xF0, values: &[0x00, 0x10, 0x20, 0x30, 0x40, 0x50] } },
+ Field { key: "bstep", at: 0x0CB0, len: 1, kind: Kind::Choice { mask: 0x0F, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05] } },
+ Field { key: "squelch", at: 0x0CB1, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09] } },
+ Field { key: "rogerprompt", at: 0x0CB3, len: 1, kind: Kind::Choice { mask: 0xC0, values: &[0x00, 0x40] } },
+ Field { key: "save", at: 0x0CB4, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05] } },
+ Field { key: "ligcon", at: 0x0CB5, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04] } },
+ Field { key: "voxdelay", at: 0x0CB6, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02] } },
+ Field { key: "breathled", at: 0x0CB7, len: 1, kind: Kind::Choice { mask: 0x70, values: &[0x00, 0x10, 0x20, 0x30, 0x40] } },
+ Field { key: "onlychmode", at: 0x0CB7, len: 1, kind: Kind::Choice { mask: 0x80, values: &[0x00, 0x80] } },
+ Field { key: "icode", at: 0x1828, len: 3, kind: Kind::Dtmf },
+ Field { key: "gcode", at: 0x1837, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0xFF, 0x0E, 0x0F, 0x0A, 0x0B, 0x0C, 0x0D] } },
+ Field { key: "group1", at: 0x1838, len: 7, kind: Kind::Dtmf },
+ Field { key: "group2", at: 0x1848, len: 7, kind: Kind::Dtmf },
+ Field { key: "group3", at: 0x1858, len: 7, kind: Kind::Dtmf },
+ Field { key: "group4", at: 0x1868, len: 7, kind: Kind::Dtmf },
+ Field { key: "group5", at: 0x1878, len: 7, kind: Kind::Dtmf },
+ Field { key: "group6", at: 0x1888, len: 7, kind: Kind::Dtmf },
+ Field { key: "group7", at: 0x1898, len: 7, kind: Kind::Dtmf },
+ Field { key: "group8", at: 0x18A8, len: 7, kind: Kind::Dtmf },
+ Field { key: "scode", at: 0x18C8, len: 7, kind: Kind::Dtmf },
+ Field { key: "ecode", at: 0x18D8, len: 7, kind: Kind::Dtmf },
+ Field { key: "bcl", at: 0x1965, len: 1, kind: Kind::Choice { mask: 0x04, values: &[0x00, 0x04] } },
+ Field { key: "specialqta", at: 0x1965, len: 1, kind: Kind::Choice { mask: 0x20, values: &[0x00, 0x20] } },
+ Field { key: "lowpower", at: 0x1966, len: 1, kind: Kind::Choice { mask: 0x30, values: &[0x00, 0x10, 0x20] } },
+ Field { key: "wide", at: 0x1966, len: 1, kind: Kind::Choice { mask: 0x08, values: &[0x00, 0x08] } },
+ Field { key: "bclb", at: 0x1975, len: 1, kind: Kind::Choice { mask: 0x04, values: &[0x00, 0x04] } },
+ Field { key: "specialqtb", at: 0x1975, len: 1, kind: Kind::Choice { mask: 0x20, values: &[0x00, 0x20] } },
+ Field { key: "lowpowerb", at: 0x1976, len: 1, kind: Kind::Choice { mask: 0x30, values: &[0x00, 0x10, 0x20] } },
+ Field { key: "wideb", at: 0x1976, len: 1, kind: Kind::Choice { mask: 0x08, values: &[0x00, 0x08] } },
+ Field { key: "poweron_msg.msg1", at: 0x1C08, len: 16, kind: Kind::Text },
+ Field { key: "poweron_msg.msg2", at: 0x1C18, len: 16, kind: Kind::Text },
+ Field { key: "poweron_msg.msg3", at: 0x1C28, len: 16, kind: Kind::Text },
+];
+
+/// The RT730 layout: 30 keys.
+pub(crate) const FIELDS_RT730: &[Field] = &[
+ Field { key: "press.ssidekey1", at: 0x0C98, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06] } },
+ Field { key: "press.lsidekey1", at: 0x0C99, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07] } },
+ Field { key: "press.ssidekey2", at: 0x0C9A, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06] } },
+ Field { key: "press.lsidekey2", at: 0x0C9B, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07] } },
+ Field { key: "press.rogerprompt", at: 0x0C9C, len: 1, kind: Kind::Choice { mask: 0x03, values: &[0x00, 0x01, 0x02, 0x03] } },
+ Field { key: "pritx", at: 0x0CA8, len: 1, kind: Kind::Choice { mask: 0x01, values: &[0x00, 0x01] } },
+ Field { key: "rxled", at: 0x0CA8, len: 1, kind: Kind::Choice { mask: 0x40, values: &[0x00, 0x40] } },
+ Field { key: "txled", at: 0x0CA8, len: 1, kind: Kind::Choice { mask: 0x80, values: &[0x00, 0x80] } },
+ Field { key: "btnvoice", at: 0x0CA9, len: 1, kind: Kind::Choice { mask: 0x04, values: &[0x00, 0x04] } },
+ Field { key: "keyautolock", at: 0x0CA9, len: 1, kind: Kind::Choice { mask: 0x10, values: &[0x00, 0x10] } },
+ Field { key: "save", at: 0x0CA9, len: 1, kind: Kind::Choice { mask: 0x08, values: &[0x00, 0x08] } },
+ Field { key: "scanmode", at: 0x0CA9, len: 1, kind: Kind::Choice { mask: 0xC0, values: &[0x00, 0x40, 0x80] } },
+ Field { key: "voiceprompt", at: 0x0CA9, len: 1, kind: Kind::Choice { mask: 0x01, values: &[0x00, 0x01] } },
+ Field { key: "fmrec", at: 0x0CAA, len: 1, kind: Kind::Choice { mask: 0x08, values: &[0x00, 0x08] } },
+ Field { key: "fmworkmode", at: 0x0CAA, len: 1, kind: Kind::Choice { mask: 0x80, values: &[0x00, 0x80] } },
+ Field { key: "ligcon", at: 0x0CAA, len: 1, kind: Kind::Choice { mask: 0x60, values: &[0x00, 0x20, 0x40, 0x60] } },
+ Field { key: "mdfa", at: 0x0CAA, len: 1, kind: Kind::Choice { mask: 0x04, values: &[0x00, 0x04] } },
+ Field { key: "dbrx", at: 0x0CAB, len: 1, kind: Kind::Choice { mask: 0x04, values: &[0x00, 0x04] } },
+ Field { key: "fmroad", at: 0x0CAE, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18] } },
+ Field { key: "tailclean", at: 0x0CAF, len: 1, kind: Kind::Choice { mask: 0x40, values: &[0x00, 0x40] } },
+ Field { key: "voxgain", at: 0x0CAF, len: 1, kind: Kind::Choice { mask: 0x07, values: &[0x00, 0x01, 0x02, 0x03] } },
+ Field { key: "squelch", at: 0x0CB1, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09] } },
+ Field { key: "tot", at: 0x0CB2, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07] } },
+ Field { key: "lang", at: 0x0CB3, len: 1, kind: Kind::Choice { mask: 0x02, values: &[0x00, 0x02] } },
+ Field { key: "voxdelay", at: 0x0CB6, len: 1, kind: Kind::Choice { mask: 0xFF, values: &[0x00, 0x01, 0x02, 0x03] } },
+ Field { key: "hoptype", at: 0x0CB7, len: 1, kind: Kind::Choice { mask: 0x03, values: &[0x00, 0x01, 0x02, 0x03] } },
+ Field { key: "poweron_msg.msg1", at: 0x1398, len: 16, kind: Kind::Text },
+ Field { key: "poweron_msg.msg2", at: 0x13A8, len: 16, kind: Kind::Text },
+ Field { key: "poweron_msg.msg3", at: 0x13B8, len: 16, kind: Kind::Text },
+ Field { key: "poweron_msg.msg4", at: 0x13C8, len: 16, kind: Kind::Text },
+];
diff --git a/src-tauri/src/radios/tidradio_tdh8g3/mod.rs b/src-tauri/src/radios/tidradio_tdh8g3/mod.rs
new file mode 100644
index 0000000..fc7fb86
--- /dev/null
+++ b/src-tauri/src/radios/tidradio_tdh8g3/mod.rs
@@ -0,0 +1,30 @@
+//! TIDRADIO TD-H8 3rd Gen (`driver_key = "tidradio_tdh8g3"`) — Experimental (#168).
+//!
+//! CHIRP `TDH8_3rd_Gen` (`chirp/drivers/tdh8.py`). The third-generation TD-H8, on the TD-H3's memory layout: transmit 136-600 MHz, receive from 18 MHz (AM in the air band), Low / Mid / High (2 / 6 / 10 W). CHIRP saves it as a "TD-H8" with variant "G3"; its image is the TD-H3's length, not the earlier TD-H8's.
+//!
+//! Everything else is the TD-H8 family's session code in `radios/tidradio_tdh8`,
+//! ported from CHIRP (GPLv2-or-later, by the CHIRP contributors). Nobody here
+//! owns one: nothing about this model has been confirmed on a radio, so it ships
+//! Experimental and the app warns before every write. See
+//! `docs/radios/tidradio-tdh8-family.md`.
+
+use crate::radios::tidradio_tdh8::{
+ TidradioTdh8, Variant, IDENT_OPEN, LAYOUT_H3, MAGIC_H8_G3, POWER_LMH,
+};
+
+pub(crate) static VARIANT: Variant = Variant {
+ key: "tidradio_tdh8g3",
+ display_name: "TIDRADIO TD-H8 3rd Gen",
+ short: "TD-H8 3rd Gen",
+ magic: MAGIC_H8_G3,
+ ident: IDENT_OPEN,
+ layout: &LAYOUT_H3,
+ power: POWER_LMH,
+ am: true,
+ chirp_models: &["TD-H8"],
+ file_prefix: "tdh8g3",
+ hardware_verified: false,
+};
+
+/// Registry entry (see `radios/registry.rs`).
+pub(crate) static DRIVER: TidradioTdh8 = TidradioTdh8(&VARIANT);
diff --git a/src-tauri/src/radios/tidradio_tdh8g3ham/mod.rs b/src-tauri/src/radios/tidradio_tdh8g3ham/mod.rs
new file mode 100644
index 0000000..98f055d
--- /dev/null
+++ b/src-tauri/src/radios/tidradio_tdh8g3ham/mod.rs
@@ -0,0 +1,30 @@
+//! TIDRADIO TD-H8 3rd Gen HAM (`driver_key = "tidradio_tdh8g3ham"`) — Experimental (#168).
+//!
+//! CHIRP `TDH8_3rd_Gen_HAM` (`chirp/drivers/tdh8.py`). The HAM-locked third-generation TD-H8: ident `P31185`, transmit on 144-149 and 420-451 MHz only (CHIRP adds 222-225 when the radio's TX-220 switch is on, which this app does not assume), receive 18-136 (AM in the air band), 150-420 and 451-600 MHz.
+//!
+//! Everything else is the TD-H8 family's session code in `radios/tidradio_tdh8`,
+//! ported from CHIRP (GPLv2-or-later, by the CHIRP contributors). Nobody here
+//! owns one: nothing about this model has been confirmed on a radio, so it ships
+//! Experimental and the app warns before every write. See
+//! `docs/radios/tidradio-tdh8-family.md`.
+
+use crate::radios::tidradio_tdh8::{
+ TidradioTdh8, Variant, IDENT_HAM, LAYOUT_H3, MAGIC_H8_G3, POWER_LMH,
+};
+
+pub(crate) static VARIANT: Variant = Variant {
+ key: "tidradio_tdh8g3ham",
+ display_name: "TIDRADIO TD-H8 3rd Gen HAM",
+ short: "TD-H8 3rd Gen HAM",
+ magic: MAGIC_H8_G3,
+ ident: IDENT_HAM,
+ layout: &LAYOUT_H3,
+ power: POWER_LMH,
+ am: true,
+ chirp_models: &["TD-H8-HAM"],
+ file_prefix: "tdh8g3ham",
+ hardware_verified: false,
+};
+
+/// Registry entry (see `radios/registry.rs`).
+pub(crate) static DRIVER: TidradioTdh8 = TidradioTdh8(&VARIANT);
diff --git a/src-tauri/src/radios/tidradio_tdh8ham/mod.rs b/src-tauri/src/radios/tidradio_tdh8ham/mod.rs
new file mode 100644
index 0000000..1fa9d56
--- /dev/null
+++ b/src-tauri/src/radios/tidradio_tdh8ham/mod.rs
@@ -0,0 +1,30 @@
+//! TIDRADIO TD-H8 HAM (`driver_key = "tidradio_tdh8ham"`) — Experimental (#168).
+//!
+//! CHIRP `TDH8_HAM` (`chirp/drivers/tdh8.py`). The HAM-locked TD-H8 (1st / 2nd generation): ident `P31185`, transmit on 144-149 and 420-451 MHz only, the rest of 136-174 / 400-521 MHz received. Low / Mid / High (1 / 4 / 8 W).
+//!
+//! Everything else is the TD-H8 family's session code in `radios/tidradio_tdh8`,
+//! ported from CHIRP (GPLv2-or-later, by the CHIRP contributors). Nobody here
+//! owns one: nothing about this model has been confirmed on a radio, so it ships
+//! Experimental and the app warns before every write. See
+//! `docs/radios/tidradio-tdh8-family.md`.
+
+use crate::radios::tidradio_tdh8::{
+ TidradioTdh8, Variant, IDENT_HAM, LAYOUT_H8, MAGIC_H8, POWER_LMH,
+};
+
+pub(crate) static VARIANT: Variant = Variant {
+ key: "tidradio_tdh8ham",
+ display_name: "TIDRADIO TD-H8 HAM",
+ short: "TD-H8 HAM",
+ magic: MAGIC_H8,
+ ident: IDENT_HAM,
+ layout: &LAYOUT_H8,
+ power: POWER_LMH,
+ am: false,
+ chirp_models: &["TD-H8-HAM"],
+ file_prefix: "tdh8ham",
+ hardware_verified: false,
+};
+
+/// Registry entry (see `radios/registry.rs`).
+pub(crate) static DRIVER: TidradioTdh8 = TidradioTdh8(&VARIANT);
diff --git a/src-tauri/src/seed.rs b/src-tauri/src/seed.rs
index 3e535cf..28b7c14 100644
--- a/src-tauri/src/seed.rs
+++ b/src-tauri/src/seed.rs
@@ -271,6 +271,23 @@ pub(crate) fn uv17pro_family_schema(key: &str) -> &'static str {
}
}
+// TD-H8 family (#168): one schema per distinct settings set, generated by
+// scripts/tidradio_tdh8_family/gen_settings.py from what CHIRP's tdh8.py writes.
+pub const TDH8_FAMILY_TIDRADIO_TDH8_SCHEMA: &str = include_str!("tdh8_family/tidradio_tdh8.json");
+pub const TDH8_FAMILY_TIDRADIO_TDH8HAM_SCHEMA: &str = include_str!("tdh8_family/tidradio_tdh8ham.json");
+pub const TDH8_FAMILY_RADTEL_RT730_SCHEMA: &str = include_str!("tdh8_family/radtel_rt730.json");
+
+/// A TD-H8 family model's settings schema, by driver key.
+#[cfg(test)]
+pub(crate) fn tdh8_family_schema(key: &str) -> &'static str {
+ match key {
+ "tidradio_tdh8" | "tidradio_tdh8g3" | "tidradio_tdh8g3ham" => TDH8_FAMILY_TIDRADIO_TDH8_SCHEMA,
+ "tidradio_tdh8ham" => TDH8_FAMILY_TIDRADIO_TDH8HAM_SCHEMA,
+ "radtel_rt730" => TDH8_FAMILY_RADTEL_RT730_SCHEMA,
+ other => panic!("{other} is not a TD-H8 family model"),
+ }
+}
+
#[cfg(test)]
pub(crate) fn model_rx_bands(model: &str) -> Option<&'static str> {
@@ -1882,6 +1899,201 @@ fn models() -> Vec {
]"##,
},
// --------------------------------------------------------
+ // TIDRADIO TD-H8 — Experimental (#168), on the TD-H8 family driver
+ // (`radios/tidradio_tdh8`). CHIRP `TDH8`: 1st / 2nd generation, unrestricted (ident P31183). Transmits on all of its coverage; no air band.
+ // --------------------------------------------------------
+ ModelSeed {
+ manufacturer: "TIDRADIO",
+ model: "TD-H8",
+ driver_key: Some("tidradio_tdh8"),
+ programming_ui: Some("generic"),
+ display_name: "TIDRADIO TD-H8",
+ analog_capable: true,
+ dmr_capable: false,
+ dstar_capable: false,
+ ysf_capable: false,
+ nxdn_capable: false,
+ p25_capable: false,
+ m17_capable: false,
+ aprs_capable: false,
+ covers_hf: false,
+ covers_vhf: true,
+ covers_uhf: true,
+ covers_220: false,
+ covers_900: false,
+ freq_min: 136.0,
+ freq_max: 521.0,
+ tx_bands: Some("[[136.0,175.0],[400.0,521.0]]"),
+ rx_bands: Some("[[136.0,175.0],[400.0,521.0]]"),
+ memory_channels: 199,
+ zones_supported: false,
+ max_zones: None,
+ channels_per_zone: None,
+ scan_lists_supported: false,
+ max_scan_lists: None,
+ banks_supported: false,
+ max_name_length: 8,
+ export_format: "chirp_csv",
+ connection_type: "Kenwood K1 (2-pin)",
+ non_channel_settings_schema: TDH8_FAMILY_TIDRADIO_TDH8_SCHEMA,
+ },
+ // --------------------------------------------------------
+ // TIDRADIO TD-H8 HAM — Experimental (#168), on the TD-H8 family driver
+ // (`radios/tidradio_tdh8`). CHIRP `TDH8_HAM`: the HAM-locked 1st / 2nd generation (ident P31185). Transmits 144-149 / 420-451 MHz only; the rest of 136-174 / 400-521 is receive-only.
+ // --------------------------------------------------------
+ ModelSeed {
+ manufacturer: "TIDRADIO",
+ model: "TD-H8 HAM",
+ driver_key: Some("tidradio_tdh8ham"),
+ programming_ui: Some("generic"),
+ display_name: "TIDRADIO TD-H8 HAM",
+ analog_capable: true,
+ dmr_capable: false,
+ dstar_capable: false,
+ ysf_capable: false,
+ nxdn_capable: false,
+ p25_capable: false,
+ m17_capable: false,
+ aprs_capable: false,
+ covers_hf: false,
+ covers_vhf: true,
+ covers_uhf: true,
+ covers_220: false,
+ covers_900: false,
+ freq_min: 136.0,
+ freq_max: 521.0,
+ tx_bands: Some("[[144.0,149.0],[420.0,451.0]]"),
+ rx_bands: Some("[[136.0,174.0],[400.0,521.0]]"),
+ memory_channels: 199,
+ zones_supported: false,
+ max_zones: None,
+ channels_per_zone: None,
+ scan_lists_supported: false,
+ max_scan_lists: None,
+ banks_supported: false,
+ max_name_length: 8,
+ export_format: "chirp_csv",
+ connection_type: "Kenwood K1 (2-pin)",
+ non_channel_settings_schema: TDH8_FAMILY_TIDRADIO_TDH8HAM_SCHEMA,
+ },
+ // --------------------------------------------------------
+ // TIDRADIO TD-H8 3rd Gen — Experimental (#168), on the TD-H8 family driver
+ // (`radios/tidradio_tdh8`). CHIRP `TDH8_3rd_Gen`: the TD-H3's layout, unrestricted. Transmits 136-600 MHz; 18-136 MHz receive-only (air band AM).
+ // --------------------------------------------------------
+ ModelSeed {
+ manufacturer: "TIDRADIO",
+ model: "TD-H8 3rd Gen",
+ driver_key: Some("tidradio_tdh8g3"),
+ programming_ui: Some("generic"),
+ display_name: "TIDRADIO TD-H8 3rd Gen",
+ analog_capable: true,
+ dmr_capable: false,
+ dstar_capable: false,
+ ysf_capable: false,
+ nxdn_capable: false,
+ p25_capable: false,
+ m17_capable: false,
+ aprs_capable: false,
+ covers_hf: false,
+ covers_vhf: true,
+ covers_uhf: true,
+ covers_220: true,
+ covers_900: false,
+ freq_min: 18.0,
+ freq_max: 600.0,
+ tx_bands: Some("[[136.0,600.0]]"),
+ rx_bands: Some("[[18.0,600.0]]"),
+ memory_channels: 199,
+ zones_supported: false,
+ max_zones: None,
+ channels_per_zone: None,
+ scan_lists_supported: false,
+ max_scan_lists: None,
+ banks_supported: false,
+ max_name_length: 8,
+ export_format: "chirp_csv",
+ connection_type: "Kenwood K1 (2-pin)",
+ non_channel_settings_schema: TDH8_FAMILY_TIDRADIO_TDH8_SCHEMA,
+ },
+ // --------------------------------------------------------
+ // TIDRADIO TD-H8 3rd Gen HAM — Experimental (#168), on the TD-H8 family driver
+ // (`radios/tidradio_tdh8`). CHIRP `TDH8_3rd_Gen_HAM`: HAM-locked (ident P31185). Transmits 144-149 / 420-451 MHz; receives 18-136, 149.99-419.99 and 451-600 too. CHIRP leaves 136-144 out of the receiver, so it is out here.
+ // --------------------------------------------------------
+ ModelSeed {
+ manufacturer: "TIDRADIO",
+ model: "TD-H8 3rd Gen HAM",
+ driver_key: Some("tidradio_tdh8g3ham"),
+ programming_ui: Some("generic"),
+ display_name: "TIDRADIO TD-H8 3rd Gen HAM",
+ analog_capable: true,
+ dmr_capable: false,
+ dstar_capable: false,
+ ysf_capable: false,
+ nxdn_capable: false,
+ p25_capable: false,
+ m17_capable: false,
+ aprs_capable: false,
+ covers_hf: false,
+ covers_vhf: true,
+ covers_uhf: true,
+ covers_220: true,
+ covers_900: false,
+ freq_min: 18.0,
+ freq_max: 600.0,
+ tx_bands: Some("[[144.0,149.0],[420.0,451.0]]"),
+ rx_bands: Some("[[18.0,136.0],[144.0,149.0],[149.99,419.99],[420.0,600.0]]"),
+ memory_channels: 199,
+ zones_supported: false,
+ max_zones: None,
+ channels_per_zone: None,
+ scan_lists_supported: false,
+ max_scan_lists: None,
+ banks_supported: false,
+ max_name_length: 8,
+ export_format: "chirp_csv",
+ connection_type: "Kenwood K1 (2-pin)",
+ non_channel_settings_schema: TDH8_FAMILY_TIDRADIO_TDH8_SCHEMA,
+ },
+ // --------------------------------------------------------
+ // Radtel RT-730 — Experimental (#168), on the TD-H8 family driver
+ // (`radios/tidradio_tdh8`). CHIRP `RT730`: its own layout on the TD-H8 protocol. CHIRP transmits 136-630 MHz and receives from 10 MHz (retailers list a 144-148 / 420-450 TX build; not modelled).
+ // --------------------------------------------------------
+ ModelSeed {
+ manufacturer: "Radtel",
+ model: "RT-730",
+ driver_key: Some("radtel_rt730"),
+ programming_ui: Some("generic"),
+ display_name: "Radtel RT-730",
+ analog_capable: true,
+ dmr_capable: false,
+ dstar_capable: false,
+ ysf_capable: false,
+ nxdn_capable: false,
+ p25_capable: false,
+ m17_capable: false,
+ aprs_capable: false,
+ covers_hf: false,
+ covers_vhf: true,
+ covers_uhf: true,
+ covers_220: true,
+ covers_900: false,
+ freq_min: 10.0,
+ freq_max: 630.0,
+ tx_bands: Some("[[136.0,630.0]]"),
+ rx_bands: Some("[[10.0,630.0]]"),
+ memory_channels: 199,
+ zones_supported: false,
+ max_zones: None,
+ channels_per_zone: None,
+ scan_lists_supported: false,
+ max_scan_lists: None,
+ banks_supported: false,
+ max_name_length: 8,
+ export_format: "chirp_csv",
+ connection_type: "Kenwood K1 (2-pin)",
+ non_channel_settings_schema: TDH8_FAMILY_RADTEL_RT730_SCHEMA,
+ },
+ // --------------------------------------------------------
// 3. AnyTone AT-D890UV — DMR Tier I/II + analog FM dual-band
// HT, 4000 channels in up to 250 zones (160 ch/zone), 250
// scan lists, 16-char alpha tags. APRS (analog + DMR) TX/RX,
diff --git a/src-tauri/src/tdh8_family/models.json b/src-tauri/src/tdh8_family/models.json
new file mode 100644
index 0000000..f33b4ae
--- /dev/null
+++ b/src-tauri/src/tdh8_family/models.json
@@ -0,0 +1,7 @@
+{
+ "tidradio_tdh8": "tidradio_tdh8",
+ "tidradio_tdh8ham": "tidradio_tdh8ham",
+ "tidradio_tdh8g3": "tidradio_tdh8",
+ "tidradio_tdh8g3ham": "tidradio_tdh8",
+ "radtel_rt730": "radtel_rt730"
+}
diff --git a/src-tauri/src/tdh8_family/radtel_rt730.json b/src-tauri/src/tdh8_family/radtel_rt730.json
new file mode 100644
index 0000000..b1b13c5
--- /dev/null
+++ b/src-tauri/src/tdh8_family/radtel_rt730.json
@@ -0,0 +1,332 @@
+[
+ {
+ "key": "section-general",
+ "label": "General",
+ "type": "section",
+ "group": "General"
+ },
+ {
+ "key": "keyautolock",
+ "label": "Auto Keypad Lock",
+ "type": "boolean"
+ },
+ {
+ "key": "lang",
+ "label": "Language",
+ "type": "select",
+ "options": [
+ "Chinese",
+ "English"
+ ]
+ },
+ {
+ "key": "save",
+ "label": "Battery Save",
+ "type": "boolean"
+ },
+ {
+ "key": "pritx",
+ "label": "Priority TX",
+ "type": "select",
+ "options": [
+ "Edit",
+ "Busy"
+ ]
+ },
+ {
+ "key": "section-display",
+ "label": "Display",
+ "type": "section",
+ "group": "Display"
+ },
+ {
+ "key": "txled",
+ "label": "Display LCD on TX",
+ "type": "boolean"
+ },
+ {
+ "key": "rxled",
+ "label": "Display LCD on RX",
+ "type": "boolean"
+ },
+ {
+ "key": "poweron_msg.msg1",
+ "label": "Power-On Message 1",
+ "type": "text",
+ "max_length": 16
+ },
+ {
+ "key": "poweron_msg.msg2",
+ "label": "Power-On Message 2",
+ "type": "text",
+ "max_length": 16
+ },
+ {
+ "key": "poweron_msg.msg3",
+ "label": "Power-On Message 3",
+ "type": "text",
+ "max_length": 16
+ },
+ {
+ "key": "poweron_msg.msg4",
+ "label": "Power-On Message 4",
+ "type": "text",
+ "max_length": 16
+ },
+ {
+ "key": "ligcon",
+ "label": "Backlight Time",
+ "type": "select",
+ "options": [
+ "CONT",
+ "10s",
+ "20s",
+ "30s"
+ ]
+ },
+ {
+ "key": "mdfa",
+ "label": "Display Mode A",
+ "type": "boolean"
+ },
+ {
+ "key": "section-sounds",
+ "label": "Sounds",
+ "type": "section",
+ "group": "Sounds"
+ },
+ {
+ "key": "voiceprompt",
+ "label": "Voice Prompt",
+ "type": "boolean"
+ },
+ {
+ "key": "btnvoice",
+ "label": "Key Beep",
+ "type": "boolean"
+ },
+ {
+ "key": "press.rogerprompt",
+ "label": "Roger Beep",
+ "type": "select",
+ "options": [
+ "Off",
+ "BOT",
+ "EOT",
+ "Both"
+ ]
+ },
+ {
+ "key": "section-transmit-receive",
+ "label": "Transmit & Receive",
+ "type": "section",
+ "group": "Transmit & Receive"
+ },
+ {
+ "key": "squelch",
+ "label": "Squelch Level",
+ "type": "select",
+ "options": [
+ "0",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ "8",
+ "9"
+ ]
+ },
+ {
+ "key": "dbrx",
+ "label": "Dual Receive",
+ "type": "boolean"
+ },
+ {
+ "key": "tot",
+ "label": "Time-out Timer",
+ "type": "select",
+ "options": [
+ "Off",
+ "30 sec",
+ "60 sec",
+ "90 sec",
+ "120 sec",
+ "150 sec",
+ "180 sec",
+ "210 sec"
+ ]
+ },
+ {
+ "key": "hoptype",
+ "label": "Hop Type",
+ "type": "select",
+ "options": [
+ "A",
+ "B",
+ "C",
+ "D"
+ ]
+ },
+ {
+ "key": "tailclean",
+ "label": "QT/DQT Tail Elimination",
+ "type": "boolean"
+ },
+ {
+ "key": "voxgain",
+ "label": "VOX Gain",
+ "type": "select",
+ "options": [
+ "Off",
+ "1",
+ "2",
+ "3"
+ ]
+ },
+ {
+ "key": "voxdelay",
+ "label": "VOX Delay",
+ "type": "select",
+ "options": [
+ "0.5s",
+ "1.0s",
+ "2.0s",
+ "3.0s"
+ ]
+ },
+ {
+ "key": "section-memory-vfo",
+ "label": "Memory & VFO",
+ "type": "section",
+ "group": "Memory & VFO"
+ },
+ {
+ "key": "fmworkmode",
+ "label": "FM Radio Work Mode",
+ "type": "select",
+ "options": [
+ "CH",
+ "VFO"
+ ]
+ },
+ {
+ "key": "fmroad",
+ "label": "FM Radio Channel",
+ "type": "select",
+ "options": [
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ "8",
+ "9",
+ "10",
+ "11",
+ "12",
+ "13",
+ "14",
+ "15",
+ "16",
+ "17",
+ "18",
+ "19",
+ "20",
+ "21",
+ "22",
+ "23",
+ "24",
+ "25"
+ ]
+ },
+ {
+ "key": "fmrec",
+ "label": "Forbid FM Radio Receive",
+ "type": "boolean"
+ },
+ {
+ "key": "section-scan",
+ "label": "Scan",
+ "type": "section",
+ "group": "Scan"
+ },
+ {
+ "key": "scanmode",
+ "label": "Scan Mode",
+ "type": "select",
+ "options": [
+ "TO",
+ "CO",
+ "SE"
+ ]
+ },
+ {
+ "key": "section-keys",
+ "label": "Keys",
+ "type": "section",
+ "group": "Keys"
+ },
+ {
+ "key": "press.ssidekey1",
+ "label": "PF1 Short Press",
+ "type": "select",
+ "options": [
+ "None",
+ "Scan",
+ "FM",
+ "Warn",
+ "TONE",
+ "Weather",
+ "Copy CH"
+ ]
+ },
+ {
+ "key": "press.lsidekey1",
+ "label": "PF1 Long Press",
+ "type": "select",
+ "options": [
+ "None",
+ "Scan",
+ "FM",
+ "Warn",
+ "TONE",
+ "Weather",
+ "Copy CH",
+ "Monitor"
+ ]
+ },
+ {
+ "key": "press.ssidekey2",
+ "label": "PF2 Short Press",
+ "type": "select",
+ "options": [
+ "None",
+ "Scan",
+ "FM",
+ "Warn",
+ "TONE",
+ "Weather",
+ "Copy CH"
+ ]
+ },
+ {
+ "key": "press.lsidekey2",
+ "label": "PF2 Long Press",
+ "type": "select",
+ "options": [
+ "None",
+ "Scan",
+ "FM",
+ "Warn",
+ "TONE",
+ "Weather",
+ "Copy CH",
+ "Monitor"
+ ]
+ }
+]
diff --git a/src-tauri/src/tdh8_family/tidradio_tdh8.json b/src-tauri/src/tdh8_family/tidradio_tdh8.json
new file mode 100644
index 0000000..0f6f075
--- /dev/null
+++ b/src-tauri/src/tdh8_family/tidradio_tdh8.json
@@ -0,0 +1,558 @@
+[
+ {
+ "key": "section-general",
+ "label": "General",
+ "type": "section",
+ "group": "General"
+ },
+ {
+ "key": "keyautolock",
+ "label": "Auto Keypad Lock",
+ "type": "boolean"
+ },
+ {
+ "key": "sync",
+ "label": "A/B Sync",
+ "type": "boolean"
+ },
+ {
+ "key": "save",
+ "label": "Power Save",
+ "type": "select",
+ "options": [
+ "Off",
+ "1:1",
+ "1:2",
+ "1:3",
+ "1:4",
+ "1:8"
+ ]
+ },
+ {
+ "key": "pritx",
+ "label": "Priority TX",
+ "type": "select",
+ "options": [
+ "Edit",
+ "Busy"
+ ]
+ },
+ {
+ "key": "onlychmode",
+ "label": "Channel Mode Only",
+ "type": "boolean"
+ },
+ {
+ "key": "section-display",
+ "label": "Display",
+ "type": "section",
+ "group": "Display"
+ },
+ {
+ "key": "ligcon",
+ "label": "Backlight Time",
+ "type": "select",
+ "options": [
+ "CONT",
+ "5s",
+ "10s",
+ "15s",
+ "30s"
+ ]
+ },
+ {
+ "key": "mdfa",
+ "label": "Display Mode A",
+ "type": "select",
+ "options": [
+ "Frequency",
+ "Name"
+ ]
+ },
+ {
+ "key": "mdfb",
+ "label": "Display Mode B",
+ "type": "select",
+ "options": [
+ "Frequency",
+ "Name"
+ ]
+ },
+ {
+ "key": "txled",
+ "label": "Display LCD on TX",
+ "type": "boolean"
+ },
+ {
+ "key": "rxled",
+ "label": "Display LCD on RX",
+ "type": "boolean"
+ },
+ {
+ "key": "breathled",
+ "label": "Breathing LED",
+ "type": "select",
+ "options": [
+ "Off",
+ "5S",
+ "10S",
+ "15S",
+ "30S"
+ ]
+ },
+ {
+ "key": "ponmsg",
+ "label": "Power-On Display",
+ "type": "select",
+ "options": [
+ "Off",
+ "Msg",
+ "Icon"
+ ]
+ },
+ {
+ "key": "poweron_msg.msg1",
+ "label": "Power-On Message 1",
+ "type": "text",
+ "max_length": 16
+ },
+ {
+ "key": "poweron_msg.msg2",
+ "label": "Power-On Message 2",
+ "type": "text",
+ "max_length": 16
+ },
+ {
+ "key": "poweron_msg.msg3",
+ "label": "Power-On Message 3",
+ "type": "text",
+ "max_length": 16
+ },
+ {
+ "key": "section-sounds",
+ "label": "Sounds",
+ "type": "section",
+ "group": "Sounds"
+ },
+ {
+ "key": "voiceprompt",
+ "label": "Voice Prompt",
+ "type": "boolean"
+ },
+ {
+ "key": "btnvoice",
+ "label": "Key Beep",
+ "type": "boolean"
+ },
+ {
+ "key": "rogerprompt",
+ "label": "Roger Beep",
+ "type": "boolean"
+ },
+ {
+ "key": "section-transmit-receive",
+ "label": "Transmit & Receive",
+ "type": "section",
+ "group": "Transmit & Receive"
+ },
+ {
+ "key": "squelch",
+ "label": "Squelch Level",
+ "type": "select",
+ "options": [
+ "0",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ "8",
+ "9"
+ ]
+ },
+ {
+ "key": "dbrx",
+ "label": "Dual Receive",
+ "type": "boolean"
+ },
+ {
+ "key": "voxgain",
+ "label": "VOX Gain",
+ "type": "select",
+ "options": [
+ "Off",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5"
+ ]
+ },
+ {
+ "key": "voxdelay",
+ "label": "VOX Delay",
+ "type": "select",
+ "options": [
+ "1.05s",
+ "2.0s",
+ "3.0s"
+ ]
+ },
+ {
+ "key": "section-memory-vfo",
+ "label": "Memory & VFO",
+ "type": "section",
+ "group": "Memory & VFO"
+ },
+ {
+ "key": "astep",
+ "label": "VFO A Step (kHz)",
+ "type": "select",
+ "options": [
+ "2.5",
+ "5.0",
+ "6.25",
+ "10.0",
+ "12.5",
+ "25.0"
+ ]
+ },
+ {
+ "key": "bstep",
+ "label": "VFO B Step (kHz)",
+ "type": "select",
+ "options": [
+ "2.5",
+ "5.0",
+ "6.25",
+ "10.0",
+ "12.5",
+ "25.0"
+ ]
+ },
+ {
+ "key": "lowpower",
+ "label": "VFO A TX Power",
+ "type": "select",
+ "options": [
+ "Low",
+ "Mid",
+ "High"
+ ]
+ },
+ {
+ "key": "wide",
+ "label": "VFO A Bandwidth",
+ "type": "select",
+ "options": [
+ "Wide",
+ "Narrow"
+ ]
+ },
+ {
+ "key": "bcl",
+ "label": "VFO A Busy Lock",
+ "type": "boolean"
+ },
+ {
+ "key": "specialqta",
+ "label": "VFO A Special QT/DQT",
+ "type": "boolean"
+ },
+ {
+ "key": "aworkmode",
+ "label": "VFO A Work Mode",
+ "type": "select",
+ "options": [
+ "VFO",
+ "VFO+CH",
+ "CH Mode"
+ ]
+ },
+ {
+ "key": "lowpowerb",
+ "label": "VFO B TX Power",
+ "type": "select",
+ "options": [
+ "Low",
+ "Mid",
+ "High"
+ ]
+ },
+ {
+ "key": "wideb",
+ "label": "VFO B Bandwidth",
+ "type": "select",
+ "options": [
+ "Wide",
+ "Narrow"
+ ]
+ },
+ {
+ "key": "bclb",
+ "label": "VFO B Busy Lock",
+ "type": "boolean"
+ },
+ {
+ "key": "specialqtb",
+ "label": "VFO B Special QT/DQT",
+ "type": "boolean"
+ },
+ {
+ "key": "bworkmode",
+ "label": "VFO B Work Mode",
+ "type": "select",
+ "options": [
+ "VFO",
+ "VFO+CH",
+ "CH Mode"
+ ]
+ },
+ {
+ "key": "fmworkmode",
+ "label": "FM Radio Work Mode",
+ "type": "select",
+ "options": [
+ "CH",
+ "VFO"
+ ]
+ },
+ {
+ "key": "fmroad",
+ "label": "FM Radio Channel",
+ "type": "select",
+ "options": [
+ "0",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ "8",
+ "9",
+ "10",
+ "11",
+ "12",
+ "13",
+ "14",
+ "15",
+ "16",
+ "17",
+ "18",
+ "19",
+ "20",
+ "21",
+ "22",
+ "23",
+ "24",
+ "25"
+ ]
+ },
+ {
+ "key": "fmrec",
+ "label": "Forbid FM Radio Receive",
+ "type": "boolean"
+ },
+ {
+ "key": "section-scan",
+ "label": "Scan",
+ "type": "section",
+ "group": "Scan"
+ },
+ {
+ "key": "scanmode",
+ "label": "Scan Mode",
+ "type": "select",
+ "options": [
+ "TO",
+ "CO",
+ "SE"
+ ]
+ },
+ {
+ "key": "section-keys",
+ "label": "Keys",
+ "type": "section",
+ "group": "Keys"
+ },
+ {
+ "key": "ssidekey1",
+ "label": "PF1 Short Press",
+ "type": "select",
+ "options": [
+ "None",
+ "FM Radio",
+ "Lamp",
+ "Monitor",
+ "TONE",
+ "Alarm",
+ "Weather"
+ ]
+ },
+ {
+ "key": "lsidekey3",
+ "label": "PF1 Long Press",
+ "type": "select",
+ "options": [
+ "None",
+ "FM Radio",
+ "Lamp",
+ "Monitor",
+ "TONE",
+ "Alarm",
+ "Weather"
+ ]
+ },
+ {
+ "key": "stopkey1",
+ "label": "Top Key Short Press",
+ "type": "select",
+ "options": [
+ "None",
+ "FM Radio",
+ "Lamp",
+ "Monitor",
+ "TONE",
+ "Alarm",
+ "Weather"
+ ]
+ },
+ {
+ "key": "ltopkey2",
+ "label": "Top Key Long Press",
+ "type": "select",
+ "options": [
+ "None",
+ "FM Radio",
+ "Lamp",
+ "Monitor",
+ "TONE",
+ "Alarm",
+ "Weather"
+ ]
+ },
+ {
+ "key": "ssidekey2",
+ "label": "PF2 Short Press",
+ "type": "select",
+ "options": [
+ "None",
+ "FM Radio",
+ "Lamp",
+ "Monitor",
+ "TONE",
+ "Alarm",
+ "Weather"
+ ]
+ },
+ {
+ "key": "lsidekey4",
+ "label": "PF2 Long Press",
+ "type": "select",
+ "options": [
+ "None",
+ "FM Radio",
+ "Lamp",
+ "Monitor",
+ "TONE",
+ "Alarm",
+ "Weather"
+ ]
+ },
+ {
+ "key": "section-dtmf-signaling",
+ "label": "DTMF & Signaling",
+ "type": "section",
+ "group": "DTMF & Signaling"
+ },
+ {
+ "key": "gcode",
+ "label": "Group Code",
+ "type": "select",
+ "options": [
+ "",
+ "Off",
+ "*",
+ "#",
+ "A",
+ "B",
+ "C",
+ "D"
+ ]
+ },
+ {
+ "key": "icode",
+ "label": "ID Code",
+ "type": "text",
+ "max_length": 3
+ },
+ {
+ "key": "group1",
+ "label": "Group Call 1",
+ "type": "text",
+ "max_length": 7
+ },
+ {
+ "key": "group2",
+ "label": "Group Call 2",
+ "type": "text",
+ "max_length": 7
+ },
+ {
+ "key": "group3",
+ "label": "Group Call 3",
+ "type": "text",
+ "max_length": 7
+ },
+ {
+ "key": "group4",
+ "label": "Group Call 4",
+ "type": "text",
+ "max_length": 7
+ },
+ {
+ "key": "group5",
+ "label": "Group Call 5",
+ "type": "text",
+ "max_length": 7
+ },
+ {
+ "key": "group6",
+ "label": "Group Call 6",
+ "type": "text",
+ "max_length": 7
+ },
+ {
+ "key": "group7",
+ "label": "Group Call 7",
+ "type": "text",
+ "max_length": 7
+ },
+ {
+ "key": "group8",
+ "label": "Group Call 8",
+ "type": "text",
+ "max_length": 7
+ },
+ {
+ "key": "scode",
+ "label": "PTT ID Start (BOT)",
+ "type": "text",
+ "max_length": 7
+ },
+ {
+ "key": "ecode",
+ "label": "PTT ID End (EOT)",
+ "type": "text",
+ "max_length": 7
+ },
+ {
+ "key": "dtmfst",
+ "label": "DTMF Side Tones",
+ "type": "boolean"
+ }
+]
diff --git a/src-tauri/src/tdh8_family/tidradio_tdh8ham.json b/src-tauri/src/tdh8_family/tidradio_tdh8ham.json
new file mode 100644
index 0000000..8294347
--- /dev/null
+++ b/src-tauri/src/tdh8_family/tidradio_tdh8ham.json
@@ -0,0 +1,582 @@
+[
+ {
+ "key": "section-general",
+ "label": "General",
+ "type": "section",
+ "group": "General"
+ },
+ {
+ "key": "keyautolock",
+ "label": "Auto Keypad Lock",
+ "type": "boolean"
+ },
+ {
+ "key": "sync",
+ "label": "A/B Sync",
+ "type": "boolean"
+ },
+ {
+ "key": "save",
+ "label": "Power Save",
+ "type": "select",
+ "options": [
+ "Off",
+ "1:1",
+ "1:2",
+ "1:3",
+ "1:4"
+ ]
+ },
+ {
+ "key": "pritx",
+ "label": "Priority TX",
+ "type": "select",
+ "options": [
+ "Edit",
+ "Busy"
+ ]
+ },
+ {
+ "key": "onlychmode",
+ "label": "Channel Mode Only",
+ "type": "boolean"
+ },
+ {
+ "key": "lang",
+ "label": "Language",
+ "type": "select",
+ "options": [
+ "Chinese",
+ "English"
+ ]
+ },
+ {
+ "key": "section-display",
+ "label": "Display",
+ "type": "section",
+ "group": "Display"
+ },
+ {
+ "key": "ligcon",
+ "label": "Backlight Time",
+ "type": "select",
+ "options": [
+ "CONT",
+ "5s",
+ "10s",
+ "15s",
+ "30s"
+ ]
+ },
+ {
+ "key": "mdfa",
+ "label": "Display Mode A",
+ "type": "select",
+ "options": [
+ "Frequency",
+ "Name"
+ ]
+ },
+ {
+ "key": "mdfb",
+ "label": "Display Mode B",
+ "type": "select",
+ "options": [
+ "Frequency",
+ "Name"
+ ]
+ },
+ {
+ "key": "txled",
+ "label": "Display LCD on TX",
+ "type": "boolean"
+ },
+ {
+ "key": "rxled",
+ "label": "Display LCD on RX",
+ "type": "boolean"
+ },
+ {
+ "key": "breathled",
+ "label": "Breathing LED",
+ "type": "select",
+ "options": [
+ "Off",
+ "5S",
+ "10S",
+ "15S",
+ "30S"
+ ]
+ },
+ {
+ "key": "ponmsg",
+ "label": "Power-On Display",
+ "type": "select",
+ "options": [
+ "Full",
+ "Msg",
+ "Icon"
+ ]
+ },
+ {
+ "key": "poweron_msg.msg1",
+ "label": "Power-On Message 1",
+ "type": "text",
+ "max_length": 16
+ },
+ {
+ "key": "poweron_msg.msg2",
+ "label": "Power-On Message 2",
+ "type": "text",
+ "max_length": 16
+ },
+ {
+ "key": "poweron_msg.msg3",
+ "label": "Power-On Message 3",
+ "type": "text",
+ "max_length": 16
+ },
+ {
+ "key": "section-sounds",
+ "label": "Sounds",
+ "type": "section",
+ "group": "Sounds"
+ },
+ {
+ "key": "voiceprompt",
+ "label": "Voice Prompt",
+ "type": "boolean"
+ },
+ {
+ "key": "btnvoice",
+ "label": "Key Beep",
+ "type": "boolean"
+ },
+ {
+ "key": "rogerprompt",
+ "label": "Roger Beep",
+ "type": "boolean"
+ },
+ {
+ "key": "section-transmit-receive",
+ "label": "Transmit & Receive",
+ "type": "section",
+ "group": "Transmit & Receive"
+ },
+ {
+ "key": "squelch",
+ "label": "Squelch Level",
+ "type": "select",
+ "options": [
+ "0",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ "8",
+ "9"
+ ]
+ },
+ {
+ "key": "dbrx",
+ "label": "Dual Receive",
+ "type": "boolean"
+ },
+ {
+ "key": "voxgain",
+ "label": "VOX Gain",
+ "type": "select",
+ "options": [
+ "Off",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5"
+ ]
+ },
+ {
+ "key": "voxdelay",
+ "label": "VOX Delay",
+ "type": "select",
+ "options": [
+ "1.05s",
+ "2.0s",
+ "3.0s"
+ ]
+ },
+ {
+ "key": "tot",
+ "label": "Time-Out Timer",
+ "type": "select",
+ "options": [
+ "OFF",
+ "30S",
+ "60S",
+ "90S",
+ "120S",
+ "150S",
+ "180S",
+ "210S"
+ ]
+ },
+ {
+ "key": "section-memory-vfo",
+ "label": "Memory & VFO",
+ "type": "section",
+ "group": "Memory & VFO"
+ },
+ {
+ "key": "astep",
+ "label": "VFO A Step (kHz)",
+ "type": "select",
+ "options": [
+ "2.5",
+ "5.0",
+ "6.25",
+ "10.0",
+ "12.5",
+ "25.0",
+ "50.0"
+ ]
+ },
+ {
+ "key": "bstep",
+ "label": "VFO B Step (kHz)",
+ "type": "select",
+ "options": [
+ "2.5",
+ "5.0",
+ "6.25",
+ "10.0",
+ "12.5",
+ "25.0"
+ ]
+ },
+ {
+ "key": "lowpower",
+ "label": "VFO A TX Power",
+ "type": "select",
+ "options": [
+ "Low",
+ "Mid",
+ "High"
+ ]
+ },
+ {
+ "key": "wide",
+ "label": "VFO A Bandwidth",
+ "type": "select",
+ "options": [
+ "Wide",
+ "Narrow"
+ ]
+ },
+ {
+ "key": "bcl",
+ "label": "VFO A Busy Lock",
+ "type": "boolean"
+ },
+ {
+ "key": "specialqta",
+ "label": "VFO A Special QT/DQT",
+ "type": "boolean"
+ },
+ {
+ "key": "aworkmode",
+ "label": "VFO A Work Mode",
+ "type": "select",
+ "options": [
+ "VFO",
+ "VFO+CH",
+ "CH Mode"
+ ]
+ },
+ {
+ "key": "lowpowerb",
+ "label": "VFO B TX Power",
+ "type": "select",
+ "options": [
+ "Low",
+ "Mid",
+ "High"
+ ]
+ },
+ {
+ "key": "wideb",
+ "label": "VFO B Bandwidth",
+ "type": "select",
+ "options": [
+ "Wide",
+ "Narrow"
+ ]
+ },
+ {
+ "key": "bclb",
+ "label": "VFO B Busy Lock",
+ "type": "boolean"
+ },
+ {
+ "key": "specialqtb",
+ "label": "VFO B Special QT/DQT",
+ "type": "boolean"
+ },
+ {
+ "key": "bworkmode",
+ "label": "VFO B Work Mode",
+ "type": "select",
+ "options": [
+ "VFO",
+ "VFO+CH",
+ "CH Mode"
+ ]
+ },
+ {
+ "key": "fmworkmode",
+ "label": "FM Radio Work Mode",
+ "type": "select",
+ "options": [
+ "CH",
+ "VFO"
+ ]
+ },
+ {
+ "key": "fmroad",
+ "label": "FM Radio Channel",
+ "type": "select",
+ "options": [
+ "0",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ "8",
+ "9",
+ "10",
+ "11",
+ "12",
+ "13",
+ "14",
+ "15",
+ "16",
+ "17",
+ "18",
+ "19",
+ "20",
+ "21",
+ "22",
+ "23",
+ "24",
+ "25"
+ ]
+ },
+ {
+ "key": "fmrec",
+ "label": "Forbid FM Radio Receive",
+ "type": "boolean"
+ },
+ {
+ "key": "section-scan",
+ "label": "Scan",
+ "type": "section",
+ "group": "Scan"
+ },
+ {
+ "key": "scanmode",
+ "label": "Scan Mode",
+ "type": "select",
+ "options": [
+ "TO",
+ "CO",
+ "SE"
+ ]
+ },
+ {
+ "key": "section-keys",
+ "label": "Keys",
+ "type": "section",
+ "group": "Keys"
+ },
+ {
+ "key": "ssidekey1",
+ "label": "PF1 Short Press",
+ "type": "select",
+ "options": [
+ "None",
+ "FM Radio",
+ "Lamp",
+ "Monitor",
+ "TONE",
+ "Alarm",
+ "Weather"
+ ]
+ },
+ {
+ "key": "lsidekey3",
+ "label": "PF1 Long Press",
+ "type": "select",
+ "options": [
+ "None",
+ "FM Radio",
+ "Lamp",
+ "Monitor",
+ "TONE",
+ "Alarm",
+ "Weather"
+ ]
+ },
+ {
+ "key": "stopkey1",
+ "label": "Top Key Short Press",
+ "type": "select",
+ "options": [
+ "None",
+ "FM Radio",
+ "Lamp",
+ "Monitor",
+ "TONE",
+ "Alarm",
+ "Weather"
+ ]
+ },
+ {
+ "key": "ltopkey2",
+ "label": "Top Key Long Press",
+ "type": "select",
+ "options": [
+ "None",
+ "FM Radio",
+ "Lamp",
+ "Monitor",
+ "TONE",
+ "Alarm",
+ "Weather"
+ ]
+ },
+ {
+ "key": "ssidekey2",
+ "label": "PF2 Short Press",
+ "type": "select",
+ "options": [
+ "None",
+ "FM Radio",
+ "Lamp",
+ "Monitor",
+ "TONE",
+ "Alarm",
+ "Weather"
+ ]
+ },
+ {
+ "key": "lsidekey4",
+ "label": "PF2 Long Press",
+ "type": "select",
+ "options": [
+ "None",
+ "FM Radio",
+ "Lamp",
+ "Monitor",
+ "TONE",
+ "Alarm",
+ "Weather"
+ ]
+ },
+ {
+ "key": "section-dtmf-signaling",
+ "label": "DTMF & Signaling",
+ "type": "section",
+ "group": "DTMF & Signaling"
+ },
+ {
+ "key": "gcode",
+ "label": "Group Code",
+ "type": "select",
+ "options": [
+ "",
+ "Off",
+ "*",
+ "#",
+ "A",
+ "B",
+ "C",
+ "D"
+ ]
+ },
+ {
+ "key": "icode",
+ "label": "ID Code",
+ "type": "text",
+ "max_length": 3
+ },
+ {
+ "key": "group1",
+ "label": "Group Call 1",
+ "type": "text",
+ "max_length": 7
+ },
+ {
+ "key": "group2",
+ "label": "Group Call 2",
+ "type": "text",
+ "max_length": 7
+ },
+ {
+ "key": "group3",
+ "label": "Group Call 3",
+ "type": "text",
+ "max_length": 7
+ },
+ {
+ "key": "group4",
+ "label": "Group Call 4",
+ "type": "text",
+ "max_length": 7
+ },
+ {
+ "key": "group5",
+ "label": "Group Call 5",
+ "type": "text",
+ "max_length": 7
+ },
+ {
+ "key": "group6",
+ "label": "Group Call 6",
+ "type": "text",
+ "max_length": 7
+ },
+ {
+ "key": "group7",
+ "label": "Group Call 7",
+ "type": "text",
+ "max_length": 7
+ },
+ {
+ "key": "group8",
+ "label": "Group Call 8",
+ "type": "text",
+ "max_length": 7
+ },
+ {
+ "key": "scode",
+ "label": "PTT ID Start (BOT)",
+ "type": "text",
+ "max_length": 7
+ },
+ {
+ "key": "ecode",
+ "label": "PTT ID End (EOT)",
+ "type": "text",
+ "max_length": 7
+ },
+ {
+ "key": "dtmfst",
+ "label": "DTMF Side Tones",
+ "type": "boolean"
+ }
+]