rigctld

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package rigctld implements a subset of Hamlib's rigctld TCP wire protocol so external amateur-radio tooling (Cloudlog, N1MM, GridTracker, PSTRotator, satellite trackers, logging programs) can read and set the frequency of one of GopherTrunk's SDRs over the network.

rigctld is a text-line protocol — each line is one command, the server replies with one or more text lines terminated by an "RPRT <errno>\n" report code line ("RPRT 0" on success). Many clients use both the short single-character form (e.g. "F 851012500") and the long form ("set_freq 851012500"); both are accepted here.

The implementation targets the ~10 commands real clients actually send. Anything else returns RPRT -1 (Hamlib's "command not supported" code), matching how real rigctld handles capability limits on minimal backends. The goal is interop with logging programs and frequency trackers — not full Hamlib coverage.

GopherTrunk's "rig" is one SDR in the pool, identified by serial. The controller abstraction (Controller interface) lets the daemon wire whichever SDR makes sense (the control SDR, by default); the server itself stays free of sdr.Pool details so it can be unit- tested with a fake Controller.

Index

Constants

View Source
const DefaultListenAddr = "127.0.0.1:4532"

DefaultListenAddr is the address the server binds when callers don't override it. Matches the Hamlib rigctld default port.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller interface {
	Serial() string
	Freq() (uint32, error)
	SetFreq(hz uint32) error
}

Controller is the subset of the daemon a rigctld server needs. Implementations hide whichever sdr.Device or iqtap.Broker the daemon decides to expose. Freq is in Hz; SetFreq returns an error when the device rejects the value or no rig is wired.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is one TCP listener that accepts rigctld clients. A daemon spawns one Server per logical rig; today GopherTrunk wires exactly one (the control SDR's frequency).

func New

func New(addr string, ctrl Controller, log *slog.Logger) (*Server, error)

New constructs a Server. addr defaults to DefaultListenAddr when empty. ctrl must be non-nil — the server doesn't run without something to control.

func (*Server) BoundAddr

func (s *Server) BoundAddr() string

BoundAddr reports the listener's bound address. Empty before Run has bound or after Close. Useful when the caller configured a ":0" port and needs the kernel-assigned value.

func (*Server) Close

func (s *Server) Close() error

Close stops accepting and closes the listener. Existing connections drain naturally on their next read.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run binds the listener and serves until ctx cancels or Close fires. Returns the underlying listener error (typically net.ErrClosed on clean shutdown, which is converted to nil).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL