chore: release v0.26.0
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
package udp
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"net"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// A Decode does not carry the mode's NAME. It carries the one-character marker
|
||||
// from the decode line — "~" for FT8, "+" for FT4 — and that character used to
|
||||
@@ -57,3 +62,54 @@ func upper(s string) string {
|
||||
}
|
||||
return string(out)
|
||||
}
|
||||
|
||||
// Resolving the marker must not DESTROY it. A Reply is matched by the receiving
|
||||
// application against its own decode list field for field, and the mode field it
|
||||
// compares is the one it sent — the marker. Sending the resolved name instead is
|
||||
// accepted silently and simply never transmits: JTDX finds no matching decode,
|
||||
// and no error is reported anywhere to say so. Reported as "clicking a CQ does
|
||||
// nothing in JTDX".
|
||||
//
|
||||
// So a Decode has to carry BOTH: Mode for the log and the status resolver,
|
||||
// DecodeModeRaw for the Reply.
|
||||
func TestDecodeKeepsTheRawModeMarkerForReplies(t *testing.T) {
|
||||
qstr := func(b *bytes.Buffer, v string) {
|
||||
binary.Write(b, binary.BigEndian, int32(len(v)))
|
||||
b.WriteString(v)
|
||||
}
|
||||
var p bytes.Buffer
|
||||
binary.Write(&p, binary.BigEndian, uint32(wsjtMagic))
|
||||
binary.Write(&p, binary.BigEndian, uint32(2)) // schema
|
||||
binary.Write(&p, binary.BigEndian, uint32(wsjtMsgDecode)) // type 2
|
||||
qstr(&p, "JTDX") // id
|
||||
binary.Write(&p, binary.BigEndian, uint8(1)) // is_new
|
||||
binary.Write(&p, binary.BigEndian, uint32(45_000_000)) // time (ms since midnight)
|
||||
binary.Write(&p, binary.BigEndian, int32(-6)) // snr
|
||||
binary.Write(&p, binary.BigEndian, float64(0.2)) // delta_time
|
||||
binary.Write(&p, binary.BigEndian, uint32(1500)) // delta_frequency
|
||||
qstr(&p, "~") // mode — the MARKER
|
||||
qstr(&p, "CQ EN35UKR") // message
|
||||
|
||||
out := make(chan Event, 4)
|
||||
s := &Server{
|
||||
out: out,
|
||||
cfg: Config{Name: "JTDX", ServiceType: ServiceWSJT},
|
||||
lastMode: map[string]string{"JTDX": "FT8"},
|
||||
dialHz: map[string]int64{"JTDX": 14074000},
|
||||
}
|
||||
s.handle(p.Bytes(), &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 2237})
|
||||
|
||||
var ev Event
|
||||
select {
|
||||
case ev = <-out:
|
||||
default:
|
||||
t.Fatal("no event emitted for the decode")
|
||||
}
|
||||
if ev.Mode != "FT8" {
|
||||
t.Errorf("resolved Mode = %q, want FT8 (what the log and the status resolver need)", ev.Mode)
|
||||
}
|
||||
if ev.DecodeModeRaw != "~" {
|
||||
t.Errorf("DecodeModeRaw = %q, want %q — a Reply built from this will not match and JTDX will not transmit",
|
||||
ev.DecodeModeRaw, "~")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user