hz.tools/sdr: go bindings for software defined radios

Paul Tagliamonte 2023-02-22 project

This… is the big one. This library represents the majority of the shared types and bindings, and is likely the most useful place to look at when learning about the IO boundary between a program and an SDR.

The git repo can be found at github.com/hztools/go-sdr, and is importable as hz.tools/sdr.

This library is designed to look (and in some cases, mirror) the Go io idioms so that this library feels as idiomatic as it can, so that Go builtins interact with IQ in a way that’s possible to reason about, and to avoid reinventing the wheel by designing new API surface. While some of the API looks (and is even called) the same thing as a similar function in io, the implementation is usually a lot more naive, and may have unexpected sharp edges such as concurrency issues or performance problems.

The following IQ types are implemented using the sdr.Samples interface. The hz.tools/sdr package contains helpers for conversion between types, and some basic manipulation of IQ streams.

IQ Formathz.tools NameUnderlying Go Type
Interleaved uint8 (rtl-sdr)sdr.SamplesU8[][2]uint8
Interleaved int8 (hackrf, uhd)sdr.SamplesI8[][2]int8
Interleaved int16 (pluto, uhd)sdr.SamplesI16[][2]int16
Interleaved float32 (airspy, uhd)sdr.SamplesC64[]complex64

The following SDRs have implemented drivers in-tree.

SDRFormatRX/TXState
rtlu8RXGood
HackRFi8RX/TXGood
PlutoSDRi16RX/TXGood
rtl kerberosu8RXOld
uhdi16/c64/i8RX/TXGood
airspyhfc64RXExp

The following major packages and subpackages exist at the time of writing:

ImportWhat is it?
hz.tools/sdrCore IQ types, supporting types and implementations that interact with the byte boundary
hz.tools/sdr/rtlsdr.Receiver implementation using librtlsdr.
hz.tools/sdr/rtl/kerberosHelpers to enable coherent RX using the Kerberos SDR.
hz.tools/sdr/rtl/e4kHelpers to interact with the E4000 RTL-SDR dongle.
hz.tools/sdr/fftInterfaces for performing an FFT, which are implemented by other packages.
hz.tools/sdr/rtltcpsdr.Receiver implementation for rtl_tcp servers.
hz.tools/sdr/plutosdr.Transceiver implementation for the PlutoSDR using libiio.
hz.tools/sdr/uhdsdr.Transceiver implementation for UHD radios, specifically the B210 and B200mini
hz.tools/sdr/hackrfsdr.Transceiver implementation for the HackRF using libhackrf.
hz.tools/sdr/mockMock SDR for testing purposes.
hz.tools/sdr/airspyhfsdr.Receiver implementation for the AirspyHF+ Discovery with libairspyhf.
hz.tools/sdr/internal/simdSIMD helpers for IQ operations, written in Go ASM. This isn’t the best to learn from, and it contains pure go implemtnations alongside.
hz.tools/sdr/streamCommon Reader/Writer helpers that operate on IQ streams.