Documentation ¶
Overview ¶
Package rtl provides bindings to the rtl-sdr library.
Index ¶
- Variables
- func DeviceCount() int
- func DeviceName(index int) string
- func DeviceUSBStrings(index int) (manufacturer, productName, serialNumber string, err error)
- func IndexBySerial(serial string) (int, error)
- type AsyncCallback
- type Device
- func (dev *Device) CenterFreq() (uint, error)
- func (dev *Device) Close() error
- func (dev *Device) GetDirectSampling() (DirectSampling, error)
- func (dev *Device) GetOffsetTuning() (bool, error)
- func (dev *Device) Read(buf []byte) (int, error)
- func (dev *Device) ReadAsync(nBuffers, bufferSize int, cb AsyncCallback) error
- func (dev *Device) ReadAsyncUsingSync(nBuffers, bufferSize int, cb AsyncCallback) error
- func (dev *Device) ResetBuffer() error
- func (dev *Device) SampleRate() (int, error)
- func (dev *Device) SetAGCMode(enabled bool) error
- func (dev *Device) SetBiasTee(enabled bool) error
- func (dev *Device) SetCenterFreq(freqHz uint) error
- func (dev *Device) SetDirectSampling(ds DirectSampling) error
- func (dev *Device) SetOffsetTuning(enabled bool) error
- func (dev *Device) SetSampleRate(rate uint) error
- func (dev *Device) SetTunerGain(gain int) error
- func (dev *Device) SetTunerGainMode(manual bool) error
- func (dev *Device) SetTunerIfGain(stage, gain int) error
- func (dev *Device) SetXtalFreq(rtlFreq, tunerFreq uint) error
- func (dev *Device) TunerGain() (int, error)
- func (dev *Device) TunerGains() ([]int, error)
- func (dev *Device) TunerType() TunerType
- func (dev *Device) XtalFreq() (uint, uint, error)
- type DirectSampling
- type LibUSBError
- type TunerType
Constants ¶
This section is empty.
Variables ¶
var ( ErrFailed = errors.New("rtl: operation failed") ErrNoDevices = errors.New("rtl: no devices") ErrNoMatchingDevice = errors.New("rtl: no matching device") )
Possible errors.
Functions ¶
func DeviceName ¶
DeviceName returns the name of a device by index
func DeviceUSBStrings ¶
DeviceUSBStrings returns the USB device strings.
func IndexBySerial ¶
IndexBySerial returns device index by USB serial string descriptor.
Types ¶
type AsyncCallback ¶
AsyncCallback returns true to stop the async loop
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
func (*Device) CenterFreq ¶
CenterFreq returns the actual frequency the device is tuned to in Hz.
func (*Device) GetDirectSampling ¶
func (dev *Device) GetDirectSampling() (DirectSampling, error)
GetDirectSampling returns the state of the direct sampling mode.
func (*Device) GetOffsetTuning ¶
GetOffsetTuning returns the state of the offset tuning mode
func (*Device) ReadAsync ¶
func (dev *Device) ReadAsync(nBuffers, bufferSize int, cb AsyncCallback) error
ReadAsyncUsingSync starts an asynchronous background read. The provided callback is called for all buffers read. This is similar to ReadAsyncUsingSync but this version relies on the built-in asynchronous reading in the librtlsdr library.
func (*Device) ReadAsyncUsingSync ¶
func (dev *Device) ReadAsyncUsingSync(nBuffers, bufferSize int, cb AsyncCallback) error
ReadAsyncUsingSync starts an asynchronous background read. The provided callback is called for all buffers read. This is similar to ReadAsync but this version starts a goroutine that uses the synchronous read of the librtlsdr library.
func (*Device) ResetBuffer ¶
ResetBuffer resets internal buffers.
func (*Device) SampleRate ¶
SampleRate returns the actual sample rate the device is configured to
func (*Device) SetAGCMode ¶
SetAGCMode enables or disables the internal digital AGC of the RTL2832.
func (*Device) SetBiasTee ¶
SetBiasTee enables or disables the bias tee on GPIO PIN 0.
func (*Device) SetCenterFreq ¶
SetCenterFreq tunes to to the provided center frequency in hz.
func (*Device) SetDirectSampling ¶
func (dev *Device) SetDirectSampling(ds DirectSampling) error
SetDirectSampling enables or disables the direct sampling mode. When enabled, the IF mode of the RTL2832 is activated, and rtlsdr_set_center_freq() will control the IF-frequency of the DDC, which can be used to tune from 0 to 28.8 MHz (xtal frequency of the RTL2832).
func (*Device) SetOffsetTuning ¶
SetOffsetTuning enables or disables offset tuning for zero-IF tuners, which allows to avoid problems caused by the DC offset of the ADCs and 1/f noise.
func (*Device) SetSampleRate ¶
SetSampleRate selects the baseband filters according to the requested sample rate
func (*Device) SetTunerGain ¶
SetTunerGain sets the gain for the device. Manual gain mode must be enabled for this to work. Value is in tenths of dB and varies by tuner. For the E4000 tuner: -10, 15, 40, 65, 90, 115, 140, 165, 190, 215, 240, 290, 340, 420, 430, 450, 470, 490 Gain values are in tenths of dB, e.g. 115 means 11.5 dB. Should use TunerGains() to get the list of supported gains.
func (*Device) SetTunerGainMode ¶
SetTunerGainMode sets the gain mode (automatic/manual) for the device. Manual gain mode must be enabled for the gain setter function to work.
func (*Device) SetTunerIfGain ¶
SetTunerIfGain sets the intermediate frequency gain for the device. - stage: intermediate frequency gain stage number (1 to 6 for E4000) - gain: tenths of a dB, -30 means -3.0 dB
func (*Device) SetXtalFreq ¶
SetXtalFreq sets the crystal oscillator frequencies used for the RTL2832 and the tuner IC.
Usually both ICs use the same clock. Changing the clock may make sense if you are applying an external clock to the tuner or to compensate the frequency (and samplerate) error caused by the original (cheap) crystal.
NOTE: Call this function only if you fully understand the implications.
rtl_freq is the frequency value used to clock the RTL2832 in Hz tuner_freq is the frequency value used to clock the tuner IC in Hz
func (*Device) TunerGain ¶
TunerGain returns the actual gain the device is configured to in tength of a dB (115 means 11.5 dB)
func (*Device) TunerGains ¶
TunerGains returns a list of gains supported by the tuner.
type DirectSampling ¶
type DirectSampling int
const ( DirectSamplingOff DirectSampling = 0 DirectSamplingIADC DirectSampling = 1 DirectSamplingQADC DirectSampling = 2 )
func (DirectSampling) String ¶
func (ds DirectSampling) String() string
type LibUSBError ¶
type LibUSBError int
LibUSBError is an error from libusb
func (LibUSBError) Error ¶
func (e LibUSBError) Error() string
type TunerType ¶
type TunerType int
const ( TunerTypeUnknown TunerType = C.RTLSDR_TUNER_UNKNOWN TunerTypeE4000 TunerType = C.RTLSDR_TUNER_E4000 TunerTypeFC0012 TunerType = C.RTLSDR_TUNER_FC0012 TunerTypeFC0013 TunerType = C.RTLSDR_TUNER_FC0013 TunerTypeFC2580 TunerType = C.RTLSDR_TUNER_FC2580 TunerTypeR820T TunerType = C.RTLSDR_TUNER_R820T TunerTypeR828D TunerType = C.RTLSDR_TUNER_R828D )
Known tuner types