Documentation
¶
Index ¶
- Constants
- Variables
- func GetDeviceCount() (count int)
- func GetDeviceName(index int) (name string)
- func GetDeviceUsbStrings(index int) (manufact, product, serial string, err error)
- func GetIndexBySerial(serial string) (index int, err error)
- func GetStringDescriptors(data []uint8) (manufact, product, serial string, err error)
- func SetStringDescriptors(info HwInfo, data []uint8) (err error)
- type Context
- func (dev *Context) CancelAsync() error
- func (dev *Context) Close() (err error)
- func (dev *Context) GetCenterFreq() (freqHz int)
- func (dev *Context) GetDirectSampling() (mode SamplingMode, err error)
- func (dev *Context) GetFreqCorrection() (ppm int)
- func (dev *Context) GetHwInfo() (info HwInfo, err error)
- func (dev *Context) GetOffsetTuning() (enabled bool, err error)
- func (dev *Context) GetSampleRate() (rateHz int)
- func (dev *Context) GetTunerGain() (gainTenthsDb int)
- func (dev *Context) GetTunerGains() (gainsTenthsDb []int, err error)
- func (dev *Context) GetTunerType() (tunerType string)
- func (dev *Context) GetUsbStrings() (manufact, product, serial string, err error)
- func (dev *Context) GetXtalFreq() (rtlFreqHz, tunerFreqHz int, err error)
- func (dev *Context) ReadAsync(f ReadAsyncCbT, _ *UserCtx, bufNum, bufLen int) error
- func (dev *Context) ReadEeprom(data []uint8, offset uint8, leng uint16) (err error)
- func (dev *Context) ReadSync(buf []uint8, leng int) (nRead int, err error)
- func (dev *Context) ResetBuffer() (err error)
- func (dev *Context) SetAgcMode(AGCMode bool) (err error)
- func (dev *Context) SetBiasTee(enable bool) error
- func (dev *Context) SetCenterFreq(freqHz int) (err error)
- func (dev *Context) SetDirectSampling(mode SamplingMode) (err error)
- func (dev *Context) SetFreqCorrection(ppm int) (err error)
- func (dev *Context) SetHwInfo(info HwInfo) (err error)
- func (dev *Context) SetOffsetTuning(enable bool) (err error)
- func (dev *Context) SetSampleRate(rateHz int) (err error)
- func (dev *Context) SetTestMode(testMode bool) (err error)
- func (dev *Context) SetTunerBw(bwHz int) (err error)
- func (dev *Context) SetTunerGain(gainTenthsDb int) (err error)
- func (dev *Context) SetTunerGainMode(manualMode bool) (err error)
- func (dev *Context) SetTunerIfGain(stage, gainTenthsDb int) (err error)
- func (dev *Context) SetXtalFreq(rtlFreqHz, tunerFreqHz int) (err error)
- func (dev *Context) WriteEeprom(data []uint8, offset uint8, leng uint16) (err error)
- type HwInfo
- type ReadAsyncCbT
- type SamplingMode
- type UserCtx
Constants ¶
const ( // EepromSize is the char size of the EEPROM EepromSize = 256 // MaxStrSize = (max string length - 2 (header bytes)) \ 2, // where each info char is followed by a null char. MaxStrSize = 35 // StrOffsetStart is the string descriptor offset start StrOffsetStart = 0x09 )
const ( DefaultGAIN = "auto" DefaultFc = 80e6 DefaultRs = 1.024e6 DefaultReadSize = 1024 CrystalFreq = 28800000 DefaultSampleRate = 2048000 DefaultAsyncBufNumber = 32 DefaultBufLength = (16 * 16384) MinimalBufLength = 512 MaximalBufLength = (256 * 16384) LIBUSB_ERROR_OTHER = -99 )
These constants are used to set default parameter values.
Variables ¶
var PackageVersion = "v2.10.0"
PackageVersion is the current version
var SamplingModes = map[SamplingMode]string{ SamplingNone: "Disabled", SamplingIADC: "I-ADC Enabled", SamplingQADC: "Q-ADC Enabled", SamplingUnknown: "Unknown", }
SamplingModes is a map of available sampling modes.
Functions ¶
func GetDeviceCount ¶
func GetDeviceCount() (count int)
GetDeviceCount returns the number of devices detected.
func GetDeviceName ¶
GetDeviceName returns the name of the device by index.
func GetDeviceUsbStrings ¶
GetDeviceUsbStrings returns the information of a device by index.
func GetIndexBySerial ¶
GetIndexBySerial returns a device index by serial id.
func GetStringDescriptors ¶
GetStringDescriptors gets the manufacturer, product, and serial strings from the hardware's eeprom.
func SetStringDescriptors ¶
SetStringDescriptors sets the manufacturer, product, and serial strings on the hardware's eeprom.
Types ¶
type Context ¶
type Context C.rtlsdr_dev_t
Context is the opened device's context.
func (*Context) CancelAsync ¶
CancelAsync cancels all pending asynchronous operations.
func (*Context) GetCenterFreq ¶
GetCenterFreq returns the tuned frequency or zero on error.
func (*Context) GetDirectSampling ¶
func (dev *Context) GetDirectSampling() (mode SamplingMode, err error)
GetDirectSampling returns the state of direct sampling mode.
func (*Context) GetFreqCorrection ¶
GetFreqCorrection returns the frequency correction value.
func (*Context) GetOffsetTuning ¶
GetOffsetTuning returns the offset tuning mode.
func (*Context) GetSampleRate ¶
GetSampleRate returns the sample rate.
func (*Context) GetTunerGain ¶
GetTunerGain returns the tuner gain.
Gain values are in tenths of dB, e.g. 115 means 11.5 dB.
func (*Context) GetTunerGains ¶
GetTunerGains returns a list of supported tuner gains. Values are in tenths of dB, e.g. 115 means 11.5 dB.
func (*Context) GetTunerType ¶
GetTunerType returns the tuner type.
func (*Context) GetUsbStrings ¶
GetUsbStrings returns the device information. Note, strings may be empty.
func (*Context) GetXtalFreq ¶
GetXtalFreq returns the crystal oscillator frequencies. Typically both ICs use the same clock.
func (*Context) ReadAsync ¶
func (dev *Context) ReadAsync(f ReadAsyncCbT, _ *UserCtx, bufNum, bufLen int) error
ReadAsync reads samples asynchronously. Note, this function will block until canceled using CancelAsync. ReadAsyncCbT is a package global variable and therefore unsafe for use with multiple dongles.
Note, please use ReadAsync2 as this method will be deprecated in the future.
Optional bufNum buffer count, bufNum * bufLen = overall buffer size, set to 0 for default buffer count (32). Optional bufLen buffer length, must be multiple of 512, set to 0 for default buffer length (16 * 32 * 512).
func (*Context) ReadEeprom ¶
ReadEeprom returns data read from the EEPROM.
func (*Context) ReadSync ¶
ReadSync performs a synchronous read of samples and returns the number of samples read.
func (*Context) ResetBuffer ¶
ResetBuffer resets the streaming buffer.
func (*Context) SetAgcMode ¶
SetAgcMode sets the AGC mode.
func (*Context) SetBiasTee ¶
SetBiasTee enables or disables bias tee.
func (*Context) SetCenterFreq ¶
SetCenterFreq sets the center frequency.
func (*Context) SetDirectSampling ¶
func (dev *Context) SetDirectSampling(mode SamplingMode) (err error)
SetDirectSampling sets the direct sampling mode.
When enabled, the IF mode of the device is activated, and SetCenterFreq() will control the IF-frequency of the DDC, which can be used to tune from 0 to 28.8 MHz (xtal frequency of the device).
func (*Context) SetFreqCorrection ¶
SetFreqCorrection sets the frequency correction.
func (*Context) SetOffsetTuning ¶
SetOffsetTuning sets the offset tuning mode for zero-IF tuners, which avoids problems caused by the DC offset of the ADCs and 1/f noise.
func (*Context) SetSampleRate ¶
SetSampleRate sets the sample rate.
When applicable, the baseband filters are also selected based on the requested sample rate.
func (*Context) SetTestMode ¶
SetTestMode sets device to test mode.
Test mode returns 8 bit counters instead of samples. Note, the counter is generated inside the device.
func (*Context) SetTunerBw ¶
SetTunerBw sets the device bandwidth.
func (*Context) SetTunerGain ¶
SetTunerGain sets the tuner gain. Note, manual gain mode must be enabled for this to work. Valid gain values may be queried using GetTunerGains.
Gain values are in tenths of dB, e.g. 115 means 11.5 dB.
func (*Context) SetTunerGainMode ¶
SetTunerGainMode sets the gain mode (automatic/manual). Manual gain mode must be enabled for the gain setter function to work.
func (*Context) SetTunerIfGain ¶
SetTunerIfGain sets the intermediate frequency gain.
Intermediate frequency gain stage number 1 to 6. Gain values are in tenths of dB, e.g. -30 means -3.0 dB.
func (*Context) SetXtalFreq ¶
SetXtalFreq sets the crystal oscillator frequencies.
Typically 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 sample rate) error caused by the original (cheap) crystal.
Note, call this function only if you fully understand the implications.
type HwInfo ¶
type HwInfo struct { VendorID uint16 ProductID uint16 Manufact string Product string Serial string HaveSerial bool EnableIR bool RemoteWakeup bool }
HwInfo holds dongle specific information.
type ReadAsyncCbT ¶
type ReadAsyncCbT func([]byte)
ReadAsyncCbT defines a user callback function type.
type SamplingMode ¶
type SamplingMode int
SamplingMode is the sampling mode type.
const ( SamplingNone SamplingMode = iota SamplingIADC SamplingQADC SamplingUnknown )
Sampling modes.
type UserCtx ¶
type UserCtx interface{}
UserCtx defines the second parameter of the ReadAsync method and is meant to be type asserted in the user's callback function when used. It allows the user to pass in virtually any object and is similar to C's void*.
Examples would be a channel, a device context, a buffer, etc..
A channel type assertion: c, ok := (*userctx).(chan bool)
A user context assertion: device := (*userctx).(*rtl.Context)