rtl

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2023 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package rtl provides bindings to the rtl-sdr library.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFailed           = errors.New("rtl: operation failed")
	ErrNoDevices        = errors.New("rtl: no devices")
	ErrNoMatchingDevice = errors.New("rtl: no matching device")
)

Possible errors.

Functions

func DeviceCount

func DeviceCount() int

DeviceCount returns the number of rtl-sdr devices found.

func DeviceName

func DeviceName(index int) string

DeviceName returns the name of a device by index

func DeviceUSBStrings

func DeviceUSBStrings(index int) (manufacturer, productName, serialNumber string, err error)

DeviceUSBStrings returns the USB device strings.

func IndexBySerial

func IndexBySerial(serial string) (int, error)

IndexBySerial returns device index by USB serial string descriptor.

Types

type AsyncCallback

type AsyncCallback func(buf []byte) bool

AsyncCallback returns true to stop the async loop

type Device

type Device struct {
	// contains filtered or unexported fields
}

func Open

func Open(index int) (*Device, error)

Open opens an rtl-sdr device by index.

func (*Device) CenterFreq

func (dev *Device) CenterFreq() (uint, error)

CenterFreq returns the actual frequency the device is tuned to in Hz.

func (*Device) Close

func (dev *Device) Close() error

Close closes the device.

func (*Device) GetDirectSampling

func (dev *Device) GetDirectSampling() (DirectSampling, error)

GetDirectSampling returns the state of the direct sampling mode.

func (*Device) GetOffsetTuning

func (dev *Device) GetOffsetTuning() (bool, error)

GetOffsetTuning returns the state of the offset tuning mode

func (*Device) Read

func (dev *Device) Read(buf []byte) (int, error)

Read performs a synchronous read from the device.

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

func (dev *Device) ResetBuffer() error

ResetBuffer resets internal buffers.

func (*Device) SampleRate

func (dev *Device) SampleRate() (int, error)

SampleRate returns the actual sample rate the device is configured to

func (*Device) SetAGCMode

func (dev *Device) SetAGCMode(enabled bool) error

SetAGCMode enables or disables the internal digital AGC of the RTL2832.

func (*Device) SetBiasTee

func (dev *Device) SetBiasTee(enabled bool) error

SetBiasTee enables or disables the bias tee on GPIO PIN 0.

func (*Device) SetCenterFreq

func (dev *Device) SetCenterFreq(freqHz uint) error

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

func (dev *Device) SetOffsetTuning(enabled bool) error

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

func (dev *Device) SetSampleRate(rate uint) error

SetSampleRate selects the baseband filters according to the requested sample rate

func (*Device) SetTunerGain

func (dev *Device) SetTunerGain(gain int) error

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

func (dev *Device) SetTunerGainMode(manual bool) error

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

func (dev *Device) SetTunerIfGain(stage, gain int) error

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

func (dev *Device) SetXtalFreq(rtlFreq, tunerFreq uint) error

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

func (dev *Device) TunerGain() (int, error)

TunerGain returns the actual gain the device is configured to in tength of a dB (115 means 11.5 dB)

func (*Device) TunerGains

func (dev *Device) TunerGains() ([]int, error)

TunerGains returns a list of gains supported by the tuner.

func (*Device) TunerType

func (dev *Device) TunerType() TunerType

TunerType returns the type of the tuner device.

func (*Device) XtalFreq

func (dev *Device) XtalFreq() (uint, uint, error)

XtalFreq returns the crystal oscillator frequencies used for the RTL2832 and the tuner IC.

Usually both ICs use the same clock.

Returns frequency value used to clock the RTL2832 in Hz and frequency value used to clock the tuner IC in Hz.

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

func (TunerType) String

func (tt TunerType) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL