libsdr
0.1.0
A simple SDR library
|
Implements a uint_8
I/Q source for RTL2832 based TV dongles.
More...
#include <rtlsource.hh>
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... | |
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.
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.
frequency | Specifies the tuner frequency. |
sample_rate | Specifies the sample rate in Hz. |
device_idx | Specifies the device to be used. The numDevices and deviceName static method can be used to select the desired device index. |
|
virtual |
Destructor.
|
staticprotected |
Callback to process received data.
|
staticprotected |
Parallel routine to receive some data from the device.
|
inline |
Returns true if AGC is enabled.
|
static |
Returns the name of the specified device.
void RTLSource::enableAGC | ( | bool | enable | ) |
Enable/Disable AGC.
|
inline |
Returns the frequency correction in parts per million (ppm).
|
inline |
Returns the tuner frequency.
|
inline |
Returns the tuner gain.
|
inline |
Retunrs a vector of supported gain factors.
|
static |
Returns the number of compatible devices found.
|
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.
|
protected |
If true, the AGC is enabled.
|
protected |
The buffer size.
|
protected |
The RTL2832 device object.
|
protected |
The current tuner frequency.
|
protected |
A vector of gain factors supported by the device.
|
protected |
The current sample rate.
|
protected |
The thread object.