fix(tci server): split armed on the frequency asked for, in either order
Audit prompted by "are we sure the commands are implemented — split, Fake It, Split rig?". The rigctl server is complete and hardened; the TCI one, three days old, had reintroduced a bug rigctld had already paid for. A client working split says two things — where to transmit, and that split is on — and nothing obliges it to say them in that order. A write to channel B while the rig was still simplex was DISCARDED, on the sound principle that preparing a transmit frequency is not a request to QSY. But then the split was armed on whatever the transmit VFO held, which is the receive frequency: the operator transmits straight onto the DX while their software shows exactly what they asked for. The frequency is now remembered and used when the split arrives, which is what rigctld does with set_split_vfo / set_split_freq. Two more from the same source: Asking for a split state the rig is already in touches nothing. A client in Fake It uses no split but still says so to be sure, and answering an error to a request that was already true is what made JTDX abandon a transmission a second into the frame through the rigctl server. A repeated PTT command is not re-sent. One client restated it sixteen times a second, and the Flex's own "xmit 1" was overwritten between two of them inside a millisecond. The same radio sits behind this server — the operator reporting this is on the Flex API backend. Fake It itself needs nothing but channel A, and now has a test saying so.
This commit is contained in:
@@ -248,3 +248,83 @@ func TestUnknownCommandsAreQuiet(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Split, with the client sending the two commands in the order it prefers.
|
||||
//
|
||||
// A client working split has to say two things: where to transmit, and that
|
||||
// split is on. Nothing obliges it to say them in that order, and the frequency
|
||||
// arriving first is the dangerous case: discarding it and then arming split
|
||||
// leaves the transmit VFO on whatever it held — the RECEIVE frequency — so the
|
||||
// operator transmits straight onto the DX while their software shows exactly
|
||||
// what they asked for.
|
||||
func TestSplitIsArmedOnTheFrequencyTheClientGaveWhicheverOrderItCame(t *testing.T) {
|
||||
// Frequency first, then split — the order that used to lose the frequency.
|
||||
r := &fakeRig{freq: 14025000, rxFreq: 14025000, mode: "CW"}
|
||||
s := srv(r)
|
||||
ask(t, s, "vfo:0,1,14027000")
|
||||
ask(t, s, "split_enable:0,true")
|
||||
if len(r.calls) != 1 || r.calls[0] != "split=true,14027000" {
|
||||
t.Errorf("frequency first: the radio was told %v, want split armed on 14027000", r.calls)
|
||||
}
|
||||
|
||||
// Split first, then the frequency — the order that always worked.
|
||||
r2 := &fakeRig{freq: 14025000, rxFreq: 14025000, mode: "CW"}
|
||||
s2 := srv(r2)
|
||||
ask(t, s2, "split_enable:0,true")
|
||||
ask(t, s2, "vfo:0,1,14027000")
|
||||
if len(r2.calls) == 0 || r2.calls[len(r2.calls)-1] != "split=true,14027000" {
|
||||
t.Errorf("split first: the radio was told %v, want it to end on 14027000", r2.calls)
|
||||
}
|
||||
}
|
||||
|
||||
// "Fake It" uses no split at all: the client shifts the DIAL at the start of
|
||||
// transmit and shifts it back at the end. All it needs is channel A, and it
|
||||
// must reach the radio both ways.
|
||||
func TestFakeItIsJustTheDialMoving(t *testing.T) {
|
||||
r := &fakeRig{freq: 14074000, rxFreq: 14074000, mode: "USB"}
|
||||
s := srv(r)
|
||||
ask(t, s, "vfo:0,0,14075300") // up for the over
|
||||
ask(t, s, "vfo:0,0,14074000") // and back
|
||||
want := []string{"freq=14075300", "freq=14074000"}
|
||||
if strings.Join(r.calls, " ") != strings.Join(want, " ") {
|
||||
t.Errorf("the radio was told %v, want %v", r.calls, want)
|
||||
}
|
||||
}
|
||||
|
||||
// A client in Fake It still says "split off" to be sure. The rig is already
|
||||
// simplex, so there is nothing to do — and saying so beats asking a backend
|
||||
// that may not be able to set split at all.
|
||||
//
|
||||
// This is what broke JTDX through the rigctl server: an error answered to a
|
||||
// request that was already true, read as rig control failing, and the
|
||||
// transmission abandoned a second into the frame.
|
||||
func TestSayingSplitOffWhenAlreadySimplexTouchesNothing(t *testing.T) {
|
||||
r := &fakeRig{freq: 14074000, rxFreq: 14074000, mode: "USB",
|
||||
splitErr: fmt.Errorf("this backend cannot split")}
|
||||
s := srv(r)
|
||||
ask(t, s, "split_enable:0,false")
|
||||
if len(r.calls) != 0 {
|
||||
t.Errorf("the radio was told %v for a state it was already in", r.calls)
|
||||
}
|
||||
}
|
||||
|
||||
// A client restating PTT must not re-command the radio. Through the rigctl
|
||||
// server, one sent set_ptt 0 sixteen times a second and the Flex's own transmit
|
||||
// request was overwritten between two of them inside a millisecond.
|
||||
func TestRepeatedPTTIsNotResentToTheRadio(t *testing.T) {
|
||||
r := &fakeRig{freq: 14074000, rxFreq: 14074000, mode: "USB"}
|
||||
s := srv(r)
|
||||
for i := 0; i < 5; i++ {
|
||||
ask(t, s, "trx:0,false")
|
||||
}
|
||||
if len(r.calls) != 1 || r.calls[0] != "ptt=false" {
|
||||
// The FIRST one always goes through: there is no knowing how the radio
|
||||
// was left.
|
||||
t.Errorf("the radio was told %v, want one unkey and no repeats", r.calls)
|
||||
}
|
||||
ask(t, s, "trx:0,true")
|
||||
ask(t, s, "trx:0,true")
|
||||
if len(r.calls) != 2 || r.calls[1] != "ptt=true" {
|
||||
t.Errorf("the radio was told %v, want the change through and the repeat dropped", r.calls)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user