fix(yaesu): the power ceiling is the radio's, not a constant

Reported on an FTDX101MP: the slider sprang back to 100 W. The console
was not wrong about the rig — yaesuMaxPower already answered 200 for
that model, and the slider was drawn to it. The SET path carried its own
hard-coded 100, so asking for 200 W sent PC100, the radio obeyed, and
the next poll read back what had actually been set.

One ceiling now, the one the console draws to, so the two cannot say
different things. Pinned with the model list, including the unknown-rig
case: crediting a radio with power it does not have would be commands it
NAKs, so silence still means 100.
This commit is contained in:
2026-09-04 08:34:28 +02:00
parent 6cbe29fef1
commit b318aa66cc
3 changed files with 41 additions and 3 deletions
+8 -1
View File
@@ -388,7 +388,14 @@ func (y *Yaesu) RefreshYaesu() error {
}
func (y *Yaesu) SetYaesuPower(w int) error {
return y.setAndRefresh(fmt.Sprintf("PC%03d;", clampInt(w, 5, 100)))
// The SAME ceiling the console draws its slider to. It was hard-coded at 100
// here while yaesuMaxPower already answered 200 for an FTDX101MP: asking for
// 200 W sent PC100, the rig obeyed, and the slider sprang back to 100 on the
// next poll — which is how the operator discovered it.
y.mu.Lock()
max := yaesuMaxPower(y.model, y.panel.RFPower)
y.mu.Unlock()
return y.setAndRefresh(fmt.Sprintf("PC%03d;", clampInt(w, 5, max)))
}
func (y *Yaesu) SetYaesuMicGain(p int) error {
+29
View File
@@ -0,0 +1,29 @@
package cat
import "testing"
// Reported on an FTDX101MP: the power slider sprang back to 100 W. The console
// already knew the rig could do 200 — yaesuMaxPower says so — but the SET path
// clamped to 100, so the radio was politely given half what was asked for.
func TestYaesuPowerCeilingFollowsTheModel(t *testing.T) {
cases := []struct {
model string
want int
}{
{"FTDX101MP", 200},
{"FT-DX5000", 200},
{"FTDX9000", 200},
{"FTDX101D", 100},
{"FTDX10", 100},
{"Yaesu (0999)", 100}, // unknown: ask for too little, never too much
}
for _, c := range cases {
if got := yaesuMaxPower(c.model, 0); got != c.want {
t.Errorf("%s ceiling = %d W, want %d", c.model, got, c.want)
}
}
// A rig REPORTING more than the table expects has just proved what it can do.
if got := yaesuMaxPower("FTDX10", 150); got != 150 {
t.Errorf("a rig reporting 150 W was capped at %d", got)
}
}