feat(rotator): one list of rotator interfaces, and ERC-M

The satellite page configured its own EasyComm or PstRotator link while five
other backends were configured in the rotator list. An operator with one az/el
mast therefore described it twice, and could describe it differently the second
time — a station that works on HF and not on a pass, for no reason visible
anywhere on screen.

Now every interface lives in Settings ▸ Rotator, once, and the satellite page
stores only a KEY into that list plus the tracking policy that is genuinely its
own (minimum elevation, step, park). The key and not the index: deleting the
first rotor must not silently point the tracker at a different mast.
migrateSatRotator() turns an existing satellite link into a real entry in the
list, selects it, and clears the old keys so it cannot run twice.

Which rotors have an elevation axis is now a question with one answer, in Go:
rotatorTypes plus rotorHasElevation, exposed to the panel by GetRotatorTypes.
The dropdown, the labels, each backend's default port and default baud all come
from there, so TypeScript no longer keeps a second copy of the same knowledge to
drift out of step. Three cases do not follow from the type alone and are treated
as such: PstRotator forwards elevation to a mast that may not have any, so the
operator says; a SPID's dialect decides (Rot1Prog has no elevation in its reply
format); and an ARCO and an ERC-M speak the same GS-232 while only one of them
lifts.

Each interface carries an Az / Az+El badge beside it. The satellite rotor
dropdown LISTS the azimuth-only ones, disabled, rather than hiding them: an
operator who owns one rotator and does not see it concludes OpsLog cannot find
it, where a greyed row saying "azimuth only" teaches the actual thing.

ERC-M by DF9GR is new — the az/el interface for a Yaesu G-5500. It emulates
GS-232, so internal/rotator/gs232 grew the elevation half: W for a two-axis
move, C2 to read both, falling back to C+B for the firmware that answers C2 with
the azimuth alone. That fallback is the point of the parser tests: reading such
a reply as "elevation zero" would put the antenna on the horizon, which is the
one wrong answer that looks plausible.

EasyComm II is promoted to an ordinary rotator interface, so it can also turn
the antenna from the compass and from a spot click.

