HARDT - The Ham Radio DSP Toolkit
Classes | Public Member Functions | Static Public Member Functions | List of all members
HRtl2832Reader< T > Class Template Reference

#include <hrtl2832reader.h>

Inheritance diagram for HRtl2832Reader< T >:
Inheritance graph
[legend]
Collaboration diagram for HRtl2832Reader< T >:
Collaboration graph
[legend]

Public Member Functions

 HRtl2832Reader (int device, H_SAMPLE_RATE rate, HRtl2832::MODE mode, int gain, int32_t frequency, int blocksize, bool offset=0, int correction=0, HProbe< T > *probe=nullptr)
 
 ~HRtl2832Reader ()
 
int Read (T *dest, size_t blocksize)
 
bool Command (HCommand *command)
 
bool EnableBiasTee (int gpio=0)
 
bool DisableBiasTee (int gpio=0)
 
bool SetCenterFrequency (uint32_t frequency)
 
uint32_t GetCenterFrequency ()
 
bool SetGain (int gain)
 
int GetGain ()
 
- Public Member Functions inherited from HReader< T >
virtual ~HReader ()=default
 
HReader< T > * Reader ()
 
- Public Member Functions inherited from HObject
 HObject ()
 

Static Public Member Functions

static void callback (unsigned char *buffer, uint32_t length, void *context)
 

Detailed Description

template<class T>
class HRtl2832Reader< T >

Read samples from an RTL-2832 device

Constructor & Destructor Documentation

◆ HRtl2832Reader()

template<class T >
HRtl2832Reader< T >::HRtl2832Reader ( int  device,
H_SAMPLE_RATE  rate,
HRtl2832::MODE  mode,
int  gain,
int32_t  frequency,
int  blocksize,
bool  offset = 0,
int  correction = 0,
HProbe< T > *  probe = nullptr 
)

Construct a new HRtl2832Reader

Parameters
deviceThe device id of the selected RTL-2832 device (usually 0-indexed)
rateThe samplerate to set on the RTL-2832 device
modeThe reader mode (IQ, I, Q, REAL). I or Q enables direct sampling.
gainThe device gain (0 to use automatic)
frequencyInitial center- or if frequency
blocksizeNumber of samples to read from the device in a single read operation If mode is set to 'IQ', then the returned amount of samples will be 'blocksize/2' since you will get multiplexed IQ samples. The buffer must however still be of length 'blocksize' due to the multiplexing
offsetSet to true to use tuner offset mode (only E4000 tuners)
correctionFrequency correction in ppm
probeProbe

◆ ~HRtl2832Reader()

template<class T >
HRtl2832Reader< T >::~HRtl2832Reader

Default destructor

Member Function Documentation

◆ callback()

template<class T >
void HRtl2832Reader< T >::callback ( unsigned char *  buffer,
uint32_t  length,
void *  context 
)
static

Callback method, should only be called by librtl

Parameters
bufferBuffer containing samples (actually a pointer to the area in the internal buffer where the newest samples has been stored.)
lengthNumber of samples in the buffer
contextPointer to the context object provided at construction

◆ Command()

template<class T >
bool HRtl2832Reader< T >::Command ( HCommand command)
inlinevirtual

Execute and/or pass on a command

Implements HReader< T >.

◆ DisableBiasTee()

template<class T >
bool HRtl2832Reader< T >::DisableBiasTee ( int  gpio = 0)

Disable the 5 volt bias-tee output voltage on the antenna connector

Parameters
gpioGpio pin. Use 0 (zero) to use default gpio pin

◆ EnableBiasTee()

template<class T >
bool HRtl2832Reader< T >::EnableBiasTee ( int  gpio = 0)

Enable the 5 volt bias-tee output voltage on the antenna connector Warning: Enabling bias tee voltage if you have a DC shorted antenna connected will damage your rtl-sdr dongle (over time)

Parameters
gpioGpio pin. Use 0 (zero) to use default gpio pin

◆ GetCenterFrequency()

template<class T >
uint32_t HRtl2832Reader< T >::GetCenterFrequency

Get current centerfrequency

Returns
Current center frequency (in Hz)

◆ GetGain()

template<class T >
int HRtl2832Reader< T >::GetGain

Get current gain. 0 (zero) means 'automatic'

Returns
Gain value

◆ Read()

template<class T >
int HRtl2832Reader< T >::Read ( T *  dest,
size_t  blocksize 
)
virtual

Read a block of samples from the soundcard

Parameters
destDestination buffer
blocksizeNumber of samples to read

Implements HReader< T >.

◆ SetCenterFrequency()

template<class T >
bool HRtl2832Reader< T >::SetCenterFrequency ( uint32_t  frequency)

Set center frequency

Parameters
frequencyThe frequency to tune to
Returns
true if successfull, otherwise false

◆ SetGain()

template<class T >
bool HRtl2832Reader< T >::SetGain ( int  gain)

Set gain. Setting gain to 0 (zero) enables automatic gain

Parameters
gainGain value
Returns
True if successfull, otherwise false

The documentation for this class was generated from the following files: