rtltcp

package
v0.7.0 Latest Latest
Warning

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

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

Documentation

Overview

Package rtltcp implements an sdr.Driver that talks to a remote rtl_tcp server. rtl_tcp ships with librtlsdr and exposes a single RTL-SDR dongle over a TCP socket so a host with USB access can share its radio with hosts on the network. SDR++, Gqrx, OpenWebRX, and SDRangel all consume the same protocol — adding it here lets GopherTrunk demodulate trunked systems from an SDR plugged into a remote Raspberry Pi / NUC / VM host.

Protocol summary (well-known, unencrypted, single-channel):

  • Client opens a TCP connection.
  • Server sends a 12-byte header: 4-byte magic "RTL0", 4 bytes tuner-type (big-endian uint32), 4 bytes tuner gain-count (big-endian uint32).
  • Server then streams unsigned 8-bit IQ samples (interleaved I, Q, I, Q, ...). Each sample maps to complex64 via (b - 127.5) / 127.5, matching the local USB rtlsdr driver.
  • Client sends commands as 5-byte packets: 1-byte opcode + 4-byte big-endian uint32 parameter. Setters send a command and immediately return; the server applies the change to its local dongle.

The driver supports one remote per Spec; multiple Specs in one config (each pointing at a different rtl_tcp host) become separate pool entries that the engine roles via the usual control/voice hinting.

Limitations:

  • rtl_tcp is single-tuner. A single endpoint can host one client.
  • rtl_tcp is plaintext. Use it on trusted networks only or over an SSH/wireguard tunnel.
  • Bias-tee + advanced rtlsdr-only knobs (direct sampling, offset tuning, IF gain) are wired through the command channel but not exposed on sdr.Device for now; SetBiasTee operates if the remote runs librtlsdr >= 0.7.

Index

Constants

View Source
const DefaultConnectTimeout = 3 * time.Second

DefaultConnectTimeout caps the TCP dial used in Open and Enumerate. rtl_tcp servers typically live on the same LAN; if the dial blocks past this bound, the operator probably has the wrong host:port configured and a fast failure is more useful than a hang.

View Source
const DriverName = "rtltcp"

DriverName is the sdr.Driver name registered with the pool.

Variables

View Source
var Magic = [4]byte{'R', 'T', 'L', '0'}

Magic is the four-byte "RTL0" tag that opens the server-sent header.

Functions

This section is empty.

Types

type Driver

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

Driver implements sdr.Driver. Construct it from config (see the daemon's wiring) and register with sdr.Register before Pool.Open.

func New

func New(specs []Spec, log *slog.Logger) *Driver

New builds a Driver over the given endpoints.

func (*Driver) Enumerate

func (d *Driver) Enumerate() ([]sdr.Info, error)

Enumerate returns one Info per configured endpoint. The driver does NOT probe each server at enumeration time — a remote that's temporarily down would otherwise vanish from the pool until the next restart. Open is the place errors surface.

func (*Driver) Name

func (d *Driver) Name() string

Name implements sdr.Driver.

func (*Driver) Open

func (d *Driver) Open(idx int) (sdr.Device, error)

Open dials the rtl_tcp server at spec[idx] and returns a Device ready for setters and StreamIQ. The 12-byte header is consumed here; subsequent reads from the connection yield IQ bytes.

type Spec

type Spec struct {
	// Addr is the host:port pair the rtl_tcp server is listening on,
	// e.g. "192.168.1.50:1234". Required.
	Addr string
	// Serial is the virtual device serial the pool reports. Empty
	// generates one from Addr so multi-endpoint configs stay unique.
	Serial string
	// Role hints the pool's role assignment: "control" | "voice" |
	// "auto". Honoured by the pool's hint matcher.
	Role string
	// ConnectTimeout overrides DefaultConnectTimeout when non-zero.
	ConnectTimeout time.Duration
}

Spec names one rtl_tcp endpoint to expose as a virtual tuner.

Jump to

Keyboard shortcuts

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