Documentation
¶
Overview ¶
Package hackrf is a pure-Go driver for the Great Scott Gadgets HackRF One software-defined radio, implementing the sdr.Driver and sdr.Device interfaces.
It speaks the libhackrf USB vendor protocol directly over the shared pure-Go USB transport at internal/sdr/rtlsdr/usb — the same transport that backs the RTL-SDR driver — so no CGO and no libhackrf are pulled into the build. Real-hardware validation against an attached HackRF One is a documented follow-up; the in-package tests exercise the wire protocol against a usb.MockTransport.
Sample format: HackRF delivers signed 8-bit interleaved IQ (I,Q,I,Q,…) on bulk endpoint 0x81 once SET_TRANSCEIVER_MODE has been flipped to receive. Each pair is converted to a complex64 sample with components in roughly [-1, 1].
Index ¶
- type Device
- func (d *Device) Close() error
- func (d *Device) FreqRange() (minHz, maxHz uint32)
- func (d *Device) Info() sdr.Info
- func (d *Device) SetBiasTee(enable bool) error
- func (d *Device) SetCenterFreq(hz uint32) error
- func (d *Device) SetGain(tenthDB int) error
- func (d *Device) SetPPM(int) error
- func (d *Device) SetSampleRate(hz uint32) error
- func (d *Device) StreamIQ(ctx context.Context) (<-chan []complex64, error)
- type Driver
- type VIDPID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device is one opened HackRF.
func (*Device) FreqRange ¶ added in v0.5.9
FreqRange reports the HackRF One's tuning span (sdr.FreqRanger). The device documents 1 MHz .. 6 GHz, but the sdr API carries frequency as uint32 Hz (ceiling ~4.294 GHz), so the upper bound is clamped to that ceiling — a whole-device sweep covers 1 MHz .. 4.294 GHz.
func (*Device) SetBiasTee ¶
SetBiasTee toggles the +3.3 V antenna-port bias for external LNAs.
func (*Device) SetCenterFreq ¶
SetCenterFreq programs the synthesizer to the requested frequency, in Hz. libhackrf splits the value into MHz + Hz-remainder octets.
func (*Device) SetGain ¶
SetGain accepts a single tenth-dB target and distributes it across the HackRF's three gain stages (RF amp on/off, LNA 0–40 dB in 8 dB steps, VGA 0–62 dB in 2 dB steps). A negative value selects a hardware-friendly preset (amp off, LNA 16 dB, VGA 20 dB) — the HackRF has no true AGC, so "auto" maps to a sane fixed split.
func (*Device) SetPPM ¶
SetPPM is a no-op for HackRF — the Si5351C reference clock is internally trimmed and the protocol carries no PPM correction.
func (*Device) SetSampleRate ¶
SetSampleRate programs the baseband sampler. libhackrf encodes the rate as a numerator/divider pair; this driver always uses a divider of 1 so the host sees exactly the requested rate.
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver implements sdr.Driver for HackRF.
func New ¶
func New(enum usb.Enumerator) *Driver
New returns a Driver that enumerates through the supplied USB backend. Pass nil to use the platform default enumerator.
type VIDPID ¶ added in v0.5.0
VIDPID is one USB identity the HackRF driver matches, exposed so `gophertrunk sdr doctor` can include HackRF in its driver-binding diagnostics. Mirrors the shape of purego.VIDPID so the doctor command can aggregate every pure-Go USB SDR into one report.
func KnownVIDPIDs ¶ added in v0.5.0
func KnownVIDPIDs() []VIDPID
KnownVIDPIDs returns the HackRF USB VID/PID variants this driver matches, in the same order Enumerate scans them. Used by `sdr doctor` to report which Windows function driver (WinUSB vs other) is bound to a connected HackRF — the in-box default is usually WinUSB via the device's WCID descriptor, but a wrong binding shows up here.