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) 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
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) 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.