fix(tci): a refused PTT is reported instead of vanishing

"PTT via CAT does nothing on TCI." What OpsLog sends is right — trx:0,true; is
the documented command and the same one the reference clients send — so the
command was going out and the radio was discarding it.

ExpertSDR announces transmit permission with TX_ENABLE: on connect, and again
whenever the band changes, "in case transmitter permission was changed" (§4.3).
While it is false the radio simply IGNORES trx. OpsLog never read that command,
so there was nothing in the log, nothing on screen, and a dead key.

Now the permission is tracked and SetPTT refuses out loud, naming where to look:
the frequency must be inside a transmit band and TX enabled in ExpertSDR. The
refusal travels the path that already exists — Manager.SetPTT to pttKey, which
logs it and hands it to the UI.

Silence is not a "no". A radio that never mentions TX_ENABLE — an older
ExpertSDR, or another program speaking TCI — is not treated as refusing: we key
and let it decide. Permission is also forgotten on connect, so a refusal
remembered from a band since left cannot block PTT until a restart.

This may not be the operator's own cause, and that is the other half of the
change: if it is not, the log now settles it in one line. cat: TCI: → trx:0,true;
present means the command left OpsLog and the radio ignored it for a reason it
has not told us; absent means the fault is on this side.
This commit is contained in:
2026-08-17 09:30:36 +02:00
parent 3f95763ca6
commit 4095455e66
3 changed files with 123 additions and 2 deletions
+39
View File
@@ -46,6 +46,18 @@ type TCI struct {
mode string
split bool
tx bool
// txAllowed is what the radio last said about TRANSMIT PERMISSION.
//
// TX_ENABLE is sent by ExpertSDR when a client connects and again whenever
// the band changes, "in case transmitter permission was changed" (§4.3). When
// it is false the radio silently ignores TRX — which is exactly what an
// operator sees as "PTT does nothing", with no error anywhere to explain it.
//
// txAllowedKnown keeps an OLDER ExpertSDR, or a TCI-compatible program that
// never sends TX_ENABLE at all, from being treated as refusing: without a
// word from the radio we key and let it decide.
txAllowed bool
txAllowedKnown bool
lastSig string // last logged state signature (log only on change)
@@ -109,6 +121,10 @@ func (t *TCI) Connect() error {
t.mu.Lock()
t.conn = conn
t.ready = false
// Forget the previous session's transmit permission: the radio announces it
// again on connect, and a refusal remembered from a band we have since left
// would block PTT until it did.
t.txAllowed, t.txAllowedKnown = false, false
t.mu.Unlock()
debugLog.Printf("TCI: connected to %s", url)
go t.reader(conn)
@@ -298,7 +314,22 @@ func (t *TCI) SetMode(mode string) error {
}
// SetPTT keys or unkeys the transmitter (VFO 0).
//
// A refusal by the radio is reported rather than swallowed. ExpertSDR announces
// transmit permission with TX_ENABLE and then simply IGNORES trx when it is
// false — out-of-band frequency, TX disabled in the program, no PA. The command
// went out, nothing happened, and nothing anywhere said why. Now the operator
// is told, and the message names the place to look.
func (t *TCI) SetPTT(on bool) error {
if on {
t.mu.Lock()
known, allowed := t.txAllowedKnown, t.txAllowed
t.mu.Unlock()
if known && !allowed {
return fmt.Errorf("the radio is refusing to transmit (TCI reports TX disabled) — " +
"check the frequency is inside a transmit band and that TX is enabled in ExpertSDR")
}
}
return t.send(fmt.Sprintf("trx:0,%t;", on))
}
@@ -392,6 +423,14 @@ func (t *TCI) handle(msg string) {
if get(0) == "0" {
t.tx = get(1) == "true"
}
case "tx_enable":
if get(0) == "0" {
allowed := get(1) == "true"
if !t.txAllowedKnown || t.txAllowed != allowed {
debugLog.Printf("TCI: the radio %s transmitting", map[bool]string{true: "allows", false: "REFUSES"}[allowed])
}
t.txAllowed, t.txAllowedKnown = allowed, true
}
default:
lname := strings.ToLower(name)
// A click on one of our panorama spots comes back as