libsdr  0.1.0
A simple SDR library
Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
sdr::RTLSource Class Reference

Implements a uint_8 I/Q source for RTL2832 based TV dongles. More...

#include <rtlsource.hh>

Inheritance diagram for sdr::RTLSource:
sdr::Source

Public Member Functions

 RTLSource (double frequency, double sample_rate=1e6, size_t device_idx=0)
 Constructor. More...
 
virtual ~RTLSource ()
 Destructor. More...
 
double frequency () const
 Returns the tuner frequency. More...
 
void setFrequency (double frequency)
 (Re-) Sets the tuner frequency. More...
 
double freqCorrection () const
 Returns the frequency correction in parts per million (ppm). More...
 
void setFreqCorrection (double ppm)
 (Re-) Sets the frequency correction in ppm. More...
 
double sampleRate () const
 Returns the sample rate. More...
 
void setSampleRate (double sample_rate)
 (Re-) sets the sample rate. More...
 
bool agcEnabled () const
 Returns true if AGC is enabled. More...
 
void enableAGC (bool enable)
 Enable/Disable AGC. More...
 
double gain () const
 Returns the tuner gain. More...
 
void setGain (double gain)
 (Re-) Sets the tuner gain. More...
 
const std::vector< double > & gainFactors () const
 Retunrs a vector of supported gain factors. More...
 
void start ()
 Starts the reception. More...
 
void stop ()
 Stops the reception. More...
 
- Public Member Functions inherited from sdr::Source
 Source ()
 Constructor. More...
 
virtual ~Source ()
 Destructor. More...
 
virtual void send (const RawBuffer &buffer, bool allow_overwrite=false)
 Sends the given buffer to all connected sinks. More...
 
void connect (SinkBase *sink, bool direct=false)
 Connect this source to a sink. More...
 
void disconnect (SinkBase *sink)
 Disconnect a sink again. More...
 
virtual void setConfig (const Config &config)
 Stores the configuration and propergates it if the configuration has been changed. More...
 
virtual Config::Type type () const
 Returns the configured source type or Config::Type_UNDEFINED otherwise. More...
 
template<class T >
void addEOS (T *instance, void(T::*function)())
 Adds a callback to the end-of-stream signal of the source. More...
 

Static Public Member Functions

static size_t numDevices ()
 Returns the number of compatible devices found. More...
 
static std::string deviceName (size_t idx)
 Returns the name of the specified device. More...
 

Static Protected Member Functions

static void * __rtl_sdr_parallel_main (void *ctx)
 Parallel routine to receive some data from the device. More...
 
static void __rtl_sdr_callback (unsigned char *buffer, uint32_t len, void *ctx)
 Callback to process received data. More...
 

Protected Attributes

double _frequency
 The current tuner frequency. More...
 
double _sample_rate
 The current sample rate. More...
 
bool _agc_enabled
 If true, the AGC is enabled. More...
 
std::vector< double > _gains
 A vector of gain factors supported by the device. More...
 
size_t _buffer_size
 The buffer size. More...
 
rtlsdr_dev_t * _device
 The RTL2832 device object. More...
 
pthread_t _thread
 The thread object. More...
 
- Protected Attributes inherited from sdr::Source
Config _config
 Holds the source configuration, this can be updated by calling setConfig. More...
 
std::map< SinkBase *, bool > _sinks
 The connected sinks. More...
 
std::list< DelegateInterface * > _eos
 The connected EOS singal handlers. More...
 

Additional Inherited Members

- Protected Member Functions inherited from sdr::Source
void signalEOS ()
 Signals the EOS. More...
 
void propagateConfig (const Config &config)
 Propagates the given configuration to all connected sinks. More...
 

Detailed Description

Implements a uint_8 I/Q source for RTL2832 based TV dongles.

This source runs in its own thread, hence the user does not need to trigger the reception of the next data chunk explicitly. The reception is started by calling the start method and stopped by calling the stop method.

Constructor & Destructor Documentation

RTLSource::RTLSource ( double  frequency,
double  sample_rate = 1e6,
size_t  device_idx = 0 
)

Constructor.

By default the gain is set to be automatically determined, this can be changed with the enableAGC and setGain methods.

Parameters
frequencySpecifies the tuner frequency.
sample_rateSpecifies the sample rate in Hz.
device_idxSpecifies the device to be used. The numDevices and deviceName static method can be used to select the desired device index.
RTLSource::~RTLSource ( )
virtual

Destructor.

Member Function Documentation

void RTLSource::__rtl_sdr_callback ( unsigned char *  buffer,
uint32_t  len,
void *  ctx 
)
staticprotected

Callback to process received data.

void * RTLSource::__rtl_sdr_parallel_main ( void *  ctx)
staticprotected

Parallel routine to receive some data from the device.

bool sdr::RTLSource::agcEnabled ( ) const
inline

Returns true if AGC is enabled.

std::string RTLSource::deviceName ( size_t  idx)
static

Returns the name of the specified device.

void RTLSource::enableAGC ( bool  enable)

Enable/Disable AGC.

double sdr::RTLSource::freqCorrection ( ) const
inline

Returns the frequency correction in parts per million (ppm).

double sdr::RTLSource::frequency ( ) const
inline

Returns the tuner frequency.

double sdr::RTLSource::gain ( ) const
inline

Returns the tuner gain.

const std::vector<double>& sdr::RTLSource::gainFactors ( ) const
inline

Retunrs a vector of supported gain factors.

size_t RTLSource::numDevices ( )
static

Returns the number of compatible devices found.

double sdr::RTLSource::sampleRate ( ) const
inlinevirtual

Returns the sample rate.

Reimplemented from sdr::Source.

void RTLSource::setFreqCorrection ( double  ppm)

(Re-) Sets the frequency correction in ppm.

void RTLSource::setFrequency ( double  frequency)

(Re-) Sets the tuner frequency.

void RTLSource::setGain ( double  gain)

(Re-) Sets the tuner gain.

Has no effect in AGC mode.

void RTLSource::setSampleRate ( double  sample_rate)

(Re-) sets the sample rate.

This method also triggers the reconfiguration of all connected sinks.

void RTLSource::start ( )

Starts the reception.

void RTLSource::stop ( )

Stops the reception.

Member Data Documentation

bool sdr::RTLSource::_agc_enabled
protected

If true, the AGC is enabled.

size_t sdr::RTLSource::_buffer_size
protected

The buffer size.

rtlsdr_dev_t* sdr::RTLSource::_device
protected

The RTL2832 device object.

double sdr::RTLSource::_frequency
protected

The current tuner frequency.

std::vector<double> sdr::RTLSource::_gains
protected

A vector of gain factors supported by the device.

double sdr::RTLSource::_sample_rate
protected

The current sample rate.

pthread_t sdr::RTLSource::_thread
protected

The thread object.


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