The ERC-M is UNTESTED on hardware. Its Test button reads BOTH axes rather than
just the azimuth, so a controller wired for azimuth alone says so there instead
of during a pass.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
2026-09-09 11:04:04 +02:00
co-authored by Claude Opus 5
parent 8b1dff581b
commit ca81d4fc68
14 changed files with 1027 additions and 305 deletions
+126 -88
View File
@@ -34,15 +34,20 @@ const (
keySatGrid = "sat.grid" // locator override ("" = the station's own)
keySatAltM = "sat.alt_m" // antenna height above sea level, metres
// The az/el rotator. Its own settings rather than the HF rotator's: a
// satellite station's elevation rotator is a different machine on a
// different port, and an operator who has both must not have to choose.
// The az/el rotator.
keySatRotOn = "sat.rot_enabled"
// Which program drives the mast: OpsLog itself over EasyComm, or PstRotator,
// which many stations already run in front of their controller. Its own port
// key because it is a different program on a different port from an EasyComm
// controller, and an operator who tries both must not lose the first setting
// to the second.
// WHICH rotor, out of the ones configured in Settings ▸ Rotator — the key
// flattenRotors gives it. How to reach it is that list's business, not
// this page's: describing one mast in two places is how a station ends up
// working on HF and not on a pass.
keySatRotID = "sat.rot_id"
keySatRotMinEl = "sat.rot_min_el" // don't drive the rotator below this elevation
keySatRotStep = "sat.rot_step" // degrees of change worth a command
keySatRotPark = "sat.rot_park" // park at az 0 / el 0 when tracking stops
// The satellite page used to configure its own EasyComm or PstRotator link.
// These keys are read once by migrateSatRotator, which turns what they hold
// into a real entry in the rotator list, and are never written again.
keySatRotType = "sat.rot_type" // "easycomm" | "pstrotator"
keySatRotPstPort = "sat.rot_pst_port" // PstRotator's UDP command port
keySatRotTransport = "sat.rot_transport" // "serial" | "tcp"
@@ -51,9 +56,6 @@ const (
keySatRotCOM = "sat.rot_com"
keySatRotBaud = "sat.rot_baud"
keySatRotMaxAz = "sat.rot_max_az" // 360 or 450
keySatRotMinEl = "sat.rot_min_el" // don't drive the rotator below this elevation
keySatRotStep = "sat.rot_step" // degrees of change worth a command
keySatRotPark = "sat.rot_park" // park at az 0 / el 0 when tracking stops
)
// customTLEName holds elements the operator pasted in by hand.
@@ -74,18 +76,21 @@ type SatSettings struct {
AltM int `json:"alt_m"`
// The az/el rotator.
RotOn bool `json:"rot_on"`
RotType string `json:"rot_type"`
RotPstPort int `json:"rot_pst_port"`
RotTransport string `json:"rot_transport"`
RotHost string `json:"rot_host"`
RotPort int `json:"rot_port"`
RotCOM string `json:"rot_com"`
RotBaud int `json:"rot_baud"`
RotMaxAz int `json:"rot_max_az"`
RotMinEl int `json:"rot_min_el"`
RotStep int `json:"rot_step"`
RotPark bool `json:"rot_park"`
//
// RotID names one of the rotors configured in Settings ▸ Rotator — the
// key flattenRotors gives it. Everything about HOW to reach that rotator
// (backend, host, COM port, baud, 360/450) belongs to the rotator list and
// is deliberately not repeated here.
//
// What IS here is the tracking policy, which is the satellite page's own
// business and means nothing to a rotor turned by hand: below which
// elevation not to bother, how far the antenna must be off before a command
// is worth sending, and whether to park at the end.
RotOn bool `json:"rot_on"`
RotID string `json:"rot_id"`
RotMinEl int `json:"rot_min_el"`
RotStep int `json:"rot_step"`
RotPark bool `json:"rot_park"`
}
// SatTransponder is one path through a satellite, as the UI needs it.
@@ -189,6 +194,11 @@ type SatPassInfo struct {
// PC with no internet as much as on one with. The fetch is the slow, optional
// half and never blocks a launch.
func (a *App) startSatellites() {
// Before anything else reads the rotator choice: an operator upgrading from
// the version where the satellite page held its own rotator link must find
// that mast already in the list and already selected.
a.migrateSatRotator()
dir := a.dataDir
birds, err := sat.LoadBirds(dir)
if err != nil {
@@ -239,47 +249,23 @@ func (a *App) satParts() (*sat.Store, *sat.Birds, *sat.Fetcher) {
// ── Settings ────────────────────────────────────────────────────────────────
func (a *App) satSettings() SatSettings {
// The rotator defaults are the common case, not a blank form: EasyComm over
// a serial port at 9600, a 360° machine, and a five-degree step — which on a
// beam with any gain at all is well inside the beamwidth and keeps a pass
// from being a command a second.
// A five-degree step, which on a beam with any gain at all is well inside
// the beamwidth and keeps a pass from being a command a second.
out := SatSettings{
MinEl: 10, WindowH: 24, AutoTLE: true,
RotType: satRotEasycomm, RotPstPort: 12000,
RotTransport: "serial", RotPort: 4533, RotBaud: 9600,
RotMaxAz: 360, RotMinEl: 0, RotStep: 5,
RotMinEl: 0, RotStep: 5,
}
if a.settings == nil {
return out
}
m, err := a.settings.GetMany(a.ctx,
keySatFavorites, keySatMinEl, keySatWindowH, keySatAutoTLE, keySatGrid, keySatAltM,
keySatRotOn, keySatRotType, keySatRotPstPort, keySatRotTransport, keySatRotHost, keySatRotPort, keySatRotCOM,
keySatRotBaud, keySatRotMaxAz, keySatRotMinEl, keySatRotStep, keySatRotPark)
keySatRotOn, keySatRotID, keySatRotMinEl, keySatRotStep, keySatRotPark)
if err != nil {
return out
}
out.RotOn = m[keySatRotOn] == "1"
if ty := m[keySatRotType]; ty == satRotPst || ty == satRotEasycomm {
out.RotType = ty
}
if v, err := strconv.Atoi(m[keySatRotPstPort]); err == nil && v > 0 && v <= 65535 {
out.RotPstPort = v
}
if tr := m[keySatRotTransport]; tr == "tcp" || tr == "serial" {
out.RotTransport = tr
}
out.RotHost = strings.TrimSpace(m[keySatRotHost])
if v, err := strconv.Atoi(m[keySatRotPort]); err == nil && v > 0 && v <= 65535 {
out.RotPort = v
}
out.RotCOM = strings.TrimSpace(m[keySatRotCOM])
if v, err := strconv.Atoi(m[keySatRotBaud]); err == nil && v >= 1200 && v <= 115200 {
out.RotBaud = v
}
if v, err := strconv.Atoi(m[keySatRotMaxAz]); err == nil && v == 450 {
out.RotMaxAz = 450
}
out.RotID = strings.TrimSpace(m[keySatRotID])
if v, err := strconv.Atoi(m[keySatRotMinEl]); err == nil && v >= -10 && v <= 30 {
out.RotMinEl = v
}
@@ -337,46 +323,21 @@ func (a *App) SaveSatSettings(s SatSettings) error {
seen[strings.ToUpper(n)] = true
favs = append(favs, n)
}
if s.RotType != satRotPst {
s.RotType = satRotEasycomm
}
if s.RotPstPort <= 0 || s.RotPstPort > 65535 {
s.RotPstPort = 12000
}
if s.RotTransport != "tcp" {
s.RotTransport = "serial"
}
if s.RotMaxAz != 450 {
s.RotMaxAz = 360
}
if s.RotStep < 1 || s.RotStep > 30 {
s.RotStep = 5
}
if s.RotPort <= 0 || s.RotPort > 65535 {
s.RotPort = 4533
}
if s.RotBaud < 1200 || s.RotBaud > 115200 {
s.RotBaud = 9600
}
for k, v := range map[string]string{
keySatFavorites: strings.Join(favs, ","),
keySatMinEl: strconv.Itoa(s.MinEl),
keySatWindowH: strconv.Itoa(s.WindowH),
keySatAutoTLE: boolStr(s.AutoTLE),
keySatGrid: strings.ToUpper(strings.TrimSpace(s.Grid)),
keySatAltM: strconv.Itoa(s.AltM),
keySatRotOn: boolStr(s.RotOn),
keySatRotType: s.RotType,
keySatRotPstPort: strconv.Itoa(s.RotPstPort),
keySatRotTransport: s.RotTransport,
keySatRotHost: strings.TrimSpace(s.RotHost),
keySatRotPort: strconv.Itoa(s.RotPort),
keySatRotCOM: strings.TrimSpace(s.RotCOM),
keySatRotBaud: strconv.Itoa(s.RotBaud),
keySatRotMaxAz: strconv.Itoa(s.RotMaxAz),
keySatRotMinEl: strconv.Itoa(s.RotMinEl),
keySatRotStep: strconv.Itoa(s.RotStep),
keySatRotPark: boolStr(s.RotPark),
keySatFavorites: strings.Join(favs, ","),
keySatMinEl: strconv.Itoa(s.MinEl),
keySatWindowH: strconv.Itoa(s.WindowH),
keySatAutoTLE: boolStr(s.AutoTLE),
keySatGrid: strings.ToUpper(strings.TrimSpace(s.Grid)),
keySatAltM: strconv.Itoa(s.AltM),
keySatRotOn: boolStr(s.RotOn),
keySatRotID: strings.TrimSpace(s.RotID),
keySatRotMinEl: strconv.Itoa(s.RotMinEl),
keySatRotStep: strconv.Itoa(s.RotStep),
keySatRotPark: boolStr(s.RotPark),
} {
if err := a.settings.Set(a.ctx, k, v); err != nil {
return err
@@ -978,3 +939,80 @@ func (a *App) GetSatelliteTuning(name string, transponder int, downHz int64) (Sa
out.Visible = p.Visible()
return out, nil
}
// migrateSatRotator moves a pre-list satellite rotator into Settings ▸ Rotator.
//
// Until now the satellite page configured its own EasyComm or PstRotator link,
// separately from the rotator list every other backend lived in. An operator who
// had set one up must not open OpsLog to an empty dropdown and a mast that no
// longer turns — so the old keys are read once, turned into a real rotor in the
// list, and the satellite page is pointed at it.
//
// Runs once. The legacy keys are cleared afterwards so a second run cannot add
// the same mast a second time, and so the next reader of this file is not left
// wondering which of the two copies is live.
func (a *App) migrateSatRotator() {
if a.settings == nil {
return
}
m, err := a.settings.GetMany(a.ctx,
keySatRotID, keySatRotType, keySatRotTransport, keySatRotHost, keySatRotPort,
keySatRotCOM, keySatRotBaud, keySatRotPstPort, keySatRotMaxAz)
if err != nil {
return
}
if strings.TrimSpace(m[keySatRotID]) != "" {
return // already migrated, or configured since
}
legacy := strings.TrimSpace(m[keySatRotType])
if legacy == "" {
return // the satellite rotator was never configured
}
atoi := func(s string) int { n, _ := strconv.Atoi(s); return n }
dev := RotatorDevice{
ID: fmt.Sprintf("rotor-sat-%d", time.Now().Unix()),
Name: "Satellite",
MaxAz: atoi(m[keySatRotMaxAz]),
// A satellite rotor carries a fixed antenna, not a motorized Ultrabeam
// or SteppIR: showing it pattern paths would be showing it something it
// cannot do.
Motorized: false,
}
switch legacy {
case satRotPst:
dev.Type = "pst"
dev.Host = strings.TrimSpace(m[keySatRotHost])
dev.Port = atoi(m[keySatRotPstPort])
// It was in the satellite settings, so it has elevation by construction.
dev.HasElevation = true
default:
dev.Type = "easycomm"
dev.Transport = strings.TrimSpace(m[keySatRotTransport])
dev.Host = strings.TrimSpace(m[keySatRotHost])
dev.Port = atoi(m[keySatRotPort])
dev.ComPort = strings.TrimSpace(m[keySatRotCOM])
dev.Baud = atoi(m[keySatRotBaud])
}
list, err := a.GetRotators()
if err != nil {
applog.Printf("satellite: cannot read the rotator list to migrate the satellite rotator: %v", err)
return
}
list = append(list, dev)
if err := a.SaveRotators(list); err != nil {
applog.Printf("satellite: cannot save the migrated satellite rotator: %v", err)
return
}
if err := a.settings.Set(a.ctx, keySatRotID, dev.ID); err != nil {
applog.Printf("satellite: migrated the rotator but could not select it: %v", err)
return
}
// Clear the old keys so this cannot run twice.
for _, k := range []string{keySatRotType, keySatRotTransport, keySatRotHost, keySatRotPort,
keySatRotCOM, keySatRotBaud, keySatRotPstPort, keySatRotMaxAz} {
_ = a.settings.Set(a.ctx, k, "")
}
applog.Printf("satellite: the %s rotator configured on the satellite page is now %q in Settings ▸ Rotator", legacy, dev.Name)
}