Files
OpsLog/icom_models_test.go
T
rouggy 8a0d76fa0c feat: IC-7300MKII, and two Icom addresses that were plain wrong
Adds the IC-7300MKII at CI-V 0xB6.

Doing so exposed a drift between the two hand-kept copies of the model table: the
settings offered the IC-7700 at 0x88 and the IC-7800 at 0x80, which are the
IC-7100's and the IC-7410's factory addresses. Picking either set an address the
rig never answers on — the symptom is a radio that simply stays silent — and the
backend then named it as the other model. Corrected to 0x74 and 0x6A, and the
four models the backend already knew (IC-7100, IC-7410, IC-7600, IC-7851) are now
offered too instead of forcing a manual address.

A test reads the model list out of the .tsx and asserts civ.ModelName agrees, so
the next model added on one side alone fails the build rather than someone's
radio.
2026-07-28 22:38:02 +02:00

43 lines
1.4 KiB
Go

package main
import (
"os"
"regexp"
"strconv"
"testing"
"hamlog/internal/cat/civ"
)
// The Icom model picker in the settings and civ.ModelName are two hand-kept
// copies of the same table, and they had drifted: the UI offered the IC-7700 at
// 0x88 and the IC-7800 at 0x80, which are the IC-7100's and the IC-7410's
// factory addresses. Picking either set an address the rig never answers on —
// the symptom is a rig that simply never replies — and the backend then named it
// as the other model.
//
// The list is read out of the .tsx itself, so a model added on one side alone
// fails here rather than on someone's radio.
func TestIcomModelAddressesMatch(t *testing.T) {
src, err := os.ReadFile("frontend/src/components/SettingsModal.tsx")
if err != nil {
t.Skipf("frontend source not available: %v", err)
}
re := regexp.MustCompile(`\{ name: '(IC-[A-Za-z0-9-]+)', addr: 0x([0-9A-Fa-f]{2}) \}`)
ms := re.FindAllStringSubmatch(string(src), -1)
if len(ms) < 5 {
t.Fatalf("only %d models found — the parse is wrong, not the data", len(ms))
}
for _, m := range ms {
name := m[1]
addr, err := strconv.ParseUint(m[2], 16, 8)
if err != nil {
t.Fatalf("bad address %q for %s", m[2], name)
}
if got := civ.ModelName(byte(addr)); got != name {
t.Errorf("settings offer %s at 0x%02X, but civ.ModelName(0x%02X) = %q",
name, addr, addr, got)
}
}
}