fix(udp): two copies of MSHV shared one dial frequency
FT8 decodes made on 14.095 were labelled 2190 m. That band is 135.7-137.8 kHz, and every affected decode's audio offset plus 136.1 kHz lands inside it — while the ones shown with no band at all land just above 137.8. The decodes were being stamped with another instance's dial. WSJT-X refuses to start a second instance without --rig-name, so its ids differ and keying on the id worked. MSHV has no such rule: both copies call themselves 'MSHV', so the LF instance's Status overwrote the HF one's dial, T/R period and mode. Instances are now identified by their sending socket as well as their name — the socket is stable for as long as the program runs, which is exactly the lifetime this has to hold over. A second application claiming an id already in use is shown as 'MSHV #2' and says so in the log, so the decodes panel can still split them. This also fixes replies: a Reply was addressed to whichever copy sent Status last, which on a two-instance station is a coin toss.
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package udp
|
||||
|
||||
import (
|
||||
"net"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Two copies of MSHV call themselves "MSHV". WSJT-X refuses to start a second
|
||||
// instance without --rig-name, so its ids differ; MSHV has no such rule, and
|
||||
// everything a decode needs — the dial frequency, the T/R period, the mode —
|
||||
// used to be filed under the id alone.
|
||||
//
|
||||
// The consequence was reported from a real station: the second copy, on LF,
|
||||
// overwrote the dial of the first, and FT8 decodes made on 14.095 came out
|
||||
// labelled 2190 m — which is 136 kHz plus an audio offset, to the hertz.
|
||||
func TestSameProgramIDFromTwoAddressesAreTwoInstances(t *testing.T) {
|
||||
s := &Server{}
|
||||
a := &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 2237}
|
||||
b := &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 2238}
|
||||
|
||||
first := s.instanceLabel("MSHV", a)
|
||||
second := s.instanceLabel("MSHV", b)
|
||||
if first == second {
|
||||
t.Fatalf("two applications on different sockets share the label %q", first)
|
||||
}
|
||||
if first != "MSHV" {
|
||||
t.Fatalf("the first instance should keep the plain id, got %q", first)
|
||||
}
|
||||
|
||||
// Stable: the same socket must keep its name for as long as it runs, or the
|
||||
// decodes panel would grow a new column every time a packet arrived.
|
||||
if again := s.instanceLabel("MSHV", a); again != first {
|
||||
t.Fatalf("label changed for the same address: %q then %q", first, again)
|
||||
}
|
||||
if again := s.instanceLabel("MSHV", b); again != second {
|
||||
t.Fatalf("label changed for the same address: %q then %q", second, again)
|
||||
}
|
||||
}
|
||||
|
||||
// Distinct ids stay distinct without decoration — a station running WSJT-X and
|
||||
// MSHV should not see either renamed.
|
||||
func TestDifferentProgramIDsAreLeftAlone(t *testing.T) {
|
||||
s := &Server{}
|
||||
a := &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 2237}
|
||||
b := &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 2238}
|
||||
if got := s.instanceLabel("WSJT-X", a); got != "WSJT-X" {
|
||||
t.Fatalf("WSJT-X was renamed to %q", got)
|
||||
}
|
||||
if got := s.instanceLabel("MSHV", b); got != "MSHV" {
|
||||
t.Fatalf("MSHV was renamed to %q", got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user