diff --git a/changelog.json b/changelog.json index dd80656..4a23a56 100644 --- a/changelog.json +++ b/changelog.json @@ -3,10 +3,12 @@ "version": "0.23.7", "date": "", "en": [ - "QSO edit: added the QRZ ↗ button next to the callsign, like the main entry form — one click opens that station's qrz.com profile." + "QSO edit: added the QRZ ↗ button next to the callsign, like the main entry form — one click opens that station's qrz.com profile.", + "PowerGenius XL: the fan mode (Standard / Contest / Broadcast) changes on the amp again. A previous fix dropped the \"setup\" prefix the amp requires (\"setup fanmode=…\"), so the amp rejected the command and the mode snapped straight back. The correct command is restored." ], "fr": [ - "Édition de QSO : ajout du bouton QRZ ↗ à côté de l'indicatif, comme dans le formulaire de saisie — un clic ouvre le profil qrz.com de la station." + "Édition de QSO : ajout du bouton QRZ ↗ à côté de l'indicatif, comme dans le formulaire de saisie — un clic ouvre le profil qrz.com de la station.", + "PowerGenius XL : le mode ventilateur (Standard / Contest / Broadcast) change de nouveau sur l'ampli. Un correctif précédent avait retiré le préfixe « setup » exigé par l'ampli (« setup fanmode=… »), qui rejetait donc la commande et le mode revenait aussitôt en arrière. La bonne commande est rétablie." ] }, { diff --git a/internal/powergenius/powergenius.go b/internal/powergenius/powergenius.go index 5fdadc0..964ea8c 100644 --- a/internal/powergenius/powergenius.go +++ b/internal/powergenius/powergenius.go @@ -125,14 +125,19 @@ func (c *Client) SetFanMode(mode string) error { default: return fmt.Errorf("powergenius: invalid fan mode %q", mode) } - // Set with the bare "key=value" verb the amp uses for its own status fields - // (same convention as "operate=1"). The earlier "setup fanmode=…" carried a - // bogus prefix the amp silently ignored, so the fan never changed and the next - // status kept reporting the old mode — the revert-to-Contest the operator saw. - reply, err := c.command("fanmode=" + m) + // The verb the amp wants is "setup fanmode=VALUE" — confirmed LIVE: with the + // "setup " prefix the amp replies code 0 (accepted), while the bare + // "fanmode=VALUE" we switched to earlier is rejected (reply code 0x50000015). + // That regression is what stopped the fan from changing; restoring "setup " + // fixes it. + reply, err := c.command("setup fanmode=" + m) if err != nil { return err } + if code := replyCode(reply); code != "" && code != "0" { + applog.Printf("pgxl: set fanmode=%s REJECTED, reply=%q", m, reply) + return fmt.Errorf("powergenius: amp rejected fanmode=%s (code %s)", m, code) + } applog.Printf("pgxl: set fanmode=%s reply=%q", m, reply) c.statusMu.Lock() c.status.FanMode = m // optimistic @@ -141,6 +146,19 @@ func (c *Client) SetFanMode(mode string) error { return nil } +// replyCode returns the result code from an "R||…" reply — "0" means +// the amp accepted the command. Returns "" when the line isn't an R reply. +func replyCode(reply string) string { + if !strings.HasPrefix(reply, "R") { + return "" + } + p := strings.SplitN(reply, "|", 3) + if len(p) < 2 { + return "" + } + return strings.TrimSpace(p[1]) +} + // SetOperate puts the amp in OPERATE (1) or STANDBY (0). func (c *Client) SetOperate(on bool) error { v := "0"