Measured rather than guessed: the whole repository was cross-compiled for
linux/amd64 and the gaps closed one by one. There were fewer than expected.
Flex and TCI were never Windows-specific — they carried //go:build windows by
inheritance and import nothing but net and gorilla/websocket. Untagged, no code
change. The two backends a Linux operator is most likely to own were already
portable.
Audio was 560 lines, not 2287: only devices.go and engine.go touch WASAPI, while
manager.go, recorder.go, wav.go and mp3.go were pure Go wearing the tag by
association. The whole platform surface is seven functions, now implemented a
second time on PulseAudio through github.com/jfreymuth/pulse — pure Go over the
server socket, so the no-cgo rule survives, and PipeWire answers the same
protocol. The fixed 16 kHz mono format and the server-side resampling mirror
what AUTOCONVERTPCM does on Windows, for the same reason.
OmniRig is the only real loss, and its backend still EXISTS off Windows rather
than being compiled out of app.go: a settings database is portable, so an
operator moving a profile across keeps "omnirig" saved and must be told to pick
a native backend instead of meeting a nil one.
The parts where Linux is not Windows, and where a compile-only stub would have
been a silent bug:
- data dir: still beside the binary, but ~/.local/share/OpsLog/data when that
folder belongs to the system — decided by trying the write, because /opt and
/usr/local are writable on some stations and not others.
- single instance: an flock, not a pid file. The kernel drops it however the
process dies, so a crash leaves nothing to delete by hand. This is the guard
that stops two instances fighting over the rig frequency.
- update: simpler here. Unix renames over a running binary, so the deferred
swap the Windows path needs a detached helper for is unreachable.
- tasklist/taskkill become /proc and SIGTERM; the boot log moves out of /tmp,
which is wiped exactly when the evidence is wanted.
- serial ports sorted naturally: /dev/ttyUSB10 was landing between USB1 and
USB2, the same trap COM10 fell into.
release.ps1 now cross-builds and vets for linux before it builds the exe, and
refuses the release if that fails — a port rots one unguarded x/sys/windows call
at a time.
Nothing has been executed on Linux yet: Wails needs webkit2gtk and cgo there, so
the binary must be built on Linux. scripts/linux-setup.sh checks the machine and
does it; BUILDING-LINUX.md is the manual version.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
79 lines
2.8 KiB
Go
79 lines
2.8 KiB
Go
package cat
|
|
|
|
import "testing"
|
|
|
|
// feed pushes messages at the backend the way the radio would.
|
|
func feed(t *TCI, msgs ...string) {
|
|
for _, m := range msgs {
|
|
t.handle(m)
|
|
}
|
|
}
|
|
|
|
// "PTT via CAT does nothing on TCI."
|
|
//
|
|
// ExpertSDR announces transmit permission with TX_ENABLE — on connect, and
|
|
// again whenever the band changes "in case transmitter permission was changed"
|
|
// (§4.3 of the protocol document). When it is false the radio simply IGNORES
|
|
// trx. OpsLog sent the documented command, the radio discarded it, and nothing
|
|
// anywhere said why: the operator pressed a dead key.
|
|
func TestPTTIsRefusedOutLoudWhenTheRadioForbidsTransmitting(t *testing.T) {
|
|
tci := NewTCI("localhost", 40001, "FT8", false)
|
|
feed(tci, "tx_enable:0,false")
|
|
|
|
err := tci.SetPTT(true)
|
|
if err == nil {
|
|
t.Fatal("keying was accepted while the radio forbids transmitting — the operator gets no reason at all")
|
|
}
|
|
// The message has to name where to look; "PTT failed" sends nobody anywhere.
|
|
for _, want := range []string{"transmit", "ExpertSDR"} {
|
|
if !contains(err.Error(), want) {
|
|
t.Errorf("the refusal reads %q, which does not mention %q", err.Error(), want)
|
|
}
|
|
}
|
|
|
|
// Unkeying is never blocked. Whatever the radio thinks about permission, a
|
|
// request to STOP transmitting must always reach it.
|
|
if err := tci.SetPTT(false); err != nil && contains(err.Error(), "refusing") {
|
|
t.Errorf("unkeying was refused: %v", err)
|
|
}
|
|
}
|
|
|
|
// Permission comes back when the operator returns to a band they may use, and
|
|
// PTT has to come back with it — not stay blocked until OpsLog is restarted.
|
|
func TestPermissionGrantedAgainRestoresPTT(t *testing.T) {
|
|
tci := NewTCI("localhost", 40001, "FT8", false)
|
|
feed(tci, "tx_enable:0,false")
|
|
if err := tci.SetPTT(true); err == nil {
|
|
t.Fatal("keying was accepted while forbidden")
|
|
}
|
|
feed(tci, "tx_enable:0,true")
|
|
// No connection here, so the send fails — but it must fail as a TRANSPORT
|
|
// error, never as a refusal.
|
|
if err := tci.SetPTT(true); err != nil && contains(err.Error(), "refusing") {
|
|
t.Errorf("still refusing after permission was granted: %v", err)
|
|
}
|
|
}
|
|
|
|
// A radio that never mentions TX_ENABLE — an older ExpertSDR, or one of the
|
|
// other programs that speak TCI — must not be treated as refusing. Silence is
|
|
// not a "no": we key, and let the radio decide.
|
|
func TestSilenceAboutPermissionIsNotARefusal(t *testing.T) {
|
|
tci := NewTCI("localhost", 40001, "FT8", false)
|
|
if err := tci.SetPTT(true); err != nil && contains(err.Error(), "refusing") {
|
|
t.Errorf("a radio that never sent TX_ENABLE was treated as forbidding transmit: %v", err)
|
|
}
|
|
}
|
|
|
|
func contains(s, sub string) bool {
|
|
return len(sub) == 0 || (len(s) >= len(sub) && indexOf(s, sub) >= 0)
|
|
}
|
|
|
|
func indexOf(s, sub string) int {
|
|
for i := 0; i+len(sub) <= len(s); i++ {
|
|
if s[i:i+len(sub)] == sub {
|
|
return i
|
|
}
|
|
}
|
|
return -1
|
|
}
|