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 ¶
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.
const DriverName = "rtltcp"
DriverName is the sdr.Driver name registered with the pool.
Variables ¶
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.
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.